/* ── DevPilot Showreel — self-contained dark theme ──────────────────────────
   Breakpoint variables are defined for JS / Sprint-2 access.
   @media rules use literal px values (CSS vars not valid in media queries).
   Breakpoints: sm=768px  lg=1280px  xl=1600px                              */

/* ── Custom properties ───────────────────────────────────────────────────── */
:root {
  /* Breakpoints (documentation / JS-readable; not usable inside @media) */
  --bp-sm: 768px;
  --bp-lg: 1280px;
  --bp-xl: 1600px;

  /* Colour tokens */
  --sr-bg:        #0A0A14;
  --sr-bg-card:   #111827;
  --sr-bg-rail:   #0D0D1A;
  --sr-bg-overlay:#000000cc;
  --sr-border:    rgba(255,255,255,0.08);
  --sr-accent:    #E8820C;
  --sr-accent-dim:rgba(232,130,12,0.15);
  --sr-text:      #F1F5F9;
  --sr-muted:     #94A3B8;
  --sr-chip-bg:   rgba(255,255,255,0.06);
  --sr-chip-active:rgba(232,130,12,0.18);

  /* Artifact-type badge palette */
  --badge-image:    #22c55e;
  --badge-video:    #3b82f6;
  --badge-pdf:      #ef4444;
  --badge-gltf:     #a855f7;
  --badge-usdz:     #8b5cf6;
  --badge-godot:    #06b6d4;
  --badge-reveal:   #f59e0b;
  --badge-markdown: #64748b;
  --badge-code:     #10b981;
  --badge-json:     #f97316;

  /* Typography */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --sr-gap:   16px;
  --sr-rail-w: 220px;

  /* Motion */
  --dur-fast:  150ms;
  --dur-med:   250ms;
  --ease-out:  cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure [hidden] always wins even against display:grid/flex rules */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background: var(--sr-bg);
  color: var(--sr-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ── Skip link ───────────────────────────────────────────────────────────── */
.sr-skip {
  position: fixed;
  top: -100%;
  left: 16px;
  z-index: 9999;
  background: var(--sr-accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
  transition: top var(--dur-fast) var(--ease-out);
}
.sr-skip:focus { top: 16px; }

/* ── Top navigation ──────────────────────────────────────────────────────── */
.sr-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: rgba(10,10,20,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--sr-border);
}

.sr-nav__brand {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--sr-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sr-nav__brand span { color: var(--sr-accent); }

.sr-nav__back {
  margin-left: auto;
  font-size: 13px;
  color: var(--sr-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--dur-fast);
}
.sr-nav__back:hover { color: var(--sr-text); }

/* ── Page header ─────────────────────────────────────────────────────────── */
.sr-header {
  padding: 48px 24px 32px;
  max-width: 720px;
}
.sr-header h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.2;
  margin-bottom: 12px;
}
.sr-header h1 em { color: var(--sr-accent); font-style: italic; }
.sr-header p { color: var(--sr-muted); font-size: 15px; max-width: 540px; }

/* ── Body layout: rail + gallery ─────────────────────────────────────────── */
.sr-body {
  display: flex;
  align-items: flex-start;
  padding: 0 24px 120px;
  gap: 24px;
  max-width: 1800px;
  margin: 0 auto;
}

/* ── Filter rail ─────────────────────────────────────────────────────────── */
.sr-rail {
  width: var(--sr-rail-w);
  flex-shrink: 0;
  position: sticky;
  top: 72px;
  background: var(--sr-bg-rail);
  border: 1px solid var(--sr-border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}

.sr-rail__heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sr-muted);
  padding: 4px 0 8px;
}

.sr-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--sr-muted);
  background: var(--sr-chip-bg);
  border: 1px solid transparent;
  transition: all var(--dur-fast) var(--ease-out);
  text-align: left;
  width: 100%;
}
.sr-chip:hover { color: var(--sr-text); border-color: var(--sr-border); }
.sr-chip[aria-pressed="true"],
.sr-chip.active {
  color: var(--sr-accent);
  background: var(--sr-chip-active);
  border-color: var(--sr-accent);
}
.sr-chip__count {
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 1px 6px;
}

/* Mobile filter toggle (hidden on desktop) */
.sr-rail-toggle {
  display: none;
  position: fixed;
  bottom: 72px;
  right: 16px;
  z-index: 150;
  background: var(--sr-accent);
  color: #fff;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

/* ── Gallery: CSS columns masonry ────────────────────────────────────────── */
.sr-gallery {
  flex: 1;
  min-width: 0;
  column-count: 1;
  column-gap: var(--sr-gap);
}

.sr-card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: var(--sr-gap);
  background: var(--sr-bg-card);
  border: 1px solid var(--sr-border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--dur-med) var(--ease-out),
              border-color var(--dur-med) var(--ease-out),
              box-shadow var(--dur-med) var(--ease-out);
}
.sr-card:hover {
  transform: translateY(-2px);
  border-color: var(--sr-accent);
  box-shadow: 0 0 0 1px var(--sr-accent), 0 8px 32px rgba(232,130,12,0.12);
}
.sr-card:focus-visible {
  outline: 2px solid var(--sr-accent);
  outline-offset: 2px;
}

.sr-card__thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #1e293b;
}
.sr-card__thumb--wide { aspect-ratio: 16/9; }

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

.sr-card__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.sr-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid currentColor;
}
.sr-badge--image    { color: var(--badge-image); }
.sr-badge--video    { color: var(--badge-video); }
.sr-badge--pdf      { color: var(--badge-pdf); }
.sr-badge--gltf     { color: var(--badge-gltf); }
.sr-badge--usdz     { color: var(--badge-usdz); }
.sr-badge--godot    { color: var(--badge-godot); }
.sr-badge--reveal   { color: var(--badge-reveal); }
.sr-badge--markdown { color: var(--badge-markdown); }
.sr-badge--code     { color: var(--badge-code); }
.sr-badge--json     { color: var(--badge-json); }

.sr-card__title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--sr-text);
  margin-bottom: 4px;
}
.sr-card__caption {
  font-size: 12px;
  color: var(--sr-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Skeleton loading cards ──────────────────────────────────────────────── */
@keyframes sr-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.8; }
}

.sr-skeleton {
  break-inside: avoid;
  margin-bottom: var(--sr-gap);
  background: var(--sr-bg-card);
  border: 1px solid var(--sr-border);
  border-radius: 10px;
  overflow: hidden;
  animation: sr-pulse 1.5s ease-in-out infinite;
}
.sr-skeleton__thumb {
  width: 100%;
  aspect-ratio: 4/3;
  background: #1e293b;
}
.sr-skeleton__body { padding: 14px 16px 16px; }
.sr-skeleton__line {
  height: 10px;
  border-radius: 4px;
  background: #1e293b;
  margin-bottom: 8px;
}
.sr-skeleton__line--title { width: 70%; height: 12px; }
.sr-skeleton__line--short { width: 45%; }

/* ── Empty / error state ─────────────────────────────────────────────────── */
.sr-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--sr-muted);
}
.sr-empty__icon { font-size: 40px; margin-bottom: 16px; }
.sr-empty__text { font-size: 15px; }

/* ── Lightbox ────────────────────────────────────────────────────────────── */
.sr-lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  background: var(--sr-bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px;
}

.sr-lightbox__dialog {
  background: var(--sr-bg-card);
  border: 1px solid var(--sr-border);
  border-radius: 14px;
  width: min(960px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}

.sr-lightbox__toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--sr-border);
  flex-shrink: 0;
}
.sr-lightbox__title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-lightbox__close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sr-muted);
  font-size: 18px;
  transition: background var(--dur-fast), color var(--dur-fast);
  flex-shrink: 0;
}
.sr-lightbox__close:hover { background: var(--sr-chip-bg); color: var(--sr-text); }
.sr-lightbox__close:focus-visible { outline: 2px solid var(--sr-accent); }

.sr-lightbox__viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  min-height: 200px;
}

/* ── GOLDEN-047 status bar ───────────────────────────────────────────────── */
#lg-status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 400;
  background: rgba(10,10,20,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--sr-border);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--font-body);
  font-size: 12px;
  color: rgba(255,255,255,0.65);
}

@keyframes lg-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.lg-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 6px #22c55e;
  animation: lg-pulse 2s ease-in-out infinite;
  display: inline-block;
}
.lg-sep { opacity: 0.3; }
#lg-status-bar a { color: #60a5fa; text-decoration: none; }
#lg-status-bar a:hover { text-decoration: underline; }

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

/* Tablet: 768px+ — 2-column masonry, side rail visible */
@media (min-width: 768px) {
  .sr-gallery { column-count: 2; }
  .sr-rail-toggle { display: none; }
}

/* Desktop: 1280px+ — 3-column masonry */
@media (min-width: 1280px) {
  .sr-gallery { column-count: 3; }
}

/* Wide: 1600px+ — 4-column masonry */
@media (min-width: 1600px) {
  .sr-gallery { column-count: 4; }
}

/* Mobile: <768px — stacked, bottom-sheet rail */
@media (max-width: 767px) {
  .sr-body {
    flex-direction: column;
    padding: 0 12px 120px;
  }

  .sr-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    top: auto;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    transform: translateY(100%);
    transition: transform var(--dur-med) var(--ease-out);
    z-index: 300;
    overflow-y: auto;
  }
  .sr-rail.open {
    transform: translateY(0);
  }

  .sr-rail-toggle {
    display: flex;
  }

  .sr-header { padding: 32px 12px 24px; }
  .sr-gallery { column-count: 1; }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
