:root {
  --paper: #f3ede2;
  --paper-deep: #e9e0d0;
  --card: #fbf8f2;
  --ink: #1f2a24;
  --ink-soft: #4b574f;
  --line: #d6cbb7;
  --clay: #a8431f;
  --clay-dark: #86331a;
  --moss: #26443a;
  --focus: #1b5fd1;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 16px;
  --shadow: 0 1px 2px rgb(31 42 36 / 0.08), 0 8px 24px -12px rgb(31 42 36 / 0.25);
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgb(168 67 31 / 0.15);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  overflow-x: hidden;
  touch-action: manipulation;
}
body.has-dialog { overflow: hidden; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.1; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { touch-action: manipulation; }

.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 40px); }

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

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: absolute; left: 12px; top: -80px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; padding-block: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--clay); }
.brand__mark { width: 30px; height: 30px; }
.brand__name { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.nav-link { text-decoration: none; font-weight: 600; padding: 8px 4px; border-bottom: 2px solid transparent; }
.nav-link:hover { border-bottom-color: var(--clay); }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px; border-radius: 999px; border: 2px solid transparent;
  font-weight: 650; text-decoration: none; cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.button--primary { background: var(--clay); color: #fff; }
.button--primary:hover { background: var(--clay-dark); }
.button--primary:active { transform: scale(0.98); }
.button--ghost { background: transparent; border-color: var(--ink); color: var(--ink); }
.button--ghost:hover { background: var(--ink); color: var(--paper); }
.link-button { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; font-weight: 650; }

/* Hero */
.hero { padding-block: clamp(28px, 5vw, 64px) clamp(24px, 4vw, 48px); }
.hero__inner { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: clamp(24px, 5vw, 72px); align-items: center; }
.eyebrow { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--clay-dark); margin-bottom: 18px; }
.hero h1 { font-size: clamp(2.6rem, 6.4vw, 5.2rem); letter-spacing: -0.025em; }
.hero h1 em { font-style: italic; color: var(--clay); font-weight: 500; }
.hero__lede { margin-block: 22px 28px; max-width: 34em; font-size: clamp(1.05rem, 1.6vw, 1.2rem); color: var(--ink-soft); }
.hero__figure { margin: 0; justify-self: end; width: 100%; max-width: 420px; }
.hero__figure img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 38% 50%;
  border-radius: 999px 999px 20px 20px; background: var(--moss);
  box-shadow: 0 0 0 8px var(--paper), 0 0 0 10px var(--line);
}

/* Browse */
.browse { padding-block: clamp(24px, 4vw, 48px) clamp(48px, 7vw, 96px); scroll-margin-top: 8px; }
.browse__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; margin-bottom: 20px; }
.browse h2 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); letter-spacing: -0.015em; }
.browse__sub { color: var(--ink-soft); }

.toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr) 220px auto; gap: 16px; align-items: end;
  padding: 16px; background: var(--paper-deep); border-radius: var(--radius);
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
.field input, .field select {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid #9d917b; background-color: #fffdf9; color: var(--ink);
  transition: border-color 0.15s ease;
}
.field input:hover, .field select:hover { border-color: var(--ink); }
.field input:focus-visible, .field select:focus-visible { outline-offset: 2px; }
.field input::placeholder { color: #6b6f66; opacity: 1; }
.field select { appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1.5l6 6 6-6' fill='none' stroke='%231f2a24' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}

.toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px 0 14px;
  border-radius: 12px; border: 1.5px solid var(--ink); background: transparent; cursor: pointer; font-weight: 650;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.toggle:hover { background: rgb(31 42 36 / 0.08); }
.toggle__icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.toggle__count {
  min-width: 24px; padding: 0 7px; border-radius: 999px; background: var(--ink); color: var(--paper);
  font-size: 0.8rem; line-height: 24px; text-align: center; font-variant-numeric: tabular-nums;
}
.toggle[aria-pressed="true"] { background: var(--moss); border-color: var(--moss); color: #fff; }
.toggle[aria-pressed="true"]:hover { background: #1a322a; }
.toggle[aria-pressed="true"] .toggle__icon { fill: currentColor; }
.toggle[aria-pressed="true"] .toggle__count { background: #fff; color: var(--moss); }

.results-line { margin-block: 18px 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; min-height: 1.55em; }

/* Cards */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.grid[hidden] { display: none; }
.card {
  position: relative; display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: transform 0.2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card:focus-within { box-shadow: var(--shadow); }
.card__media { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--paper-deep); }
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.card:hover .card__media img { transform: scale(1.04); }
.card__saved {
  position: absolute; top: 12px; right: 12px; display: none; align-items: center; gap: 6px;
  padding: 5px 12px 5px 9px; border-radius: 999px; background: var(--moss); color: #fff; font-size: 0.8rem; font-weight: 700;
}
.card.is-saved .card__saved { display: inline-flex; }
.card__body { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 20px; flex: 1; min-width: 0; }
.card__title { font-size: 1.6rem; letter-spacing: -0.01em; }
.card__open { all: unset; cursor: pointer; display: block; }
.card__open::after { content: ""; position: absolute; inset: 0; }
.card__open:focus-visible { outline: none; }
.card:has(.card__open:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.card__by { color: var(--ink-soft); font-size: 0.95rem; }
.card__desc { color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__foot {
  margin-top: auto; padding-top: 14px; border-top: 1px dashed var(--line);
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.card__when { font-weight: 650; }
.card__when span { color: var(--ink-soft); font-weight: 500; }
.card__price { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; }
.card__seats { color: var(--ink-soft); font-size: 0.9rem; flex-basis: 100%; margin-top: -6px; }

.chip {
  display: inline-block; align-self: flex-start; padding: 3px 12px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--chip-bg, #eee); color: var(--chip-fg, #333);
}
[data-cat="Baking"] { --chip-bg: #f5dfb2; --chip-fg: #6b4308; }
[data-cat="Ceramics"] { --chip-bg: #f2d1c1; --chip-fg: #7d3016; }
[data-cat="Floristry"] { --chip-bg: #f3d3e0; --chip-fg: #7a2549; }
[data-cat="Painting"] { --chip-bg: #d3e2f4; --chip-fg: #1a4377; }

/* Empty / error */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 56px 20px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--ink-soft); }
.empty[hidden], .load-error[hidden] { display: none; }
.empty svg { color: var(--clay); }
.empty h3 { font-size: 1.8rem; color: var(--ink); }
.empty p { max-width: 32em; margin-bottom: 8px; }
.load-error { padding: 16px; background: #f8dcd2; border-radius: 12px; }

/* Footer */
.site-footer { background: var(--moss); color: #e8efe9; padding-block: 36px; font-size: 0.92rem; }
.site-footer__inner { display: grid; gap: 8px; }
.site-footer a { color: #fff; }

/* Detail dialog */
.detail {
  padding: 0; border: 0; border-radius: 24px; background: var(--card); color: var(--ink);
  width: min(960px, calc(100vw - 48px)); max-width: none; max-height: min(720px, calc(100dvh - 48px));
  overflow: hidden; box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.5);
  overscroll-behavior: contain;
}
.detail[open] { display: block; animation: pop 0.22s ease-out; }
.detail::backdrop { background: rgb(24 31 27 / 0.62); }
.detail__scroll { display: grid; grid-template-columns: 0.9fr 1.1fr; max-height: inherit; overflow: auto; overscroll-behavior: contain; }
.detail__media { position: relative; min-height: 100%; background: var(--paper-deep); }
.detail__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.detail__content { display: flex; flex-direction: column; gap: 14px; padding: 40px 36px 0; min-width: 0; }
.detail__close {
  position: absolute; top: 14px; right: 14px; z-index: 3; width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 50%; border: 0; background: var(--ink); color: #fff; cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.detail__close:hover { background: var(--clay-dark); }
.detail__close:active { transform: scale(0.94); }
.detail__close:focus-visible { outline-color: #fff; outline-offset: -6px; box-shadow: 0 0 0 3px var(--focus); }
.detail h2 { font-size: clamp(2rem, 3.4vw, 2.8rem); letter-spacing: -0.02em; padding-right: 40px; overflow-wrap: anywhere; }
.detail__by { color: var(--ink-soft); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 6px 0 0; border-top: 1px solid var(--line); }
.facts > div { padding: 12px 8px 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.facts dt { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.facts dd { margin: 2px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.facts .facts__wide { grid-column: 1 / -1; }
.detail__body { font-size: 1.1rem; line-height: 1.6; margin-top: 4px; }
.detail__actions {
  position: sticky; bottom: 0; margin: auto -36px 0; padding: 18px 36px 28px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  background: linear-gradient(to bottom, rgb(251 248 242 / 0), var(--card) 24%);
}
.detail__hint { color: var(--ink-soft); font-size: 0.9rem; }
.save-btn { min-width: 220px; }
.save-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.save-btn[aria-pressed="true"] { background: var(--moss); }
.save-btn[aria-pressed="true"]:hover { background: #1a322a; }
.save-btn[aria-pressed="true"] svg { fill: currentColor; }

@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }

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

/* Mobile */
@media (max-width: 760px) {
  .hero__inner { grid-template-columns: 1fr; }
  .hero__figure { justify-self: stretch; max-width: none; order: -1; }
  .hero__figure img { aspect-ratio: 16 / 9; border-radius: 999px 999px 16px 16px / 160px 160px 16px 16px; box-shadow: none; }
  .hero h1 { font-size: clamp(2.4rem, 12vw, 3.2rem); }
  .toolbar { grid-template-columns: minmax(0, 1fr) auto; padding: 14px; gap: 12px; }
  .field--search { grid-column: 1 / -1; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }

  .detail {
    width: 100%; height: 100dvh; max-height: none; margin: 0; border-radius: 0; max-width: 100%;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .detail__scroll { display: block; height: 100%; max-height: none; }
  .detail__media { min-height: 0; aspect-ratio: 3 / 2; }
  .detail__content { padding: 22px 20px 0; min-height: calc(100% - 66.6vw); }
  .detail__actions { margin-inline: -20px; padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); }
  .save-btn { flex: 1 1 100%; }
  .detail__close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .card:hover, .card:hover .card__media img { transform: none; }
}
