/* ---------- Tokens ---------- */
:root {
  --paper: #f4f1ec;
  --surface: #ffffff;
  --ink: #141414;
  --ink-muted: #5b564f;
  --line: #ddd6c9;
  --red: #ce3a1d;
  --blue: #23439c;
  --yellow: #e8a50c;
  --on-accent: #ffffff;
  --paper-muted: #b9b2a6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

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

  --font-display: "Century Gothic", "Avenir Next", Avenir, Futura, "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body: Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;

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

/* ---------- Reset ---------- */
*, *::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: 16px;
  line-height: 1.6;
  overflow-x: clip;
}
h1, h2, h3, p, dl, dd, figure {
  margin: 0;
}
img { max-width: 100%; display: block; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
input, select {
  font: inherit;
  color: inherit;
}
ul { list-style: none; margin: 0; padding: 0; }

/* ---------- Focus & skip link ---------- */
:focus { outline: 2px solid var(--blue); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -100px;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  z-index: 200;
  transition: top 200ms var(--ease-standard);
  font-family: var(--font-display);
  font-weight: 600;
}
.skip-link:focus {
  top: 12px;
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

/* ---------- Eyebrow / labels ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 var(--space-2);
}

/* ---------- Hero ---------- */
.hero {
  background: var(--ink);
  color: var(--paper);
  overflow: clip;
  position: relative;
}
.hero-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-9);
}
@media (min-width: 720px) {
  .hero-inner { padding: var(--space-6) var(--space-8) var(--space-10); }
}

.brand-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
  margin-bottom: var(--space-8);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: var(--space-1);
}
.wordmark:focus-visible { outline-color: var(--yellow); }
.emblem {
  width: 44px;
  height: 44px;
  overflow: visible;
}
.shape { transform-box: fill-box; transform-origin: center; }
.shape-circle { fill: var(--blue); }
.shape-quarter { fill: var(--yellow); }
.shape-triangle { fill: var(--red); }
.shape-square { fill: var(--paper); }

@media (prefers-reduced-motion: no-preference) {
  .shape { animation: shape-in 700ms var(--ease-standard) both; }
  .shape-square { animation-delay: 0ms; }
  .shape-triangle { animation-delay: 90ms; }
  .shape-quarter { animation-delay: 180ms; }
  .shape-circle { animation-delay: 270ms; }
  @keyframes shape-in {
    from { opacity: 0; transform: scale(0.4); }
    to { opacity: 1; transform: scale(1); }
  }
}

.wordmark .shape { transition: transform 400ms var(--ease-standard); }
.wordmark:focus-visible .shape-circle { transform: rotate(25deg) translate(2px, -2px); }
.wordmark:focus-visible .shape-triangle { transform: rotate(-12deg); }
.wordmark:focus-visible .shape-quarter { transform: rotate(15deg); }
@media (hover: hover) and (pointer: fine) {
  .wordmark:hover .shape-circle { transform: rotate(25deg) translate(2px, -2px); }
  .wordmark:hover .shape-triangle { transform: rotate(-12deg); }
  .wordmark:hover .shape-quarter { transform: rotate(15deg); }
}

.wordmark-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
.tagline {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--paper-muted);
  max-width: 46ch;
  line-height: 1.6;
}

.hero-headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.8rem, 9vw, 8.2rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-8);
  max-width: 20ch;
}
@media (prefers-reduced-motion: no-preference) {
  .hero-headline { animation: headline-in 800ms var(--ease-standard) both; animation-delay: 120ms; }
  @keyframes headline-in {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-4);
  background: rgba(244, 241, 236, 0.06);
  border: 1px solid rgba(244, 241, 236, 0.18);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.control {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1 1 200px;
  min-width: 0;
}
.control label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-muted);
}
.control input,
.control select {
  height: 48px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(244, 241, 236, 0.35);
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
}
.control input::placeholder { color: var(--ink-muted); }
.control input:focus-visible,
.control select:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}
.control select { appearance: auto; }

.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 48px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(244, 241, 236, 0.35);
  background: transparent;
  color: var(--paper);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 180ms var(--ease-standard), border-color 180ms var(--ease-standard), transform 150ms var(--ease-standard);
}
.chip-toggle .pin-icon { width: 16px; height: 16px; fill: var(--paper-muted); transition: fill 180ms var(--ease-standard); }
.chip-toggle[aria-pressed="true"] {
  background: var(--yellow);
  border-color: var(--yellow);
  color: var(--ink);
}
.chip-toggle[aria-pressed="true"] .pin-icon { fill: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .chip-toggle:hover { border-color: var(--yellow); transform: translateY(-2px); }
}
.chip-toggle:active { transform: scale(0.97); }
.chip-toggle:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ---------- Board ---------- */
.board {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-9);
}
@media (min-width: 720px) {
  .board { padding: var(--space-9) var(--space-8) var(--space-8); }
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 2px solid var(--ink);
}
.board-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  letter-spacing: -0.02em;
}
.board-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.ledger-head {
  display: none;
  padding: 0 var(--space-4);
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
@media (min-width: 860px) {
  .ledger-head {
    display: grid;
    grid-template-columns: 56px 60px 1fr 140px 90px 90px 80px;
    align-items: center;
    gap: var(--space-4);
  }
}

.ledger {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ---------- Row ---------- */
.row {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: clip;
}
.row-open {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr;
  grid-template-areas:
    "media main"
    "media meta"
    "media cta";
  gap: var(--space-1) var(--space-4);
  padding: var(--space-4);
  text-align: left;
  align-items: center;
  border-radius: inherit;
  transition: background 180ms var(--ease-standard), transform 150ms var(--ease-standard);
}
@media (min-width: 860px) {
  .row-open {
    grid-template-columns: 56px 60px 1fr 140px 90px 90px 80px;
    grid-template-areas: none;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-4);
  }
}

@media (hover: hover) and (pointer: fine) {
  .row-open:hover { background: var(--paper); }
  .row:hover { transform: translateY(-2px); }
  .row { transition: transform 180ms var(--ease-standard); }
}
.row-open:active { transform: scale(0.99); }
.row-open:focus-visible { outline-offset: -3px; }

.row-idx {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-muted);
}
@media (min-width: 860px) { .row-idx { display: block; } }

.row-media {
  grid-area: media;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}
.row-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.row-mark {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.row-mark svg { width: 14px; height: 14px; }

.row-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.row-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.row-category {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.saved-flag {
  display: inline-block;
  margin-left: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
}

.row-meta {
  grid-area: meta;
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
}
@media (min-width: 860px) {
  .row-meta { display: contents; }
}
.row-when, .row-price, .row-seats {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
  white-space: nowrap;
}
@media (min-width: 860px) {
  .row-when, .row-price, .row-seats { font-size: 0.85rem; }
}
.row-price { color: var(--ink); font-weight: 600; }
.row-seats.low { color: var(--red); font-weight: 600; }

.row-cta {
  grid-area: cta;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  margin-top: var(--space-2);
}
@media (min-width: 860px) { .row-cta { margin-top: 0; justify-content: flex-end; } }
.row-cta svg { width: 14px; height: 14px; transition: transform 180ms var(--ease-standard); }
@media (hover: hover) and (pointer: fine) {
  .row-open:hover .row-cta { color: var(--red); }
  .row-open:hover .row-cta svg { transform: translateX(3px); }
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-9) var(--space-5);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.empty-state p {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--ink-muted);
  margin-bottom: var(--space-4);
}
#reset-filters {
  display: inline-flex;
  align-items: center;
  height: 48px;
  padding: 0 var(--space-5);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  transition: background 180ms var(--ease-standard), transform 150ms var(--ease-standard);
}
@media (hover: hover) and (pointer: fine) {
  #reset-filters:hover { background: var(--red); }
}
#reset-filters:active { transform: scale(0.97); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: var(--space-6) var(--space-5);
  text-align: center;
}
.site-footer p {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* ---------- Detail dialog ---------- */
.detail {
  border: none;
  padding: 0;
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: var(--paper);
  width: min(720px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 32px));
  overflow: hidden;
}
.detail::backdrop {
  background: rgba(20, 20, 20, 0.6);
}

.detail-inner {
  overflow-y: auto;
  max-height: min(860px, calc(100vh - 32px));
  position: relative;
}

.detail-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(244, 241, 236, 0.12);
  color: var(--paper);
  z-index: 2;
  transition: background 180ms var(--ease-standard), transform 150ms var(--ease-standard);
}
.detail-close svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .detail-close:hover { background: var(--red); }
}
.detail-close:active { transform: scale(0.92); }
.detail-close:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

.detail-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}
.detail-media img { width: 100%; height: 100%; object-fit: cover; }
.detail-mark {
  position: absolute;
  left: var(--space-5);
  bottom: calc(-1 * var(--space-5));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 4px var(--ink);
}
.detail-mark svg { width: 32px; height: 32px; }

.detail-copy {
  padding: var(--space-7) var(--space-5) var(--space-6);
}
@media (min-width: 600px) {
  .detail-copy { padding: var(--space-7) var(--space-7) var(--space-6); }
}
.detail-copy .eyebrow { color: var(--paper-muted); }
.detail-copy h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}
.detail-instructor {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--paper-muted);
  margin-bottom: var(--space-5);
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  border-top: 1px solid rgba(244, 241, 236, 0.18);
  border-bottom: 1px solid rgba(244, 241, 236, 0.18);
  padding: var(--space-5) 0;
  margin-bottom: var(--space-5);
}
@media (min-width: 600px) {
  .detail-facts { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.detail-facts dt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-muted);
  margin-bottom: var(--space-1);
}
.detail-facts dd {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--paper);
}

.detail-body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--paper);
  max-width: 62ch;
  margin-bottom: var(--space-6);
}

.save-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 48px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-sm);
  border: 2px solid var(--paper);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 180ms var(--ease-standard), color 180ms var(--ease-standard), border-color 180ms var(--ease-standard), transform 150ms var(--ease-standard);
}
.save-toggle .pin-icon { width: 16px; height: 16px; fill: var(--paper); transition: fill 180ms var(--ease-standard); }
@media (hover: hover) and (pointer: fine) {
  .save-toggle:hover { background: rgba(244, 241, 236, 0.12); }
}
.save-toggle:active { transform: scale(0.97); }
.save-toggle:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.save-toggle[aria-pressed="true"] {
  background: var(--red);
  border-color: var(--red);
  color: var(--on-accent);
}
.save-toggle[aria-pressed="true"] .pin-icon { fill: var(--on-accent); }
@media (hover: hover) and (pointer: fine) {
  .save-toggle[aria-pressed="true"]:hover { background: #b3330f; }
}

/* ---------- Category mark colors ---------- */
.mark-Ceramics { fill: var(--blue); }
.mark-Floristry { fill: var(--yellow); }
.mark-Painting { fill: var(--red); }
.mark-Baking { fill: var(--ink); }
.detail-mark .mark-Baking { fill: var(--paper); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
  .shape, .hero-headline { animation: none !important; }
  .row, .row-open, .chip-toggle, .save-toggle, .detail-close, #reset-filters, .row-cta svg, .wordmark .shape {
    transition: none !important;
  }
  .wordmark:hover .shape, .wordmark:focus-visible .shape, .row:hover {
    transform: none !important;
  }
}
