:root {
    --text-color: #333;
    --bg-color: #fcfcfc;
    --accent-color: #d1b17a;
    --link-color: #a07a3f;
    --font-serif: 'Merriweather', Georgia, serif;
    --font-arabic: 'Noto Naskh Arabic', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --sidebar-width: 350px;
    --content-max-width: 700px;
}

body {
    font-family: var(--font-serif);
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.7;
    margin: 0;
    padding: 0;
}

header {
    padding: 1rem 2rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 2rem;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #666;
    justify-content: flex-start; /* Breadcrumbs usually start from left */
}

.breadcrumbs a {
    text-decoration: none;
    color: var(--link-color);
    transition: color 0.2s;
}

.breadcrumbs a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.breadcrumbs .separator {
    color: #ccc;
    font-size: 0.8rem;
    margin: 0 0.2rem;
}

.breadcrumbs .current {
    color: #333;
    font-weight: 500;
}

.breadcrumbs .text {
    color: #666;
    font-weight: 400;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 400;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #111;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.arabic-text {
    font-family: var(--font-arabic);
    font-size: 1.8rem;
    direction: rtl;
    text-align: right;
    margin-bottom: 0.5rem;
    line-height: 2;
    color: #000;
    display: none; /* Hidden by default */
}

/* When the body has the class 'show-arabic', display the text */
body.show-arabic .arabic-text {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Hide footnotes when body has the class */
body.hide-footnotes .sidenote {
    display: none;
}

/* Adjust grid when footnotes are hidden to center content or expand it? 
   For now, let's just hide them. The grid column will remain empty.
   To reclaim space: 
*/
body.hide-footnotes .verse-container {
    grid-template-columns: 1fr; /* Expand to full width */
}

.arabic-toggle-container {
    text-align: center;
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem; /* Space between buttons */
}

.toggle-btn {
    background: transparent;
    border: 1px solid #ccc;
    padding: 0.4rem 1.2rem;
    border-radius: 2rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    font-weight: 500;
}

.toggle-btn:hover {
    border-color: #999;
    color: #555;
}

.toggle-btn.active {
    background-color: var(--link-color);
    border-color: var(--link-color);
    color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.toggle-btn.active:hover {
    background-color: #8c6b36; /* Slightly darker shade of link-color for hover */
    border-color: #8c6b36;
}

/* Sidenote Layout using CSS Grid */
.verse-container {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    gap: 2rem;
    margin-bottom: 1rem; /* Reduced from 2rem */
    position: relative;
    padding: 0.5rem 1rem; /* Reduced from 1rem */
    border-radius: 4px;
    transition: background-color 0.5s ease;
}

.verse-content {
    grid-column: 1;
    max-width: var(--content-max-width);
}

.verse-number {
    font-family: var(--font-sans);
    font-size: 0.75rem; /* Smaller */
    color: #aaa;
    margin-bottom: 0.2rem; /* Tighter */
    display: block;
}

.verse-translation {
    font-size: 1.1rem; /* Slightly smaller for compactness */
}

/* Compact mode when footnotes are hidden */
body.hide-footnotes .verse-container {
    grid-template-columns: 1fr;
    margin-bottom: 0.5rem;
    padding: 0.3rem 1rem;
}

body.hide-footnotes .verse-number {
    display: inline;
    margin-right: 0.5rem;
}

body.hide-footnotes .verse-content {
    display: flex;
    align-items: baseline;
    max-width: 100%;
}

/* Fix for when Arabic is SHOWN while notes are HIDDEN */
body.hide-footnotes.show-arabic .verse-content {
    display: block; /* Revert to block to stack Arabic and English */
}

body.hide-footnotes.show-arabic .verse-number {
    display: block; /* Put number back on top or inline with Arabic? Block is safer for RTL mixing */
    margin-bottom: 0.5rem;
}

body.hide-footnotes .verse-translation {
    display: inline;
}

.sidenote {
    grid-column: 2;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #666;
    padding-left: 1rem;
    border-left: 1px solid #eee;
    align-self: start; /* Align footnote with the top of the verse */
}

.sidenote-header {
    font-weight: bold;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    color: #999;
}

/* Highlighting */
.highlight {
    background-color: rgba(255, 245, 157, 0.4);
    animation: fadeHighlight 2s ease-out;
}

@keyframes fadeHighlight {
    from { background-color: rgba(255, 235, 59, 0.6); }
    to { background-color: rgba(255, 245, 157, 0.4); }
}

/* ROI Specific Styles */
.roi-content {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.roi-section {
    margin-bottom: 3rem;
}

.roi-text p {
    margin-bottom: 1.5rem;
    text-align: justify;
}

/* Responsive Design */
@media (max-width: 900px) {
    .verse-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .sidenote {
        grid-column: 1;
        border-left: none;
        border-top: 1px solid #eee;
        padding-top: 1rem;
        padding-left: 0;
        margin-top: 0.5rem;
        background-color: #f9f9f9;
        padding: 1rem;
    }

    header {
        padding: 1rem;
        /* text-align: center; removed as breadcrumbs are usually left-aligned */
    }

    .breadcrumbs {
        font-size: 0.85rem;
        gap: 0.3rem;
    }
}

/* Chapter Navigation */
.chapter-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

.chapter-nav a:nth-child(1) {
    text-align: left;
    justify-self: start;
}

.chapter-nav a:nth-child(2) {
    text-align: center;
    justify-self: center;
}

.chapter-nav a:nth-child(3) {
    text-align: right;
    justify-self: end;
}

.nav-btn {
    text-decoration: none;
    color: var(--link-color);
    font-family: var(--font-sans);
    font-weight: 500;
}

.nav-btn:hover {
    text-decoration: underline;
}

/* Index Pages */
.chapter-list {
    list-style: none;
    padding: 0;
}

/* Chapter Card Styles */
a.chapter-card, .chapter-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.chapter-card {
    border: 1px solid #eee;
    padding: 1.5rem;
    border-radius: 4px;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none; /* Ensure no underline on the card itself */
}

.chapter-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: block;
    color: var(--link-color); /* Match header link color */
}

.chapter-meta {
    font-size: 0.85rem;
    color: #888;
}