/* ============================================================
   Side Street - a magazine of everyday city life
   Editorial system: ink on paper, one cobalt accent, sharp corners.
   Fonts: DM Serif Display (headlines), Literata (body),
   IBM Plex Mono (meta), DM Sans (interface).
   ============================================================ */

@font-face {
  font-family: 'DM Serif Display';
  src: url('assets/dm-serif.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Literata';
  src: url('assets/literata.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('assets/dm-sans.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f6f6f3;
  --paper-2: #ecece7;
  --ink: #1d1d1b;
  --muted: #5b5b54;
  --line: #d8d8d1;
  --accent: #2450b3;
  --accent-ink: #f7f7f4;
  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Literata', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --font-sans: 'DM Sans', 'Helvetica Neue', Arial, sans-serif;
  --photo-filter: grayscale(1) contrast(1.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17171a;
    --paper-2: #202024;
    --ink: #ecebe6;
    --muted: #a6a69c;
    --line: #3a3a3f;
    --accent: #9cb6f0;
    --accent-ink: #14161d;
    --photo-filter: grayscale(1) contrast(1.05) brightness(.9);
  }
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

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

html.has-modal,
html.has-modal body { overflow: hidden; }

::selection { background: var(--accent); color: var(--accent-ink); }

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

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

button { font: inherit; color: inherit; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  padding: .6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-sans);
  text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 1rem; }

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}

.masthead-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.1rem 2rem .95rem;
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.95rem;
  line-height: 1;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0;
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--muted);
  letter-spacing: .02em;
}

.masthead-nav {
  margin-left: auto;
  display: flex;
  gap: 1.6rem;
}

.masthead-nav a {
  font-family: var(--font-sans);
  font-size: .9rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}
.masthead-nav a:hover { border-bottom-color: var(--accent); }

/* ---------- shared type pieces ---------- */

.kicker {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 .8rem;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--accent);
}

.saved-chip {
  display: none;
  font-size: .65rem;
  letter-spacing: .1em;
  padding: .05rem .4rem;
  border: 1px solid currentColor;
  border-radius: 0;
}
.is-saved .saved-chip { display: inline-block; }

.meta-line {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .35rem 1.25rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--muted);
}
.meta-line .mins { text-align: right; }

.linklike {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: inherit;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

/* ---------- featured story (hero) ---------- */

.featured {
  border-bottom: 1px solid var(--line);
}

.hero {
  max-width: 1280px;
  margin: 0 auto;
  padding: 3rem 2rem 3.5rem;
  display: grid;
  grid-template-columns: 6fr 6fr;
  gap: 3rem;
  align-items: center;
}

.hero-title {
  margin: 0 0 1.1rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 3.6vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.005em;
  max-width: 20ch;
}

.hero-title .linklike:hover,
.hero-title .linklike:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: .08em;
  text-decoration-color: var(--accent);
}

.hero-summary {
  margin: 0 0 1.4rem;
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--muted);
  max-width: 38ch;
}

.hero-media {
  margin: 0;
}

.hero-media img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  filter: var(--photo-filter);
  transition: filter .4s ease;
}
.hero:hover .hero-media img { filter: none; }

.hero-media figcaption,
.card-media + figcaption,
.detail-figure figcaption {
  margin-top: .45rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--muted);
}

/* ---------- index section ---------- */

.index {
  padding: 0 0 4.5rem;
}

.index-head {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.4rem 2rem 1.4rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
}

.index-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.55rem;
}

.count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--muted);
}

/* toolbar */

.toolbar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem 1.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.6rem;
  align-items: flex-end;
}

.control { display: flex; flex-direction: column; gap: .45rem; }

.control-label {
  font-family: var(--font-mono);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--muted);
}

.input {
  font-family: var(--font-sans);
  font-size: .95rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: .62rem .8rem;
  min-width: 0;
}

#search-input { width: min(21rem, 100%); }
#topic-select { width: auto; }

.input::placeholder { color: var(--muted); opacity: 1; }

.btn {
  font-family: var(--font-sans);
  font-size: .88rem;
  padding: .62rem 1.05rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .2s ease, transform .1s ease;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.07); }

.btn-saved[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* story grid */

.story-grid {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2.4rem 2rem;
}

.story-card { border-top: 1px solid var(--ink); padding-top: 1.2rem; }

.card-a {
  grid-column: span 12;
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 1.6rem;
}
.card-b { grid-column: span 6; }
.card-c {
  grid-column: span 6;
  background: var(--paper-2);
  border-top: 3px solid var(--accent);
  padding: 1.5rem 1.6rem 1.6rem;
  transition: background-color .2s ease;
}
.card-c:hover { background: var(--paper); }

.card-media img {
  width: 100%;
  object-fit: cover;
  filter: var(--photo-filter);
  transition: filter .4s ease;
}
.card-a .card-media img { aspect-ratio: 4 / 3; }
.card-b .card-media img { aspect-ratio: 16 / 10; }

.card-a .card-body { display: flex; flex-direction: column; }

.card-title {
  margin: 0 0 .7rem;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.14;
  font-size: 1.5rem;
}
.card-a .card-title { font-size: 1.85rem; max-width: 24ch; }

.card-title .linklike:hover,
.card-title .linklike:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: .07em;
  text-decoration-color: var(--accent);
}

.card-summary {
  margin: 0 0 1.2rem;
  font-size: .97rem;
  line-height: 1.65;
  color: var(--muted);
}
.card-a .card-summary { max-width: 52ch; }

.card-c .card-summary {
  font-style: italic;
  font-size: 1.02rem;
}

.card-b .card-media { margin-bottom: .4rem; }
.card-b .card-body { display: flex; flex-direction: column; }
.card-b .meta-line { margin-top: auto; }

/* empty state */

.empty {
  max-width: 30rem;
  margin: 1rem auto 3rem;
  padding: 2.6rem 2rem;
  text-align: center;
  border: 1px dashed var(--line);
}
.empty h3 {
  margin: 0 0 .5rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.4rem;
}
.empty p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: .95rem;
}

/* ---------- colophon ---------- */

.colophon {
  border-top: 2px solid var(--ink);
}

.colophon-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.4rem 2rem 3rem;
}

.colophon-word {
  margin: 0 0 .9rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
}

.colophon-text {
  margin: 0 0 .45rem;
  font-family: var(--font-mono);
  font-size: .74rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 62ch;
}

/* ---------- detail (reader) ---------- */

#detail {
  width: min(56rem, calc(100% - 2.5rem));
  max-height: calc(100dvh - 2.5rem);
  margin: auto;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}

#detail::backdrop {
  background: rgb(18 18 15 / .62);
}

.detail-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .8rem 1.4rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.detail-top .kicker { margin: 0 1rem 0 0; }
.detail-top .btn { margin-left: auto; padding: .48rem .85rem; font-size: .82rem; }
.detail-top .btn-save { margin-left: auto; }
.detail-top .btn-close { margin-left: 0; }

.btn-save.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.detail-article {
  padding: 2.4rem clamp(1.4rem, 5vw, 3.8rem) 4rem;
}

.detail-title {
  margin: 0 0 1.1rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.9rem, 4vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.005em;
  max-width: 22ch;
}

.detail-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .35rem 1.5rem;
  margin: 0 0 1.4rem;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--muted);
}

.detail-dek {
  margin: 0 0 2rem;
  font-style: italic;
  font-size: 1.14rem;
  line-height: 1.6;
  color: var(--muted);
  max-width: 52ch;
}

.detail-figure { margin: 0 0 2.4rem; }

.detail-figure img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  filter: var(--photo-filter);
}

.detail-body p {
  margin: 0 0 1.35em;
  font-size: 1.04rem;
  line-height: 1.78;
  max-width: 66ch;
}

.detail-body p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 3.3em;
  line-height: .82;
  float: left;
  padding: .06em .12em 0 0;
  color: var(--accent);
}

.endmark {
  display: block;
  width: .55em;
  height: .55em;
  margin-top: .4rem;
  background: var(--accent);
}

/* ---------- entry motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .hero, .story-card, .empty {
    animation: rise .55s cubic-bezier(.16, 1, .3, 1) both;
  }
  .story-grid > :nth-child(1) { animation-delay: .05s; }
  .story-grid > :nth-child(2) { animation-delay: .1s; }
  .story-grid > :nth-child(3) { animation-delay: .15s; }
  .story-grid > :nth-child(4) { animation-delay: .2s; }
  .story-grid > :nth-child(5) { animation-delay: .25s; }
  .story-grid > :nth-child(6) { animation-delay: .3s; }
  .story-grid > :nth-child(7) { animation-delay: .35s; }
  #detail[open] { animation: rise .35s cubic-bezier(.16, 1, .3, 1) both; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- mobile ---------- */

@media (max-width: 860px) {
  .masthead-inner {
    flex-wrap: wrap;
    row-gap: .45rem;
    padding-top: 1rem;
    padding-bottom: .8rem;
  }
  .masthead-nav { margin-left: 0; gap: 1.2rem; }
  .tagline { margin-left: auto; text-align: right; }

  .hero {
    grid-template-columns: 1fr;
    gap: 1.6rem;
    padding: 2.2rem 1.25rem 2.6rem;
  }
  .hero-media { order: 2; }

  .index-head { padding: 2rem 1.25rem 1.2rem; }
  .toolbar { padding: 0 1.25rem 1.6rem; }
  .story-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 0 1.25rem;
  }
  .card-a, .card-b, .card-c { grid-column: 1 / -1; }
  .card-a { grid-template-columns: 1fr; gap: .9rem; }

  .control { width: 100%; }
  #search-input { width: 100%; }
  .control-end { width: 100%; }
  .control-end .btn { width: 100%; }

  #detail {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border: 0;
  }
  .detail-top { padding: .7rem 1.1rem; }
  .detail-article { padding: 1.8rem 1.25rem 3.5rem; }
  .detail-title { font-size: 1.8rem; }

  .colophon-inner { padding: 2rem 1.25rem 2.6rem; }
}

@media (max-width: 480px) {
  .tagline { display: none; }
  .meta-line { flex-direction: column; gap: .15rem; }
  .meta-line .mins { text-align: left; }
  .detail-meta { flex-direction: column; gap: .15rem; }
}
