/* Melancholly: "soft, then tilts", dealt from a deck.
   The page starts pale (pearl) and falls into night (the plum-black of the sigil) as you scroll.
   site.js drives --bg and the .night class; pages that live in the dark set class="night" on <html>. */

:root {
  --pearl: #efe8ea;
  --rose: #c9a3ad;
  --oxblood: #6b1426;
  --ember: #c8323f;
  --ink: #170512;
  --bone: #ece2e6;

  --bg: var(--pearl);
  --fg: var(--ink);
  --muted: rgba(23, 5, 18, 0.66);
  --line: rgba(23, 5, 18, 0.16);
  --accent: var(--oxblood);

  --display: "Bodoni Moda", "Bodoni 72", Didot, serif;
  --text: "Hanken Grotesk", system-ui, sans-serif;

  --measure: 34rem;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --ease: cubic-bezier(.2, .7, .1, 1);
}

html.night {
  --fg: var(--bone);
  --muted: rgba(236, 226, 230, 0.68);
  --line: rgba(236, 226, 230, 0.16);
  --accent: #e0707c;
}
html.night:not(.dusk) { --bg: var(--ink); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--text);
  font-size: clamp(1rem, .95rem + .2vw, 1.125rem);
  line-height: 1.6;
  transition: color .5s ease;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
p { margin: 0 0 1em; max-width: var(--measure); }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1.02; letter-spacing: -0.01em; }
::selection { background: var(--ember); color: var(--pearl); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--bg); padding: .5rem 1rem; }

/* ---------- Navigation ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem var(--gutter);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font-family: var(--display); font-size: 1.25rem; font-style: italic; }
.sigil {
  display: inline-block; width: 1.1rem; height: 1.9rem; background: currentColor;
  -webkit-mask: url(/img/sigil-white.png) center / contain no-repeat;
          mask: url(/img/sigil-white.png) center / contain no-repeat;
}
.nav ul { display: flex; gap: clamp(1rem, 3vw, 2.25rem); list-style: none; margin: 0; padding: 0; }
.nav ul a { text-decoration: none; font-size: .95rem; padding: .25rem 0; border-bottom: 1px solid transparent; transition: border-color .2s; }
.nav ul a:hover, .nav ul a[aria-current="page"] { border-bottom-color: currentColor; }

/* ---------- Hero ---------- */
.hero {
  min-height: 100svh;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: center; gap: var(--gutter);
  padding: 7rem var(--gutter) 4rem;
}
.hero h1 {
  font-size: clamp(3.4rem, 9.2vw, 10rem);
  font-style: italic; letter-spacing: -0.035em; line-height: .9;
  margin-left: -0.04em;
}
.hero .lede { font-size: clamp(1.1rem, 1rem + .6vw, 1.5rem); line-height: 1.45; margin-top: 2rem; max-width: 26rem; color: var(--muted); }
.hero-card { justify-self: center; width: min(100%, 25rem); perspective: 1200px; }
.hero-card .playing-card { transform: rotate(var(--tilt, -6deg)) translateY(var(--lift, 0)); transition: transform .2s linear; }

/* A playing card */
.playing-card {
  position: relative; aspect-ratio: 5 / 7; border-radius: 1.1rem; overflow: hidden;
  background: var(--ink);
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 30px 60px -20px rgba(23,5,18,.55), 0 12px 24px -12px rgba(23,5,18,.4);
}
.playing-card img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Sections ---------- */
.section { padding: clamp(5rem, 12vw, 10rem) var(--gutter); }
.section-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gutter); align-items: end; margin-bottom: clamp(3rem, 6vw, 5rem); }
.section-head h2 { font-size: clamp(2.6rem, 6vw, 5.5rem); font-style: italic; letter-spacing: -0.02em; }
.section-head p { margin: 0; color: var(--muted); }
.epigraph { margin: 0; font-family: var(--display); font-style: italic; font-size: clamp(1.1rem, 1rem + .5vw, 1.4rem); }
.epigraph cite { display: block; font-family: var(--text); font-style: normal; font-size: .9rem; color: var(--muted); margin-top: .35rem; }

/* ---------- The deck ---------- */
.deck {
  --w: clamp(12rem, 21vw, 17.5rem);
  --step: calc(var(--w) * .84);
  display: flex; justify-content: center; list-style: none; margin: 0 auto; padding: 2rem 0 3rem;
}
.deck > li { width: var(--w); flex: none; margin-left: calc(var(--step) - var(--w)); position: relative; z-index: calc(var(--i) + 1); }
.deck > li:first-child { margin-left: 0; }
.deck .card {
  display: block; text-decoration: none; color: var(--bone);
  transform-origin: 50% 120%;
  transform: translateY(var(--y)) rotate(var(--r));
  transition: transform .6s var(--ease);
}
.deck > li:nth-child(1) { --r: -12deg; --y: 2.2rem; }
.deck > li:nth-child(2) { --r: -4deg;  --y: 0rem; }
.deck > li:nth-child(3) { --r: 4deg;   --y: 0rem; }
.deck > li:nth-child(4) { --r: 12deg;  --y: 2.2rem; }

/* Deal: the hand starts as one stacked pile, then fans out once */
.js .deck:not(.is-dealt) .card { transform: translateX(calc((1.5 - var(--i)) * var(--step))) translateY(1rem) rotate(0deg); }
.js .deck.is-dealt > li .card { transition-delay: calc(var(--i) * 70ms); }
.js .deck.is-dealt.settled > li .card { transition-delay: 0ms; }

.deck a.card:hover, .deck a.card:focus-visible { transform: translateY(calc(var(--y) - 2.25rem)) rotate(calc(var(--r) * .35)); }
.deck > li:has(a.card:hover), .deck > li:has(a.card:focus-visible) { z-index: 10; }
.deck a.card:focus-visible { outline-offset: 6px; border-radius: 1.2rem; }

.card .playing-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(23,5,18,0) 35%, rgba(23,5,18,.92) 100%);
}
.card .face { position: absolute; inset: auto 0 0 0; z-index: 1; padding: 1.25rem 1.25rem 1.4rem; }
.deck > li:not(:last-child) .face { padding-right: calc(var(--w) - var(--step) + .75rem); }
.card .face h3 { font-size: clamp(1.4rem, 1.1rem + .9vw, 1.9rem); font-style: italic; }
.card .face p { font-size: .9rem; line-height: 1.4; margin: .5rem 0 0; color: rgba(236,226,230,.8); }
.card .index {
  position: absolute; top: .8rem; left: .95rem; z-index: 1;
  font-family: var(--display); font-size: 1.35rem; line-height: 1; text-align: center; color: var(--bone);
  padding: .45rem .5rem .4rem; border-radius: .6rem; background: rgba(23,5,18,.62);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.card .index span { display: block; font-size: 1.1rem; margin-top: .1rem; }
.card.red .index { color: #ff8f99; }
.card.back .playing-card::after { display: none; }
.card.back .face { text-align: center; }
.card.back .face p { color: rgba(236,226,230,.7); }

/* ---------- Stories ---------- */
.stories { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.story {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--gutter); align-items: baseline;
  padding: clamp(1.4rem, 3vw, 2.25rem) 0; border-bottom: 1px solid var(--line);
}
.story h3 { font-size: clamp(1.9rem, 4.2vw, 3.8rem); font-style: italic; letter-spacing: -0.02em; transition: transform .5s var(--ease), color .3s; }
.story p { margin: 0; color: var(--muted); }
.story figure { margin: 0; }
.story img { border-radius: .8rem; }

@media (hover: hover) and (min-width: 900px) {
  .story figure {
    position: absolute; right: 2%; top: 50%; width: 19rem; z-index: 5; pointer-events: none;
    opacity: 0; transform: translateY(-45%) rotate(5deg) scale(.92);
    transition: opacity .35s ease, transform .5s var(--ease);
  }
  .story figure img { box-shadow: 0 30px 60px -20px rgba(0,0,0,.7); }
  .story:hover figure { opacity: 1; transform: translateY(-50%) rotate(-3deg) scale(1); }
  .story:hover h3 { transform: translateX(.6rem); color: var(--accent); }
  .story:hover p { opacity: .35; }
}
@media (hover: none), (max-width: 899px) {
  .story { grid-template-columns: 1fr; gap: .75rem; }
  .story figure { order: -1; }
  .story img { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
}

/* ---------- About teaser / about page ---------- */
.split { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: clamp(2rem, 6vw, 6rem); align-items: center; }
.split .playing-card { max-width: 22rem; transform: rotate(-3deg); }
.split h2 { font-size: clamp(2.4rem, 5vw, 4.5rem); font-style: italic; margin-bottom: 1.5rem; }
.text-link { display: inline-block; margin-top: .75rem; font-weight: 500; text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: .1rem; }
.text-link:hover { color: var(--accent); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .6rem 2rem; margin: 2.5rem 0 0; max-width: var(--measure); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- Darkstone ---------- */
.ds-hero {
  position: relative; min-height: 92svh; display: grid; align-items: end;
  padding: 8rem var(--gutter) clamp(3rem, 8vw, 6rem); overflow: hidden; isolation: isolate;
}
.ds-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; opacity: .55; transform: scale(1.06); }
.ds-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(23,5,18,.35) 0%, rgba(23,5,18,.2) 40%, var(--ink) 100%); }
.ds-hero h1 { font-size: clamp(3rem, 10vw, 9.5rem); font-style: italic; letter-spacing: -0.035em; line-height: .92; max-width: 12ch; }
.ds-hero .lede { font-family: var(--display); font-style: italic; font-size: clamp(1.3rem, 1rem + 1.4vw, 2.2rem); margin: 1.5rem 0 0; max-width: none; }

.lore { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--gutter); }
.lore li { border-top: 1px solid var(--line); }
.lore a { display: block; padding: 1.6rem 0 1.9rem; text-decoration: none; }
.lore h3 { font-size: clamp(1.6rem, 2.6vw, 2.4rem); font-style: italic; transition: color .25s, transform .5s var(--ease); }
.lore .sub { display: block; margin-top: .4rem; font-weight: 500; }
.lore p { margin: .5rem 0 0; color: var(--muted); }
.lore a:hover h3, .lore a:focus-visible h3 { color: var(--accent); transform: translateX(.5rem); }

.map { margin: 0; }
.map img { border-radius: 1rem; width: 100%; }
.map figcaption { color: var(--muted); margin-top: .9rem; font-size: .95rem; }

/* ---------- Footer ---------- */
.footer { padding: clamp(4rem, 10vw, 7rem) var(--gutter) 2.5rem; display: grid; grid-template-columns: auto 1fr auto; gap: 1.5rem 3rem; align-items: end; }
.footer .sigil { width: 2.6rem; height: 4.4rem; }
.footer ul { display: flex; gap: 1.5rem; list-style: none; margin: 0; padding: 0; }
.footer small { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; max-width: 46rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 6.5rem; min-height: auto; }
  .hero-card { width: min(70%, 19rem); margin-top: 1rem; }
  .section-head, .split { grid-template-columns: 1fr; }
  .split .playing-card { max-width: 16rem; }
  .lore { grid-template-columns: 1fr; }
  .footer { grid-template-columns: auto 1fr; }
  .footer ul { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .brand span { display: none; }
  .deck {
    --w: min(68vw, 16rem);
    justify-content: flex-start; overflow-x: auto; scroll-snap-type: x mandatory;
    gap: 1.25rem; padding: 2.5rem var(--gutter) 3rem; margin: 0 calc(var(--gutter) * -1);
    scrollbar-width: none;
  }
  .deck::-webkit-scrollbar { display: none; }
  .deck > li { margin-left: 0 !important; scroll-snap-align: center; }
  .deck > li .face { padding-right: 1.25rem !important; }
  .deck > li:nth-child(odd) { --r: -2.5deg; --y: 0rem; }
  .deck > li:nth-child(even) { --r: 2.5deg; --y: .75rem; }
  .js .deck:not(.is-dealt) .card { transform: translateY(1.5rem) rotate(0deg); opacity: 0; }
  .deck .card { transition: transform .6s var(--ease), opacity .6s ease; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
  .hero-card .playing-card { transform: rotate(-6deg) !important; }
}
