/* Château Nerval — la page d'accueil : l'entrée, puis la vraie application en démonstration.
   Couleurs et typographie reprises de theme.ts. */

@font-face { font-family: "Cormorant Garamond"; src: url("fonts/CormorantGaramond.woff2") format("woff2"); font-weight: 500 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("fonts/CormorantGaramond-Italic.woff2") format("woff2"); font-weight: 500 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("fonts/Spectral-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("fonts/Spectral-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("fonts/HankenGrotesk.woff2") format("woff2"); font-weight: 500 700; font-display: swap; }

:root {
  --titre: "Cormorant Garamond", Garamond, "Times New Roman", serif;
  --texte: "Spectral", Georgia, serif;
  --ui: "Hanken Grotesk", system-ui, sans-serif;
  --fond: #FBF6F0; --carte: #FFFDFB; --carte2: #F1EDE4; --filet: #EADFD6;
  --encre: #3A2E33; --sourdine: #6A5A58; --bronze: #8A6055; --prune: #4A2B3A; --beige: #E0CDBD;
}

/* Le soir (20 h à 7 h, comme l'application) : la palette de nuit de theme.ts. */
html.nuit {
  --fond: #151B2B; --carte: #1F2638; --carte2: #283149; --filet: #8C7966;
  --encre: #F6EEE3; --sourdine: #B7ADA2; --bronze: #D4B184;
}
html.nuit .btn-plein { border-color: #D4B184; }
html.nuit .btn-trait { border-color: #8C7966; }
html.nuit .registre-etat.erreur { color: #C9705A; }
html.nuit .sceau-trace .lune { fill: #D4B184; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--fond); color: var(--encre); font-family: var(--texte); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden; }
img, video, svg { display: block; max-width: 100%; }
a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
p, h1, h2 { margin: 0; }
:focus-visible { outline: 2px solid #B58B5A; outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

h1, h2 { font-family: var(--titre); font-weight: 600; line-height: 1.06; text-wrap: balance; }
.capitales { font-family: var(--ui); font-size: .68rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
.surtitre { color: var(--bronze); margin-bottom: 12px; }
.chapo { font-family: var(--titre); font-style: italic; font-weight: 500; font-size: clamp(1.2rem, 4.4vw, 1.5rem); line-height: 1.3; margin-top: 10px; color: var(--sourdine); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 12px 26px; border-radius: 14px; border: 1px solid var(--prune); font-family: var(--ui); font-weight: 600; font-size: .98rem; letter-spacing: .02em; text-decoration: none; text-align: center; transition: transform .3s ease, filter .3s ease; }
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.07); }
.btn-plein { background: var(--prune); color: #FBF6F0; }
.btn-clair { background: var(--beige); color: #2B1A1D; border-color: var(--bronze); }
.btn-trait { background: transparent; color: var(--encre); border-color: var(--filet); }
.rond { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--filet); background: var(--carte); display: grid; place-items: center; padding: 0; font-size: 1.5rem; line-height: 1; }

/* ───── L'entrée : les grilles, puis la porte ───── */
.portail { position: fixed; inset: 0; z-index: 100; background: #2B2320; display: grid; place-items: center; overflow: hidden; transition: opacity 1.1s ease; }
html.entree #portail { display: grid !important; }
.portail.sort { opacity: 0; pointer-events: none; }
.portail-image, .portail-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.portail-video { opacity: 0; transition: opacity .7s ease; }
.portail-video.joue { opacity: 1; }
.portail-voile { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(20, 14, 18, .5) 0%, rgba(20, 14, 18, .28) 40%, rgba(20, 14, 18, .62) 100%); transition: opacity 1s ease; }
.portail-texte { position: relative; z-index: 2; display: grid; justify-items: center; gap: 20px; text-align: center; color: #FBF6F0; padding: 0 24px; text-shadow: 0 2px 20px rgba(10, 8, 14, .7); transition: opacity .8s ease; }
.portail.ouvre .portail-texte, .portail.ouvre .portail-voile { opacity: 0; pointer-events: none; }
.portail-nom { font-family: var(--titre); font-weight: 600; font-size: clamp(2.2rem, 9vw, 3.2rem); line-height: 1; }
.portail-sceau { width: 132px; height: 132px; border-radius: 50%; border: 1px solid rgba(251, 246, 240, .7); background: rgba(43, 26, 29, .38); color: #FBF6F0; display: grid; place-items: center; padding: 0; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: sceau-respire 3s ease-in-out infinite; }
.portail-sceau svg { width: 84px; height: auto; }
.portail-phrase { font-family: var(--titre); font-style: italic; font-weight: 500; font-size: clamp(1.35rem, 5.4vw, 1.7rem); line-height: 1.25; }
.portail-prenom { display: grid; gap: 8px; justify-items: center; width: min(300px, 80vw); margin-top: 4px; }
.portail-prenom label { font-family: var(--ui); font-size: .64rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }
.portail-prenom input { width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid rgba(251, 246, 240, .7); background: rgba(43, 26, 29, .45); color: #FBF6F0; text-align: center; font: inherit; font-size: 1.05rem; padding: 0 14px; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.portail-prenom input::placeholder { color: rgba(251, 246, 240, .75); }
.portail-prenom p { font-size: .74rem; line-height: 1.35; opacity: .85; text-shadow: 0 1px 10px rgba(10, 8, 14, .8); }
.registre input[type="text"] { flex: 1 1 130px; min-width: 0; min-height: 50px; border-radius: 14px; border: 1px solid var(--filet); background: var(--carte2); color: var(--encre); padding: 0 16px; font: inherit; }
.portail-langue { position: absolute; z-index: 3; left: 16px; top: calc(14px + env(safe-area-inset-top)); color: #FBF6F0; text-decoration: none; background: rgba(21, 27, 43, .4); border: 1px solid rgba(251, 246, 240, .5); border-radius: 999px; padding: 9px 16px; font-size: .62rem; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.portail-passer { position: absolute; z-index: 3; right: 16px; top: calc(14px + env(safe-area-inset-top)); background: rgba(21, 27, 43, .4); color: #FBF6F0; border: 1px solid rgba(251, 246, 240, .5); border-radius: 999px; padding: 9px 16px; font-size: .62rem; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes entre { from { opacity: 0; transform: translateY(8px); } }
@keyframes sceau-respire { 50% { box-shadow: 0 0 0 12px rgba(251, 246, 240, .12); transform: scale(1.03); } }

/* ───── La Maison : l'application elle-même ───── */
.scene { height: 100dvh; display: flex; flex-direction: column; }
.accueil { display: none; }
.maison { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bandeau { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px; background: var(--carte); border-bottom: 1px solid var(--filet); }
.bandeau p { font-size: .9rem; line-height: 1.25; display: grid; gap: 2px; min-width: 0; }
.bandeau .capitales { font-size: .56rem; color: var(--bronze); }
.bandeau .btn { min-height: 42px; padding: 8px 16px; font-size: .88rem; flex: none; border-radius: 12px; }
.cadre { flex: 1; min-height: 0; background: var(--fond); }
#app { width: 100%; height: 100%; border: 0; display: block; background: var(--fond); }

/* ───── Les clés ───── */
.cles { border: 0; padding: 0; margin: 0; max-width: none; max-height: none; width: 100%; height: 100%; background: var(--fond); color: var(--encre); overflow-y: auto; overscroll-behavior: contain; }
.cles[open] { animation: entre .5s ease both; }
.cles::backdrop { background: rgba(20, 14, 18, .6); }
.cles-page { max-width: 560px; margin: 0 auto; padding: 64px 20px calc(40px + env(safe-area-inset-bottom)); text-align: center; position: relative; }
.cles-fermer { position: absolute; right: 16px; top: calc(14px + env(safe-area-inset-top)); }
.cles h2 { font-size: clamp(2rem, 7.4vw, 2.7rem); }
.sceau-trace { width: 78px; margin: 0 auto 18px; color: var(--encre); }
.js .sceau-trace .trait { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 2.2s ease .2s; }
.js .sceau-trace .lune { opacity: 0; transition: opacity 1.2s ease 1.9s; }
.js [open] .sceau-trace .trait { stroke-dashoffset: 0; }
.js [open] .sceau-trace .lune { opacity: 1; }

.cta { margin-top: 24px; display: grid; justify-items: center; gap: 12px; }
.cta-boutons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.cta-boutons .btn { flex: 1 1 200px; max-width: 300px; min-height: 54px; }
.rassurance { color: var(--sourdine); font-size: .6rem; letter-spacing: .14em; line-height: 1.7; }
.etapes { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; counter-reset: etape; text-align: left; max-width: 400px; }
.etapes li { counter-increment: etape; display: grid; grid-template-columns: 28px 1fr; gap: 12px; font-size: .95rem; line-height: 1.4; }
.etapes li::before { content: counter(etape); width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--bronze); display: grid; place-items: center; font-family: var(--titre); font-weight: 600; }
.etapes a { color: var(--bronze); }
.qr-ligne { display: flex; gap: 16px; align-items: center; text-align: left; background: var(--carte); border: 1px solid var(--filet); border-radius: 18px; padding: 14px 18px 14px 14px; }
.qr-ligne img { width: 124px; height: 124px; border-radius: 10px; flex: none; }
.qr-ligne strong { font-family: var(--titre); font-weight: 600; font-size: 1.35rem; line-height: 1.15; display: block; }
.petit { font-size: .86rem; color: var(--sourdine); line-height: 1.4; margin-top: 6px; }

.registre { margin-top: 30px; text-align: left; background: var(--carte); border: 1px solid var(--filet); border-radius: 18px; padding: 16px; }
.registre label { font-family: var(--titre); font-weight: 600; font-size: 1.35rem; display: block; }
.registre-ligne { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.registre input[type="email"] { flex: 1 1 200px; min-width: 0; min-height: 50px; border-radius: 14px; border: 1px solid var(--filet); background: var(--carte2); color: var(--encre); padding: 0 16px; font: inherit; }
.registre-mention { font-size: .82rem; color: var(--sourdine); margin-top: 12px; }
.registre-etat { margin-top: 8px; font-style: italic; min-height: 1.4em; }
.registre-etat.erreur { color: #B5533A; }
.piege { position: absolute; left: -9999px; }

.questions { margin-top: 48px; text-align: left; }
.questions details { border-top: 1px solid var(--filet); }
.questions details:last-of-type { border-bottom: 1px solid var(--filet); }
.questions summary { list-style: none; cursor: pointer; padding: 16px 34px 16px 0; position: relative; font-family: var(--titre); font-weight: 600; font-size: 1.28rem; line-height: 1.25; }
.questions summary::-webkit-details-marker { display: none; }
.questions summary::after { content: "+"; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-weight: 500; font-size: 1.5rem; color: var(--bronze); transition: transform .4s ease; }
.questions details[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.questions details p { padding: 0 0 18px; color: var(--sourdine); }
.questions a { color: var(--bronze); }
.pied { margin-top: 48px; }
.pied-devise { font-family: var(--titre); font-style: italic; font-weight: 500; font-size: 1.3rem; }
.pied-liens { margin-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; font-size: .6rem; color: var(--sourdine); }
.pied-liens a { text-decoration: none; padding: 6px 0; }
.pied-liens a:hover { text-decoration: underline; }
.sans-script { text-align: center; padding: 20px; }

/* ───── Grand écran : l'app dans un téléphone, l'invitation à côté ───── */
@media (min-width: 900px) {
  body { font-size: 18px; }
  .scene { flex-direction: row; align-items: center; justify-content: center; gap: clamp(40px, 7vw, 110px); padding: 24px 40px; background: radial-gradient(1200px 700px at 70% 40%, #FFFDFB 0%, var(--fond) 60%); }
  .accueil { display: block; max-width: 460px; }
  .marque { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--titre); font-weight: 600; font-size: 1.35rem; }
  .marque svg { width: 32px; height: auto; }
  h1 { font-size: clamp(2.6rem, 4.4vw, 3.8rem); margin-top: 36px; }
  .sous-titre { margin-top: 16px; font-size: 1.08rem; color: var(--sourdine); max-width: 36ch; }
  .indication { margin-top: 26px; color: var(--bronze); font-size: .62rem; }
  .accueil .cta { justify-items: start; margin-top: 20px; }
  /* Un iPhone à sa vraie taille (écran 393 × 852) : jamais écrasé, seulement réduit d'un bloc (--e, posé par app.js). */
  .maison { flex: none; display: block; position: relative; width: calc(421px * var(--e, 1)); height: calc(880px * var(--e, 1)); }
  .bandeau { display: none; }
  .cadre { position: absolute; left: 0; top: 0; width: 421px; height: 880px; padding: 14px; transform: scale(var(--e, 1)); transform-origin: top left; border-radius: 68px;
    background: linear-gradient(145deg, #5a5053 0%, #1d181a 22%, #2a2325 60%, #4d4447 100%);
    box-shadow: inset 0 0 0 2px #7b7174, inset 0 0 0 5px #151112, 0 0 0 1px #8d8386, 0 60px 90px -45px rgba(58, 46, 51, .65), 0 30px 40px -30px rgba(58, 46, 51, .35); }
  .cadre::before { content: ""; position: absolute; z-index: 2; top: 25px; left: 50%; transform: translateX(-50%); width: 120px; height: 35px; border-radius: 20px; background: #0a090a; pointer-events: none; }
  .cadre::after { content: ""; position: absolute; right: -4px; top: 250px; width: 4px; height: 96px; border-radius: 0 3px 3px 0; background: #4d4447; box-shadow: -425px -70px 0 -0.5px #4d4447, -425px 46px 0 -0.5px #4d4447; pointer-events: none; }
  #app { width: 393px; height: 852px; border-radius: 55px; }
  .cles { width: min(600px, 92vw); height: auto; max-height: 92dvh; margin: auto; border-radius: 26px; border: 1px solid var(--filet); }
  html.nuit .scene { background: radial-gradient(1200px 700px at 70% 40%, #1F2638 0%, #151B2B 62%); }

  /* L'entrée se joue dans l'écran de l'iPhone (app.js y déplace le portail) : les grilles, la porte, puis
     l'application, dans le même téléphone du début à la fin. Rien n'est étiré sur l'écran large. */
  /* Le seuil : tant que l'on n'est pas arrivé, les grilles floutées emplissent le fond et le téléphone se tient
     au centre. À l'arrivée, le flou se dissipe, le téléphone glisse à sa place (--dx, posé par app.js) et la
     page paraît autour. */
  .scene::before { content: ""; position: fixed; inset: -40px; z-index: 0; background: url("media/grilles-debut.jpg") center / cover; filter: blur(34px) brightness(.5) saturate(.9); opacity: 0; pointer-events: none; transition: opacity 1.8s ease; }
  html.au-seuil .scene::before { opacity: 1; }
  .accueil { position: relative; z-index: 1; transition: opacity 1.4s ease .7s, transform 1.4s cubic-bezier(.2, .6, .2, 1) .7s; }
  html.au-seuil .accueil { opacity: 0; transform: translateY(16px); pointer-events: none; transition: none; }
  .maison { z-index: 1; transition: transform 1.7s cubic-bezier(.3, .6, .2, 1); }
  html.au-seuil .maison { transform: translateX(var(--dx, 0px)); transition: none; }
  html.entree body > #portail { display: none !important; } /* jamais en plein écran, même un instant */
  .cadre .portail { position: absolute; inset: 14px; z-index: 1; border-radius: 55px; }
  .cadre .portail-nom { font-size: 2.3rem; }
  .cadre .portail-phrase { font-size: 1.4rem; }
  .cadre .portail-sceau { width: 118px; height: 118px; }
  .cadre .portail-sceau svg { width: 74px; }
  .cadre .portail-texte { gap: 16px; padding: 0 22px; }
  .cadre .portail-prenom { width: 270px; }
  .cadre .portail-passer, .cadre .portail-langue { top: 70px; }
  .cadre .portail-passer { right: 18px; }
  .cadre .portail-langue { left: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .sceau-trace .trait { stroke-dashoffset: 0; }
  .js .sceau-trace .lune { opacity: 1; }
}

/* ───── La feuille « Tester la bêta », allégée ───── */
.cles-page { padding-top: 56px; }
.cles .sceau-trace { width: 64px; margin-bottom: 14px; }
.cles .chapo { margin-top: 8px; }
.cles .cta { margin-top: 22px; gap: 10px; }
.cles .cta-boutons .btn { max-width: 340px; flex-basis: 100%; }
.aide { font-size: .9rem; color: var(--sourdine); }
.aide a { color: var(--bronze); }
.registre { margin-top: 28px; padding: 0; background: none; border: 0; border-radius: 0; text-align: center; }
.registre-titre { font-size: .9rem; color: var(--sourdine); }
.registre-ligne { margin-top: 10px; flex-wrap: nowrap; }
.registre input[type="email"], .registre input[type="text"] { flex: 1 1 0; min-height: 48px; }
.registre input[type="text"] { flex-grow: .7; }
.registre .btn { flex: none; width: 48px; min-height: 48px; padding: 0; font-size: 1.2rem; border-radius: 14px; }
.registre-etat:empty { display: none; }
.questions { margin-top: 30px; text-align: left; border-top: 1px solid var(--filet); border-bottom: 1px solid var(--filet); }
.questions summary { font-size: 1.15rem; padding: 14px 34px 14px 0; }
.questions dl { margin: 0; padding: 0 0 14px; display: grid; gap: 4px; }
.questions dt { font-family: var(--titre); font-weight: 600; font-size: 1.08rem; margin-top: 10px; }
.questions dd { margin: 0; color: var(--sourdine); font-size: .94rem; line-height: 1.45; }
.questions a { color: var(--bronze); }
.cles .pied { margin-top: 26px; }
.cles .pied-liens { margin-top: 0; }
@media (max-width: 420px) { .registre input[type="text"] { flex-grow: .55; } }
.questions[open] > summary::after { transform: translateY(-50%) rotate(45deg); }
@media (min-width: 900px) { .cles { height: fit-content; } }
