/* ===========================
   CSS Variables - Circadian Theme
   =========================== */
:root {
    --midnight-navy: #0F172A;
    --deep-indigo: #1E293B;
    --slate-grey: #334155;
    --soft-white: #E2E8F0;
    --circadian-amber: #F59E0B;
    --rem-purple: #818CF8;
    --success-green: #34D399;
    --info-blue: #60A5FA;
    
    --font-heading: 'Nunito', sans-serif;
    --font-body: 'Open Sans', sans-serif;
}

/* ===========================
   Base Styles
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--midnight-navy);
    color: var(--soft-white);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; margin-bottom: 1rem; }
h3 { font-size: 1.5rem; margin-bottom: 0.75rem; }

a {
    color: var(--circadian-amber);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #FBBF24;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===========================
   Navigation
   =========================== */
.nav-glass {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(129, 140, 248, 0.2);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--soft-white);
}

.logo .accent {
    color: var(--circadian-amber);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--soft-white);
    font-size: 1.5rem;
    cursor: pointer;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--soft-white);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
    background: rgba(129, 140, 248, 0.2);
    color: var(--circadian-amber);
}

/* Mobile Navigation */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(15, 23, 42, 0.98);
        flex-direction: column;
        gap: 0;
        padding: 1rem 0;
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s ease;
        border-bottom: 1px solid rgba(129, 140, 248, 0.2);
    }
    
    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }
    
    .nav-links li {
        padding: 0 20px;
    }
    
    .nav-links a {
        display: block;
        padding: 1rem;
    }
}

/* ===========================
   Hero Section
   =========================== */
.hero {
    position: relative;
    padding: 5rem 0 4rem;
    background: linear-gradient(180deg, var(--deep-indigo) 0%, var(--midnight-navy) 100%);
    overflow: hidden;
}

.hero-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top right, rgba(129, 140, 248, 0.1), transparent 50%),
                radial-gradient(circle at bottom left, rgba(245, 158, 11, 0.1), transparent 50%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.hero h1 {
    margin-bottom: 1rem;
    font-size: 3rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .hero {
        padding: 3rem 0 2rem;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
}

/* ===========================
   Animations
   =========================== */
.fade-in {
    animation: fadeIn 0.8s ease-out;
}

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

/* ===========================
   Content Sections
   =========================== */
.content-section {
    padding: 3rem 0;
}

.intro-box {
    padding: 2rem 0;
}

.section-title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--circadian-amber);
}

/* ===========================
   Content Cards
   =========================== */
.content-card {
    background: var(--deep-indigo);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.content-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(129, 140, 248, 0.15);
}

.content-card ul {
    line-height: 1.8;
}

.content-card ul li {
    margin-bottom: 0.5rem;
}

/* ===========================
   Stats Grid
   =========================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.stat {
    text-align: center;
    padding: 1.5rem;
    background: rgba(129, 140, 248, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(129, 140, 248, 0.3);
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--circadian-amber);
    font-family: var(--font-heading);
}

.stat-label {
    display: block;
    margin-top: 0.5rem;
    opacity: 0.9;
    font-size: 0.95rem;
}

/* ===========================
   Tip Generator
   =========================== */
.tip-generator {
    padding: 2rem 0;
}

.tip-card {
    text-align: center;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.1), rgba(245, 158, 11, 0.1));
}

.tip-card h3 {
    margin-bottom: 1.5rem;
}

.tip-text {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    min-height: 60px;
    transition: opacity 0.3s ease;
}

/* ===========================
   Card Grid
   =========================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.nav-card {
    background: var(--deep-indigo);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    display: block;
    color: var(--soft-white);
}

.nav-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 32px rgba(129, 140, 248, 0.2);
    border-color: var(--circadian-amber);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.nav-card h3 {
    color: var(--circadian-amber);
    margin-bottom: 0.5rem;
}

.nav-card p {
    opacity: 0.9;
    font-size: 0.95rem;
}

/* ===========================
   Buttons
   =========================== */
.btn-primary {
    background: var(--circadian-amber);
    color: var(--midnight-navy);
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #FBBF24;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* ===========================
   Sleep Stages
   =========================== */
.stage-card {
    border-left: 4px solid var(--info-blue);
}

.stage-card h3 {
    color: var(--info-blue);
}

.rem-card {
    border-left: 4px solid var(--rem-purple);
    background: linear-gradient(135deg, var(--deep-indigo), rgba(129, 140, 248, 0.05));
}

.rem-card h3 {
    color: var(--rem-purple);
}

.stage-detail {
    background: rgba(129, 140, 248, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    border-left: 3px solid var(--rem-purple);
}

.stage-detail strong {
    color: var(--circadian-amber);
}

/* ===========================
   Hypnogram
   =========================== */
.hypnogram {
    margin: 2rem 0;
    background: var(--midnight-navy);
    border-radius: 12px;
    padding: 1rem;
    position: relative;
}

#hypnogramCanvas {
    width: 100%;
    height: 300px;
    cursor: crosshair;
}

.hypnogram-tooltip {
    position: fixed;
    background: rgba(30, 41, 59, 0.95);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    pointer-events: none;
    border: 1px solid var(--rem-purple);
    display: none;
    z-index: 1000;
}

.hypnogram-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.hypnogram-note {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--circadian-amber);
}

/* ===========================
   10-3-2-1-0 Rule
   =========================== */
.rule-grid {
    display: grid;
    gap: 1.5rem;
    margin-top: 2rem;
}

.rule-item {
    display: flex;
    gap: 1.5rem;
    align-items: start;
}

.rule-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--circadian-amber);
    font-family: var(--font-heading);
    min-width: 80px;
    text-align: center;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    padding: 0.5rem;
    border: 2px solid rgba(245, 158, 11, 0.3);
}

.rule-content h4 {
    color: var(--circadian-amber);
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .rule-item {
        flex-direction: column;
        gap: 1rem;
    }
    
    .rule-number {
        min-width: 60px;
        font-size: 2rem;
    }
}

/* ===========================
   Disorders - Symptom Checklist
   =========================== */
.symptom-checklist {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(239, 68, 68, 0.1));
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
}

.symptom-checklist h3 {
    color: var(--circadian-amber);
    margin-bottom: 1rem;
}

.symptom-list {
    list-style: none;
    margin-left: 0;
}

.symptom-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(129, 140, 248, 0.1);
}

.symptom-list li:last-child {
    border-bottom: none;
}

.symptom-list li:before {
    content: "⚠️ ";
    margin-right: 0.5rem;
}

/* ===========================
   CTA Box
   =========================== */
.cta-box {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.2), rgba(245, 158, 11, 0.2));
    border: 2px solid var(--circadian-amber);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    margin: 2rem 0;
}

.cta-box h3 {
    color: var(--circadian-amber);
    margin-bottom: 1rem;
}

/* ===========================
   Sleep Calculator
   =========================== */
.calculator-container {
    max-width: 800px;
    margin: 0 auto;
}

.time-input-group {
    margin-bottom: 1.5rem;
}

.time-input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--circadian-amber);
}

.time-input {
    width: 100%;
    padding: 1rem;
    background: var(--midnight-navy);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 8px;
    color: var(--soft-white);
    font-size: 1.25rem;
    font-family: var(--font-body);
    text-align: center;
}

.time-input:focus {
    outline: none;
    border-color: var(--circadian-amber);
}

.results-box {
    background: var(--deep-indigo);
    border: 2px solid var(--circadian-amber);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.results-box.show {
    opacity: 1;
    transform: translateY(0);
}

.bedtime-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: rgba(129, 140, 248, 0.1);
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--circadian-amber);
}

.bedtime-option:last-child {
    margin-bottom: 0;
}

.bedtime-option .time {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--circadian-amber);
    font-family: var(--font-heading);
}

.bedtime-option .cycles {
    opacity: 0.9;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .bedtime-option {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* ===========================
   Quiz
   =========================== */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.question-card {
    background: var(--deep-indigo);
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 12px;
    padding: 2rem;
}

.question-number {
    color: var(--circadian-amber);
    font-weight: 600;
    margin-bottom: 1rem;
}

.question-text {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.answer-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.answer-btn {
    padding: 1.5rem;
    background: var(--midnight-navy);
    border: 2px solid rgba(129, 140, 248, 0.3);
    border-radius: 8px;
    color: var(--soft-white);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-heading);
}

.answer-btn:hover:not(:disabled) {
    background: rgba(129, 140, 248, 0.2);
    border-color: var(--circadian-amber);
    transform: translateY(-2px);
}

.answer-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.answer-btn.correct {
    background: rgba(52, 211, 153, 0.2);
    border-color: var(--success-green);
    color: var(--success-green);
}

.answer-btn.incorrect {
    background: rgba(239, 68, 68, 0.2);
    border-color: #EF4444;
    color: #EF4444;
}

.quiz-score {
    text-align: center;
    background: var(--deep-indigo);
    border: 2px solid var(--circadian-amber);
    border-radius: 12px;
    padding: 3rem 2rem;
}

.score-display {
    font-size: 4rem;
    font-weight: 700;
    color: var(--circadian-amber);
    margin: 1rem 0;
    font-family: var(--font-heading);
}

.score-message {
    font-size: 1.25rem;
    margin-bottom: 2rem;
}

/* ===========================
   Forms
   =========================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--circadian-amber);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 1rem;
    background: var(--midnight-navy);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 8px;
    color: var(--soft-white);
    font-family: var(--font-body);
    font-size: 1rem;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--circadian-amber);
}

.form-textarea {
    min-height: 150px;
    resize: vertical;
}

/* ===========================
   Sitemap
   =========================== */
.sitemap-section {
    margin-bottom: 2rem;
}

.sitemap-section h3 {
    color: var(--circadian-amber);
    margin-bottom: 1rem;
}

.sitemap-list {
    list-style: none;
    margin-left: 0;
}

.sitemap-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(129, 140, 248, 0.1);
}

.sitemap-list li:last-child {
    border-bottom: none;
}

.sitemap-list a {
    color: var(--soft-white);
    font-weight: 600;
}

.sitemap-list a:hover {
    color: var(--circadian-amber);
}

/* ===========================
   Text Link
   =========================== */
.text-link {
    color: var(--circadian-amber);
    text-decoration: underline;
    text-decoration-color: rgba(245, 158, 11, 0.3);
}

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

/* ===========================
   Footer
   =========================== */
.footer {
    background: var(--deep-indigo);
    border-top: 1px solid rgba(129, 140, 248, 0.2);
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--soft-white);
    font-size: 0.95rem;
    transition: color 0.3s ease;
}

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

.copyright {
    text-align: center;
    opacity: 0.7;
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .footer-links {
        gap: 1rem;
    }
}

/* ===========================
   Page-Specific Grid
   =========================== */
.page-grid {
    padding: 3rem 0;
}

/* ===========================
   Responsive Utilities
   =========================== */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .content-card {
        padding: 1.5rem;
    }
    
    .question-text {
        font-size: 1.25rem;
    }
    
    .score-display {
        font-size: 3rem;
    }
}