/* Curb - newsstand editorial
   Palette: cool graphite paper, near-black ink, one riso-red accent.
   Type: Oswald (display), DM Sans (body), IBM Plex Mono (metadata).
   Shape lock: sharp corners (radius 0) everywhere. */

@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.ttf") format("truetype");
  font-weight: 100 1000;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 500;
  font-display: swap;
}

:root {
  --paper: #e7e9ec;
  --paper-2: #f2f3f5;
  --surface: #ffffff;
  --ink: #111316;
  --ink-2: #383e46;
  --muted: #5c636c;
  --line: #c5c9d0;
  --rule: #111316;
  --accent: #c0331a;
  --accent-ink: #ffffff;
  --radius: 0px;
  --maxw: 1300px;
  --pad: 32px;
  --font-display: "Oswald", "Arial Narrow", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1113;
    --paper-2: #16191c;
    --surface: #1b1f23;
    --ink: #f1f2f4;
    --ink-2: #c9cdd3;
    --muted: #989fa8;
    --line: #33383f;
    --rule: #f1f2f4;
    --accent: #ff5c3a;
    --accent-ink: #14171a;
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 92px; }

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;
  text-rendering: optimizeLegibility;
}

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

a { color: inherit; }

h1, h2, h3, p { margin: 0; }

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- Nameplate ---------- */
.nameplate {
  border-top: 8px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.nameplate__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px var(--pad) 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: 36px;
  align-items: end;
}
.nameplate__title {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(3.4rem, 9.5vw, 7.5rem);
  line-height: 0.8;
  letter-spacing: -0.015em;
}
.nameplate__aside {
  display: grid;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--accent);
}
.nameplate__statement {
  color: var(--ink-2);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 40ch;
}
.nameplate__issue {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule);
}
.toolbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px var(--pad);
  display: flex;
  align-items: flex-end;
  gap: 22px;
}
.field {
  display: grid;
  gap: 5px;
}
.field--search { flex: 1 1 auto; max-width: 380px; }
.field > label,
.saved-toggle__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.field__control { display: block; }
input[type="search"],
select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
input[type="search"]::placeholder { color: var(--muted); opacity: 1; }
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input[type="search"]:focus,
select:focus { border-color: var(--accent); }

.saved-toggle {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.saved-toggle:hover { background: var(--ink); color: var(--paper); }
.saved-toggle:active { transform: translateY(1px); }
.saved-toggle__count {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border: 1px solid currentColor;
}
.saved-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}
.saved-toggle[aria-pressed="true"] .saved-toggle__count {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ---------- Page / issue ---------- */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 34px var(--pad) 72px;
}
.page:focus { outline: none; }
.issue__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--rule);
  margin-bottom: 28px;
}
.issue__title {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  line-height: 1;
  letter-spacing: 0.01em;
}
.issue__count {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Lead story ---------- */
.stories { display: grid; gap: 40px; }

.lead {
  position: relative;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}
.lead__media { margin: 0; overflow: hidden; background: var(--paper-2); }
.lead__media img {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 11;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.lead__body {
  padding: 34px 36px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  border-left: 1px solid var(--line);
}
.lead__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 3.6vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
}
.lead__summary {
  color: var(--ink-2);
  font-size: 1.05rem;
  max-width: 46ch;
}
.lead__spacer { flex: 1 1 auto; min-height: 4px; }
.lead__body .card__foot { width: 100%; }

.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.kicker__cat {
  color: var(--accent-ink);
  background: var(--accent);
  padding: 4px 9px;
}
.kicker__time { color: var(--muted); }

/* ---------- Story grid ---------- */
.stories__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px 28px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--rule);
}
.card__media {
  margin: 0;
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.card__media img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.card__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.08;
  letter-spacing: -0.005em;
}
.card__summary {
  color: var(--ink-2);
  font-size: 0.95rem;
  line-height: 1.5;
}
.card__foot {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.saved-tag {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--accent);
}
.saved-tag[hidden] { display: none; }

/* Whole-card hit area for the open control */
.story-item { position: relative; }
.open-item {
  align-self: flex-start;
  margin-top: 2px;
  padding: 11px 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.open-item:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.open-item:active { transform: translateY(1px); }
.open-item::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
}
.lead .open-item,
.card .open-item { position: static; }
.story-item:hover .card__title,
.story-item:hover .lead__title,
.story-item:focus-within .card__title,
.story-item:focus-within .lead__title { color: var(--accent); }
.story-item:hover img { transform: scale(1.035); }
.story-item:focus-within { outline: 3px solid var(--accent); outline-offset: 4px; }
.open-item:focus-visible { outline: none; }

/* ---------- Empty state ---------- */
.empty {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 56px 32px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 14px;
}
.empty[hidden] { display: none; }
.empty__title {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1;
}
.empty__text { color: var(--ink-2); max-width: 46ch; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--accent:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Footer ---------- */
.footer {
  border-top: 3px solid var(--rule);
  background: var(--paper-2);
}
.footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 30px var(--pad) 44px;
  display: grid;
  gap: 10px;
}
.footer__brand {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 1.4rem;
  letter-spacing: 0.01em;
}
.footer__note {
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 70ch;
}

/* ---------- Detail dialog ---------- */
.detail {
  width: min(760px, calc(100% - 32px));
  max-height: min(90vh, 920px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  overflow: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.detail::backdrop { background: rgba(9, 11, 13, 0.62); }
.detail__top {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.detail__cat {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 5px 10px;
}
.detail__close {
  padding: 9px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.detail__close:hover { background: var(--ink); color: var(--paper); }
.detail__media { margin: 0; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.detail__media img { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; }
.detail__inner { padding: 30px 38px 40px; }
.detail__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
}
.detail__byline {
  margin-top: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.detail__byline span + span {
  padding-left: 14px;
  margin-left: 14px;
  border-left: 1px solid var(--line);
}
.detail__body { margin-top: 22px; display: grid; gap: 18px; }
.detail__body p {
  color: var(--ink-2);
  font-size: 1.08rem;
  line-height: 1.72;
  max-width: 68ch;
}
.detail__body p:first-child { color: var(--ink); font-size: 1.18rem; }
.detail__actions {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.save-btn {
  padding: 13px 24px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.save-btn:hover { background: var(--ink); color: var(--paper); }
.save-btn:active { transform: translateY(1px); }
.save-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.save-btn[aria-pressed="true"]:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .story-item {
    animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 45ms);
  }
  @keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .stories__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  :root { --pad: 20px; }
  .nameplate__inner {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-top: 22px;
  }
  .nameplate__aside { border-bottom-width: 2px; }
  .toolbar__inner { flex-wrap: wrap; gap: 14px; }
  .field--search { max-width: none; flex: 1 1 100%; order: 1; }
  .field:not(.field--search) { flex: 1 1 140px; order: 2; }
  .saved-toggle { order: 3; }
  .lead { grid-template-columns: 1fr; }
  .lead__body { border-left: none; border-top: 1px solid var(--line); padding: 24px 22px; }
  .lead__media img { aspect-ratio: 16 / 10; }
  .detail__inner { padding: 24px 22px 34px; }
}

@media (max-width: 560px) {
  .stories__grid { grid-template-columns: 1fr; }
  .issue__head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .toolbar__inner { padding-top: 10px; padding-bottom: 12px; }
  .saved-toggle { flex: 1 1 100%; justify-content: center; }
  .detail { width: 100%; max-height: 100dvh; }
}
