/* ==========================================================================
   LinguisticQuran - Main Stylesheet
   Modern, Premium UI with RTL Support
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables - Design Tokens
   -------------------------------------------------------------------------- */
:root {
    /* Colors - Primary Palette */
    --color-primary: #0d6e6e;
    --color-primary-light: #14a3a3;
    --color-primary-dark: #094d4d;
    --color-primary-gradient: linear-gradient(135deg, #0d6e6e 0%, #14a3a3 100%);

    /* Colors - Secondary/Accent */
    --color-accent: #c9a227;
    --color-accent-light: #e6c255;
    --color-accent-dark: #9a7b1d;

    /* Colors - Semantic */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;

    /* Colors - Neutral */
    --color-bg: #fafafa;
    --color-bg-alt: #f3f4f6;
    --color-surface: #ffffff;
    --color-surface-hover: #f9fafb;
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;

    /* Colors - Text */
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    --color-text-inverse: #ffffff;

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-arabic: 'Amiri', 'Traditional Arabic', serif;

    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;

    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Container */
    --container-max: 1280px;
    --container-padding: var(--space-6);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #111827;
        --color-bg-alt: #1f2937;
        --color-surface: #1f2937;
        --color-surface-hover: #374151;
        --color-border: #374151;
        --color-border-light: #4b5563;
        --color-text: #f9fafb;
        --color-text-secondary: #d1d5db;
        --color-text-muted: #9ca3af;
    }
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-primary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* RTL Support */
[dir="rtl"] {
    font-family: var(--font-arabic), var(--font-primary);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-light);
}

img {
    max-width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
   Container
   -------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: var(--line-height-tight);
    color: var(--color-text);
}

h1 {
    font-size: var(--font-size-4xl);
}

h2 {
    font-size: var(--font-size-3xl);
}

h3 {
    font-size: var(--font-size-2xl);
}

h4 {
    font-size: var(--font-size-xl);
}

h5 {
    font-size: var(--font-size-lg);
}

h6 {
    font-size: var(--font-size-base);
}

.text-arabic {
    font-family: var(--font-arabic);
    font-size: 1.5em;
    line-height: var(--line-height-relaxed);
    direction: rtl;
    text-align: right;
}

.ayah-text {
    font-family: var(--font-arabic);
    font-size: 1.75rem;
    line-height: 2.2;
    direction: rtl;
    text-align: center;
    color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Disclaimer Banner
   -------------------------------------------------------------------------- */
.disclaimer-banner {
    background: linear-gradient(90deg, var(--color-warning) 0%, #d97706 100%);
    color: #1f2937;
    padding: var(--space-3) 0;
    font-size: var(--font-size-sm);
}

.disclaimer-banner p {
    text-align: center;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.main-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    gap: var(--space-6);
}

.logo {
    display: flex;
    flex-direction: column;
    gap: 0;
    color: var(--color-text);
}

.logo:hover {
    color: var(--color-primary);
}

.logo-arabic {
    font-family: var(--font-arabic);
    font-size: var(--font-size-lg);
    color: var(--color-primary);
}

.logo-text {
    font-size: var(--font-size-sm);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--space-6);
}

.nav-menu a {
    color: var(--color-text-secondary);
    font-weight: 500;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-menu a:hover {
    color: var(--color-primary);
    background: var(--color-bg-alt);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.language-switcher select {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--color-primary-gradient);
    color: var(--color-text-inverse);
}

.btn-primary:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Main Content
   -------------------------------------------------------------------------- */
.main-content {
    flex: 1;
    padding: var(--space-8) 0;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.card-header {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
}

/* --------------------------------------------------------------------------
   Surah Grid
   -------------------------------------------------------------------------- */
.surah-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.surah-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-normal);
    cursor: pointer;
}

.surah-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.surah-number {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-gradient);
    color: var(--color-text-inverse);
    font-weight: 600;
    border-radius: var(--radius-md);
}

.surah-info {
    flex: 1;
}

.surah-name-ar {
    font-family: var(--font-arabic);
    font-size: var(--font-size-lg);
    color: var(--color-text);
}

.surah-name-tr {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.surah-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Ayah Display
   -------------------------------------------------------------------------- */
.ayah-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-4);
}

.ayah-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: var(--radius-full);
    margin-left: var(--space-2);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.main-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--space-12) 0 var(--space-6);
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-8);
    margin-bottom: var(--space-8);
}

.footer-section h4 {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-4);
    color: var(--color-text);
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: var(--space-2);
}

.footer-section a {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.footer-section a:hover {
    color: var(--color-primary);
}

.footer-bottom {
    text-align: center;
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* --------------------------------------------------------------------------
   Score/Rating Display
   -------------------------------------------------------------------------- */
.score-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    background: var(--color-bg-alt);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.score-badge.high {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

.score-badge.medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-text-muted);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mb-8 {
    margin-bottom: var(--space-8);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TECVİD RENKLENDİRMESİ
   ═══════════════════════════════════════════════════════════════════════════ */

/* Med (Uzatma) — Mavi */
.tj-madd {
    color: #1d4ed8;
    font-weight: 600;
}

/* Ğunne (Genizleme) — Yeşil */
.tj-ghunnah {
    color: #15803d;
    font-weight: 600;
}

/* Kalkale (Titreme) — Mor */
.tj-qalqalah {
    color: #7e22ce;
    font-weight: 600;
}

/* Şedde (Vurgu) — Kırmızı */
.tj-shadda {
    color: #b91c1c;
    font-weight: 600;
}

/* Tenvin — Turuncu */
.tj-tanwin {
    color: #b45309;
    font-weight: 600;
}

/* Vasıl Elif'i — Gri */
.tj-wasla {
    color: #6b7280;
}

/* Tecvid legend kutusu */
.tajweed-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.25rem;
    padding: 0.85rem 1.25rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.82rem;
}

.tajweed-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.tajweed-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Tecvid toggle butonu */
.tajweed-toggle {
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    color: #1d4ed8;
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tajweed-toggle:hover,
.tajweed-toggle.active {
    background: #1d4ed8;
    color: white;
    border-color: #1d4ed8;
}

/* ==========================================================================
   HAMBURGER MENU BUTTON
   ========================================================================== */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.menu-toggle:hover {
    background: var(--color-bg-alt);
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: all var(--transition-normal);
    transform-origin: center;
}

.menu-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.menu-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile nav-actions inside menu (hidden on desktop) */
.nav-mobile-actions {
    display: none;
}

/* ==========================================================================
   MOBILE OVERLAY
   ========================================================================== */
.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tablet & Small Desktop  (max-width: 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    :root {
        --container-padding: var(--space-4);
    }

    .nav-menu {
        gap: var(--space-4);
    }

    .surah-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

/* --------------------------------------------------------------------------
   Mobile (max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    :root {
        --container-padding: var(--space-4);
    }

    /* --- Disclaimer banner --- */
    .disclaimer-banner p {
        font-size: var(--font-size-xs);
        padding: 0 var(--space-2);
    }

    /* --- Header / Nav --- */
    .menu-toggle {
        display: flex;
        order: 3;
    }

    .nav-actions {
        display: none; /* hidden on mobile, shown inside slide-out menu */
    }

    .nav-wrapper {
        padding: var(--space-3) 0;
        flex-wrap: nowrap;
        gap: var(--space-3);
    }

    /* Slide-out menu */
    .nav-menu {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: min(300px, 85vw);
        height: 100vh;
        background: var(--color-surface);
        border-left: 1px solid var(--color-border);
        box-shadow: var(--shadow-xl);
        padding: var(--space-16) var(--space-6) var(--space-6);
        gap: var(--space-2);
        z-index: 200;
        transition: right var(--transition-normal);
        overflow-y: auto;
        pointer-events: none;
        visibility: hidden;
    }

    .nav-menu.active {
        right: 0;
        pointer-events: auto;
        visibility: visible;
    }

    .nav-menu li {
        border-bottom: 1px solid var(--color-border-light);
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }

    .nav-menu a {
        display: block;
        padding: var(--space-3) var(--space-2);
        font-size: var(--font-size-base);
        border-radius: 0;
    }

    /* Mobile nav-actions block inside menu */
    .nav-mobile-actions {
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
        padding-top: var(--space-4);
        border-top: 1px solid var(--color-border) !important;
        margin-top: var(--space-2);
    }

    .nav-mobile-actions .language-switcher select {
        width: 100%;
    }

    .nav-mobile-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Overlay */
    .nav-overlay {
        display: block;
    }

    /* --- Typography scaling --- */
    h1 {
        font-size: var(--font-size-3xl);
    }

    h2 {
        font-size: var(--font-size-2xl);
    }

    h3 {
        font-size: var(--font-size-xl);
    }

    /* --- Main content --- */
    .main-content {
        padding: var(--space-6) 0;
    }

    /* --- Cards --- */
    .card {
        padding: var(--space-4);
    }

    /* --- Surah grid --- */
    .surah-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }

    .surah-card {
        padding: var(--space-3);
    }

    /* --- Ayah --- */
    .ayah-text {
        font-size: 1.4rem;
        line-height: 2;
    }

    /* --- Footer --- */
    .main-footer {
        padding: var(--space-8) 0 var(--space-4);
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-6);
    }

    /* --- Tajweed legend --- */
    .tajweed-legend {
        gap: 0.5rem 0.75rem;
        font-size: 0.78rem;
    }
}

/* --------------------------------------------------------------------------
   Small Mobile  (max-width: 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    :root {
        --container-padding: var(--space-3);
    }

    h1 {
        font-size: var(--font-size-2xl);
    }

    h2 {
        font-size: var(--font-size-xl);
    }

    /* --- Footer --- */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--space-5);
    }

    /* --- Ayah --- */
    .ayah-text {
        font-size: 1.25rem;
        line-height: 1.9;
    }

    /* --- Score badge --- */
    .score-badge {
        font-size: var(--font-size-xs);
    }

    /* --- Surah number badge --- */
    .surah-number {
        width: 40px;
        height: 40px;
    }

    /* --- Buttons in tight spaces --- */
    .btn {
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-xs);
    }
}

/* --------------------------------------------------------------------------
   RTL mobile adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    [dir="rtl"] .nav-menu {
        right: auto;
        left: -100%;
        border-left: none;
        border-right: 1px solid var(--color-border);
    }

    [dir="rtl"] .nav-menu.active {
        left: 0;
    }
}
