/*
 * PAYSAGE-DOM-01 — Le jeu à l'horizontale (décision du propriétaire, 01/12/2026).
 * 1. « Tourne ton téléphone » : écran d'invitation quand un téléphone est tenu verticalement (voir paysage.js).
 * 2. Interface commune d'un téléphone en paysage (hauteur 360 à 540 px) : barre de ressources fine, navigation en rail
 *    de fanions à gauche, feuilles qui glissent de la droite. La largeur est abondante, la hauteur est rare :
 *    rien d'horizontal ne s'empile plus au-dessus du décor.
 * Le PC et la tablette ne sont pas concernés (hauteur supérieure à 540 px).
 */

/* ───────────── 1. Tourne ton téléphone ───────────── */
.tourne { display: none; }
html.tourne-actif, html.tourne-actif body { height: 100%; overflow: hidden; }
html.tourne-actif .tourne {
  position: fixed; inset: 0; z-index: 2000; display: grid; grid-template-rows: 1fr auto auto 1fr auto; justify-items: center; align-content: center; gap: 0;
  padding: max(20px, env(safe-area-inset-top, 0px)) 24px max(16px, env(safe-area-inset-bottom, 0px)); text-align: center; overflow: hidden;
  color: var(--fi-texte, #f4ecd8); font-family: var(--fi-corps, system-ui, sans-serif);
  background:
    radial-gradient(120% 56% at 50% 108%, #f0a868 0%, rgba(214, 120, 84, .62) 22%, rgba(44, 56, 112, 0) 62%),
    radial-gradient(90% 40% at 50% 0%, #1d2a66 0%, rgba(13, 19, 48, 0) 70%),
    linear-gradient(180deg, #0a1030 0%, #131c46 58%, #2c3870 100%);
}
/* Étoiles discrètes : le ciel de l'académie, avant le lever du jour. */
.tourne::before {
  content: ""; position: absolute; inset: 0 0 45% 0; pointer-events: none; opacity: .8;
  background-image: radial-gradient(1.4px 1.4px at 12% 22%, #fff8e0 50%, transparent 52%), radial-gradient(1.2px 1.2px at 78% 14%, #fff8e0 50%, transparent 52%), radial-gradient(1.6px 1.6px at 62% 38%, #fbe9a8 50%, transparent 52%), radial-gradient(1px 1px at 30% 52%, #fff 50%, transparent 52%), radial-gradient(1.3px 1.3px at 90% 46%, #fff8e0 50%, transparent 52%), radial-gradient(1px 1px at 46% 10%, #fff 50%, transparent 52%), radial-gradient(1.2px 1.2px at 20% 70%, #fbe9a8 50%, transparent 52%);
}
.tourne-scene { grid-row: 2; position: relative; width: min(64vw, 250px); aspect-ratio: 1; display: grid; place-items: center; margin-bottom: 4px; }
.tourne-halo { position: absolute; inset: 6%; border-radius: 50%; background: radial-gradient(closest-side, rgba(251, 233, 168, .34), rgba(227, 184, 79, .12) 55%, transparent 72%); }
.tourne-fleche { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--fi-or, #e3b84f); opacity: .9; animation: tourne-fleche 4.2s var(--fi-courbe, ease) infinite; }
.tourne-tel { position: relative; width: 38%; aspect-ratio: 9 / 18.5; transform-origin: 50% 50%; animation: tourne-tel 4.2s cubic-bezier(.6, 0, .2, 1) infinite; filter: drop-shadow(0 12px 16px rgba(0, 0, 0, .55)); }
.tourne-tel svg { display: block; width: 100%; height: 100%; overflow: visible; }
.tourne-jour { animation: tourne-jour 4.2s ease infinite; }
.tourne-nuit { animation: tourne-nuit 4.2s ease infinite; }
@keyframes tourne-tel { 0%, 22% { transform: rotate(0deg); } 46%, 88% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }
@keyframes tourne-fleche { 0%, 14% { opacity: 0; transform: rotate(18deg); } 24% { opacity: .95; } 46% { opacity: .95; transform: rotate(-52deg); } 58%, 100% { opacity: 0; transform: rotate(-52deg); } }
@keyframes tourne-jour { 0%, 40% { opacity: 0; } 54%, 88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes tourne-nuit { 0%, 40% { opacity: 1; } 54%, 88% { opacity: 0; } 100% { opacity: 1; } }
.tourne-titre { grid-row: 3; margin: 14px 0 0; font: 700 clamp(1.7rem, 8.4vw, 2.3rem)/1.1 var(--fi-titre, Georgia, serif); color: var(--fi-or-clair, #fbe9a8); text-shadow: 0 2px 0 #3d2a05, 0 0 22px rgba(240, 191, 85, .4); letter-spacing: .01em; }
.tourne-texte { grid-row: 4; align-self: start; max-width: 30ch; margin: 12px 0 0; font-size: 1.0625rem; line-height: 1.45; color: var(--fi-texte, #f4ecd8); }
.tourne-marque { grid-row: 1; align-self: start; display: inline-flex; align-items: center; gap: 10px; font: 700 .9375rem/1 var(--fi-titre, Georgia, serif); letter-spacing: .08em; color: var(--fi-or-clair, #fbe9a8); }
.tourne-marque img { width: 34px; height: 34px; }
.tourne-rester {
  grid-row: 5; min-height: 44px; padding: 8px 18px; border: 1px solid rgba(223, 227, 242, .35); background: rgba(10, 16, 48, .72); cursor: pointer; border-radius: 22px;
  font: 600 .9375rem/1.2 var(--fi-corps, system-ui, sans-serif); color: #f4ecd8; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(223, 227, 242, .5);
}
.tourne-rester:focus-visible { outline: 3px solid var(--fi-focus, #9fd4ff); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .tourne-tel { animation: none; transform: rotate(-90deg); }
  .tourne-fleche { animation: none; opacity: .9; transform: rotate(-52deg); }
  .tourne-jour { animation: none; opacity: 1; } .tourne-nuit { animation: none; opacity: 0; }
}

/* ───────────── 2. Téléphone en paysage : interface commune ───────────── */
@media (orientation: landscape) and (max-height: 540px) {
  :root {
    --header-height: 46px; --fi-barre-h: 44px; --nav-height: 0px;
    --rail: calc(78px + env(safe-area-inset-left, 0px)); /* noms complets « Académie », « Collection » (propriétaire, 02/12) */
    --bord-droit: max(8px, env(safe-area-inset-right, 0px));
  }
  /* Barre de ressources : une ligne fine ; l'avatar coiffe le rail. */
  :root .fi-barre-rang.header-row { max-width: none; min-height: 45px; gap: 8px; padding: 2px var(--bord-droit) 2px calc(env(safe-area-inset-left, 0px) + 10px); }
  :root .fi-barre.topbar::after { display: none; }
  :root .header-row .fi-avatar, :root .header-row .header-avatar { width: 44px; height: 42px; }
  :root .header-row .fi-avatar-rond { width: 38px; height: 38px; }
  :root .header-row .fi-avatar-rond .character-portrait { --portrait-size: 34px; }
  :root .header-row .fi-ressources { flex: 1; justify-content: flex-start; flex-wrap: nowrap; gap: 6px; }
  :root .res button.fi-res { flex: 0 1 auto; min-height: 36px; max-width: none; padding-right: 10px; }
  :root .res button.fi-res::before { content: ""; position: absolute; inset: -4px 0; } /* cible tactile de 44 px sans épaissir la barre */
  :root .res .lbl { display: none; }
  :root .res .fi-res-val { font-size: .9375rem; }
  :root .header-row .suma-mini { width: 40px; height: 40px; }
  :root .header-row .suma-mini img { width: 40px; height: 40px; }

  /* Navigation : rail de cinq fanions à gauche, sous l'avatar. Le fanion actif s'avance vers le décor. */
  :root .nav.fi-nav.fi-nav--pose {
    position: fixed; inset: calc(var(--header-height) + env(safe-area-inset-top, 0px)) auto 0 0; z-index: 30; width: var(--rail); height: auto;
    display: flex; flex-direction: column; gap: 3px; align-items: stretch;
    padding: 3px 6px max(3px, env(safe-area-inset-bottom, 0px)) env(safe-area-inset-left, 0px);
    background: linear-gradient(90deg, rgba(10, 16, 48, .92) 0%, rgba(10, 16, 48, .78) 62%, rgba(10, 16, 48, 0) 100%);
  }
  :root .nav.fi-nav.fi-nav--pose::before { display: none; }
  :root .nav.fi-nav--pose .fi-onglet { flex: 1 1 0; height: auto; min-height: 44px; margin: 0; transform: none; }
  :root .nav.fi-nav--pose .fi-onglet-plaque { --fronton: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%); justify-content: center; gap: 1px; padding: 0 9px 0 0; }
  :root .nav.fi-nav--pose .fi-onglet-plaque::after { display: none; }
  :root .nav.fi-nav--pose .fi-onglet .fi-ico { width: 24px; height: 24px; }
  :root .nav.fi-nav--pose .fi-onglet .fi-onglet-cadenas { top: calc(50% - 16px); right: 12px; width: 13px; height: 13px; }
  :root .nav.fi-nav--pose .fi-onglet-nom { font-size: .625rem; letter-spacing: 0; white-space: nowrap; overflow: visible; text-overflow: clip; max-width: none; }
  :root .nav.fi-nav--pose .fi-onglet:hover { transform: translateX(2px); }
  :root .nav.fi-nav--pose .fi-onglet:active { transform: translateX(-1px); }
  :root .nav.fi-nav--pose .fi-onglet[aria-current="page"] { transform: translateX(6px); filter: drop-shadow(0 0 8px rgba(246, 201, 106, .7)) drop-shadow(3px 0 3px rgba(0, 0, 0, .5)); }
  :root .nav.fi-nav--pose .fi-onglet[aria-current="page"]::after { display: none; }
  :root .nav.fi-nav--pose .dot, :root .nav.fi-nav--pose .fi-pastille { top: 5px; right: 12px; }
  /* Les écrans encore en page laissent la place du rail ; aucune barre basse à réserver. */
  body:has(.nav) .wrap { padding-left: calc(var(--rail) + 6px); padding-right: var(--bord-droit); padding-bottom: 16px; }
  .nav-initiation + .brand { padding-inline-start: calc(var(--rail) + 6px); }
  .nav-initiation ~ .wrap .actionbar.sticky { margin-inline: 0; }
  :root .ui-fable .wrap, html.ui-fable .wrap { padding-top: 8px; }
  html.acad-plein .wrap, html.lieu-plein .wrap { padding: 0; }
  #toast { bottom: 10px; }
  html.acad-plein #pending-actions, html.lieu-plein #pending-actions { left: calc(var(--rail) + 8px); }

  /* Feuilles de l'académie : en paysage, elles glissent de la droite et laissent le décor visible à gauche. */
  .fe-acad { --acad-gauche: var(--rail); }
  .fe-acad > .guide-heading { left: calc(var(--rail) + 6px); top: calc(var(--acad-haut) + 4px); }
  .fe-acad-hud { left: calc(var(--rail) + 6px); right: auto; bottom: max(8px, env(safe-area-inset-bottom, 0px)); flex-direction: column; }
  .fe-acad:not(:has(.scene3d)) .fe-acad-hud { flex-direction: column; }
  .fe-acad-nom { display: inline; }
  .fe-acad-jeton { min-height: 44px; font-size: .875rem; }
  .fe-feuille-hote { place-items: stretch end; grid-template-rows: minmax(0, 1fr); padding-top: var(--acad-haut); }
  .fe-feuille { width: min(46%, 430px); height: auto; min-height: 0; max-height: none; margin: 6px max(6px, env(safe-area-inset-right, 0px)) 6px 0; animation-name: paysage-glisse; }
  .fe-feuille--grande { width: calc(100% - var(--rail) - 16px - env(safe-area-inset-right, 0px)); height: auto; }
  .fe-feuille .fi-tiroir-poignee { display: none; }
  .fe-feuille--grande .fe-lieu { display: none; }
  .fe-feuille .fi-panneau-titre { min-height: 44px; font-size: 1rem; justify-content: space-between; padding: 2px 6px 2px 12px; }
  .fe-feuille .fi-panneau-corps { padding: 10px 12px 12px; }
  .fe-acad:not(:has(.scene3d)):not(.fe-acad--feuille) .fe-acad-liste { left: calc(var(--rail) + 190px); bottom: 4px; }
  .fe-acad-scene > .scene:not(.scene3d) { padding: calc(var(--acad-haut) + 6px) 12px 96px calc(var(--rail) + 12px); }

  /* Arène (avant sa refonte) : le hall tient dans la hauteur, l'entrée du combat reste visible sans défiler. */
  .ui-fable #app > .wrap:has(> .arena-hall) { padding-top: 6px; padding-bottom: 6px; }
  .arena-hall { min-height: calc(100dvh - var(--header-height) - env(safe-area-inset-top, 0px) - 14px); gap: 4px; }
  .arena-hall-header h2 { font-size: 1.5rem; }
  .arena-hall .arena-entry { min-height: 48px; }

  /* Fenêtres et tiroirs du jeu : jamais plus hauts que l'écran, contenu défilable. */
  .modal .card { max-height: calc(100dvh - 16px); }
  .modal.ui-dialog.tiroir { inset: 0 0 0 auto; width: min(64%, 620px); max-height: none; height: 100dvh; animation-name: paysage-glisse; }
  .modal.ui-dialog.tiroir > .dialog-panel { max-height: 100dvh; height: 100dvh; padding-right: max(8px, env(safe-area-inset-right, 0px)); }
  .tiroir-poignee.fi-tiroir-poignee { display: none; }
  .fi-tiroir:not(.fe-feuille) { max-height: calc(100dvh - 8px); }
}

@media (orientation: landscape) and (max-height: 285px) {
  :root .nav.fi-nav--pose.nav-initiation .fi-onglet { min-height: 0; }
  :root .nav.fi-nav--pose.nav-initiation .fi-onglet-plaque > .fi-ico:not(.fi-onglet-cadenas) { width: 19px; height: 19px; }
}
@keyframes paysage-glisse { from { transform: translateX(100%); } }
@media (orientation: landscape) and (max-height: 540px) and (min-width: 800px) {
  :root .res .lbl { display: inline; font-size: .8125rem; }
}
