/* ============================================
   Sleep First — Styles
   Earthy, warm, nighttime vibes
   ============================================ */

:root {
  /* Earth tones palette */
  --bg-deep:       #1a1612;
  --bg-surface:    #241f1a;
  --bg-card:       #2e2721;
  --bg-card-hover: #3a322b;

  --cream:         #f5ead6;
  --cream-muted:   #d4c4a8;
  --warm-brown:    #8b7355;
  --terracotta:    #c4704b;
  --terracotta-soft: #d4886a;
  --deep-green:    #4a6741;
  --deep-green-light: #5e8053;
  --sage:          #8fa882;

  --text-primary:  #f5ead6;
  --text-secondary: #b8a88a;
  --text-muted:    #7a6b55;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;

  /* Spacing */
  --section-pad: clamp(3rem, 8vw, 6rem);
  --container-max: 800px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  height: 100%;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  position: relative;
  height: 100vh;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

a {
  color: var(--terracotta);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  color: var(--terracotta-soft);
}

/* ============================================
   Section 1: Hero
   ============================================ */

.hero {
  text-align: center;
}

.hero .container {
  position: relative;
  z-index: 2;
  animation: fadeInUp 1s var(--ease-out) both;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 5rem);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.hero h1 .highlight {
  color: var(--terracotta);
  display: inline-block;
  animation: breathe 4s var(--ease-in-out) infinite;
}

.hero-text {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--terracotta);
  color: var(--cream);
  padding: 1rem 2rem;
  border-radius: 60px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s var(--ease-out);
  border: none;
  cursor: pointer;
}

.cta-button:hover {
  background: var(--terracotta-soft);
  color: var(--cream);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(196, 112, 75, 0.3);
}

.cta-button svg {
  animation: bobDown 2s var(--ease-in-out) infinite;
}

/* Hero background element */
.hero-bg-element {
  position: absolute;
  top: -30%;
  right: -20%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 103, 65, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

/* ============================================
   Section 2: Calculator
   ============================================ */

.calculator {
  background: var(--bg-surface);
  border-top: 1px solid rgba(245, 234, 214, 0.06);
  justify-content: center;
}

.calculator .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-height: 100%;
}

.calculator h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 600;
  text-align: center;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.section-subtitle {
  text-align: center;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 1.5rem;
  font-size: 0.95rem;
  line-height: 1.7;
  flex-shrink: 0;
}

/* ---- Calc Stage: fixed-height container for button/results ---- */

.calc-stage {
  position: relative;
  width: 100%;
  min-height: 380px;
  flex-shrink: 0;
}

/* Sleep button (prompt state) */
.calc-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.calc-prompt.stage-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sleep-button {
  background: none;
  border: 2px solid var(--terracotta);
  border-radius: 50%;
  width: 200px;
  height: 200px;
  cursor: pointer;
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.sleep-button::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 112, 75, 0.15) 0%, transparent 70%);
  transition: opacity 0.3s ease;
}

.sleep-button:hover {
  transform: scale(1.05);
  border-color: var(--terracotta-soft);
  box-shadow: 0 0 40px rgba(196, 112, 75, 0.2);
}

.sleep-button:active {
  transform: scale(0.97);
}

.sleep-button-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.moon-icon {
  color: var(--terracotta);
  animation: breathe 4s var(--ease-in-out) infinite;
}

.sleep-button-label {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sleep-button-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Results (results state) */
.calc-results {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.calc-results.stage-visible {
  opacity: 1;
  visibility: visible;
}

.results-header {
  text-align: center;
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.results-header strong {
  color: var(--cream);
}

/* Carousel */
.carousel-wrapper {
  position: relative;
  overflow: hidden;
  margin: 0 -1.5rem;
  padding: 0 1.5rem;
  touch-action: pan-y;
}

.carousel-track {
  display: flex;
  gap: 1rem;
  transition: transform 0.4s var(--ease-out);
  cursor: grab;
  padding: 0.5rem 0;
}

.carousel-track.dragging {
  transition: none;
  cursor: grabbing;
}

.cycle-card {
  flex: 0 0 calc(33.333% - 0.667rem);
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid rgba(245, 234, 214, 0.08);
  border-radius: 16px;
  padding: 1.25rem 0.75rem;
  text-align: center;
  transition: all 0.3s var(--ease-out);
  user-select: none;
  opacity: 0;
  transform: translateY(16px);
  animation: cardIn 0.5s var(--ease-out) forwards;
}

.cycle-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  border-color: rgba(245, 234, 214, 0.12);
}

.cycle-card.optimal {
  border-color: var(--deep-green);
  box-shadow: 0 4px 20px rgba(74, 103, 65, 0.15);
}

.cycle-card.optimal .card-quality {
  color: var(--sage);
}

.card-time {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.card-period {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.card-hours {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0.5rem 0 0.35rem;
}

.card-quality {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: rgba(245, 234, 214, 0.06);
}

.quality-minimal   { color: var(--warm-brown); }
.quality-okay      { color: var(--cream-muted); }
.quality-good      { color: var(--terracotta-soft); }
.quality-optimal   { color: var(--sage); }
.quality-luxurious { color: var(--deep-green-light); }

/* Carousel dots */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.4;
  transition: all 0.3s ease;
  cursor: pointer;
  border: none;
  padding: 0;
}

.carousel-dot.active {
  opacity: 1;
  background: var(--terracotta);
  transform: scale(1.3);
}

.fall-asleep-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-style: italic;
}

.reset-button {
  display: block;
  margin: 1rem auto 0;
  background: none;
  border: 1px solid var(--warm-brown);
  color: var(--cream-muted);
  padding: 0.5rem 1.5rem;
  border-radius: 40px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  font-family: var(--font-body);
}

.reset-button:hover {
  border-color: var(--terracotta);
  color: var(--cream);
  transform: translateY(-1px);
}

/* ============================================
   Tip Bar — Condensed footer CTA
   ============================================ */

.tip-bar {
  width: 100%;
  margin-top: 1.25rem;
  flex-shrink: 0;
}

.tip-bar-state {
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tip-bar-state.hidden {
  display: none;
}

.tip-bar-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid rgba(245, 234, 214, 0.08);
  border-radius: 40px;
  flex-wrap: wrap;
}

.tip-bar-bolt {
  color: var(--terracotta);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.tip-bar-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.tip-bar-amounts {
  display: flex;
  gap: 0.4rem;
}

.tip-bar-amounts .tip-amount-btn {
  background: var(--bg-surface);
  border: 1px solid var(--warm-brown);
  color: var(--cream-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 40px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  font-family: var(--font-body);
  white-space: nowrap;
}

.tip-bar-amounts .tip-amount-btn:hover {
  border-color: var(--terracotta);
  color: var(--cream);
  background: var(--bg-card-hover);
}

.tip-bar-amounts .tip-amount-btn:active {
  transform: scale(0.96);
}

.tip-bar-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Tip bar invoice state */
.tip-bar-invoice-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid rgba(245, 234, 214, 0.08);
  border-radius: 16px;
}

.tip-bar-qr {
  width: 200px;
  height: 200px;
  background: #fff;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

.tip-bar-qr img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.tip-bar-invoice-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tip-bar-copy-btn {
  background: none;
  border: 1px solid var(--warm-brown);
  color: var(--cream-muted);
  padding: 0.4rem 1.2rem;
  border-radius: 40px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  font-family: var(--font-body);
}

.tip-bar-copy-btn:hover {
  border-color: var(--terracotta);
  color: var(--cream);
}

.tip-bar-copy-btn.copied {
  border-color: var(--sage);
  color: var(--sage);
}

.tip-bar-status {
  color: var(--text-muted);
  font-size: 0.75rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.tip-bar-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: var(--font-body);
  transition: color 0.2s ease;
}

.tip-bar-cancel:hover {
  color: var(--text-secondary);
}

/* Tip bar thanks */
.tip-bar-check {
  color: var(--sage);
  flex-shrink: 0;
}

.tip-bar-thanks-text {
  color: var(--cream);
  font-size: 0.85rem;
  font-weight: 500;
}

.tip-bar-again-btn,
.tip-bar-retry-btn {
  background: none;
  border: 1px solid var(--warm-brown);
  color: var(--cream-muted);
  padding: 0.35rem 1rem;
  border-radius: 40px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  font-family: var(--font-body);
}

.tip-bar-again-btn:hover,
.tip-bar-retry-btn:hover {
  border-color: var(--terracotta);
  color: var(--cream);
}

/* Tip bar error */
.tip-bar-error-text {
  color: var(--warm-brown);
  font-size: 0.85rem;
}


/* ============================================
   Animations
   ============================================ */

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

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes bobDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

@keyframes cardIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 640px) {
  .cycle-card {
    flex: 0 0 calc(50% - 0.5rem);
    min-width: 140px;
  }

  .sleep-button {
    width: 170px;
    height: 170px;
  }

  .card-time {
    font-size: 1.5rem;
  }

  .calc-stage {
    min-height: 340px;
  }

  .tip-bar-row {
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
  }

  .tip-bar-label {
    font-size: 0.72rem;
  }

  .tip-bar-qr {
    width: 180px;
    height: 180px;
  }
}

@media (max-width: 400px) {
  .cycle-card {
    flex: 0 0 calc(70%);
    min-width: 130px;
  }

  .tip-bar-row {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .cycle-card {
    flex: 0 0 calc(33.333% - 0.667rem);
  }
}
