/* abdullahijaz.me — one dark room. Layers, back to front:
   fog (WebGL) · vignette · skull (WebGL, lit by the lantern) · wall (faint writing)
   · lit (the same wall, bright, masked by the lantern) · whispers · echo · grain · sill (footer).
   site.js clones .wall into .lit and moves the lantern. */

@font-face {
  font-family: "Cormorant";
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url(../fonts/cormorant-garamond-latin-300-italic.woff2) format("woff2");
}
@font-face {
  font-family: "Cormorant";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/cormorant-garamond-latin-400-italic.woff2) format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(../fonts/geist-mono-latin.woff2) format("woff2");
}

:root {
  --bg: #050506;
  --ink: 222 228 238;
  --wall: rgb(var(--ink) / .1);
  --lit: rgb(var(--ink) / .94);
  --glow: 0 0 18px rgb(186 202 228 / .38);
  --serif: "Cormorant", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  /* skull canvas height; the canvas is 4:5 and the skull itself fills about .6 x .9 of it */
  --sk: clamp(220px, 58vh, 640px);
  color-scheme: dark;
}
@media (max-width: 640px) {
  :root { --sk: min(46vh, 100vw); }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  color: rgb(var(--ink) / .8);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: pinch-zoom;
  -webkit-tap-highlight-color: transparent;
}

/* fog */
.fog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  opacity: 0;
  transition: opacity 2.4s ease;
}
.gl .fog { opacity: 1; }
.no-gl body {
  background:
    radial-gradient(ellipse 70% 50% at 30% 80%, rgb(120 132 150 / .07), transparent 70%),
    radial-gradient(ellipse 60% 45% at 75% 30%, rgb(120 132 150 / .05), transparent 70%),
    var(--bg);
}

/* vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse 85% 75% at 50% 46%, transparent 45%, rgb(0 0 0 / .72) 100%);
}

/* the wall */
.room, .wall, .lit {
  position: fixed;
  inset: 0;
}
.room { z-index: 2; }
.wall { margin: 0; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* the skull: drawn on .skull; .skull-spot keeps its place on the wall (lines and whispers stay clear of it)
   and shows a still picture of it when WebGL is missing (.no-skull, set by site.js) */
.skull, .skull-spot {
  position: absolute;
  left: 50%;
  top: 46%;
  translate: -50% -50%;
}
.skull {
  position: fixed;
  z-index: 2;
  height: var(--sk);
  width: calc(var(--sk) * .8);
  pointer-events: none;
}
.skull-spot {
  height: calc(var(--sk) * .9);
  width: calc(var(--sk) * .6);
}
.no-skull .skull { display: none; }
.no-skull .skull-spot {
  background: url(../img/skull.png) center / contain no-repeat;
}
.no-skull .room .skull-spot {
  opacity: .22;
  animation: breathe 9s ease-in-out infinite;
  @media (prefers-reduced-motion: reduce) { animation: none; }
}
@keyframes breathe {
  50% { opacity: .13; }
}

.frag {
  position: absolute;
  left: var(--x);
  top: var(--y);
  max-width: var(--w, 22ch);
  margin: 0;
  rotate: var(--r, 0deg);
  font: italic 300 clamp(17px, 1.55vw, 23px)/1.28 var(--serif);
  color: var(--wall);
}
.frag.small { font-size: clamp(15px, 1.2vw, 18px); }
.mono {
  font-family: var(--mono);
  font-style: normal;
  font-weight: 450;
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.frag .mono {
  display: block;
  margin-bottom: .8em;
}
.tally svg {
  display: block;
  height: 30px;
  width: auto;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

@media (max-width: 640px) {
  .frag {
    left: var(--mx, var(--x));
    top: var(--my, var(--y));
    max-width: var(--mw, 16ch);
  }
  .frag.wide, .frag.narrow { display: none; }
  .tally svg { height: 24px; }
}
@media (max-height: 520px) and (min-width: 641px) {
  .frag.wide, .frag.tall { display: none; }
}

/* the same wall, lit: only visible inside the lantern */
.lit {
  z-index: 3;
  pointer-events: none;
  opacity: var(--li, 0);
  --lx: 50vw;
  --ly: 60vh;
  --lr: 220px;
  -webkit-mask-image: radial-gradient(circle var(--lr) at var(--lx) var(--ly), #000 0, rgb(0 0 0 / .72) 34%, rgb(0 0 0 / .22) 66%, transparent 100%);
  mask-image: radial-gradient(circle var(--lr) at var(--lx) var(--ly), #000 0, rgb(0 0 0 / .72) 34%, rgb(0 0 0 / .22) 66%, transparent 100%);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.lit .frag {
  color: var(--lit);
  text-shadow: var(--glow);
}
.no-gl .lit {
  background: radial-gradient(circle var(--lr) at var(--lx) var(--ly), rgb(150 165 190 / .12), transparent 72%);
}

/* lines that write themselves */
.whispers {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
.whisper {
  position: absolute;
  margin: 0;
  white-space: nowrap;
  font: italic 400 clamp(16px, 1.35vw, 20px)/1.2 var(--serif);
  color: rgb(var(--ink) / .62);
  text-shadow: 0 0 14px rgb(186 202 228 / .28);
  transition: opacity 2.6s ease, filter 2.6s ease, translate 2.6s ease;
}
.whisper span {
  opacity: 0;
  filter: blur(3px);
  transition: opacity .9s ease, filter .9s ease;
}
.whisper span.on {
  opacity: 1;
  filter: blur(0);
}
.whisper.gone {
  opacity: 0;
  filter: blur(5px);
  translate: 0 -8px;
}

/* the other cursor */
.echo {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 5;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgb(226 234 246 / .55), rgb(226 234 246 / .12) 45%, transparent 70%);
  opacity: 0;
  transition: opacity 1.2s ease;
  will-change: transform;
}
.echo.on { opacity: 1; }

/* film grain */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 6;
  pointer-events: none;
  opacity: .075;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.25 -.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
  @media (prefers-reduced-motion: reduce) { animation: none; }
}
@keyframes grain {
  0% { translate: 0 0; }
  17% { translate: -3% 2%; }
  33% { translate: 2% -4%; }
  50% { translate: -5% -1%; }
  67% { translate: 4% 3%; }
  83% { translate: -1% 5%; }
  100% { translate: 0 0; }
}

/* the sill */
.sill {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 450;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgb(var(--ink) / .36);
}
.clock {
  font-variant-numeric: tabular-nums;
  min-width: 9ch;
}
.right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.here {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px;
}
.here b {
  font-weight: inherit;
  display: inline-block;
  min-width: 1ch;
  text-align: center;
}
.here i, .sound i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgb(var(--ink) / .55);
}
.here i {
  animation: pulse 4.2s ease-in-out infinite;
  @media (prefers-reduced-motion: reduce) { animation: none; }
}
@keyframes pulse {
  50% { opacity: .25; }
}
.sound {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  transition: color .3s ease;
}
.sound i {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgb(var(--ink) / .5);
  transition: background .3s ease, box-shadow .3s ease;
}
.sound:hover { color: rgb(var(--ink) / .7); }
.sound[aria-pressed="true"] { color: rgb(var(--ink) / .72); }
.sound[aria-pressed="true"] i {
  background: rgb(var(--ink) / .85);
  box-shadow: 0 0 8px rgb(186 202 228 / .6);
}
.sound:focus-visible {
  outline: 1px solid rgb(var(--ink) / .6);
  outline-offset: 2px;
}
html:not(.js) .sound { display: none; }

/* 404 */
.lost {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
}
.lost h1 {
  margin: 0;
  font: italic 300 clamp(34px, 6vw, 72px)/1.05 var(--serif);
  color: rgb(var(--ink) / .5);
  text-shadow: var(--glow);
}
.lost .mono { color: rgb(var(--ink) / .32); }
.lost a {
  color: rgb(var(--ink) / .55);
  text-decoration: none;
  padding: 12px 8px;
  border-radius: 4px;
}
.lost a:hover { color: rgb(var(--ink) / .85); }
.lost a:focus-visible {
  outline: 1px solid rgb(var(--ink) / .6);
  outline-offset: 2px;
}
