/* aloftinthebreeze — shared stylesheet
   Built for long-form reading: comfortable line length, generous leading,
   system fonts (no files to host), automatic dark mode, phone-first spacing. */

:root {
  --bg: #fbf8f2;
  --surface: #f3eee4;
  --text: #2b2723;
  --muted: #6b645b;
  --rule: #ddd5c7;
  --accent: #2f6370;
  --accent-text: #ffffff;
  --focus: #b4540a;

  --serif: Charter, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --surface: #1f1d24;
    --text: #e4ded4;
    --muted: #a39b90;
    --rule: #34313a;
    --accent: #8cc3cf;
    --accent-text: #10212a;
    --focus: #f0a35e;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; }

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  background: var(--accent);
  color: var(--accent-text);
  padding: 0.6rem 1rem;
  font-family: var(--sans);
  z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

.wrap {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---------- Header and footer ---------- */

.site-header {
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}
.wordmark {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}
.site-nav {
  display: flex;
  gap: 1.25rem;
  font-family: var(--sans);
  font-size: 0.95rem;
}
.site-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] { border-bottom-color: var(--accent); }

.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
}
.site-footer .wrap { padding-top: 1.5rem; padding-bottom: 2rem; }
.site-footer p { margin: 0 0 0.5rem; }

/* ---------- General page content ---------- */

.page { padding-top: 2rem; }
.page h1 {
  font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.4rem);
  line-height: 1.2;
  margin: 0 0 0.75rem;
  font-weight: 600;
}
.page h2 {
  font-size: 1.3rem;
  line-height: 1.3;
  margin: 2rem 0 0.5rem;
}
.lede {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}
.page p, .page li { max-width: 62ch; }
.page ul { padding-left: 1.25rem; }
.page li { margin-bottom: 0.4rem; }

/* ---------- Chips, ratings, tags ---------- */

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.4rem 0 0.75rem;
}
.chip {
  display: inline-block;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.6;
}
.chip.rating { font-weight: 600; border-color: var(--muted); }
.page .tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0 0; padding: 0; list-style: none; }

/* ---------- Library index: story cards ---------- */

.page .story-list { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.page .story-card {
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 8px;
  padding: 1.1rem 1.1rem 1.25rem;
  margin: 0 0 1rem;
}
.story-card h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}
.story-card h2 a { color: var(--text); text-decoration: none; }
.story-card h2 a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.story-card .byline { margin: 0.15rem 0 0; color: var(--muted); font-style: italic; }
.story-card .summary { margin: 0.5rem 0 0; max-width: 62ch; }
.story-card.is-placeholder { opacity: 0.7; border-style: dashed; }

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

.story-head { margin-bottom: 1.5rem; }
.story-head .byline { margin: 0; font-style: italic; color: var(--muted); font-size: 1.1rem; }
.page .chapter-list { list-style: none; margin: 0.75rem 0 0; padding: 0; border-top: 1px solid var(--rule); }
.chapter-list li { border-bottom: 1px solid var(--rule); margin: 0; max-width: none; }
.chapter-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  padding: 0.85rem 0.25rem;
  min-height: 44px;
  text-decoration: none;
  color: var(--text);
}
.chapter-list a:hover { background: var(--surface); }
.chapter-list .when { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

/* ---------- Chapter reading view ---------- */

.crumbs {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
}
.crumbs a { color: var(--muted); }

.chapter-head { margin-bottom: 1.5rem; }
.chapter-head .kicker {
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.chapter-head h1 {
  font-size: clamp(1.7rem, 1.35rem + 1.5vw, 2.3rem);
  line-height: 1.2;
  margin: 0 0 0.4rem;
  font-weight: 600;
}
.chapter-head .byline { margin: 0; font-style: italic; color: var(--muted); }

details.notes {
  margin: 1rem 0 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--sans);
  font-size: 0.9rem;
}
details.notes summary {
  cursor: pointer;
  padding: 0.7rem 0.9rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}
details.notes .notes-body { padding: 0 0.9rem 0.9rem; }
details.notes p { margin: 0 0 0.6rem; max-width: 62ch; }

/* The reading column itself */
.prose {
  max-width: 34rem;
  font-size: clamp(1.125rem, 1.06rem + 0.3vw, 1.25rem);
  line-height: 1.7;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
  text-wrap: pretty;
  margin: 2rem 0;
}
.prose p { margin: 0 0 1.1em; }
.prose hr {
  border: 0;
  text-align: center;
  margin: 2rem 0;
  height: auto;
}
.prose hr::after {
  content: "*\00a0\00a0*\00a0\00a0*";
  color: var(--muted);
  letter-spacing: 0.2em;
}
.prose blockquote {
  margin: 1.2em 0;
  padding-left: 1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

.end-note {
  max-width: 62ch;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
}

/* Previous / contents / next */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.5rem 0;
  font-family: var(--sans);
}
.pager a,
.pager span {
  flex: 1 1 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
}
.pager a { color: var(--text); background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager a.next { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.pager span[aria-disabled="true"] { color: var(--muted); border-style: dashed; }
.pager.top { margin-top: 0; font-size: 0.9rem; }
.pager.top a, .pager.top span { min-height: 40px; }

/* ---------- Content notice (gate) ---------- */

.notice-box {
  max-width: 36rem;
  margin: 0 auto;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 10px;
  padding: 1.5rem 1.25rem 1.75rem;
}
.notice-box h1 { margin-top: 0; }
.notice-box ul { padding-left: 1.25rem; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; font-family: var(--sans); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}
.button.secondary { background: transparent; color: var(--accent); font-weight: 400; }
.small { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); }

/* ---------- Small screens ---------- */

@media (max-width: 30rem) {
  .site-header .wrap { padding-top: 0.7rem; padding-bottom: 0.4rem; }
  .story-card { padding: 1rem; }
  .prose { margin: 1.5rem 0; }
  .prose p { text-align: left; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.page .tags li { margin: 0; max-width: none; }
