/*
  Noctilana : la page est la chambre du jeu, la nuit, éclairée par une veilleuse (DESIGN.md du jeu).
  Fond aubergine, cartes prune, texte ivoire ; l'or de la veilleuse seulement pour ce qu'on touche et
  ce qui titre. Tout en aplats : ni ombre, ni relief, ni bordure décorative. Le seul décor est le ciel
  peint (indigo, prune, rose), avec la lune, les étoiles et le troupeau, dessinés en SVG (defs.svg).
*/
:root {
  --night-top: #2b1736;
  --night-bottom: #140b1c;
  --velvet: #40264d;
  --velvet-deep: #261733;
  --brass: #dbab5c;
  --brass-light: #f7d999;
  --ivory: #f5e8cf;
  --ivory-soft: #d6c4ad;
  --ivory-faint: rgba(214, 196, 173, 0.74);
  --ink: #33120f;
  --wool: #fad180;
  --peach: #faa88a;
  --moonlight: #f0e09e;
  --lavender: #d1a8f2;
  --sky-top: #171a45;
  --sky-mid: #332154;
  --sky-horizon: #5c2b45;
  --line: rgba(245, 232, 207, 0.08);
  --well: rgba(0, 0, 0, 0.22);
  --display: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --round: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 5vw, 64px);
  --column: 1080px;
  color-scheme: dark;
}
/* Japonais et coréen : un mincho et une gothique arrondie du système, dans le même esprit. */
:lang(ja) {
  --display: ui-serif, "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --round: "Hiragino Maru Gothic ProN", "Hiragino Sans", ui-rounded, system-ui, sans-serif;
}
:lang(ko) {
  --display: ui-serif, "AppleMyungjo", "Nanum Myeongjo", "Noto Serif KR", serif;
  --round: ui-rounded, "Apple SD Gothic Neo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--night-bottom); }
body {
  margin: 0;
  min-height: 100vh;
  /* La nuit de la chambre, avec la lueur pêche de la veilleuse en haut à gauche. */
  background:
    radial-gradient(ellipse 70% 40% at 0% 0%, rgba(250, 168, 138, 0.13), transparent 70%),
    linear-gradient(180deg, var(--night-top), var(--night-bottom) 70%) no-repeat,
    var(--night-bottom);
  color: var(--ivory);
  font: 500 17px/1.6 var(--round);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 0.22em; }
:focus-visible { outline: 3px solid var(--brass-light); outline-offset: 3px; border-radius: 8px; }
img, svg { max-width: 100%; }

/* Un seul système de titre : le label, petites capitales sérif en or, sans fond. */
h2 {
  margin: 0 0 1.1rem;
  font: 700 1rem/1.3 var(--display);
  font-variant: small-caps;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
  color: var(--brass);
}
/* Le japonais et le coréen n'ont pas de petites capitales : le label garde sa taille et son or. */
html:lang(ja) :is(h2, .toc > p, .verb, .kind), html:lang(ko) :is(h2, .toc > p, .verb, .kind) { font-variant: normal; font-variant-caps: normal; letter-spacing: 0.04em; }
:lang(ja) h2, :lang(ko) h2 { font-size: 1rem; }
h1, .title, .doc-head h1 { font-family: var(--display); font-weight: 600; color: var(--ivory); text-wrap: balance; }
h3 { margin: 0 0 0.35rem; font: 700 1.12rem/1.3 var(--round); color: var(--ivory); }

/* En-tête : le nom du jeu en sérif ivoire, la navigation comme la barre d'onglets du jeu. */
.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 24px;
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) 12px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font: 600 1.35rem/1 var(--display);
  color: var(--ivory);
  text-decoration: none;
}
.logo::before {
  content: "";
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: url("/icons/noctilana.png") center / cover no-repeat;
}
.top nav { display: flex; align-items: center; gap: 0 22px; flex-wrap: wrap; font-weight: 600; font-size: 0.98rem; color: var(--ivory-soft); }
.top nav > a { position: relative; padding: 12px 0; text-decoration: none; }
.top nav > a:hover, .top nav > a[aria-current] { color: var(--brass-light); }
/* L'onglet choisi : un trait or de 18 × 3 sous le libellé. */
.top nav > a[aria-current]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 18px;
  height: 3px;
  margin-left: -9px;
  border-radius: 2px;
  background: var(--brass);
}
@media (max-width: 560px) {
  .top { gap: 0 16px; }
  .top nav { gap: 0 16px; font-size: 0.94rem; }
}

/* Menu des langues : un <details> dont la liste flotte par-dessus la page, sans rien décaler. */
.lang-menu { position: relative; }
.lang-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover, .lang-menu[open] summary { color: var(--brass-light); }
.lang-menu .globe { flex: none; }
.lang-menu .chevron { flex: none; transition: transform 0.15s ease; }
.lang-menu[open] .chevron { transform: rotate(180deg); }
.lang-menu ul {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 190px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--velvet);
  border-radius: 14px;
}
.top nav .lang-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--ivory);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.top nav .lang-menu a:hover { background: var(--line); }
.top nav .lang-menu a[aria-current] { color: var(--brass-light); font-weight: 700; }
.lang-menu .check { flex: none; color: var(--brass); }
/* Sur téléphone, le menu passe à la ligne sous le logo : la liste s'aligne sur la marge droite de
   l'en-tête, pour ne jamais dépasser de l'écran. */
@media (max-width: 560px) {
  .top { position: relative; }
  .lang-menu { position: static; }
  .lang-menu ul { top: calc(100% - 8px); right: var(--gutter); }
}

main { display: block; }
.home main, .doc main { max-width: calc(var(--column) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

/* Boutons : aplats or, texte encre. « Bientôt » reste lisible sans paraître actif (or à 16 %). */
.store, .prose .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  margin: 0;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--brass);
  color: var(--ink);
  font: 700 1rem/1.2 var(--round);
  text-decoration: none;
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
}
.store:hover, .prose .button:hover { background: var(--brass-light); }
.store:active, .prose .button:active { opacity: 0.8; transform: scale(0.98); }
.store.soon { background: rgba(219, 171, 92, 0.16); color: rgba(245, 232, 207, 0.85); }
.stores { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; }

/* Le ciel de la Chambre : la carte signature, remplie par le ciel peint. */
.sky {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-mid) 55%, var(--sky-horizon));
}
.stage {
  --pad: clamp(20px, 4vw, 48px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: end;
  gap: 8px clamp(16px, 4vw, 48px);
  margin-top: 8px;
  padding: clamp(28px, 5vw, 56px) var(--pad) 0;
}
/* Le texte passe devant le sol de la scène, qui s'étend sous lui jusqu'au bord gauche de la carte. */
.stage-text { position: relative; z-index: 1; align-self: center; padding-bottom: clamp(72px, 9vw, 112px); }
.title { margin: 0; font-size: clamp(2.6rem, 1.6rem + 4vw, 4.4rem); line-height: 1; }
.pitch { margin: 1rem 0 1.6rem; max-width: 30em; font-size: clamp(1.05rem, 1rem + 0.35vw, 1.22rem); color: var(--ivory-soft); }
/* La scène va jusqu'aux bords de la carte : le sol ferme le ciel. */
.scene { display: block; width: calc(100% + var(--pad)); max-width: none; margin-right: calc(-1 * var(--pad)); }
@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; padding-bottom: 0; }
  .stage-text { padding-bottom: 0; }
  .scene { width: calc(100% + 2 * var(--pad)); margin: 8px calc(-1 * var(--pad)) 0; }
}

/* Le troupeau en 3D (flock.js) se pose sur le ciel : étoiles et lune restent en SVG derrière. */
.scene { position: relative; aspect-ratio: 560 / 300; }
@media (max-width: 760px) {
  .scene { aspect-ratio: 5 / 4; }
  /* Le ciel de la scène se fond dans celui de la carte. */
  .scene > canvas { -webkit-mask-image: linear-gradient(transparent, #000 22%); mask-image: linear-gradient(transparent, #000 22%); }
}
.scene > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Sur ordinateur, la prairie passe sous le texte jusqu'au bord gauche de la carte. */
@media (min-width: 761px) {
  .stage { position: relative; overflow: hidden; }
  .stage .scene { position: static; }
  .stage .scene > canvas { border-radius: inherit; }
  /* Voile du ciel derrière le texte : il reste lisible sur les nuages. */
  .stage::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: inherit;
    background: linear-gradient(90deg, rgba(18, 20, 66, 0.82) 0%, rgba(18, 20, 66, 0.55) 34%, rgba(18, 20, 66, 0) 56%); }
  .stage-text { z-index: 2; }
}
.twinkle { animation: twinkle 5s ease-in-out infinite alternate; }
.twinkle-2 { animation-delay: -2s; }
@keyframes twinkle { from { opacity: 0.9; } to { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .twinkle { animation: none; }
  .store, .prose .button, .lang-menu .chevron { transition: none; }
}

/* Sections de l'accueil : un label or, puis des cartes prune en aplat. */
.band { padding: clamp(48px, 7vw, 88px) 0 0; }
.band > p.intro { max-width: 36em; margin: 0 0 1.4rem; font-size: 1.1rem; color: var(--ivory-soft); }

.loop ol { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; }
.loop li { counter-increment: step; padding: 20px; border-radius: 16px; background: var(--velvet); }
.loop li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--wool);
  font: 700 1.05rem/1 var(--round);
  font-variant-numeric: tabular-nums;
}
.loop p { margin: 0; color: var(--ivory-soft); }
@media (max-width: 760px) { .loop ol { grid-template-columns: 1fr; } }

/* Hypnogramme « Ton sommeil » : les marches du sommeil, trait or pour la part atteinte. */
.depth .sky { padding: clamp(20px, 3vw, 32px); }
.hypno { display: block; width: 100%; height: auto; }
.layers { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; padding: 0; }
.layers li { padding: 14px 16px; border-radius: 16px; background: rgba(0, 0, 0, 0.28); }
.layers b { display: block; font: 700 1.02rem/1.3 var(--round); }
.layers span { display: block; margin-top: 4px; font-size: 0.92rem; line-height: 1.4; color: var(--ivory-soft); }
.layers .verb { margin-top: 8px; font: 700 0.85rem/1.3 var(--display); font-variant-caps: all-small-caps; letter-spacing: 0.06em; color: var(--ivory-faint); }
.t-wool { color: var(--wool); }
.t-peach { color: var(--peach); }
.t-moon { color: var(--moonlight); }
.t-lavender { color: var(--lavender); }
@media (max-width: 860px) { .layers { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .layers { grid-template-columns: 1fr; } }

/* Fait pour le lit : une zone de liste, rangées séparées par un filet ivoire à 8 %. */
.rows { list-style: none; margin: 0; padding: 0 4px; border-radius: 16px; background: var(--well); }
.rows li { display: grid; grid-template-columns: 2.2rem minmax(0, 1fr); gap: 12px; align-items: start; padding: 16px 12px; }
.rows li + li { border-top: 1px solid var(--line); }
.rows svg { width: 26px; height: 26px; margin-top: 2px; color: var(--brass-light); }
.rows p { margin: 0; color: var(--ivory-soft); }
.rows strong { color: var(--ivory); font-weight: 700; }

/* Ce qui est payant : deux cartes prune, la promesse dans une zone sombre. */
.deal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.offer { padding: 20px; border-radius: 16px; background: var(--velvet); }
.offer p { margin: 0; color: var(--ivory-soft); }
.offer .kind { margin: 0 0 6px; font: 700 0.85rem/1.3 var(--display); font-variant-caps: all-small-caps; letter-spacing: 0.06em; color: var(--ivory-faint); }
.promise { margin-top: 16px; }
@media (max-width: 760px) { .deal-grid { grid-template-columns: 1fr; } }

.last { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px 32px; margin-top: clamp(48px, 7vw, 88px); padding: clamp(24px, 4vw, 40px); }
.last h2 { margin-bottom: 0.4rem; }
.last p { margin: 0; color: var(--ivory-soft); }
.last .moon-mark { width: 56px; height: 56px; flex: none; }

/* Pages longues : un bandeau de ciel pour le titre, puis une colonne de lecture. */
.doc-head {
  position: relative;
  overflow: hidden;
  margin-top: 8px;
  padding: clamp(28px, 5vw, 56px) clamp(20px, 4vw, 48px);
  border-radius: 24px;
  background:
    radial-gradient(1.5px 1.5px at 12% 28%, var(--ivory) 99%, transparent),
    radial-gradient(1px 1px at 31% 70%, var(--ivory-soft) 99%, transparent),
    radial-gradient(1.5px 1.5px at 52% 22%, var(--ivory-soft) 99%, transparent),
    radial-gradient(1px 1px at 66% 64%, var(--ivory) 99%, transparent),
    radial-gradient(1.5px 1.5px at 74% 18%, var(--ivory) 99%, transparent),
    radial-gradient(1px 1px at 90% 78%, var(--ivory-soft) 99%, transparent),
    linear-gradient(180deg, var(--sky-top), var(--sky-mid) 60%, var(--sky-horizon));
}
/* Le croissant de lune : un disque transparent dont l'ombre dessine le croissant (une forme, pas un relief). */
.doc-head::after {
  content: "";
  position: absolute;
  top: clamp(18px, 4vw, 36px);
  right: clamp(26px, 6vw, 64px);
  width: clamp(34px, 5vw, 52px);
  height: clamp(34px, 5vw, 52px);
  border-radius: 50%;
  box-shadow: -9px 7px 0 0 var(--brass);
}
.doc-head h1 { margin: 0; padding-right: 64px; font-size: clamp(2rem, 1.3rem + 3vw, 3.4rem); line-height: 1.05; hyphens: auto; }
/* Un titre japonais se coupe entre deux mots, jamais devant un « ー ». */
:lang(ja) .doc-head h1, :lang(ja) .title { line-break: strict; word-break: auto-phrase; }
:lang(ko) .doc-head h1 { word-break: keep-all; }
@media (max-width: 560px) { :lang(ja) .doc-head h1 { font-size: 1.4rem; } }
.updated { display: inline-block; margin: 0.9rem 0 0; padding: 4px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.32); color: var(--ivory-soft); font-size: 0.92rem; font-weight: 600; }
.reading {
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) minmax(0, 42rem);
  gap: clamp(28px, 5vw, 72px);
  padding: clamp(28px, 4vw, 48px) 0 clamp(48px, 7vw, 96px);
}
.toc { position: sticky; top: 20px; align-self: start; }
.toc > p { margin: 0 0 0.6rem; font: 700 1rem/1.3 var(--display); font-variant-caps: all-small-caps; letter-spacing: 0.08em; color: var(--brass); }
.toc ul { list-style: none; margin: 0; padding: 4px 0; border-radius: 16px; background: var(--well); }
.toc li + li { border-top: 1px solid var(--line); }
.toc a { display: block; padding: 0.55rem 14px; color: var(--ivory-soft); text-decoration: none; font-size: 0.94rem; line-height: 1.35; }
.toc a:hover { color: var(--brass-light); }
@media (max-width: 860px) {
  .reading { grid-template-columns: 1fr; }
  .toc { position: static; }
}
.prose { font-size: 1.04rem; line-height: 1.7; }
.prose > :first-child { margin-top: 0; }
.prose p { color: var(--ivory-soft); }
.prose .lede { font-size: 1.2rem; line-height: 1.55; font-weight: 600; color: var(--ivory); }
.prose h2 { margin: 2.4rem 0 0.5rem; font-size: 1.15rem; scroll-margin-top: 20px; }
.prose ul { padding-left: 1.2rem; color: var(--ivory-soft); }
.prose li { margin-bottom: 0.4rem; }
.prose li::marker { color: var(--brass); }
.prose strong { color: var(--ivory); font-weight: 700; }
.prose a { color: var(--brass-light); text-decoration-color: rgba(219, 171, 92, 0.6); }
.prose a:hover { text-decoration-color: var(--brass-light); }
.prose .button { color: var(--ink); }
.prose .contact { margin: 1.6rem 0 0.8rem; }
.prose .hint { font-size: 0.96rem; color: var(--ivory-faint); }

/* Pied de page : la nuit basse, comme la barre d'onglets, avec son filet ivoire. */
.bottom {
  margin-top: clamp(56px, 8vw, 96px);
  padding: 32px var(--gutter) max(32px, env(safe-area-inset-bottom));
  background: var(--night-bottom);
  border-top: 1px solid var(--line);
}
.bottom nav, .bottom p { max-width: var(--column); margin-left: auto; margin-right: auto; }
.bottom nav { display: flex; flex-wrap: wrap; gap: 0 28px; font-weight: 700; color: var(--brass); }
.bottom nav a { padding: 10px 0; text-decoration: none; }
.bottom nav a:hover { color: var(--brass-light); }
.bottom p { margin-top: 1rem; margin-bottom: 0; color: var(--ivory-faint); font-size: 0.92rem; }
.bottom p a { color: var(--ivory-soft); }
