/* ============================================================
   GROUND FLOOR — a magazine of the everyday city
   World: civic print shop. Marigold notice stock, warm black ink,
   stamp red. Space Grotesk display/UI, Literata for article body.
   ============================================================ */

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 900;
  font-display: swap;
}

:root {
  --marigold: #f2c438;
  --marigold-deep: #e6b624;
  --ink: #191509;
  --ink-soft: #4a4126;
  --stamp: #96220a;
  --paper: #fbf6ea;
  --paper-dim: #f3ecdc;
  --rule: 1px solid var(--ink);
  --rule-heavy: 8px solid var(--ink);
  --grot: "Space Grotesk", "Arial", sans-serif;
  --lit: "Literata", Georgia, "Times New Roman", serif;
  --focus: 2px solid var(--ink);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: var(--marigold); }

body {
  margin: 0;
  background: var(--marigold);
  color: var(--ink);
  font-family: var(--grot);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 56px);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px; top: -48px;
  z-index: 60;
  background: var(--ink);
  color: var(--marigold);
  font-family: var(--grot);
  font-weight: 600;
  padding: 10px 16px;
  text-decoration: none;
  transition: top 160ms var(--ease);
}
.skip-link:focus { top: 12px; }

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

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

.masthead { padding-top: 22px; }

.utility {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: var(--rule);
}

.issue-line {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
}
.issue-no { color: var(--stamp); font-weight: 700; }
.issue-sep { opacity: 0.55; }

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--grot);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: var(--rule);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.saved-toggle:hover { background: var(--ink); color: var(--marigold); }
.saved-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--marigold);
}
.saved-toggle[aria-pressed="true"] .saved-count { color: var(--marigold); }
.saved-toggle .icon { width: 13px; height: 13px; }
.saved-count {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  background: var(--stamp);
  color: var(--marigold);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 6px;
}
.saved-toggle[aria-pressed="true"] .saved-count { background: var(--stamp); }

.mast-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 24px;
  padding: clamp(18px, 3vw, 36px) 0 clamp(20px, 3.2vw, 40px);
}

.wordmark {
  margin: 0;
  font-family: var(--grot);
  font-size: clamp(76px, 11.5vw, 164px);
  line-height: 0.88;
  font-weight: 700;
  letter-spacing: -0.045em;
  text-transform: uppercase;
  color: var(--ink);
}

.mast-aside {
  max-width: 340px;
  padding-bottom: 10px;
  border-left: 3px solid var(--stamp);
  padding-left: 20px;
}
.tagline {
  margin: 0 0 14px;
  font-family: var(--grot);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
}
.mast-note {
  margin: 0;
  font-family: var(--grot);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stamp);
}

.mast-rule { border-top: var(--rule-heavy); }

/* ---------- controls ---------- */

.board { padding-bottom: 8px; }

.controls {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 0;
  border-bottom: var(--rule);
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  max-width: 460px;
  border: var(--rule);
  background: var(--paper);
  padding: 0 14px;
  height: 48px;
}
.search-box .icon { width: 16px; height: 16px; flex: none; color: var(--ink-soft); }
.search-box input {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: var(--grot);
  font-size: 16px;
  color: var(--ink);
  height: 100%;
}
.search-box input::placeholder { color: var(--ink-soft); opacity: 1; }
.search-box input:focus { outline: none; }
.search-box:focus-within {
  outline: var(--focus);
  outline-offset: 2px;
}

.topic-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  border: var(--rule);
  background: var(--paper);
  padding: 0 6px 0 14px;
}
.topic-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.topic-box select {
  height: 36px;
  border: 0;
  background: transparent;
  font-family: var(--grot);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  padding: 0 4px;
  cursor: pointer;
}
.topic-box:focus-within {
  outline: var(--focus);
  outline-offset: 2px;
}

.count {
  margin: 0 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.index-caption {
  margin: 26px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--stamp);
}

/* ---------- the index ---------- */

.index {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  border-top: var(--rule);
}

.row { border-bottom: var(--rule); }

.row-open {
  display: grid;
  grid-template-columns: 56px 148px 1fr auto;
  gap: 22px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 20px 8px;
  cursor: pointer;
  font-family: var(--grot);
  color: var(--ink);
  position: relative;
  isolation: isolate;
}
/* signature interaction: the ink pass */
.row-open::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms var(--ease);
}
.row-open:hover::before,
.row-open:focus-visible::before { transform: scaleX(1); }
.row-open:hover,
.row-open:focus-visible { color: var(--marigold); }
.row-open:hover .row-topic,
.row-open:focus-visible .row-topic { color: var(--marigold); }
.row-open:hover .row-no,
.row-open:focus-visible .row-no { color: var(--marigold); }
.row-open:hover .row-thumb img,
.row-open:focus-visible .row-thumb img { border-color: var(--marigold); }
.row-open:hover .row-saved,
.row-open:focus-visible .row-saved {
  background: var(--marigold);
  color: var(--ink);
}

.row-no {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--stamp);
  letter-spacing: -0.02em;
}

.row-thumb {
  display: block;
  width: 148px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1.5px solid var(--ink);
  filter: saturate(0.9) contrast(1.04);
  display: block;
}

.row-main { min-width: 0; }
.row-title {
  display: block;
  font-size: clamp(21px, 2.2vw, 27px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 7px;
}
.row-summary {
  display: block;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0;
}
.row-open:hover .row-summary,
.row-open:focus-visible .row-summary { color: var(--marigold); opacity: 0.85; }

.row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: none;
}
.row-topic {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stamp);
  border: 1.5px solid currentColor;
  padding: 4px 9px;
  white-space: nowrap;
}
.row-sub {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: right;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.row-open:hover .row-sub,
.row-open:focus-visible .row-sub { color: var(--marigold); opacity: 0.85; }

.row-saved {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--stamp);
  color: var(--marigold);
  padding: 4px 9px;
  margin-top: 2px;
}

/* ---------- empty state ---------- */

.empty-state {
  border: var(--rule);
  border-top: none;
  background: var(--paper);
  padding: clamp(36px, 6vw, 72px) clamp(24px, 5vw, 64px);
  text-align: center;
}
.empty-title {
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.empty-body {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 16px;
}

.btn {
  font-family: var(--grot);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--marigold);
  border: var(--rule);
  padding: 13px 22px;
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.btn:hover { background: var(--stamp); border-color: var(--stamp); }

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

.colophon {
  border-top: var(--rule-heavy);
  background: var(--marigold);
  padding: 36px 0 48px;
  margin-top: 48px;
}
.colophon-mark {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.colophon p {
  max-width: 62ch;
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 10px;
}
.colophon-fine { font-size: 13px !important; color: var(--ink-soft); }

/* ---------- detail sheet ---------- */

.detail {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}

.detail-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(25, 21, 9, 0.55);
  cursor: pointer;
  padding: 0;
}

.sheet {
  position: relative;
  width: min(760px, 100%);
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  border-left: 8px solid var(--ink);
  box-shadow: -32px 0 64px rgba(25, 21, 9, 0.4);
  display: flex;
  flex-direction: column;
  animation: sheet-in 320ms var(--ease);
}

@keyframes sheet-in {
  from { transform: translateX(40px); opacity: 0.4; }
  to { transform: translateX(0); opacity: 1; }
}

.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(20px, 4vw, 44px);
  border-bottom: var(--rule);
  background: var(--paper);
  flex: none;
}
.sheet-brand {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.sheet-actions { display: flex; align-items: center; gap: 10px; }

.save-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--grot);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease),
              border-color 160ms var(--ease);
}
.save-toggle .icon { width: 13px; height: 13px; }
.save-toggle:hover { background: var(--marigold); }
.save-toggle[aria-pressed="true"] {
  background: var(--stamp);
  border-color: var(--stamp);
  color: var(--paper);
}
.save-toggle[aria-pressed="true"] .icon path { fill: currentColor; }

.close-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--grot);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 160ms var(--ease), border-color 160ms var(--ease);
}
.close-btn .icon { width: 12px; height: 12px; }
.close-btn:hover { background: var(--stamp); border-color: var(--stamp); }

.sheet-scroll {
  overflow-y: auto;
  padding: clamp(28px, 5vw, 52px) clamp(20px, 5vw, 56px) 56px;
  flex: 1;
  overscroll-behavior: contain;
}

.sheet-title {
  margin: 0 0 14px;
  font-family: var(--grot);
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.sheet-meta {
  margin: 0 0 26px;
  padding: 12px 0;
  border-top: var(--rule);
  border-bottom: var(--rule);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-variant-numeric: tabular-nums;
}
.sheet-meta .meta-topic { color: var(--stamp); }

.sheet-figure { margin: 0 0 30px; }
.sheet-figure img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1.5px solid var(--ink);
  filter: saturate(0.9) contrast(1.04);
  display: block;
}
.sheet-figure figcaption {
  padding-top: 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-soft);
}

.sheet-body p {
  margin: 0 0 1.15em;
  font-family: var(--lit);
  font-size: 18px;
  line-height: 1.62;
  max-width: 64ch;
}
.sheet-body p:first-child::first-letter {
  font-family: var(--grot);
  font-weight: 700;
  font-size: 3.4em;
  line-height: 0.82;
  float: left;
  padding: 6px 10px 0 0;
  color: var(--stamp);
}

.sheet-end {
  margin: 40px 0 0;
  text-align: center;
  color: var(--stamp);
  font-size: 14px;
  letter-spacing: 0.4em;
}

body.sheet-locked { overflow: hidden; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .mast-row { grid-template-columns: 1fr; align-items: start; }
  .mast-aside {
    border-left: 0;
    border-top: 3px solid var(--stamp);
    padding: 14px 0 0;
    max-width: 460px;
  }
  .row-open {
    grid-template-columns: 40px 112px 1fr;
    grid-template-areas:
      "no thumb main"
      "no thumb meta";
    gap: 14px 16px;
    align-items: start;
  }
  .row-no { grid-area: no; }
  .row-thumb { grid-area: thumb; width: 112px; }
  .row-main { grid-area: main; }
  .row-meta { grid-area: meta; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .row-sub { text-align: left; }
}

@media (max-width: 620px) {
  .utility { flex-wrap: wrap; row-gap: 12px; }
  .controls { gap: 12px; }
  .search-box { max-width: none; flex-basis: 100%; }
  .topic-box { flex: 1 1 auto; }
  .count { margin-left: 0; flex-basis: 100%; }

  .row-open {
    grid-template-columns: 1fr;
    grid-template-areas:
      "meta"
      "thumb"
      "main";
    gap: 12px;
    padding: 18px 4px;
  }
  .row-no { display: none; }
  .row-thumb { width: 100%; aspect-ratio: 16 / 9; }
  .row-title { font-size: 23px; }
  .row-saved { order: -1; }

  .sheet { width: 100%; border-left: 0; }
  .sheet-bar { padding: 12px 18px; }
  .sheet-brand { display: none; }
  .sheet-actions { width: 100%; justify-content: space-between; }
  .save-toggle span, .close-btn span { font-size: 12px; }
  .sheet-body p { font-size: 17px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .row-open::before { transition: none; }
  .sheet { animation: none; }
  .skip-link { transition: none; }
  .saved-toggle, .save-toggle, .close-btn, .btn { transition: none; }
}
