/* 
   NORA App - Universal Compatibility & UX Polish Layer
   Ensures perfect rendering across Safari, Chrome, Firefox, Edge, and all devices.
   
   Analyzed Modules: 
   - sections.css, dashboard.css, theme.css, step-nav.css, print.css, exit_modal.css
*/

:root {
    --font-sans: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --brand-compat: #00274E;
    --accent-compat: #CBA052;
    --vh-100: 100vh;
    --vh-100: 100dvh;
}

/* 1. Global Reset & Browser Normalization */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-tab-size: 4;
    tab-size: 4;
    scroll-behavior: smooth;
    height: -webkit-fill-available;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-family: var(--font-sans);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    line-height: 1.5;
    background-color: #f3f4f8;
    color: #0F172A;
    overflow-x: hidden;

    /* Numeric alignment for financial data (consistent with print.css) */
    font-variant-numeric: tabular-nums;
}

/* 2. UX Polishes: Selection & Focus */
::selection {
    background-color: rgba(203, 160, 82, 0.3);
    color: #000;
}

:focus-visible {
    outline: 2px solid var(--accent-compat);
    outline-offset: 2px;
}

/* 3. Premium Scrollbars (Universal Support) */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(0, 39, 78, 0.12);
        border-radius: 10px;
        border: 3px solid transparent;
        background-clip: content-box;
    }

    ::-webkit-scrollbar-thumb:hover {
        background-color: rgba(0, 39, 78, 0.25);
    }

    /* Firefox */
    * {
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 39, 78, 0.15) transparent;
    }
}

/* 4. Form & Input Compatibility (iOS Zoom Fix) */
input,
select,
textarea,
button {
    font-family: inherit;
    font-size: 16px;
    /* Prevents iOS auto-zoom */
}

/* Safari specific fix for date inputs height */
input[type="date"] {
    min-height: 2.5rem;
    background-color: #fff;
}

/* Universal Select Arrow Fix (Safari/Firefox consistency) */
select {
    appearance: none !important;
    -webkit-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
    background-position: right 0.75rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.25rem !important;
    padding-right: 2.5rem !important;
}

/* 5. Dialog (Exit Modal) Fixes */
dialog {
    margin: auto;
    /* Center correctly */
}

dialog::backdrop {
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    background: rgba(0, 0, 0, 0.45);
}

/* 6. Layout Stability (Flex/Grid) */
.quiz-layout,
.step-layout,
.dash-layout {
    min-width: 0;
    /* Prevents grid items from overflowing */
}

/* 7. Image Rendering Optimization */
img {
    max-width: 100%;
    height: auto;
    -webkit-user-drag: none;
    user-select: none;
    vertical-align: middle;
}

/* 8. Mobile & Safe Areas (iPhone/Android Notch) */
@media (max-width: 991px) {

    /* Fix for sidebar and main area safe gaps */
    .dash-main,
    .quiz-layout {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    #btnNewStudyMobile {
        bottom: calc(20px + env(safe-area-inset-bottom)) !important;
        right: calc(20px + env(safe-area-inset-right)) !important;
    }
}

/* 9. Typography wrapping */
h1,
h2,
h3,
h4,
.dash-main-title {
    text-wrap: balance;
    overflow-wrap: break-word;
}

/* 10. Print Optimization (Sync with print.css) */
@media print {
    @page {
        size: A4;
        margin: 1cm;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11pt;
    }

    .dash-sidebar,
    #dashMenuToggle,
    .social-header,
    .lang-switcher,
    #btnNewStudyMobile,
    .btn,
    #splash {
        display: none !important;
    }

    .dash-main {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #eee !important;
        page-break-inside: avoid;
    }
}

/* 11. Accessibility Utilities */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}