/* =========================================================
   Generative Art Showcase — styles
   Modern minimalist. All theming via CSS custom properties.
   ========================================================= */

:root {
  --bg: #0e0e10;
  --bg-elev: #161618;
  --fg: #f4f4f5;
  --fg-muted: #9a9a9f;
  --line: #2a2a2e;
  --accent: #f4f4f5;

  --space: 24px;
  --radius: 10px;
  --max-width: 1400px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --transition: 180ms ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  padding: var(--space) calc(var(--space) * 1.5);
  border-bottom: 1px solid var(--line);
}

.site-header__lead {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 0.75);
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  transition: color var(--transition);
}

.home-link:hover { color: var(--fg); }

.home-link svg { display: block; }

.site-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}

/* ---------- View switcher ---------- */
.view-switcher {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.view-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.view-btn svg { display: block; }

.view-btn:hover { color: var(--fg); }

.view-btn.is-active {
  background: var(--fg);
  color: var(--bg);
}

/* ---------- Layout ---------- */
.content {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--space) * 1.5);
}

/* A class-level `display` would otherwise override the `hidden` attribute,
   leaving both views visible at once. Force hidden elements to stay hidden. */
[hidden] {
  display: none !important;
}

/* ---------- Grid view ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  text-align: left;
  appearance: none;
  font: inherit;
  color: inherit;
  padding: 0;
}

.card:hover {
  border-color: var(--fg-muted);
  transform: translateY(-2px);
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--bg);
}

.card__body {
  padding: 14px 16px 16px;
}

.card__title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.card__meta {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin: 4px 0 0;
}

/* ---------- Stage / fullscreen view ---------- */
.stage {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 1fr auto auto;
  align-items: center;
  gap: 16px;
  min-height: calc(100vh - 160px);
}

.stage-frame-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
}

.stage-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 60vh;
  border: 0;
}

.stage-nav {
  appearance: none;
  border: 0;
  background: none;
  color: var(--fg-muted);
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition);
}

/* Chevron drawn from a square: two adjacent borders, rotated 45deg. */
.stage-nav::before {
  content: "";
  width: 14px;
  height: 14px;
  border: solid currentColor;
  border-width: 2px 2px 0 0;
}
.stage-nav--next::before { transform: translateX(-3px) rotate(45deg); }
.stage-nav--prev::before { transform: translateX(3px) rotate(-135deg); }

.stage-nav:hover {
  color: var(--fg);
}

.stage-caption {
  grid-column: 2;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.stage-caption__title { font-weight: 600; }
.stage-caption__meta { color: var(--fg-muted); font-size: 0.85rem; }

.stage-counter {
  grid-column: 1 / -1;
  grid-row: 3;
  justify-self: center;
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Empty state ---------- */
.empty-state {
  color: var(--fg-muted);
  text-align: center;
  padding: 80px 0;
}

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space);
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space) calc(var(--space) * 1.5);
  border-top: 1px solid var(--line);
}

.site-footer__copy {
  margin: 0;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.site-footer__social {
  display: inline-flex;
  gap: 6px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--fg-muted);
  transition: color var(--transition), background var(--transition);
}

.social-link:hover {
  color: var(--fg);
  background: var(--bg-elev);
}

.social-link svg { display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  /* Stack everything vertically: artwork on top (centered), the prev/next
     buttons below it, then the caption. */
  .stage {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr auto auto auto;
    justify-items: center;
  }
  .stage-frame-wrap { grid-column: 1 / -1; grid-row: 1; }
  .stage-nav--prev { grid-row: 2; grid-column: 1; justify-self: end; }
  .stage-nav--next { grid-row: 2; grid-column: 2; justify-self: start; }
  .stage-caption { grid-column: 1 / -1; grid-row: 3; justify-content: center; }
  .stage-counter { grid-row: 4; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
