/* ─────────────────────────── Design tokens ─────────────────────────── */

:root {
  --bg: #faf7f2;
  --bg-elev: #ffffff;
  --bg-soft: #f3ede3;
  --bg-hero: linear-gradient(180deg, #faf7f2 0%, #f2e9d8 100%);
  --ink: #19130c;
  --ink-soft: #4a4138;
  --ink-muted: #8c8278;
  --accent: #b8864b;
  --accent-soft: #d7b483;
  --accent-ink: #774e1e;
  --border: #e8dfd0;
  --border-strong: #d4c7b0;
  --ring: rgba(184, 134, 75, 0.28);
  --surface-hi: #ffffff;
  --shadow-sm: 0 1px 2px rgba(30, 20, 10, 0.04), 0 2px 6px rgba(30, 20, 10, 0.04);
  --shadow-md: 0 6px 18px rgba(30, 20, 10, 0.08), 0 2px 4px rgba(30, 20, 10, 0.04);
  --shadow-lg: 0 24px 60px rgba(30, 20, 10, 0.14);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg: #0e0f13;
  --bg-elev: #181a22;
  --bg-soft: #222530;
  --bg-hero: linear-gradient(180deg, #0e0f13 0%, #171925 100%);
  --ink: #f2efe8;
  --ink-soft: #c9c6be;
  --ink-muted: #8e8f99;
  --accent: #d4a574;
  --accent-soft: #e5bf91;
  --accent-ink: #f3d0a3;
  --border: #2b2e3a;
  --border-strong: #3a3d4b;
  --ring: rgba(212, 165, 116, 0.34);
  --surface-hi: #20222c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* ─────────────────────────── Base ─────────────────────────── */

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

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

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}

h1, h2, h3, h4, h5 {
  font-family: 'Fraunces', 'Playfair Display', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--ink);
  margin: 0;
}

h1 { font-size: clamp(2rem, 4.2vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 2.8vw, 2.1rem); }
h3 { font-size: 1.15rem; font-weight: 600; }

p { margin: 0; color: var(--ink-soft); }
p.muted { color: var(--ink-muted); }

a { color: var(--accent-ink); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent); }

code {
  font-family: 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 0.9em;
  background: var(--bg-soft);
  padding: 0.1em 0.4em;
  border-radius: 6px;
  color: var(--ink);
}

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

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

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 1000;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem);
}

.eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 0.75rem;
}

.muted { color: var(--ink-muted); }

/* ─────────────────────────── Buttons ─────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.25rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
    background-color 0.18s, color 0.18s, border-color 0.18s;
  text-decoration: none;
  font-family: inherit;
}
.btn-sm { padding: 0.55rem 1rem; font-size: 0.88rem; }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  color: var(--bg);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* ─────────────────────────── Header ─────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.9rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
}
.brand:hover { color: var(--ink); }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-text strong {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-text small {
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  justify-content: center;
}
.nav a {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.nav a:hover {
  background: var(--bg-soft);
  color: var(--ink);
}
.nav a.active {
  background: var(--ink);
  color: var(--bg);
}
.nav a.active:hover { color: var(--bg); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { border-color: var(--border-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.icon-sun { display: none; }
.icon-moon { display: inline; }
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }

/* ─────────────────────────── Hero ─────────────────────────── */

.hero {
  padding: clamp(3rem, 8vw, 6rem) 0 clamp(2rem, 5vw, 4rem);
  background: var(--bg-hero);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.hero-copy h1 em {
  font-style: italic;
  color: var(--accent-ink);
  font-weight: 500;
}

.hero-copy .lede {
  font-size: 1.12rem;
  color: var(--ink-soft);
  margin-top: 1.25rem;
  max-width: 46ch;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 2.75rem 0 0;
}
.hero-stats > div {
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.hero-stats dt {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}
.hero-stats dd {
  margin: 0.4rem 0 0;
  font-family: 'Fraunces', serif;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.hero-stats .dd-sm {
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.3;
}

/* Hero decorative art — stacked cards with soft gold glow */
.hero-art {
  position: relative;
  aspect-ratio: 4 / 4.3;
  min-height: 320px;
}
.hc {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  box-shadow: var(--shadow-md);
}
.hc1 {
  inset: 12% 18% 18% 0;
  background: linear-gradient(135deg, #d8a866 0%, #b07a39 100%);
  border: none;
  transform: rotate(-6deg);
}
.hc2 {
  inset: 6% 8% 22% 12%;
  background: var(--bg-elev);
  transform: rotate(2deg);
  background-image: radial-gradient(circle at 25% 30%, color-mix(in srgb, var(--accent) 30%, transparent) 0%, transparent 55%);
}
.hc3 {
  inset: 20% 0 4% 22%;
  background: linear-gradient(150deg, var(--ink) 0%, #2a241b 100%);
  transform: rotate(-2deg);
  color: var(--bg);
  background-image: linear-gradient(150deg, var(--ink) 0%, #2a241b 100%),
    radial-gradient(circle at 70% 70%, color-mix(in srgb, var(--accent) 80%, transparent) 0%, transparent 45%);
  background-blend-mode: normal;
}
.hc-glow {
  position: absolute;
  right: -5%;
  bottom: -10%;
  width: 65%;
  aspect-ratio: 1;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 40%, transparent) 0%, transparent 60%);
  filter: blur(30px);
  pointer-events: none;
}

/* ─────────────────────────── Sections ─────────────────────────── */

.section-head {
  margin-bottom: 2.5rem;
  max-width: 42rem;
}
.section-head h2 { margin-top: 0.25rem; }

.features { padding: clamp(3rem, 6vw, 5rem) 0; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.feature {
  padding: 1.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s;
}
.feature:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--accent-ink);
  margin-bottom: 1rem;
}
.feature-icon svg { width: 22px; height: 22px; }
.feature h3 { margin-bottom: 0.4rem; }
.feature p { font-size: 0.95rem; }

/* API section */
.api { padding: clamp(3rem, 6vw, 5rem) 0 clamp(4rem, 8vw, 6rem); background: var(--bg-soft); border-top: 1px solid var(--border); }

.endpoints {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.endpoints li {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 1.25rem;
  align-items: start;
  padding: 1.25rem 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.35rem 0;
  border-radius: 8px;
  color: #fff;
  margin-top: 0.25rem;
}
.method-get { background: #4a6b8f; }
.method-post { background: var(--accent); color: #1a1208; }
.endpoint-path {
  display: inline-block;
  font-size: 0.95rem;
  background: transparent;
  padding: 0;
  color: var(--ink);
}
.endpoints p { margin-top: 0.35rem; font-size: 0.92rem; }

/* ─────────────────────────── List page ─────────────────────────── */

.list { padding: clamp(2.5rem, 5vw, 4rem) 0 5rem; }

.list-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.list-title h1 { margin: 0.25rem 0 0.35rem; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.4rem 0.3rem 1rem;
  box-shadow: var(--shadow-sm);
  min-width: min(360px, 90vw);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}
.search .search-icon {
  width: 18px; height: 18px;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.25rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  outline: none;
}
.search input::placeholder { color: var(--ink-muted); }
.search-clear {
  display: inline-flex;
  width: 24px; height: 24px;
  align-items: center; justify-content: center;
  border-radius: 999px;
  color: var(--ink-muted);
  font-size: 1.2rem;
  line-height: 1;
  text-decoration: none;
}
.search-clear:hover { background: var(--bg-soft); color: var(--ink); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s;
  cursor: zoom-in;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.card-media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-soft);
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease);
}
.card:hover .card-media img {
  transform: scale(1.04);
}

.card-body { padding: 1rem 1.1rem 1.1rem; flex: 1; display: flex; flex-direction: column; gap: 0.55rem; }

.card-response {
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-meta {
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Empty state */
.empty {
  grid-column: 1 / -1;
  padding: 4rem 1rem;
  text-align: center;
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-illo {
  display: inline-flex;
  margin-bottom: 1rem;
  color: var(--ink-muted);
}
.empty-illo svg { width: 56px; height: 56px; }
.empty h3 { margin-bottom: 0.5rem; }
.empty p { color: var(--ink-muted); max-width: 36ch; margin: 0 auto; }

/* ─────────────────────────── Pagination ─────────────────────────── */

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.85rem;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  font-variant-numeric: tabular-nums;
}
.page-link:hover {
  background: var(--bg-soft);
  color: var(--ink);
  border-color: var(--border-strong);
}
.page-link.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.page-link.disabled {
  color: var(--ink-muted);
  background: transparent;
  border-color: transparent;
  cursor: not-allowed;
}
.pagination .gap {
  color: var(--ink-muted);
  padding: 0 0.25rem;
}

/* ─────────────────────────── Lightbox ─────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 8, 5, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  animation: lightbox-in 0.25s var(--ease-out);
}
.lightbox[hidden] { display: none; }

@keyframes lightbox-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}
.lightbox-figure img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: lightbox-img 0.35s var(--ease-out);
}
@keyframes lightbox-img {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.lightbox-figure figcaption {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.95rem;
  max-width: 60ch;
  text-align: center;
  line-height: 1.55;
}
.lightbox-figure figcaption:empty { display: none; }

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.05); }
.lightbox-close svg { width: 20px; height: 20px; }

/* ─────────────────────────── Error page ─────────────────────────── */

.error-screen {
  padding: clamp(4rem, 10vw, 8rem) 0;
}
.error-inner {
  max-width: 44rem;
}
.error-detail {
  margin: 1.5rem 0 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.88rem;
  color: var(--ink-soft);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─────────────────────────── Footer ─────────────────────────── */

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
  flex-wrap: wrap;
}
.footer-inner .dot { opacity: 0.5; }

/* ─────────────────────────── Animations ─────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .feature, .card, .hero-stats > div {
    opacity: 0;
    transform: translateY(12px);
    animation: enter 0.6s var(--ease-out) forwards;
  }
  .card:nth-child(n+4) { animation-delay: 0.05s; }
  .card:nth-child(n+7) { animation-delay: 0.1s; }
}
@keyframes enter {
  to { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────── Responsive ─────────────────────────── */

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { min-height: 240px; max-width: 28rem; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .list-header { flex-direction: column; align-items: stretch; }
  .search { min-width: 0; }
  .endpoints li { grid-template-columns: 64px 1fr; gap: 0.9rem; padding: 1rem 1.1rem; }
}

@media (max-width: 560px) {
  .nav { display: none; }
  .header-inner { gap: 0.75rem; }
  .hero-ctas { flex-direction: column; align-items: stretch; }
  .hero-ctas .btn { justify-content: center; }
  .grid { grid-template-columns: 1fr; gap: 1rem; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
}
