/* ============================================
   Sri Vishnu Sahasranama - Chanting Guide
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --color-bg: #f0f4f8;
    --color-bg-alt: #e8eef5;
    --color-text: #1a1a2e;
    --color-text-muted: #4a5568;
    --color-primary: #1a3a6b;
    --color-primary-light: #2d5aa0;
    --color-primary-pale: #e8f0fe;
    --color-gold: #b8860b;
    --color-gold-light: #daa520;
    --color-saffron: #ff8c00;
    --color-border: #c4cdd8;
    --color-border-light: #dce3ec;
    --color-white: #ffffff;

    --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(26, 58, 107, 0.08);
    --shadow-md: 0 4px 12px rgba(26, 58, 107, 0.1);
    --shadow-lg: 0 8px 24px rgba(26, 58, 107, 0.12);
}

/* --- Reset & Base --- */
*, *::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: #0d1b2a;
    color: #8899aa;
    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: #a0b4cc;
    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));
    z-index: 1000;
    transition: width 0.1s ease;
    width: 0%;
}

/* --- Header --- */
.site-header {
    background: linear-gradient(135deg, #0d1b2a 0%, #1a3a6b 50%, #0d1b2a 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(218, 165, 32, 0.12) 0%, transparent 70%);
    pointer-events: none;
}

.header-content {
    position: relative;
    max-width: 700px;
    margin: 0 auto;
}

.header-ornament {
    font-size: 1.5rem;
    color: var(--color-gold-light);
    margin-bottom: 1rem;
    opacity: 0.8;
}

.site-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, #daa520 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(218, 165, 32, 0.15);
    border: 1px solid rgba(218, 165, 32, 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 1rem;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.9rem;
    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;
}

.nav-btn.pdf-btn {
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius);
    border-bottom: none;
    margin: 0.4rem 0.5rem;
    padding: 0.5rem 1rem;
    flex: 0 0 auto;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.nav-btn.pdf-btn:hover {
    background: var(--color-primary-dark, #141440);
    color: var(--color-white);
}

/* --- 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;
}

/* --- Pre-Stotra Section --- */
.pre-stotra-section {
    margin-bottom: 2.5rem;
}

.pre-stotra-label {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-gold);
}

.pre-stotra-label .label-sanskrit {
    font-family: var(--font-devanagari);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-gold);
    text-transform: none;
    letter-spacing: 0;
    margin-left: 0.5rem;
}

.speaker-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    font-style: italic;
    margin-bottom: 0.75rem;
}

/* --- Dhyana Verse --- */
.dhyana-verse {
    background: var(--color-white);
    border: 1px solid var(--color-border-light);
    border-left: 4px solid var(--color-gold);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.dhyana-verse .transliteration {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--color-text);
    margin-bottom: 1rem;
    white-space: pre-line;
    font-style: italic;
}

.dhyana-verse .english-transliteration {
    font-size: 1.05rem;
    font-style: normal;
    font-weight: 500;
    color: var(--color-text);
}

.dhyana-verse .devanagari-text {
    font-family: var(--font-devanagari);
    font-size: 1.15rem;
    line-height: 2;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
    white-space: pre-line;
    font-weight: 500;
}

.dhyana-verse .iast-transliteration {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.dhyana-verse .viniyoga-text .english-transliteration {
    font-size: 0.95rem;
    font-weight: 400;
}

.dhyana-verse .translation {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border-light);
    line-height: 1.6;
}

/* --- Stotram 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-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--color-primary-pale) 0%, var(--color-bg-alt) 100%);
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
}

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

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

.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;
}

/* Shloka text within the verse card */
.shloka-text {
    font-size: 1rem;
    line-height: 2;
    padding: 1rem;
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: center;
    font-style: italic;
    border: 1px solid var(--color-border-light);
}

.shloka-english {
    margin-bottom: 0.5rem;
}

.shloka-english .shloka-line {
    font-size: 1.05rem;
    font-style: normal;
    font-weight: 500;
    color: var(--color-primary);
}

.shloka-iast {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    font-style: italic;
    opacity: 0.85;
}

.shloka-iast .shloka-separator {
    font-size: 0.72rem;
}

.shloka-line {
    display: block;
    margin-bottom: 0.25rem;
}

.shloka-translations {
    border-top: 1px solid var(--color-border-light);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

.shloka-translation {
    display: block;
    font-size: 0.82rem;
    font-style: normal;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
    line-height: 1.5;
}

/* Devanagari display in stotram */
.shloka-devanagari {
    margin-bottom: 0.75rem;
}

.shloka-devanagari .devanagari-line {
    font-family: var(--font-devanagari);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--color-primary);
    line-height: 2;
    display: block;
    margin-bottom: 0.15rem;
}

.shloka-devanagari .devanagari-sep {
    font-family: var(--font-devanagari);
    font-size: 1.1rem;
    color: var(--color-gold);
}

.shloka-separator {
    display: block;
    color: var(--color-gold);
    font-style: normal;
    font-size: 0.8rem;
    margin: 0.15rem 0;
}

/* Names breakdown within verse */
.names-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.name-row {
    display: flex;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    background: var(--color-bg);
    border: 1px solid transparent;
    transition: all 0.15s ease;
    align-items: flex-start;
}

.name-row:hover {
    border-color: var(--color-primary-light);
    background: var(--color-primary-pale);
}

.name-num {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--color-gold);
    font-weight: 600;
    min-width: 2.5rem;
    text-align: right;
    padding-top: 0.15rem;
    flex-shrink: 0;
}

.name-details {
    flex: 1;
}

.name-iast {
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-primary);
    display: block;
    line-height: 1.4;
    font-style: italic;
}

.name-devanagari {
    font-family: var(--font-devanagari);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    display: block;
    line-height: 1.4;
    margin-top: 0.1rem;
}

.name-meaning {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-top: 0.15rem;
}

/* --- Names Grid (All Names View) --- */
.names-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.names-grid .name-row {
    background: var(--color-white);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
}

/* --- 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);
}

/* --- Closing Block --- */
.closing-block {
    text-align: center;
    padding: 2rem 0;
}

.closing-verse {
    margin-bottom: 1.5rem;
}

.closing-verse .transliteration {
    font-style: italic;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.closing-verse .translation {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* --- Search Highlight --- */
.highlight,
mark {
    background: rgba(218, 165, 32, 0.25);
    color: var(--color-text);
    padding: 0.1em 0.2em;
    border-radius: 3px;
    font-weight: 600;
}

/* --- Search Results Animation --- */
#search-results .name-row {
    animation: fadeInUp 0.3s ease forwards;
}

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

/* --- Floating 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, #0d1b2a 0%, #1a3a6b 50%, #0d1b2a 100%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    margin-top: 3rem;
}

.footer-ornament {
    font-size: 1.2rem;
    color: var(--color-gold-light);
    margin-bottom: 0.75rem;
    opacity: 0.7;
}

.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;
}

/* --- Expand/Collapse All --- */
.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);
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .scroll-buttons {
        bottom: 1.25rem;
        right: 1rem;
    }

    .scroll-btn {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }

    .header-sections {
        flex-direction: column;
        gap: 0.4rem;
    }
    html {
        font-size: 16px;
    }

    .site-title {
        font-size: 1.8rem;
    }

    .site-subtitle {
        font-size: 0.95rem;
    }

    .verse-body {
        padding: 0.75rem;
    }

    .shloka-text {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .name-row {
        padding: 0.5rem;
    }

    .name-num {
        min-width: 2rem;
    }
}

@media (min-width: 768px) {
    .names-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Print Styles --- */
/* --- Word Cards (like Soundarya Lahari / Bhagavad Gita) --- */
.word-section-label {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    margin-top: 0.75rem;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.word-card {
    background: var(--color-white);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius);
    padding: 0.85rem 0.65rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.word-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-gold);
    transform: translateY(-2px);
}

.word-devanagari {
    font-family: var(--font-devanagari);
    font-size: 1.4rem;
    line-height: 1.4;
    color: var(--color-text);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.word-transliteration {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--color-gold);
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

.word-num {
    font-size: 0.65rem;
    color: var(--color-text-muted);
    margin-bottom: 0.2rem;
    font-weight: 600;
}

.word-meaning {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

@media (max-width: 768px) {
    .word-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .word-devanagari {
        font-size: 1.2rem;
    }

    .shloka-devanagari .devanagari-line {
        font-size: 1.1rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .word-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media print {
    .progress-bar,
    .view-nav,
    .expand-controls,
    .verse-toggle,
    .search-box,
    .scroll-buttons {
        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;
    }
}
