/* Bright & Early — a flip-through morning paper.
   Warm paper, real serifs, columns. Topbar + horizontal page-flipper + pager. */

:root {
  /* "Crisp Sunrise" — warm, energetic, modern-but-warm */
  --paper: #fcfbf8;       /* alabaster reading canvas */
  --ink: #2b2d42;         /* deep navy-grey (softer than black) */
  --ink-soft: #6b6e83;    /* muted navy-grey */
  --rule: #e9e5da;        /* warm hairline */
  --accent: #ff7a59;      /* sunrise orange — buttons, active tabs, links */
  --highlight: #ffd166;   /* golden yellow — accents & marks */
  --card: #ffffff;        /* clean cards & inputs */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.5;
}

/* ---- Topbar: masthead + section tabs ---- */
.topbar {
  flex: none;
  padding: env(safe-area-inset-top) 0.75rem 0;
}
.topbar__head {
  text-align: center;
  padding-top: 0.6rem;
}
.masthead {
  margin: 0;
  font-size: clamp(1.7rem, 7vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant: small-caps;
  line-height: 1;
}
.dateline {
  margin: 0.3rem 0 0.55rem;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.62rem;
  color: var(--ink-soft);
}
.dateline__sep { margin: 0 0.4rem; }

.tabs {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.tabs::-webkit-scrollbar { display: none; }
/* Centre the tabs once they comfortably fit; stay left-aligned + scrollable on
   narrow screens so the first tab is always reachable. */
@media (min-width: 960px) { .tabs { justify-content: center; } }
.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.55rem 0.6rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border-bottom: 2.5px solid transparent;
  white-space: nowrap;
  transition: color 0.15s;
}
.tab svg { width: 15px; height: 15px; flex: none; }
.tab:hover { color: var(--ink); }
.tab--active { color: var(--accent); border-bottom-color: var(--accent); }

/* Reading-progress bar — the "horizon" that fills as you flip through. */
.progress { height: 3px; background: var(--rule); }
.progress__bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--highlight), var(--accent));
  transition: width 0.35s ease;
}

/* ---- Pager: horizontal scroll-snap of full-width pages ---- */
.pager {
  flex: 1;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.pager::-webkit-scrollbar { display: none; }

.page {
  flex: 0 0 100%;
  height: 100%;
  overflow-y: auto;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: 1.3rem 1.25rem 2.5rem;
}
.page__inner { max-width: 1080px; margin: 0 auto; }

.page__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 2px solid var(--rule);
  padding-bottom: 0.5rem;
  margin-bottom: 1.2rem;
}
.page__section {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent);
}
.page__num {
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-transform: uppercase;
  white-space: nowrap;
}

.loading { text-align: center; font-style: italic; color: var(--ink-soft); padding: 3rem 1rem; width: 100%; }

/* ---- Stories: columns within a page ---- */
.stories { column-gap: 2rem; }
@media (min-width: 680px) { .stories { column-count: 2; } }
@media (min-width: 1040px) { .stories { column-count: 3; } }

.story {
  break-inside: avoid;
  display: inline-block;
  width: 100%;
  margin: 0 0 1.5rem;
  padding-bottom: 1.3rem;
  border-bottom: 1px solid var(--rule);
}
.story__media { margin-bottom: 0.6rem; }
.story__img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 3px;
  background: #e7e1d2;
  display: block;
}
.story__headline {
  font-size: 1.24rem;
  line-height: 1.2;
  margin: 0 0 0.45rem;
  font-weight: 700;
}
.story__headline a { color: var(--ink); text-decoration: none; }
.story__headline a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.story__summary { margin: 0 0 0.6rem; color: var(--ink-soft); font-size: 1rem; }
.story__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  align-items: baseline;
  font-family: var(--sans);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.story__source { color: var(--ink-soft); }
.story__more { color: var(--accent); text-decoration: none; font-weight: 700; }
.story__more:hover { text-decoration: underline; }
.story__share {
  appearance: none;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  font: inherit;
  font-weight: 700;
  letter-spacing: inherit;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.story__share:hover { color: var(--accent); }

/* The lead story on each page gets the front-page treatment. */
.story--lead {
  column-span: all;
  border-bottom: 3px double var(--rule);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}
.story--lead .story__headline { font-size: clamp(1.7rem, 4.5vw, 2.7rem); line-height: 1.12; }
.story--lead .story__summary { font-size: 1.12rem; }
@media (min-width: 680px) {
  .story--lead { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.6rem; align-items: start; }
  .story--lead .story__media { grid-row: span 3; margin: 0; }
  .story--lead .story__img { aspect-ratio: 4 / 3; height: 100%; }
}

/* ---- Bottom nav ---- */
.navbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  background: var(--card);
}
.navbtn {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.navbtn:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.navbtn:disabled { opacity: 0.35; cursor: default; }
.navstatus {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  min-width: 3.5rem;
  text-align: center;
}

/* ---- The Back Page: end-mark, newsletter, tip jar ---- */
.page--back .back__inner {
  max-width: 540px;
  text-align: center;
  padding-top: 2rem;
}
.tab--back { font-size: 1rem; padding-inline: 0.9rem; }
.back__mark {
  font-family: var(--sans);
  letter-spacing: 0.4em;
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-bottom: 1.2rem;
}
.back__title {
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  line-height: 1.15;
  margin: 0 0 0.7rem;
  font-weight: 800;
}
.back__lede { color: var(--ink-soft); font-size: 1.05rem; margin: 0 auto 2rem; }
.back__block {
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
  margin-top: 1.5rem;
}
.back__h {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 0.9rem;
}
.signup { display: flex; gap: 0.5rem; max-width: 380px; margin: 0 auto; }
.signup__input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
.signup__input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.signup__btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0 1.1rem;
  border-radius: 6px;
  cursor: pointer;
}
.signup__btn:hover { filter: brightness(1.06); }
.back__soon { color: var(--ink-soft); font-style: italic; }
.tipjar {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  text-decoration: none;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
}
.tipjar:hover { filter: brightness(1.06); }
.back__fine {
  font-family: var(--sans);
  font-size: 0.74rem;
  color: var(--ink-soft);
  margin: 0.8rem auto 0;
}
.back__social {
  font-family: var(--sans);
  font-size: 0.82rem;
  margin: 2rem 0 0;
}
.back__social a { color: var(--accent); text-decoration: none; font-weight: 700; }
.back__social span { color: var(--rule); margin: 0 0.6rem; }
.back__colophon {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--ink-soft);
  border-top: 3px double var(--rule);
  padding-top: 1.2rem;
  margin-top: 2.4rem;
}

/* ---- Toast (share feedback) ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 5rem;
  transform: translate(-50%, 1rem);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.85rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Standalone shareable story page (/s/<id>.html) ---- */
.storypage {
  height: auto;
  display: block;
  overflow: auto;
  padding: 0 1.25rem 4rem;
}
.reader { max-width: 660px; margin: 0 auto; }
.reader__brand {
  display: block;
  text-align: center;
  font-variant: small-caps;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  padding: 1.6rem 0 1.2rem;
  margin-bottom: 1.4rem;
  border-bottom: 3px double var(--rule);
}
.reader__kicker {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.6rem;
}
.reader__headline { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.12; margin: 0 0 1.1rem; }
.reader__img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
  background: #e7e1d2;
  margin-bottom: 1.1rem;
}
.reader__summary { font-size: 1.2rem; line-height: 1.6; color: var(--ink); margin: 0 0 2rem; }
.reader__actions { display: flex; flex-direction: column; gap: 0.9rem; align-items: flex-start; }
.reader__cta {
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  text-decoration: none;
  padding: 0.75rem 1.3rem;
  border-radius: 999px;
}
.reader__back { font-family: var(--sans); font-size: 0.9rem; color: var(--ink-soft); text-decoration: none; }
.reader__back:hover { color: var(--accent); }

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1b22;       /* deep pre-dawn navy */
    --ink: #ecebf2;
    --ink-soft: #9a9db1;
    --rule: #33353f;
    --accent: #ff8a6b;      /* sunrise orange, lifted for dark */
    --highlight: #ffd166;
    --card: #23242e;
  }
  .story__img, .reader__img { background: #2a2c38; }
}
