/* ============================================================
   THE NEWSSTAND — every GooD NewS in one place.

   A rack of back issues: each year is a divider tab, each month is a
   paper standing in the rack with its real front page showing and a
   little stack-of-pages thickness behind it. Built on the site's own
   tokens so it re-skins with the theme picker.
   ============================================================ */

/* ---- the sign over the rack ----------------------------------------- */
.ns-sign {
  max-width: var(--measure, 940px);
  margin: 0 auto;
  padding: 6px var(--gutter, 24px) 0;
  text-align: center;
}
.ns-sign__title {
  margin: 0;
  font-family: var(--font-masthead, "Rye", Georgia, serif);
  font-size: clamp(30px, 7vw, 58px);
  line-height: 1;
  color: var(--ink, #23201a);
  text-shadow: 3px 3px 0 var(--paper-edge, #d9cda6);
}
.ns-sign__sub {
  margin: 10px 0 0;
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: clamp(12px, 2.4vw, 14px);
  letter-spacing: 0.04em;
  color: var(--accent, #c8362b);
  text-transform: uppercase;
}
.ns-sign__note {
  margin: 10px auto 0;
  max-width: 54ch;
  font-size: clamp(14px, 2.6vw, 16px);
  line-height: 1.6;
  color: var(--ink-soft, #5a5240);
}

/* ---- the control bar ------------------------------------------------- */
.ns-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 18px 0 0;
  padding: 10px var(--gutter, 24px);
  background: var(--paper, #f4ecd8);
  border-top: 2px solid var(--rule-strong, #3a352b);
  border-bottom: 2px solid var(--rule-strong, #3a352b);
  box-shadow: 0 6px 14px -10px rgba(24, 21, 16, 0.6);
}
.ns-bar__row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto 8px;
}
.ns-search {
  flex: 1 1 200px;
  min-height: 42px;
  padding: 8px 12px;
  border: 2px solid var(--rule-strong, #3a352b);
  border-radius: 6px;
  background: #fffdf6;
  font-family: var(--font-body, Georgia, serif);
  font-size: 16px;                       /* 16px stops iOS zooming on focus */
  color: var(--ink, #23201a);
}
.ns-btn {
  min-height: 42px;
  padding: 8px 16px;
  border: 2px solid var(--rule-strong, #3a352b);
  border-radius: 6px;
  background: var(--sunny, #f2c014);
  color: var(--ink, #23201a);
  font-family: var(--font-headline, "Bungee", sans-serif);
  font-size: 12px;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--rule-strong, #3a352b);
  transition: transform 90ms ease, box-shadow 90ms ease;
  -webkit-tap-highlight-color: transparent;
}
.ns-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0; }
.ns-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 12px;
  color: var(--ink-soft, #5a5240);
  cursor: pointer;
  user-select: none;
}
.ns-check input { width: 18px; height: 18px; accent-color: var(--accent, #c8362b); }

/* year chips — the rack's index tabs */
.ns-years {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  max-width: 1180px;
  margin: 0 auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.ns-years::-webkit-scrollbar { display: none; }
.ns-year-chip {
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 1.5px solid var(--rule, #c4b88f);
  border-radius: 999px;
  background: #fffdf6;
  color: var(--ink-soft, #5a5240);
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ns-year-chip:hover,
.ns-year-chip.is-on {
  border-color: var(--rule-strong, #3a352b);
  background: var(--comic-blue, #1f4e8c);
  color: #fff;
}

/* ---- the rack -------------------------------------------------------- */
.ns-rack {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px var(--gutter, 24px) 40px;
}

.ns-yearhead {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 30px 0 14px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--rule-strong, #3a352b);
  scroll-margin-top: 110px;              /* clears the sticky bar on jump */
}
.ns-rack > .ns-yearhead:first-child { margin-top: 0; }
.ns-yearhead__y {
  font-family: var(--font-headline, "Bungee", sans-serif);
  font-size: clamp(22px, 4.5vw, 32px);
  line-height: 1;
  color: var(--ink, #23201a);
}
.ns-yearhead__n {
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 12px;
  color: var(--ink-soft, #5a5240);
}
.ns-yearhead__rule { flex: 1; }

.ns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px 14px;
}

/* ---- one issue on the rack ------------------------------------------ */
.ns-card {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ns-card__paper {
  position: relative;
  transition: transform 140ms ease;
}
/* the stack of pages behind the front page — this is a whole newsletter,
   not a single sheet, and it should look like one */
.ns-card__paper::before,
.ns-card__paper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fffdf6;
  border: 1.5px solid var(--rule, #c4b88f);
  border-radius: 2px;
  z-index: -1;
}
.ns-card__paper::before { transform: translate(3px, 3px) rotate(0.6deg); }
.ns-card__paper::after  { transform: translate(6px, 6px) rotate(1.2deg); }

.ns-card__cover {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 17 / 22;
  object-fit: cover;
  object-position: top center;
  background: #fff;
  border: 2px solid var(--rule-strong, #3a352b);
  border-radius: 2px;
  box-shadow: 0 6px 14px -10px rgba(24, 21, 16, 0.8);
}
.ns-card:hover .ns-card__paper,
.ns-card:focus-visible .ns-card__paper { transform: translateY(-6px) rotate(-0.8deg); }
.ns-card:hover .ns-card__cover { box-shadow: 0 14px 22px -12px rgba(24, 21, 16, 0.85); }

.ns-card__month {
  display: block;
  margin: 9px 0 0;
  font-family: var(--font-headline, "Bungee", sans-serif);
  font-size: 13px;
  line-height: 1.2;
  color: var(--ink, #23201a);
}
.ns-card__meta {
  display: block;
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 11px;
  color: var(--ink-soft, #5a5240);
}

/* stand-in when an issue has no cover thumbnail yet */
.ns-card__nocover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 17 / 22;
  background: #fffdf6;
  border: 2px solid var(--rule-strong, #3a352b);
  border-radius: 2px;
  box-shadow: 0 6px 14px -10px rgba(24, 21, 16, 0.8);
  text-align: center;
  padding: 8px;
}
.ns-card__nocover-head {
  font-family: var(--font-masthead, "Rye", Georgia, serif);
  font-size: 15px;
  color: var(--comic-blue, #1f4e8c);
  line-height: 1.1;
}
.ns-card__nocover-m {
  font-family: var(--font-headline, "Bungee", sans-serif);
  font-size: 12px;
  color: var(--ink, #23201a);
}
.ns-card__nocover-y {
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 11px;
  color: var(--ink-soft, #5a5240);
}

/* the star that means Kimo's column ran that month */
.ns-card__star {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sunny, #f2c014);
  border: 2px solid var(--rule-strong, #3a352b);
  color: var(--ink, #23201a);
  font-size: 15px;
  line-height: 1;
  box-shadow: 2px 2px 0 rgba(24, 21, 16, 0.35);
  z-index: 3;
}

/* ---- a month we don't have ------------------------------------------- */
.ns-ghost {
  display: grid;
  place-items: center;
  aspect-ratio: 17 / 22;
  border: 1.5px dashed var(--rule, #c4b88f);
  border-radius: 2px;
  color: var(--ink-soft, #5a5240);
  opacity: 0.32;                        /* present, but never louder than a real issue */
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 11px;
  text-align: center;
  padding: 6px;
}

/* ---- a run of years nobody ever digitized ---------------------------- */
.ns-gap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 26px 0;
  padding: 14px 16px;
  border: 2px dashed var(--rule, #c4b88f);
  border-radius: 8px;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 9px,
    rgba(90, 82, 64, 0.05) 9px, rgba(90, 82, 64, 0.05) 18px);
  color: var(--ink-soft, #5a5240);
}
.ns-gap__y {
  font-family: var(--font-headline, "Bungee", sans-serif);
  font-size: clamp(16px, 3.4vw, 22px);
  color: var(--ink-soft, #5a5240);
  flex: 0 0 auto;
}
.ns-gap__t { font-size: 13px; line-height: 1.5; }

.ns-empty {
  max-width: 1180px;
  margin: 0 auto 40px;
  padding: 0 var(--gutter, 24px);
  text-align: center;
  font-family: var(--font-accent, "Special Elite", monospace);
  color: var(--ink-soft, #5a5240);
}

/* ============================================================
   THE READER
   ============================================================ */
.nsr {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  background: #2a251d;
  color: #f4ecd8;
}
.nsr[hidden] { display: none; }

.nsr__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--comic-blue, #1f4e8c);
  border-bottom: 3px solid #14243c;
}
.nsr__id { flex: 1 1 140px; min-width: 0; }
.nsr__title {
  display: block;
  font-family: var(--font-headline, "Bungee", sans-serif);
  font-size: 14px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nsr__meta {
  display: block;
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 11px;
  opacity: 0.8;
}
.nsr__nav { display: flex; align-items: center; gap: 8px; }
.nsr__count {
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 12px;
  min-width: 62px;
  text-align: center;
}
.nsr__acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.nsr__btn {
  min-height: 36px;
  min-width: 36px;
  padding: 6px 10px;
  border: 2px solid #14243c;
  border-radius: 5px;
  background: #fffdf6;
  color: #23201a;
  font-family: var(--font-headline, "Bungee", sans-serif);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.nsr__btn:disabled { opacity: 0.4; cursor: default; }
.nsr__btn--wide { padding: 6px 12px; }
.nsr__btn--quiz { background: var(--sunny, #f2c014); }
.nsr__btn--close { background: var(--accent, #c8362b); color: #fff; font-size: 18px; }

.nsr__stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  /* "safe" keeps a page that's taller than the stage reachable: centring alone
     would push its top edge out of the scroll container. */
  place-items: safe center;
  padding: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    #2a251d;
}
.nsr__canvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
  border-radius: 2px;
}
.nsr.is-zoomed .nsr__canvas { max-width: none; }

.nsr__spinner {
  position: absolute;
  font-family: var(--font-accent, "Special Elite", monospace);
  font-size: 13px;
  opacity: 0.85;
}
.nsr__spinner[hidden] { display: none; }

/* big page buttons, for thumbs */
.nsr__foot {
  display: none;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: #1d1912;
  border-top: 2px solid #14243c;
}
.nsr__page-btn {
  flex: 1;
  min-height: 44px;
  border: 2px solid #14243c;
  border-radius: 6px;
  background: #fffdf6;
  color: #23201a;
  font-family: var(--font-headline, "Bungee", sans-serif);
  font-size: 12px;
  cursor: pointer;
}
.nsr__page-btn:disabled { opacity: 0.4; }

@media (max-width: 760px) {
  .nsr__foot { display: flex; }
  .nsr__nav { display: none; }          /* the foot buttons take over */
  .nsr__btn--wide { font-size: 11px; padding: 6px 8px; }
  .ns-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px 10px; }
  .ns-bar { padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .ns-card__paper, .ns-btn { transition: none; }
  .ns-card:hover .ns-card__paper { transform: none; }
}
