/**
 * ASDF Learn Page - CSS
 *
 * Extracted from inline styles for maintainability.
 * Self-contained with custom variables (not dependent on system.css).
 *
 * @version 2.0.0
 */

@import url('./design-tokens.css');

:root {
  --bg: #0d0906;
  --surface: #1a1410;
  --text: #faf8f5;
  --text-muted: #c9b89a;
  --text-ghost: #5a4d40;
  --accent: #eab308;
  --accent-soft: rgba(234, 179, 8, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  overflow: hidden;
}
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  visibility: hidden;
}
body.ready {
  visibility: visible;
}

/* Container - Smooth scroll */
.container {
  height: 100vh;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, var(--bg), transparent);
}
.back {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--text-ghost);
  text-decoration: none;
}
.back:hover {
  color: var(--accent);
}
.level {
  padding: var(--space-xs) var(--space-sm);
  background: var(--accent-soft);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 100px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--accent);
}

/* Progress */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--surface);
  z-index: calc(var(--z-sticky) + 1);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f59e0b);
  width: 0%;
  transition: width var(--duration-slow);
}

/* Phase */
.phase {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg);
  transition:
    opacity var(--duration-slow) ease,
    filter var(--duration-slow) ease,
    transform var(--duration-slow) ease;
}
.phase.locked {
  opacity: 0.08;
  filter: blur(8px);
  pointer-events: none;
  transform: scale(0.98);
}
.phase.active {
  opacity: 1;
  filter: none;
  transform: none;
}
.phase-inner {
  max-width: 480px;
  width: 100%;
}

.badge {
  display: inline-block;
  padding: var(--space-2xs) var(--space-sm);
  margin-bottom: var(--space-md);
  border-radius: 100px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-2xs);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-ghost);
}
.phase.completed .badge {
  background: var(--accent-soft);
  border-color: rgba(234, 179, 8, 0.3);
  color: var(--accent);
}

/* Swipe Title */
.swipe-title {
  position: relative;
  overflow: hidden;
  margin-bottom: var(--space-sm);
}
.swipe-title h2 {
  font-size: clamp(26px, 5vw, 38px);
  font-weight: var(--font-normal);
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
}
.swipe-mask {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  padding-left: var(--space-2xs);
  cursor: grab;
  user-select: none;
  transition: transform 0.05s linear;
}
.swipe-mask.dragging {
  cursor: grabbing;
}
.swipe-mask.done {
  transform: translateX(100%);
  pointer-events: none;
  transition: transform var(--duration-fast) ease;
}
.swipe-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--text-ghost);
}
.swipe-arrow {
  display: inline-block;
  animation: bounce 1s ease infinite;
  margin-left: var(--space-xs);
}
@keyframes bounce {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(4px);
  }
}

.subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--text-ghost);
  margin-bottom: var(--space-lg);
}
.text p {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-sm);
}

/* Interaction hint */
.hint {
  margin-top: var(--space-lg);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--text-ghost);
}

/* Drag Slider */
.drag-slider {
  position: relative;
  height: 56px;
  margin-top: var(--space-lg);
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.drag-slider.done {
  display: none;
}
.drag-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  transform: scaleX(0);
  transform-origin: left;
}
.drag-hint-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: var(--space-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--text-ghost);
}
.drag-handle {
  position: absolute;
  left: var(--space-2xs);
  top: var(--space-2xs);
  bottom: var(--space-2xs);
  width: 48px;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.4), rgba(234, 179, 8, 0.2));
  border: 1px solid rgba(234, 179, 8, 0.5);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: var(--text-sm);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.drag-handle.dragging {
  cursor: grabbing;
}
.drag-success {
  display: none;
  padding: var(--space-lg);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
}
.drag-slider.done + .drag-success {
  display: block;
}
.drag-success span {
  opacity: 0;
  animation: fadein 0.3s ease forwards;
}
.drag-success span:nth-child(1) {
  animation-delay: 0s;
}
.drag-success span:nth-child(2) {
  animation-delay: 0.15s;
  color: var(--accent);
}
.drag-success span:nth-child(3) {
  animation-delay: 0.3s;
}
.drag-success span:nth-child(4) {
  animation-delay: 0.45s;
  color: #f59e0b;
}
.drag-success span:nth-child(5) {
  animation-delay: 0.6s;
}
@keyframes fadein {
  to {
    opacity: 1;
  }
}

/* Burn Clicker */
.burn-box {
  position: relative;
  height: 110px;
  margin-top: var(--space-lg);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  cursor: pointer;
  overflow: hidden;
}
.burn-box.done {
  background: var(--accent-soft);
  border-color: rgba(234, 179, 8, 0.3);
  cursor: default;
}
.burn-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}
.burn-box.done .burn-content {
  display: none;
}
.burn-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--text-ghost);
}
.burn-dots {
  display: flex;
  gap: var(--space-xs);
}
.burn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transition: background var(--duration-fast);
}
.burn-dot.on {
  background: var(--accent);
}
.burn-done {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.burn-box.done .burn-done {
  display: flex;
}
.burn-done-icon {
  font-size: var(--text-2xl);
}
.burn-done-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--accent);
}
.burn-emoji {
  position: absolute;
  font-size: var(--text-xl);
  pointer-events: none;
  animation: floatup 0.8s ease forwards;
}
@keyframes floatup {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }
  100% {
    transform: scale(1.5) translateY(-30px);
    opacity: 0;
  }
}

/* Type Input */
.type-wrap {
  margin-top: var(--space-lg);
  text-align: center;
}
.type-wrap.done .type-input,
.type-wrap.done .type-hint {
  display: none;
}
.type-input {
  width: 100%;
  max-width: 280px;
  padding: var(--space-sm) var(--space-md);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(234, 179, 8, 0.2);
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-base);
  text-align: center;
  color: var(--text);
  outline: none;
}
.type-input::placeholder {
  color: var(--text-ghost);
}
.type-input:focus {
  border-color: rgba(234, 179, 8, 0.5);
}
.type-input.shake {
  animation: shake 0.3s ease;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}
.type-hint {
  margin-top: var(--space-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--text-ghost);
}
.type-hint span.on {
  color: var(--accent);
}
.type-done {
  display: none;
  padding: var(--space-lg);
}
.type-wrap.done .type-done {
  display: block;
}
.type-done-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-lg);
  color: var(--accent);
}
.type-done-sub {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Explore Grid — 5 items: 2+2+1 */
.explore {
  margin-top: var(--space-lg);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

/* 5th item spans full width */
.explore-item:nth-child(5) {
  grid-column: 1 / -1;
}
.explore-item {
  padding: var(--space-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast);
}
.explore-item:hover {
  border-color: rgba(234, 179, 8, 0.2);
}
.explore-item.on {
  background: var(--accent-soft);
  border-color: rgba(234, 179, 8, 0.3);
}
.explore-icon {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2xs);
}
.explore-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.explore-item.on .explore-name {
  color: var(--accent);
}
.explore-check {
  display: none;
  margin-left: var(--space-2xs);
}
.explore-item.on .explore-check {
  display: inline;
}
.explore-done {
  display: none;
  margin-top: var(--space-md);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--accent);
}
.explore.done + .explore-done {
  display: block;
}

/* Final */
.final {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
}
.final.show {
  display: flex;
}
.final-icon {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-md);
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}
.final-title {
  font-size: clamp(24px, 5vw, 32px);
  font-weight: var(--font-normal);
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
  margin-bottom: var(--space-sm);
}
.final-sub {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}
.final-cta {
  display: inline-block;
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.3), rgba(234, 179, 8, 0.15));
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--accent);
  text-decoration: none;
}
.final-cta:hover {
  transform: translateY(-2px);
}
.final-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: center;
}
.final-cta-alt {
  display: inline-block;
  padding: var(--space-sm) var(--space-lg);
  background: transparent;
  border: 1px solid var(--text-ghost);
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
}
.final-cta-alt:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}
.final-back {
  display: block;
  margin-top: var(--space-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--text-ghost);
  text-decoration: none;
}

/* Tool descriptions in Phase 5 */
.explore-desc {
  display: block;
  font-size: var(--text-2xs);
  color: var(--text-ghost);
  margin-top: var(--space-2xs);
  font-family: 'Inter', sans-serif;
}

/* Responsive */
@media (max-width: 600px) {
  .header {
    padding: var(--space-sm) var(--space-md);
  }
  .phase {
    padding: var(--space-2xl) var(--space-md);
  }
  .explore {
    grid-template-columns: 1fr;
  }
  /* On mobile, 5th item is just normal 1-column */
  .explore-item:nth-child(5) {
    grid-column: auto;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .phase {
    transition: opacity var(--duration-fast);
  }
  .swipe-arrow,
  .final-icon {
    animation: none;
  }
  .burn-emoji {
    animation: none;
    opacity: 0;
  }
}
