@font-face {
    font-family: 'LPMQ Isep Misbah';
    src: url('/assets/fonts/subset-LPMQIsepMisbah.woff2?v=2') format('woff2'),
         url('/assets/fonts/subset-LPMQIsepMisbah.woff?v=2') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Amiri';
    src: url('/assets/fonts/amiri-regular.woff2?v=2') format('woff2'),
         url('/assets/fonts/amiri-regular.woff?v=2') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Light Theme */
    --bg-color: #f4f4f5;
    --card-bg: #ffffff;
    --text-color: #1a1a1a;
    --border-color: #e5e5e5;
    --header-bg: #ffffff;
    --link-color: #2b6cb0;
    --meta-color: #718096;
    --quran-color: #2b6cb0;
    --tafsir-color: #1a1a1a;
    --tafsir-indo-color: #4a5568;
    
    --font-quran: "LPMQ Isep Misbah", "Scheherazade New", serif;
    --font-arabic-tafsir: "Amiri", "Traditional Arabic", serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif: "Georgia", "Cambria", "Times New Roman", serif;
    
    --size-arabic: 32px;
}

body.theme-sepia {
    --bg-color: #efe5ce;
    --card-bg: #fbf0d9;
    --text-color: #433422;
    --border-color: #e3d3b7;
    --header-bg: #fbf0d9;
    --link-color: #b05c2b;
    --meta-color: #8c7b65;
}

body.theme-dark {
    --bg-color: #0a0a0a;
    --card-bg: #121212;
    --text-color: #e0e0e0;
    --border-color: #333333;
    --header-bg: #1a1a1a;
    --link-color: #90cdf4;
    --meta-color: #a0aec0;
    --quran-color: #90cdf4;
    --tafsir-color: #e2e8f0;
    --tafsir-indo-color: #a0aec0;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    transition: background-color 0.2s, color 0.2s;
}

/* Ensure focus states are highly visible for a11y */
*:focus-visible {
    outline: 3px solid var(--link-color);
    outline-offset: 2px;
}

header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
    text-decoration: none;
}

.reader-controls button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 4px;
    padding: 10px; /* Target 44x44px for a11y */
    min-width: 44px;
    min-height: 44px;
    margin-left: 5px;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.reader-controls button[aria-pressed="true"] {
    background: var(--border-color);
}

.container {
    max-width: 760px; /* Optimal reading width */
    margin: 0 auto;
    padding: 20px;
}

.hero {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
}

.search-form {
    display: flex;
    max-width: 500px;
    margin: 0 auto 20px auto;
}

.search-form input {
    flex: 1;
    padding: 14px; /* Ensure 44px height */
    border: 1px solid var(--border-color);
    border-radius: 4px 0 0 4px;
    font-size: 1rem;
    background: var(--bg-color);
    color: var(--text-color);
}

.search-form button {
    padding: 14px 24px;
    background: var(--link-color);
    color: #fff;
    border: none;
    border-radius: 0 4px 4px 0;
    font-size: 1rem;
    cursor: pointer;
    min-height: 44px;
}

.resume-reading {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 8px;
    display: inline-block;
}
.resume-reading h3 { margin-top: 0; margin-bottom: 10px; font-size: 1.1rem; }

.surah-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.surah-card {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    align-items: center;
    min-height: 50px;
}

.surah-card:hover {
    border-color: var(--link-color);
    background: rgba(43, 108, 176, 0.03);
}

.surah-num {
    background: var(--border-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 0.9rem;
}

.surah-name {
    font-weight: bold;
}

/* Nav Top/Bottom */
.nav-top, .nav-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 40px 0;
    font-size: 0.9rem;
}

.btn {
    text-decoration: none;
    color: var(--link-color);
    font-weight: 600;
    padding: 12px 16px; /* 44px target */
    border-radius: 4px;
    display: inline-block;
    flex-shrink: 0;
}

.btn.primary {
    background: var(--link-color);
    color: #fff;
}

.btn.outline {
    border: 1px solid var(--link-color);
    font-size: 0.85rem;
    padding: 10px 16px;
}

.current-ayah {
    color: var(--meta-color);
    font-size: 1rem;
    margin: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    text-align: center;
}

/* Reader Elements - Card UI */
.read-mode-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.ayah-block {
    position: relative;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

body.theme-dark .ayah-block {
    box-shadow: none;
}

.terjemahan-separator {
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    margin-top: 1.25rem;
    display: flex;
    justify-content: center;
}
.ayah-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 1rem;
    min-height: 44px; /* A11y */
    min-width: 60px;
    border-radius: 9999px;
    background-color: transparent;
    color: var(--meta-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s, color 0.2s;
}
.ayah-pill:hover, .ayah-pill:active {
    background-color: var(--border-color);
    color: var(--text-color);
}
.ayah-pill svg {
    width: 16px;
    height: 16px;
    margin-left: 4px;
    opacity: 0.7;
}

/* Arabic typography - Dual font handling */
.arabic {
    font-family: var(--font-arabic-tafsir);
    font-size: var(--size-arabic);
    line-height: 2.4;
    margin-bottom: 1rem;
    color: var(--tafsir-color);
    text-align: right;
}

.quran-text {
    font-family: var(--font-quran);
    color: var(--quran-color);
    font-size: 1.22em;
}

.translation {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--tafsir-color);
    font-weight: bold;
    text-align: left;
}

.tafsir-inline {
    color: var(--tafsir-indo-color);
    font-weight: normal;
}

.ayah-actions {
    margin-top: 25px;
}

.search-result {
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
}
.search-result h3 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
}
.search-result h3 a {
    color: var(--link-color);
    text-decoration: none;
}

.back-link-container {
    margin-top: 60px;
    text-align: center;
}
.back-link {
    text-decoration: none;
    color: var(--link-color);
    padding: 10px 20px; /* 44px */
    display: inline-block;
}

@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    :root {
        --size-arabic: 28px;
    }
    .header-inner {
        flex-direction: row;
        padding: 10px 15px;
    }
    .site-title {
        font-size: 1.1rem;
    }
    .reader-controls button {
        padding: 8px;
        min-width: 40px;
        min-height: 40px;
    }
    .ayah-block {
        padding: 1rem;
    }
}

/* Editorial Content Styling */
.tafsir-editorial {
    padding: 20px 30px;
    background: var(--header-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 40px;
    line-height: 1.8;
}

.tafsir-editorial h1 {
    font-size: 1.8rem;
    color: var(--link-color);
    margin-top: 0;
    margin-bottom: 15px;
}

.tafsir-editorial h2 {
    font-size: 1.4rem;
    color: var(--text-color);
    margin-top: 30px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.tafsir-editorial p {
    margin-bottom: 15px;
}

.tafsir-editorial ul {
    margin-bottom: 20px;
    padding-left: 20px;
}

.tafsir-editorial li {
    margin-bottom: 8px;
}

@media (max-width: 600px) {
    .tafsir-editorial {
        padding: 15px;
    }
}

/* Read Mode Toggle */
.read-mode-toggle {
    display: flex;
    background-color: var(--border-color);
    padding: 0.25rem;
    border-radius: 0.75rem;
    max-width: 24rem;
    margin: 0 auto 1.5rem auto;
}
.read-mode-toggle button {
    flex: 1;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--meta-color);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.read-mode-toggle button.active {
    background-color: var(--card-bg);
    color: var(--link-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
body.theme-dark .read-mode-toggle button.active {
    background-color: var(--bg-color); /* darker active state on dark mode */
}

/* Arab Mode overrides */
.read-mode-container.mode-arab .translation {
    display: none;
}
.read-mode-container.mode-arab .arabic {
    margin-bottom: 0;
}

.mukaddimah-title {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--meta-color);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
}
