/* Portail du gardien de nuit, niveau 3 : styles communs */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700;800&family=Newsreader:ital,opsz,wght@0,6..72,400..600;1,6..72,400..600&family=Special+Elite&family=Reenie+Beanie&display=swap');

:root {
  --fond: #0A0B0D;
  --fond-2: #111317;
  --ligne: #23262C;
  --ligne-2: #3A3D44;
  --texte: #D9D6CE;
  --clair: #F2EFE8;
  --gris: #8B8F96;
  --gris-2: #9DA1A8;
  --rouge: #E5303F;
  --ambre: #D9A23A;
  --vert: #5FAE74;
  --papier: #E7E3D9;
  --encre: #15161A;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --serif: 'Newsreader', Georgia, serif;
  --machine: 'Special Elite', 'Courier New', monospace;
  --main: 'Reenie Beanie', 'Bradley Hand', cursive;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--fond); color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  overflow-x: clip;
}
a { color: var(--clair); text-underline-offset: 4px; }
a:hover { color: var(--rouge); }
button { font: inherit; color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, label:focus-within { outline: 2px solid var(--clair); outline-offset: 3px; }
img { display: block; max-width: 100%; }
::selection { background: var(--rouge); color: var(--fond); }

.sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--mono); }
.sur-titre { margin: 0; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .2em; color: var(--rouge); text-transform: uppercase; }
.petit { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--gris); }

/* Texte écrit « en blanc » : visible seulement à la sélection */
.blanc { color: transparent; }
.blanc::selection { background: var(--rouge); color: var(--fond); }

/* Mise en page */
.page { position: relative; max-width: 1360px; margin: 0 auto; padding: 0 28px 80px; }
.entete {
  position: sticky; top: 0; z-index: 50;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 28px; background: rgba(10,11,13,.95); border-bottom: 1px solid var(--ligne);
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em; color: var(--gris);
}
.marque { display: flex; align-items: center; gap: 12px; color: var(--clair); text-decoration: none; }
.marque b { display: block; font-size: 15px; letter-spacing: .2em; }
.marque span { display: block; font-size: 10px; letter-spacing: .22em; color: var(--gris); }
.entete .infos { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.horloge { font-size: 20px; font-weight: 800; color: var(--clair); font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.secteur { display: inline-flex; align-items: center; gap: 8px; }
.secteur::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.releve { color: var(--rouge); }
.presence { font-variant-numeric: tabular-nums; letter-spacing: .08em; cursor: help; }
.parasite img { animation: parasite .5s steps(3) 1; }
@keyframes parasite { 0% { filter: grayscale(1) contrast(3) brightness(2); } 50% { filter: grayscale(1) contrast(2) brightness(.3); } 100% { filter: grayscale(.55) contrast(1.1) brightness(.88); } }

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border: 1px solid var(--ligne-2); background: transparent;
  color: var(--clair); font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; text-decoration: none; cursor: pointer;
  transition: background-color .12s linear, color .12s linear, border-color .12s linear;
}
.bouton:hover { background: var(--clair); color: var(--fond); border-color: var(--clair); }
.bouton.plein { background: var(--clair); color: var(--fond); border-color: var(--clair); }
.bouton.plein:hover { background: var(--rouge); border-color: var(--rouge); color: var(--fond); }
.bouton.danger { border-color: #5A1219; }
.bouton[disabled] { opacity: .4; cursor: default; }
.lien { background: none; border: 0; padding: 4px 0; color: var(--gris); font-family: var(--mono); font-size: 12px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.lien:hover { color: var(--clair); }

.panneau { border: 1px solid var(--ligne); background: var(--fond-2); padding: 18px 20px; }
.panneau > h2, .panneau > h3 { margin: 0 0 12px; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .18em; color: var(--gris); text-transform: uppercase; }

.papier { background: var(--papier); color: var(--encre); box-shadow: 0 24px 50px rgba(0,0,0,.55); }
.manuscrit { font-family: var(--main); font-size: 26px; line-height: 1.15; }

/* Caméras */
.camera { position: relative; overflow: hidden; background: #000; border: 1px solid var(--ligne-2); aspect-ratio: 16 / 9; }
.camera img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.55) contrast(1.1) brightness(.88); }
.camera .osd { position: absolute; left: 10px; top: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--clair); text-shadow: 0 1px 2px #000; }
.camera .osd-bas { position: absolute; right: 10px; bottom: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--clair); text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums; }
.camera .osd-bas.acces { padding: 3px 7px; background: rgba(0,0,0,.72); color: var(--ambre); font-size: 13px; font-weight: 700; letter-spacing: .12em; }
.camera::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0, rgba(0,0,0,.22) 1px, transparent 1px, transparent 3px); }
.rec { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--rouge); animation: clignote 1.1s steps(1) infinite; }

/* Calques globaux injectés par le moteur */
#g-calques { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
#g-calques .grain { position: absolute; inset: -60px; opacity: .2; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 2.6 0 0 0 -1.25'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E"); animation: grain .7s steps(1) infinite; }
#g-calques .lignes { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,.12) 0, rgba(0,0,0,.12) 1px, transparent 1px, transparent 3px); }
#g-calques .vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,.5) 100%); transition: background .8s linear; }
html[data-level="2"] #g-calques .grain { opacity: .26; }
html[data-level="3"] #g-calques .grain { opacity: .32; }
html[data-level="2"] #g-calques .vignette { background: radial-gradient(ellipse at center, transparent 48%, rgba(0,0,0,.72) 100%); }
html[data-level="3"] #g-calques .vignette { background: radial-gradient(ellipse at center, transparent 40%, rgba(60,0,6,.72) 100%); animation: pouls 1.1s ease-in-out infinite; }

#g-toasts { position: fixed; right: 18px; bottom: 18px; z-index: 145; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100% - 36px)); pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 14px; background: #0E0F12; border: 1px solid var(--ligne-2); box-shadow: 0 14px 40px rgba(0,0,0,.7); font-family: var(--mono); font-size: 13px; line-height: 1.5; color: var(--clair); animation: entre .3s ease-out; }
.toast.arnaud { background: var(--papier); color: var(--encre); border-color: var(--papier); font-family: var(--main); font-size: 28px; line-height: 1.1; transform: rotate(-1.5deg); }
.toast .de { display: block; margin-bottom: 4px; font-size: 10px; letter-spacing: .14em; color: var(--gris); }

#g-dialogue { position: fixed; inset: 0; z-index: 140; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.72); }
#g-dialogue.ouvert { display: flex; }
#g-dialogue .boite { width: min(560px, 100%); padding: 24px; background: var(--fond); border: 1px solid #5A1219; box-shadow: 0 20px 60px rgba(0,0,0,.85); }
#g-dialogue .boite h2 { margin: 0 0 10px; font-family: var(--mono); font-size: 13px; letter-spacing: .18em; color: var(--rouge); }
#g-dialogue .boite p { white-space: pre-line; margin: 0 0 16px; font-size: 20px; line-height: 1.45; color: var(--clair); }
#g-dialogue .actions { display: flex; flex-wrap: wrap; gap: 10px; }
#g-dialogue .transcription { min-height: 1.5em; font-family: var(--mono); font-size: 14px; color: var(--gris-2); }

#g-veille { position: fixed; inset: 0; z-index: 130; display: none; background: #000; }
#g-veille.ouvert { display: block; }
#g-veille img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; mix-blend-mode: screen; filter: grayscale(1); transition: opacity 14s ease-in 3s; }
#g-veille.ouvert img { opacity: .18; }
#g-veille p { position: absolute; left: 0; right: 0; bottom: 30px; margin: 0; text-align: center; font-family: var(--mono); font-size: 12px; letter-spacing: .2em; color: #2C2E33; }
#g-alerte-veille { position: fixed; left: 50%; top: 70px; z-index: 125; transform: translateX(-50%); display: none; padding: 10px 16px; background: #1A0507; border: 1px solid #5A1219; font-family: var(--mono); font-size: 12px; letter-spacing: .12em; color: var(--clair); }
#g-alerte-veille.ouvert { display: block; }

#g-screamer { position: fixed; inset: 0; z-index: 9999; display: none; overflow: hidden; background: #000; }
#g-screamer.ouvert { display: block; }
#g-screamer > * { position: absolute; inset: 0; display: none; }
#g-screamer.approche .approche, #g-screamer.cri img.a, #g-screamer.doux img.a, #g-screamer.apres .apres { display: block; }
#g-screamer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: grayscale(.35) contrast(1.5) brightness(1.1); }
#g-screamer.cri img.a { animation: screamer 1.5s cubic-bezier(.2,.9,.2,1) both; }
#g-screamer.doux img.a { opacity: 0; animation: doux 4s ease-in forwards; }
/* Avant le cri : la caméra de votre poste se resserre sur lui */
#g-screamer .approche img { filter: grayscale(.6) contrast(1.2) brightness(.8); transform-origin: 40% 40%; animation: approche 3s ease-in forwards; }
#g-screamer .approche::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0, rgba(0,0,0,.25) 1px, transparent 1px, transparent 3px); }
#g-screamer .osd, #g-screamer .osd-bas { position: absolute; z-index: 1; font-family: var(--mono); font-size: 14px; letter-spacing: .14em; color: var(--clair); text-shadow: 0 1px 2px #000; }
#g-screamer .osd { left: 18px; top: 14px; }
#g-screamer .osd-bas { right: 18px; bottom: 14px; font-variant-numeric: tabular-nums; }
/* Après : la chaise est vide */
#g-screamer .apres img { filter: grayscale(.7) contrast(1.1) brightness(.4); }
#g-screamer .apres p { position: absolute; left: 0; right: 0; top: 45%; margin: 0; padding: 0 20px; text-align: center; font-family: var(--mono); font-size: 14px; letter-spacing: .2em; color: #8B8F96; }

/* Coupure de courant */
#g-noir { position: fixed; inset: 0; z-index: 135; display: none; background: #000; }
#g-noir.ouvert { display: block; }
#g-noir img { width: 100%; height: 100%; object-fit: cover; opacity: 0; filter: grayscale(1) contrast(1.3); mix-blend-mode: screen; }
#g-noir.visage img { animation: dans-le-noir 1.6s ease-in .3s forwards; }

/* Calques posés sur une caméra du poste */
.g-sur-camera { position: fixed; z-index: 40; overflow: hidden; pointer-events: none; background: #000; }
.g-sur-camera img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.55) contrast(1.1) brightness(.88); }
.g-sur-camera.visage { background: transparent; }
.g-sur-camera.visage img { opacity: .7; mix-blend-mode: screen; filter: grayscale(1) contrast(1.5); }
.g-sur-camera p { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .2em; color: var(--gris); background: repeating-linear-gradient(0deg, #08090B 0, #08090B 2px, #121418 2px, #121418 4px); }
.g-sur-camera .osd { position: absolute; left: 10px; top: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--clair); text-shadow: 0 1px 2px #000; }

#g-fantome { position: fixed; left: 0; top: 0; z-index: 128; pointer-events: none; opacity: 0; transition: opacity 1.5s linear; will-change: transform; }
html[data-level="2"] #g-fantome { opacity: .3; }
html[data-level="3"] #g-fantome { opacity: .8; }

/* Effets par niveau d'exposition */
html[data-level="2"] .glitch:hover img, html[data-level="3"] .glitch:hover img { animation: dechire .35s steps(2) infinite; }
html[data-level="3"] .page { transform: rotate(-.35deg); transform-origin: 50% 0; }
.brouille { color: var(--rouge) !important; }
.secoue { animation: secoue .4s linear 1; }
.dechire { animation: dechire-page .4s steps(4) 1; }

@keyframes clignote { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
@keyframes grain { 0% { transform: translate(0,0); } 25% { transform: translate(-40px,24px); } 50% { transform: translate(30px,-36px); } 75% { transform: translate(-22px,-12px); } 100% { transform: translate(14px,30px); } }
@keyframes entre { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes dechire { 0% { transform: translateX(0); filter: grayscale(.5) contrast(1.2) drop-shadow(3px 0 0 rgba(229,48,63,.7)) drop-shadow(-3px 0 0 rgba(60,200,255,.5)); clip-path: inset(10% 0 40% 0); } 100% { transform: translateX(-4px); filter: grayscale(.5) contrast(1.3) drop-shadow(-4px 0 0 rgba(229,48,63,.7)); clip-path: inset(0 0 0 0); } }
@keyframes secoue { 0%, 100% { transform: translate(0,0); } 20% { transform: translate(-3px,1px); } 40% { transform: translate(3px,-1px); } 60% { transform: translate(-2px,2px); } 80% { transform: translate(2px,-2px); } }
@keyframes screamer { 0% { transform: scale(1.6); } 12% { transform: scale(1.02) translate(-6px,4px); } 30% { transform: scale(1.04) translate(6px,-4px); } 50% { transform: scale(1.03) translate(-4px,-3px); } 70% { transform: scale(1.05) translate(4px,3px); } 100% { transform: scale(1.06); } }
@keyframes doux { to { opacity: .35; } }
@keyframes approche { from { transform: scale(1); } to { transform: scale(1.4); } }
@keyframes dans-le-noir { to { opacity: .14; } }
@keyframes pouls { 0%, 100% { opacity: .8; } 12% { opacity: 1; } 24% { opacity: .85; } 36% { opacity: .97; } }
@keyframes dechire-page {
  0% { transform: translateX(-7px) skewX(-1.5deg); filter: drop-shadow(4px 0 0 rgba(229,48,63,.65)) drop-shadow(-4px 0 0 rgba(60,200,255,.45)); }
  33% { transform: translateX(6px) skewX(1deg); }
  66% { transform: translateX(-3px); filter: drop-shadow(-3px 0 0 rgba(229,48,63,.6)); }
  100% { transform: none; filter: none; }
}

/* Menu du haut */
.g-menu { display: flex; flex-wrap: wrap; gap: 8px; }
.bouton.menu { min-height: 36px; padding: 0 12px; font-size: 11px; }
.g-pastille { display: inline-block; min-width: 18px; margin-left: 6px; padding: 1px 5px; background: var(--rouge); color: var(--fond); font-size: 10px; line-height: 16px; text-align: center; letter-spacing: 0; }
.toast.cliquable { cursor: pointer; }
.toast.cliquable:hover { border-color: var(--clair); }

/* Messagerie interne */
#g-chat { position: fixed; top: 0; right: 0; bottom: 0; z-index: 132; display: flex; flex-direction: column; width: min(440px, 100%); background: var(--fond); border-left: 1px solid var(--ligne-2); box-shadow: -24px 0 60px rgba(0,0,0,.7); animation: glisse .2s ease-out; }
#g-chat[hidden] { display: none; }
.g-chat-tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--ligne); font-family: var(--mono); font-size: 12px; letter-spacing: .16em; color: var(--clair); }
.g-chat-tete .bouton { min-height: 36px; font-size: 11px; }
.g-fils { display: flex; border-bottom: 1px solid var(--ligne); }
.g-fils button { flex: 1; min-height: 44px; padding: 0 8px; background: none; border: 0; border-bottom: 2px solid transparent; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--gris); cursor: pointer; }
.g-fils button[aria-selected="true"] { color: var(--clair); border-bottom-color: var(--rouge); }
.g-fil-nom { padding: 10px 14px 0; }
.g-fil-nom b { display: block; font-size: 17px; font-weight: 600; color: var(--clair); }
.g-fil-nom span { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--gris); }
.g-bulles { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.g-vide { margin: auto; font-family: var(--mono); font-size: 12px; color: var(--gris); }
.g-bulle { max-width: 86%; padding: 9px 12px 7px; background: #16181C; border: 1px solid var(--ligne); animation: entre .25s ease-out; }
.g-bulle p { margin: 0; font-size: 16px; line-height: 1.4; color: var(--clair); }
.g-bulle img { width: 100%; margin-bottom: 8px; aspect-ratio: 4 / 3; object-fit: cover; filter: saturate(.85); }
.g-bulle .h { display: block; margin-top: 4px; font-family: var(--mono); font-size: 10px; color: var(--gris); text-align: right; }
.g-bulle.eux { align-self: flex-start; }
.g-bulle.arnaud p { font-family: var(--mono); font-size: 14px; }
.g-bulle.moi { align-self: flex-end; background: var(--papier); border-color: var(--papier); }
.g-bulle.moi p { color: var(--encre); }
.g-bulle.moi .h { color: #55585E; }
.g-bulle.ecrit p { font-family: var(--mono); font-size: 12px; color: var(--gris); animation: clignote 1.2s steps(1) infinite; }
.g-saisie { padding: 12px 14px 16px; border-top: 1px solid var(--ligne); }
.g-saisie .g-ferme { margin: 0; }
.g-rapides { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.g-rapides .bouton { min-height: 36px; padding: 0 10px; font-size: 11px; }
.g-ecrire { display: flex; gap: 6px; }
.g-ecrire input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; background: #0E0F12; border: 1px solid var(--ligne-2); color: var(--clair); font-family: var(--mono); font-size: 16px; }
.g-ecrire input:focus { outline: 2px solid var(--ambre); outline-offset: -2px; }
.g-ecrire input::placeholder { color: var(--gris); }
.g-rapides .danger { margin-left: auto; }
.g-systeme { align-self: center; margin: 4px 0; padding: 4px 10px; border: 1px solid var(--rouge); font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--rouge); }

/* Règlement, par-dessus la page */
#g-reglement { position: fixed; inset: 0; z-index: 133; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.82); }
#g-reglement[hidden] { display: none; }
#g-reglement .boite { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 26px 28px; background: var(--papier); color: var(--encre); box-shadow: 0 24px 60px rgba(0,0,0,.8); }
#g-reglement .sur-titre { color: #8A1C25; }
#g-reglement h2 { margin: 6px 0 14px; font-family: var(--machine); font-size: 28px; font-weight: 400; line-height: 1.15; }
.g-ordre p { margin: 0 0 10px; font-size: 16px; line-height: 1.5; }
.g-ordre { margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px dashed #9C978B; }
.g-consignes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; font-family: var(--machine); }
.g-consignes li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 6px; align-items: baseline; font-size: 18px; line-height: 1.35; }
.g-consignes li span:first-child { color: #55585E; }
.g-consignes em { font-family: var(--mono); font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .12em; color: #A11D2A; }
.g-note { margin: 12px 0 18px; font-family: var(--mono); font-size: 12px; }
#g-reglement .actions .bouton { width: 100%; background: var(--encre); border-color: var(--encre); color: var(--papier); }
#g-reglement .actions .bouton:hover { background: #8A1C25; border-color: #8A1C25; }
@keyframes glisse { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 720px) {
  body { font-size: 17px; }
  .page { padding: 0 16px 60px; }
  .entete { padding: 10px 16px; }
  .cache-mobile { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html[data-level="3"] .page { transform: none; }
  #g-fantome { display: none; }
}
