/* MINUIT — fondations communes (invité, régie, TV) */

@font-face { font-family: 'Geist'; src: url('../fonts/geist.woff2') format('woff2'); font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Geist'; src: url('../fonts/geist-ext.woff2') format('woff2'); font-weight: 100 900; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Geist Mono'; src: url('../fonts/geist-mono.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Instrument Serif'; src: url('../fonts/instrument-serif-italic.woff2') format('woff2'); font-style: italic; font-display: swap; }
@font-face { font-family: 'Instrument Serif'; src: url('../fonts/instrument-serif.woff2') format('woff2'); font-style: normal; font-display: swap; }

:root {
  color-scheme: dark;
  --ink: #040506;
  --ink-1: #08090b;
  --ink-2: #0e1013;
  --ink-3: #15181c;
  --ink-4: #1d2126;
  --line: rgba(200, 212, 222, 0.09);
  --line-2: rgba(200, 212, 222, 0.16);
  --fog: #8b939b;
  --dim: #5c636a;
  --bone: #d8dbd7;
  --bone-2: #b9bdb9;
  --blood: #6e1210;
  --blood-2: #9b1d18;
  --blood-glow: rgba(155, 29, 24, 0.35);
  --ok: #c9d0c4;
  --sans: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --ease-slow: cubic-bezier(0.22, 0.61, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 2px;
  --tap: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--ink); }
body {
  margin: 0; min-height: 100dvh; background: var(--ink); color: var(--bone);
  font-family: var(--sans); font-weight: 350; font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img, video, canvas, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: var(--blood); color: var(--bone); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- typographie */
.eyebrow, .mono {
  font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--fog);
}
.mono { text-transform: none; letter-spacing: 0.04em; }
.serif { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: 0; }
h1, h2, h3 { margin: 0; font-weight: 300; letter-spacing: -0.012em; line-height: 1.15; }
h1 { font-size: clamp(1.7rem, 5.4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 4vw, 1.75rem); }
h3 { font-size: 1.05rem; font-weight: 450; letter-spacing: 0; }
p { margin: 0; }
.muted { color: var(--fog); }
.dim { color: var(--dim); }
.red { color: var(--blood-2); }

/* ---------------------------------------------------------------- boutons */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: transparent; color: var(--bone);
  min-height: var(--tap); padding: 0 22px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 15px; font-weight: 450; letter-spacing: 0.01em; cursor: pointer;
  transition: background 0.25s, border-color 0.25s, color 0.25s, opacity 0.25s, transform 0.12s;
  text-decoration: none; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn:hover { border-color: rgba(216, 219, 215, 0.4); }
.btn:active { transform: scale(0.985); }
.btn:focus-visible, .chip:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 1px solid var(--bone); outline-offset: 3px;
}
.btn[disabled], .btn.is-busy { opacity: 0.38; pointer-events: none; }
.btn--solid { background: var(--bone); color: var(--ink); border-color: var(--bone); }
.btn--solid:hover { background: #fff; border-color: #fff; }
.btn--blood { background: var(--blood); border-color: var(--blood-2); color: #f1e9e6; }
.btn--blood:hover { background: var(--blood-2); }
.btn--ghost { border-color: transparent; color: var(--fog); }
.btn--ghost:hover { color: var(--bone); border-color: var(--line); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 14px; font-size: 13.5px; }
.btn--xs { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn .k { font-family: var(--mono); font-size: 11px; color: var(--dim); }

.iconbtn {
  appearance: none; border: 1px solid var(--line); background: rgba(8, 9, 11, 0.6); color: var(--bone-2);
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.iconbtn svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- champs */
.field { display: grid; gap: 8px; }
.field > span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fog); }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; background: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  min-height: 52px; padding: 12px 14px; font-size: 16px; color: var(--bone); outline: none;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--dim); }

/* ---------------------------------------------------------------- puces d'état */
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 9px;
  border: 1px solid var(--line-2); border-radius: 12px; font-family: var(--mono);
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fog); white-space: nowrap;
}
.chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.chip--assigned { color: var(--fog); }
.chip--received { color: #c3cbd2; border-color: rgba(195, 203, 210, 0.3); }
.chip--projecting { color: #e5e1d6; border-color: rgba(229, 225, 214, 0.35); }
.chip--voting { color: #f0d9c9; border-color: rgba(240, 160, 120, 0.4); }
.chip--validated { color: var(--bone); border-color: rgba(216, 219, 215, 0.45); background: rgba(216, 219, 215, 0.06); }
.chip--refused { color: #e3a29b; border-color: rgba(155, 29, 24, 0.6); background: rgba(110, 18, 16, 0.18); }
.chip--tie, .chip--none { color: var(--fog); }

/* ---------------------------------------------------------------- calques d'ambiance */
.fx-grain {
  position: fixed; inset: -50%; z-index: 90; pointer-events: none; opacity: 0.075;
  background-image: var(--grain); background-size: 180px 180px; mix-blend-mode: screen;
  animation: grain 0.9s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 17% { transform: translate(-3%, 2%); } 33% { transform: translate(2%, -4%); }
  50% { transform: translate(-4%, -1%); } 67% { transform: translate(3%, 3%); } 83% { transform: translate(-1%, 4%); } 100% { transform: translate(0, 0); }
}
.fx-vignette {
  position: fixed; inset: 0; z-index: 89; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
.fx-presence {
  position: fixed; z-index: 88; pointer-events: none; opacity: 0;
  background-size: cover; background-position: center; filter: grayscale(1) contrast(1.2) brightness(0.9);
  mix-blend-mode: screen; transition: opacity 4s var(--ease-slow);
}
body.fx-off .fx-grain, body.fx-off .fx-presence { display: none; }
body.fx-off .fx-vignette { opacity: 0.6; }

/* ---------------------------------------------------------------- utilitaires */
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 200;
  display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  max-width: 520px; background: rgba(14, 16, 19, 0.96); border: 1px solid var(--line-2); color: var(--bone);
  padding: 12px 16px; font-size: 14px; border-radius: var(--radius); pointer-events: auto;
  animation: toast-in 0.35s var(--ease-out); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.toast--err { border-color: rgba(155, 29, 24, 0.7); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.progress { height: 2px; background: var(--line); position: relative; overflow: hidden; }
.progress > i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--bone); transition: width 0.3s; }

.sound-pop {
  position: fixed; z-index: 150; right: 16px; top: calc(64px + env(safe-area-inset-top));
  background: rgba(10, 11, 13, 0.97); border: 1px solid var(--line-2); padding: 16px; width: 240px; border-radius: var(--radius);
  display: grid; gap: 12px; box-shadow: 0 30px 60px rgba(0, 0, 0, 0.7);
}
input[type=range] { width: 100%; accent-color: var(--bone); height: 28px; }

.offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 180; text-align: center; padding: 6px 12px calc(6px);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; background: #1a0b0a; color: #e0b0aa;
  border-bottom: 1px solid var(--blood);
}

/* ---------------------------------------------------------------- épouvante (dread.js) */
.living { position: absolute; inset: 0; overflow: hidden; background: #000; }
.living__img, .living__gl { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.living__img { filter: grayscale(0.55) brightness(calc(1 - var(--dark, 0))); transition: filter 1.2s; }
.living__gl { opacity: 0; transition: opacity 1.6s var(--ease-slow); }
.living.is-gl .living__gl { opacity: 1; }

.is-haunted { color: #d9a39c; }
.is-typing::after { content: ''; display: inline-block; width: 0.06em; height: 0.8em; margin-left: 0.1em; vertical-align: -0.05em; background: #b3423a; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* perte de signal : une bande de parasites traverse, l'image décroche (pas de flash : on assombrit) */
.sigloss { position: absolute; inset: 0; z-index: 60; pointer-events: none; overflow: hidden;
  background: rgba(0, 0, 0, 0.55); animation: sigloss-bg var(--ms, 700ms) linear forwards; }
.sigloss i { position: absolute; left: -5%; right: -5%; height: 18%; background-image: var(--grain); background-size: 140px 70px;
  opacity: 0.32; mix-blend-mode: screen; animation: sigloss-band var(--ms, 700ms) steps(9) forwards; filter: contrast(1.4) brightness(0.7); }
.sigloss i + i { height: 6%; animation-duration: calc(var(--ms, 700ms) * 0.7); animation-direction: reverse; opacity: 0.22; }
.sigloss span { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-family: var(--mono);
  letter-spacing: 0.4em; font-size: clamp(11px, 1.3vw, 22px); color: rgba(216, 219, 215, 0.55); }
@keyframes sigloss-band { from { top: -20%; transform: translateX(0); } to { top: 105%; transform: translateX(3%); } }
@keyframes sigloss-bg { 0% { opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* frayeur plein écran (TV et téléphones) */
.scare { position: fixed; inset: 0; z-index: 300; background: #000; color: #e9ebe7; display: grid; overflow: hidden;
  opacity: 0; transition: opacity 0.6s var(--ease-slow); }
.scare.is-in { opacity: 1; }
.scare .living { opacity: 0; transition: opacity 3.2s var(--ease-slow), transform 9s cubic-bezier(.3, 0, .2, 1); transform: scale(1.04); }
.scare.is-face .living { opacity: 1; transform: scale(1.22); }
.scare__text { position: relative; z-index: 2; align-self: end; padding: 0 7vw calc(9vh + env(safe-area-inset-bottom)); display: grid; gap: 1.6vh; }
.scare__kicker { font-family: var(--mono); font-size: clamp(11px, 1.1vw, 20px); letter-spacing: 0.3em; text-transform: uppercase; color: #b3423a; min-height: 1.4em; }
.scare__line { font-family: var(--serif); font-style: italic; font-size: clamp(2.4rem, 7vw, 8rem); line-height: 1; min-height: 1em; text-shadow: 0 0 40px #000; }
.scare__sub { font-size: clamp(1rem, 2vw, 2rem); color: var(--bone-2); min-height: 1.3em; }
body.dread-off .scare .living { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.15s !important; }
  .fx-grain { animation: none; }
  .fx-presence { display: none; }
}

/* frayeur « course » : la vidéo plein écran, façon caméra de surveillance, puis noir */
.scare__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0;
  filter: grayscale(0.85) contrast(1.15) brightness(0.95); }
.scare.is-playing .scare__video { opacity: 1; }
.scare.is-cut .scare__video { opacity: 0; transition: opacity 0.12s; }
.scare.is-run .scare__text { opacity: 0; }
.scare.is-run.is-cut .scare__text { opacity: 1; }
/* le bébé garde ses couleurs de chair */
.scare__video[data-clip="bebe"] { filter: contrast(1.1) saturate(1.1) brightness(1.02); }
/* les frayeurs refaites en 3D sont déjà étalonnées (vision nocturne, sang) */
.scare__video[data-clip^="sc-"] { filter: none; }
