/* ═══════════════════════════════════════════════════════════
   CSS ANIMATIONS GALLERY — page styles
   (design tokens inherited from style.css)
   ═══════════════════════════════════════════════════════════ */

.gallery-main {
  position: relative;
  z-index: 1;
  padding-top: 40px;
  padding-bottom: 60px;
}

/* ── HERO ──────────────────────────────────────────────────── */
.gallery-hero {
  max-width: 780px;
  margin-bottom: 36px;
}

.gallery-hero h1 {
  font-family: var(--font-title);
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 14px;
}

.hero-highlight {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gallery-hero-sub {
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1.7;
  max-width: 640px;
}

.reduced-motion-note {
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.reduced-motion-note strong { color: var(--warning); }

/* ── TOOLBAR ───────────────────────────────────────────────── */
.gallery-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
}

/* Sticky only on larger screens (below ~1024px the header can
   wrap to two rows, so the toolbar stays in the page flow).
   Transparent at rest; once pinned it becomes a full-width
   glass bar like the header — no floating box edges. */
@media (min-width: 1024px) {
  .gallery-toolbar {
    position: sticky;
    top: 62px; /* tucks in just below the sticky header */
    z-index: 50;
    margin-inline: calc(50% - 50vw);   /* full viewport bleed */
    padding: 14px calc(50vw - 50%);    /* content stays aligned */
    border-bottom: 1px solid transparent;
    transition: background 0.25s ease, border-color 0.25s ease;
  }

  .gallery-toolbar.is-stuck {
    background: rgba(6, 9, 19, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom-color: var(--border);
  }
}

.gallery-search-wrap {
  position: relative;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 1.1rem;
  pointer-events: none;
}

.gallery-search {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 12px 16px 12px 40px;
  outline: none;
  transition: var(--transition);
}

.gallery-search:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.12);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-family: var(--font-title);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 14px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.chip:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.chip.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
  border-color: var(--secondary);
  color: var(--text);
}

.chip .chip-count {
  opacity: 0.6;
  font-weight: 400;
  margin-left: 4px;
}

/* ── ANIMATION GRID ────────────────────────────────────────── */
.anim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

/* Mid-grid ad slot spans the full row, sitting neatly between cards */
.anim-grid .ad-inline {
  grid-column: 1 / -1;
  padding: 6px 0;
}

.anim-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.anim-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.45);
}

.anim-card.hidden { display: none; }

/* The stage: where each animation performs */
.anim-stage {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(139, 92, 246, 0.08), transparent 70%),
    rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.stage-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.hover-hint {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-disabled);
  pointer-events: none;
}

/* Demo primitives used inside stages */
.demo-box {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 6px 18px -6px rgba(139, 92, 246, 0.5);
}

.demo-btn {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.demo-text {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* ── CARD INFO & ACTIONS ───────────────────────────────────── */
.anim-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 6px;
}

.anim-info h3 {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 600;
}

.anim-cat-tag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.anim-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px 16px;
  margin-top: auto;
}

.btn-view-code,
.btn-copy-anim,
.btn-replay {
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-title);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 0;
  transition: var(--transition);
}

.btn-view-code {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.btn-view-code:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

.btn-copy-anim {
  flex: 1;
  background: var(--secondary);
  border: 1px solid var(--secondary);
  color: #001018;
}

.btn-copy-anim:hover {
  background: var(--text);
  border-color: var(--text);
}

.btn-replay {
  width: 34px;
  flex: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.9rem;
}

.btn-replay:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.25);
  transform: rotate(-45deg);
}

.no-results {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-size: 0.95rem;
}

/* ── CODE MODAL ────────────────────────────────────────────── */
.code-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(3, 5, 12, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.code-modal-overlay[hidden] { display: none; }

.code-modal {
  background: #0b1224;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.code-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.code-modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.code-modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
}

.modal-code {
  margin: 0;
  white-space: pre;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
}

.modal-note {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 10px 14px;
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 8px;
}

/* ── CSS FUNDAMENTALS: LEARN SECTION ───────────────────────── */
.hero-jump {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 600;
}
.hero-jump:hover { text-decoration: underline; }

.fundamentals {
  margin-top: 32px;
  scroll-margin-top: 80px; /* anchor lands below the sticky header */
}

.fundamentals h2 {
  font-family: var(--font-title);
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

.fundamentals-intro {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.7;
  max-width: 720px;
  margin-bottom: 28px;
}

.learn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.learn-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 26px 24px;
}

.learn-kicker {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 10px;
}

.learn-card h3 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.learn-card p {
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.75;
  margin-bottom: 16px;
}

.learn-card p strong { color: var(--text); }

.learn-card code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--secondary);
}

.learn-demo {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.learn-code { white-space: pre; overflow-x: auto; margin: 0; }

/* Colour demo */
.color-demo { display: grid; grid-template-columns: 96px 1fr; gap: 18px; align-items: start; }

.fund-swatch {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: hsl(258, 90%, 66%);
  transition: background 0.15s ease;
}

.fund-sliders { display: flex; flex-direction: column; gap: 8px; }

.fund-sliders label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.fund-sliders strong { color: var(--text); }

.fund-outputs {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fund-out {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: var(--transition);
}

.fund-out:hover { border-color: var(--secondary); color: var(--secondary); }

/* Specificity table */
.spec-table code { white-space: nowrap; }

/* Stacking context demo */
.stack-demo {
  position: relative;
  padding: 10px 10px 34px;
  min-height: 130px;
}

.stack-panel {
  width: 62%;
  padding: 18px 16px;
  border-radius: 10px;
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 600;
}

.stack-a {
  position: relative;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(139, 92, 246, 0.5);
}

.stack-demo.trapped .stack-a { z-index: 0; }

.stack-badge {
  position: absolute;
  right: -70px;
  bottom: -22px;
  z-index: 9999;
  background: var(--warning);
  color: #1a1200;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.stack-b {
  position: relative;
  z-index: 1;
  margin: -18px 0 0 34%;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.35), rgba(6, 182, 212, 0.15));
  border: 1px solid rgba(6, 182, 212, 0.5);
}

.stack-toggle { margin-top: 14px; font-size: 0.82rem !important; }

/* Responsive resize demo */
.resize-box {
  resize: horizontal;
  overflow: auto;
  min-width: 200px;
  max-width: 100%;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 16px 16px 20px;
  position: relative;
  container-type: inline-size;
}

.fluid-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(0.95rem, 7cqi, 1.7rem);
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.autofit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
}

.autofit-grid span {
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.4), rgba(6, 182, 212, 0.4));
  border: 1px solid var(--border);
}

.resize-hint {
  position: absolute;
  right: 8px;
  bottom: 4px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-disabled);
  pointer-events: none;
}

/* ── ARTICLES ──────────────────────────────────────────────── */
.gallery-articles { margin-top: 24px; }

.gallery-articles .seo-explanation h2 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.gallery-articles code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--secondary);
}

.howto-steps {
  margin: 0 0 20px 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.8;
}

.howto-steps li { margin-bottom: 8px; }
.howto-steps strong { color: var(--text); }

/* ── REDUCED MOTION: pause all previews ────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .anim-stage *,
  .anim-stage *::before,
  .anim-stage *::after,
  .gallery-hero h1 {
    animation: none !important;
    transition: none !important;
  }
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .anim-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .anim-stage { height: 120px; }
  .anim-info { flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 12px 4px; }
  .anim-actions { padding: 8px 12px 12px; }
  .code-modal-overlay { padding: 12px; }
  .learn-grid { grid-template-columns: 1fr; }
  .color-demo { grid-template-columns: 1fr; }
  .fund-swatch { width: 100%; height: 64px; }
  .stack-badge { right: -10px; }
}
