/* ═══════════════════════════════════════════════
   Ducky Energy - Web Theme
   Mirrors frontend/lib/theme/app_theme.dart
   ═══════════════════════════════════════════════ */

/* ── CSS Custom Properties ─────────────────── */
:root {
  /* Backgrounds */
  --bg-base: #0D1117;
  --bg-surface: #161B22;
  --bg-surface2: #21262D;
  --bg-surface3: #2D333B;

  /* Price colors */
  --price-green: #3FB950;
  --price-amber: #F0A000;
  --price-red: #F85149;

  /* Accent */
  --accent: #58A6FF;
  --accent-dim: rgba(88, 166, 255, 0.12);
  --accent-border: rgba(88, 166, 255, 0.25);
  --nuclear-blue: #A78BFA;

  /* Text */
  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --text-muted: #7D8590;

  /* Borders */
  --border: #30363D;
  --border-subtle: #21262D;

  /* Spacing */
  --gap-2: 2px;
  --gap-4: 4px;
  --gap-8: 8px;
  --gap-10: 10px;
  --gap-12: 12px;
  --gap-16: 16px;
  --gap-20: 20px;
  --gap-24: 24px;
  --gap-28: 28px;
  --gap-32: 32px;
  --gap-40: 40px;
  --gap-48: 48px;
  --gap-64: 64px;
  --gap-80: 80px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-card: 16px;
  --radius-section: 20px;
  --radius-pill: 999px;

  /* Animation */
  --anim-fast: 200ms;
  --anim-quick: 250ms;
  --anim-normal: 300ms;
  --anim-slow: 400ms;

  /* Layout */
  --nav-height: 56px;
  --nav-height-lg: 64px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 16px);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--anim-fast) ease;
}

a:hover {
  color: #79b8ff;
}

/* ── Utility ──────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--gap-20);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Skip link: hidden until focused */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gap-16);
  z-index: 200;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  transition: top var(--anim-fast) ease;
}

.skip-link:focus {
  top: var(--gap-8);
}

.accent {
  color: var(--accent);
}

/* ── Lang Toggle ──────────────────────────── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-4);
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  user-select: none;
}

.lang-toggle button {
  appearance: none;
  border: none;
  background: none;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--anim-fast) ease;
  min-height: 30px;
  min-width: 44px;
}

.lang-toggle button:hover {
  color: var(--text-primary);
}

.lang-toggle button.active {
  background: var(--accent);
  color: #fff;
}

.lang-toggle button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Nav Bar ──────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding-top: env(safe-area-inset-top);
}

.nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-12);
  height: var(--nav-height);
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-10);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

.nav-brand img {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--gap-12);
}

.nav-links {
  display: none;
  position: absolute;
  top: var(--nav-height);
  left: 0;
  right: 0;
  flex-direction: column;
  align-items: stretch;
  list-style: none;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  padding: var(--gap-12) var(--gap-20) var(--gap-20);
  gap: var(--gap-4);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

.nav-links.open {
  display: flex;
}

.nav-links li {
  display: flex;
  justify-content: flex-end;
}

.nav-links a {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 44px;
  padding: 0 var(--gap-12);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
}

.nav-links a:hover {
  color: var(--text-primary);
  background: var(--bg-surface2);
}

.nav-links .nav-cta {
  justify-content: center;
  margin-top: var(--gap-8);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 600;
  transition: box-shadow var(--anim-fast) ease;
}

.nav-links .nav-cta:hover {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 20px rgba(88, 166, 255, 0.3);
}

/* Mobile nav toggle */
.nav-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-md);
}

.nav-toggle:hover {
  background: var(--bg-surface2);
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--anim-fast) ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ── Hero ─────────────────────────────────── */
.hero {
  position: relative;
  padding: calc(var(--nav-height) + 48px) var(--gap-20) var(--gap-48);
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -20%;
  left: 50%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(88, 166, 255, 0.08) 0%, transparent 70%);
  transform: translateX(-50%);
  pointer-events: none;
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-40);
}

.hero-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  margin-bottom: var(--gap-16);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-pill);
}

.hero h1 {
  font-size: clamp(2rem, 8vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: var(--gap-16);
}

.hero-sub {
  font-size: 1.02rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin-bottom: var(--gap-28);
  line-height: 1.65;
}

.hero-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-16);
}

.text-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.text-link:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Play badge (icon + text button) */
.play-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-10);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 12px 26px;
  min-height: 48px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  transition: all var(--anim-fast) ease;
  text-decoration: none;
}

.play-badge img {
  flex-shrink: 0;
}

.play-badge:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(88, 166, 255, 0.15);
  color: var(--text-primary);
}

/* Phone mockup */
.hero-visual {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.hero-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 260px;
  height: 380px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(88, 166, 255, 0.14) 0%, transparent 70%);
  pointer-events: none;
}

.phone {
  position: relative;
  width: min(240px, 62vw);
  background: var(--bg-surface3);
  border: 1px solid var(--border);
  border-radius: 36px;
  padding: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  transform: perspective(1000px) rotateX(10deg) rotateY(-10deg) rotateZ(4deg);
  transition: transform var(--anim-normal) ease;
}

.phone-screen {
  aspect-ratio: 338 / 612;
  border-radius: 26px;
  overflow: hidden;
  background: var(--bg-surface);
}

.phone-screen img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Section common ──────────────────────── */
section {
  padding: var(--gap-48) 0;
}

.section-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: var(--gap-8);
}

.section-title {
  font-size: clamp(1.5rem, 6vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: var(--gap-12);
}

.section-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin-bottom: var(--gap-32);
  line-height: 1.6;
}

.centered {
  text-align: center;
}

.centered .section-subtitle {
  margin-left: auto;
  margin-right: auto;
}

/* ── Features ─────────────────────────────── */
.features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-16);
}

.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--gap-24);
  transition: all var(--anim-normal) ease;
}

.feature-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.feature-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--gap-16);
  background: var(--accent-dim);
  border: 1px solid rgba(88, 166, 255, 0.2);
  border-radius: var(--radius-xl);
  font-size: 20px;
  line-height: 1;
}

.feature-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--gap-8);
}

.feature-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── App Screens ──────────────────────────── */
.screens-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 82%;
  gap: var(--gap-16);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 4px var(--gap-20);
  text-align: left;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.screens-scroll::-webkit-scrollbar {
  display: none;
}

.screen-card {
  scroll-snap-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--gap-16);
  transition: border-color var(--anim-normal) ease;
}

.screen-card:hover {
  border-color: var(--accent);
}

.screen-frame {
  aspect-ratio: 455 / 280;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
}

.screen-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.screen-card figcaption h3 {
  font-size: 15px;
  font-weight: 700;
  margin-top: var(--gap-12);
  margin-bottom: var(--gap-4);
}

.screen-card figcaption p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── How It Works ─────────────────────────── */
.steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-16);
}

.step {
  text-align: center;
  padding: var(--gap-24) var(--gap-16);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.step-number {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--gap-16);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.step h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--gap-8);
}

.step p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── CTA Section ─────────────────────────── */
.cta-section {
  text-align: center;
  padding: var(--gap-64) 0;
}

.cta-section h2 {
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: var(--gap-12);
}

.cta-section p {
  color: var(--text-secondary);
  margin-bottom: var(--gap-28);
}

/* ── Footer ───────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: var(--gap-20) 0;
  padding-bottom: calc(var(--gap-20) + env(safe-area-inset-bottom));
}

.footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-12);
  text-align: center;
}

.footer-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-12);
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-8);
  font-size: 13px;
  font-weight: 600;
}

.footer-brand img {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap-20);
  list-style: none;
}

.footer-links a {
  font-size: 13px;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-copy {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Legal Pages ──────────────────────────── */
.legal-page .nav {
  position: relative;
  background: var(--bg-base);
  backdrop-filter: none;
}

.legal-content {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--gap-32) var(--gap-20);
  color: var(--text-secondary);
  line-height: 1.8;
}

.legal-content h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--gap-32) 0 var(--gap-12);
}

.legal-content h1:first-child {
  margin-top: 0;
}

.legal-content h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: var(--gap-28) 0 var(--gap-10);
}

.legal-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: var(--gap-24) 0 var(--gap-8);
}

.legal-content p {
  margin-bottom: var(--gap-16);
}

.legal-content ul, .legal-content ol {
  margin: 0 0 var(--gap-16) var(--gap-24);
}

.legal-content li {
  margin-bottom: var(--gap-8);
}

.legal-content strong {
  color: var(--text-primary);
}

.legal-content a {
  color: var(--accent);
}

.legal-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--gap-16);
  margin: var(--gap-16) 0;
  color: var(--text-secondary);
}

.legal-content code {
  background: var(--bg-surface2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ── Animations ───────────────────────────── */
.fade-in {
  opacity: 1;
  transform: none;
}

.js .fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.js .fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-in-delay-1 { transition-delay: 0.1s; }
.fade-in-delay-2 { transition-delay: 0.2s; }
.fade-in-delay-3 { transition-delay: 0.3s; }
.fade-in-delay-4 { transition-delay: 0.4s; }

/* ── 404 Page ─────────────────────────────── */
.page-404 {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--gap-24);
}

.page-404 h1 {
  font-size: clamp(4rem, 20vw, 6rem);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--gap-8);
}

.page-404 p {
  color: var(--text-secondary);
  margin-bottom: var(--gap-28);
  max-width: 400px;
}

.page-404 .nav-cta {
  display: inline-block;
  padding: 12px 24px;
  min-height: 48px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

/* ── Tablet (≥720px) ──────────────────────── */
@media (min-width: 720px) {
  .container {
    padding: 0 var(--gap-24);
  }

  section {
    padding: var(--gap-64) 0;
  }

  .hero {
    padding: calc(var(--nav-height) + 64px) var(--gap-24) var(--gap-64);
  }

  .hero h1 {
    font-size: clamp(2.25rem, 4.5vw, 3rem);
  }

  .hero-cta {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .hero-cta .text-link {
    flex-basis: 100%;
  }

  .phone {
    width: 280px;
  }

  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .screens-scroll {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-columns: auto;
    overflow: visible;
    scroll-snap-type: none;
  }

  .screen-card {
    scroll-snap-align: unset;
  }

  .steps {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap-20);
  }

  .step {
    padding: var(--gap-28) var(--gap-20);
  }

  .footer-main {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
  }
}

/* ── Desktop (≥960px) ─────────────────────── */
@media (min-width: 960px) {
  :root {
    --nav-height: var(--nav-height-lg);
  }

  .nav-toggle {
    display: none;
  }

  .nav-links {
    display: flex;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: var(--gap-8);
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
  }

  .nav-links li {
    justify-content: flex-start;
  }

  .nav-links a {
    justify-content: flex-start;
    min-height: 40px;
    font-size: 14px;
    padding: 0 var(--gap-12);
  }

  .nav-links .nav-cta {
    margin-top: 0;
    margin-left: var(--gap-8);
    padding: 8px 20px;
    min-height: 40px;
  }

  .hero {
    padding: calc(var(--nav-height-lg) + 72px) var(--gap-24) var(--gap-80);
  }

  .hero-grid {
    grid-template-columns: 1.05fr 0.95fr;
    gap: var(--gap-48);
    align-items: center;
  }

  .hero-content {
    text-align: left;
    align-items: flex-start;
  }

  .hero-content .hero-cta {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .hero-visual {
    order: 2;
  }

  .phone {
    width: min(320px, 100%);
    transform: perspective(1200px) rotateX(12deg) rotateY(-12deg) rotateZ(6deg);
  }

  .features-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .screens-scroll {
    grid-template-columns: repeat(3, 1fr);
  }

  .cta-section {
    padding: var(--gap-80) 0;
  }

  .footer {
    padding: var(--gap-24) 0;
    padding-bottom: calc(var(--gap-24) + env(safe-area-inset-bottom));
  }
}

/* ── Small phones (≤380px) ────────────────── */
@media (max-width: 380px) {
  .nav .container {
    gap: var(--gap-8);
  }

  .nav-brand {
    font-size: 14px;
  }

  .lang-toggle button {
    min-width: 36px;
    padding: 5px 8px;
    font-size: 12px;
  }
}

/* ── Reduced motion ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .fade-in {
    opacity: 1 !important;
    transform: none !important;
  }
}
