/* ═══════════════════════════════════════════════════════════
   INKWELL — a theme for stories
   Aesthetic: warm literary bookshop at golden hour
   ═══════════════════════════════════════════════════════════ */

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Palette ─────────────────────────────────────────────── */
:root {
  --parchment:  #f5f0e8;
  --cream:      #faf6ef;
  --warm-white: #fdfbf6;
  --ink:        #2a2420;
  --ink-md:     #5c534a;
  --ink-lt:     #9a8f82;
  --wine:       #8b3a4a;
  --wine-dark:  #6e2d3b;
  --wine-glow:  rgba(139, 58, 74, .08);
  --sepia:      #c4a97d;
  --sepia-lt:   rgba(196, 169, 125, .25);
  --rule:       #ddd5c8;
  --radius:     6px;

  --font-display: 'Cormorant', 'Garamond', serif;
  --font-body:    'Crimson Pro', 'Georgia', serif;
  --font-ui:      'Plus Jakarta Sans', -apple-system, sans-serif;
}

/* ── Base ────────────────────────────────────────────────── */
html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--parchment);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Subtle paper grain overlay */
.page-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

a {
  color: var(--wine);
  text-decoration: none;
  transition: color .2s ease;
}
a:hover { color: var(--wine-dark); }

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

::selection {
  background: var(--sepia-lt);
  color: var(--ink);
}

/* ── Fade-in animation ───────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.main {
  animation: fadeUp .5s ease-out;
}

/* ── Layout ──────────────────────────────────────────────── */
.container        { max-width: 920px;  margin: 0 auto; padding: 0 2rem; }
.container-narrow { max-width: 660px;  margin: 0 auto; padding: 0 2rem; }

/* ── Header / Nav ────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 240, 232, .88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule);
}

.nav-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .01em;
}
.site-title:hover { color: var(--wine); }

.nav-links {
  list-style: none;
  display: flex;
  gap: 2.5rem;
}
.nav-links a {
  font-family: var(--font-ui);
  font-size: .78rem;
  font-weight: 500;
  color: var(--ink-lt);
  text-transform: uppercase;
  letter-spacing: .1em;
  position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--wine);
  transition: width .25s ease;
}
.nav-links a:hover, .nav-links a.active { color: var(--wine); }
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }

/* Hamburger */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
}
.menu-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--ink);
  border-radius: 1px;
  transition: transform .25s ease, opacity .2s ease;
}

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  padding: 7rem 0 5rem;
  text-align: center;
  position: relative;
}

.hero-ornament {
  font-family: var(--font-display);
  color: var(--sepia);
  font-size: .9rem;
  letter-spacing: .6em;
  margin-bottom: 1.5rem;
  opacity: .6;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.2;
  max-width: 580px;
  margin: 0 auto .8rem;
  letter-spacing: -.01em;
  color: var(--ink);
}

.hero-sub {
  font-family: var(--font-body);
  color: var(--ink-lt);
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: .04em;
  margin-bottom: 2.5rem;
}
.hero-sub em {
  font-style: italic;
  color: var(--ink-md);
}

.btn {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--warm-white);
  background: var(--wine);
  padding: .85rem 2.4rem;
  border-radius: var(--radius);
  transition: background .2s ease, transform .15s ease, box-shadow .2s ease;
  box-shadow: 0 2px 8px rgba(139, 58, 74, .15);
}
.btn:hover {
  background: var(--wine-dark);
  color: var(--warm-white);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(139, 58, 74, .2);
}

/* ── Section Label ───────────────────────────────────────── */
.section-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.section-label::before,
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.section-label span {
  font-family: var(--font-ui);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-lt);
  white-space: nowrap;
}

/* ── Story Grid ──────────────────────────────────────────── */
.latest { padding: 0 0 6rem; }

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.story-card {
  background: var(--warm-white);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s ease, box-shadow .25s ease, transform .2s ease;
}
.story-card:hover {
  border-color: var(--sepia);
  box-shadow: 0 4px 20px rgba(42, 36, 32, .06);
  transform: translateY(-2px);
}
.story-card a {
  display: flex;
  color: inherit;
  text-decoration: none;
}

.card-accent {
  width: 4px;
  flex-shrink: 0;
  background: linear-gradient(to bottom, var(--wine), var(--sepia));
  opacity: 0;
  transition: opacity .25s ease;
}
.story-card:hover .card-accent { opacity: 1; }

.card-body {
  padding: 1.5rem 1.6rem;
  flex: 1;
}

.story-card h2, .story-card h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: .5rem;
  color: var(--ink);
}
.story-desc {
  font-size: .88rem;
  font-weight: 300;
  color: var(--ink-md);
  margin-bottom: .85rem;
  line-height: 1.6;
}

.story-meta {
  font-family: var(--font-ui);
  font-size: .72rem;
  color: var(--ink-lt);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}

.genre-tag {
  background: var(--wine-glow);
  color: var(--wine);
  padding: .2rem .6rem;
  border-radius: 3px;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.reading-time { margin-left: auto; }

/* ── Page Title (list pages) ─────────────────────────────── */
.page-title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 500;
  font-style: italic;
  margin: 3.5rem 0 2.5rem;
  letter-spacing: -.01em;
  text-align: center;
}

/* ── Single Story ────────────────────────────────────────── */
.story-single {
  animation: fadeUp .6s ease-out;
}

.header-ornament {
  font-family: var(--font-display);
  color: var(--sepia);
  font-size: 1.3rem;
  margin-bottom: .8rem;
  opacity: .5;
}

.story-header {
  padding-top: 4rem;
  padding-bottom: 2.5rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}
.story-header h1 {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.25;
  letter-spacing: -.01em;
  margin-bottom: .8rem;
  color: var(--ink);
}
.story-header .story-meta {
  justify-content: center;
  margin-bottom: .6rem;
}
.story-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  margin-top: .4rem;
}
.tag {
  font-family: var(--font-ui);
  font-size: .68rem;
  font-weight: 500;
  color: var(--ink-lt);
  letter-spacing: .02em;
}

/* ── Story Body — the reading experience ─────────────────── */
.story-body {
  padding-bottom: 4rem;
  font-weight: 400;
  font-size: 1.02rem;
}

/* Drop cap on first paragraph */
.story-body > p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 3.6em;
  float: left;
  line-height: .8;
  margin: .05em .12em 0 0;
  color: var(--wine);
  font-weight: 600;
}

.story-body p {
  margin-bottom: 1.4rem;
}

.story-body h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  margin: 3rem 0 1.2rem;
  letter-spacing: -.01em;
  color: var(--ink);
}
.story-body h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
}

.story-body blockquote {
  border-left: 2px solid var(--sepia);
  padding: .5rem 0 .5rem 1.5rem;
  margin: 2rem 0;
  color: var(--ink-md);
  font-style: italic;
  font-weight: 300;
  font-size: 1.05rem;
}

.story-body hr {
  border: none;
  text-align: center;
  margin: 3rem 0;
}
.story-body hr::before {
  content: "\2666  \2666  \2666";
  color: var(--sepia);
  font-size: .6rem;
  letter-spacing: .3em;
}

.story-body ul, .story-body ol {
  margin: 0 0 1.4rem 1.3rem;
}
.story-body em { font-style: italic; }
.story-body strong { font-weight: 500; }

/* ── Prev / Next Nav ─────────────────────────────────────── */
.story-nav {
  display: flex;
  justify-content: space-between;
  padding: 2.5rem 2rem 5rem;
  border-top: 1px solid var(--rule);
  gap: 1rem;
}
.nav-prev, .nav-next {
  max-width: 45%;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.nav-next { margin-left: auto; text-align: right; align-items: flex-end; }
.nav-label {
  font-family: var(--font-ui);
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-lt);
}
.nav-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--wine);
  font-style: italic;
}
.nav-prev:hover .nav-title,
.nav-next:hover .nav-title {
  color: var(--wine-dark);
}

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 2.5rem 2rem;
  font-family: var(--font-ui);
  font-size: .72rem;
  color: var(--ink-lt);
  border-top: 1px solid var(--rule);
  letter-spacing: .02em;
}
.footer-ornament {
  color: var(--sepia);
  font-size: .7rem;
  margin-bottom: .6rem;
  opacity: .5;
}

/* ── Chapter List (story landing page) ────────────────────── */
.story-about {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 300;
  font-style: italic;
  color: var(--ink-md);
  max-width: 520px;
  margin: 0 auto 1rem;
  line-height: 1.6;
}

.chapter-list {
  max-width: 580px;
  margin: 0 auto 2.5rem;
}

.chapter-row {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  transition: color .15s ease;
}
.chapter-row:first-of-type { border-top: none; }
.chapter-row:hover { color: var(--wine); }

.chapter-num {
  font-family: var(--font-ui);
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink-lt);
  min-width: 1.8rem;
}
.chapter-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  flex: 1;
}
.chapter-reading-time {
  font-family: var(--font-ui);
  font-size: .7rem;
  color: var(--ink-lt);
  white-space: nowrap;
}

.start-reading {
  text-align: center;
  margin-bottom: 4rem;
}

/* Story title above chapter title on single page */
.chapter-story-title {
  font-family: var(--font-ui);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .4rem;
}
.chapter-story-title a {
  color: var(--ink-lt);
}
.chapter-story-title a:hover {
  color: var(--wine);
}

/* ── Chapter Sidebar (desktop) ───────────────────────────── */
.chapter-layout {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.chapter-sidebar {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding: 1.2rem 0;
}

.sidebar-story-title {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink);
  display: block;
  margin-bottom: .8rem;
  line-height: 1.3;
}
.sidebar-story-title:hover { color: var(--wine); }

.sidebar-label {
  font-family: var(--font-ui);
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-lt);
  margin-bottom: .5rem;
}

.sidebar-chapter-list {
  display: flex;
  flex-direction: column;
}

.sidebar-chapter {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  padding: .45rem .6rem;
  border-radius: var(--radius);
  color: var(--ink-md);
  font-size: .82rem;
  line-height: 1.35;
  transition: background .15s ease, color .15s ease;
}
.sidebar-chapter:hover {
  background: var(--wine-glow);
  color: var(--wine);
}
.sidebar-chapter.is-current {
  background: var(--wine-glow);
  color: var(--wine);
  font-weight: 500;
}

.sidebar-chapter-num {
  font-family: var(--font-ui);
  font-size: .7rem;
  font-weight: 600;
  color: var(--ink-lt);
  min-width: 1.4rem;
  flex-shrink: 0;
}
.sidebar-chapter.is-current .sidebar-chapter-num {
  color: var(--wine);
}

.sidebar-chapter-name {
  font-family: var(--font-display);
  font-weight: 500;
}

.chapter-content {
  flex: 1;
  min-width: 0;
}

/* Drawer chapter items — hidden on desktop */
.drawer-chapter-divider,
.drawer-chapter-item { display: none; }

/* Hide mobile-only overlay on desktop */
.nav-overlay { display: none; }

/* ═══════════════════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  html { font-size: 16px; }

  .container, .container-narrow { padding: 0 1.5rem; }
  .nav-inner { padding: 1rem 1.5rem; }

  /* Remove backdrop-filter so position:fixed works inside header.
     Bump z-index above overlay so drawer renders on top. */
  .site-header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--parchment);
    z-index: 102;
  }

  /* Hamburger */
  .menu-toggle { display: flex; z-index: 102; }
  .nav-links {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 260px;
    max-width: 75vw;
    background: var(--cream);
    border-left: 1px solid var(--rule);
    flex-direction: column;
    align-items: flex-start;
    padding: 5rem 2.5rem 2rem;
    gap: 0;
    transform: translateX(100%);
    transition: transform .3s ease;
    z-index: 101;
    box-shadow: -8px 0 32px rgba(42, 36, 32, .1);
    overflow-y: auto;
  }
  .nav-links li {
    list-style: none;
    width: 100%;
    padding: .9rem 0;
    border-bottom: 1px solid var(--rule);
  }
  .nav-links li:last-child { border-bottom: none; }
  .nav-links a {
    font-size: .9rem;
    letter-spacing: .08em;
    color: var(--ink-md);
    display: block;
  }
  .nav-links a::after { display: none; }

  /* Overlay */
  .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(42, 36, 32, .3);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
  }
  body.nav-open .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.nav-open .nav-links { transform: translateX(0); }
  body.nav-open .menu-toggle span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
  body.nav-open .menu-toggle span:nth-child(2) { opacity: 0; }
  body.nav-open .menu-toggle span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

  /* Hero */
  .hero { padding: 4.5rem 0 3rem; }
  .hero h1 { font-size: 2.2rem; }

  /* Grid */
  .story-grid { grid-template-columns: 1fr; }

  /* Single story */
  .story-header { padding-top: 3rem; }
  .story-header h1 { font-size: 2rem; }

  .story-body > p:first-of-type::first-letter {
    font-size: 3em;
  }

  /* Nav */
  .story-nav {
    flex-direction: column;
    gap: 1.2rem;
    padding: 2rem 1.5rem 4rem;
  }
  .nav-prev, .nav-next { max-width: 100%; text-align: left; align-items: flex-start; }

  /* Chapter sidebar hidden on mobile */
  .chapter-layout { display: block; }
  .chapter-sidebar { display: none; }

  /* Drawer chapter list — visible on mobile */
  .drawer-chapter-divider {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .9rem 0 .3rem;
    border-bottom: none;
    list-style: none;
  }
  .drawer-chapter-divider span {
    font-family: var(--font-ui);
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--ink-lt);
    white-space: nowrap;
  }
  .drawer-chapter-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--rule);
  }

  .drawer-chapter-item {
    display: block;
    padding: .5rem 0;
    border-bottom: none;
  }
  .drawer-chapter-item a {
    font-family: var(--font-display);
    font-size: .88rem;
    color: var(--ink-md);
    font-weight: 500;
  }
  .drawer-chapter-item a:hover { color: var(--wine); }
  .drawer-chapter-item a.drawer-chapter-current {
    color: var(--wine);
    font-weight: 600;
  }
  .drawer-chapter-num {
    font-family: var(--font-ui);
    font-size: .7rem;
    font-weight: 600;
    color: var(--ink-lt);
  }
  .drawer-chapter-item a.drawer-chapter-current .drawer-chapter-num {
    color: var(--wine);
  }
}
