/* ============================================
   Medha Suktam
   The Hymn of Divine Intelligence
   ============================================ */

:root {
    --color-bg: #eff3f5;
    --color-bg-alt: #e4eaed;
    --color-text: #121a1e;
    --color-text-muted: #405058;
    --color-primary: #1a4a6a;
    --color-primary-light: #2a6a9a;
    --color-primary-pale: #eef4f8;
    --color-gold: #8a7a2a;
    --color-gold-light: #b0a030;
    --color-saffron: #c48a1a;
    --color-border: #a0b8c8;
    --color-border-light: #c0d0d8;
    --color-white: #ffffff;
    --color-invocation-bg: #eef4f8;
    --color-invocation-border: #2a6a9a;
    --color-prayer-bg: #f0eef8;
    --color-prayer-border: #5a4a8a;
    --color-blessing-bg: #eef8f0;
    --color-blessing-border: #2a7a4a;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', 'Georgia', serif;
    --font-devanagari: 'Noto Sans Devanagari', sans-serif;

    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(18, 26, 30, 0.08);
    --shadow-md: 0 4px 12px rgba(18, 26, 30, 0.1);
    --shadow-lg: 0 8px 24px rgba(18, 26, 30, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 18px; }
body { font-family: var(--font-body); color: var(--color-text); background: var(--color-bg); line-height: 1.7; -webkit-font-smoothing: antialiased; }

/* --- Top Bar --- */
.top-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 1.5rem; background: #0e1820; color: #708090; font-family: var(--font-body); font-size: 0.75rem; letter-spacing: 0.03em; border-bottom: 1px solid rgba(255,255,255,0.08); }
.top-bar a { color: #88a0b8; text-decoration: none; transition: color 0.2s ease; }
.top-bar a:hover { color: var(--color-gold-light); }
.top-bar .back-link { font-weight: 500; }

/* --- Reading Progress Bar --- */
.progress-bar { position: fixed; top: 0; left: 0; height: 3px; background: linear-gradient(90deg, var(--color-primary), var(--color-gold-light), var(--color-primary-light)); z-index: 1000; transition: width 0.1s ease; width: 0%; }

/* --- Header --- */
.site-header { background: linear-gradient(135deg, #0a1a2e 0%, #1a4a6a 40%, #8a7a2a 70%, #1a4a6a 100%); color: var(--color-white); text-align: center; padding: 3rem 1.5rem 2.5rem; position: relative; overflow: hidden; }
.site-header::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: radial-gradient(ellipse at center, rgba(138,122,42,0.15) 0%, transparent 70%); pointer-events: none; }
.header-content { position: relative; max-width: 700px; margin: 0 auto; }
.header-ornament { font-size: 2rem; color: var(--color-gold-light); margin-bottom: 1rem; opacity: 0.9; }
.site-title { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; letter-spacing: 0.02em; margin-bottom: 0.5rem; background: linear-gradient(135deg, #fff 0%, #e0d080 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.site-subtitle { font-family: var(--font-body); font-size: 1.1rem; font-weight: 300; opacity: 0.9; margin-bottom: 0.25rem; }
.site-source { font-size: 0.78rem; opacity: 0.6; font-style: italic; margin-bottom: 1rem; }
.header-sections { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-top: 0.5rem; }
.header-tag { font-size: 0.7rem; padding: 0.25rem 0.75rem; background: rgba(138,122,42,0.15); border: 1px solid rgba(138,122,42,0.3); border-radius: 20px; color: rgba(255,255,255,0.85); letter-spacing: 0.02em; }

/* --- Navigation --- */
.view-nav { position: sticky; top: 0; z-index: 100; background: var(--color-bg); border-bottom: 1px solid var(--color-border-light); box-shadow: var(--shadow-sm); }
.nav-inner { max-width: 900px; margin: 0 auto; display: flex; gap: 0; padding: 0 1rem; }
.nav-btn { flex: 1; padding: 0.75rem 0.5rem; border: none; background: transparent; font-family: var(--font-body); font-size: 0.85rem; color: var(--color-text-muted); cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s ease; }
.nav-btn:hover { color: var(--color-primary); background: var(--color-primary-pale); }
.nav-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

/* --- Content --- */
.content { max-width: 900px; margin: 0 auto; padding: 0 1rem; }
.view { display: none; }
.view.active { display: block; }

/* --- Section Blocks --- */
.section-block { margin: 2rem 0; }
.section-heading { font-family: var(--font-display); font-size: 1.5rem; color: var(--color-primary); text-align: center; margin-bottom: 0.5rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--color-border-light); position: relative; }
.section-heading::after { content: ''; position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); width: 60px; height: 2px; background: var(--color-primary); }
.section-heading-sanskrit { display: block; font-family: var(--font-devanagari); font-size: 1rem; color: var(--color-text-muted); font-weight: 400; margin-top: 0.25rem; }
.section-intro { text-align: center; color: var(--color-text-muted); font-size: 0.9rem; font-style: italic; margin-bottom: 1.5rem; line-height: 1.8; }
.section-intro em { color: var(--color-primary); font-weight: 500; }

/* --- Section Divider --- */
.section-divider { text-align: center; padding: 1.5rem 0; font-family: var(--font-display); font-size: 1.1rem; color: var(--color-primary); font-weight: 600; position: relative; }
.section-divider::before, .section-divider::after { content: ''; position: absolute; top: 50%; width: 80px; height: 1px; background: var(--color-border); }
.section-divider::before { right: calc(50% + 100px); }
.section-divider::after { left: calc(50% + 100px); }

/* --- Expand/Collapse Controls --- */
.expand-controls { text-align: center; margin-bottom: 1rem; }
.expand-btn { padding: 0.4rem 1rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-white); font-family: var(--font-body); font-size: 0.8rem; color: var(--color-text-muted); cursor: pointer; margin: 0 0.25rem; transition: all 0.15s ease; }
.expand-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* --- Verse Card --- */
.verse-card { background: var(--color-white); border: 1px solid var(--color-border-light); border-radius: var(--radius); margin-bottom: 1.5rem; box-shadow: var(--shadow-sm); overflow: hidden; transition: box-shadow 0.2s ease; }
.verse-card:hover { box-shadow: var(--shadow-md); }

.verse-card.invocation-type { border-left: 4px solid var(--color-invocation-border); }
.verse-card.prayer-type { border-left: 4px solid var(--color-prayer-border); }
.verse-card.blessing-type { border-left: 4px solid var(--color-blessing-border); }

.verse-header { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--color-border-light); cursor: pointer; }

.invocation-type .verse-header { background: linear-gradient(135deg, var(--color-invocation-bg) 0%, var(--color-bg-alt) 100%); }
.prayer-type .verse-header { background: linear-gradient(135deg, var(--color-prayer-bg) 0%, var(--color-bg-alt) 100%); }
.blessing-type .verse-header { background: linear-gradient(135deg, var(--color-blessing-bg) 0%, var(--color-bg-alt) 100%); }

.verse-number { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; color: var(--color-white); font-family: var(--font-display); font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }
.invocation-type .verse-number { background: var(--color-invocation-border); }
.prayer-type .verse-number { background: var(--color-prayer-border); }
.blessing-type .verse-number { background: var(--color-blessing-border); }

.verse-text-preview { font-size: 0.85rem; color: var(--color-text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-devanagari); }

.verse-type-tag { font-size: 0.6rem; padding: 0.15rem 0.5rem; border-radius: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; flex-shrink: 0; }
.invocation-type .verse-type-tag { background: rgba(42,106,154,0.1); color: #1a4a6a; border: 1px solid rgba(42,106,154,0.3); }
.prayer-type .verse-type-tag { background: rgba(90,74,138,0.1); color: #3a2a6a; border: 1px solid rgba(90,74,138,0.3); }
.blessing-type .verse-type-tag { background: rgba(42,122,74,0.1); color: #1a5a3a; border: 1px solid rgba(42,122,74,0.3); }

.verse-toggle { color: var(--color-text-muted); font-size: 1.2rem; transition: transform 0.2s ease; flex-shrink: 0; }
.verse-card.expanded .verse-toggle { transform: rotate(180deg); }
.verse-body { padding: 1.25rem; }
.verse-card:not(.expanded) .verse-body { display: none; }

/* --- Text Blocks --- */
.devanagari-block { font-family: var(--font-devanagari); font-size: 1.15rem; line-height: 2; padding: 1.25rem; background: var(--color-bg-alt); border-radius: var(--radius); margin-bottom: 1rem; text-align: center; border: 1px solid var(--color-border-light); color: var(--color-text); white-space: pre-line; }
.transliteration-block { font-size: 0.95rem; line-height: 1.9; padding: 1rem 1.25rem; background: var(--color-white); border-radius: var(--radius); margin-bottom: 1rem; font-style: italic; color: var(--color-text); border: 1px solid var(--color-border-light); text-align: center; white-space: pre-line; }
.english-block { padding: 1rem 1.25rem; margin-bottom: 0; border-left: 3px solid var(--color-primary); background: var(--color-primary-pale); border-radius: 0 var(--radius) var(--radius) 0; }
.english-label { font-family: var(--font-display); font-size: 0.75rem; font-weight: 600; color: var(--color-primary); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.4rem; }
.english-text { font-size: 0.92rem; line-height: 1.7; color: var(--color-text); }

/* --- Overview --- */
.overview-content { display: flex; flex-direction: column; gap: 1.5rem; }
.overview-card { background: var(--color-white); border: 1px solid var(--color-border-light); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.overview-card h3 { font-family: var(--font-display); font-size: 1.1rem; color: var(--color-primary); margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--color-border-light); }
.overview-card p { margin-bottom: 0.75rem; font-size: 0.92rem; line-height: 1.7; }
.overview-card p:last-child { margin-bottom: 0; }
.overview-card ul { margin-left: 1.25rem; font-size: 0.92rem; line-height: 1.8; }
.overview-card li { margin-bottom: 0.35rem; }

/* --- Search --- */
.search-box { position: relative; margin-bottom: 1.5rem; }
.search-box input { width: 100%; padding: 0.9rem 1.25rem; padding-right: 5rem; border: 2px solid var(--color-border); border-radius: var(--radius); font-family: var(--font-body); font-size: 1rem; color: var(--color-text); background: var(--color-white); outline: none; transition: border-color 0.2s ease; }
.search-box input:focus { border-color: var(--color-primary); }
.search-box input::placeholder { color: var(--color-border); }
.search-count { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); font-size: 0.8rem; color: var(--color-text-muted); }

.highlight, mark { background: rgba(26,74,106,0.2); color: var(--color-text); padding: 0.1em 0.2em; border-radius: 3px; font-weight: 600; }

/* --- Scroll Buttons --- */
.scroll-buttons { position: fixed; bottom: 2rem; right: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.scroll-buttons.visible { opacity: 1; pointer-events: auto; }
.scroll-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--color-border); background: var(--color-white); color: var(--color-primary); font-size: 1rem; cursor: pointer; box-shadow: var(--shadow-md); transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; }
.scroll-btn:hover { background: var(--color-primary); color: var(--color-white); border-color: var(--color-primary); box-shadow: var(--shadow-lg); transform: scale(1.1); }

/* --- Footer --- */
.site-footer { text-align: center; padding: 2rem 1.5rem; background: linear-gradient(135deg, #0a1a2e 0%, #1a4a6a 50%, #0a1a2e 100%); color: rgba(255,255,255,0.85); font-size: 0.85rem; margin-top: 3rem; }
.footer-ornament { font-size: 1.2rem; color: var(--color-gold-light); margin-bottom: 0.75rem; opacity: 0.8; }
.footer-note { font-size: 0.75rem; opacity: 0.5; margin-top: 0.25rem; }
.footer-note a { color: var(--color-gold-light); text-decoration: none; }
.footer-note a:hover { text-decoration: underline; }

/* --- Responsive --- */
@media (max-width: 600px) {
    html { font-size: 16px; }
    .site-title { font-size: 1.6rem; }
    .site-subtitle { font-size: 0.95rem; }
    .nav-btn { font-size: 0.72rem; padding: 0.7rem 0.3rem; }
    .verse-body { padding: 0.75rem; }
    .devanagari-block { padding: 0.75rem; font-size: 1rem; }
    .transliteration-block { padding: 0.75rem; font-size: 0.85rem; }
    .header-sections { flex-direction: column; gap: 0.4rem; }
    .verse-type-tag { display: none; }
    .section-divider::before, .section-divider::after { width: 40px; }
    .section-divider::before { right: calc(50% + 60px); }
    .section-divider::after { left: calc(50% + 60px); }
    .overview-card { padding: 1rem; }
}

@media print {
    .progress-bar, .view-nav, .expand-controls, .verse-toggle, .search-box, .top-bar { display: none !important; }
    .verse-card:not(.expanded) .verse-body { display: block !important; }
    .verse-card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
    body { font-size: 12pt; }
}
