/* Marginalia — short fiction by Sebastian Shaw */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,400;1,9..144,500&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;1,8..60,400&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #faf6ee;
  --bg-raised: #f2ecdf;
  --paper: #fffdf8;
  --ink: #211d18;
  --ink-soft: #4a453d;
  --ink-faint: #8a8274;
  --rule: #ddd4c0;
  --accent: #8a3324;
  --accent-soft: #b5533e;
  --gold: #a8823a;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --max-width: 1100px;
  --radius: 3px;
}

:root[data-theme="dark"] {
  --bg: #16140f;
  --bg-raised: #1e1b15;
  --paper: #1b1812;
  --ink: #ece6d8;
  --ink-soft: #c9c0ac;
  --ink-faint: #8c8371;
  --rule: #35301f;
  --accent: #d97a5f;
  --accent-soft: #e2937b;
  --gold: #c9a15c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16140f;
    --bg-raised: #1e1b15;
    --paper: #1b1812;
    --ink: #ece6d8;
    --ink-soft: #c9c0ac;
    --ink-faint: #8c8371;
    --rule: #35301f;
    --accent: #d97a5f;
    --accent-soft: #e2937b;
    --gold: #c9a15c;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: inherit; }

img { max-width: 100%; display: block; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  padding: 22px 0;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand .mark { color: var(--accent); font-style: italic; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  font-family: var(--font-ui);
  font-size: 0.92rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Hero ---------- */

.hero {
  padding: 88px 0 64px;
  border-bottom: 1px solid var(--rule);
}

.hero .kicker {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--accent);
  margin: 0 0 18px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.08;
  margin: 0 0 22px;
  max-width: 16ch;
}

.hero h1 em { color: var(--accent); font-style: italic; }

.hero p.lede {
  font-family: var(--font-body);
  font-size: 1.2rem;
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0 0 30px;
}

.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  padding: 12px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  color: var(--ink);
  transition: all 0.15s ease;
}

.btn:hover { background: var(--ink); color: var(--bg); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffdf8;
}

.btn.primary:hover { background: var(--accent-soft); border-color: var(--accent-soft); }

/* ---------- Section headings ---------- */

.section {
  padding: 72px 0;
  border-bottom: 1px solid var(--rule);
}

.section:last-of-type { border-bottom: none; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.section-head h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.9rem;
  margin: 0;
}

.section-head .see-all {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--accent);
  white-space: nowrap;
}

.section-head .see-all:hover { text-decoration: underline; }

.section-note {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink-faint);
  max-width: 60ch;
  margin: -24px 0 40px;
}

/* ---------- Novels (external works) ---------- */

.novels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.novel-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 320px;
  padding: 32px;
  border-radius: var(--radius);
  text-decoration: none;
  color: #fdf9ef;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--rule);
}

.novel-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--bg-image) center/cover no-repeat;
  transition: transform 0.4s ease;
}

.novel-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--scrim);
}

.novel-card:hover::before { transform: scale(1.06); }

.novel-card.vanguard {
  --bg-image: url('../images/vanguard-bg.webp');
  --scrim: linear-gradient(185deg, rgba(10, 18, 32, 0.1) 0%, rgba(9, 14, 24, 0.55) 55%, rgba(6, 9, 15, 0.9) 100%);
}

.novel-card.warden {
  --bg-image: url('../images/warden-bg.webp');
  --scrim: linear-gradient(185deg, rgba(10, 14, 12, 0.1) 0%, rgba(8, 12, 14, 0.55) 55%, rgba(5, 8, 9, 0.9) 100%);
}

.novel-card .tag {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: rgba(253, 249, 239, 0.75);
  margin-bottom: 12px;
}

.novel-card h3 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 500;
  margin: 0 0 10px;
}

.novel-card p {
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: rgba(253, 249, 239, 0.88);
  margin: 0 0 18px;
  max-width: 42ch;
}

.novel-card .go {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.novel-card .go .arrow { transition: transform 0.15s ease; }
.novel-card:hover .go .arrow { transform: translateX(4px); }

/* ---------- Story cards ---------- */

.story-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.story-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.story-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.35);
}

.story-card .cover {
  height: 148px;
  background: var(--cg);
  position: relative;
  overflow: hidden;
}

.story-card .cover svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.story-card .body { padding: 24px; display: flex; flex-direction: column; gap: 10px; flex: 1; }

.story-card .meta {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  display: flex;
  gap: 10px;
}

.story-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  margin: 0;
  line-height: 1.3;
}

.story-card .excerpt {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0;
  flex: 1;
}

.story-card .read-time {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: auto;
}

/* ---------- About / newsletter strip ---------- */

.about-strip {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 56px;
  align-items: start;
}

.about-strip h2 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 500;
  margin: 0 0 8px;
}

.about-strip .role {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.about-strip p {
  font-family: var(--font-body);
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* ---------- Footer ---------- */

.site-footer {
  padding: 44px 0;
  border-top: 1px solid var(--rule);
}

.site-footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.site-footer a { text-decoration: none; color: var(--ink-faint); }
.site-footer a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 20px; }

/* ---------- Story reading page ---------- */

.story-header {
  padding: 64px 0 40px;
  border-bottom: 1px solid var(--rule);
}

.story-header .breadcrumb {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--ink-faint);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
}

.story-header .breadcrumb:hover { color: var(--accent); }

.story-header .meta {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 16px;
}

.story-header h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  line-height: 1.12;
  margin: 0 0 18px;
  max-width: 20ch;
}

.story-header .dek {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 55ch;
  margin: 0 0 22px;
}

.story-header .content-note {
  font-family: var(--font-ui);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin: 0 0 18px;
}

.story-header .byline {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  color: var(--ink-faint);
}

.story-body {
  max-width: 68ch;
  margin: 0 auto;
  padding: 56px 28px 40px;
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.85;
  color: var(--ink);
}

.story-body p { margin: 0 0 1.4em; }

.story-body p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 3.6em;
  font-weight: 600;
  float: left;
  line-height: 0.85;
  padding: 0.05em 0.08em 0 0;
  color: var(--accent);
}

.story-body .ornament {
  text-align: center;
  color: var(--accent);
  margin: 2.2em 0;
  font-size: 1.1rem;
  letter-spacing: 0.4em;
}

.story-body .story-dateline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  margin: 0 0 1.1em;
  text-align: left;
}

.story-body .ornament + .story-dateline {
  margin-top: -0.6em;
}

.story-footer {
  border-top: 1px solid var(--rule);
  padding: 40px 0 72px;
}

.story-footer .wrap {
  max-width: 68ch;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.placeholder-flag {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 4px 12px;
  margin-bottom: 18px;
}

/* ---------- All stories page ---------- */

.page-header {
  padding: 72px 0 48px;
  border-bottom: 1px solid var(--rule);
}

.page-header .kicker {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--accent);
  margin: 0 0 16px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 16px;
}

.page-header p {
  font-family: var(--font-body);
  color: var(--ink-soft);
  font-size: 1.1rem;
  max-width: 56ch;
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .novels-grid { grid-template-columns: 1fr; }
  .story-grid { grid-template-columns: repeat(2, 1fr); }
  .about-strip { grid-template-columns: 1fr; gap: 24px; }
  .site-nav { gap: 16px; }
}

@media (max-width: 560px) {
  .story-grid { grid-template-columns: 1fr; }
  .site-nav a:not(.theme-toggle) { display: none; }
  .hero { padding: 56px 0 44px; }
  .story-body { padding: 40px 20px 24px; font-size: 1.08rem; }
}
