/* ═══════════ tokens ═══════════ */
:root {
  --night: #0b1410;      /* green-tinted forest night */
  --moss: #16241c;
  --ink: #f2dfa9;        /* candlelit parchment */
  --ink-dim: #b7a878;
  --gold: #e8b84b;
  --gold-bright: #f6d47c;
  --plum: #7c3b5e;
  --teal: #3e7c7b;
  --line: rgba(232, 184, 75, 0.18);
  /* contribution ramp — sequential, one hue, dark→light (validated) */
  --c0: #182420;
  --c1: #54431c;
  --c2: #8a6a24;
  --c3: #c39a35;
  --c4: #f2c95c;
  --display: "Cinzel Decorative", serif;
  --body: "Cormorant Garamond", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--night);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.25rem;
  line-height: 1.55;
  overflow-x: hidden;
  /* the wand: handle to the lower right, casting tip at the star */
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='30' height='30'><line x1='9' y1='9' x2='27' y2='27' stroke='%235a3d22' stroke-width='4' stroke-linecap='round'/><line x1='9' y1='9' x2='27' y2='27' stroke='%23916b3d' stroke-width='1.8' stroke-linecap='round'/><path d='M7 0L8.6 5.4L14 7L8.6 8.6L7 14L5.4 8.6L0 7L5.4 5.4Z' fill='%23ffdf8e'/></svg>") 7 7, crosshair;
}
body:not(.entered) { overflow: hidden; }

a, button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 2px; }
::selection { background: var(--plum); color: var(--ink); }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ═══════════ shared type ═══════════ */
.eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--teal);
  margin-bottom: 1.4rem;
}

h1, h2 {
  font-family: var(--display);
  font-weight: 700;
  color: var(--gold-bright);
  text-wrap: balance;
}

h2 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.12; margin-bottom: 1.6rem; }

.lede { max-width: 34em; color: var(--ink); }
.lede + .lede { margin-top: 1rem; }

/* ═══════════ intro gate ═══════════ */
#intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.1rem;
  padding: 2rem;
  background: radial-gradient(ellipse at 50% 60%, #11201a, var(--night) 78%);
  transition: opacity 0.9s ease, visibility 0.9s;
}
#intro.gone { opacity: 0; visibility: hidden; pointer-events: none; }

.intro-name {
  font-size: clamp(2.6rem, 9vw, 6rem);
  font-weight: 900;
  line-height: 1.05;
  text-shadow: 0 0 34px rgba(232, 184, 75, 0.35);
}
.intro-sub { font-family: var(--mono); font-size: 0.9rem; letter-spacing: 0.28em; color: var(--ink-dim); text-transform: uppercase; }
.intro-hint { font-style: italic; color: var(--ink-dim); font-size: 1rem; margin-top: 1.2rem; }

#enter {
  margin-top: 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  background: none;
  border: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.14em;
}
#enter .seal {
  display: grid;
  place-items: center;
  width: 5.2rem;
  height: 5.2rem;
  border-radius: 50%;
  font-size: 1.9rem;
  color: var(--night);
  background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold) 55%, #9c7526);
  box-shadow: 0 0 30px rgba(232, 184, 75, 0.45), inset 0 -4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
#enter:hover .seal, #enter:focus-visible .seal {
  transform: scale(1.08) rotate(8deg);
  box-shadow: 0 0 55px rgba(246, 212, 124, 0.75), inset 0 -4px 10px rgba(0, 0, 0, 0.35);
}

/* ═══════════ sound toggle ═══════════ */
#sound {
  position: fixed;
  top: 1.1rem;
  right: 1.2rem;
  z-index: 5;
  background: rgba(11, 20, 16, 0.55);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  padding: 0.45rem 0.9rem;
  backdrop-filter: blur(6px);
}
#sound:hover { color: var(--gold); border-color: var(--gold); }

/* ═══════════ acts ═══════════ */
main { position: relative; z-index: 1; pointer-events: none; }

.act {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: clamp(1.4rem, 5vw, 5rem);
}

.act-copy { max-width: 36rem; min-width: 0; }
.act-copy.wide { max-width: 52rem; }
.act-copy.center { margin-inline: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }

/* content itself is interactive again */
.act a, .act button, .act .card, .act .contrib-grid, .act .spells { pointer-events: auto; }

#act-wizard { justify-content: flex-start; }
#act-wizard .act-copy {
  background: linear-gradient(115deg, rgba(11, 20, 16, 0.72), rgba(11, 20, 16, 0.15));
  border-left: 1px solid var(--line);
  padding: 2rem 2.4rem;
  border-radius: 4px;
}
#act-spells { justify-content: flex-end; }
#act-book { justify-content: center; }

.cast-hint { font-family: var(--mono); font-size: 0.75rem; color: var(--teal); margin-top: 2rem; letter-spacing: 0.1em; }

.fallback-portrait { display: none; max-width: min(320px, 70vw); border: 3px solid var(--gold); border-radius: 4px; margin-top: 1.6rem; }
.no-webgl .fallback-portrait { display: block; }
.no-webgl #scene { display: none; }
.no-webgl body, .no-webgl { background: radial-gradient(ellipse at 50% 20%, #14251d, var(--night) 70%); }

/* ═══════════ spells (chapter ii) ═══════════ */
.spells { list-style: none; display: flex; flex-direction: column; gap: 0.15rem; }
.spell {
  display: grid;
  grid-template-columns: 2.6rem 15rem 1fr;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  transition: background 0.3s ease;
}
.spell:hover { background: rgba(232, 184, 75, 0.06); }
.spell .rune { font-size: 1.5rem; color: var(--gold); font-weight: 400; text-shadow: 0 0 12px rgba(232, 184, 75, 0.6); }
.spell code { font-family: var(--mono); font-size: 0.92rem; color: var(--gold-bright); }
.spell span { font-style: italic; color: var(--ink-dim); }

/* ═══════════ spellbook (chapter iii) ═══════════ */
#repos { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-bottom: 3rem; }
#repos .loading, .empty { font-style: italic; color: var(--ink-dim); }

.card {
  display: block;
  pointer-events: auto;
  text-decoration: none;
  color: var(--ink);
  background: linear-gradient(160deg, rgba(38, 32, 22, 0.85), rgba(20, 24, 20, 0.85));
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.2rem 1.3rem;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 8px 30px rgba(232, 184, 75, 0.15);
}
.card h3 { font-family: var(--mono); font-size: 0.95rem; font-weight: 500; color: var(--gold-bright); margin-bottom: 0.5rem; overflow-wrap: anywhere; }
.card p { font-size: 1.05rem; color: var(--ink-dim); min-height: 2.6em; }
.card footer { display: flex; gap: 1rem; margin-top: 0.9rem; font-family: var(--mono); font-size: 0.72rem; color: var(--teal); }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 2.4rem 1rem; border: 1px dashed var(--line); border-radius: 4px; background: rgba(11, 20, 16, 0.55); }
.empty-state p { font-style: italic; color: var(--ink-dim); margin-bottom: 1.4rem; }

/* ═══════════ contribution heatmap ═══════════ */
#contrib h3 { font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: var(--gold-bright); margin-bottom: 1rem; }
#contrib h3 b { color: var(--gold); }

.contrib-grid {
  max-width: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 10px);
  grid-auto-columns: 10px;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 0.6rem;
}
.contrib-grid span { border-radius: 2px; background: var(--c0); }
.contrib-grid span[data-level="1"] { background: var(--c1); }
.contrib-grid span[data-level="2"] { background: var(--c2); }
.contrib-grid span[data-level="3"] { background: var(--c3); box-shadow: 0 0 6px rgba(232, 184, 75, 0.35); }
.contrib-grid span[data-level="4"] { background: var(--c4); box-shadow: 0 0 8px rgba(246, 212, 124, 0.55); }
.contrib-caption { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-dim); letter-spacing: 0.06em; }

/* ═══════════ buttons & footer ═══════════ */
.btn-gold {
  display: inline-block;
  margin-top: 1.6rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--night);
  background: linear-gradient(120deg, var(--gold-bright), var(--gold));
  padding: 0.9rem 1.9rem;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 0 26px rgba(232, 184, 75, 0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.btn-gold:hover { transform: translateY(-3px); box-shadow: 0 6px 44px rgba(246, 212, 124, 0.6); }

.btn-row { display: flex; gap: 1rem; margin-top: 1.6rem; flex-wrap: wrap; justify-content: center; }
.btn-row .btn-gold { margin-top: 0; }
.btn-ghost {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  border: 1px solid var(--line);
  padding: 0.9rem 1.9rem;
  border-radius: 999px;
  text-decoration: none;
  transition: border-color 0.3s ease, transform 0.3s ease;
}
.btn-ghost:hover { border-color: var(--gold); transform: translateY(-3px); }

#act-owl footer { margin-top: 5rem; font-family: var(--mono); font-size: 0.72rem; color: var(--ink-dim); letter-spacing: 0.08em; }

/* ═══════════ scroll reveal (js-enhanced) ═══════════ */
.js .act-copy > * { opacity: 0; transform: translateY(26px); transition: opacity 0.9s ease, transform 0.9s ease; }
.js .act.in .act-copy > * { opacity: 1; transform: none; }
.js .act.in .act-copy > *:nth-child(2) { transition-delay: 0.12s; }
.js .act.in .act-copy > *:nth-child(3) { transition-delay: 0.24s; }
.js .act.in .act-copy > *:nth-child(4) { transition-delay: 0.36s; }
.js .act.in .act-copy > *:nth-child(5) { transition-delay: 0.48s; }

/* ═══════════ small screens ═══════════ */
@media (max-width: 720px) {
  body { font-size: 1.1rem; }
  .spell { grid-template-columns: 2rem 1fr; }
  .spell span { grid-column: 2; }
  .act-copy { background: rgba(11, 20, 16, 0.62); padding: 1.4rem 1.2rem; border-radius: 6px; }
  #act-wizard .act-copy { background: linear-gradient(115deg, rgba(11, 20, 16, 0.8), rgba(11, 20, 16, 0.5)); }
}

/* ═══════════ reduced motion ═══════════ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .act-copy > * { transition: none; opacity: 1; transform: none; }
  #intro { transition: none; }
  .card, .btn-gold, #enter .seal { transition: none; }
}

/* ═══════════ the animated spellbook (chapter ii) ═══════════ */
.act-copy.book-wide { max-width: 58rem; }

.book {
  position: relative;
  width: min(52rem, 100%);
  aspect-ratio: 13 / 9;
  margin-top: 0.6rem;
  perspective: 2600px;
  pointer-events: auto;
  cursor: pointer;
  transform: translateX(-25%); /* closed: the cover sits centred */
  transition: transform 1.1s cubic-bezier(0.6, 0.05, 0.3, 1);
  filter: drop-shadow(0 26px 42px rgba(0, 0, 0, 0.55));
}
.book.open { transform: translateX(0); }

.book-base,
.sheet { position: absolute; top: 0; right: 0; width: 50%; height: 100%; }

.book-base {
  background: linear-gradient(135deg, #3d2334, #241120 70%);
  border-radius: 4px 10px 10px 4px;
  box-shadow: inset 0 0 0 2px rgba(232, 184, 75, 0.25), inset 8px 0 16px rgba(0, 0, 0, 0.5);
}

.sheet {
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform 1.1s cubic-bezier(0.55, 0.06, 0.28, 0.99);
}
.sheet.flipped { transform: rotateY(-180deg); }

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.face.back { transform: rotateY(180deg); }

.cover-face {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.9rem;
  padding: 2rem;
  border-radius: 4px 10px 10px 4px;
  background:
    radial-gradient(ellipse at 30% 25%, rgba(232, 184, 75, 0.12), transparent 60%),
    linear-gradient(135deg, #4a2a3c, #2c1622 75%);
  box-shadow:
    inset 0 0 0 3px rgba(201, 150, 46, 0.55),
    inset 0 0 0 7px rgba(201, 150, 46, 0.18),
    inset 0 0 60px rgba(0, 0, 0, 0.55);
}
.cover-rune { font-size: 2.2rem; color: var(--gold); text-shadow: 0 0 18px rgba(232, 184, 75, 0.8); }
.cover-title { font-family: var(--display); font-weight: 700; font-size: clamp(1.05rem, 2.6vw, 1.65rem); color: var(--gold-bright); line-height: 1.25; }
.cover-sub { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.18em; color: var(--ink-dim); text-transform: uppercase; }

.page-face {
  padding: clamp(0.9rem, 2.4vw, 1.9rem) clamp(1rem, 2.6vw, 2.1rem);
  gap: 0.3rem;
  color: #3a2c18;
  background:
    radial-gradient(ellipse at 15% 8%, rgba(120, 84, 30, 0.18), transparent 50%),
    radial-gradient(ellipse at 88% 94%, rgba(120, 84, 30, 0.16), transparent 45%),
    linear-gradient(105deg, #ead9b4, #f2e5c4 30%, #e6d3ab 88%);
}
.face.front.page-face { border-radius: 2px 8px 8px 2px; box-shadow: inset 16px 0 28px rgba(94, 66, 24, 0.25), inset -3px 0 8px rgba(94, 66, 24, 0.18); }
.face.back.page-face { border-radius: 8px 2px 2px 8px; box-shadow: inset -16px 0 28px rgba(94, 66, 24, 0.25), inset 3px 0 8px rgba(94, 66, 24, 0.18); }

.page-eyebrow { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.16em; color: #7c5b22; text-transform: uppercase; }
.page-title { font-family: var(--display); font-weight: 700; font-size: clamp(1rem, 2.2vw, 1.35rem); color: #5a3c10; margin-bottom: 0.4rem; }
.page-note { font-style: italic; font-size: clamp(0.85rem, 1.8vw, 1.05rem); line-height: 1.5; color: #57431f; }
.page-note b { color: #7c4a12; font-style: normal; }
.page-hint { margin-top: auto; font-family: var(--mono); font-size: 0.68rem; color: #8a6a2e; letter-spacing: 0.12em; }
.page-fin { margin-top: auto; text-align: center; font-family: var(--display); color: #8a6222; }
.folio { margin-top: auto; align-self: center; font-family: var(--body); font-style: italic; color: #8a6a2e; font-size: 0.85rem; }

.book .spells { gap: 0; }
.book .spell {
  grid-template-columns: 1.7rem 1fr;
  grid-template-rows: auto auto;
  gap: 0 0.55rem;
  padding: 0.5rem 0.1rem;
  border-bottom: 1px solid rgba(122, 90, 34, 0.35);
}
.book .spell { cursor: pointer; }
.book .spell:hover { background: rgba(122, 90, 34, 0.12); }
.book .spell.selected {
  background: rgba(122, 90, 34, 0.14);
  box-shadow: inset 3px 0 0 var(--spell-c, var(--gold));
}
.book .spell.selected .rune { color: var(--spell-c, var(--gold)); text-shadow: 0 0 8px var(--spell-c, var(--gold)); }
.book .spell .rune { grid-row: 1 / 3; font-size: 1.15rem; color: #8a5f1a; text-shadow: none; align-self: center; }
.book .spell code { font-size: clamp(0.6rem, 1.35vw, 0.8rem); color: #5a3c10; font-weight: 500; overflow-wrap: anywhere; }
.book .spell span { grid-column: 2; font-size: clamp(0.7rem, 1.5vw, 0.9rem); line-height: 1.35; color: #6b5327; }

.page-nav {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  z-index: 200;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(11, 20, 16, 0.65);
  color: var(--gold);
  font-size: 1.3rem;
  line-height: 1;
  backdrop-filter: blur(4px);
  transition: border-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
}
.page-nav:hover { border-color: var(--gold); color: var(--gold-bright); }
.page-nav:disabled { opacity: 0.25; cursor: default; }
.page-nav.prev { left: -1.1rem; }
.page-nav.next { right: -1.1rem; }
.book-hint { font-family: var(--mono); font-size: 0.7rem; color: var(--teal); letter-spacing: 0.1em; margin-top: 1.1rem; }

@media (max-width: 720px) {
  .page-nav.prev { left: -0.4rem; }
  .page-nav.next { right: -0.4rem; }
  .book { aspect-ratio: 1 / 1.1; }
  .page-face { padding: 0.9rem 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .book, .sheet { transition: none; }
}

/* ── legendary quests (featured CV projects, above the live GitHub feed) ── */
.quests-title { font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: var(--gold-bright); margin-bottom: 1rem; }
.quests { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; margin-bottom: 2.2rem; }
.quest { cursor: default; }
.quest h3 em { font-style: italic; font-size: 0.78rem; color: var(--teal); }
.academy { margin-top: 1.4rem; font-style: italic; color: var(--ink-dim); max-width: 34rem; }
.academy b { color: var(--gold); font-style: normal; }
