/* ============================================
   Animation Showcase — Anime.js v4 Lab
   Extends style.css design tokens
   ============================================ */

/* --- Demo Section Framework --- */
.demo-section {
  padding: var(--space-3xl) var(--gutter);
  max-width: var(--max-width);
  margin: 0 auto;
  border-top: 1px solid var(--border-light);
}

.demo-section--scroll {
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
}

.demo-section--scroll .demo-header {
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding: 0 var(--gutter);
}

.demo-section--finale {
  background: linear-gradient(180deg, transparent 0%, var(--bg-secondary) 50%, transparent 100%);
}

.demo-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.demo-num {
  font-family: var(--font-serif);
  font-size: var(--text-3xl);
  font-weight: 600;
  color: var(--border-medium);
  line-height: 1;
  min-width: 3rem;
}

.demo-title {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.demo-desc {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 520px;
  line-height: 1.6;
}

.demo-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: var(--space-xl);
}

.demo-btn {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.55rem 1.2rem;
  border-radius: 100px;
  border: 1px solid var(--border-medium);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.35s var(--ease-spring);
}

.demo-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
  transform: translateY(-1px);
}

.demo-btn.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
}

/* ============================================ */
/* HERO                                         */
/* ============================================ */
.showcase-hero {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-3xl) var(--gutter);
  position: relative;
  overflow: hidden;
}

.showcase-hero-inner {
  position: relative;
  z-index: 1;
}

.showcase-hero-title {
  font-family: var(--font-serif);
  font-size: var(--text-hero);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-lg);
}

.sh-line {
  display: block;
}

.sh-line--em {
  font-style: italic;
  color: var(--accent);
}

.showcase-hero-sub {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: var(--space-2xl);
}

.showcase-hero-scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.sh-scroll-line {
  width: 1px;
  height: 48px;
  background: linear-gradient(to bottom, var(--text-tertiary), transparent);
}

/* Hero floating particles */
.sh-hero-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.sh-particle {
  position: absolute;
  border-radius: 50%;
  background: var(--accent-warm);
  opacity: 0;
}

/* ============================================ */
/* DEMO 1 — Stagger Lab                          */
/* ============================================ */
.stagger-stage {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  padding: var(--space-xl);
  display: flex;
  justify-content: center;
}

.stagger-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-sm);
  max-width: 480px;
  width: 100%;
}

.stagger-dot {
  aspect-ratio: 1;
  border-radius: 0.5rem;
  background: var(--accent);
  opacity: 0;
  transform: scale(0);
}

/* ============================================ */
/* DEMO 2 — Spring Physics                       */
/* ============================================ */
.spring-lab {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.spring-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s ease, transform 0.3s var(--ease-spring);
}

.spring-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.spring-ball-wrapper {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.spring-ball {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
}

.spring-ball--subtle { background: #4a9e8e; }
.spring-ball--playful { background: var(--accent-warm); }
.spring-ball--stiff { background: #e8734a; }
.spring-ball--wobbly { background: #7b5ea7; }

.spring-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.spring-label {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 500;
}

.spring-info code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  background: var(--bg-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
  word-break: break-all;
}

/* ============================================ */
/* DEMO 3 — Timeline Orchestra                   */
/* ============================================ */
.timeline-stage {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  height: 320px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tl-circle {
  position: absolute;
  width: 0;
  height: 0;
  border-radius: 50%;
  border: 3px solid var(--accent-warm);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.tl-bar {
  position: absolute;
  height: 4px;
  border-radius: 4px;
  background: var(--accent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scaleX(0);
  transform-origin: left center;
  opacity: 0;
}

.tl-bar--1 { width: 120px; background: #e8734a; }
.tl-bar--2 { width: 100px; background: #4a9e8e; }
.tl-bar--3 { width: 140px; background: #7b5ea7; }
.tl-bar--4 { width: 90px; background: var(--accent-warm); }

.tl-ring {
  position: absolute;
  width: 0;
  height: 0;
  border-radius: 50%;
  border: 2px dashed var(--text-tertiary);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.tl-diamond {
  position: absolute;
  width: 0;
  height: 0;
  background: #d4567a;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  opacity: 0;
}

/* ============================================ */
/* DEMO 4 — Scroll Symphony                      */
/* ============================================ */
.scroll-progress-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 3px;
  background: var(--border-light);
}

.scroll-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.scroll-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: var(--space-xl) var(--gutter);
  max-width: var(--max-width);
  margin: 0 auto;
}

.scroll-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  padding: var(--space-xl);
  opacity: 0.3;
  transform: translateY(40px);
}

.scroll-card--reverse {
  direction: rtl;
}

.scroll-card--reverse .scroll-card-text {
  direction: ltr;
}

.scroll-card-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.scroll-card-shape {
  width: 80px;
  height: 80px;
  background: var(--accent);
  border-radius: 1rem;
}

.scroll-card-pinwheel {
  position: relative;
  width: 80px;
  height: 80px;
}

.scroll-card-pinwheel span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 36px;
  background: var(--accent-warm);
  border-radius: 4px;
  transform-origin: bottom center;
}

.scroll-card-text h3 {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.scroll-card-text p {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============================================ */
/* DEMO 5 — SVG Studio                           */
/* ============================================ */
.svg-lab {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.svg-demo-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  padding: var(--space-lg);
}

.svg-demo-label {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 500;
  margin-bottom: var(--space-md);
}

.svg-demo-label span {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--accent);
}

.svg-canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ============================================ */
/* DEMO 6 — Keyframe Gallery                     */
/* ============================================ */
.keyframe-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  padding: var(--space-xl);
  min-height: 300px;
}

.kf-element {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.kf-inner {
  width: 80px;
  height: 80px;
  background: var(--accent);
  border-radius: 1rem;
}

.kf-code {
  background: #f0ebe3;
  border-radius: 0.75rem;
  padding: var(--space-lg);
  overflow-x: auto;
}

.kf-code code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: #8b6f47;
  line-height: 1.8;
  white-space: pre;
}

/* ============================================ */
/* DEMO 7 — Draggable Playground                 */
/* ============================================ */
.drag-playground {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  height: 350px;
  overflow: hidden;
}

.drag-card {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 500;
  color: white;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.drag-card:active { cursor: grabbing; }

.drag-card:nth-child(1) { top: 30px; left: 40px; background: #e8734a; }
.drag-card:nth-child(2) { top: 50px; left: 200px; background: #4a9e8e; }
.drag-card:nth-child(3) { top: 120px; left: 360px; background: #7b5ea7; }
.drag-card:nth-child(4) { top: 180px; left: 120px; background: #d4567a; }

.drag-hint {
  position: absolute;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  pointer-events: none;
}

/* ============================================ */
/* DEMO 8 — Composition Lab                      */
/* ============================================ */
.comp-lab {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.comp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  padding: var(--space-lg);
  text-align: center;
}

.comp-card h4 {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.comp-card h4 span {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--accent);
}

.comp-card > p {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

.comp-stage {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
  position: relative;
}

/* Track line */
.comp-stage::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--border-light);
}

.comp-ball {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
  z-index: 1;
}

/* ============================================ */
/* DEMO 9 — Text Finale                          */
/* ============================================ */
.text-finale-stage {
  text-align: center;
  padding: var(--space-2xl) var(--gutter);
}

.text-finale-line {
  font-family: var(--font-serif);
  font-size: var(--text-3xl);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.text-finale-credit {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-style: italic;
  color: var(--accent);
  margin-top: var(--space-lg);
}

/* ============================================ */
/* DEMO 10 — Utility Showcase                    */
/* ============================================ */
.utils-lab {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1.25rem;
  padding: var(--space-xl);
}

.utils-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--space-sm);
}

.utils-cell {
  aspect-ratio: 1;
  border-radius: 0.5rem;
  transition: none;
}

/* ============================================ */
/* RESPONSIVE                                   */
/* ============================================ */
@media (max-width: 1024px) {
  .spring-lab { grid-template-columns: repeat(2, 1fr); }
  .comp-lab { grid-template-columns: 1fr; }
  .keyframe-stage { grid-template-columns: 1fr; }
  .svg-lab { grid-template-columns: 1fr; }
  .scroll-card { grid-template-columns: 1fr; }
  .scroll-card--reverse { direction: ltr; }
}

@media (max-width: 768px) {
  .demo-header { flex-direction: column; gap: var(--space-sm); }
  .demo-num { font-size: var(--text-2xl); }
  .stagger-grid { grid-template-columns: repeat(6, 1fr); gap: 4px; }
  .stagger-dot { border-radius: 0.35rem; }
  .spring-lab { grid-template-columns: repeat(2, 1fr); }
  .timeline-stage { height: 250px; }
  .utils-grid { grid-template-columns: repeat(4, 1fr); }
  .showcase-hero-title { font-size: clamp(2.5rem, 1.5rem + 5vw, 5rem); }
  .text-finale-line { font-size: var(--text-2xl); }
  .drag-playground { height: 280px; }
  .drag-card { width: 70px; height: 70px; font-size: var(--text-xs); }
  .drag-card:nth-child(1) { top: 20px; left: 20px; }
  .drag-card:nth-child(2) { top: 30px; left: 120px; }
  .drag-card:nth-child(3) { top: 90px; left: 220px; }
  .drag-card:nth-child(4) { top: 140px; left: 60px; }
}

@media (max-width: 480px) {
  .stagger-grid { grid-template-columns: repeat(6, 1fr); gap: 3px; }
  .spring-lab { grid-template-columns: 1fr; }
  .utils-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================ */
/* BACK BUTTON (mirrored from images.css /       */
/* photo.css for self-containment)               */
/* ============================================ */
.back-btn {
  position: fixed;
  top: 2rem;
  left: 2rem;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.55rem 1.1rem;
  border-radius: 100px;
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color 0.3s ease,
              border-color 0.3s ease,
              transform 0.3s var(--ease-spring);
}

.back-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.04);
}

@media (max-width: 768px) {
  .back-btn {
    top: 1rem;
    left: 1rem;
    padding: 0.4rem 0.9rem;
    font-size: var(--text-xs);
  }
}
