/* =========================
   FONTS
========================= */
@font-face {
    font-family: 'IsepMisbah';
    src: url('../fonts/LPMQ-IsepMisbah.ttf') format('truetype');
    font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('../fonts/Montserrat-Regular.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    src: url('../fonts/Montserrat-Bold.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
}

/* =========================
   DESIGN TOKENS (VARIABLES)
========================= */
:root {
    /* Light Mode Premium */
    --bg-body: #1b4332;
    --bg-page: #ffffff;
    --text-primary: #1f2421;
    --text-secondary: #606662;
    --text-heading: #1b4332;
    --accent-color: #c8a85c;
    
    /* Cetakan Masking Pattern Islami */
    --mask-pattern: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='60'%20height='60'%20viewBox='0%200%2060%2060'%3E%3Cpath%20d='M30%200%20L60%2030%20L30%2060%20L0%2030%20Z%20M0%200%20L60%2060%20M60%200%20L0%2060%20M30%200%20L30%2060%20M0%2030%20L60%2030'%20stroke='black'%20stroke-width='0.6'%20fill='none'/%3E%3Ccircle%20cx='30'%20cy='30'%20r='5'%20stroke='black'%20stroke-width='0.6'%20fill='none'/%3E%3C/svg%3E");
    --pattern-opacity: 0.25; 

    /* Ayat Card Token (PENTING: Agar kartu tidak hilang) */
    --card-border: rgba(200, 168, 92, 0.15);
    --card-bg-normal: linear-gradient(135deg, #ffffff 0%, #fdfcf9 100%);
    --card-bg-active: linear-gradient(135deg, #ffffff 0%, #fffdf0 100%);
    --card-shadow-base: 0 4px 20px rgba(0, 0, 0, 0.02), 0 10px 25px rgba(200, 168, 92, 0.04);
    
    /* Active State Tokens */
    --active-border: rgba(200, 168, 92, 0.5);
    --active-shadow: 0 12px 30px rgba(200, 168, 92, 0.12);
    --active-shadow-hover: 0 16px 40px rgba(200, 168, 92, 0.18);
}

[data-theme="dark"] {
    /* Dark Mode Premium */
    --bg-body: #D4AF37;
    --bg-page: #131a16;
    --text-primary: #e3e8e5;
    --text-secondary: #909a94;
    --text-heading: #ecdcb9;
    --accent-color: #d4af37;
    
    --pattern-opacity: 0.12; 

    /* Ayat Card Token Dark Mode */
    --card-border: rgba(255, 255, 255, 0.06);
    --card-bg-normal: linear-gradient(135deg, #1b4332 0%, #131a16 100%);
    --card-bg-active: linear-gradient(135deg, #222920 0%, #1b4332 100%);
    --card-shadow-base: 0 4px 20px rgba(0, 0, 0, 0.3);
    
    /* Active State Tokens Dark Mode */
    --active-border: rgba(212, 175, 55, 0.5);
    --active-shadow: 0 12px 30px rgba(212, 175, 55, 0.1);
    --active-shadow-hover: 0 16px 40px rgba(212, 175, 55, 0.15);
}

/* =========================
   ANIMATION KEYFRAMES
========================= */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmerEffect {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes gentlePulse {
    0%, 100% { 
        filter: drop-shadow(0 0 5px rgba(201, 168, 76, 0.3)); 
        transform: scale(0.99); 
    }
    50% { 
        filter: drop-shadow(0 0 15px rgba(201, 168, 76, 0.6)); 
        transform: scale(1); 
    }
}

@keyframes brandFlow {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

/* =========================
   RESET & BASE
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    font-family: 'Montserrat', sans-serif;
    color: var(--text-primary);
    padding: 10px;
    transition: background-color 0.4s ease, color 0.4s ease;
    min-height: 100vh;
}

/* =========================
   PAGE CONTAINER
========================= */
.page {
    max-width: 480px;
    margin: auto;
    background-color: var(--bg-page);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
    position: relative;
    overflow: hidden;
    transition: background-color 0.4s ease;
    z-index: 1;
}

.page > * {
    position: relative;
    z-index: 2;
}

.page::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1; /* Dipastikan -1 agar otomatis berada di belakang ayat-card */
    pointer-events: none;

    background: linear-gradient(135deg, #C9A84C 0%, #FDE047 25%, #FFFFFF 50%, #C9A84C 75%, #FDE047 100%);
    background-size: 200% auto;


    -webkit-mask-image: var(--mask-pattern);
    mask-image: var(--mask-pattern);
    -webkit-mask-repeat: repeat;
    mask-repeat: repeat;
    -webkit-mask-size: 76px;
    mask-size: 76px;

    opacity: var(--pattern-opacity);
    transition: opacity 0.4s ease;
}

/* =========================
   THEME TOGGLE BUTTON
========================= */
.theme-toggle {
    position: absolute;
    top: 11px; /* Disesuaikan ke 20px agar sejajar secara visual dengan padding container */
    right: 20px;
    background: transparent;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    z-index: 10;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.theme-toggle:hover {
    background-color: rgba(200, 168, 92, 0.1);
    transform: scale(1.05);
}

.theme-icon {
    transition: stroke 0.3s ease;
}

/* =========================
   HEADER
========================= */
.header {
	margin-left: -21px;
	margin-right: -21px;
    margin-top: -15px;
	width: calc(100% + 42px);
	background: var(--card-bg-normal);
	padding: 16px 15px;
    text-align: center;
    margin-bottom: 15px;
    animation: fadeInUp 1.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.header h1 {
    color: var(--text-heading);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 6px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.header h6 {
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.3;
    margin-bottom: 12px;
    font-size: 0.55rem;
    opacity: 0.85;
}

.separator {
    width: 135px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color) 0%, #FFFEEA 50%, var(--accent-color) 100%);
    background-size: 200% auto;
    border-radius: 5px;
    margin: 16px auto;
    animation: shimmerEffect 11s linear infinite;
    box-shadow: 0 2px 8px rgba(218, 165, 32, 0.2);
}

.header p {
    color: var(--text-secondary);
    line-height: 1.4; /* Sedikit dilonggarkan dari 1.1 agar nama Almarhumah lebih mudah dibaca */
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    background: var(--card-bg-normal);
    padding: 10px 20px;
    border-radius: 12px;
    display: inline-block;
    border: 1px solid rgba(226, 232, 240, 0.5);
    animation: gentlePulse 3.5s ease-in-out infinite;
}

.header p strong {
    color: var(--text-heading);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* =========================
   TYPOGRAPHY & VERSES
========================= */
.bismillah {
    font-family: 'IsepMisbah';
    font-size: 1.7rem;
    text-align: center;
    direction: rtl;
    color: var(--text-primary);
    margin-bottom: 19px;
    line-height: 1.8;
}

.arabic {
    font-family: 'IsepMisbah';
    direction: rtl;
    text-align: right;
    font-size: 1.7rem;
    color: var(--text-primary);
    line-height: 2.1;
    margin-bottom: 13px;
    transform-origin: right center;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), color 0.4s ease;
}

.ayat-card.active .arabic {
    transform: scale(1.03); /* Diturunkan dari 1.05 agar teks Arab tidak memotong garis tepi pada layar kecil */
    color: var(--text-heading);
}

.latin {
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.3;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.translation {
    color: var(--text-primary);
    line-height: 1.4;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

/* Footnotes (Catatan Kaki) */
.catatankaki {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed rgba(113, 128, 150, 0.2); 
    transition: border-color 0.4s ease;
}

.ayat-card.active .catatankaki {
    border-top-color: rgba(212, 175, 55, 0.3);
}

.catatankaki p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.5;
    font-style: italic;
    margin: 0;
    opacity: 0.8;
}

.catatankaki-ref {
    color: #E53E3E;
    font-size: 0.7rem;
    font-weight: 600;
    vertical-align: super;
    line-height: 0;
    margin-left: 2px;
    display: inline-block;
    transform: translateY(-2px);
}

.catatankaki-num {
    color: #E53E3E;
    font-weight: 600;
    margin-right: 4px;
    font-style: normal;
}

/* =========================
   AYAT CARD COMPONENT
========================= */
.ayat-card {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    padding: 15px;
    margin-bottom: 13px;
    cursor: pointer;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow-base);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.6s ease;
}

.ayat-card::before,
.ayat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 0;
}

.ayat-card::before {
    background: var(--card-bg-normal);
    opacity: 1;
}

.ayat-card::after {
    background: var(--card-bg-active);
    opacity: 0;
}

.ayat-card > * {
    position: relative;
    z-index: 1;
}

.ayat-card:hover {
    transform: translateY(-2px); /* Dioptimalkan menjadi 2px agar transisi naik terasa kokoh di perangkat mobile */
    box-shadow: 0 10px 20px -5px rgba(0,0,0,0.05), 0 20px 40px -10px rgba(0,0,0,0.08);
}

/* Active State */
.ayat-card.active {
    border-color: var(--active-border);
    box-shadow: var(--active-shadow);
}

.ayat-card.active::before { opacity: 0; }
.ayat-card.active::after { opacity: 1; }

.ayat-card.active:hover {
    box-shadow: var(--active-shadow-hover);
}

/* Card Header Layout */
.ayat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 5px;
}

.ayat-number {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-page);
    border: 2px solid var(--accent-color);
    color: var(--text-heading);
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.5s ease;
}

.ayat-line {
    flex: 1;
    height: 2px;
    background: var(--accent-color);
    transition: background-color 0.5s ease;
}

.ayat-card.active .ayat-number {
    background: var(--accent-color);
    color: #ffffff;
    border-color: var(--accent-color);
}

/* =========================
   PAGINATION CONTROLS
========================= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 13px;
    margin-bottom: 12px;
}

.page-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Isolasikan hover/active hanya untuk tombol yang tidak disabled */
.page-btn:hover:not(:disabled), 
.page-btn:active:not(:disabled) {
    background: var(--accent-color);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(200, 168, 92, 0.3);
}

[data-theme="dark"] .page-btn:hover:not(:disabled), 
[data-theme="dark"] .page-btn:active:not(:disabled) {
    color: var(--bg-page);
}

.page-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: transparent;
    color: var(--accent-color);
}

/* Dropdown Paginasi Bulat Premium */
.footer-page-select {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--text-heading);
    color: var(--bg-page);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    text-align-last: center;
    border: none;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* =========================
   FOOTER
========================= */
.footer {
    margin-left: -21px;  /* Menarik ke kiri sejauh padding .page */
    margin-right: -21px; /* Menarik ke kanan sejauh padding .page */
    margin-bottom: -15px; /* Menembus mentok ke batas bawah border .page */
    margin-top: 15px;    /* Jarak pemisah dari komponen pagination di atasnya */
    
    width: calc(100% + 42px); /* Lebar otomatis kalkulasi total kanan-kiri */
    background: var(--card-bg-normal);
    border-top: 1px solid var(--card-border);
    padding: 16px 11px; /* Memberikan padding internal baru agar teks brand di dalam tidak mentok */
    text-align: center;
}

.footer-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--text-heading);
    color: var(--bg-page);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.footer-brand {
    color: var(--accent-color);
    font-size: 0.55rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 8px;
    display: block;
}