/* ==========================================================================
   Mercury Mobility — Shared Stylesheet
   Version: 2.0.0
   ========================================================================== */

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

:root {
    --primary-dark: #072D44;
    --primary-medium: #09436B;
    --accent-blue: #5891AC;
    --light-blue: #9ECFDD;
    --off-white: #F6F6F6;

    /* Light theme (default) */
    --bg-primary: #fff;
    --bg-secondary: var(--off-white);
    --bg-tertiary: var(--primary-dark);
    --text-primary: #1a1a1a;
    --text-secondary: #555;
    --text-tertiary: #fff;
    --border-color: #e0e0e0;
    --header-bg: #fff;
    --card-bg: #fff;
    --card-shadow: rgba(0, 0, 0, 0.06);
    --focus-ring: rgba(88, 145, 172, 0.5);
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

html.dark {
    color-scheme: dark;

    --bg-primary: #0a0e27;
    --bg-secondary: #141829;
    --bg-tertiary: #1a2332;
    --text-primary: #f0f0f0;
    /* Adjusted from #aaa/#a0a0a0 → #c0c0c0 for WCAG AA (≥4.5:1 on both bg) */
    --text-secondary: #c0c0c0;
    --text-tertiary: #f0f0f0;
    --border-color: #2a3a4a;
    --header-bg: #0f1420;
    --card-bg: #141829;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --focus-ring: rgba(158, 207, 221, 0.6);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   2. Focus & Accessibility
   -------------------------------------------------------------------------- */
.skip-nav {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 10000;
    padding: 0.75rem 1.5rem;
    background: var(--accent-blue);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 0 0 6px 6px;
    transition: top 0.2s ease;
}

.skip-nav:focus {
    top: 0;
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Global focus-visible styles for keyboard navigation */
:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --------------------------------------------------------------------------
   3. Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --------------------------------------------------------------------------
   4. Header
   -------------------------------------------------------------------------- */
header {
    background: var(--header-bg);
    padding: 0.5rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 36px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.15rem;
    white-space: nowrap;
    transition: color 0.3s ease;
    flex-shrink: 0;
}

.logo:hover {
    color: var(--accent-blue);
    text-decoration: none;
}

.logo img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

/* Logo light/dark swap */
.logo-light { display: inline-block; }
.logo-dark { display: none; }
html.dark .logo-light { display: none; }
html.dark .logo-dark { display: inline-block; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

nav[aria-label] {
    display: flex;
    align-items: center;
}

nav[aria-label] ul {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    align-items: center;
    margin: 0;
}

nav[aria-label] a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: color 0.2s ease;
    padding: 0.2rem 0;
    white-space: nowrap;
}

nav[aria-label] a:hover {
    color: var(--accent-blue);
    text-decoration: none;
}

nav[aria-label] a[aria-current="page"] {
    color: var(--accent-blue);
    border-bottom: 2px solid var(--accent-blue);
}

#nav-menu {
    margin-top: 0.25rem;
}

.nav-cta {
    font-weight: 600;
    font-size: 0.88rem;
}

/* Hamburger */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    width: 20px;
    height: 16px;
    gap: 4px;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    flex-shrink: 0;
}

.hamburger span {
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.3s ease;
    display: block;
}

.hamburger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.hamburger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* --------------------------------------------------------------------------
   5. Theme Toggle (unified across all pages)
   -------------------------------------------------------------------------- */
.theme-toggle {
    width: 48px;
    height: 26px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 13px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.theme-toggle::before {
    content: '';
    width: 20px;
    height: 20px;
    background: var(--accent-blue);
    border-radius: 50%;
    position: absolute;
    left: 2px;
    transition: left 0.3s ease;
}

html.dark .theme-toggle::before {
    left: 22px;
}

.theme-toggle .toggle-icon {
    position: absolute;
    width: 12px;
    height: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #fff;
    transition: opacity 0.3s ease;
}

.theme-toggle .toggle-icon--sun {
    left: 6px;
    opacity: 1;
}

.theme-toggle .toggle-icon--moon {
    right: 6px;
    opacity: 0;
}

html.dark .theme-toggle .toggle-icon--sun {
    opacity: 0;
}

html.dark .theme-toggle .toggle-icon--moon {
    opacity: 1;
}

/* --------------------------------------------------------------------------
   6. Breadcrumbs
   -------------------------------------------------------------------------- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.breadcrumbs a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs .separator {
    color: var(--text-secondary);
    user-select: none;
}

.breadcrumbs .current {
    color: var(--text-primary);
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   7. Main Content Area
   -------------------------------------------------------------------------- */
main {
    max-width: 950px;
    margin: 70px auto 60px;
    padding: 0 1.5rem;
}

.page-header {
    margin-bottom: 2.5rem;
}

.page-title {
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.7rem;
    line-height: 1.2;
}

.page-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   8. Typography
   -------------------------------------------------------------------------- */
h2 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 2.5rem 0 1.25rem;
    scroll-margin-top: 100px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    line-height: 1.3;
}

h3 {
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.75rem 0 0.9rem;
}

p {
    margin-bottom: 1.1rem;
    color: var(--text-secondary);
}

ul,
ol {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

li {
    margin-bottom: 0.7rem;
    color: var(--text-secondary);
}

strong {
    color: var(--text-primary);
    font-weight: 600;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-medium);
    text-decoration: underline;
}

section {
    margin-bottom: 3rem;
}

/* --------------------------------------------------------------------------
   9. Section Icons (used in legal pages, FAQ sections)
   -------------------------------------------------------------------------- */
.section-icon {
    width: 28px;
    height: 28px;
    color: var(--accent-blue);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   10. Highlight & Warning Boxes
   -------------------------------------------------------------------------- */
.highlight-box {
    background: linear-gradient(135deg, rgba(88, 145, 172, 0.08), rgba(158, 207, 221, 0.04));
    border-left: 5px solid var(--accent-blue);
    padding: 1.75rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.warning-box {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.08), rgba(220, 53, 69, 0.04));
    border-left: 5px solid #dc3545;
    padding: 1.75rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.highlight-box p,
.warning-box p {
    margin: 0;
}

.highlight-box p + p,
.warning-box p + p {
    margin-top: 0.5rem;
}

/* --------------------------------------------------------------------------
   11. Table of Contents (Privacy Policy, Terms)
   -------------------------------------------------------------------------- */
.toc {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2.5rem;
    border-left: 5px solid var(--accent-blue);
}

.toc-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.toc-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-blue);
    flex-shrink: 0;
}

.toc h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0;
    display: block;
}

.toc ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.3rem;
    margin: 0;
}

.toc li {
    margin: 0;
}

.toc a {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 0.93rem;
    padding: 0.5rem 0;
    display: block;
    transition: all 0.2s ease;
}

.toc a:hover {
    color: var(--primary-medium);
    transform: translateX(4px);
    text-decoration: none;
}

/* --------------------------------------------------------------------------
   12. Footer
   -------------------------------------------------------------------------- */
footer {
    background: var(--primary-dark);
    color: #fff;
    padding: 3.5rem 1.5rem 2rem;
    margin-top: 4rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1.5fr;
    gap: 2.5rem;
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-section h4 {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--light-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.footer-section ul li {
    margin-bottom: 0.6rem;
    color: rgba(255, 255, 255, 0.75);
}

.footer-section a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: color 0.2s ease;
    font-size: 0.9rem;
    font-weight: 400;
}

.footer-section a:hover {
    color: var(--light-blue);
    text-decoration: none;
}

.footer-section p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-bottom {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

.footer-bottom p {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   13. Responsive: Tablet (769px – 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .header-container {
        padding: 0 1.25rem;
    }

    .nav-right {
        gap: 1.5rem;
    }

    nav[aria-label] ul {
        gap: 1.25rem;
    }

    .footer-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

/* --------------------------------------------------------------------------
   14. Responsive: Mobile nav breakpoint (≤768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    body {
        font-size: 0.9375rem; /* 15px */
    }

    main {
        margin: 62px auto 40px;
        padding: 0 1rem;
    }

    .header-container {
        padding: 0 1rem;
    }

    .logo {
        font-size: 1.05rem;
        gap: 0.4rem;
    }

    .logo img {
        width: 26px;
        height: 26px;
    }

    .hamburger {
        display: flex;
    }

    nav[aria-label] ul {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        background: var(--header-bg);
        padding: 0.25rem 0;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
        z-index: 999;
    }

    nav[aria-label] ul.active {
        display: flex;
    }

    nav[aria-label] ul li {
        border-bottom: 1px solid var(--border-color);
    }

    nav[aria-label] ul li:last-child {
        border-bottom: none;
    }

    nav[aria-label] a {
        display: block;
        padding: 0.6rem 1.25rem;
        font-size: 0.9rem;
    }

    .nav-cta {
        margin: 0.35rem 1rem;
        text-align: center;
        padding: 0.6rem 1.25rem;
        font-size: 0.9rem;
    }

    .page-title {
        font-size: clamp(1.6rem, 5vw, 2.2rem);
        margin-bottom: 0.5rem;
    }

    h2 {
        margin: 2rem 0 1rem;
    }

    h3 {
        margin: 1.5rem 0 0.75rem;
    }

    .toc {
        padding: 1.5rem;
        margin-bottom: 2rem;
    }

    .toc ul {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }

    .toc a {
        font-size: 0.9rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .breadcrumbs {
        margin-bottom: 1rem;
        font-size: 0.85rem;
    }
}

/* --------------------------------------------------------------------------
   15. Responsive: Small mobile (≤480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }

    body {
        font-size: 0.875rem; /* 14px */
    }

    main {
        margin: 56px auto 30px;
        padding: 0 0.75rem;
    }

    .header-container {
        padding: 0 0.75rem;
        gap: 0.75rem;
    }

    .logo {
        font-size: 0.95rem;
        min-width: 0;
    }

    .logo img {
        width: 24px;
        height: 24px;
    }

    .theme-toggle {
        width: 42px;
        height: 22px;
        border-radius: 11px;
    }

    .theme-toggle::before {
        width: 16px;
        height: 16px;
        left: 2px;
    }

    html.dark .theme-toggle::before {
        left: 20px;
    }

    .theme-toggle .toggle-icon {
        width: 10px;
        height: 10px;
    }

    .theme-toggle .toggle-icon--sun {
        left: 5px;
    }

    .theme-toggle .toggle-icon--moon {
        right: 5px;
    }

    .page-header {
        margin-bottom: 1.75rem;
    }

    .page-title {
        font-size: clamp(1.4rem, 5vw, 1.8rem);
        margin-bottom: 0.4rem;
    }

    .page-meta {
        font-size: 0.85rem;
    }

    h2 {
        gap: 0.6rem;
        margin: 1.75rem 0 0.85rem;
    }

    .section-icon {
        width: 24px;
        height: 24px;
    }

    h3 {
        font-size: 1.05rem;
        margin: 1.25rem 0 0.65rem;
    }

    p {
        margin-bottom: 0.9rem;
    }

    ul,
    ol {
        margin-left: 1.25rem;
        margin-bottom: 1.25rem;
    }

    li {
        margin-bottom: 0.6rem;
    }

    .toc {
        padding: 1.25rem;
        margin-bottom: 1.75rem;
    }

    .toc-header {
        margin-bottom: 1rem;
    }

    .toc h2 {
        font-size: 1.05rem;
    }

    .toc a {
        font-size: 0.85rem;
        padding: 0.4rem 0;
    }

    .highlight-box,
    .warning-box {
        padding: 1.25rem;
        margin: 1.5rem 0;
    }

    .breadcrumbs {
        margin-bottom: 0.75rem;
        font-size: 0.8rem;
    }

    section {
        margin-bottom: 2.5rem;
    }

    footer {
        padding: 2rem 0.75rem 1.5rem;
    }

    .footer-section h4 {
        font-size: 0.85rem;
    }

    .footer-section a,
    .footer-section p {
        font-size: 0.85rem;
    }

    .footer-bottom {
        font-size: 0.8rem;
    }
}

/* --------------------------------------------------------------------------
   16. Ultra-wide (1441px+)
   -------------------------------------------------------------------------- */
@media (min-width: 1441px) {
    .header-container,
    .footer-container {
        max-width: 1320px;
    }

    main {
        max-width: 1020px;
    }
}

/* --------------------------------------------------------------------------
   17. Print Styles
   -------------------------------------------------------------------------- */
@media print {
    header,
    footer,
    .skip-nav,
    .breadcrumbs,
    .theme-toggle,
    .hamburger,
    .back-to-home,
    .btn-primary,
    .btn-secondary,
    .btn-cta,
    .nav-cta {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt;
        line-height: 1.5;
    }

    main {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    h1, h2, h3 {
        color: #000 !important;
        page-break-after: avoid;
    }

    p, li {
        color: #333 !important;
    }

    a {
        color: #000 !important;
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #555;
    }

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

    .highlight-box,
    .warning-box {
        border-left-width: 3px;
        padding: 1rem;
    }

    .toc {
        page-break-inside: avoid;
    }

    section {
        page-break-inside: avoid;
    }
}

/* --------------------------------------------------------------------------
   18. Touch Devices
   -------------------------------------------------------------------------- */
@media (hover: none) {
    .theme-toggle,
    .hamburger,
    .nav-cta,
    a {
        min-height: 44px;
        min-width: 44px;
    }
}

/* --------------------------------------------------------------------------
   19. iOS Input Zoom Prevention
   -------------------------------------------------------------------------- */
@supports (-webkit-touch-callout: none) {
    input,
    textarea,
    select {
        font-size: 16px;
    }
}
