/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

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

/* Header styles */
header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #ffd700 0%, #f5a623 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header h2 {
    font-size: 1.5rem;
    color: #a0a0a0;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    font-size: 1rem;
}

/* Psalms grid - Index page */
.psalms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.psalm-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    text-align: center;
    text-decoration: none;
    color: #fff;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.psalm-card:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.3);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.psalm-number {
    font-size: 2rem;
    font-weight: 700;
    color: #ffd700;
}

.psalm-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.psalm-hebrew {
    font-size: 0.9rem;
    color: #a0a0a0;
    direction: rtl;
}

/* Psalm page styles */
.psalm-page header {
    text-align: left;
}

.back-link {
    display: inline-block;
    color: #ffd700;
    text-decoration: none;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: #fff;
}

.psalm-page h1 {
    text-align: left;
    font-size: 2rem;
}

/* Controls panel */
.controls-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.play-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #f5a623 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.play-button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

.play-button svg {
    width: 28px;
    height: 28px;
    color: #1a1a2e;
}

.progress-container {
    flex: 1;
    min-width: 200px;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700 0%, #f5a623 100%);
    width: 0%;
    border-radius: 4px;
    transition: width 0.1s;
}

.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.5rem;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #888;
    font-size: 0.9rem;
}

.speed-control select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 0.5rem;
    color: #fff;
    cursor: pointer;
}

.speed-control select option {
    background: #1a1a2e;
}

/* Recording selector control */
.recording-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #888;
    font-size: 0.9rem;
}

.recording-control select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 0.5rem;
    color: #fff;
    cursor: pointer;
    max-width: 180px;
}

.recording-control select option {
    background: #1a1a2e;
}

/* View Toggle Controls */
.view-toggles {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.toggle-label {
    color: #888;
    font-size: 0.9rem;
}

.toggle-btn {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.toggle-btn.active {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.4);
    color: #ffd700;
}

/* Words container */
.words-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    direction: rtl;
    text-align: right;
    font-size: 1.8rem;
    line-height: 2.2;
    min-height: 300px;
}

/* Verse container - each verse on its own line */
.verse-container {
    display: flex;
    flex-direction: row-reverse;  /* RTL: verse number on right */
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.verse-container:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Verse number in margin */
.verse-number {
    flex-shrink: 0;
    width: 2.5rem;
    font-size: 1rem;
    color: #ffd700;
    opacity: 0.6;
    text-align: center;
    padding-top: 0.3rem;
    font-weight: 500;
}

/* Verse content wrapper */
.verse-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* STACKED MODE: Hebrew + Transliteration together (RTL flow) */
.verse-line-stacked {
    direction: rtl;
    text-align: right;
    line-height: 1.4;
}

.verse-line-stacked.verse-line-continuation {
    margin-right: 2rem;  /* RTL: indentation on the right */
}

/* Word wrapper - contains stacked Hebrew + Transliteration */
.word-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    margin: 0.2rem;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    vertical-align: top;
}

.word-wrapper:hover {
    background-color: rgba(255, 215, 0, 0.1);
}

.word-wrapper.active {
    background-color: rgba(255, 215, 0, 0.2);
}

/* Hebrew word in stacked mode */
.word-wrapper .word-hebrew {
    display: block;
    font-size: 1.8rem;
    text-align: center;
    transition: text-shadow 0.2s ease, color 0.2s ease;
}

/* Transliteration below Hebrew in stacked mode */
.word-wrapper .word-transliteration {
    display: block;
    font-size: 1rem;
    color: #a0a0a0;
    text-align: center;
    margin-top: 0.1rem;
}

/* Active state for stacked mode */
.word-wrapper.active .word-hebrew {
    color: #ffd700;
    text-shadow:
        0 0 10px rgba(255, 215, 0, 0.6),
        0 0 20px rgba(255, 215, 0, 0.4),
        0 0 30px rgba(255, 215, 0, 0.2);
}

.word-wrapper.active .word-transliteration {
    color: #ffd700;
}

/* TRANSLITERATION ONLY MODE: LTR flow */
.verse-line-translit-only {
    direction: ltr;
    text-align: left;
    line-height: 2.2;
}

.verse-line-translit-only.verse-line-continuation {
    margin-left: 2rem;  /* LTR: indentation on the left */
}

/* Transliteration word in solo mode */
.word-transliteration-solo {
    display: inline;
    font-size: 1.8rem;
    color: #e0e0e0;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    transition: text-shadow 0.2s ease, color 0.2s ease;
}

.word-transliteration-solo:hover {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.word-transliteration-solo.active {
    color: #ffd700;
    text-shadow:
        0 0 10px rgba(255, 215, 0, 0.6),
        0 0 20px rgba(255, 215, 0, 0.4),
        0 0 30px rgba(255, 215, 0, 0.2);
}

.error {
    color: #ff6b6b;
    text-align: center;
    direction: ltr;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .psalms-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.75rem;
    }

    .psalm-card {
        padding: 1rem 0.5rem;
    }

    .psalm-number {
        font-size: 1.5rem;
    }

    .controls-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .play-button {
        align-self: center;
    }

    .words-container {
        font-size: 1.4rem;
        padding: 1.5rem;
        line-height: 2.2;
    }

    .verse-container {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    .verse-number {
        width: 2rem;
        font-size: 0.85rem;
    }

    .verse-text {
        line-height: 2.2;
    }

    .verse-line-stacked.verse-line-continuation {
        margin-right: 1.5rem;  /* Slightly less indentation on mobile */
    }

    .verse-line-translit-only.verse-line-continuation {
        margin-left: 1.5rem;
    }

    /* View toggles responsive */
    .view-toggles {
        justify-content: center;
    }

    .toggle-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    /* Word sizes responsive */
    .word-wrapper .word-hebrew {
        font-size: 1.4rem;
    }

    .word-wrapper .word-transliteration {
        font-size: 0.85rem;
    }

    .word-transliteration-solo {
        font-size: 1.4rem;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}
