@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Lora:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* John Nairn — progression fantasy + military science fiction.
   One site, three universes (The Forge / The Knowledge / The Black).
   Base theme is a neutral "epic parchment"; per-universe accents are set by a
   body class (uni-forge / uni-knowledge / uni-black) so each world reads
   distinctly without a separate stylesheet. */

:root {
  --sand:   #ece7dc;   /* page background (stone parchment) */
  --paper:  #ffffff;   /* cards */
  --ink:    #20242b;   /* body text / nav */
  --sea:    #2f5d7c;   /* headings, links (default — overridden per universe) */
  --rope:   #9c7b3f;   /* accents, sub-labels (antique gold) */
  --accent: #a8472a;   /* CTA (forge ember — overridden per universe) */
  --white:  #ffffff;
  --muted:  #6b6b6b;
  --rule:   rgba(0,0,0,0.10);
}

/* ── Per-universe accent themes ─────────────────────────────── */
body.uni-forge     { --sea:#9c6b2f; --accent:#b5532a; --rope:#9c7b3f;
                     background-image: url('/images_cache/wallpaper_forge.jpg'); background-size: 600px 600px; }
body.uni-knowledge { --sea:#2f6d6a; --accent:#3f6f5e; --rope:#8a7b46;
                     background-image: url('/images_cache/wallpaper_knowledge.jpg'); background-size: 600px 600px; }
body.uni-black     { --sea:#46789c; --accent:#3a6ea5; --rope:#7d8794; --sand:#e4e7ec;
                     background-image: url('/images_cache/wallpaper_black.jpg'); background-size: 600px 600px; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Lora', Georgia, 'Times New Roman', serif;
  color: var(--ink);
  background-color: var(--sand);
  background-image: url('/images_cache/wallpaper_home.jpg');
  background-size: 600px 600px;
  line-height: 1.6;
  font-size: 1rem;
}

h1, h2, h3, .nav-brand {
  font-family: 'Cinzel', 'Playfair Display', serif;
  letter-spacing: 0.02em;
}

/* ── Navigation ─────────────────────────────────────────── */
nav { background: var(--ink); padding: 0 1.5rem; }
.nav-inner {
  max-width: 980px; margin: 0 auto;
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0.5rem; padding: 0.75rem 0;
}
.nav-brand {
  color: var(--sand); text-decoration: none; font-size: 1.05rem;
  letter-spacing: 0.06em; margin-right: auto; white-space: nowrap;
}
nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem;
}
nav ul a {
  color: #c4c0b6; text-decoration: none; font-size: 0.9rem;
  letter-spacing: 0.03em; transition: color 0.15s;
}
nav ul a:hover, nav ul a.active { color: var(--sand); }
nav ul a.cta-link { color: #d6a06a; }
nav ul a.cta-link:hover { color: var(--sand); }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  text-align: center; padding: 3.5rem 1.5rem 2.5rem;
  border-bottom: 1px solid var(--rule);
}
.page-header h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 0 0 0.5rem; color: var(--ink); }
.page-header .subtitle { color: var(--sea); font-style: italic; margin: 0; font-size: 1.1rem; }

/* ── Hero (home only) ────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  text-align: center; padding: 5.5rem 1.5rem 4rem;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(160deg, #1b1f26 0%, #2b3340 55%, #3a2a26 100%);
  color: #f1ede4;
  min-height: calc(100vw * 814 / 1920);
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url('/images_cache/bg_hero_triptych.jpg') center top / 100% auto no-repeat;
  opacity: 0.15;
  z-index: 0;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4rem); margin: 0 0 0.4rem; color: #f6f2e8; }
.hero .tagline { color: #d6a06a; font-style: italic; font-size: 1.25rem; margin: 0 0 2rem; }
.hero .lead { max-width: 600px; margin: 0 auto 2.5rem; font-size: 1.12rem; color: #d9d4c8; }

/* ── Cinema hero (home) — cross-fading universe wallpapers ───
   Ported from the JDN "cinema" effect, re-tuned for dark genre mood:
   slower 20s / 4-frame cycle, subtler Ken Burns, dark scrim overlay
   (not JDN's cream wash) so light text stays readable. Pure CSS. */
.cinema { position: relative; overflow: hidden; border-bottom: 1px solid var(--rule); }
.cinema-frames { position: absolute; inset: 0; z-index: 0; }
.cinema .frame {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0; will-change: opacity, transform;
  animation: jnCinemaFade 20s infinite, jnCinemaKB 20s infinite;
}
.cinema .frame:nth-child(1) { animation-delay: 0s; }
.cinema .frame:nth-child(2) { animation-delay: 5s; }
.cinema .frame:nth-child(3) { animation-delay: 10s; }
.cinema .frame:nth-child(4) { animation-delay: 15s; }
@keyframes jnCinemaFade {
  0% { opacity: 0; } 2% { opacity: 1; } 23% { opacity: 1; } 27% { opacity: 0; } 100% { opacity: 0; }
}
@keyframes jnCinemaKB {
  0% { transform: scale(1.04); } 27% { transform: scale(1.10); } 100% { transform: scale(1.10); }
}
.cinema-caps { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.cinema-caps span {
  position: absolute; left: 1.5rem; right: 1.5rem; bottom: 1.1rem; text-align: center;
  font-family: 'Lora', Georgia, serif; font-style: italic; font-size: 1.05rem; color: #f1ede4;
  text-shadow: 0 1px 10px rgba(0,0,0,0.85), 0 0 4px rgba(0,0,0,0.85);
  opacity: 0; animation: jnCinemaFade 20s infinite;
}
.cinema-caps span:nth-child(1) { animation-delay: 0s; }
.cinema-caps span:nth-child(2) { animation-delay: 5s; }
.cinema-caps span:nth-child(3) { animation-delay: 10s; }
.cinema-caps span:nth-child(4) { animation-delay: 15s; }
/* The hero text sits above the frames; replace the static triptych + solid
   gradient with a translucent dark scrim so the moving image shows through. */
.cinema-hero {
  position: relative; z-index: 2; border-bottom: none;
  /* Lighter scrim than before so the image reads through; darkens toward the
     text band. Radial centre-glow keeps headings legible over busy frames. */
  background:
    radial-gradient(120% 90% at 50% 45%, rgba(12,14,20,0.18) 0%, rgba(12,14,20,0.55) 100%),
    linear-gradient(rgba(12,14,20,0.20), rgba(12,14,20,0.50));
}
.cinema-hero::before { display: none; }
.cinema-hero h1, .cinema-hero .tagline, .cinema-hero .lead,
.cinema-hero .subtitle {
  text-shadow: 0 2px 14px rgba(0,0,0,0.85), 0 0 6px rgba(0,0,0,0.7);
}
/* Per-universe page cinema: shorter than the home hero, 3-frame cycle.
   Inherits the active universe's --accent/--sea via body.uni-* theming. */
.cinema-page { min-height: clamp(280px, 38vw, 460px); display: flex; }
.cinema-page .cinema-hero {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
}
/* 4 frames per universe — inherits the base 20s / 4-frame jnCinemaFade timing. */
.cinema-page .page-header h1 { color: #f6f2e8; }
.cinema-page .page-header .subtitle { color: #d6a06a; }

@media (prefers-reduced-motion: reduce) {
  /* Respect reduced motion: keep the gentle opacity cross-fade (fades are
     vestibular-safe), but drop the Ken Burns zoom so nothing scales/moves. */
  .cinema .frame { animation: jnCinemaFade 20s infinite; transform: none; }
  .cinema-caps span { animation: jnCinemaFade 20s infinite; }
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-block; text-decoration: none; padding: 0.85rem 2rem;
  border-radius: 4px; font-weight: bold; font-size: 1.05rem; transition: filter 0.15s;
  font-family: 'Cinzel', serif; letter-spacing: 0.03em;
}
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { filter: brightness(0.9); }
.btn-secondary { background: var(--sea); color: var(--white); }
.btn-secondary:hover { filter: brightness(0.9); }

/* ── Main content wrapper ────────────────────────────────── */
main { max-width: 920px; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
main.narrow { max-width: 720px; }

/* ── Section spacing ─────────────────────────────────────── */
section { margin-bottom: 3.5rem; }
section h2 {
  font-size: 1.5rem; color: var(--sea); margin: 0 0 0.75rem;
  padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule);
}

/* ── Universe group heading (books hub) ──────────────────── */
.universe-head {
  margin: 2.8rem 0 0.4rem; color: var(--sea);
  border-bottom: 2px solid var(--rule); padding-bottom: 0.4rem;
  font-size: 1.7rem;
}
.universe-tag { color: var(--rope); font-style: italic; margin: 0 0 1.2rem; }

/* ── Series card (hub + worlds) ──────────────────────────── */
.series-card {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 6px;
  overflow: hidden; display: flex; gap: 1.5rem; padding: 1.5rem;
  text-decoration: none; color: inherit; transition: box-shadow 0.15s; margin-bottom: 1.25rem;
}
.series-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.14); }
.series-card img { width: 120px; flex-shrink: 0; object-fit: cover; border-radius: 3px; }
.series-card-body h3 { margin: 0 0 0.3rem; font-size: 1.3rem; color: var(--ink); }
.series-card-body .series-sub { color: var(--rope); font-style: italic; margin: 0 0 0.75rem; font-size: 0.95rem; }
.series-card-body p { margin: 0 0 1rem; color: #444; font-size: 0.95rem; }
.series-card-body .card-link { color: var(--sea); font-weight: bold; font-size: 0.95rem; }

/* ── Books grid (series page) ────────────────────────────── */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 2rem; }
.book-card { background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.book-card img { width: 100%; display: block; aspect-ratio: 2/3; object-fit: cover; background:#d9d4c8; }
.book-card-body { padding: 1rem 1.25rem 1.25rem; }
.book-card-body .book-num { color: var(--rope); font-size: 0.85rem; font-weight: bold; margin: 0 0 0.2rem; }
.book-card-body h3 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.book-card-body .blurb { font-size: 0.9rem; color: #444; line-height: 1.55; margin: 0 0 1rem; }
.book-card-body .status { font-size: 0.85rem; color: var(--muted); font-style: italic; }
.book-card-body .status.free { color: var(--sea); font-style: normal; font-weight: bold; }

/* ── Universe columns (home) ─────────────────────────────── */
.universe-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2rem; align-items: start;
}
.uni-col { display: flex; flex-direction: column; gap: 1.25rem; align-items: stretch; }

/* ── Scatter items ───────────────────────────────────────── */
.scatter-item {
  display: block; width: 90%; height: auto;
  box-shadow: 4px 8px 28px rgba(0,0,0,0.35);
  border-radius: 4px;
  transition: transform 0.25s, box-shadow 0.25s;
}
.scatter-item.tilt-left  { align-self: flex-start; }
.scatter-item.tilt-right { align-self: flex-end;   }
.scatter-item:hover { transform: scale(1.05); box-shadow: 6px 12px 36px rgba(0,0,0,0.45); }

/* ── Series scatter accent ───────────────────────────────── */
.series-scatter {
  display: flex; justify-content: center; align-items: flex-start;
  gap: 1.5rem; flex-wrap: wrap; margin: 1.5rem 0 2rem;
}
.series-scatter img {
  max-width: 300px; width: 45%;
  box-shadow: 4px 8px 28px rgba(0,0,0,0.3); border-radius: 4px;
  transition: transform 0.25s, box-shadow 0.25s;
}
.series-scatter img:hover { transform: scale(1.04); box-shadow: 6px 12px 36px rgba(0,0,0,0.4); }

/* ── CTA box ─────────────────────────────────────────────── */
.cta-box {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 6px;
  padding: 2.5rem 2rem; text-align: center; margin: 3rem 0;
}
.cta-box h2 { border: none; color: var(--ink); font-size: 1.5rem; margin: 0 0 0.5rem; }
.cta-box p { color: var(--muted); margin: 0 0 1.5rem; }

/* ── Universe cards (worlds hub) ─────────────────────────── */
.world-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; }
.world-card {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 6px;
  padding: 1.75rem; text-decoration: none; color: inherit; transition: box-shadow 0.15s;
}
.world-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.14); }
.world-card h3 { margin: 0 0 0.3rem; font-size: 1.4rem; color: var(--sea); }
.world-card .series-sub { color: var(--rope); font-style: italic; margin: 0 0 0.75rem; font-size: 0.95rem; }
.world-card p { color: #444; font-size: 0.95rem; margin: 0 0 1rem; }
.world-card .card-link { color: var(--sea); font-weight: bold; font-size: 0.95rem; }

/* ── World intro ─────────────────────────────────────────── */
.world-intro p { font-size: 1.05rem; max-width: 680px; }

/* ── Footer ──────────────────────────────────────────────── */
footer {
  text-align: center; padding: 2rem 1.5rem; color: var(--muted);
  font-size: 0.88rem; border-top: 1px solid var(--rule);
}
footer a { color: var(--sea); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .series-card { flex-direction: column; }
  .series-card img { width: 100%; height: 220px; }
  .books-grid { grid-template-columns: 1fr; }
  .nav-brand { font-size: 0.95rem; }
}
