/* ==========================================================
   V. B. Anstee — site styles
   Hand-written, no framework. Edit the variables below to
   re-theme the whole site.
   ========================================================== */

:root {
  --bg: #04050a;
  --bg-2: #0a0d16;
  --panel: rgba(12, 18, 28, 0.72);
  --ink: #e6f2f4;
  --muted: #8fa3ab;
  --cyan: #a0e1e1;      /* from your old theme + the black hole's ring */
  --cyan-hot: #e2ffff;
  --pink: #ffd7ef;
  --amber: #ffcf6b;
  --line: rgba(160, 225, 225, 0.16);
  --line-strong: rgba(160, 225, 225, 0.4);
  --radius: 4px;
  --wrap: 1180px;
  --font: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pixel: "Silkscreen", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--cyan); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--cyan-hot); }
::selection { background: var(--cyan); color: var(--bg); }

/* ---------- background layers ---------- */
#stars {
  position: fixed; inset: 0; z-index: -2;
  width: 100%; height: 100%;
  pointer-events: none;
}
.scanlines {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.14) 2px 3px);
  mix-blend-mode: multiply;
  opacity: .5;
}
.vignette {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(0,0,0,.65) 100%);
}

/* ---------- layout ---------- */
.wrap { width: min(var(--wrap), 100% - 2.5rem); margin-inline: auto; }
section { position: relative; }
.section { padding: clamp(4rem, 9vw, 7.5rem) 0; }

/* ---------- type ---------- */
.kicker {
  font-family: var(--pixel);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 1rem;
  display: inline-flex; align-items: center; gap: .6rem;
}
.kicker::before {
  content: ""; width: 8px; height: 8px; background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: blink 1.6s steps(2, jump-none) infinite;
}
@keyframes blink { 50% { opacity: .15; } }

h1, h2, h3 { line-height: 1.05; margin: 0 0 1rem; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.8rem, 8vw, 6.2rem); font-weight: 800; }
h2 { font-size: clamp(2rem, 4.5vw, 3.4rem); font-weight: 800; }
h3 { font-size: 1.35rem; font-weight: 700; }
.lede { font-size: clamp(1.1rem, 1.8vw, 1.3rem); color: #c6d6db; max-width: 38ch; }
.muted { color: var(--muted); }
.glow { text-shadow: 0 0 24px rgba(160,225,225,.35); }

/* glitch effect on the big name — subtle, plays once then on hover */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  opacity: 0; pointer-events: none;
}
.glitch::before { color: var(--pink); transform: translate(-3px, 0); clip-path: inset(0 0 60% 0); }
.glitch::after  { color: var(--cyan); transform: translate(3px, 0);  clip-path: inset(55% 0 0 0); }
.glitch.run::before { animation: glitch-a .6s steps(6) 1; }
.glitch.run::after  { animation: glitch-b .6s steps(6) 1; }
@keyframes glitch-a { 0%,100%{opacity:0} 10%,70%{opacity:.85; transform:translate(-4px,-1px)} 40%{transform:translate(3px,1px); clip-path: inset(20% 0 50% 0)} }
@keyframes glitch-b { 0%,100%{opacity:0} 10%,70%{opacity:.85; transform:translate(4px,1px)} 40%{transform:translate(-3px,-1px); clip-path: inset(60% 0 10% 0)} }

/* ---------- buttons ---------- */
.btn {
  --c: var(--cyan);
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .85rem 1.35rem;
  font-family: var(--pixel); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bg); background: var(--c);
  border: 1px solid var(--c);
  border-radius: var(--radius);
  text-decoration: none;
  box-shadow: 0 0 0 0 rgba(160,225,225,0), 0 0 24px rgba(160,225,225,.25);
  transition: transform .15s ease, box-shadow .2s ease, background .2s;
  cursor: pointer;
}
.btn:hover { color: var(--bg); background: var(--cyan-hot); transform: translateY(-2px); box-shadow: 0 0 0 4px rgba(160,225,225,.15), 0 0 32px rgba(160,225,225,.45); }
.btn.ghost { background: transparent; color: var(--c); }
.btn.ghost:hover { background: rgba(160,225,225,.1); color: var(--cyan-hot); }
.btn.small { padding: .6rem 1rem; font-size: .72rem; }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }
.btn-row { display: flex; flex-wrap: wrap; gap: .8rem; }

/* ---------- header ---------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  transition: background .3s, border-color .3s, backdrop-filter .3s;
  border-bottom: 1px solid transparent;
}
.site-header.scrolled {
  background: rgba(4,5,10,.72);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--ink); }
.brand img { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-strong); }
.brand span { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: .95rem; }
.nav { display: flex; align-items: center; gap: 2rem; }
.nav a {
  font-family: var(--pixel); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); text-decoration: none; position: relative; padding: .3rem 0;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--cyan-hot); }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan);
}
.nav .x-link svg { width: 16px; height: 16px; fill: currentColor; vertical-align: -2px; }
@media (min-width: 761px) and (max-width: 980px) { .nav { gap: 1.2rem; } } /* room for 5 menu items on tablets */
.nav-toggle { display: none; background: none; border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius); padding: .45rem .6rem; cursor: pointer; }
.nav-toggle span { display: block; width: 20px; height: 2px; background: currentColor; margin: 4px 0; transition: transform .2s, opacity .2s; }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav {
    position: fixed; inset: 72px 0 auto 0;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: rgba(4,5,10,.96); border-bottom: 1px solid var(--line);
    padding: .5rem 1.25rem 1.25rem;
    transform: translateY(-120%); transition: transform .3s ease;
  }
  .nav a { padding: .9rem 0; width: 100%; border-bottom: 1px solid var(--line); }
  .nav a[aria-current="page"]::after { display: none; }
  body.nav-open .nav { transform: translateY(0); }
  body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
}

/* ---------- black hole sprite ---------- */
/* blackhole-sheet.png is 17 frames of 240x135 laid side by side.
   Black background + mix-blend-mode: screen = it floats on the stars. */
.blackhole {
  --w: 240px;
  aspect-ratio: 240 / 135;
  width: var(--w);
  background: url(../img/blackhole-sheet.png) 0 0 / 1700% 100% no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  mix-blend-mode: screen;
  animation: bh-spin 1.7s steps(16) infinite;
  pointer-events: none;
}
@keyframes bh-spin { to { background-position: 100% 0; } }
.blackhole.slow { animation-duration: 2.6s; }

/* ---------- hero ---------- */
.hero {
  min-height: 100svh;
  display: grid; align-items: center;
  padding: 110px 0 4rem;
  overflow: hidden;
}
.hero .blackhole {
  position: absolute;
  --w: min(1500px, 125vw);
  left: 50%; top: 50%;
  transform: translate(-38%, -50%) scale(var(--bh-scale, 1));
  opacity: .95;
}
.hero .hero-copy { position: relative; z-index: 2; max-width: 640px; }
.hero .hero-copy::before { /* soft shade so text stays readable over the disc */
  content: ""; position: absolute; inset: -18% -25% -18% -30%; z-index: -1;
  background: radial-gradient(ellipse at 35% 50%, rgba(4,5,10,.82) 0%, rgba(4,5,10,.55) 45%, transparent 72%);
  pointer-events: none;
}
.hero h1 { margin-bottom: 1.25rem; }
.hero .lede { margin-bottom: 2rem; }
.hero::after { /* fade into page */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 30%;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}
.scroll-cue {
  position: absolute; left: 50%; bottom: 1.75rem; z-index: 3; transform: translateX(-50%);
  font-family: var(--pixel); font-size: .7rem; letter-spacing: .15em; color: var(--muted); text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
}
.scroll-cue i { width: 2px; height: 34px; background: linear-gradient(var(--cyan), transparent); animation: drip 1.8s ease-in-out infinite; }
@keyframes drip { 0%{transform:scaleY(0); transform-origin:top} 50%{transform:scaleY(1); transform-origin:top} 51%{transform-origin:bottom} 100%{transform:scaleY(0); transform-origin:bottom} }

@media (max-width: 760px) {
  .hero { align-items: end; }
  .scroll-cue { display: none; }
  .hero .blackhole { --w: 210vw; top: 30%; transform: translate(-45%, -50%) scale(var(--bh-scale, 1)); }
}

/* page hero (inner pages) */
.page-hero { padding: 150px 0 3rem; overflow: hidden; }
.page-hero .blackhole {
  position: absolute; --w: 900px; right: -220px; top: 30px; opacity: .55; z-index: -1;
}
@media (max-width: 760px) { .page-hero .blackhole { --w: 640px; right: -300px; } }

/* ---------- HUD panel ---------- */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 4vw, 3rem);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.panel::before, .panel::after { /* corner brackets */
  content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid var(--cyan);
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ---------- featured book (home) ---------- */
.feature { display: grid; grid-template-columns: minmax(220px, 380px) 1fr; gap: clamp(2rem, 5vw, 4.5rem); align-items: center; }
.feature .tagline { font-weight: 700; font-size: 1.15rem; color: var(--cyan-hot); margin-bottom: 1.25rem; }
.feature .tagline span { display: block; }
@media (max-width: 760px) { .feature { grid-template-columns: 1fr; } .feature .cover { max-width: 300px; } }

/* ---------- covers ---------- */
.cover {
  position: relative; display: block;
  border-radius: 3px;
  transform-style: preserve-3d;
  transition: transform .25s ease, box-shadow .25s ease;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(255,255,255,.06);
  will-change: transform;
}
.cover img { border-radius: 3px; width: 100%; height: auto; }
.cover::after { /* moving sheen */
  content: ""; position: absolute; inset: 0; border-radius: 3px; pointer-events: none;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 0%), rgba(255,255,255,.22), transparent 45%);
  opacity: 0; transition: opacity .25s;
}
.cover:hover::after, .cover.tilting::after { opacity: 1; }
.cover:hover { box-shadow: 0 40px 70px -20px rgba(0,0,0,.95), 0 0 40px rgba(160,225,225,.25), 0 0 0 1px rgba(160,225,225,.35); }

/* ---------- series strip / grid ---------- */
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2.5rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2.25rem 1.75rem; }
.book-card { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: .9rem; }
.book-card .cover { aspect-ratio: 1280 / 1810; overflow: hidden; background: var(--bg-2); }
.book-card .cover img { height: 100%; object-fit: cover; }
.book-card .num { font-family: var(--pixel); font-size: .7rem; letter-spacing: .12em; color: var(--muted); }
.book-card h3 { margin: 0; font-size: 1.3rem; }
.book-card p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.book-card:hover h3 { color: var(--cyan-hot); }

.chip {
  display: inline-block; align-self: flex-start;
  font-family: var(--pixel); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase;
  padding: .3rem .5rem; border-radius: 2px; white-space: nowrap;
  border: 1px solid var(--line-strong); color: var(--cyan);
}
.chip.soon { color: var(--amber); border-color: rgba(255,207,107,.45); }

/* horizontal strip on home */
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 210px); gap: 1.5rem; overflow-x: auto; padding: .5rem .25rem 1.5rem; scroll-snap-type: x mandatory; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.strip .book-card { scroll-snap-align: start; }

/* ---------- about ---------- */
.about { display: grid; grid-template-columns: 1fr minmax(240px, 400px); gap: clamp(2rem, 6vw, 5rem); align-items: center; }
.about p { color: #c6d6db; max-width: 60ch; }
.portrait { position: relative; aspect-ratio: 1; width: 100%; }
.portrait::before { /* ring behind avatar */
  content: ""; position: absolute; inset: 8% 8% 8% 8%; border-radius: 50%;
  background: radial-gradient(circle, rgba(160,225,225,.18), transparent 65%);
  box-shadow: 0 0 0 1px var(--line), 0 0 0 22px rgba(160,225,225,.03), 0 0 0 23px var(--line);
}
.portrait img { position: relative; }
@media (max-width: 760px) { .about { grid-template-columns: 1fr; } .portrait { max-width: 280px; order: -1; justify-self: center; } }

/* ---------- newsletter CTA ---------- */
.cta { text-align: center; }
.cta .panel { max-width: 760px; margin-inline: auto; padding-block: clamp(2.5rem, 6vw, 4rem); overflow: hidden; }
.cta .blackhole, .page-hero .blackhole {
  -webkit-mask-image: radial-gradient(ellipse at 55% 50%, #000 35%, transparent 70%);
          mask-image: radial-gradient(ellipse at 55% 50%, #000 35%, transparent 70%);
}
.cta .blackhole { position: absolute; --w: 700px; left: 50%; top: 50%; transform: translate(-50%, -50%); opacity: .25; z-index: -1; }
.cta p { color: #c6d6db; max-width: 46ch; margin: 0 auto 1.75rem; }
.cta .btn-row { justify-content: center; }

/* ---------- single book page ---------- */
.book { display: grid; grid-template-columns: minmax(240px, 420px) 1fr; gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.book .cover { position: sticky; top: 100px; }
.book h1 { font-size: clamp(2.6rem, 6.5vw, 5rem); }
.book .tagline { font-weight: 700; font-size: clamp(1.1rem, 2vw, 1.35rem); color: var(--cyan-hot); margin: 0 0 1.75rem; }
.book .tagline span { display: block; }
.book .blurb p { color: #c6d6db; max-width: 62ch; }
.book .where { margin-top: 2.25rem; }
.book .where .kicker::before { display: none; }
.book-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.book-nav a { text-decoration: none; display: flex; flex-direction: column; gap: .2rem; color: var(--ink); }
.book-nav a small { font-family: var(--pixel); font-size: .68rem; letter-spacing: .1em; color: var(--muted); }
.book-nav a:hover { color: var(--cyan-hot); }
.book-nav .next { text-align: right; margin-left: auto; }
@media (max-width: 760px) { .book { grid-template-columns: 1fr; } .book .cover { position: relative; top: 0; max-width: 300px; } }

/* ---------- contact ---------- */
.signup { max-width: 640px; }
.signup .ml-embedded { margin-top: 1.5rem; min-height: 120px; }
/* Gentle overrides so the MailerLite form sits on a dark page.
   MailerLite's own form styles still apply — set colours in the
   MailerLite form editor too if anything looks off. */
.signup .ml-form-embedContainer .ml-form-embedWrapper { background: transparent !important; }
.signup .ml-form-embedContainer .ml-form-embedWrapper .ml-form-embedBody { padding: 0 !important; }
.cta .ml-embedded { max-width: 520px; margin: 0 auto; }
.form-fallback { display: none; margin-top: 1rem; color: var(--muted); font-size: .95rem; }
.form-fallback.show { display: block; }

/* ---------- prose pages ---------- */
.prose { max-width: 72ch; }
.prose h2 { font-size: 1.35rem; margin-top: 2.5rem; color: var(--cyan-hot); }
.prose p, .prose li { color: #c6d6db; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 2.5rem 0 3rem; margin-top: 2rem; }
.site-footer .wrap { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.site-footer p { margin: 0; color: var(--muted); font-size: .9rem; }
.site-footer nav { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.site-footer nav a { color: var(--muted); font-family: var(--pixel); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; }
.site-footer nav a:hover { color: var(--cyan-hot); }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .8s ease, transform .8s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .1s; } .reveal.d2 { transition-delay: .2s; } .reveal.d3 { transition-delay: .3s; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  /* the black hole spins in place, so keep it going (gently) even with
     reduced motion on. Delete this rule to freeze it for those visitors. */
  .blackhole, .blackhole.slow { animation: bh-spin 3s steps(16) infinite !important; }
}
