/* ==========================================================================
   Téléphones (écran tactile, pointeur principal grossier) — paysage obligatoire.
   Tout est borné par (hover: none) and (pointer: coarse) : la version PC n'est jamais touchée.
   Chargé en dernier : à spécificité égale, ces règles l'emportent sur main/tv/terminal.css.
   ========================================================================== */

/* ---------- Invitation à tourner le téléphone (portrait) ---------- */
#rotate, .hud-aside { display: none; }

@media (hover: none) and (pointer: coarse) and (orientation: portrait) and (max-width: 600px) {
  #rotate {
    position: fixed; inset: 0; z-index: 90;
    display: grid; align-content: center; justify-items: center; gap: 18px;
    padding: 24px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left));
    background: radial-gradient(90% 60% at 50% 30%, rgba(155, 92, 255, .22), transparent 70%), var(--night);
    text-align: center; font-family: var(--f-hud);
  }
  .rotate-phone {
    position: relative; width: 44px; height: 78px;
    border: 5px solid var(--ink); background: #1a1424;
    box-shadow: 4px 4px 0 var(--red), 8px 8px 0 rgba(155, 92, 255, .6);
    animation: rotate-hint 2.6s steps(8, end) infinite;
  }
  .rotate-phone::after {
    content: ""; position: absolute; left: 50%; bottom: 5px; width: 10px; height: 4px; margin-left: -5px;
    background: var(--amber);
  }
  @keyframes rotate-hint {
    0%, 20% { transform: rotate(0); }
    55%, 85% { transform: rotate(-90deg); }
    100% { transform: rotate(0); }
  }
  #rotate h2 { margin: 6px 0 0; font-size: 20px; font-weight: 700; color: #fff; letter-spacing: .03em; }
  #rotate p { margin: 0; max-width: 300px; font-family: var(--f-mono); font-size: 21px; line-height: 1.15; color: var(--ink-dim); }
  #rotate .rotate-fs { font-size: 21px; padding: 10px 16px 11px; }
  #rotate .rotate-fs[hidden] { display: none; }
  #rotate small { max-width: 280px; font-family: var(--f-mono); font-size: 17px; line-height: 1.1; color: var(--ink-dim); opacity: .75; }
}

/* ---------- Tous les téléphones ---------- */
@media (hover: none) and (pointer: coarse) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { overscroll-behavior: none; }
  .pxpanel { backdrop-filter: none; }
  .hud-btn kbd, .marker-label kbd { display: none; }
  .hud-btn { min-height: 34px; }
  .tv-hint { display: none; }
}

/* ---------- Téléphone en paysage (hauteur courte) ---------- */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  /* HUD, mode « barre » (aucune bande latérale libre) : petites boîtes en icônes, en haut, hors des encoches.
     La plaque d'identité disparaît ; CV / Tél / Mail passent en texte seul (groupe .hud-aside, créé par mobile.js). */
  .plate { display: none; }
  .hud-nav { right: max(6px, env(safe-area-inset-right)); top: 4px; gap: 4px; }
  .hud-btn { padding: 4px 6px 5px; min-height: 0; justify-content: center; }
  .hud-btn span { display: none; }
  .hud-btn .px-icon { width: 14px; height: 14px; }
  .hud-nav .hud-cv { display: none; }   /* remplacé par le CV en texte du groupe .hud-aside */
  .hud-aside {
    display: flex; position: absolute; top: 4px; left: max(6px, env(safe-area-inset-left)); gap: 4px;
  }
  .hud-aside .hud-btn { font-size: 15px; }
  body:not([data-scene="salon"]) .hud-aside { left: calc(max(6px, env(safe-area-inset-left)) + 44px); }
  .finds { font-size: 14px; top: calc(100% + 2px); }

  /* Dans la télé / le PC : le compteur s'efface, « retour » reste à gauche */
  body:not([data-scene="salon"]) .finds { display: none; }
  #back { top: 4px; bottom: auto; left: max(6px, env(safe-area-inset-left)); }

  /* Salon : pas de consigne (les marqueurs « La télé » / « Le PC » suffisent), marqueurs plus petits */
  .hint { display: none; }
  .marker-label { font-size: 17px; padding: 4px 8px 5px; }
  .marker-label small { font-size: 14px; }
  .marker.is-hover .marker-label small { max-height: 18px; }

  /* Applis en plein écran : sous la barre du HUD, bords étroits */
  .tvapp.is-fullscreen .tv-inner,
  .termapp.is-fullscreen {
    inset: 38px max(6px, env(safe-area-inset-right)) 6px max(6px, env(safe-area-inset-left));
    border-width: 3px;
  }

  /* ----- Télé ----- */
  .tv-inner { font-size: 18px; }
  .tv-top { gap: 10px; padding: 6px 12px 5px; }
  .tv-brand { padding: 4px 12px 5px; font-size: 13px; }
  .tv-tab { padding: 5px 9px; font-size: 18px; }
  .tv-tab span { display: inline; }
  .tv-tab .px-icon { width: 14px; height: 14px; }
  .tv-right .tv-clock { display: inline; font-size: 20px; }
  .tv-avatar { width: 26px; height: 26px; font-size: 14px; }
  .tv-view { padding: 10px 14px 12px; }
  .kicker { font-size: 11px; }
  .view-title { font-size: 30px; margin-bottom: 8px; }
  .view-title small { font-size: 16px; }
  .row-title { font-size: 23px; margin: 10px 0 4px; }
  .row-title small { font-size: 16px; }
  .btn { font-size: 20px; padding: 6px 14px 7px; min-height: 34px; }

  .hero { grid-template-columns: 1.3fr 1fr; gap: 14px; }
  .hero h1 { font-size: 44px; }
  .hero-role { font-size: 23px; margin: 4px 0 6px; }
  .hero-role span { font-size: 17px; }
  .hero-pitch { font-size: 18px; margin-bottom: 10px; }
  .hero-stats { gap: 6px; }
  .hero-stats li { padding: 6px 9px; }
  .hero-stats b { font-size: 28px; }
  .hero-stats span { font-size: 16px; }

  .tile { width: 158px; height: 90px; }
  .poster { padding: 8px 10px; }
  .poster-mono { font-size: 58px; }
  .poster-title { font-size: 15px; }
  .poster-sub { font-size: 15px; }

  .episodes { gap: 8px; }
  .episode { grid-template-columns: 26px 140px 1fr; gap: 10px; padding: 8px; }
  .ep-num { display: block; font-size: 34px; }
  .episode .poster { height: 80px; }
  .ep-title { font-size: 23px; }
  .ep-meta, .ep-ctx { font-size: 17px; }

  .detail { grid-template-columns: 170px 1fr; gap: 16px; }
  .detail-side .poster { height: 110px; }
  .tags li { font-size: 15px; }
  .detail h2 { font-size: 28px; }
  .detail-meta { font-size: 18px; }
  .detail-ctx { font-size: 17px; }
  .metrics li { min-width: 90px; padding: 5px 8px; }
  .metrics b { font-size: 26px; }
  .metrics span { font-size: 15px; }
  .bullets { gap: 6px; }
  .bullets li { font-size: 18px; }

  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card .poster { height: 76px; }
  .card-body { padding: 9px 11px 11px; }
  .card h3 { font-size: 23px; }
  .card p, .award { font-size: 17px !important; }

  .skills { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 9px; }
  .skill { padding: 9px 11px; }
  .skill h3 { font-size: 21px; margin-bottom: 6px; }
  .chips li { font-size: 16px; }
  .langs li { font-size: 18px; }

  .contact { grid-template-columns: 1fr 1fr; gap: 8px; }
  .contact-item { padding: 9px 12px; }
  .contact-item span { font-size: 15px; }
  .contact-item b { font-size: 22px; }

  /* ----- PC / terminal ----- */
  .termapp { font-size: 17px; }
  .term-bar { padding: 3px 10px; }
  .term-title { font-size: 15px; }
  .term-help { font-size: 16px; padding: 2px 8px; min-height: 28px; }
  .term-body { grid-template-columns: 160px minmax(0, 1fr); }
  .term-tree { padding: 8px 4px 8px 10px; }
  .term-tree button { font-size: 17px; padding: 5px 4px; }
  .term-main { padding: 8px 12px 10px; }
  .t-ls button { font-size: 17px; padding: 4px 6px; }
  .t-ls .t-dir { min-width: 150px; }
  .t-project { padding: 9px 12px; }
  .t-project h3 { font-size: 26px; }
  .t-project > p { font-size: 17px; }
  .t-impact b { font-size: 22px; }
  .t-stack li { font-size: 15px; }
  .t-zoom { font-size: 16px; padding: 3px 8px; }
  .term-input { padding: 3px 10px; }
  .term-input input { font-size: 17px; }
  .term-chips { padding: 3px 10px 6px; }
  .t-chip { font-size: 16px; padding: 3px 10px; }

  /* Schéma en grand : tient dans l'écran, défilement si besoin */
  .dg-modal { padding: 6px max(6px, env(safe-area-inset-right)) 6px max(6px, env(safe-area-inset-left)); }
  .dg-modal-box header { padding: 6px 10px; font-size: 16px; }
  .dg-modal-box header b { font-size: 22px; }
  .dg-close { font-size: 16px; padding: 3px 12px; min-height: 30px; }
  .dg-modal-body .diagram { margin: 0 auto; }
}

/* Écran plus large que l'image : le HUD se range dans les bandes latérales (--band posé par mobile.js, classe
   has-bands si la bande fait au moins 56 px), sans rien recouvrir. Mêmes bandes dans le salon, la télé et le PC. */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  body.has-bands .hud-nav { top: 6px; gap: 4px; flex-direction: column; align-items: flex-end; }
  body.has-bands .hud-btn { justify-content: center; padding: 4px 6px 5px; font-size: 15px; min-height: 0; }
  body.has-bands .hud-btn span { display: none; }
  body.has-bands .hud-btn .px-icon { width: 14px; height: 14px; }
  body.has-bands #back { display: none; }

  /* Colonne de gauche : CV / Tél / Mail en texte seul ; colonne de droite : navigation en icônes seules */
  body.has-bands .hud-nav { right: max(6px, env(safe-area-inset-right)); }
  body.has-bands .hud-aside {
    top: 6px; left: max(6px, env(safe-area-inset-left)); flex-direction: column; align-items: flex-start; gap: 4px;
  }
  body.has-bands[data-scene="salon"] .finds { left: 50%; transform: translateX(-50%); font-size: 15px; }

  /* L'appli reste dans l'image : les bandes latérales sont réservées au HUD.
     (.tvapp elle-même est rétrécie, pour que ses requêtes de conteneur voient la vraie largeur.) */
  body.has-bands .tvapp.is-fullscreen { inset: 0 var(--band); padding: 0; }
  body.has-bands .tvapp.is-fullscreen .tv-inner { inset: 6px 0; }
  body.has-bands .termapp.is-fullscreen { inset: 6px var(--band); }
  body.has-bands .dg-modal { inset: 0 var(--band); }
  /* Terminal : on garde l'arborescence des projets visible tant qu'il reste de la place */
  @container (min-width: 500px) {
    .term-body { grid-template-columns: 152px minmax(0, 1fr); }
    .term-tree { display: block; }
    .term-tree button { font-size: 16px; }
    .term-title { text-align: center; }
  }
  /* Largeur de l'image seule : l'appli est plus étroite, on garde les icônes seules dans la barre de la télé */
  @container (max-width: 700px) {
    .tv-tab span { display: none; }
    .tv-tab { padding: 6px 9px; }
    .tv-tab .px-icon { width: 18px; height: 18px; }
    .tv-right .tv-clock { display: none; }
    .hero h1 { font-size: 38px; }
    .hero-pitch { font-size: 17px; }
    .hero-stats b { font-size: 24px; }
    .hero-stats span { font-size: 15px; }
    .episode { grid-template-columns: 110px 1fr; }
    .ep-num { display: none; }
    .detail { grid-template-columns: 140px 1fr; gap: 12px; }
  }
}

/* Petit paysage (iPhone SE, mini) : largeur serrée */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 520px) and (max-width: 720px) {
  .term-body { grid-template-columns: minmax(0, 1fr); }
  .term-tree { display: none; }
  .tv-tab span { display: none; }
  .tv-tab { padding: 6px 8px; }
  .tv-tab .px-icon { width: 18px; height: 18px; }
  .tv-right .tv-clock { display: none; }
  .episode { grid-template-columns: 110px 1fr; }
  .ep-num { display: none; }
  .detail { grid-template-columns: 130px 1fr; }
  .hero h1 { font-size: 38px; }
}

/* Écrans très bas (barres du navigateur visibles) */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 360px) {
  .tv-view { padding: 8px 12px 10px; }
  .hero h1 { font-size: 36px; }
  .hero-pitch { font-size: 17px; margin-bottom: 8px; }
  .view-title { font-size: 26px; margin-bottom: 6px; }
  .term-chips { display: none; }
}
