/*
 * F#21 Shareable Collections — public gallery styles (SET-108).
 *
 * Mirrors Setti's app aesthetic (cool-tinted dark, brand accent #b6c649) but is
 * standalone: the gallery is a separate static deploy with no Tailwind/token
 * build step, so the renderer's design-token values are inlined here verbatim
 * (src/renderer/styles/globals.css :root). Keep them in sync if the app palette
 * shifts materially — this is the public face of a published collection.
 *
 * Fonts: a system stack (no third-party font fetch) — fast LCP, no swap CLS.
 * Self-hosting Geist to match the app exactly is a deferred polish item.
 */

:root {
  /* Surface tiers */
  --surface-inset: oklch(0.12 0.02 266.47);
  --surface-base: oklch(0.179 0.0261 266.47);
  --surface-subtle: oklch(0.215 0.029 263.5);
  --surface-raised: oklch(0.2795 0.0368 260.03);
  --surface-emphasized: oklch(0.3729 0.0306 259.73);

  /* Text tiers */
  --text-primary: oklch(0.9288 0.0126 255.51);
  --text-secondary: oklch(0.7137 0.0192 261.32);
  --text-muted: oklch(0.62 0.024 263);

  /* Borders */
  --border-strong: oklch(0.3796 0.0274 256.82);
  --border-subtle: oklch(0.2795 0.0368 260.03);
  --border-faint: oklch(0.26 0.029 263.5);

  --brand-accent: #b6c649;

  --radius: 0.5rem;
  --radius-tile: 1.25rem; /* matches the app card rounded-[20px] */

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --maxw: 1200px;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-inset);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.0125em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 4rem) clamp(1rem, 4vw, 2.5rem) 3rem;
}

/* ── Masthead ─────────────────────────────────────────────── */
.masthead {
  margin-bottom: clamp(1.5rem, 4vw, 2.75rem);
  max-width: 72ch;
}

.masthead__title {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-wrap: balance;
}

.masthead__description {
  margin: 0.85rem 0 0;
  font-size: clamp(1rem, 1.4vw, 1.125rem);
  line-height: 1.55;
  color: var(--text-secondary);
  text-wrap: pretty;
}

.masthead__meta {
  margin: 1rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Gallery grid ─────────────────────────────────────────── */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: clamp(0.75rem, 1.5vw, 1.25rem);
  align-items: start; /* tiles size to content; don't stretch short tiles to row height */
}

.tile {
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-tile);
  overflow: hidden;
  transition:
    border-color 0.18s ease,
    transform 0.18s ease;
}

@media (hover: hover) {
  .tile:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
  }
}

/* Media frame: aspect-ratio reserves exact space → zero CLS. Falls back to
   1:1 when the manifest omits dimensions. */
.tile__frame {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ar, 1 / 1);
  background: var(--surface-inset);
  display: block;
}

.tile__frame img,
.tile__frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--surface-inset);
}

.tile__frame video {
  object-fit: contain; /* don't crop video frames — controls + letterbox is fine */
}

.tile__badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.2rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
  background: color-mix(in oklch, var(--surface-inset) 78%, transparent);
  border: 1px solid var(--border-faint);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.tile__caption {
  margin: 0;
  padding: 0.75rem 0.9rem 0.9rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-secondary);
  text-wrap: pretty;
}

/* ── States (loading / error / empty) ────────────────────── */
.state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 50vh;
  text-align: center;
  padding: 2rem;
}

.state__text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
}

.state__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.state__link {
  color: var(--brand-accent);
  text-decoration: none;
  font-weight: 500;
}

.state__link:hover {
  text-decoration: underline;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--brand-accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Apex landing (getsetti.com/, no slug) ───────────────── */
.landing {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 60vh;
  text-align: center;
  padding: 2rem;
}

.landing__mark {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.landing__dot {
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--brand-accent);
}

.landing__tagline {
  margin: 0;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  color: var(--text-secondary);
}

.landing__note {
  margin: 0;
  max-width: 42ch;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-wrap: pretty;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-faint);
  font-size: 0.8125rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.wordmark:hover {
  color: var(--text-primary);
}

.wordmark__dot {
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: var(--brand-accent);
}

.footer__links {
  display: inline-flex;
  align-items: center;
  gap: 1.25rem;
}

.footer__link {
  color: var(--text-muted);
  text-decoration: none;
}

.footer__link:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
