@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

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

:root {
  --navy: #0f172a;
  --navy-mid: #1e293b;
  --cream: #faf7f2;
  --cream-dark: #f0ebe2;
  --amber: #f59e0b;
  --amber-dark: #d97706;
  --lavender: #8b5cf6;
  --green: #10b981;
  --text: #1e293b;
  --text-light: #64748b;
  --white: #ffffff;
  --radius: 16px;
  --shadow: 0 8px 40px rgba(0,0,0,0.12);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.18);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', sans-serif;
  color: var(--text);
  background: var(--cream);
  line-height: 1.6;
}

/* ── NAV ── */
#main-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 1rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  transition: background 0.3s, box-shadow 0.3s;
}
#main-nav.scrolled {
  background: var(--white);
  box-shadow: 0 2px 20px rgba(0,0,0,0.08);
}
.nav-logo { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.nav-logo img { width: 28px; height: 28px; display: block; flex: 0 0 28px; }
.nav-logo span { font-weight: 800; font-size: 1.1rem; color: var(--white); transition: color 0.3s; }
#main-nav.scrolled .nav-logo span { color: var(--navy); }
.nav-link {
  font-weight: 600; font-size: 0.9rem; color: rgba(255,255,255,0.8);
  text-decoration: none; transition: color 0.3s;
}
#main-nav.scrolled .nav-link { color: var(--text-light); }
.nav-link:hover { color: var(--amber); }

/* ── HERO ── */
#hero {
  position: relative; overflow: hidden;
  background: var(--navy);
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 7rem 1.5rem 4rem;
}

.star {
  position: absolute; border-radius: 50%;
  background: white; opacity: 0;
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(0.8); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

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

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3);
  color: var(--amber); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.3rem 0.9rem; border-radius: 999px; margin-bottom: 1.25rem;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900; color: var(--white); line-height: 1.15;
  margin-bottom: 1rem;
}
h1 span { color: var(--amber); }

.hero-sub {
  font-size: 1.05rem; color: rgba(255,255,255,0.7);
  margin-bottom: 2.5rem; max-width: 520px; margin-left: auto; margin-right: auto;
}

/* ── CALCULATOR CARD ── */
.calc-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%; max-width: 560px;
  position: relative; z-index: 2;
}

.calc-label {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-light); margin-bottom: 0.75rem;
}

.pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 180px));
  justify-content: center;
  gap: 0.9rem 1rem;
  margin-bottom: 1.5rem;
}
.pill {
  width: 100%;
  min-height: 108px;
  padding: 0.75rem 0.9rem;
  border-radius: 999px;
  border: 2px solid #e2e8f0;
  background: transparent;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.2s;
}
.pill small {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72em;
}
.pill:hover { border-color: var(--amber); color: var(--amber); }
.pill.active { background: var(--amber); border-color: var(--amber); color: var(--white); }

.mode-toggle {
  display: flex; border: 2px solid #e2e8f0; border-radius: 999px;
  overflow: hidden; margin-bottom: 1.5rem;
}
.mode-btn {
  flex: 1; padding: 0.6rem 0.5rem; border: none; background: transparent;
  font-family: 'Nunito', sans-serif; font-size: 0.85rem; font-weight: 700;
  color: var(--text-light); cursor: pointer; transition: all 0.2s;
}
.mode-btn.active { background: var(--navy); color: var(--white); border-radius: 999px; }

.time-row { margin-bottom: 1.5rem; }
.time-input {
  width: 100%; padding: 0.85rem 1rem; border: 2px solid #e2e8f0; border-radius: 12px;
  font-family: 'Nunito', sans-serif; font-size: 1.1rem; font-weight: 700;
  color: var(--text); background: var(--cream); transition: border-color 0.2s;
}
.time-input:focus { outline: none; border-color: var(--amber); }

.calc-error { color: #ef4444; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.75rem; min-height: 1.2em; }

.calc-btn {
  width: 100%; padding: 1rem; border: none; border-radius: 12px;
  background: var(--amber); color: var(--white);
  font-family: 'Nunito', sans-serif; font-size: 1.05rem; font-weight: 800;
  cursor: pointer; transition: background 0.2s, transform 0.1s;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.calc-btn:hover { background: var(--amber-dark); }
.calc-btn:active { transform: scale(0.98); }

/* ── RESULTS ── */
#result-section {
  display: none; opacity: 0; transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  width: 100%; max-width: 560px; position: relative; z-index: 2;
  margin-top: 1.5rem;
}
#result-section.visible { opacity: 1; transform: translateY(0); }

.result-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: var(--radius); padding: 2rem; color: var(--white);
  text-align: center; box-shadow: var(--shadow-lg);
}
.result-moon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.result-age-badge {
  display: inline-block; background: rgba(245,158,11,0.2);
  color: var(--amber); font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 0.25rem 0.75rem; border-radius: 999px; margin-bottom: 1rem;
}
.result-label { font-size: 0.9rem; color: rgba(255,255,255,0.6); font-weight: 600; }
.result-time { font-size: clamp(2.5rem, 8vw, 3.5rem); font-weight: 900; color: var(--amber); line-height: 1.1; }
.result-range { font-size: 0.85rem; color: rgba(255,255,255,0.5); margin: 0.25rem 0 1.25rem; }

.result-meta {
  display: flex; flex-direction: column; gap: 0.5rem;
  background: rgba(255,255,255,0.06); border-radius: 12px; padding: 1rem;
  margin-bottom: 1rem;
}
.result-meta-item { display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-size: 0.9rem; font-weight: 600; }

.result-nap {
  background: rgba(139,92,246,0.15); border: 1px solid rgba(139,92,246,0.3);
  color: #c4b5fd; border-radius: 10px; padding: 0.6rem 1rem;
  font-size: 0.85rem; font-weight: 600; margin-bottom: 1rem;
}

.result-share {
  font-size: 0.8rem; color: rgba(255,255,255,0.35); font-weight: 600;
  cursor: default; letter-spacing: 0.03em;
}

/* ── MAIN CONTENT ── */
.section { padding: 5rem 1.5rem; }
.section-inner { max-width: 900px; margin: 0 auto; }

.section-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 900;
  color: var(--navy); margin-bottom: 0.5rem;
}
.section-sub { color: var(--text-light); font-size: 1rem; margin-bottom: 2.5rem; }

/* ── AGE TABLE ── */
#sleep-table { background: var(--white); }

.age-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.age-card {
  background: var(--cream);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  border-left: 4px solid var(--amber);
}
.age-card-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.age-card-icon { font-size: 1.4rem; }
.age-card-label { font-weight: 800; font-size: 0.95rem; color: var(--navy); }
.age-card-range { font-size: 0.8rem; color: var(--text-light); }
.age-card-hours {
  font-size: 1.6rem; font-weight: 900; color: var(--amber);
  line-height: 1; margin: 0.25rem 0;
}
.age-card-note { font-size: 0.82rem; color: var(--text-light); }

.table-source { font-size: 0.78rem; color: var(--text-light); margin-top: 1.5rem; }

/* ── AD PLACEHOLDER ── */
.ad-placeholder {
  border: 2px dashed #cbd5e1; border-radius: var(--radius);
  padding: 1.5rem; text-align: center;
  color: #94a3b8; font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  margin: 2rem auto; max-width: 900px;
}

/* ── AGE GUIDANCE ── */
#age-guidance { background: var(--cream-dark); }

.guidance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.25rem;
}
.guidance-card {
  background: var(--white); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}
.guidance-card h3 {
  font-size: 1rem; font-weight: 800; color: var(--navy); margin-bottom: 0.25rem;
}
.guidance-card .age-range {
  font-size: 0.78rem; color: var(--amber); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem;
}
.guidance-card p { font-size: 0.88rem; color: var(--text-light); margin-bottom: 0.5rem; }
.guidance-card .tip {
  font-size: 0.83rem; color: var(--text); background: var(--cream);
  border-radius: 8px; padding: 0.5rem 0.75rem; margin-top: 0.5rem;
}
.guidance-card .tip::before { content: '💡 '; }

/* ── AFFILIATE BANNER ── */
.affiliate-banner {
  background: #fffbeb; border: 2px solid var(--amber);
  border-radius: var(--radius); padding: 1.5rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin: 0 auto; max-width: 900px;
}
.affiliate-banner p { font-size: 1rem; font-weight: 700; color: var(--navy); }
.affiliate-banner a {
  background: var(--amber); color: var(--white);
  font-weight: 800; font-size: 0.9rem; padding: 0.6rem 1.25rem;
  border-radius: 999px; text-decoration: none; white-space: nowrap;
  transition: background 0.2s;
}
.affiliate-banner a:hover { background: var(--amber-dark); }

/* ── FAQ ── */
#faq { background: var(--white); }

.faq-list { max-width: 720px; margin: 0 auto; }
.faq-item { border-bottom: 1px solid #e2e8f0; }
.faq-question {
  width: 100%; text-align: left; background: none; border: none;
  padding: 1.1rem 0; display: flex; justify-content: space-between; align-items: center;
  font-family: 'Nunito', sans-serif; font-size: 0.95rem; font-weight: 700;
  color: var(--navy); cursor: pointer; gap: 1rem;
}
.faq-question .chevron {
  flex-shrink: 0; width: 20px; height: 20px; color: var(--text-light);
  transition: transform 0.3s;
}
.faq-item.open .chevron { transform: rotate(180deg); }
.faq-answer {
  max-height: 0; overflow: hidden; transition: max-height 0.35s ease;
  font-size: 0.9rem; color: var(--text-light); padding: 0;
}
.faq-item.open .faq-answer { max-height: 300px; padding-bottom: 1rem; }

/* ── RELATED TOOL ── */
.related-tool-wrap {
  padding-top: 0;
}

.related-tool-card {
  background: linear-gradient(135deg, #fff7e8 0%, #ffffff 100%);
  border: 2px solid rgba(245, 158, 11, 0.18);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 8px 30px rgba(0,0,0,0.06);
}

.related-tool-eyebrow {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber-dark);
  margin-bottom: 0.45rem;
}

.related-tool-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--navy);
  margin-bottom: 0.3rem;
}

.related-tool-copy {
  font-size: 0.92rem;
  color: var(--text-light);
  max-width: 620px;
}

.related-tool-button {
  background: var(--navy);
  color: var(--white);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.75rem 1.2rem;
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
}

.related-tool-button:hover {
  background: #0b1220;
  transform: translateY(-1px);
}

/* ── FOOTER ── */
footer {
  background: var(--navy); color: rgba(255,255,255,0.5);
  padding: 2.5rem 1.5rem; text-align: center; font-size: 0.82rem;
}
footer a { color: rgba(255,255,255,0.5); text-decoration: none; }
footer a:hover { color: var(--amber); }
footer .footer-logo { color: var(--white); font-weight: 800; font-size: 1rem; margin-bottom: 0.75rem; }
footer .footer-sources { margin-bottom: 0.5rem; }
footer .footer-disclaimer { font-style: italic; margin-bottom: 0.75rem; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .calc-card { padding: 1.5rem; }
  .related-tool-card { text-align: center; justify-content: center; }
  .pills {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 0.55rem;
  }
  .pill {
    min-height: 96px;
    font-size: 0.78rem;
    padding: 0.55rem 0.7rem;
  }
  .affiliate-banner { flex-direction: column; text-align: center; }
}
