/*
 * style.css — shared styles for fidgets.adampooley.dev
 *
 * Design tokens match Redirect Manager so both sites look like siblings.
 * All layout is done here; component-specific styles follow in sections.
 */

/* ─── Design tokens (mirror Redirect Manager) ─────────────────────────────── */
:root {
  --bg:          #16171a;
  --surface:     #1e2025;
  --surface-hi:  #252830;
  --border:      #2d2f38;
  --text:        #c8cacd;
  --text-dim:    #606370;
  --text-bright: #e8e9eb;
  --blue:        #58a6ff;
  --orange:      #d89a3a;
  --green:       #3fb950;
  --red:         #e05454;
  --muted-text:  #7a7d88;
}

/* ─── Reset and base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; color: var(--text-bright); }

/* ─── Navigation ──────────────────────────────────────────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 48px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.nav-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.nav-brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
}
.nav-brand:hover { text-decoration: none; color: var(--blue); }

.nav-tagline {
  font-size: 12px;
  color: var(--text-dim);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link {
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  transition: color 0.15s;
}
.nav-link:hover { color: var(--text); text-decoration: none; }

/* Subtle admin link in the top-right of the public nav.
   Visible enough for Adam to find; quiet enough not to confuse visitors. */
.nav-admin-link {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-admin-link:hover {
  color: var(--text);
  border-color: var(--border);
  text-decoration: none;
}

/* ─── Flash messages ──────────────────────────────────────────────────────── */
.flash-list { padding: 12px 24px 0; }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  border: 1px solid transparent;
}
.flash-success { background: #162318; color: var(--green); border-color: #1e3d22; }
.flash-error   { background: #2a1010; color: var(--red);   border-color: #3d1818; }
.flash-info    { background: #0f2040; color: var(--blue);  border-color: #1a3860; }


/* ═══════════════════════════════════════════════════════════════════════════
   CATALOG PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.catalog-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

.catalog-header {
  margin-bottom: 28px;
}
.catalog-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.catalog-subtitle {
  color: var(--text-dim);
  margin: 6px 0 0;
}

/* Model grid */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.1s;
}
.model-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  text-decoration: none;
}

.card-thumb {
  aspect-ratio: 1;
  background: var(--surface-hi);
  overflow: hidden;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-bright);
}
.card-desc {
  font-size: 12px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  color: var(--text-dim);
  padding: 48px 0;
  text-align: center;
}


/* ═══════════════════════════════════════════════════════════════════════════
   VIEWER PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

/*
 * Two-column layout: canvas fills the left, panel scrolls on the right.
 * On mobile the columns stack vertically.
 */
.viewer-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: calc(100vh - 49px); /* full height minus the nav bar */
}

@media (max-width: 800px) {
  .viewer-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;  /* stage grows to fit canvas + media strip */
    height: auto;
  }
  /* flex:1 has no height to fill once the row is auto, so size the canvas
     explicitly; the media strip then flows naturally below it. */
  #canvas-host {
    height: 62vw;
    min-height: 240px;
  }
}

/* ── Canvas area ── */
.viewer-stage {
  position: relative;
  background: radial-gradient(130% 130% at 50% 20%, #21252e 0%, var(--bg) 70%);
  display: flex;
  flex-direction: column;
}

#canvas-host {
  flex: 1;
  position: relative;
}

#canvas-host canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  background: inherit;
}

.canvas-hint {
  margin: 0;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ── Right panel ── */
.viewer-panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.panel-model-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-model-desc {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}
.panel-model-mass {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.panel-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Slot blocks ── */
.slot-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.slot-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-bright);
}
.slot-current-label {
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Swatches ── */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 7px;
}

.swatch {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  outline: 1px solid rgba(255, 255, 255, 0.07);
  transition: transform 0.08s ease, outline-color 0.1s;
}
.swatch:hover {
  transform: translateY(-1px);
  outline-color: rgba(255, 255, 255, 0.2);
}

/* Selected state: white border + checkmark */
.swatch.selected {
  border-color: #fff;
}
.swatch.selected::after {
  content: "✓";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* Out of stock: dimmed + badge */
.swatch-oos {
  opacity: 0.38;
}
.swatch-finish {
  position: absolute;
  bottom: 2px;
  left: 3px;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
.swatch-oos-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

/* ── Configuration summary ── */
.config-summary {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.summary-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.summary-list {
  margin: 0;
  padding-left: 16px;
  font-size: 13px;
}
.summary-list li {
  margin: 3px 0;
}
.summary-list .label {
  color: var(--text-dim);
}

.btn-copy {
  margin-top: 12px;
  width: 100%;
  padding: 9px;
  background: var(--blue);
  color: #0b1020;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.1s;
}
.btn-copy:hover { opacity: 0.88; }
.btn-copy:active { transform: translateY(1px); }

/* ─── Media strip (viewer page) ───────────────────────────────────────────── */
.media-strip {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  overflow-x: auto;          /* horizontal scroll on narrow screens, not wrap */
  scrollbar-width: thin;
}
.media-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 144px;
  height: 144px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-hi);
  cursor: pointer;
  transition: border-color 0.1s, transform 0.1s;
}
.media-thumb:hover { border-color: var(--blue); }
.media-thumb:active { transform: translateY(1px); }
.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-thumb-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  background: rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.media-thumb-more {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-bright);
  font-weight: 600;
  font-size: 14px;
}

/* ─── Lightbox ────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 11, 0.92);
  /* extra bottom room so the centered media clears the thumbnail rail */
  padding: 24px 24px 128px;
}
.lightbox.is-open { display: flex; }
body.lightbox-open { overflow: hidden; }

.lightbox-stage {
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lightbox-content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 92vw;
  max-height: 80vh;
}
.lightbox-content img,
.lightbox-content video {
  max-width: 92vw;
  max-height: 72vh;
  border-radius: 6px;
  display: block;
}
.lightbox-caption {
  color: var(--text);
  font-size: 13px;
  text-align: center;
  max-width: 80vw;
}
.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}
.lightbox-close:hover,
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox-close {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 26px;
  line-height: 1;
}
.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 30px;
  line-height: 1;
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

/* Thumbnail rail along the bottom of the lightbox — jump to any item. */
.lightbox-rail {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 14px 16px;
  overflow-x: auto;
  scrollbar-width: thin;
  background: linear-gradient(to top, rgba(8, 9, 11, 0.85), rgba(8, 9, 11, 0));
}
.lightbox-rail-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-hi);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s, border-color 0.12s, transform 0.12s;
}
.lightbox-rail-thumb:hover { opacity: 0.85; transform: translateY(-2px); }
.lightbox-rail-thumb.is-current {
  opacity: 1;
  border-color: var(--blue);
}
.lightbox-rail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lightbox-rail-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

/* Floating enlarged preview shown while hovering a strip thumbnail. */
.media-hover-preview {
  position: fixed;
  z-index: 900;
  display: none;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.media-hover-preview.is-visible { display: block; }
.media-hover-preview img {
  display: block;
  max-width: 360px;
  max-height: 360px;
  border-radius: 7px;
}
.media-hover-preview.is-video::after {
  content: "▶";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 30px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

/* ─── Admin media list (configure page) ───────────────────────────────────── */
.media-admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.media-admin-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-hi);
}
.media-admin-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex: 0 0 auto;
}
.media-admin-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.media-admin-caption { color: var(--text); font-size: 13px; }
.media-upload-form { margin-top: 4px; }

/* ─── About page ──────────────────────────────────────────────────────────── */
.about-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}
.about-page h1 { margin-bottom: 8px; }
.about-page h2 { margin: 28px 0 8px; font-size: 17px; }
.about-page p { color: var(--text); }
.about-page ul, .about-page ol { color: var(--text); padding-left: 20px; }
.about-page a { color: var(--blue); }
.about-swatch-grid { margin-top: 12px; }
.about-cta { margin: 20px 0; }
.about-catalog-link {
  display: inline-block;
  padding: 10px 18px;
  background: var(--blue);
  color: #0b1020 !important;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: opacity 0.1s;
}
.about-catalog-link:hover { opacity: 0.88; }

/* ─── Error pages ─────────────────────────────────────────────────────────── */
.error-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 80px 20px;
  text-align: center;
}
.error-page .error-code {
  font-size: 64px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.02em;
}
.error-page p { color: var(--text-dim); margin: 8px 0 24px; }

/* ─── Finer mobile pass ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .lightbox-nav { width: 40px; height: 40px; font-size: 24px; }
  .lightbox-close { width: 36px; height: 36px; font-size: 22px; }
  .media-thumb { width: 128px; height: 128px; }
}
