/* Shared by the landing page and the game: colour tokens, the cellar's
   atmosphere (lamp, grain, vignette) and the glossary tooltip. */

:root {
  /* the cellar */
  --earth: #0d0907;        /* damp-earth black, the walls */
  --earth-2: #15100c;
  --earth-3: #1f1712;
  --line: #3a2c22;
  --bone: #dccfb8;         /* text */
  --bone-dim: #9a8c76;
  --bone-faint: #6b5f50;
  --tallow: #c9a76a;       /* lamplight, tarnished brass, coins */
  --tallow-hi: #e8c98a;
  --blood: #8e1b14;        /* debt, danger */
  --blood-hi: #d23a26;
  --phosphor: #8fd6a0;     /* the machine's screens */
  --phosphor-dim: #3c6a49;
  --bruise: #8a63c4;       /* the curse */
  --cold: #6f9fc4;         /* tickets */
  --ember: #d47a34;        /* legendary, pattern hits */

  --f-tell: 'IM Fell English', 'Nanum Myeongjo', Georgia, serif;   /* the human voice */
  --f-machine: 'VT323', 'Do Hyeon', monospace;                      /* the machine's voice */
  --f-plate: 'Silkscreen', 'Do Hyeon', monospace;                   /* labels stamped on metal */

  --dread: 0;              /* 0..1, set by the game as the floor gets closer */
}
html[lang="ko"] { --f-tell: 'Nanum Myeongjo', 'IM Fell English', serif; }

/* ---------- atmosphere ---------- */
.atmo { position: fixed; inset: 0; pointer-events: none; z-index: 65; overflow: hidden; }
.atmo i { position: absolute; display: block; }

/* the one bulb hanging over everything */
.atmo .lamp {
  inset: 0;
  background: radial-gradient(ellipse 55% 48% at 50% -6%, #f3c77a30 0%, #f3c77a12 38%, transparent 70%);
  mix-blend-mode: screen;
  animation: lamp 9s infinite;
  transition: opacity .15s;
}
@keyframes lamp {
  0%, 100% { opacity: 1; }
  41% { opacity: 1; } 42% { opacity: .35; } 43% { opacity: .9; } 44% { opacity: .2; } 46% { opacity: 1; }
  77% { opacity: .95; } 78% { opacity: .55; } 79% { opacity: 1; }
}
body.lamp-out .atmo .lamp { animation: none; opacity: 0; }
body.lamp-out .atmo .vignette { background: radial-gradient(ellipse at 50% 40%, #0008 0%, #000e 70%); }

.atmo .vignette {
  inset: 0;
  background: radial-gradient(ellipse 80% 75% at 50% 42%,
    transparent calc(52% - var(--dread) * 26%),
    rgba(4, 2, 1, calc(.55 + var(--dread) * .3)) 92%);
  transition: background 2s;
}
/* film grain: tiny noise tile jumping around */
.atmo .grain {
  inset: -60%;
  opacity: calc(.075 + var(--dread) * .05);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%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 .95 0 0 0 0 .85 0 0 0 1.6 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain .9s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 17% { transform: translate(-7%, 4%); } 33% { transform: translate(5%, -9%); }
  50% { transform: translate(-11%, 8%); } 67% { transform: translate(9%, 2%); } 83% { transform: translate(-3%, -6%); }
}

/* ---------- glossary terms and their tooltip ---------- */
[data-term] { cursor: help; }
.term {
  text-decoration: underline dotted;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.term:hover { text-decoration-color: currentColor; }
[data-term]:focus-visible { outline: 2px solid var(--tallow); outline-offset: 2px; border-radius: 3px; }

#tip {
  position: fixed; z-index: 90; left: 0; top: 0;
  max-width: min(330px, calc(100vw - 24px));
  padding: 9px 13px 11px;
  background: #0b0806f5;
  border: 1px solid #5a4632;
  border-left: 3px solid var(--tallow);
  border-radius: 3px;
  box-shadow: 0 14px 30px #000c, 0 0 0 1px #000;
  color: var(--bone);
  pointer-events: none;
  opacity: 0; transform: translateY(3px);
  transition: opacity .12s, transform .12s;
  text-align: left;
}
#tip.on { opacity: 1; transform: none; }
#tip.pinned { pointer-events: auto; }
#tip img.art { height: 1.05em; vertical-align: -0.18em; image-rendering: pixelated; }
#tip .tt { display: block; font-family: var(--f-tell); font-size: 19px; line-height: 1.2; color: var(--tallow-hi); }
#tip .ts { display: block; font-family: var(--f-machine); font-size: 17px; line-height: 1.1; color: var(--phosphor); margin-top: 2px; }
#tip .tb { display: block; font-family: var(--f-tell); font-size: 16px; line-height: 1.4; color: var(--bone); margin-top: 5px; }
html[lang="ko"] #tip .tb { font-size: 15px; line-height: 1.55; word-break: keep-all; }
html[lang="ko"] #tip .tt { font-size: 17px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .atmo .lamp, .atmo .grain { animation: none; }
}
