/* Shared by every page with the site header and footer (every full page but 404 and 500):
   the base styles, header, buttons, footer and the Your Privacy Choices dialog. Loaded after
   brand.css (the tokens) and before the page's own <style>, which holds only what that page
   alone uses. */

/* ==========================================================================
   Design Tokens - Spacing, Typography, Colors
   ========================================================================== */
:root {
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
}

/* Dark Theme (Default) */
[data-theme="dark"] {
    --border-color: rgba(255, 255, 255, 0.1);
}

/* Light Theme */
[data-theme="light"] {
    --border-color: rgba(15, 23, 42, 0.1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Accessibility: Focus styles */
:focus-visible {
    outline: 2px solid var(--brand-blue);
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

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

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* Screen reader only utility */
.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;
}

/* Skip link: visually hidden until it receives keyboard focus */
a.sr-only:focus-visible {
    position: fixed;
    top: var(--space-4);
    left: var(--space-4);
    z-index: 200;
    width: auto;
    height: auto;
    margin: 0;
    padding: var(--space-3) var(--space-5);
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: var(--font-semibold);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Header
   ========================================================================== */
.header {
    /* www4\'s header: 12px above and below the 50px logo, 75px tall with the border */
    padding: var(--space-3) var(--space-8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--header-bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo img {
    /* the www4 logo\'s 140 by 50 */
    height: 50px;
    width: auto;
}

.logo .logo-light,
.logo .logo-dark {
    display: none;
}

[data-theme="light"] .logo .logo-light {
    display: block;
}

[data-theme="dark"] .logo .logo-dark {
    display: block;
}

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

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

/* Theme Toggle */
/* The buttons' design: their corners, the service cards' border, and their hover */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

/* Like Get help and Call: lift and the cards' glow; the border takes the icon's color (dark in light mode, white in dark) */
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: currentColor;
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow-blue);
}

.theme-toggle:active {
    transform: translateY(-1px);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* CTA Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 var(--space-5);
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
    border-radius: 10px;
    transition: all var(--transition-base);
    white-space: nowrap;
    border: none;
    cursor: pointer;
    /* Every button is 44px tall, the touch-friendly minimum (the header theme toggle too) */
    height: 44px;
    min-height: 44px;
    min-width: 44px;
}

/* Header CTA - icon only on mobile */
.btn--header {
    padding: 0 var(--space-3);
}

.btn--header .btn-text {
    display: none;
}

@media (min-width: 480px) {
    .btn--header {
        padding: 0 var(--space-5);
    }

    .btn--header .btn-text {
        display: inline;
    }
}

.btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Call buttons: tinted blue like the home page's blue service icons; text and icon in the logo's blue (the "IT") */
.btn--primary {
    background: linear-gradient(135deg, rgba(var(--brand-blue-rgb), 0.2), rgba(var(--brand-blue-rgb), 0.1));
    color: var(--logo-blue);
    /* the service cards' border */
    border: 1px solid var(--border-color);
}

.btn--primary:hover {
    /* the service cards' hover: border in the button's color, and their glow */
    border-color: var(--brand-blue);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow-blue);
}

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

/* Get help and Email Support: tinted red like the home page's red service icons; text and icon in the logo's red (the "US") */
.btn--red {
    background: linear-gradient(135deg, rgba(var(--brand-red-rgb), 0.2), rgba(var(--brand-red-rgb), 0.1));
    color: var(--logo-red);
    /* the service cards' border */
    border: 1px solid var(--border-color);
}

.btn--red:hover {
    /* the service cards' hover: border in the button's color, and their glow */
    border-color: var(--brand-red);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow-red);
}

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

/* ==========================================================================
   Main Content
   ========================================================================== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-12) var(--space-6);
}

.container {
    max-width: 900px;
    width: 100%;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
    padding: var(--space-12) var(--space-8) var(--space-8);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.footer-content {
    max-width: 900px;
    margin: 0 auto;
}

/* Offices */
.footer-offices {
    margin-bottom: var(--space-8);
}

.footer-offices-label {
    text-align: center;
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-5);
}

.offices-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}

.office-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-2);
    transition: all var(--transition-slow);
    min-height: 44px;
}

.office-card:hover {
    border-color: var(--brand-blue);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow-blue);
}

.office-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-1);
}

.office-icon svg {
    width: 20px;
    height: 20px;
}

.service-icon--blue {
    background: linear-gradient(135deg, rgba(74, 144, 217, 0.2), rgba(74, 144, 217, 0.1));
    color: var(--brand-blue-light);
}

.service-icon--purple {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(168, 85, 247, 0.1));
    color: var(--color-purple-light);
}

.service-icon--green {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.1));
    color: var(--color-green-light);
}

.service-icon--red {
    background: linear-gradient(135deg, rgba(229, 57, 53, 0.2), rgba(229, 57, 53, 0.1));
    color: var(--brand-red-light);
}

.office-name {
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
}

.office-area {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.office-link {
    font-size: var(--text-xs);
    color: var(--brand-blue-light);
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-1);
}

.office-link svg {
    width: 12px;
    height: 12px;
}

/* Footer Contact */
.footer-contact {
    display: flex;
    justify-content: center;
    gap: var(--space-8);
    padding: var(--space-6) 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.footer-contact a {
    color: var(--text-secondary);
    font-size: var(--text-base);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    transition: color var(--transition-fast);
    min-height: 44px;
}

.footer-contact a:hover {
    color: var(--brand-blue-light);
}

.footer-contact svg {
    width: 16px;
    height: 16px;
    color: var(--brand-blue-light);
}

/* Footer Bottom */
.footer-bottom {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-base);
}

.footer-bottom p {
    margin: 0;
    font-size: var(--text-sm);
}

.reg-mark {
    font-size: 0.6em;
    line-height: 0;
}

/* Legal links and settings under the copyright */
.footer-legal ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 var(--space-6);
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
}

.footer-legal a,
.footer-legal button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    /* the copyright line's color */
    color: var(--text-muted);
    font: inherit;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.footer-legal a[aria-current="page"] {
    color: var(--text-primary);
}

/* Same blue hover as the footer's phone and email links */
.footer-legal a:hover,
.footer-legal button:hover {
    color: var(--brand-blue-light);
}

/* Blue, like the footer's phone and email icons; the words stay --text-muted */
.footer-theme svg,
.footer-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--brand-blue-light);
}

/* "Your Privacy Choices" icon: California's opt-out icon, in its own colors */
.privacy-icon {
    width: 30px;
    height: 14px;
    flex-shrink: 0;
}

.privacy-icon .pi-frame {
    fill: var(--privacy-icon-white);
    stroke: var(--privacy-icon-blue);
    stroke-width: 1.5;
}

.privacy-icon .pi-fill {
    fill: var(--privacy-icon-blue);
}

.privacy-icon .pi-check,
.privacy-icon .pi-x {
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.privacy-icon .pi-check {
    stroke: var(--privacy-icon-blue);
}

.privacy-icon .pi-x {
    stroke: var(--privacy-icon-white);
}

/* "Your Privacy Choices" dialog: the main site's consent layout. Only
   "Strictly necessary" is used here, so the other switches are locked off */
.privacy-dialog {
    /* margin: auto centers it; the page reset removes the browser's own */
    margin: auto;
    width: calc(100% - 2 * var(--space-4));
    max-width: 600px;
    max-height: calc(100% - 2 * var(--space-4));
    overflow-y: auto;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-xl);
}

.privacy-dialog::backdrop {
    background: var(--overlay-backdrop);
}

/* Hidden until opened. Browsers support this for <dialog> on their own; one without <dialog>
   would otherwise show the panel inline at the end of the page (the footer link then simply
   opens the Privacy Policy) */
.privacy-dialog:not([open]) {
    display: none;
}

.privacy-dialog-body {
    padding: var(--space-8) var(--space-8) var(--space-3);
}

.privacy-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

.privacy-dialog-head h2 {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    line-height: var(--leading-tight);
}

.privacy-dialog-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.privacy-dialog-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.privacy-dialog-close svg {
    width: 20px;
    height: 20px;
}

.privacy-dialog p {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
}

.privacy-dialog p.privacy-dialog-intro {
    margin-bottom: var(--space-6);
    font-size: var(--text-lg);
}

.privacy-dialog p a {
    color: var(--link-color);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    transition: color var(--transition-fast);
}

.privacy-dialog p a:hover {
    color: var(--text-primary);
}

.consent-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.consent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    padding: var(--space-5) 0;
    border-top: 1px solid var(--border-color);
}

.consent-row h3 {
    margin: 0 0 var(--space-1);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
}

/* Not used on this site: the whole row is grey and disabled, like its switch */
.privacy-dialog .consent-row--off h3,
.privacy-dialog .consent-row--off p {
    color: var(--text-muted);
}

.consent-row--off {
    cursor: not-allowed;
}

.consent-always {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
}

/* Switch drawn on the checkbox itself; the knob is a gradient so it
   needs no pseudo-element. Disabled and off: grey, cannot be changed */
.consent-switch {
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    width: 48px;
    height: 28px;
    margin: 0;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-full);
    background:
        radial-gradient(circle 8px at 12px 50%, var(--text-muted) 92%, transparent 100%),
        var(--bg-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

@media (max-width: 480px) {
    .privacy-dialog-body {
        padding: var(--space-6) var(--space-5) var(--space-1);
    }
}

@media print {
    .footer-legal, .privacy-dialog {
        display: none;
    }
}

/* ==========================================================================
   Responsive Design - Mobile First
   ========================================================================== */
/* Header "Get help": icon only until there is room for both header
   labels (the email link it replaced was hidden at this width too) */
@media (max-width: 768px) {
    .btn--help {
        padding: 0 var(--space-3);
    }

    .btn--help .btn-text {
        display: none;
    }
}

/* Smallest phones: tighter header gaps so the logo keeps its room */
@media (max-width: 360px) {
    .header-actions {
        gap: var(--space-2);
    }

    /* The 140px logo plus the three buttons would touch at 320px: a smaller logo (about 95px) leaves a gap */
    .logo img {
        height: 34px;
    }

    /* The logo's box keeps www4's 50px height, so the header stays 75px tall here too */
    .logo {
        height: 50px;
        display: flex;
        align-items: center;
    }
}

/* Tablet and below */
@media (max-width: 768px) {
    .header {
        padding: var(--space-3) var(--space-4);
    }

    .offices-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
        margin: 0 auto;
    }

    .footer-contact {
        flex-direction: column;
        align-items: center;
        gap: var(--space-4);
    }
}

/* Mobile */
@media (max-width: 480px) {
    .main {
        padding: var(--space-8) var(--space-4);
    }

    .footer {
        padding: var(--space-8) var(--space-4) var(--space-6);
    }
}

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

    html {
        scroll-behavior: auto;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: currentColor;
    }
}

@media print {
    body {
        background: white;
        color: black;
    }
}
