/* ============================================================
   Sleep Cycle Time Calculator — style.css
   Palette: deep space navy, indigo/violet accents, moonlight
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Custom Properties ── */
:root {
  --bg:           #0a0a1a;
  --bg-surface:   #12122a;
  --bg-card:      #1a1a35;
  --accent:       #7c6fcd;
  --accent-light: #a89bd4;
  --accent-glow:  rgba(124, 111, 205, 0.25);
  --teal:         #4ecdc4;
  --teal-glow:    rgba(78, 205, 196, 0.2);
  --text:         #f0eeff;
  --text-muted:   #8b8aad;
  --text-dim:     #5a5980;
  --border:       rgba(124, 111, 205, 0.2);
  --border-hover: rgba(124, 111, 205, 0.5);
  --font-head:    'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --radius:       16px;
  --radius-sm:    10px;
  --transition:   0.3s ease;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

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

img { max-width: 100%; display: block; }
a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--text); }

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: var(--font-head);
  line-height: 1.2;
  color: var(--text);
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); font-weight: 600; }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.4rem); font-weight: 600; }

p { color: var(--text-muted); line-height: 1.75; }

/* ── Layout ── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

section { padding: 5rem 0; }

/* ── Starfield Canvas ── */
#starfield {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── Hero Video ── */
.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 72% center;
  opacity: 0.58;
  z-index: 0;
  pointer-events: none;
}

/* Hide SVG fallback when video is present */
.hero-video + .sleeping-scene {
  display: none;
}

/* ── Sleeping Figure Animation ── */
.sleeping-scene {
  position: absolute;
  bottom: -1rem;
  right: -3rem;
  width: min(860px, 84vw);
  height: 96%;
  opacity: 1;
  filter:
    drop-shadow(0 0 42px rgba(124, 111, 205, 0.22))
    drop-shadow(0 0 16px rgba(78, 205, 196, 0.08));
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

/* Moonlight glow from right */
.sleeping-scene::before {
  content: '';
  position: absolute;
  right: 20px;
  top: 40%;
  transform: translateY(-50%);
  width: 640px;
  height: 640px;
  background: radial-gradient(circle, rgba(168, 155, 212, 0.32) 0%, rgba(124, 111, 205, 0.16) 26%, rgba(78, 205, 196, 0.1) 42%, transparent 74%);
  border-radius: 50%;
  pointer-events: none;
}

/* SVG sleeping figure */
.sleeping-figure {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  transform: scale(1.14) translate(-4%, -3%);
  filter: brightness(1.18) contrast(1.08) saturate(1.08);
}

/* Breathing / restless animation on the figure */
.figure-body {
  transform-origin: 50% 80%;
  animation: restless 8s ease-in-out infinite;
}

.figure-blanket {
  transform-origin: 50% 60%;
  animation: blanket-shift 8s ease-in-out infinite;
}

.figure-head {
  transform-origin: center center;
  animation: head-turn 12s ease-in-out infinite;
}

@keyframes restless {
  0%   { transform: rotate(0deg) translateY(0px); }
  20%  { transform: rotate(0.5deg) translateY(-1px); }
  45%  { transform: rotate(-0.8deg) translateY(1px); }
  65%  { transform: rotate(0.3deg) translateY(-0.5px); }
  80%  { transform: rotate(-0.4deg) translateY(0.8px); }
  100% { transform: rotate(0deg) translateY(0px); }
}

@keyframes blanket-shift {
  0%   { transform: scaleX(1) translateX(0); }
  30%  { transform: scaleX(1.01) translateX(2px); }
  60%  { transform: scaleX(0.99) translateX(-1px); }
  100% { transform: scaleX(1) translateX(0); }
}

@keyframes head-turn {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(2deg); }
  55%  { transform: rotate(-1.5deg); }
  80%  { transform: rotate(1deg); }
  100% { transform: rotate(0deg); }
}

/* ── Hero Section ── */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 2rem 0;
}

/* Subtle gradient overlay */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(10, 10, 26, 0.97) 0%,
    rgba(10, 10, 26, 0.72) 42%,
    rgba(10, 10, 26, 0.03) 100%
  );
  z-index: 1;
  pointer-events: none;
}

.hero .container {
  position: relative;
  z-index: 2;
  width: 100%;
}

.hero__content {
  max-width: 560px;
}

.hero__eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 1rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: rgba(124, 111, 205, 0.08);
}

.hero__title {
  margin-bottom: 1rem;
}

.hero__title em {
  font-style: italic;
  color: var(--accent-light);
}

.hero__subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  max-width: 440px;
}

/* ── Calculator Card ── */
.calculator-card {
  background: rgba(18, 18, 42, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow:
    0 0 40px rgba(124, 111, 205, 0.08),
    0 20px 60px rgba(0, 0, 0, 0.4);
}

/* ── Tabs ── */
.calc-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
  background: rgba(10, 10, 26, 0.6);
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.calc-tab {
  flex: 1;
  padding: 0.65rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.calc-tab:hover {
  color: var(--text);
  background: rgba(124, 111, 205, 0.1);
}

.calc-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(124, 111, 205, 0.4);
}

/* ── Calculator Panels ── */
.calc-panel { display: none; }
.calc-panel.active { display: block; }

.calc-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.calc-input-row {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.calc-input {
  flex: 1;
  padding: 0.85rem 1.1rem;
  background: rgba(10, 10, 26, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 500;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.calc-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Style the time input clock icon */
.calc-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7) sepia(1) saturate(2) hue-rotate(220deg);
  cursor: pointer;
  opacity: 0.7;
}

.calc-btn {
  padding: 0.85rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(124, 111, 205, 0.35);
}

.calc-btn:hover {
  background: #9080e0;
  box-shadow: 0 6px 28px rgba(124, 111, 205, 0.5);
  transform: translateY(-1px);
}

.calc-btn:active {
  transform: translateY(0);
}

/* ── Results Area ── */
.results-area {
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.results-area.hidden { display: none; }

.results-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

/* ── Result Cards ── */
.result-card {
  position: relative;
  padding: 1.1rem 1rem;
  background: rgba(10, 10, 26, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  animation: card-in 0.4s ease both;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.result-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(124, 111, 205, 0.15);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Featured card (recommended) */
.result-card--featured {
  border-color: var(--teal);
  background: rgba(78, 205, 196, 0.06);
  box-shadow: 0 0 20px var(--teal-glow);
}

.result-card__time {
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.result-card__meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.5rem;
}

.result-card__cycles {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-light);
}

.result-card__hours {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.result-card__tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
}

/* Tag colour variants */
.tag-bliss .result-card__tag    { background: rgba(124, 111, 205, 0.2); color: var(--accent-light); }
.tag-recommended .result-card__tag { background: rgba(78, 205, 196, 0.2); color: var(--teal); }
.tag-minimum .result-card__tag  { background: rgba(255, 200, 100, 0.15); color: #f0c060; }
.tag-emergency .result-card__tag { background: rgba(255, 100, 100, 0.12); color: #e07070; }

/* ── Nap Section ── */
.nap-section {
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.nap-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.nap-buttons {
  display: flex;
  gap: 0.75rem;
}

.nap-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: rgba(10, 10, 26, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.nap-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(124, 111, 205, 0.1);
}

.nap-btn strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.nap-result {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: rgba(124, 111, 205, 0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  animation: card-in 0.3s ease both;
}

.nap-result.hidden { display: none; }

.nap-result__label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.nap-result__time {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-light);
}

/* ── How It Works Section ── */
.how-it-works {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-surface) 50%, var(--bg) 100%);
  position: relative;
  z-index: 2;
}

.section-header {
  text-align: center;
  margin-bottom: 3.5rem;
}

.section-eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 0.75rem;
}

.section-header p {
  max-width: 520px;
  margin: 0.75rem auto 0;
  font-size: 1rem;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.step-card {
  padding: 2rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  transition: border-color var(--transition), transform var(--transition);
}

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

.step-number {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-light);
}

.step-card h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.step-card p {
  font-size: 0.875rem;
}

/* ── Sleep Science Section ── */
.sleep-science {
  position: relative;
  z-index: 2;
}

.science-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 3rem;
}

.science-card {
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.science-card__icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  display: block;
}

.science-card h3 {
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
}

.science-card p {
  font-size: 0.9rem;
  line-height: 1.7;
}

/* Sleep stages visual */
.sleep-stages {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
}

.stage-bar__label {
  width: 80px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.stage-bar__track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 100px;
  overflow: hidden;
}

.stage-bar__fill {
  height: 100%;
  border-radius: 100px;
  transition: width 1s ease;
}

.stage-bar__fill--n1  { background: #5a5980; width: 5%; }
.stage-bar__fill--n2  { background: #7c6fcd; width: 45%; }
.stage-bar__fill--n3  { background: #4a3fa0; width: 25%; }
.stage-bar__fill--rem { background: #4ecdc4; width: 25%; }

.stage-bar__pct {
  width: 30px;
  text-align: right;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Inertia callout */
.inertia-callout {
  margin-top: 2.5rem;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(124, 111, 205, 0.08), rgba(78, 205, 196, 0.05));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.inertia-callout h3 {
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
}

.inertia-callout p {
  font-size: 0.9rem;
  line-height: 1.75;
}

/* ── FAQ Section ── */
.faq-section {
  background: var(--bg-surface);
  position: relative;
  z-index: 2;
}

.faq-list {
  max-width: 720px;
  margin: 0 auto;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-item:first-child {
  border-top: 1px solid var(--border);
}

.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  gap: 1rem;
  transition: color var(--transition);
}

.faq-question:hover { color: var(--accent-light); }

.faq-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--accent-light);
  transition: transform var(--transition), background var(--transition);
}

.faq-item.open .faq-icon {
  transform: rotate(45deg);
  background: var(--accent-glow);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
}

.faq-item.open .faq-answer {
  max-height: 300px;
  padding-bottom: 1.25rem;
}

.faq-answer p {
  font-size: 0.9rem;
  line-height: 1.75;
}

/* ── Related Tool ── */
.related-tool-section {
  padding: 0 0 3rem;
  position: relative;
  z-index: 2;
}

.related-tool-card {
  background: linear-gradient(135deg, rgba(18, 18, 42, 0.94), rgba(26, 26, 53, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.related-tool-eyebrow {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(124, 111, 205, 0.1);
  color: var(--accent-light);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.related-tool-card h2 {
  margin-bottom: 0.65rem;
}

.related-tool-card p {
  max-width: 640px;
  margin-bottom: 1rem;
}

.related-tool-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.15rem;
  border-radius: 999px;
  background: var(--teal);
  color: var(--bg);
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.related-tool-link:hover {
  color: var(--bg);
  background: #69ddd5;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(78, 205, 196, 0.22);
}

/* ── Footer ── */
.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 3rem 0 2rem;
  position: relative;
  z-index: 2;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-brand h3 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.footer-brand p {
  font-size: 0.8rem;
  max-width: 280px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color var(--transition);
}

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

.footer-bottom {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-bottom p {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ── Scroll Reveal ── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ── Utility ── */
.hidden { display: none !important; }

.text-accent { color: var(--accent-light); }
.text-teal   { color: var(--teal); }

/* ── Responsive ── */
@media (max-width: 768px) {
  section { padding: 3.5rem 0; }

  .hero-video {
    object-position: 68% center;
    opacity: 0.66;
  }

  .sleeping-scene {
    width: 118%;
    height: 44%;
    right: -10%;
    bottom: -0.25rem;
    opacity: 0.82;
  }

  .hero {
    align-items: flex-start;
    padding-top: 3rem;
  }

  .hero__content {
    max-width: 100%;
  }

  .hero__subtitle {
    max-width: 100%;
  }

  .results-grid {
    grid-template-columns: 1fr 1fr;
  }

  .steps-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .science-grid {
    grid-template-columns: 1fr;
  }

  .calc-input-row {
    flex-direction: column;
  }

  .calc-btn {
    width: 100%;
  }

  .nap-buttons {
    flex-direction: column;
  }

  .footer-inner {
    flex-direction: column;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .calc-tabs {
    flex-direction: column;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  h1 { font-size: 1.8rem; }
}
