/* tenere-mobile.css — Optimisation mobile de l'interface Grominet (jarvis-OS)
 * Injecté dans toutes les pages servies par jarvis_bridge. Aucune media query
 * n'existait dans les CSS d'origine (design desktop) — on ajoute l'adaptation.
 */

/* ═══════════════════════════════════════════════════════════════════════
   HOME (home.html) — écran d'accueil
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* Contrôles + pill : plus compacte, en haut à gauche sans déborder */
  .home-controls {
    top: 12px;
    left: 12px;
    transform: none !important;
  }
  .hc-pill {
    gap: 2px;
    padding: 5px;
    border-radius: 14px;
  }
  .hc-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .hc-btn svg {
    width: 17px;
    height: 17px;
  }

  /* Signature (brand + horloge) : centrée en bas, taille réduite */
  .home-signature {
    position: fixed;
    right: 0;
    bottom: 56px;
    left: 0;
    text-align: center;
    z-index: 30;
    transform: none !important;
    pointer-events: none;
  }
  .home-signature .brand {
    font-size: 11px;
    letter-spacing: 0.24em;
  }
  .home-signature .clock-row {
    justify-content: center;
  }
  .home-signature .clock {
    font-size: clamp(36px, 12vw, 52px);
  }
  .home-signature .date {
    font-size: 9px;
    letter-spacing: 0.16em;
  }

  /* Canal passif : masqué sur petit écran (économise l'espace) */
  .home-channel {
    display: none !important;
  }

  /* Widgets (chat / musique) : pleine largeur, en bas */
  .hc-widget {
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
  }
  .hc-widget .hcw-messages,
  .hc-widget .hcw-body,
  .hc-widget .hcw-weather-grid {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }
  .hc-widget--chat {
    left: 10px;
    right: 10px;
    bottom: 76px;
    width: auto;
    max-width: none;
    max-height: 60vh;
  }
  .hc-widget--music {
    left: 10px;
    right: 10px;
    bottom: 76px;
    width: auto;
    max-width: none;
  }
  .hc-widget--reminders {
    left: 10px;
    right: 10px;
    bottom: 76px;
    width: auto;
    max-width: none;
    max-height: 60vh;
  }

  /* Input du widget chat */
  .hcw-input-row {
    flex-wrap: nowrap;
  }
  .hcw-input {
    min-width: 0;
    flex: 1;
  }

  /* Orbe : bien centré, taille adaptée — le wrapper devient un carré
     de la taille de l'orbe (le JS dimensionne le buffer WebGL d'après le
     parent ; un parent plein écran 390×844 forçait un buffer déformé et
     l'orbe était coupé). */
  .home-orb-wrap {
    position: fixed;
    inset: auto !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: min(78vw, 78vh);
    height: min(78vw, 78vh);
    max-width: 340px;
    max-height: 340px;
    display: grid;
    place-items: center;
  }
  #orb-canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }

  /* Rooms nav : chapitre masqué, mission control compact, pages centrées */
  .rooms-chapter {
    display: none !important;
  }
  body[data-mode="home"] #j-rooms-mc,
  body[data-mode="home"] .rooms-mc {
    inset: auto auto 8px 50% !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    height: auto !important;
    padding: 12px 24px 12px 16px !important;
    font-size: 12px !important;
    letter-spacing: 0.12em !important;
    z-index: 60 !important;
  }
  body[data-mode="home"] #j-rooms-mc .mc-dot,
  body[data-mode="home"] .rooms-mc .mc-dot {
    width: 8px !important;
    height: 8px !important;
  }
  .rooms-mc {
    inset: auto !important;
    top: 14px !important;
    right: 14px !important;
    bottom: auto !important;
    left: auto !important;
    padding: 12px 24px 12px 16px !important;
    font-size: 12px !important;
    letter-spacing: 0.12em !important;
    z-index: 60 !important;
  }
  .rooms-mc .mc-kbd {
    display: none !important;
  }
  .rooms-pages {
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 20px);
    gap: 3px;
    padding: 5px;
    border-radius: 999px;
  }
  .rooms-pages button {
    padding: 6px 10px;
    font-size: 11px;
    gap: 5px;
  }
  .rooms-pages button .num {
    display: none;
  }

  /* Caméra overlay : pleine largeur, adaptée à l'écran */
  .cam-overlay {
    left: 10px;
    right: 10px;
    bottom: 72px;
    width: auto !important;
    max-width: none !important;
    border-radius: 16px;
  }
  .cam-overlay .cam-topbar {
    padding: 8px 10px;
  }
  .cam-overlay .cam-flip {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .cam-overlay .cam-feed {
    aspect-ratio: auto;
    height: min(38vh, 340px);
    max-height: 340px;
  }

  /* Wake : boutons/texte adaptés */
  .home-shell {
    padding: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGES (dashboard / capabilities / settings / command / …)
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {

  /* En-tête de page : paddings réduits */
  #page-root .page-head {
    padding: 20px 16px 16px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  #page-root .page-head::after {
    left: 16px;
    width: 40%;
  }
  #page-root .page-head h1 {
    font-size: clamp(22px, 6vw, 30px);
  }
  #page-root .page-head-meta {
    white-space: normal;
    font-size: 10px;
  }

  /* Corps de page : paddings réduits */
  #page-root .page-body {
    padding: 18px 14px 0;
    gap: 32px;
  }

  /* Navigation rooms (pill bas) — surcharge la sidebar verticale
     cocoon-wide-display (même spécificité que _shared.css) */
  body[data-subpages="cocoon-wide-display"] .rooms-pages {
    position: fixed !important;
    top: auto !important;
    bottom: 12px !important;
    left: 10px !important;
    right: 10px !important;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    display: block !important;
    white-space: nowrap !important;
    flex-direction: row !important;
    gap: 0 !important;
    padding: 5px !important;
    border-radius: 999px !important;
    background: rgba(13, 17, 23, 0.78) !important;
    border: 0.5px solid var(--line-2) !important;
    backdrop-filter: blur(14px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(14px) saturate(140%) !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    scrollbar-width: none !important;
    touch-action: pan-x !important;
    overscroll-behavior-x: contain !important;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages::-webkit-scrollbar {
    display: none;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages::before {
    display: none !important;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages button {
    border-radius: 999px !important;
    padding: 6px 10px !important;
    font-size: 11px !important;
    gap: 5px !important;
    font-family: var(--mono) !important;
    justify-content: center !important;
    display: inline-flex !important;
    white-space: nowrap !important;
    margin-right: 3px !important;
    vertical-align: middle !important;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages button .num {
    display: none !important;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages button[data-active="true"]::before {
    display: none !important;
  }
  body[data-subpages="cocoon-wide-display"] .page-body,
  body[data-subpages="cocoon-wide-display"] .page-head {
    padding-left: 14px !important;
  }
  body[data-subpages="cocoon-wide-display"] .page-head::after {
    left: 16px !important;
    width: 40% !important;
  }
  .rooms-pages {
    left: 10px !important;
    right: 10px !important;
    transform: none !important;
    max-width: none !important;
    bottom: 12px;
    display: block;
    white-space: nowrap;
    gap: 0;
    padding: 5px;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
  }
  .rooms-pages button {
    padding: 6px 10px;
    font-size: 11px;
    gap: 5px;
    display: inline-flex;
    white-space: nowrap;
    margin-right: 3px;
    vertical-align: middle;
  }
  .rooms-pages button .num {
    display: none;
  }
  .rooms-chapter {
    top: 14px;
    left: 14px;
    font-size: 9px;
    letter-spacing: 0.16em;
  }
  body[data-mode="home"] #j-rooms-mc {
    inset: auto auto 8px 50% !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    height: auto !important;
    padding: 12px 24px 12px 16px !important;
    font-size: 12px !important;
    letter-spacing: 0.12em !important;
    z-index: 60 !important;
  }
  .rooms-mc {
    inset: auto !important;
    top: 14px !important;
    right: 14px !important;
    bottom: auto !important;
    left: auto !important;
    padding: 12px 24px 12px 16px !important;
    font-size: 12px !important;
    letter-spacing: 0.12em !important;
    z-index: 60 !important;
  }
  .rooms-mc .mc-kbd {
    display: none !important;
  }

  /* KPI strip : 2 colonnes */
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi-card {
    padding: 14px 14px 12px;
  }
  .kpi-val {
    font-size: 28px;
  }

  /* Mission rows : compactes */
  .mission-row {
    grid-template-columns: 52px 1fr;
    gap: 10px;
    padding: 12px 0;
  }
  .mission-row .m-prog-bar,
  .mission-row .m-actions {
    grid-column: 1 / -1;
  }
  .m-actions {
    justify-content: flex-start;
  }

  /* Row-stripe : compact */
  .row-stripe {
    padding: 12px 12px 12px 16px;
    gap: 10px;
    margin: 4px 0;
  }
  .row-stripe-title {
    font-size: 12.5px;
    white-space: normal;
  }
  .row-stripe-right {
    align-items: flex-end;
  }

  /* Session rows (Fils) */
  .session-row {
    grid-template-columns: 42px 1fr auto;
    gap: 8px;
    padding: 10px 0;
  }
  .sess-date {
    display: none;
  }

  /* Memory rows */
  .memory-row {
    grid-template-columns: 1fr 70px auto;
    gap: 8px;
  }

  /* Settings rows */
  .setting-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px 0;
  }
  .setting-row .input-mono {
    width: 100% !important;
  }

  /* Grids de cartes : 1 colonne */
  .skills-grid,
  .routine-grid,
  .theme-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  /* Panels latéraux : pleine largeur */
  #detail-panel {
    width: 100% !important;
    right: -110% !important;
  }
  #detail-panel.open {
    right: 0 !important;
  }
  #dash-detail-panel {
    width: 100% !important;
    right: -110% !important;
  }
  #dash-detail-panel.open {
    right: 0 !important;
  }
  .panel-body,
  .mp-header {
    padding: 16px;
  }

  /* Boutons : zones tactiles confortables */
  .m-btn {
    padding: 8px 12px;
  }
  .add-bar {
    padding: 12px 14px;
  }

  /* Tables / listes horizontales : scroll si besoin */
  .cn-row {
    grid-template-columns: 8px 1fr auto;
    gap: 10px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   MISSION CONTROL (⌘T) — panneau compact ancré en bas à gauche (mobile)
   ───────────────────────────────────────────────────────────────────────
   Sur petit écran le voile plein écran devient une carte réduite posée
   en bas à gauche, au-dessus de la pill de navigation rooms.
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .mission-overlay.is-hidden {
    display: none !important;
  }
  .mission-overlay {
    inset: auto auto 62px 12px !important;
    width: min(320px, calc(100vw - 24px));
    display: block !important;
    padding: 10px;
    border: 0.5px solid var(--line-2);
    border-radius: 14px;
    background: rgba(6, 8, 13, 0.95);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
  }
  .mc-header {
    position: static !important;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 2px 8px;
  }
  .mc-header-hint {
    display: none;
  }
  .mc-close {
    position: static !important;
    transform: none !important;
  }
  .mission-grid {
    grid-template-columns: 1fr !important;
    width: 100% !important;
    gap: 6px;
    max-height: 42vh;
    overflow-y: auto;
  }
  .mission-card {
    padding: 9px 11px !important;
    min-height: 0 !important;
    border-radius: 10px !important;
    gap: 0 10px;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
  }
  .mission-card::before {
    border-radius: 10px;
  }
  .mc-card-eyebrow {
    font-size: 8px;
    gap: 5px;
  }
  .mc-card-num {
    font-size: 15px;
  }
  .mc-card-title {
    font-size: 15px;
    letter-spacing: -0.02em;
  }
  .mc-card-sub,
  .mc-card-pages {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Tablettes (641–1024px) — ajustements intermédiaires
   ═══════════════════════════════════════════════════════════════════════ */
 @media (min-width: 641px) and (max-width: 1024px) {
  #page-root .page-head {
    padding: 28px 24px 20px;
  }
  #page-root .page-body {
    padding: 24px 22px 0;
  }
  .rooms-pages {
    left: 12px !important;
    right: 12px !important;
    transform: none !important;
    max-width: none !important;
    justify-content: flex-start;
    display: block;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
  }
  /* Orbe tablette : carré centré adapté (buffer WebGL carré) */
  .home-orb-wrap {
    position: fixed;
    inset: auto !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: min(72vw, 72vh);
    height: min(72vw, 72vh);
    max-width: 560px;
    max-height: 560px;
    display: grid;
    place-items: center;
  }
  #orb-canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }
  body[data-mode="home"] #j-rooms-mc {
    inset: auto auto 10px 50% !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    height: auto !important;
    padding: 12px 24px 12px 16px !important;
    font-size: 12px !important;
    letter-spacing: 0.12em !important;
    z-index: 60 !important;
  }
  body[data-mode="home"] #j-rooms-mc .mc-dot,
  .rooms-mc .mc-dot {
    width: 8px !important;
    height: 8px !important;
  }
  .rooms-mc {
    inset: auto !important;
    top: 16px !important;
    right: 16px !important;
    bottom: auto !important;
    left: auto !important;
    padding: 12px 24px 12px 16px !important;
    font-size: 12px !important;
    letter-spacing: 0.12em !important;
    z-index: 60 !important;
  }
  .rooms-mc .mc-kbd {
    display: none !important;
  }

  /* Sur les pages (workspace/capacités/config) : la sidebar verticale
     cocoon-wide-display devient une pill horizontale en bas */
  body[data-subpages="cocoon-wide-display"] .rooms-pages {
    position: fixed !important;
    top: auto !important;
    bottom: 14px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
    display: inline-flex !important;
    flex-direction: row !important;
    gap: 3px !important;
    padding: 5px !important;
    border-radius: 999px !important;
    background: rgba(13, 17, 23, 0.78) !important;
    border: 0.5px solid var(--line-2) !important;
    backdrop-filter: blur(14px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(14px) saturate(140%) !important;
    overflow: hidden !important;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages::before {
    display: none !important;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages button {
    border-radius: 999px !important;
    padding: 6px 10px !important;
    font-size: 11px !important;
    gap: 5px !important;
    font-family: var(--mono) !important;
    justify-content: center !important;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages button .num {
    display: none !important;
  }
  body[data-subpages="cocoon-wide-display"] .rooms-pages button[data-active="true"]::before {
    display: none !important;
  }
  body[data-subpages="cocoon-wide-display"] .page-body,
  body[data-subpages="cocoon-wide-display"] .page-head {
    padding-left: 22px !important;
  }
  body[data-subpages="cocoon-wide-display"] .page-head::after {
    left: 24px !important;
    width: 40% !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   RÈGLE GLOBALE (toutes largeurs) — sur les pages avec tab bar basse
   (workspace / capacités / configuration), le bouton Mission Control est
   forcé en HAUT à droite pour ne jamais recouvrir la pill de navigation.
   ═══════════════════════════════════════════════════════════════════════ */

/* Quand une page est ouverte dans l'iframe (#page-frame), le bouton
   Mission Control de la HOME (appendChild sur body, z-index 60) reste
   visible AU-DESSUS de l'iframe → doublure avec celui de la page. On le
   masque tant que l'iframe est active. */
body:has(.page-frame.is-active) > #j-rooms-mc,
body:has(.page-frame.is-active) > .rooms-mc {
  display: none !important;
}

body[data-subpages="cocoon-wide-display"] .rooms-mc,
body[data-mode="workspace"] .rooms-mc,
body[data-mode="capacites"] .rooms-mc,
body[data-mode="config"] .rooms-mc {
  inset: auto !important;
  top: 16px !important;
  right: 16px !important;
  bottom: auto !important;
  left: auto !important;
  width: auto !important;
  height: auto !important;
  padding: 12px 24px 12px 16px !important;
  font-size: 12px !important;
  letter-spacing: 0.12em !important;
  z-index: 60 !important;
}
body[data-subpages="cocoon-wide-display"] .rooms-mc .mc-kbd,
body[data-mode="workspace"] .rooms-mc .mc-kbd,
body[data-mode="capacites"] .rooms-mc .mc-kbd,
body[data-mode="config"] .rooms-mc .mc-kbd {
  display: none !important;
}
body[data-subpages="cocoon-wide-display"] .rooms-mc .mc-dot,
body[data-mode="workspace"] .rooms-mc .mc-dot,
body[data-mode="capacites"] .rooms-mc .mc-dot,
body[data-mode="config"] .rooms-mc .mc-dot {
  width: 8px !important;
  height: 8px !important;
}


/* ═══════════════════════════════════════════════════════════════════════
   WIDGET MÉTÉO — affichage des températures par ville (Open-Meteo)
   ═══════════════════════════════════════════════════════════════════════ */
.hc-widget--weather {
  width: 280px;
}
.hcw-weather-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 0 2px;
}
.hcw-weather-city {
  background: rgba(220, 232, 255, 0.04);
  border: 0.5px solid var(--line-2, rgba(220,232,255,0.09));
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.hcw-weather-temp {
  font-family: var(--serif, serif);
  font-size: 22px;
  color: var(--fg-0, #fff);
  line-height: 1;
}
.hcw-weather-name {
  font-family: var(--mono, monospace);
  font-size: 10px;
  color: var(--fg-2, #9ab);
  margin-top: 6px;
  letter-spacing: 0.06em;
}
.hcw-weather-desc {
  font-size: 10px;
  color: var(--fg-3, #778);
  margin-top: 2px;
}
.hcw-empty {
  grid-column: 1 / -1;
  color: var(--fg-3, #778);
  font-size: 12px;
  text-align: center;
  padding: 8px 0;
}
@media (max-width: 640px) {
  .hc-widget--weather {
    width: auto;
  }
}
