/* Midnight Shlice — artist page. Concept: a midnight jazz LP.
   Front cover = hero. Scroll flips the record. Back cover = tracklist of links. */

@font-face {
  font-family: "Fraunces";
  src: url("../assets/fonts/fraunces.woff2") format("woff2");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../assets/fonts/fraunces-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --gold: #e8c778;
  --gold-dim: #b99a52;
  --ink: #f4f1e9;
  --muted: #9aa3ad;
  --bg0: #0a0e17;
  --bg1: #111a2b;
  --line: rgba(232, 199, 120, .18);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --hero-grade: saturate(1.2) contrast(1.06) brightness(1.06);
  /* film grain: inline SVG turbulence, tiled */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%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 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.10'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg0);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- FRONT COVER ---------- */

.hero {
  position: sticky;
  top: 0;
  height: 100vh;
  /* svh, not dvh: iOS toolbar collapse changes dvh mid-scroll, which would
     shift the sticky region and the dissolve's progress denominator */
  height: 100svh;
  overflow: hidden;
  z-index: 1;
}

.hero-media { position: absolute; inset: 0; background: var(--bg0); }

/* poster paints instantly (39KB) while the full hero jpeg streams in.
   It lives on ::before (below img/canvas) and MUST disappear once a live
   layer owns the hero — dissolved shader cells are transparent, and
   anything behind them shows through the flip effect. */
.hero-media::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/poster-portrait.20260810.jpg") 55% 50% / cover no-repeat;
  filter: var(--hero-grade);
}
/* html.static keeps the poster: its img is always fully opaque (no fade
   loop), so nothing can bleed through, and slow reduced-motion loads get
   the 39KB fast paint instead of flat navy */
@media (orientation: landscape) {
  .hero-media::before { background-image: url("../assets/poster.20260810.jpg"); }
}

html.webgl-on .hero-media::before,
html.no-webgl.hero-loaded .hero-media::before { display: none; }
/* (no-webgl WITHOUT hero-loaded keeps the poster: if the big image is slow
   or broken, the 39KB poster is the hero — never a blank gradient) */

.hero-media :is(img, video),
.hero-media canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: var(--hero-grade);
}

/* focal point: Chefchaouen loop: 55% keeps the man in frame in both crops */
.hero-media :is(img, video) { object-fit: cover; object-position: 55% 50%; }
/* canvas is always laid out (never display:none before init — it must have
   a measurable size when WebGL sizes its buffer); transparent until drawn */
html.webgl-on .hero-media :is(img, video) { visibility: hidden; }
html.no-webgl .hero-media canvas { display: none; }

/* grade + atmosphere above image AND canvas */
.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    var(--grain) repeat,
    radial-gradient(125% 95% at 50% 25%, transparent 68%, rgba(10, 14, 23, .16) 100%),
    linear-gradient(180deg, rgba(10, 14, 23, .12) 0%, transparent 22%, transparent 64%, rgba(10, 14, 23, .78) 100%),
    linear-gradient(200deg, rgba(232, 199, 120, .04), transparent 40%);
  background-blend-mode: overlay, normal, normal, normal;
  pointer-events: none;
}

.hero-text {
  text-shadow: 0 2px 20px rgba(6, 9, 16, .8), 0 1px 3px rgba(6, 9, 16, .5);
  position: absolute;
  left: clamp(20px, 6vw, 84px);
  bottom: clamp(72px, 14vh, 128px);
  max-width: min(88vw, 720px);
  will-change: transform, opacity;
}

.eyebrow {
  font-size: clamp(11px, 1.2vw, 13px);
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
  animation: rise .9s cubic-bezier(.2, .7, .2, 1) both .15s;
}

h1 {
  font-weight: 340;
  font-size: clamp(46px, 10.5vw, 118px);
  line-height: .98;
  letter-spacing: .01em;
  font-variation-settings: "opsz" 144;
  animation: rise 1s cubic-bezier(.2, .7, .2, 1) both .3s;
}

h1 i {
  color: var(--gold);
  font-style: italic;
  font-weight: 420;
}

.tagline {
  margin-top: 16px;
  font-size: clamp(14px, 1.6vw, 17px);
  font-style: italic;
  color: var(--muted);
  letter-spacing: .04em;
  animation: rise 1s cubic-bezier(.2, .7, .2, 1) both .5s;
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 26px 10px;
  border-radius: 999px;
  text-decoration: none;
  font-size: clamp(13px, 1.35vw, 16px);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(10, 14, 23, .32);
  border: 1px solid rgba(232, 199, 120, .3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-shadow: 0 2px 14px rgba(0, 0, 0, .75);
  animation: rise 1s ease both 1.1s;
  transition: background-color .3s ease, border-color .3s ease, transform .3s ease;
}

.scroll-cue:hover,
.scroll-cue:focus-visible {
  background: rgba(232, 199, 120, .12);
  border-color: var(--gold);
  transform: translateX(-50%) translateY(-3px);
}

.cue-line {
  width: 2px;
  height: 26px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--gold), transparent);
  animation: drip 2.2s ease-in-out infinite;
  transform-origin: top;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes drip {
  0%, 100% { transform: scaleY(.35); opacity: .5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* No Ken Burns zoom: the hero is a video and carries its own motion.
   (The old "breathe" animation was for a still hero and cropped the video.) */

/* ---------- BACK COVER ---------- */

.links {
  position: relative;
  z-index: 2;
  background:
    var(--grain) repeat,
    radial-gradient(130% 80% at 78% -8%, #17223a 0%, transparent 55%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 55%, #06080e 100%);
  border-top: 1px solid var(--line);
  padding: clamp(56px, 9vh, 96px) 20px clamp(48px, 8vh, 80px);
}

.sleeve { max-width: 620px; margin: 0 auto; }

.side-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 44px 0 18px;
}

.side-head:first-child { margin-top: 0; }
.side-head span { color: var(--gold); }

.side-head::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--line);
  transform: translateY(-4px);
}

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 12px;
  margin: 0 -12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  transition:
    opacity .7s cubic-bezier(.2, .7, .2, 1),
    transform .45s cubic-bezier(.2, .7, .2, 1),
    background-color .25s ease;
  will-change: transform;
}

/* pre-entrance state exists ONLY when JS is running (html.js) — with JS
   off/blocked/crashed the links must simply be visible; :not(.is-in) keeps
   this above later class toggles without ordering games */
html.js .card:not(.is-in) { opacity: 0; transform: translateY(18px); }

/* stagger the entrance like needle-drop */
.card:nth-of-type(1) { transition-delay: .05s; }
.card:nth-of-type(2) { transition-delay: .12s; }
.card:nth-of-type(3) { transition-delay: .19s; }
.card:nth-of-type(4) { transition-delay: .06s; }
.card:nth-of-type(5) { transition-delay: .13s; }

.card:hover, .card:focus-visible { background: rgba(232, 199, 120, .06); }
.card:focus-visible { outline: 1px solid var(--gold-dim); outline-offset: 2px; }

.card.is-in:hover { transition-delay: 0s; }

.tno {
  font-size: 12px;
  font-style: italic;
  color: var(--gold-dim);
  min-width: 22px;
}

.ic {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--accent, var(--gold));
  flex: 0 0 auto;
}

.ic svg { width: 21px; height: 21px; fill: currentColor; }

.lbl { display: flex; flex-direction: column; min-width: 0; }
.lbl .p { font-size: 17px; font-weight: 460; letter-spacing: .01em; }
.lbl .s { font-size: 12px; color: var(--muted); margin-top: 2px; font-style: italic; }

/* narrow screens: drop the dotted leaders, let labels breathe */
@media (max-width: 540px) {
  /* phones: keep the cue on ONE line and clear of the tagline */
  .scroll-cue {
    bottom: 18px;
    gap: 7px;
    padding: 9px 16px 8px;
    font-size: 11px;
    letter-spacing: .12em;
  }
  .cue-line { height: 18px; }
  .hero-text { bottom: 132px; }
  .sound-btn { top: 14px; right: 14px; }

  .leader { display: none; }
  .lbl { flex: 1; }
  .lbl .s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

.leader {
  flex: 1;
  min-width: 24px;
  border-bottom: 1px dotted rgba(154, 163, 173, .4);
  transform: translateY(3px);
  transition: border-color .3s ease;
}

.card:hover .leader { border-bottom-color: var(--gold); }

.arw {
  color: var(--muted);
  font-size: 19px;
  transition: transform .3s cubic-bezier(.2, .7, .2, 1), color .3s ease;
}

.card:hover .arw { transform: translateX(5px); color: var(--gold); }

footer {
  margin-top: 64px;
  text-align: center;
}

.moon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  margin: 0 auto 18px;
  background: radial-gradient(circle at 34% 32%, #fdf6e3 0%, #f0d68a 34%, #caa24e 66%, #7c5f27 100%);
  box-shadow: 0 0 34px rgba(232, 199, 120, .4), inset -4px -5px 10px rgba(90, 64, 20, .6);
}

.liner {
  font-style: italic;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.7;
}

.colophon {
  margin-top: 18px;
  font-size: 10.5px;
  letter-spacing: .32em;
  color: var(--gold-dim);
}

/* ---------- MOTION OFF ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .card { opacity: 1; transform: none; }
  /* must out-rank the html.js entrance-hide if the OS toggles mid-session */
  html.js .card:not(.is-in) { opacity: 1; transform: none; }
  .hero { position: relative; height: 100svh; }
  html.webgl-on .hero-media canvas { display: none; }
  html.webgl-on .hero-media :is(img, video) { visibility: visible; }
}

/* JS sets html.static for the same treatment (reduced-motion or explicit) */
html.static { scroll-behavior: auto; }
html.static .hero { position: relative; }
html.static .card { opacity: 1; transform: none; transition: none; }
html.static .hero-media canvas { display: none; }
html.static .hero-media :is(img, video) { visibility: visible; animation: none; }
html.static .eyebrow, html.static h1, html.static .tagline,
html.static .scroll-cue, html.static .cue-line { animation: none; }


/* ---------- SOUND TOGGLE ---------- */

.sound-btn {
  position: absolute;
  top: clamp(16px, 3vw, 28px);
  right: clamp(16px, 3vw, 28px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(10, 14, 23, .38);
  border: 1px solid rgba(232, 199, 120, .32);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
  animation: rise .9s ease both 1.3s;
  transition: background-color .3s ease, border-color .3s ease;
}

.sound-btn:hover,
.sound-btn:focus-visible { background: rgba(232, 199, 120, .14); border-color: var(--gold); }
.sound-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.sound-ico { width: 20px; height: 20px; display: grid; place-items: center; flex: 0 0 auto; }
.sound-ico svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; grid-area: 1 / 1; }
.sound-btn .ico-on { display: none; }
.sound-btn[aria-pressed="true"] .ico-on { display: block; }
.sound-btn[aria-pressed="true"] .ico-off { display: none; }

/* the invitation shows once, then the button shrinks to just the icon */
.sound-label { white-space: nowrap; }
.sound-btn.is-quiet { gap: 0; padding: 12px; }
.sound-btn.is-quiet .sound-label {
  width: 0; overflow: hidden; opacity: 0;
  transition: width .4s ease, opacity .3s ease;
}

@media (max-width: 540px) {
  .sound-btn { font-size: 11px; padding: 9px 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .sound-btn { animation: none; }
}
