/* =========================================================
   Saltwrit — reading-first stylesheet
   Palette is lamp-lit: deep slate ground, brass accent.
   ========================================================= */

:root {
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-read: "Literata", Georgia, "Times New Roman", serif;
  --font-ui: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --reading-size: 19px;
  --reading-measure: 34rem;
  --step: 0.5rem;
  --radius: 3px;

  --bg: #0e1418;
  --bg-raised: #161f25;
  --bg-sunken: #0a0f12;
  --fg: #e3ded2;
  --fg-dim: #8e9aa1;
  --rule: #23303a;
  --accent: #c9964a;
  --accent-soft: rgba(201, 150, 74, 0.16);
  --link: #d9b676;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html[data-theme="sepia"] {
  --bg: #ece2cf;
  --bg-raised: #e3d7c0;
  --bg-sunken: #dfd2b8;
  --fg: #34281a;
  --fg-dim: #7a6a54;
  --rule: #cdbb9c;
  --accent: #8a5a20;
  --accent-soft: rgba(138, 90, 32, 0.14);
  --link: #7d5119;
  --shadow: 0 10px 28px rgba(80, 62, 35, 0.18);
}

html[data-theme="light"] {
  --bg: #fbfaf7;
  --bg-raised: #f1efe9;
  --bg-sunken: #eae7df;
  --fg: #1c1f22;
  --fg-dim: #656d75;
  --rule: #ddd9d0;
  --accent: #96631d;
  --accent-soft: rgba(150, 99, 29, 0.12);
  --link: #8a5a1a;
  --shadow: 0 10px 28px rgba(30, 30, 30, 0.12);
}

html[data-face="sans"] { --font-read: var(--font-ui); }
html[data-width="wide"] { --reading-measure: 44rem; }

* { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg-raised);
  color: var(--fg);
  padding: 0.6rem 1rem;
  z-index: 60;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

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

/* --------------------------------------------------------- site chrome */

.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.4rem 1.25rem 1rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}
.wordmark:hover { color: var(--accent); }

.site-head nav { display: flex; gap: 1.25rem; }
.site-head nav a {
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.site-head nav a:hover { color: var(--accent); }

.site-foot {
  max-width: 68rem;
  margin: 5rem auto 0;
  padding: 1.5rem 1.25rem 3rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  color: var(--fg-dim);
  font-size: 0.85rem;
}
.site-foot p { margin: 0; }
.site-foot nav { display: flex; gap: 1.25rem; }
.site-foot a { color: var(--fg-dim); text-decoration: none; }
.site-foot a:hover { color: var(--accent); }

main { max-width: 68rem; margin: 0 auto; padding: 0 1.25rem; }
body.is-reading main { max-width: none; padding: 0; }

/* ---------------------------------------------------------- shared bits */

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 0 0 0.5rem;
}
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--accent); }

.byline { color: var(--fg-dim); margin: 0.2rem 0 0.7rem; font-size: 0.92rem; }
.blurb { margin: 0 0 0.9rem; color: var(--fg); opacity: 0.86; }
.lede { color: var(--fg-dim); max-width: 42rem; margin: 0.4rem 0 0; }

.button {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bg);
  background: var(--accent);
  padding: 0.7rem 1.3rem;
  border-radius: var(--radius);
}
.button:hover { color: var(--bg); filter: brightness(1.08); }

.button-quiet {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.button-quiet:hover { color: var(--accent); background: var(--accent-soft); }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 0.22rem 0.65rem;
  text-decoration: none;
}
a.tag:hover { color: var(--accent); border-color: var(--accent); }

.status { color: var(--accent); }
.status-completed { color: var(--fg-dim); }

.page-head { padding: 2.5rem 0 1.75rem; }
.page-head h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.015em;
}

/* --------------------------------------------------------------- covers */

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(150deg,
      hsl(calc(var(--cover-seed, 0) * 1deg) 22% 22%),
      hsl(calc(var(--cover-seed, 0) * 1deg + 40deg) 18% 12%));
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }

.cover-type {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.15;
  color: #efe6d4;
  text-align: center;
  padding: 0 0.9rem;
  letter-spacing: -0.01em;
}
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  border-radius: inherit;
}

/* ----------------------------------------------------------------- home */

.hero { padding: 3rem 0 2rem; }

.hero-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 2.5rem;
  max-width: 22ch;
}

.hero-lead {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 2rem;
  align-items: center;
  padding: 1.75rem;
  background: var(--bg-raised);
  border-radius: var(--radius);
}
.hero-cover { display: block; }
.hero-copy h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.hero-copy h2 a { color: var(--fg); text-decoration: none; }
.hero-copy h2 a:hover { color: var(--accent); }

.strip { padding: 2.5rem 0 0; }
.strip-title {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

.latest-list { list-style: none; margin: 0; padding: 0; }
.latest-list li { border-bottom: 1px solid var(--rule); }
.latest-list a {
  display: grid;
  grid-template-columns: minmax(0, 13rem) 1fr auto;
  gap: 1rem;
  align-items: baseline;
  padding: 0.75rem 0;
  text-decoration: none;
  color: var(--fg);
}
.latest-list a:hover { color: var(--accent); }
.lc-novel { color: var(--fg-dim); font-size: 0.85rem; }
.lc-chapter { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-date { color: var(--fg-dim); font-size: 0.78rem; font-variant-numeric: tabular-nums; }

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.75rem;
  padding-bottom: 1rem;
}

.novel-card-link {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 1rem;
  text-decoration: none;
  color: var(--fg);
}
.novel-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.06rem;
  margin: 0;
  line-height: 1.2;
}
.novel-card-link:hover h3 { color: var(--accent); }
.novel-card .blurb {
  font-size: 0.88rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.novel-card .meta-row {
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--fg-dim);
  margin: 0 0 0.5rem;
}

/* ---------------------------------------------------------- novel page */

.novel-head {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 2.5rem;
  padding: 3rem 0 2rem;
}
.novel-head h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0;
}
.novel-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.novel-blurb { max-width: 42rem; }

.chapter-index { padding-top: 2.5rem; }
.chapter-index h2 {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.6rem;
  margin: 0 0 0.25rem;
}

.chapter-list { list-style: none; margin: 0; padding: 0; }
.chapter-list li { border-bottom: 1px solid var(--rule); }
.chapter-list a {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  gap: 1rem;
  align-items: baseline;
  padding: 0.7rem 0.5rem;
  text-decoration: none;
  color: var(--fg);
}
.chapter-list a:hover { color: var(--accent); background: var(--accent-soft); }
.ci-num { color: var(--fg-dim); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.ci-date { color: var(--fg-dim); font-size: 0.78rem; }
.chapter-list a.is-read .ci-title { opacity: 0.55; }
.chapter-list a.is-current { box-shadow: inset 2px 0 0 var(--accent); }

.pager { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 1.5rem 0; }
.pager-item {
  min-width: 2.2rem;
  text-align: center;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg-dim);
  font-size: 0.85rem;
}
.pager-item:hover { color: var(--accent); border-color: var(--accent); }
.pager-item.is-current { color: var(--bg); background: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------- reader */

.reader { position: relative; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.topbar-novel {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--fg);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-tools { display: flex; gap: 0.3rem; flex: none; }

.tool {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  line-height: 1;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.42rem 0.6rem;
  cursor: pointer;
}
.tool:hover { color: var(--accent); border-color: var(--accent); }
.tool sub { font-size: 0.7em; }

.topbar-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
}
.topbar-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

/* the spine: chapter position inside the whole book */
.spine {
  position: fixed;
  left: 1.6rem;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  z-index: 10;
  color: var(--fg-dim);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}
.spine-rail {
  position: relative;
  width: 2px;
  height: 42vh;
  background: var(--rule);
  border-radius: 2px;
}
.spine-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0;
  background: var(--accent);
  border-radius: 2px;
}
.spine-tick {
  position: absolute;
  left: -3px;
  width: 8px;
  height: 1px;
  background: var(--rule);
}
.spine-num { color: var(--accent); font-size: 0.82rem; }

@media (min-width: 1180px) { .spine { display: flex; } }

.chapter {
  max-width: var(--reading-measure);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}
.chapter-head { padding-bottom: 1.75rem; border-bottom: 1px solid var(--rule); }
.chapter-head h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
}
.ch-num {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.chapter-meta { color: var(--fg-dim); font-size: 0.8rem; margin: 0.8rem 0 0; }

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 1.5rem 0;
}
.chapter-nav a, .chapter-nav .is-off {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: var(--fg);
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.chapter-nav span { font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-dim); }
.chapter-nav .is-off { opacity: 0.4; }
.chapter-nav a:hover { border-color: var(--accent); color: var(--accent); }
.cn-next { text-align: right; }
.cn-index { border: 0 !important; color: var(--fg-dim) !important; font-size: 0.78rem !important; }
.cn-index:hover { color: var(--accent) !important; }
.chapter-nav-top { border-bottom: 1px solid var(--rule); }

/* ---------------------------------------------------------------- prose */

.prose {
  font-family: var(--font-read);
  font-size: 1rem;
  line-height: 1.7;
}
.prose.narrow { max-width: var(--reading-measure); }
.prose p { margin: 0 0 1.15em; }
.prose h2, .prose h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 2em 0 0.6em;
}
.prose blockquote {
  margin: 1.5em 0;
  padding-left: 1.1em;
  border-left: 2px solid var(--accent);
  color: var(--fg-dim);
  font-style: italic;
}

.reading {
  font-size: var(--reading-size);
  line-height: 1.78;
  padding-top: 2rem;
  hyphens: auto;
}
.reading p { margin: 0 0 1.3em; }
.reading p + p { text-indent: 1.4em; }
.reading > p:first-of-type::first-letter {
  font-family: var(--font-display);
  float: left;
  font-size: 3.1em;
  line-height: 0.82;
  padding: 0.06em 0.09em 0 0;
  color: var(--accent);
}

.scene-break {
  border: 0;
  height: 1.5em;
  margin: 1.5em 0;
  background: none;
  position: relative;
}
.scene-break::after {
  content: "\2042";
  position: absolute;
  inset: 0;
  text-align: center;
  color: var(--accent);
  font-size: 1.1rem;
}

/* --------------------------------------------------------- responsive */

@media (max-width: 760px) {
  .hero-lead { grid-template-columns: 130px 1fr; gap: 1.25rem; padding: 1.1rem; }
  .novel-head { grid-template-columns: 120px 1fr; gap: 1.25rem; padding: 2rem 0 1.5rem; }
  .latest-list a { grid-template-columns: 1fr auto; }
  .lc-novel { grid-column: 1 / -1; }
  .chapter-list a { grid-template-columns: 2.4rem 1fr; }
  .ci-date { display: none; }
  .site-foot { flex-direction: column; gap: 0.5rem; }
  .reading > p:first-of-type::first-letter { font-size: 2.7em; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

@media print {
  .site-head, .site-foot, .topbar, .spine, .chapter-nav, .skip { display: none !important; }
  body { background: #fff; color: #000; }
}

/* --------------------------------------------------- late corrections */

/* small covers need smaller lettering than the hero */
.novel-card .cover-type { font-size: 0.78rem; padding: 0 0.5rem; }
.hero-cover .cover-type, .cover-lg .cover-type { font-size: 1.35rem; }

/* fallback for browsers without color-mix() */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--bg); }
}

/* the spine sits in the left gutter; keep it clear of the text column */
@media (min-width: 1180px) and (max-width: 1400px) {
  .spine { left: 1rem; }
}
