/* ===== Spring Animation Playground — CSS ===== */

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

:root {
  --bg: #FFFAF5;
  --bg-alt: #FFF0F3;
  --surface: #FFFFFF;
  --pink-100: #FFD1DC;
  --pink-200: #FFB7C5;
  --pink-300: #FF91A4;
  --pink-400: #FF6B8A;
  --green-200: #86EFAC;
  --green-300: #4ADE80;
  --green-400: #22C55E;
  --text: #3D2C2E;
  --text-sub: #8B7073;
  --text-light: #BFA3A7;
  --code-bg: #2D1F21;
  --code-text: #FFD1DC;
  --accent: #FF91A4;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(255, 145, 164, 0.12);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* --- Background Petal Canvas --- */
#bgPetals {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* --- Header --- */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255, 250, 245, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 183, 197, 0.25);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--pink-400);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-blossom {
  animation: logoSpin 8s linear infinite;
}

@keyframes logoSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

nav { display: flex; gap: 24px; }

.nav-link {
  text-decoration: none;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 0;
  position: relative;
  transition: color 0.3s;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--pink-300);
  border-radius: 1px;
  transition: width 0.3s ease;
}

.nav-link:hover { color: var(--pink-400); }
.nav-link:hover::after { width: 100%; }

/* --- Hero --- */
#hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

#heroCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 680px;
  padding: 0 24px;
}

.hero-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--pink-300);
  background: rgba(255, 145, 164, 0.1);
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 24px;
}

.hero-title {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 800;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 20px;
  animation: heroFadeUp 1s ease-out both;
}

.hero-desc {
  font-size: 16px;
  color: var(--text-sub);
  max-width: 520px;
  margin: 0 auto 28px;
  animation: heroFadeUp 1s ease-out 0.2s both;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  animation: heroFadeUp 1s ease-out 0.4s both;
}

.chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--pink-400);
  border: 1px solid rgba(255, 183, 197, 0.4);
  box-shadow: 0 2px 8px rgba(255, 145, 164, 0.08);
}

@keyframes heroFadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Playground Sections --- */
.playground-section {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 80px auto;
  padding: 0 24px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.section-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--pink-200), var(--pink-400));
  color: #fff;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(255, 107, 138, 0.3);
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.section-sub {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- Canvas Wrapper --- */
.canvas-wrapper {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 183, 197, 0.2);
}

.canvas-wrapper canvas {
  display: block;
  width: 100%;
  height: 420px;
  background: linear-gradient(180deg, #FFF5F7 0%, #FFF0F3 40%, #E8F5E9 100%);
}

/* --- Control Panel --- */
.control-panel {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: var(--bg-alt);
  border-top: 1px solid rgba(255, 183, 197, 0.2);
  flex-wrap: wrap;
}

.control-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  white-space: nowrap;
}

.control-panel input[type="range"] {
  width: 100px;
  accent-color: var(--pink-300);
  cursor: pointer;
}

.control-panel span {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--pink-400);
  min-width: 24px;
}

.btn-reset {
  margin-left: auto;
  padding: 6px 18px;
  border: 1px solid var(--pink-200);
  background: var(--surface);
  color: var(--pink-400);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-reset:hover {
  background: var(--pink-200);
  color: #fff;
}

/* --- XAML Reference --- */
.xaml-ref {
  margin-top: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.xaml-badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 8px 16px;
  background: var(--pink-300);
  color: #fff;
}

.xaml-ref pre {
  background: var(--code-bg);
  padding: 16px 20px;
  overflow-x: auto;
}

.xaml-ref code {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--code-text);
}

/* --- Sway Stage (CSS Animation Section) --- */
.sway-stage {
  position: relative;
  height: 480px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 183, 197, 0.2);
  /* ground gradient */
  background: linear-gradient(180deg,
    #FFF5F7 0%,
    #FFF0F3 55%,
    #DCF5E0 70%,
    #B6E8C0 100%);
}

.sway-controls {
  margin-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 183, 197, 0.2);
  border-top: none;
}

/* Sway flower (generated by JS) */
.sway-flower {
  position: absolute;
  bottom: 0;
  transform-origin: bottom center;
}

.sway-stem {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  border-radius: 2px;
  background: var(--green-300);
  transform-origin: bottom center;
}

.sway-bloom {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.sway-leaf {
  position: absolute;
  transform-origin: 0% 50%;
}

.sway-leaf-right {
  transform-origin: 100% 50%;
}

/* Sway keyframes — dynamically injected per flower */
@keyframes sway-default {
  0%, 100% { transform: rotate(calc(var(--sway-angle) * -1)); }
  50%      { transform: rotate(var(--sway-angle)); }
}

/* --- Footer --- */
footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-alt);
  border-top: 1px solid rgba(255, 183, 197, 0.2);
  color: var(--text-sub);
  font-size: 14px;
}

.footer-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-light);
  margin-top: 8px;
}

/* --- AI Bloom Section --- */
.bloom-badge {
  background: linear-gradient(135deg, #8B5CF6, var(--pink-400)) !important;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3) !important;
}

.bloom-stage {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 183, 197, 0.2);
  background: linear-gradient(180deg,
    #FFF8FA 0%,
    #FFF0F5 40%,
    #F0FFF4 75%,
    #DCFCE7 100%);
}

#bloomSvg {
  display: block;
  width: 100%;
  height: 520px;
}

.bloom-progress {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bloom-step {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255, 183, 197, 0.15);
  color: var(--text-light);
  transition: all 0.4s ease;
}

.bloom-step.active {
  background: var(--pink-300);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255, 145, 164, 0.3);
}

.bloom-step.done {
  background: rgba(74, 222, 128, 0.2);
  color: var(--green-400);
}

.bloom-controls { border-radius: 0 0 var(--radius) var(--radius); }

.btn-play {
  padding: 8px 24px;
  border: none;
  background: linear-gradient(135deg, var(--pink-300), #8B5CF6);
  color: #fff;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 16px rgba(255, 145, 164, 0.3);
}

.btn-play:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 145, 164, 0.4);
}

.btn-play:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Sway flower improvements: unified SVG structure */
.sway-flower-svg {
  position: absolute;
  bottom: 0;
  transform-origin: bottom center;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .header-inner { padding: 12px 16px; }
  nav { gap: 14px; }
  .nav-link { font-size: 12px; }
  .playground-section { margin: 48px auto; }
  .section-title { font-size: 22px; }
  .control-panel { gap: 12px; padding: 12px 16px; }
  .control-panel input[type="range"] { width: 70px; }
  .canvas-wrapper canvas { height: 300px; }
  .sway-stage { height: 360px; }
  #bloomSvg { height: 380px; }
  .bloom-progress { top: 8px; right: 8px; }
}
