/* Ground Truth — a field guide to city life
   Recipe: Archive Museum, overridden with a vertical spine label
   and an oversized specimen-plate index. */

:root {
  --paper: #f6f3ea;
  --paper-alt: #ece5d1;
  --ink: #1e1c16;
  --muted: #5a543f;
  --accent: #35562e;
  --accent-ink: #f6f3ea;
  --accent-soft: #e3e9d6;
  --line: #c9c0a8;
  --line-strong: #a89c7c;
  --shadow: 0 12px 32px -18px rgba(30, 28, 22, 0.45);

  --radius: 3px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 96px;
  --sp-10: 128px;

  --fs-2xs: 0.75rem;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: 3rem;
  --fs-hero: clamp(3.25rem, 9vw, 7.5rem);

  --font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;
  --font-body: 'Iowan Old Style', Palatino, 'Palatino Linotype', Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Roboto Mono', Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  overflow-x: clip;
}

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

h1, h2, h3, h4, p, dl, dd, figure {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -60px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  background: var(--ink);
  color: var(--paper);
  padding: 0 var(--sp-5);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  z-index: 200;
  transition: top 200ms var(--ease);
}

.skip-link:focus {
  top: var(--sp-4);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Focus ---------- */

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

:focus:not(:focus-visible) {
  outline: 2px solid transparent;
}

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

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: relative;
  z-index: 10;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.brand-mark {
  color: var(--accent);
  flex-shrink: 0;
  animation: compass-spin 90s linear infinite;
}

@keyframes compass-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
}

.brand-tagline {
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  color: var(--muted);
  letter-spacing: 0.04em;
}

.site-nav {
  display: flex;
  gap: var(--sp-5);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-inline-end: var(--sp-2);
}

.site-nav a {
  text-decoration: none;
  padding: var(--sp-3) var(--sp-1);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .site-nav a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
}

.site-nav a:active {
  transform: scale(0.97);
}

/* ---------- Hero ---------- */

.hero {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-10) var(--sp-5) var(--sp-7);
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.9fr);
  gap: var(--sp-8);
  align-items: stretch;
}

.hero-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: var(--sp-4);
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-hero);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--ink);
  animation: hero-settle 700ms var(--ease) both;
}

@keyframes hero-settle {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-lede {
  margin-top: var(--sp-5);
  max-width: 52ch;
  font-size: var(--fs-md);
  line-height: 1.65;
  color: var(--muted);
}

.hero-plate {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--paper-alt);
  border-radius: var(--radius);
  padding: var(--sp-6) var(--sp-5) var(--sp-5) var(--sp-8);
  box-shadow: var(--shadow);
}

.spine-label {
  position: absolute;
  left: var(--sp-3);
  top: var(--sp-5);
  bottom: var(--sp-5);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rosette-title {
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: var(--sp-4);
}

.rosette-key {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.rosette-key li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px dashed var(--line);
}

.rosette-key li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.key-icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.key-name {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.key-count {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* ---------- Controls ---------- */

.controls {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
}

.controls-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-5);
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--sp-5);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.field label {
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field-search {
  flex: 1 1 260px;
  min-width: 200px;
}

.field-search input {
  height: 44px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 16px;
}

.field-search input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field-filter select {
  height: 44px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 16px;
  min-width: 200px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 44px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 150ms var(--ease);
}

.toggle-chip .chip-icon {
  color: var(--accent);
  transition: color 180ms var(--ease);
}

.toggle-chip .count {
  font-family: var(--font-mono);
  color: var(--muted);
}

.toggle-chip.is-active,
.toggle-chip[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.toggle-chip.is-active .chip-icon,
.toggle-chip[aria-pressed='true'] .chip-icon,
.toggle-chip.is-active .count,
.toggle-chip[aria-pressed='true'] .count {
  color: var(--accent-ink);
}

@media (hover: hover) and (pointer: fine) {
  .toggle-chip:hover {
    border-color: var(--accent);
  }
}

.toggle-chip:active {
  transform: scale(0.97);
}

/* ---------- Listing ---------- */

.listing {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-5) var(--sp-9);
}

.listing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

.listing-head h2 {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.listing-count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-6);
}

.plate {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: clip;
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease), border-color 200ms var(--ease);
}

.plate-featured {
  grid-column: span 2;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 1.4fr;
}

.plate-featured .plate-frame {
  aspect-ratio: auto;
  height: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .plate:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--line-strong);
  }
}

.plate:focus-within {
  border-color: var(--accent);
}

.plate-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
}

.plate-frame.family-culture { background: #ece4ef; }
.plate-frame.family-food { background: #eee7d3; }
.plate-frame.family-movement { background: #dfe7ea; }
.plate-frame.family-people { background: #efe3df; }
.plate-frame.family-places { background: var(--accent-soft); }

.plate-number {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(246, 243, 234, 0.85);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
}

.plate-art {
  width: 44%;
  max-width: 96px;
  color: var(--accent);
}

.plate-body {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
}

.plate-family {
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.plate-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.plate-meta {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--muted);
}

.plate-teaser {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink);
  flex: 1;
}

.plate-open {
  margin-top: var(--sp-3);
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: var(--sp-2) 0;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: gap 180ms var(--ease), border-color 180ms var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .plate-open:hover {
    gap: var(--sp-3);
    border-color: var(--accent);
  }
}

.plate-open:active {
  transform: scale(0.97);
}

/* ---------- Empty state ---------- */

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}

.empty-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.empty-detail {
  color: var(--muted);
  margin-bottom: var(--sp-5);
}

.reset-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--sp-5);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-sm);
  transition: transform 150ms var(--ease), opacity 180ms var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .reset-btn:hover {
    opacity: 0.88;
  }
}

.reset-btn:active {
  transform: scale(0.97);
}

/* ---------- Detail dialog ---------- */

.specimen-dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(680px, 92vw);
  width: 100%;
  max-height: 88vh;
  border-radius: var(--radius);
}

.specimen-dialog::backdrop {
  background: rgba(20, 19, 14, 0.6);
}

.specimen-dialog[open] {
  animation: dialog-in 220ms var(--ease) both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.specimen-card {
  position: relative;
  background: var(--paper);
  border: 10px solid var(--paper-alt);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: var(--sp-6);
  max-height: calc(88vh - 20px);
  overflow-y: auto;
}

.dialog-close {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--paper);
  transition: transform 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .dialog-close:hover {
    color: var(--ink);
    border-color: var(--line-strong);
  }
}

.dialog-close:active {
  transform: scale(0.94) rotate(90deg);
}

.specimen-top {
  display: flex;
  gap: var(--sp-5);
  align-items: flex-start;
  padding-right: var(--sp-8);
}

.specimen-art {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: var(--sp-3);
}

.specimen-art.family-culture { background: #ece4ef; }
.specimen-art.family-food { background: #eee7d3; }
.specimen-art.family-movement { background: #dfe7ea; }
.specimen-art.family-people { background: #efe3df; }
.specimen-art.family-places { background: var(--accent-soft); }

.specimen-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-2);
}

.specimen-eyebrow .dot {
  margin: 0 var(--sp-2);
}

.specimen-title {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.specimen-label {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-6);
  margin: var(--sp-6) 0;
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.label-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}

.label-row dt {
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.label-row dd {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--ink);
}

.specimen-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  font-size: var(--fs-md);
  line-height: 1.7;
  max-width: 62ch;
}

.stamp-btn {
  margin-top: var(--sp-7);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 44px;
  padding: var(--sp-2) var(--sp-5) var(--sp-2) var(--sp-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-sm);
  transition: background 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease);
}

.stamp-mark {
  width: 32px;
  height: 32px;
  color: var(--muted);
  transform: scale(0.7) rotate(-18deg);
  opacity: 0.5;
  transition: transform 260ms var(--ease), opacity 260ms var(--ease), color 260ms var(--ease);
}

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

.stamp-btn.is-saved .stamp-mark {
  color: var(--accent-ink);
  transform: scale(1) rotate(-8deg);
  opacity: 1;
  animation: stamp-thud 320ms var(--ease);
}

@keyframes stamp-thud {
  0% { transform: scale(1.6) rotate(-8deg); opacity: 0; }
  60% { transform: scale(0.92) rotate(-8deg); opacity: 1; }
  100% { transform: scale(1) rotate(-8deg); opacity: 1; }
}

@media (hover: hover) and (pointer: fine) {
  .stamp-btn:hover {
    border-color: var(--accent);
  }
}

.stamp-btn:active {
  transform: scale(0.97);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--paper-alt);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-5);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--sp-7);
}

.footer-brand .brand-name {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
}

.footer-brand p {
  margin-top: var(--sp-3);
  color: var(--muted);
  max-width: 40ch;
}

.colophon {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-5);
}

.colophon dt {
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: var(--sp-1);
}

.colophon dd {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.footer-note {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: var(--sp-5);
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ---------- Reduced motion ---------- */

@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;
  }

  .brand-mark {
    animation: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: start;
    padding-top: var(--sp-8);
  }

  .footer-inner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: var(--sp-3) var(--sp-5);
  }

  .brand-tagline {
    display: none;
  }

  .hero {
    padding: var(--sp-7) var(--sp-5) var(--sp-6);
    gap: var(--sp-6);
  }

  .hero-plate {
    padding: var(--sp-5) var(--sp-5) var(--sp-4) var(--sp-7);
  }

  .controls-inner {
    padding: var(--sp-5);
  }

  .field-search,
  .field-filter select {
    min-width: 0;
  }

  .listing {
    padding: var(--sp-7) var(--sp-5) var(--sp-8);
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .plate-featured {
    grid-column: span 1;
    grid-template-columns: 1fr;
  }

  .plate-featured .plate-frame {
    aspect-ratio: 16 / 10;
    height: auto;
  }

  .specimen-card {
    padding: var(--sp-5);
    border-width: 6px;
  }

  .specimen-top {
    padding-right: var(--sp-7);
  }

  .specimen-title {
    font-size: var(--fs-2xl);
  }

  .colophon {
    grid-template-columns: 1fr;
  }
}
