/* ============================================
   iOS Design System - ask-quran Legal Site
   ============================================ */

:root {
    /* ===== Color System ===== */
    /* System Backgrounds */
    --bg-color: #f2f2f7;
    --secondary-bg: #ffffff;
    --card-bg: #ffffff;

    /* Text Colors */
    --text-primary: #000000;
    --text-secondary: #3c3c43;
    --text-tertiary: #3c3c4399;  /* 60% opacity */

    /* Accent & System Colors */
    --accent-color: #007aff;
    --system-red: #ff3b30;
    --system-orange: #ff9500;
    --system-yellow: #ffcc00;
    --system-green: #34c759;
    --system-teal: #5ac8fa;
    --system-indigo: #5856d6;

    /* Fill Colors (for backgrounds) */
    --fill-primary: rgba(120, 120, 128, 0.2);
    --fill-secondary: rgba(120, 120, 128, 0.16);
    --fill-tertiary: rgba(118, 118, 128, 0.12);
    --fill-quaternary: rgba(116, 116, 128, 0.08);

    /* Borders & Separators */
    --border-color: #c6c6c8;
    --separator-color: #3c3c434d;

    /* ===== Typography Scale ===== */
    --font-size-xs: 11px;    /* Caption 2 */
    --font-size-sm: 13px;    /* Footnote */
    --font-size-md: 15px;    /* Subhead */
    --font-size-lg: 17px;    /* Body (iOS standard) */
    --font-size-xl: 20px;    /* Headline */
    --font-size-2xl: 22px;   /* Title 3 */
    --font-size-3xl: 28px;   /* Title 2 */
    --font-size-4xl: 34px;   /* Title 1 */
    --font-size-5xl: 40px;   /* Large Title */

    /* Line Heights */
    --line-height-tight: 1.2;
    --line-height-normal: 1.35;
    --line-height-relaxed: 1.47;  /* iOS body standard */
    --line-height-loose: 1.5;

    /* Font Weights */
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Letter Spacing */
    --letter-spacing-tight: -0.43px;
    --letter-spacing-normal: -0.24px;
    --letter-spacing-wide: 0.07px;

    /* ===== Spacing Scale (8pt Grid) ===== */
    --spacing-1: 4px;
    --spacing-2: 8px;
    --spacing-3: 12px;
    --spacing-4: 16px;
    --spacing-5: 20px;
    --spacing-6: 24px;
    --spacing-7: 32px;
    --spacing-8: 40px;
    --spacing-9: 48px;
    --spacing-10: 64px;
    --spacing-11: 80px;

    /* ===== Shadow Tokens ===== */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.08);

    /* ===== Border Radius ===== */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* ===== Animation Timing ===== */
    --duration-fast: 0.15s;
    --duration-base: 0.2s;
    --duration-slow: 0.3s;
    --duration-spring: 0.5s;

    /* iOS Easing Functions */
    --ease-ios: cubic-bezier(0.4, 0.0, 0.2, 1);
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);

    /* Font Family */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-family-mono: ui-monospace, "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Dark Mode Colors */
        --bg-color: #000000;
        --secondary-bg: #1c1c1e;
        --card-bg: #1c1c1e;

        --text-primary: #ffffff;
        --text-secondary: #ebebf599;  /* 60% opacity */
        --text-tertiary: #ebebf54d;   /* 30% opacity */

        --accent-color: #0a84ff;
        --system-red: #ff453a;
        --system-orange: #ff9f0a;
        --system-yellow: #ffd60a;
        --system-green: #32d74b;
        --system-teal: #64d2ff;
        --system-indigo: #5e5ce6;

        --fill-primary: rgba(120, 120, 128, 0.36);
        --fill-secondary: rgba(120, 120, 128, 0.32);
        --fill-tertiary: rgba(118, 118, 128, 0.24);
        --fill-quaternary: rgba(118, 118, 128, 0.18);

        --border-color: #38383a;
        --separator-color: #54545899;

        /* Dark Mode Shadows */
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.24);
        --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.5);
    }
}

/* ===== Base Resets ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== Body & Typography ===== */
body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-lg);  /* 17px - iOS standard */
    line-height: var(--line-height-relaxed);  /* 1.47 */
    letter-spacing: var(--letter-spacing-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

/* Selection Highlighting */
::selection {
    background-color: var(--accent-color);
    color: #ffffff;
}

::-moz-selection {
    background-color: var(--accent-color);
    color: #ffffff;
}

/* ===== Container ===== */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--spacing-7) var(--spacing-4);  /* 32px vertical, 16px horizontal */
}

/* ===== Header (Glassmorphic Sticky) ===== */
header {
    position: sticky;
    top: 0;
    z-index: 10;
    margin-left: calc(-1 * var(--spacing-4));
    margin-right: calc(-1 * var(--spacing-4));
    padding: var(--spacing-4) var(--spacing-4) var(--spacing-5);  /* 16px sides, 20px bottom */
    margin-bottom: var(--spacing-7);  /* 32px */
    background: rgba(242, 242, 247, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid var(--separator-color);
}

@media (prefers-color-scheme: dark) {
    header {
        background: rgba(28, 28, 30, 0.8);
    }
}

/* Fallback for browsers without backdrop-filter */
@supports not (backdrop-filter: blur(20px)) {
    header {
        background: var(--bg-color);
    }
}

/* ===== Typography Hierarchy ===== */
h1 {
    font-size: var(--font-size-4xl);  /* 34px */
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    margin-bottom: var(--spacing-1);  /* 4px */
}

.subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-md);  /* 15px */
    font-weight: var(--font-weight-regular);
}

/* ===== Content Cards ===== */
.content-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);  /* 12px */
    overflow: hidden;
    margin-bottom: var(--spacing-7);  /* 32px */
    box-shadow: var(--shadow-md);
    border: 0.5px solid var(--separator-color);
    transition: transform var(--duration-base) var(--ease-ios),
                box-shadow var(--duration-base) var(--ease-ios);
}

/* Light mode inner highlight */
@media (prefers-color-scheme: light) {
    .content-card {
        box-shadow: var(--shadow-md),
                    inset 0 1px 0 rgba(255, 255, 255, 0.5);
    }
}

/* Hover effect (desktop only) */
@media (hover: hover) {
    .content-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }
}

/* ===== Navigation Links ===== */
.nav-links {
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-4) var(--spacing-5);  /* 16px vertical, 20px horizontal */
    min-height: 44px;  /* iOS minimum touch target */
    text-decoration: none;
    color: var(--text-primary);
    position: relative;
    background-color: transparent;
    transition: background-color var(--duration-fast) var(--ease-ios),
                transform var(--duration-fast) var(--ease-ios),
                opacity var(--duration-fast) var(--ease-ios);
}

.nav-item:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: calc(3rem);  /* Aligned with text */
    right: 0;
    height: 0.5px;
    background-color: var(--separator-color);
}

/* Hover state (desktop only) */
@media (hover: hover) {
    .nav-item:hover {
        background-color: var(--fill-tertiary);
    }
}

/* Active (tap) state */
.nav-item:active {
    transform: scale(0.98);
    background-color: var(--fill-primary);
}

/* Focus state for keyboard navigation */
.nav-item:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

.nav-item .icon {
    font-size: 1.5rem;
    margin-right: var(--spacing-3);  /* 12px */
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.nav-item h3 {
    font-size: var(--font-size-lg);  /* 17px */
    font-weight: var(--font-weight-regular);
}

.nav-item p {
    display: none;
}

/* ===== Legal Content Styles ===== */
.legal-content {
    padding: var(--spacing-5);  /* 20px */
}

.legal-content h1 {
    font-size: var(--font-size-3xl);  /* 28px */
    margin-bottom: var(--spacing-6);  /* 24px */
}

.legal-content h2 {
    font-size: var(--font-size-2xl);  /* 22px */
    font-weight: var(--font-weight-semibold);
    margin-top: var(--spacing-8);  /* 40px */
    margin-bottom: var(--spacing-4);  /* 16px */
}

.legal-content h3 {
    font-size: var(--font-size-xl);  /* 20px */
    font-weight: var(--font-weight-semibold);
    margin-top: var(--spacing-6);  /* 24px */
    margin-bottom: var(--spacing-3);  /* 12px */
}

.legal-content p,
.legal-content li {
    font-size: var(--font-size-lg);  /* 17px */
    line-height: var(--line-height-relaxed);
    margin-bottom: var(--spacing-4);  /* 16px */
    color: var(--text-primary);
}

/* Custom List Styling */
.legal-content ul {
    list-style: none;
    margin-left: var(--spacing-6);  /* 24px */
    margin-bottom: var(--spacing-6);  /* 24px */
}

.legal-content ul li {
    position: relative;
    padding-left: var(--spacing-6);  /* 24px */
}

.legal-content ul li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--text-tertiary);
    font-weight: var(--font-weight-bold);
}

/* ===== Back Link (with Chevron) ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-2);  /* 8px */
    color: var(--accent-color);
    text-decoration: none;
    font-size: var(--font-size-lg);  /* 17px */
    margin-bottom: var(--spacing-4);  /* 16px */
    padding: var(--spacing-2);  /* 8px */
    margin-left: calc(-1 * var(--spacing-2));  /* -8px to align with content */
    border-radius: var(--radius-sm);  /* 8px */
    transition: background-color var(--duration-fast) var(--ease-ios),
                transform var(--duration-fast) var(--ease-ios),
                opacity var(--duration-fast) var(--ease-ios);
}

.back-link::before {
    content: "‹";  /* Chevron left */
    font-size: 1.5em;
    font-weight: var(--font-weight-semibold);
    line-height: 1;
}

/* Hover state (desktop only) */
@media (hover: hover) {
    .back-link:hover {
        background-color: var(--fill-tertiary);
    }
}

/* Active state */
.back-link:active {
    transform: scale(0.96);
    opacity: 0.5;
}

/* Focus state */
.back-link:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ===== Email Links ===== */
a[href^="mailto:"] {
    color: var(--accent-color);
    text-decoration: none;
    background-color: var(--fill-secondary);
    padding: var(--spacing-2);  /* 8px */
    border-radius: var(--radius-sm);  /* 8px */
    display: inline-block;
    transition: background-color var(--duration-base) var(--ease-ios);
}

a[href^="mailto:"]:hover {
    background-color: var(--fill-primary);
}

a[href^="mailto:"]:active {
    background-color: var(--fill-primary);
}

/* ===== Regular Links ===== */
a {
    color: var(--accent-color);
    transition: opacity var(--duration-base) var(--ease-ios);
}

@media (hover: hover) {
    a:hover {
        opacity: 0.8;
    }
}

/* ===== Code/Monospace Elements ===== */
code,
pre {
    font-family: var(--font-family-mono);
    font-size: 0.9em;
    background-color: var(--fill-secondary);
    color: var(--accent-color);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-sm);
}

pre {
    padding: var(--spacing-4);
    overflow-x: auto;
    line-height: var(--line-height-normal);
}

pre code {
    background: none;
    padding: 0;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: var(--spacing-7) 0;  /* 32px vertical */
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);  /* 13px */
}

/* ===== Content Groups (Optional Utility) ===== */
.content-group {
    margin-bottom: var(--spacing-7);  /* 32px */
}

.content-group:last-child {
    margin-bottom: 0;
}

/* ===== Responsive Adjustments ===== */

/* Mobile optimizations */
@media (max-width: 600px) {
    h1 {
        font-size: var(--font-size-3xl);  /* 28px on mobile */
    }

    .legal-content h1 {
        font-size: var(--font-size-2xl);  /* 22px on mobile */
    }

    .nav-item {
        padding: var(--spacing-5) var(--spacing-5);  /* 20px all around */
        min-height: 44px;  /* Ensure iOS touch target */
    }
}

/* Desktop enhancements */
@media (min-width: 601px) {
    .container {
        padding: var(--spacing-9) var(--spacing-6);  /* 48px vertical, 24px horizontal */
    }

    .content-card {
        border-radius: var(--radius-lg);  /* 16px on desktop */
    }
}
