/* ============================================================
   AI-Gallery Design System Tokens
   Exhibition-catalog identity: warm ink, ivory, one vermilion accent.
   ============================================================ */

/* Webfonts — MUST be first: @import has to precede all style rules.
   Off the reflex list: Bricolage Grotesque + Spectral + Hanken Grotesk */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=Hanken+Grotesk:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Spectral:ital,wght@0,300;0,400;0,500;1,400;1,500&display=swap');

/* Colors */
:root {
  /* Surfaces — warm near-black ink, not pure black */
  --ink: #16130f;
  --ink-raised: #211d18;
  --ink-frame: #35302a;
  --ink-deep: #0f0c09;

  /* Type — warm ivory ramp */
  --ivory: #f4efe6;        /* primary text ~17:1 on ink */
  --ivory-soft: #e6dfd3;   /* captions / long-form ~14:1 */
  --ivory-dim: #b7afa2;    /* secondary / labels ~8:1 */
  --ivory-mute: #8b8478;   /* decorative only */

  /* Accent — vermilion (single committed accent) */
  --vermilion: #e8552f;        /* fills; ink text sits ~5:1 */
  --vermilion-bright: #ff6a43; /* hover + small accent text on ink ~5.5:1 */

  /* Washes */
  --hover-wash: rgba(244, 239, 230, 0.14);
  --press-wash: rgba(244, 239, 230, 0.22);
  --overlay-black: rgba(10, 8, 6, 0.4);
}

/* Effects */
:root {
  --hairline-frame: 1px solid var(--ink-frame);
  --hairline-ivory: 1px solid var(--ivory);
  --ring-atmospheric: 0 0 0 1px var(--overlay-black);
  --ring-hover-shadow: 0 0 0 1px var(--ivory-dim);
  --underline-accent: inset 0 -2px 0 0 var(--vermilion);

  --ease: cubic-bezier(0.2, 0, 0.2, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --transition-color: color var(--dur-fast) var(--ease);
  --transition-button: background-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

/* Z-index scale (semantic) */
:root {
  --z-nav: 20;
  --z-sticky: 30;
  --z-modal: 1000;
  --z-cursor: 1100;
}

/* Typography */
:root {
  --font-display: 'Bricolage Grotesque', 'Arial Narrow', Impact, sans-serif;
  --font-sans: 'Hanken Grotesk', system-ui, Helvetica, Arial, sans-serif;
  --font-serif: 'Spectral', Georgia, 'Times New Roman', serif;
  /* Retained for compatibility — catalog labels are tracked sans, not terminal mono */
  --font-mono: 'Hanken Grotesk', system-ui, sans-serif;

  --ls-label: 2px;
  --ls-label-wide: 2.4px;
  --ls-serif: -0.1px;
  --ls-display: -0.02em;
}

/* Radius */
:root {
  --radius-input: 2px;
  --radius-img: 4px;
  --radius-card: 12px;
  --radius-feature: 14px;
  --radius-pill: 999px;
  --radius-round: 50%;
}

/* Spacing — modular scale (1.5x-ish) for consistent rhythm */
:root {
  --container-max: 1300px;
  --gutter: clamp(20px, 4vw, 48px);   /* page side padding */
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 36px;
  --space-6: 56px;
  --section-y: clamp(40px, 6vh, 72px); /* vertical rhythm between sections */
}

/* ============================================================
   Base Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { overflow-x: hidden; }

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

/* Custom scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--ink-frame); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: var(--ivory-mute); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--vermilion-bright); outline-offset: 3px; border-radius: 2px; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

#root { min-height: 100vh; }

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

/* Catalog label — tracked uppercase sans with tabular figures (not terminal mono) */
.label {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.num { font-variant-numeric: tabular-nums; }

/* Compatibility: legacy .mono hooks now render as catalog labels */
.mono {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Animations & Reveals
   ============================================================ */

@keyframes revealIn {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}
.reveal { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .reveal:not(.in) { opacity: 0; }
  .reveal.in { animation: revealIn 0.7s var(--ease-out-quint) both; animation-delay: var(--reveal-delay, 0ms); }
}

@keyframes shimmer { 0% { background-position: -160% 0; } 100% { background-position: 160% 0; } }
.shimmer {
  background: linear-gradient(100deg, #1c1813 30%, #2a251e 50%, #1c1813 70%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .shimmer { animation: none; } }

@keyframes lbFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes viewFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Custom Cursor
   ============================================================ */

#cursor {
  position: fixed; top: 0; left: 0; z-index: var(--z-cursor); pointer-events: none;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--vermilion);
  transform: translate(-50%, -50%);
  transition: width 0.18s var(--ease), height 0.18s var(--ease), background 0.18s var(--ease), opacity 0.2s var(--ease);
  mix-blend-mode: difference;
  opacity: 0;
}
#cursor.active {
  width: 58px; height: 58px;
  background: transparent;
  border: 1px solid var(--vermilion);
}
#cursor .cur-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-sans); font-size: 9px; font-weight: 700; letter-spacing: 1px;
  color: var(--vermilion); text-transform: uppercase; opacity: 0;
  transition: opacity 0.18s var(--ease);
}
#cursor.active .cur-label { opacity: 1; }
@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) {
  #cursor { display: none !important; }
}

/* ============================================================
   Components
   ============================================================ */

/* Buttons */
.ds-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  line-height: 1; border: none; cursor: pointer; transition: var(--transition-button);
  white-space: nowrap;
}
.ds-btn:disabled { cursor: not-allowed; opacity: 0.4; }
.ds-btn.sm { padding: 8px 16px; font-size: 14px; }
.ds-btn.md { padding: 10px 24px; font-size: 16px; }
.ds-btn.lg { padding: 15px 30px; font-size: 15px; }
.ds-btn.label { font-family: var(--font-sans); font-weight: 700; text-transform: uppercase; letter-spacing: var(--ls-label); }
.ds-btn.label.lg { font-size: 13px; }

.ds-btn-primary {
  background: var(--vermilion); color: var(--ink); border-radius: var(--radius-pill);
  font-family: var(--font-sans); font-weight: 700;
}
.ds-btn-primary:hover { background: var(--vermilion-bright); color: var(--ink); }
.ds-btn-primary:active { background: var(--vermilion); opacity: 0.85; }

.ds-btn-outline {
  background: transparent; color: var(--ivory); border: 1px solid var(--ink-frame);
  border-radius: var(--radius-round);
}
.ds-btn-outline:hover { border-color: var(--ivory); background: var(--hover-wash); color: var(--ivory); }

.ds-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer; transition: var(--transition-button); padding: 0;
}
.ds-icon-btn.accent { background: var(--vermilion); color: var(--ink); border: none; }
.ds-icon-btn.accent:hover { background: var(--vermilion-bright); }

/* Tags */
.ds-tag {
  display: inline-flex; align-items: center;
  font-family: var(--font-sans); font-size: 11px; font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; line-height: 1.2; padding: 5px 11px; border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}
.ds-tag.accent { background: var(--vermilion); color: var(--ink); }
.ds-tag.outline { background: transparent; color: var(--ivory-dim); border: 1px solid var(--ink-frame); }

/* Play Glyph */
.play-glyph {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--ivory); background: rgba(15, 12, 9, 0.34);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: var(--ivory); flex: none;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.3s var(--ease-out-quint);
}

/* Media Card */
.media-card {
  cursor: pointer; display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.4s var(--ease-out-quint); width: 100%;
}
@media (hover: hover) and (pointer: fine) {
  .media-card:hover { transform: translateY(-5px); }
  .media-card:hover .play-glyph { border-color: var(--vermilion); color: var(--vermilion); transform: scale(1.06); }
}
.media-card-frame {
  position: relative; border-radius: var(--radius-img); overflow: hidden; background: #1a1610;
}
.media-card-frame::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  border: 1px solid var(--ink-frame); pointer-events: none;
  transition: border-color 0.2s var(--ease); z-index: 10;
}
.media-card:hover .media-card-frame::after { border-color: var(--vermilion); }

.media-card-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  transition: opacity 0.4s var(--ease);
}
.media-card-vid {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity 0.4s var(--ease); pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .media-card:hover .media-card-vid { opacity: 1; }
}

.media-card-broken {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  color: var(--ivory-mute); font-family: var(--font-sans); font-size: 11px; letter-spacing: var(--ls-label);
  text-transform: uppercase; text-align: center; padding: 12px;
}

.media-card-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.28s var(--ease); pointer-events: none;
}
.media-card:hover .media-card-play { opacity: 1; }

.media-card-meta {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--ink-deep);
  border-top: 1px solid var(--ink-frame); padding: 8px 12px; display: flex; align-items: center; gap: 10px;
  transform: translateY(101%); transition: transform 0.34s var(--ease-out-quint); pointer-events: none;
}
.media-card:hover .media-card-meta { transform: translateY(0); }

.media-card-title {
  font-family: var(--font-sans); font-weight: 600; font-size: 15px; line-height: 1.2;
  color: var(--ivory); transition: color 0.15s var(--ease);
}
.media-card:hover .media-card-title { color: var(--vermilion-bright); }

/* Gallery — masonry (each item appears exactly once) */
.gallery {
  columns: 300px 3;
  column-gap: clamp(16px, 2vw, 24px);
}
@media (max-width: 640px) { .gallery { columns: 160px 2; column-gap: 14px; } }
.gallery-item {
  break-inside: avoid;
  margin: 0 0 clamp(16px, 2vw, 24px);
}

.empty-state {
  padding: clamp(48px, 8vh, 96px) 0; text-align: center; color: var(--ivory-dim);
  font-family: var(--font-serif); font-size: clamp(18px, 2.4vw, 24px); font-style: italic;
}

/* Filter Bar */
.filter-bar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: rgba(22, 19, 15, 0.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ink-frame);
}
.filter-btn {
  background: none; border: none; cursor: pointer; padding: 18px 0 16px;
  font-family: var(--font-sans); font-size: 12px; font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; white-space: nowrap; flex: none; font-variant-numeric: tabular-nums;
  color: var(--ivory-dim); box-shadow: none; transition: color 0.15s var(--ease);
}
.filter-btn:hover { color: var(--ivory); }
.filter-btn.active { color: var(--ivory); box-shadow: var(--underline-accent); }
.filter-btn .filter-count { color: var(--ivory-dim); margin-left: 3px; }
.filter-btn.active .filter-count { color: var(--vermilion-bright); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(12, 10, 7, 0.985);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; flex-direction: column; animation: lbFade 0.28s var(--ease);
}
@media (prefers-reduced-motion: reduce) { .lightbox { animation: none; } }
/* Keep the vertical clip clear of the stacked controls on small screens */
@media (max-width: 640px) {
  .lb-vid-container { max-height: 64vh !important; }
}

.lb-error {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--ivory-dim); text-align: center; padding: 24px; z-index: 7;
  /* Semi-transparent so the poster still reads behind the message */
  background: linear-gradient(rgba(15, 12, 9, 0.62), rgba(15, 12, 9, 0.86));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.lb-error .label { color: var(--vermilion-bright); }

/* Loading spinner */
@keyframes lbSpin { to { transform: rotate(360deg); } }
.lb-spinner {
  position: absolute; top: 50%; left: 50%; width: 42px; height: 42px; margin: -21px 0 0 -21px; z-index: 5;
  display: none; pointer-events: none; border-radius: 50%;
  border: 3px solid rgba(244, 239, 230, 0.22); border-top-color: var(--vermilion);
  animation: lbSpin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .lb-spinner { animation: none; } }

/* Seekable progress bar */
.lb-progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 6px; z-index: 6; cursor: pointer;
  background: rgba(244, 239, 230, 0.16);
}
.lb-progress:hover { height: 9px; }
.lb-progress:focus-visible { outline: 2px solid var(--vermilion-bright); outline-offset: -2px; }
.lb-progress-fill { height: 100%; width: 0; background: var(--vermilion); transition: width 0.1s linear; }
@media (prefers-reduced-motion: reduce) { .lb-progress-fill { transition: none; } }

/* Hero */
@media (min-width: 880px) {
  .hero-grid { grid-template-columns: 1.05fr 0.95fr !important; }
}
@media (max-width: 620px) {
  .intro-grid { grid-template-columns: 1fr !important; }
}

.hero-feature {
  position: relative; border-radius: var(--radius-card); overflow: hidden;
  background: #000; cursor: pointer; aspect-ratio: 16 / 9;
}
.hero-feature::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  border: 1px solid var(--ink-frame); pointer-events: none;
  transition: border-color 0.2s var(--ease); z-index: 10;
}
.hero-feature:hover::after { border-color: var(--vermilion); }
@media (hover: hover) and (pointer: fine) {
  .hero-feature:hover .play-glyph { border-color: var(--vermilion); color: var(--vermilion); transform: scale(1.06); }
}

/* Footer */
.back-link { font-size: 13px; font-weight: 700; letter-spacing: var(--ls-label); color: var(--ivory); transition: color 0.15s var(--ease); }
.back-link:hover { color: var(--vermilion-bright); }

/* Lightbox nav — flanking arrows on desktop, under the video on mobile */
.lb-bottom-nav { display: none; }
@media (max-width: 640px) {
  .lb-side-nav { display: none; }
  .lb-bottom-nav { display: flex; }
}

/* Masthead / footer — trim clutter on small screens */
@media (max-width: 620px) {
  .nav-copyright, .nav-tagline { display: none; }
}

/* No-JS fallback */
.nojs-fallback {
  max-width: 640px; margin: 0 auto; padding: clamp(48px, 10vh, 120px) 24px;
  font-family: var(--font-sans); color: var(--ivory);
}
.nojs-fallback h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(40px, 8vw, 72px); line-height: 0.98; margin: 0 0 20px; letter-spacing: var(--ls-display); }
.nojs-fallback p { font-family: var(--font-serif); font-size: 19px; line-height: 1.5; color: var(--ivory-soft); }
.nojs-fallback a { color: var(--vermilion-bright); text-decoration: underline; }
