
/* =========================================================
   IQRANIX AI — MADINAH MUSHAF DESIGN
   Fixed-page Quran reader
   Themes: Royal, Emerald, White, Black
========================================================= */

:root {
    --app-bg: #0b1428;
    --surface: #14213a;
    --surface-soft: #1a2b47;
    --text: #f5f1e8;
    --muted: #aab6c9;
    --accent: #d7b66b;
    --accent-soft: rgba(215,182,107,.14);
    --border: rgba(215,182,107,.28);

    --paper: #f7f0df;
    --paper-text: #28271f;
    --paper-border: #b69a62;
    --paper-decoration: #a48a58;

    --active-green: #b7e5bc;
    --active-green-text: #123b23;

    --danger: #ed7777;

    --header-height: 66px;
    --radius: 16px;

    --font-ui: "DM Sans", sans-serif;
    --font-quran: "Amiri", serif;
}


/* =========================================================
   RESET
========================================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    width: 100%;
    min-height: 100dvh;
    overflow-x: hidden;
    background: var(--app-bg);
    color: var(--text);
    font-family: var(--font-ui);
    -webkit-tap-highlight-color: transparent;
}

button,
select,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}


/* =========================================================
   THEMES
========================================================= */

body[data-theme="royal"] {
    --app-bg: #0b1428;
    --surface: #14213a;
    --surface-soft: #1a2b47;
    --text: #f5f1e8;
    --muted: #aab6c9;
    --accent: #d7b66b;
    --border: rgba(215,182,107,.28);

    --paper: #f7f0df;
    --paper-text: #28271f;
    --paper-border: #b69a62;
    --paper-decoration: #a48a58;
}

body[data-theme="emerald"] {
    --app-bg: #09241c;
    --surface: #123a2e;
    --surface-soft: #194b3a;
    --text: #eff8f1;
    --muted: #b5d2c1;
    --accent: #d2bd79;
    --border: rgba(210,189,121,.3);

    --paper: #f5f0dc;
    --paper-text: #252a20;
    --paper-border: #9eaa72;
    --paper-decoration: #82905d;
}

body[data-theme="white"] {
    --app-bg: #f0f1f2;
    --surface: #ffffff;
    --surface-soft: #f3f4f5;
    --text: #17212b;
    --muted: #697581;
    --accent: #987338;
    --border: rgba(120,100,65,.22);

    --paper: #fffdf6;
    --paper-text: #24221c;
    --paper-border: #c4b68d;
    --paper-decoration: #a38d60;
}

body[data-theme="black"] {
    --app-bg: #050505;
    --surface: #151515;
    --surface-soft: #202020;
    --text: #f5f5f5;
    --muted: #a9a9a9;
    --accent: #d7bd7a;
    --border: rgba(215,189,122,.25);

    --paper: #191919;
    --paper-text: #f2ead9;
    --paper-border: #927c51;
    --paper-decoration: #c0a36b;
}


/* =========================================================
   MAIN APP
========================================================= */

.learn-app {
    width: 100%;
    max-width: 900px;
    min-height: 100dvh;
    margin: 0 auto;
    padding-bottom: 12px;
    display: flex;
    flex-direction: column;
}


/* =========================================================
   HEADER
========================================================= */

.learn-header {
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 17px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.back-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;

    color: var(--text);
    text-decoration: none;
    font-size: 27px;

    border-radius: 12px;
    background: var(--surface-soft);
}

.header-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
}

.brand-subtitle {
    font-size: 8px;
    letter-spacing: 1.5px;
    color: var(--muted);
}

.theme-button {
    width: 38px;
    height: 38px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--surface-soft);
    color: var(--accent);

    font-size: 22px;
}


/* =========================================================
   THEME PANEL
========================================================= */

.theme-panel {
    position: absolute;
    z-index: 100;
    top: 60px;
    right: max(12px, calc((100vw - 870px) / 2));

    width: min(290px, calc(100vw - 24px));
    padding: 16px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 15px;

    box-shadow: 0 15px 45px rgba(0,0,0,.3);
}

.theme-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.theme-panel-header h3 {
    font-size: 14px;
}

.theme-panel-header button {
    border: 0;
    background: none;
    color: var(--text);
    font-size: 24px;
}

.theme-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 10px 8px;

    background: var(--surface-soft);
    color: var(--text);

    border: 1px solid transparent;
    border-radius: 10px;

    font-size: 11px;
    font-weight: 600;
}

.theme-option.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.theme-swatch {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid rgba(120,120,120,.3);
}

.royal-swatch {
    background: #17284a;
}

.emerald-swatch {
    background: #14513b;
}

.white-swatch {
    background: #fff;
}

.black-swatch {
    background: #080808;
}


/* =========================================================
   RECITER
========================================================= */

.reciter-strip {
    display: flex;
    align-items: center;
    gap: 11px;

    margin: 12px 14px;
    padding: 11px 12px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 13px;
}

.reciter-avatar {
    width: 43px;
    height: 43px;
    flex-shrink: 0;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: var(--accent-soft);
    border: 1px solid var(--border);

    color: var(--accent);
    font-family: var(--font-quran);
    font-size: 25px;
}

.reciter-details {
    min-width: 0;
    flex: 1;

    display: flex;
    flex-direction: column;
    gap: 3px;
}

.reciter-label {
    color: var(--accent);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1.4px;
}

.reciter-details strong {
    font-size: 12px;
}

.reciter-details > span:last-child {
    color: var(--muted);
    font-size: 10px;
}

.reciter-status {
    display: flex;
    align-items: center;
    gap: 5px;

    color: var(--muted);
    font-size: 8px;
    font-weight: 700;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #49c68a;
    box-shadow: 0 0 8px rgba(73,198,138,.35);
}


/* =========================================================
   SURAH TOOLBAR
========================================================= */

.mushaf-toolbar {
    margin: 0 14px 9px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 10px;
}

.selection-group {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.selection-group label,
.page-indicator > span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
}

.selection-group select {
    width: 100%;
    height: 39px;
    padding: 0 10px;

    color: var(--text);
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 9px;

    font-size: 12px;
}

.page-indicator {
    min-width: 75px;
    height: 39px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;

    padding: 0 10px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.page-indicator strong {
    color: var(--accent);
    font-size: 16px;
}

.page-indicator small {
    color: var(--muted);
    font-size: 8px;
}


/* =========================================================
   READING STATUS
========================================================= */

.reading-status {
    min-height: 25px;
    margin: 0 16px 8px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    color: var(--muted);
    font-size: 10px;
}

.reading-status.active {
    color: var(--accent);
}


/* =========================================================
   MUSHAF AREA
========================================================= */

.mushaf-area {
    width: 100%;
    padding: 0 8px;

    display: flex;
    flex-direction: column;
    align-items: center;
}

.mushaf-navigation {
    width: 100%;

    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 30px;
    align-items: center;
    gap: 5px;
}

.page-nav-button {
    width: 30px;
    height: 54px;

    display: grid;
    place-items: center;

    color: var(--accent);
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 9px;

    font-family: var(--font-ui);
    font-size: 30px;
}

.page-nav-button:disabled,
.page-navigation-bar button:disabled {
    opacity: .35;
    cursor: not-allowed;
}


/* =========================================================
   MUSHAF BOOK
========================================================= */

.mushaf-book {
    width: 100%;
    min-width: 0;
    display: flex;
    justify-content: center;
}

.mushaf-page {
    width: 100%;
    max-width: 570px;

    height: clamp(370px, 59dvh, 620px);

    padding: 7px;

    background: var(--paper);
    color: var(--paper-text);

    border: 1px solid var(--paper-border);
    border-radius: 4px;

    box-shadow:
        0 8px 25px rgba(0,0,0,.24),
        inset 0 0 0 2px rgba(255,255,255,.22);

    overflow: hidden;

    touch-action: pan-y;
    user-select: none;
}

.mushaf-page-border {
    width: 100%;
    height: 100%;

    padding: 8px 10px;

    display: flex;
    flex-direction: column;

    border: 1px solid var(--paper-border);
    position: relative;
    overflow: hidden;
}

.mushaf-page-border::before {
    content: "";
    position: absolute;
    inset: 4px;

    border: 1px solid rgba(164,138,88,.2);
    pointer-events: none;
}


/* =========================================================
   MUSHAF HEADER
========================================================= */

.mushaf-page-header {
    min-height: 25px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 5px 5px;

    color: var(--paper-decoration);
    border-bottom: 1px solid rgba(164,138,88,.45);

    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
}


/* =========================================================
   MUSHAF LINES
========================================================= */

.mushaf-lines {
    flex: 1;
    min-height: 0;

    width: 100%;

    display: flex;
    flex-direction: column;
    justify-content: space-evenly;

    overflow: hidden;

    direction: rtl;
    text-align: center;

    padding: 5px 0;
}

.mushaf-line {
    width: 100%;
    min-height: 0;

    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-around;

    direction: rtl;
    text-align: center;

    white-space: nowrap;
    overflow: hidden;

    line-height: 1.8;
}

.mushaf-word {
    display: inline;
    flex-shrink: 0;

    padding: 0 1px;

    color: var(--paper-text);

    font-family: var(--font-quran);
    font-size: clamp(13px, 2.35vw, 22px);
    font-weight: 400;

    line-height: 1.9;

    border-radius: 4px;

    transition:
        background .2s ease,
        color .2s ease;
}

.mushaf-word.active-word {
    background: var(--active-green);
    color: var(--active-green-text);

    border-radius: 4px;
}

.mushaf-word.completed-word {
    color: var(--paper-text);
}

.mushaf-word.active-ayah {
    background: var(--active-green);
    color: var(--active-green-text);
    border-radius: 4px;
}

.mushaf-ayah-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 20px;
    height: 20px;

    margin: 0 3px;

    color: var(--paper-decoration);

    font-family: var(--font-quran);
    font-size: 12px;
}

.mushaf-basmala {
    width: 100%;
    text-align: center;

    color: var(--paper-text);

    font-family: var(--font-quran);
    font-size: clamp(21px, 4vw, 31px);
    line-height: 2;

    padding: 4px 0;
}


/* =========================================================
   PAGE FOOTER
========================================================= */

.mushaf-page-footer {
    min-height: 24px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    border-top: 1px solid rgba(164,138,88,.45);

    color: var(--paper-decoration);
    font-size: 10px;
}

.page-footer-decoration {
    font-family: var(--font-quran);
    font-size: 17px;
}


/* =========================================================
   LOADING AND EMPTY STATES
========================================================= */

.mushaf-loading {
    height: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;

    color: var(--paper-decoration);
    font-size: 11px;
}

.loading-spinner {
    width: 25px;
    height: 25px;

    display: inline-block;

    border: 3px solid rgba(160,140,100,.2);
    border-top-color: var(--accent);

    border-radius: 50%;

    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   SWIPE HINT
========================================================= */

.swipe-hint {
    padding: 8px 0 5px;

    color: var(--muted);
    font-size: 9px;
    text-align: center;
}


/* =========================================================
   PAGE NAVIGATION BAR
========================================================= */

.page-navigation-bar {
    width: 100%;
    max-width: 570px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;

    padding: 5px 0;
}

.page-navigation-bar button {
    padding: 7px 10px;

    color: var(--text);
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 8px;

    font-size: 10px;
}

.page-navigation-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

#\mushafPageLabel,
#\learnProgressPercent {
    font-variant-numeric: tabular-nums;
}

.page-navigation-center span {
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
}


/* =========================================================
   AUDIO PLAYER
========================================================= */

.learning-player {
    margin: 9px 12px;
    padding: 13px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.player-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.player-ayah-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.player-ayah-info span {
    color: var(--accent);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
}

.player-ayah-info strong {
    font-size: 11px;
}

.player-reciter-name {
    color: var(--muted);
    font-size: 9px;
}

.audio-progress-area {
    display: flex;
    align-items: center;
    gap: 8px;

    margin-top: 13px;
}

.audio-progress-area span {
    min-width: 30px;

    color: var(--muted);
    font-size: 9px;
    font-variant-numeric: tabular-nums;
}

#learnAudioProgress {
    width: 100%;
    min-width: 0;
    height: 4px;

    appearance: none;
    -webkit-appearance: none;

    background: var(--surface-soft);
    border-radius: 10px;

    cursor: pointer;
}

#learnAudioProgress::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;

    width: 12px;
    height: 12px;

    background: var(--accent);
    border-radius: 50%;
}

#learnAudioProgress::-moz-range-thumb {
    width: 12px;
    height: 12px;

    background: var(--accent);
    border: none;
    border-radius: 50%;
}

.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(13px, 5vw, 25px);

    padding: 10px 0;
}

.player-controls button {
    width: 34px;
    height: 34px;

    display: grid;
    place-items: center;

    background: transparent;
    border: none;

    color: var(--text);
    font-size: 17px;
}

.player-controls .main-play-button {
    width: 46px;
    height: 46px;

    color: #172033;
    background: var(--accent);

    border-radius: 50%;

    font-size: 19px;
}

.player-settings {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;

    padding-top: 9px;
    border-top: 1px solid var(--border);
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 6px;

    color: var(--muted);
    font-size: 9px;
}

.toggle-option input {
    accent-color: #45a66a;
    width: 13px;
    height: 13px;
}


/* =========================================================
   LESSON PROGRESS
========================================================= */

.lesson-progress {
    margin: 0 14px 10px;
    padding: 11px 12px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.progress-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 8px;

    font-size: 10px;
}

.progress-heading span {
    color: var(--accent);
    font-weight: 700;
}

.progress-track {
    width: 100%;
    height: 5px;

    overflow: hidden;

    background: var(--surface-soft);
    border-radius: 10px;
}

.progress-fill {
    width: 0%;
    height: 100%;

    background: #49bd80;
    border-radius: 10px;

    transition: width .3s ease;
}

.progress-details {
    display: flex;
    justify-content: space-between;

    margin-top: 7px;

    color: var(--muted);
    font-size: 9px;
}

.progress-details strong {
    color: var(--text);
}


/* =========================================================
   ERROR PANEL
========================================================= */

.error-panel {
    margin: 12px;
    padding: 20px;

    text-align: center;

    background: var(--surface);
    border: 1px solid rgba(237,119,119,.35);
    border-radius: 14px;
}

.error-icon {
    width: 34px;
    height: 34px;

    display: grid;
    place-items: center;

    margin: 0 auto 10px;

    background: rgba(237,119,119,.12);
    color: var(--danger);

    border-radius: 50%;
    font-size: 20px;
    font-weight: 700;
}

.error-panel h3 {
    margin-bottom: 7px;
    font-size: 14px;
}

.error-panel p {
    margin-bottom: 13px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.error-panel button {
    padding: 9px 17px;

    background: var(--accent);
    color: #172033;

    border: none;
    border-radius: 8px;

    font-size: 11px;
    font-weight: 700;
}


/* =========================================================
   LOADING OVERLAY
========================================================= */

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;

    background: rgba(5,12,25,.83);
    color: white;

    font-size: 12px;
}


/* =========================================================
   DISCLAIMER
========================================================= */

.learning-disclaimer {
    margin: 0 14px;
    padding: 12px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 11px;
}

.learning-disclaimer strong {
    color: var(--accent);
    font-size: 10px;
}

.learning-disclaimer p {
    margin-top: 5px;

    color: var(--muted);
    font-size: 9px;
    line-height: 1.6;
}


/* =========================================================
   MOBILE LAYOUT
========================================================= */

@media (max-width: 480px) {

    .learn-app {
        padding-bottom: 8px;
    }

    .reciter-strip {
        margin: 9px 10px;
        padding: 9px;
    }

    .mushaf-toolbar {
        margin-left: 10px;
        margin-right: 10px;
    }

    .mushaf-navigation {
        grid-template-columns: 25px minmax(0, 1fr) 25px;
        gap: 4px;
    }

    .page-nav-button {
        width: 25px;
        height: 45px;
        font-size: 25px;
    }

    .mushaf-page {
        height: clamp(350px, 55dvh, 500px);
        padding: 5px;
    }

    .mushaf-page-border {
        padding: 6px 7px;
    }

    .mushaf-page-header {
        min-height: 22px;
        font-size: 7px;
    }

    .mushaf-word {
        font-size: clamp(12px, 3.5vw, 18px);
        line-height: 1.8;
    }

    .mushaf-ayah-marker {
        min-width: 16px;
        height: 17px;
        font-size: 10px;
    }

    .mushaf-page-footer {
        min-height: 20px;
    }

    .learning-player {
        margin: 7px 9px;
        padding: 11px;
    }

    .lesson-progress {
        margin-left: 10px;
        margin-right: 10px;
    }

    .learning-disclaimer {
        margin-left: 10px;
        margin-right: 10px;
    }

}


/* =========================================================
   SMALL PHONES
========================================================= */

@media (max-width: 360px) {

    .mushaf-page {
        height: 350px;
    }

    .mushaf-word {
        font-size: 12px;
    }

    .player-controls {
        gap: 10px;
    }

    .player-settings {
        gap: 6px;
    }

    .toggle-option {
        font-size: 8px;
    }

}


/* =========================================================
   SHORT SCREENS
========================================================= */

@media (max-height: 700px) {

    .reciter-strip {
        margin-top: 6px;
        margin-bottom: 7px;
        padding: 7px 10px;
    }

    .reciter-avatar {
        width: 35px;
        height: 35px;
    }

    .mushaf-page {
        height: 43dvh;
        min-height: 290px;
    }

    .learning-player {
        margin-top: 5px;
        margin-bottom: 5px;
        padding: 9px;
    }

    .player-controls {
        padding: 5px 0;
    }

    .lesson-progress {
        padding: 8px 10px;
    }

}


/* =========================================================
   ACCESSIBILITY
========================================================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }

}
