/* =========================================================
   Sleep Hygiene for Teenagers: main stylesheet
   Theme: calm night sky / moonlight, glassmorphism cards
   ========================================================= */

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

:root {
  /* palette */
  --bg-1: #0a0e27;
  --bg-2: #131a3d;
  --bg-3: #1c2454;
  --accent-1: #8e7cff;
  --accent-2: #6c5ce7;
  --accent-glow: #a29bfe;
  --moonlight: #ffe9b3;
  --moonlight-soft: #ffd97d;
  --text-main: #eceaff;
  --text-muted: #b3affc;
  --text-dim: #8a86c9;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.12);
  --card-border-hover: rgba(162, 155, 254, 0.55);
  --shadow-glow: 0 8px 32px rgba(108, 92, 231, 0.25);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --nav-height: 76px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  min-height: 100vh;
  line-height: 1.65;
  overflow-x: hidden;
  position: relative;
}

h1, h2, h3, h4 {
  font-family: 'Poppins', sans-serif;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

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

ul, ol {
  list-style: none;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
}

/* ---------- starfield background ---------- */
#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  opacity: 0.6;
  animation: twinkle linear infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(1); }
  50% { opacity: 0.95; transform: scale(1.6); }
}

/* decorative glow blobs */
.glow-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}
.glow-blob.one {
  width: 420px; height: 420px;
  background: var(--accent-2);
  top: -120px; left: -100px;
}
.glow-blob.two {
  width: 380px; height: 380px;
  background: var(--moonlight-soft);
  opacity: 0.12;
  top: 30%; right: -140px;
}

/* ---------- nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  background: rgba(10, 14, 39, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-main);
}

.logo-moon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--moonlight) 0%, var(--moonlight-soft) 45%, var(--accent-2) 100%);
  box-shadow: 0 0 18px rgba(255, 217, 125, 0.55);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2.1rem;
}

.nav-links a {
  position: relative;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.4rem 0.1rem;
  transition: color 0.25s ease;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-1), var(--moonlight-soft));
  transition: width 0.25s ease;
  border-radius: 2px;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-main);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 200;
}

.nav-toggle span {
  width: 26px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.85rem 1.7rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(108, 92, 231, 0.45);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(108, 92, 231, 0.6);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  padding: clamp(4rem, 10vw, 7rem) 0 clamp(3rem, 8vw, 5rem);
  z-index: 1;
}

.hero-inner {
  max-width: 760px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--moonlight-soft);
  background: rgba(255, 217, 125, 0.1);
  border: 1px solid rgba(255, 217, 125, 0.3);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2.4rem, 5.5vw, 3.8rem);
  font-weight: 800;
  margin-bottom: 1.25rem;
}

.hero h1 .accent {
  background: linear-gradient(120deg, var(--moonlight-soft), var(--accent-glow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p.lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 560px;
  margin-bottom: 2.2rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-hero {
  padding: clamp(3rem, 7vw, 4.5rem) 0 2.5rem;
  text-align: center;
}

.page-hero .eyebrow { margin-inline: auto; }

.page-hero h1 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  margin-bottom: 0.9rem;
}

.page-hero p.lead {
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
  font-size: 1.05rem;
}

/* ---------- sections ---------- */
.section {
  position: relative;
  z-index: 1;
  padding: clamp(2.5rem, 6vw, 4rem) 0;
}

.section-heading {
  margin-bottom: 2.5rem;
  text-align: center;
}

.section-heading h2 {
  font-size: clamp(1.7rem, 3.5vw, 2.3rem);
  margin-bottom: 0.75rem;
}

.section-heading p {
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- glass cards ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 2rem;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-6px);
  border-color: var(--card-border-hover);
  box-shadow: var(--shadow-glow);
}

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

.topic-card .icon-badge {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: linear-gradient(135deg, rgba(142, 124, 255, 0.25), rgba(255, 217, 125, 0.15));
  border: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 1.2rem;
}

.topic-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.6rem;
}

.topic-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
}

.card-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--moonlight-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.card-link .arrow {
  transition: transform 0.25s ease;
}

.card:hover .card-link .arrow {
  transform: translateX(4px);
}

/* ---------- answer content ---------- */
.answer-content {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 2rem;
  color: var(--text-main);
}

.answer-content p + p {
  margin-top: 0.75rem;
}

/* ---------- decorative hero moon (pure CSS, no image needed) ---------- */
.hero-moon {
  position: absolute;
  top: 10%;
  right: 4%;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--moonlight) 0%, var(--moonlight-soft) 40%, var(--accent-2) 100%);
  box-shadow: 0 0 90px rgba(255, 217, 125, 0.35), 0 0 160px rgba(108, 92, 231, 0.25);
  opacity: 0.85;
  animation: float 8s ease-in-out infinite;
  z-index: -1;
}

.hero-moon::after {
  content: "";
  position: absolute;
  top: 18%;
  left: 12%;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: var(--bg-1);
  opacity: 0.35;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}

@media (max-width: 860px) {
  .hero-moon { display: none; }
}

/* ---------- moon phase divider ---------- */
.moon-phase-divider {
  display: flex;
  justify-content: center;
  gap: clamp(0.6rem, 2vw, 1.4rem);
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  opacity: 0.7;
  padding: 0.5rem 0 2rem;
  position: relative;
  z-index: 1;
}

/* ---------- stat row ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.stat-card {
  text-align: center;
  padding: 1.75rem 1rem;
}

.stat-card .stat-num {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 2.1rem;
  background: linear-gradient(120deg, var(--moonlight-soft), var(--accent-glow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.4rem;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---------- tip cards (5 things) ---------- */
.tip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.75rem;
}

.tip-card {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.tip-card.full-width {
  grid-column: 1 / -1;
}

.tip-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
}

.tip-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.tip-head h3 {
  font-size: 1.15rem;
}

/* ---------- reference list ---------- */
.reference-list {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.reference-item {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
}

.ref-index {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  color: var(--moonlight-soft);
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 28px;
}

.ref-body {
  flex: 1;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  color: var(--text-main);
  font-size: 0.95rem;
}

.ref-tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.tag {
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(142, 124, 255, 0.18);
  color: var(--accent-glow);
  border: 1px solid rgba(142, 124, 255, 0.3);
}

/* ---------- page prev/next nav ---------- */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.page-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.25s ease, transform 0.25s ease;
  max-width: 45%;
}

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

.page-nav-link.next { text-align: right; align-items: flex-end; }

.page-nav-link .nav-eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.page-nav-link .nav-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  color: var(--text-main);
}

/* ---------- footer ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2.5rem 0;
  margin-top: 2rem;
}

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

.footer-meta {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ---------- reveal-on-scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- back to top ---------- */
.to-top {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(108, 92, 231, 0.5);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 90;
}

.to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .card-grid,
  .tip-grid { grid-template-columns: 1fr; }

  .stat-row { grid-template-columns: 1fr; }

  .nav-links {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(78vw, 320px);
    background: rgba(10, 14, 39, 0.97);
    backdrop-filter: blur(20px);
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 1.8rem;
    padding: 2rem;
    transform: translateX(100%);
    transition: transform 0.35s ease;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
  }

  .nav-links.open {
    transform: translateX(0);
  }

  .nav-toggle {
    display: flex;
  }

  body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

@media (max-width: 560px) {
  .page-nav-link { max-width: 100%; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
