/* ─────────────────────────────────────────────────────────────
   graal.gay v2 — light editorial theme
   ───────────────────────────────────────────────────────────── */

:root {
  --bg: #fafaf8;
  --bg-elev: #ffffff;
  --ink: #1a1a17;
  --ink-soft: #57574f;
  --ink-faint: #8b8b80;
  --line: #e8e8e2;
  --accent: #c8a415;           /* refined graal gold */
  --accent-soft: #f5ecc9;
  --up: #1a7f4b;
  --down: #b3402e;
  --shadow-sm: 0 1px 2px rgb(26 26 23 / .05);
  --shadow-md: 0 2px 6px rgb(26 26 23 / .05), 0 10px 28px -10px rgb(26 26 23 / .12);
  --shadow-lg: 0 4px 10px rgb(26 26 23 / .06), 0 20px 48px -12px rgb(26 26 23 / .18);
  --radius: 14px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}

html[data-theme="dark"] {
  --bg: #131311;
  --bg-elev: #1c1c19;
  --ink: #f2f2ec;
  --ink-soft: #b8b8ac;
  --ink-faint: #7d7d73;
  --line: #2c2c27;
  --accent: #e3c33f;
  --accent-soft: #3a3319;
  --up: #4cc184;
  --down: #e0705c;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
  --shadow-md: 0 2px 6px rgb(0 0 0 / .3), 0 10px 28px -10px rgb(0 0 0 / .5);
  --shadow-lg: 0 4px 10px rgb(0 0 0 / .4), 0 20px 48px -12px rgb(0 0 0 / .6);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s var(--ease-out), color .35s var(--ease-out);
}

.container { max-width: 1180px; margin-inline: auto; padding-inline: 24px; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

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

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

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

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}

.brand {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 600; letter-spacing: -.01em;
}
.brand-dot { color: var(--accent); }

.header-nav { display: flex; align-items: center; gap: 18px; }
.nav-link { font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.nav-link:hover { color: var(--accent); }

.theme-toggle {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--ink-soft);
  transition: background .2s, color .2s, transform .4s var(--ease-out);
}
.theme-toggle:hover { background: var(--line); color: var(--ink); transform: rotate(30deg); }
.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: block; }

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

.hero { padding: 88px 0 56px; }

.hero-eyebrow {
  margin: 0 0 14px;
  font-size: 12.5px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent);
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(38px, 6vw, 64px);
  font-weight: 500; line-height: 1.05; letter-spacing: -.02em;
}
.hero-title em { font-style: italic; color: var(--accent); }

.hero-sub {
  margin: 18px 0 0;
  font-size: 17px; color: var(--ink-soft);
  max-width: 46ch;
}

.hero-stats {
  display: flex; gap: clamp(28px, 6vw, 72px);
  margin: 52px 0 0; padding: 28px 0 0;
  border-top: 1px solid var(--line);
}

.stat { min-width: 0; }
.stat-label {
  font-size: 12px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint);
}
.stat-value {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 500; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.stat-unit { margin-left: 4px; font-size: .6em; color: var(--ink-faint); }

/* ─── Controls ───────────────────────────────────────────── */

.controls { padding-bottom: 28px; }

.search-box {
  position: relative;
  display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 16px;
  color: var(--ink-faint); pointer-events: none;
}
.search-input {
  width: 100%; height: 52px;
  padding: 0 18px 0 46px;
  font: inherit; font-size: 15.5px; color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.filter-row {
  display: flex; flex-wrap: wrap; align-items: end;
  gap: 20px 32px; margin-top: 20px;
}

.filter-group { display: flex; flex-direction: column; gap: 7px; }
.filter-group--range { flex: 1 1 220px; max-width: 320px; }

.filter-label {
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint);
  display: flex; justify-content: space-between; gap: 12px;
}
.filter-label output { color: var(--accent); font-weight: 600; letter-spacing: 0; text-transform: none; }

.select {
  height: 40px; padding: 0 34px 0 14px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--bg-elev) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-sm);
  appearance: none; cursor: pointer;
  transition: border-color .2s;
}
.select:hover, .select:focus { border-color: var(--accent); outline: none; }

/* range slider */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 40px; background: transparent; }
.range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 100%), var(--line) var(--fill, 100%));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: -7px;
  border-radius: 50%; background: var(--bg-elev);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease-out);
}
.range::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
.range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg-elev); border: 2px solid var(--accent);
}

/* segmented control */
.segmented {
  display: inline-flex; padding: 3px;
  background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.segment {
  padding: 6px 14px; border-radius: 7px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  transition: background .18s, color .18s;
}
.segment:hover { color: var(--ink); }
.segment.is-active { background: var(--ink); color: var(--bg); }
html[data-theme="dark"] .segment.is-active { background: var(--accent); color: #131311; }

/* ─── Results meta ───────────────────────────────────────── */

.results-meta {
  min-height: 22px;
  font-size: 13.5px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ─── Card grid ──────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity .5s var(--ease-out),
    transform .5s var(--ease-out),
    box-shadow .25s var(--ease-out),
    border-color .25s;
}
.card.is-in { opacity: 1; transform: none; }
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-img {
  display: grid; place-items: center;
  aspect-ratio: 5 / 4;
  background:
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
/* hats without images get a compact row-style layout instead of a big empty box */
.no-img .card-img { display: none; }

/* ─── GIF freeze on hover (ported from v1) ───────────────
   Static canvas snapshot sits over the live GIF until hover/tap. */
.gif-container { position: relative; }

.gif-container canvas.gif-freeze {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* hide the live GIF while frozen — transparent pixels would show through */
.gif-container.gif-frozen > img { visibility: hidden; }

@media (hover: hover) {
  .gif-container.gif-frozen:hover > img { visibility: visible; }
  .gif-container.gif-frozen:hover canvas.gif-freeze { visibility: hidden; }
}

/* tap-to-play state for touch devices */
.gif-container.gif-frozen.gif-playing > img { visibility: visible; }
.gif-container.gif-frozen.gif-playing canvas.gif-freeze { visibility: hidden; }
.card-img img {
  height: 78%;
  image-rendering: pixelated;
  transition: transform .35s var(--ease-out);
  filter: drop-shadow(0 6px 14px rgb(0 0 0 / .12));
}
.card:hover .card-img img { transform: scale(1.08) translateY(-2px); }
.card-img .img-fallback { font-size: 44px; filter: grayscale(.3); }

.card-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; }

.card-name {
  font-size: 14.5px; font-weight: 600; line-height: 1.3;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}

.card-price-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-price {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 600; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.card-price small { font-size: .62em; font-weight: 500; color: var(--ink-faint); margin-left: 1px; }

.trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.trend--up { color: var(--up); }
.trend--down { color: var(--down); }
.trend--flat { color: var(--ink-faint); }

.card-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--ink-faint);
}

.sparkline { display: block; }
.sparkline polyline {
  fill: none; stroke: var(--accent); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.sparkline .spark-fill { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }

/* skeletons */
.card--skeleton { cursor: default; pointer-events: none; }
.card--skeleton:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--line); }
.sk {
  border-radius: 8px;
  background: linear-gradient(100deg, var(--line) 40%, color-mix(in srgb, var(--line) 40%, var(--bg-elev)) 50%, var(--line) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-img { aspect-ratio: 5 / 4; border-radius: 0; }
.sk-line { height: 14px; }
.sk-line.w60 { width: 60%; }
.sk-line.w40 { width: 40%; }
.sk-line.w80 { width: 80%; }

/* ─── Empty state ────────────────────────────────────────── */

.empty-state { padding: 80px 0; text-align: center; }
.empty-title { margin: 0; font-family: var(--font-display); font-size: 26px; }
.empty-sub { margin: 8px 0 0; color: var(--ink-faint); }

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

.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; padding: 44px 0 72px;
  font-variant-numeric: tabular-nums;
}
.page-btn {
  min-width: 38px; height: 38px; padding: 0 10px;
  border-radius: 9px;
  font-size: 14px; font-weight: 500; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.page-btn:hover:not(:disabled) { background: var(--line); color: var(--ink); }
.page-btn:disabled { opacity: .35; cursor: default; }
.page-btn.is-current { background: var(--ink); color: var(--bg); }
html[data-theme="dark"] .page-btn.is-current { background: var(--accent); color: #131311; }
.page-ellipsis { color: var(--ink-faint); padding: 0 4px; }

/* ─── Modal ──────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: rgb(20 20 17 / .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .25s var(--ease-out);
}
.modal-backdrop[hidden] { display: none; }
.modal-backdrop.is-open { opacity: 1; }

.modal {
  position: relative;
  width: min(560px, 100%); max-height: 86vh; overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg);
  transform: translateY(18px) scale(.98);
  transition: transform .3s var(--ease-out);
}
.modal-backdrop.is-open .modal { transform: none; }
.modal:focus { outline: none; }

.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-elev); border: 1px solid var(--line);
  color: var(--ink-soft);
  transition: color .2s, border-color .2s, transform .2s;
}
.modal-close:hover { color: var(--ink); border-color: var(--accent); transform: rotate(90deg); }

.modal-hero {
  display: grid; place-items: center;
  padding: 44px 24px 28px;
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 72%),
    var(--bg);
  border-bottom: 1px solid var(--line);
}
.modal-hero img { height: 150px; image-rendering: pixelated; filter: drop-shadow(0 10px 22px rgb(0 0 0 / .16)); }

.modal-info { padding: 22px 26px 28px; }
.modal-name { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.modal-desc { margin: 10px 0 0; color: var(--ink-soft); font-size: 14px; }

.modal-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-top: 20px;
}
.modal-stat { padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.modal-stat dt { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.modal-stat dd { margin: 4px 0 0; font-family: var(--font-display); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

.modal-chart { margin-top: 20px; padding: 16px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.modal-chart h4 { margin: 0 0 12px; font-size: 11.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.modal-chart svg { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.chart-dot { fill: var(--bg-elev); stroke: var(--accent); stroke-width: 1.6; }
.chart-label { font-size: 10px; fill: var(--ink-faint); font-family: var(--font-body); }

.modal-sales { margin-top: 18px; }
.modal-sales h4 { margin: 0 0 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.sale-row {
  display: flex; justify-content: space-between;
  padding: 7px 2px; font-size: 13.5px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.sale-row:last-child { border-bottom: 0; }
.sale-date { color: var(--ink-faint); }
.sale-price { font-weight: 600; }

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

.site-footer { border-top: 1px solid var(--line); padding: 30px 0 40px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; font-size: 13px; color: var(--ink-faint); }
.footer-inner p { margin: 0; }
.footer-links a { font-weight: 500; }
.footer-links span { margin: 0 8px; }

/* ─── Reveal on scroll ───────────────────────────────────── */

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); }
.reveal.is-in { opacity: 1; transform: none; }
.reveal:nth-child(2) { transition-delay: .06s; }
.reveal:nth-child(3) { transition-delay: .12s; }
.reveal:nth-child(4) { transition-delay: .18s; }

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

@media (max-width: 640px) {
  .hero { padding: 56px 0 40px; }
  .hero-stats { flex-wrap: wrap; gap: 24px 36px; }
  .filter-row { gap: 16px 20px; }
  .filter-group--range { max-width: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .modal-stats { grid-template-columns: repeat(2, 1fr); }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
