/* ============================================
   CSS Custom Properties & Theme Variables
   ============================================ */
:root {
    /* Brand Colors */
    --brand: #2563eb;
    --brand-light: #3b82f6;
    --brand-dark: #1d4ed8;
    --brand2: #0891b2;
    --brand2-light: #06b6d4;
    --brand2-dark: #0e7490;

    /* Neutral Colors */
    --ink: #0f172a;
    --ink-light: #1e293b;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --bg: #ffffff;
    --surface: #f8fafc;
    --surface-dark: #f1f5f9;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;

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

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(2, 6, 23, .04);
    --shadow: 0 1px 2px rgba(2, 6, 23, .06), 0 10px 30px rgba(2, 6, 23, .06);
    --shadow-lg: 0 8px 30px rgba(2, 6, 23, .10);
    --shadow-xl: 0 20px 40px rgba(2, 6, 23, .15);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

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

    /* Typography */
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Courier New', monospace;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Z-index layers */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

html {
    scroll-behavior: smooth
}

body {
    background: radial-gradient(1200px circle at 16% -10%, rgba(37, 99, 235, .14), transparent 55%), radial-gradient(900px circle at 92% 8%, rgba(6, 182, 212, .12), transparent 52%), linear-gradient(180deg, #f8fafc 0%, #ffffff 55%, #f8fafc 100%);
    color: #1e293b;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif
}

.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .6s ease, transform .6s ease
}

.reveal.show {
    opacity: 1;
    transform: none
}

.hero-gradient {
    background: radial-gradient(900px circle at 15% 15%, rgba(37, 99, 235, .18), transparent 55%), radial-gradient(700px circle at 85% 10%, rgba(6, 182, 212, .16), transparent 52%), linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 35%, #f8fafc 100%)
}

.glass {
    background: rgba(255, 255, 255, .78);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(226, 232, 240, .9);
    box-shadow: var(--shadow)
}

.card {
    transition: transform .22s ease, box-shadow .22s ease, background .22s ease;
    border-radius: 1rem;
    border: 1px solid transparent;
    background: linear-gradient(#ffffff, #ffffff) padding-box, linear-gradient(135deg, rgba(37, 99, 235, .35), rgba(6, 182, 212, .22), rgba(148, 163, 184, .22)) border-box;
    box-shadow: 0 1px 2px rgba(2, 6, 23, .04)
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg)
}

.btn {
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, .2)
}

.nav-blur {
    background: rgba(255, 255, 255, .84);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, .8);
    transition: all .3s ease
}

.nav-blur.scrolled {
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 10px 40px -18px rgba(2, 6, 23, .25)
}

.nav-link.router-link-active {
    color: #2563eb !important;
    background: linear-gradient(180deg, #eff6ff, #ffffff) !important;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .12)
}

.logo-text {
    font-weight: 700;
    background: linear-gradient(135deg, #2563eb, #0891b2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent
}

.badge {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 500
}

.footer {
    border-top: 1px solid var(--border);
    background: #f8fafc
}

input,
textarea {
    outline: none;
    transition: border-color .2s
}

input:focus,
textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .1)
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
    color: #fff;
    border-radius: .85rem;
    padding: .7rem 1.05rem;
    font-weight: 700;
    letter-spacing: -.01em;
    box-shadow: 0 8px 22px rgba(37, 99, 235, .18);
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(37, 99, 235, .22);
    filter: saturate(1.05)
}

.btn-primary:active {
    transform: translateY(0)
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background: rgba(255, 255, 255, .75);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(226, 232, 240, .9);
    color: #0f172a;
    border-radius: .85rem;
    padding: .7rem 1.05rem;
    font-weight: 650;
    letter-spacing: -.01em;
    box-shadow: 0 1px 2px rgba(2, 6, 23, .06);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease
}

.btn-secondary:hover {
    transform: translateY(-1px);
    background: #ffffff;
    box-shadow: 0 10px 26px rgba(2, 6, 23, .08)
}

.btn-secondary:active {
    transform: translateY(0)
}

/* Enhanced image styling */
img {
    max-width: 100%;
    height: auto
}

.hero-image {
    transition: transform .3s ease, box-shadow .3s ease
}

.hero-image:hover {
    transform: scale(1.02);
    box-shadow: 0 20px 40px rgba(2, 6, 23, .12)
}

/* Improved testimonial cards */
.glass:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(2, 6, 23, .09)
}

/* Smooth transitions for all interactive elements */
a,
button {
    transition: all .2s ease
}

/* Gradient text support */
.bg-gradient-to-r {
    background-image: linear-gradient(to right, var(--tw-gradient-stops))
}

.from-blue-600 {
    --tw-gradient-from: #2563eb;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(37, 99, 235, 0))
}

.to-cyan-600 {
    --tw-gradient-to: #0891b2
}

.bg-clip-text {
    -webkit-background-clip: text;
    background-clip: text
}

.text-transparent {
    color: transparent
}

/* Enhanced hero section */
.hero-gradient {
    position: relative
}

/* ============================================
   Responsive Utilities
   ============================================ */
.container {
    width: 100%;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Visibility 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;
}

.hidden {
    display: none;
}

@media (max-width: 767px) {
    .hidden-mobile {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .hidden-desktop {
        display: none !important;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {

    *,
    *::before,
    *::after {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a,
    a:visited {
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
    }

    abbr[title]::after {
        content: " (" attr(title) ")";
    }

    a[href^="#"]::after,
    a[href^="javascript:"]::after {
        content: "";
    }

    pre,
    blockquote {
        border: 1px solid #999;
        page-break-inside: avoid;
    }

    thead {
        display: table-header-group;
    }

    tr,
    img {
        page-break-inside: avoid;
    }

    img {
        max-width: 100% !important;
    }

    p,
    h2,
    h3 {
        orphans: 3;
        widows: 3;
    }

    h2,
    h3 {
        page-break-after: avoid;
    }

    /* Hide non-essential elements when printing */
    header,
    footer,
    nav,
    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }
}

/* ============================================
   Accessibility Enhancements
   ============================================ */
/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--brand);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 9999;
}

.skip-to-main:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #000;
        --muted: #333;
    }

    .glass {
        background: rgba(255, 255, 255, 0.95);
        border: 2px solid #000;
    }
}

/* ============================================
   Mobile Responsiveness Enhancements
   ============================================ */

/* Responsive Typography */
html {
    font-size: 16px;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

/* Minimum Touch Target Sizes (44x44px) */
button,
a,
input[type="button"],
input[type="submit"],
.btn,
.btn-primary,
.btn-secondary {
    min-height: 44px;
    min-width: 44px;
}

/* Mobile Navigation Improvements */
@media (max-width: 768px) {
    .nav-blur {
        padding: 0.5rem 0;
    }

    /* Ensure mobile menu items are easily tappable */
    .nav-link {
        padding: 1rem !important;
        font-size: 1rem;
    }
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Hero Section Mobile Optimization */
@media (max-width: 1024px) {
    .hero-gradient {
        min-height: auto;
        padding: 4rem 0;
    }
}

/* Card Layout Mobile Optimization */
@media (max-width: 640px) {
    .card {
        padding: 1.25rem;
    }

    .glass {
        padding: 1rem;
    }
}

/* Button Responsive Sizing */
@media (max-width: 640px) {

    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 0.875rem 1.25rem;
        font-size: 1rem;
    }
}

/* Responsive Spacing */
@media (max-width: 768px) {
    .mx-auto {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Form Elements Mobile Optimization */
@media (max-width: 640px) {

    input,
    textarea,
    select {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
}

/* Footer Mobile Layout */
@media (max-width: 768px) {
    .footer {
        text-align: center;
    }
}

/* Exam Interface Mobile Optimization */
@media (max-width: 1024px) {

    /* Make exam interface stack vertically on tablets/mobile */
    .exam-layout {
        flex-direction: column;
    }

    /* Ensure question palette is accessible on mobile */
    .question-palette {
        width: 100%;
        max-height: 300px;
        overflow-y: auto;
    }
}

/* Responsive Text Sizing with Clamp */
h1 {
    font-size: clamp(1.75rem, 5vw, 3.5rem);
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

h3 {
    font-size: clamp(1.25rem, 3vw, 1.875rem);
}

p {
    font-size: clamp(0.875rem, 2vw, 1rem);
}

/* Mobile-Specific Utilities */
@media (max-width: 640px) {
    .mobile-full-width {
        width: 100% !important;
    }

    .mobile-text-center {
        text-align: center !important;
    }

    .mobile-hidden {
        display: none !important;
    }
}

/* Improve tap highlight */
* {
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
}

/* Smooth scrolling for mobile */
@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
}

/* Prevent horizontal scroll on mobile */
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ============================================
   Exam Interface Mobile Optimization
   ============================================ */

/* Exam Header Mobile */
@media (max-width: 768px) {

    /* Make exam header stack vertically on mobile */
    .exam-header {
        flex-direction: column !important;
        gap: 0.75rem !important;
        padding: 0.75rem !important;
    }

    .exam-header>div {
        width: 100% !important;
    }

    /* Reduce logo size on mobile */
    .exam-header img {
        width: 2rem !important;
        height: 2rem !important;
    }

    .exam-header h1 {
        font-size: 1rem !important;
    }

    .exam-header p,
    .exam-header .text-sm {
        font-size: 0.75rem !important;
    }

    /* Timer and submit button row */
    .exam-header-actions {
        display: flex;
        justify-content: space-between;
        width: 100%;
        gap: 0.5rem;
    }
}

/* Exam Main Content Mobile */
@media (max-width: 1024px) {

    /* Stack exam content vertically on tablets/mobile */
    .exam-content-wrapper {
        flex-direction: column !important;
        height: auto !important;
    }

    /* Question area takes full width */
    .exam-question-area {
        width: 100% !important;
        max-height: none !important;
        padding: 1rem !important;
    }

    /* Question palette becomes bottom sheet on mobile */
    .exam-palette {
        width: 100% !important;
        max-height: 40vh !important;
        border-left: none !important;
        border-top: 2px solid #e5e7eb !important;
        position: sticky !important;
        bottom: 0 !important;
        background: white !important;
        z-index: 10 !important;
    }
}

/* Mobile Question Navigation Buttons */
@media (max-width: 640px) {

    /* Make navigation buttons stack on very small screens */
    .exam-nav-buttons {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .exam-nav-buttons button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Action buttons in a column */
    .exam-action-buttons {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .exam-action-buttons button {
        width: 100% !important;
        padding: 0.75rem !important;
        font-size: 0.875rem !important;
    }

    /* Reduce button text on mobile */
    .exam-action-buttons button span {
        display: inline !important;
    }
}

/* Mobile Question Palette Grid */
@media (max-width: 640px) {

    /* Smaller palette buttons on mobile */
    .palette-button {
        width: 2.5rem !important;
        height: 2.5rem !important;
        font-size: 0.875rem !important;
    }

    /* Reduce palette grid columns on mobile */
    .palette-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 0.5rem !important;
    }
}

/* Mobile Question Display */
@media (max-width: 768px) {

    /* Better question text sizing */
    .question-text {
        font-size: 1rem !important;
        line-height: 1.5 !important;
    }

    /* Options with better touch targets */
    .option-item {
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    .option-radio {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }
}

/* Mobile Progress Bar */
@media (max-width: 640px) {
    .progress-info {
        flex-direction: column !important;
        gap: 0.25rem !important;
        font-size: 0.75rem !important;
    }
}

/* Mobile Timer Display */
@media (max-width: 640px) {
    .timer-display {
        padding: 0.5rem 0.75rem !important;
    }

    .timer-display p {
        font-size: 0.875rem !important;
    }
}

/* Mobile Welcome/Instructions Screens */
@media (max-width: 640px) {

    .welcome-screen,
    .instructions-screen {
        padding: 1rem !important;
    }

    .welcome-screen h1,
    .instructions-screen h2 {
        font-size: 1.5rem !important;
    }

    .welcome-screen p,
    .instructions-screen p {
        font-size: 0.875rem !important;
    }
}

/* Mobile Results Screen */
@media (max-width: 640px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    .result-card {
        padding: 0.75rem !important;
    }

    .result-score {
        font-size: 1.5rem !important;
    }
}

/* Mobile-friendly hover states (use active instead) */
@media (hover: none) and (pointer: coarse) {
    .card:hover {
        transform: none;
    }

    .card:active {
        transform: translateY(-3px);
        box-shadow: var(--shadow-lg);
    }

    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none;
    }

    .btn-primary:active {
        transform: translateY(-1px);
    }
}