/* =============================================
   THE WEEKLY DISPATCH — Styles
   Newspaper aesthetic for Sunday comics reader
   ============================================= */

:root {
  --paper: #f3efe3;
  --page: #e6e1d3;
  --ink: #1b1712;
  --ink-soft: #5c554a;
  --rule: #1b1712;
  --teal: #256d6a;
  --coral: #c8623f;
  --card: #f7f4ea;
  --shadow: 0 1px 0 rgba(27,23,18,.08);
  --maxw: 1360px;
}

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

html, body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none }
button { font-family: inherit; cursor: pointer }
img { display: block; max-width: 100% }

/* ---------- PAPER ---------- */
.paper {
  max-width: var(--maxw);
  margin: 0 auto;
  background: var(--paper);
  min-height: 100vh;
  padding: 0 clamp(16px, 3vw, 48px) 64px;
  border-left: 1px solid rgba(27, 23, 18, .12);
  border-right: 1px solid rgba(27, 23, 18, .12);
}

/* ---------- MASTHEAD ---------- */
.masthead { padding: 26px 0 0 }

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.masthead-title {
  font-family: "Playfair Display", serif;
  font-weight: 900;
  text-align: center;
  line-height: 1;
  font-size: clamp(38px, 6vw, 84px);
  letter-spacing: .01em;
  margin: 10px 0 0;
}

.masthead-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px auto 0;
  max-width: 520px;
}

.masthead-divider .divider-line {
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.masthead-divider .divider-star {
  font-size: 12px;
  color: var(--ink);
}

.masthead-motto {
  text-align: center;
  font-style: italic;
  font-family: "Playfair Display", serif;
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 8px;
  letter-spacing: .02em;
}

/* ---------- SECTION BAR ---------- */
.section-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 2px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-top: 22px;
  padding: 8px 2px;
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-weight: 600;
}

.section-bar .page-no {
  color: var(--ink-soft);
  letter-spacing: .16em;
}

/* ---------- BREADCRUMB ---------- */
.crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 6px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.crumb button {
  background: none;
  border: none;
  padding: 0;
  color: var(--teal);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-size: 12px;
}

.crumb button:hover { color: var(--ink) }
.crumb .sep { opacity: .5 }

/* ---------- SUNDAY SPREAD ---------- */
.lede {
  max-width: 640px;
  margin: 22px auto 8px;
  text-align: center;
}

.lede h2 {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: clamp(24px, 3vw, 34px);
  margin: 0 0 6px;
}

.lede p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
}

.spread-grid {
  display: grid;
  gap: 22px;
  margin-top: 30px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.comic-card {
  background: var(--card);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-align: left;
  padding: 0;
  transition: transform .18s ease, box-shadow .18s ease;
}

.comic-card:hover {
  transform: translateY(-3px);
  box-shadow: 6px 8px 0 rgba(27, 23, 18, .14);
}

.comic-card:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.cover-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #dcd6c6;
  border-bottom: 1px solid var(--rule);
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Playfair Display", serif;
  font-weight: 900;
  font-size: 20px;
  text-align: center;
  padding: 16px;
  color: var(--ink);
  letter-spacing: .02em;
}

.kicker {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--teal);
  color: #fff;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: 4px 8px;
  font-weight: 600;
}

.comic-meta { padding: 16px 16px 18px }

.comic-meta h3 {
  font-family: "Playfair Display", serif;
  font-weight: 900;
  font-size: 22px;
  margin: 0;
  line-height: 1.05;
}

.comic-meta .by {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 6px;
}

.comic-meta .tag {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

.comic-meta .count {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(27, 23, 18, .18);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.comic-meta .count .arrow { font-size: 14px }

/* ---------- COMIC PAGE ---------- */
.comic-head {
  text-align: center;
  margin: 12px auto 0;
  max-width: 760px;
}

.comic-head .by {
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.comic-head h1 {
  font-family: "Playfair Display", serif;
  font-weight: 900;
  font-size: clamp(34px, 5vw, 60px);
  margin: 8px 0 6px;
  line-height: 1;
}

.comic-head p {
  margin: 0;
  color: var(--ink-soft);
  font-style: italic;
  font-family: "Playfair Display", serif;
  font-size: 17px;
}

.featured {
  max-width: 760px;
  margin: 26px auto 0;
  border: 1px solid var(--rule);
  background: var(--card);
  cursor: zoom-in;
  position: relative;
}

.featured img { width: 100%; height: auto }

.featured .read-hint {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 6px 10px;
  opacity: .92;
}

.featured .cover-fallback {
  aspect-ratio: 3 / 4;
  position: relative;
}

.ep-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--maxw);
  margin: 38px 0 0;
  border-bottom: 2px solid var(--rule);
  padding-bottom: 8px;
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  font-weight: 600;
}

.ep-grid {
  display: grid;
  gap: 16px;
  margin-top: 22px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.ep-card {
  background: var(--card);
  border: 1px solid var(--rule);
  text-align: left;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .16s ease, box-shadow .16s ease;
}

.ep-card:hover {
  transform: translateY(-2px);
  box-shadow: 4px 6px 0 rgba(27, 23, 18, .14);
}

.ep-card:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.ep-thumb {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #dcd6c6;
  border-bottom: 1px solid var(--rule);
  position: relative;
}

.ep-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.ep-info { padding: 10px 12px 12px }

.ep-info .num {
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--ink-soft);
  font-weight: 600;
}

.ep-info .ttl {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 16px;
  margin-top: 2px;
  line-height: 1.1;
}

.ep-card.soon {
  cursor: default;
  opacity: .72;
}

.ep-card.soon:hover {
  transform: none;
  box-shadow: none;
}

.soon-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg,
    #ded8c8,
    #ded8c8 10px,
    #d6cfbd 10px,
    #d6cfbd 20px
  );
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------- LIGHTBOX ---------- */
.lb {
  position: fixed;
  inset: 0;
  background: rgba(18, 15, 11, .92);
  z-index: 50;
  display: none;
  flex-direction: column;
}

.lb.open { display: flex }

.lb-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px clamp(14px, 3vw, 34px);
  color: var(--paper);
  flex: 0 0 auto;
}

.lb-title {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 18px;
}

.lb-title small {
  display: block;
  font-family: "Inter", sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .65;
  margin-bottom: 2px;
}

.lb-close {
  background: none;
  border: 1px solid rgba(243, 239, 227, .4);
  color: var(--paper);
  width: 38px;
  height: 38px;
  font-size: 18px;
  line-height: 1;
  border-radius: 0;
}

.lb-close:hover { background: rgba(243, 239, 227, .12) }

.lb-stage {
  flex: 1;
  overflow: auto;
  text-align: center;
  padding: 0 clamp(10px, 3vw, 40px) 20px;
}

.lb-stage img {
  max-width: min(920px, 100%);
  height: auto;
  display: inline-block;
  vertical-align: top;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .3);
}

.lb-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(14px, 3vw, 34px) 22px;
  flex: 0 0 auto;
}

.lb-btn {
  background: var(--paper);
  color: var(--ink);
  border: none;
  padding: 11px 20px;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 600;
}

.lb-btn:disabled {
  opacity: .35;
  cursor: default;
}

.lb-count {
  color: var(--paper);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .75;
}

/* ---------- FOOTER ---------- */
.paper-footer {
  border-top: 2px solid var(--rule);
  margin-top: 56px;
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.paper-footer .feed { color: var(--teal) }

/* ---------- RESPONSIVE ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 560px) {
  .masthead-top { font-size: 9px }
  .spread-grid { grid-template-columns: 1fr 1fr; gap: 14px }
  .ep-grid { grid-template-columns: 1fr 1fr }
}

/* ---------- LOADING ---------- */
#app.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 40vh;
}

#app.loading::after {
  content: "Loading the funnies…";
  font-family: "Playfair Display", serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 18px;
}