/* ========================================
   CSS Variables for Light/Dark Mode
   ======================================== */

:root {
    /* Light mode colors */
    --color-bg: #ffffff;
    --color-bg-alt: #faf9ff; /* subtle violet-tinted off-white */
    --color-bg-subtle: #f3f1ff; /* soft surface */

    --color-text: #14121a;
    --color-text-secondary: #3f3a4a;
    --color-text-tertiary: #625b70;

    --color-border: #e4e0f2;
    --color-border-strong: #c9c1e3;

    /* Brand accent (links, focus, highlights) */
    --color-primary: #6d28d9; /* purple */
    --color-primary-hover: #5b21b6;
    --color-primary-bg: #efe7ff;

    --color-secondary: #3f3a4a;
    --color-secondary-hover: #14121a;

    /* Focus */
    --color-focus: #6d28d9;
    --color-focus-outline: rgba(109, 40, 217, 0.45);

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    --font-family-heading: 'Fraunces', ui-serif, Georgia, 'Times New Roman', serif;

    --font-size-base: 18px;
    --font-size-xs: 14px;
    --font-size-small: 15px;
    --font-size-medium: 16px;
    --font-size-large: 20px;
    --font-size-xl: 32px;
    --font-size-xxl: 52px;

    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --line-height-base: 1.75;
    --line-height-relaxed: 1.85;
    --line-height-tight: 1.65;
    --line-height-heading: 1.25;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-xxl: 3rem;
    --space-xxxl: 7rem;

    /* Layout */
    --max-width: 1100px;
    --max-narrow-width: 680px;
    --max-text-width: 70ch;

    /* Border radius */
    --border-radius: 6px;
    --border-radius-small: 6px;
    --border-radius-medium: 10px;
    --border-radius-large: 16px;

    /* Transition */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;

    /* CTA palette (orange primary CTA; AAA in light mode with white text) */
    --accent-orange: #9a3412;
    --accent-orange-hover: #7c2d12;
    --accent-orange-soft: #fff1e7;

    /* Button tokens */
    --btn-primary-bg: var(--accent-orange);
    --btn-primary-bg-hover: var(--accent-orange-hover);
    --btn-primary-fg: #ffffff;

    --btn-secondary-bg: transparent;
    --btn-secondary-fg: var(--color-text);
    --btn-secondary-border: var(--color-border-strong);

    --btn-ghost-bg-hover: rgba(0, 0, 0, 0.06);

    /* Focus ring (purple feels more “intentional” than orange) */
    --btn-focus-ring: rgba(109, 40, 217, 0.45);
}

/* Dark mode - AAA contrast optimized */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0b0b12; /* cool slate (not pure black) */
        --color-bg-alt: #121226;
        --color-bg-subtle: #191934;

        --color-text: #f3f2ff;
        --color-text-secondary: #c9c6e4;
        --color-text-tertiary: #a7a2c8;

        --color-border: #2a2950;
        --color-border-strong: #3a3870;

        /* Brand accent (purple) */
        --color-primary: #a78bfa;
        --color-primary-hover: #c4b5fd;
        --color-primary-bg: #1a1530;

        --color-secondary: #c9c6e4;
        --color-secondary-hover: #f3f2ff;

        --color-focus: #a78bfa;
        --color-focus-outline: rgba(167, 139, 250, 0.45);

        /* CTA button: keep AAA in dark mode by using dark text on bright orange */
        --btn-primary-bg: #fb923c;
        --btn-primary-bg-hover: #fdba74; /* still AAA with dark text */
        --btn-primary-fg: #0b0b12;

        --btn-secondary-fg: var(--color-text);
        --btn-secondary-border: var(--color-border-strong);

        --btn-ghost-bg-hover: rgba(255, 255, 255, 0.08);
        --btn-focus-ring: rgba(167, 139, 250, 0.45);
    }
}

/* ========================================
   Local Font Faces
   ======================================== */

@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/inter-v20-latin-regular.woff2') format('woff2');
}

@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/inter-v20-latin-500.woff2') format('woff2');
}

@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/inter-v20-latin-700.woff2') format('woff2');
}

@font-face {
    font-family: Fraunces;
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/assets/fonts/fraunces-v38-latin-600.woff2') format('woff2');
}

@font-face {
    font-family: Fraunces;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/fraunces-v38-latin-700.woff2') format('woff2');
}

/* ========================================
   Base Styles
   ======================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .btn:hover {
        transform: none;
    }
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

strong,
b {
    font-weight: var(--font-weight-bold);
}

/* ========================================
   Skip Link (Accessibility)
   ======================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    border: 0;
    padding: 0;
    white-space: nowrap;
    clip-path: inset(100%);
    clip: rect(0 0 0 0);
    overflow: hidden;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    padding: var(--space-sm) var(--space-lg);
    background-color: var(--color-primary);
    color: white;
    text-decoration: none;
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-base);
    z-index: 9999;
    border-radius: 0 0 var(--border-radius-large) 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-bottom: none;

    &:focus {
        top: 0;
        outline: 4px solid white;
        outline-offset: 3px;
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.3);
    }

    &:focus-visible {
        top: 0;
        outline: 4px solid white;
        outline-offset: 3px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

/* ========================================
   Focus Styles (Strong, Accessible)
   ======================================== */

/* Strong focus indicators for keyboard navigation (WCAG 2.2 AAA) */
:focus {
    outline: 3px solid var(--color-focus);
    outline-offset: 3px;
    transition: outline-offset var(--transition-fast);

    &:not(:focus-visible) {
        outline: none;
    }
}

:focus-visible {
    outline: 4px solid var(--color-focus);
    outline-offset: 4px;
    border-radius: 3px;
    box-shadow: 0 0 0 8px var(--color-focus-outline);

    *& {
        outline-style: solid !important;
    }

    img& {
        outline: 4px solid var(--color-focus);
        outline-offset: 4px;
    }
}

/* ========================================
   Typography
   ======================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 var(--space-lg) 0;
    line-height: var(--line-height-heading);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    letter-spacing: -0.02em;
}

h1 {
    font-size: var(--font-size-xxl);
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.03em;
}

h2 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    letter-spacing: -0.02em;
}

/* Heading font (keeps layout intact; just typography) */
h1,
h2,
h3,
h4,
h5,
h6,
.section-title {
    font-family: var(--font-family-heading);
}

p {
    margin: 0 0 var(--space-md) 0;
    max-width: var(--max-text-width);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    text-decoration-skip-ink: auto;
    transition: color var(--transition-fast);
    border-bottom: 1px solid transparent;

    &:hover {
        color: var(--color-primary-hover);
        border-bottom-color: currentColor;
    }

    &:focus-visible {
        outline: 3px solid var(--color-focus);
        outline-offset: 3px;
        border-bottom-color: transparent;
    }
}

/* ========================================
   Layout Containers
   ======================================== */

/* Avoid in-page anchor targets sitting under sticky nav */
[id] {
    scroll-margin-top: 6rem;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-md);

    &.narrow {
        max-width: var(--max-narrow-width);
    }
}

.section {
    padding: var(--space-xxxl) 0;
    border-bottom: 1px solid var(--color-border);

    &:last-child {
        border-bottom: none;
    }

    &:nth-child(even) {
        background-color: var(--color-bg-alt);
    }
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-block;
    padding: 1rem 2rem;
    min-height: 48px;
    min-width: 120px;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    border-radius: var(--border-radius-large);
    transition: all var(--transition-base);
    cursor: pointer;
    border: 2px solid transparent;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    &:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    &:active {
        transform: translateY(0);
    }

    &.small {
        border-radius: var(--border-radius-small);
        font-size: var(--font-size-xs);
        min-height: 36px;
        min-width: fit-content;
        padding: 0.5rem 1rem;
    }
}

.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

/* PRIMARY CTA
   Use the CTA/button tokens (defined in BOTH modes) to guarantee contrast.
   This fixes the dark-mode purple/white contrast violation without changing your purple brand accents. */
.btn-primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-fg);
    border-color: var(--btn-primary-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);

    &:hover {
        background-color: var(--btn-primary-bg-hover);
        border-color: var(--btn-primary-bg-hover);
        color: var(--btn-primary-fg);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    }

    &:focus-visible {
        outline: 4px solid var(--color-focus);
        outline-offset: 4px;
        box-shadow:
            0 0 0 8px var(--color-focus-outline),
            0 2px 8px rgba(0, 0, 0, 0.12);
    }
}

/* SECONDARY CTA
   Keep it outlined and “lighter touch” (more professional than flipping to a heavy block).
   Uses existing tokens only; works in both modes. */
.btn-secondary {
    background-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-fg);
    border-color: var(--btn-secondary-border);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.05);

    &:hover {
        background-color: var(--accent-orange-soft);
        color: var(--btn-secondary-fg);
        border-color: var(--btn-primary-bg);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);

        @media (prefers-color-scheme: dark) {
            background-color: rgba(251, 146, 60, 0.12);
            border-color: var(--btn-primary-bg);
            color: var(--btn-secondary-fg);
        }
    }

    &:focus-visible {
        outline: 4px solid var(--color-focus);
        outline-offset: 4px;
        box-shadow:
            0 0 0 8px var(--color-focus-outline),
            0 1px 4px rgba(0, 0, 0, 0.05);
    }
}

/* ========================================
   Section Titles
   ======================================== */

.section-title {
    margin-bottom: var(--space-xl);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    letter-spacing: -0.02em;
    line-height: var(--line-height-heading);
    text-align: center;
}

/* ========================================
   Content Lists
   ======================================== */

.content-list {
    max-width: var(--max-text-width);
    margin: 0 auto;
    padding: 0;
    list-style: none;

    & li {
        position: relative;
        padding-left: var(--space-lg);
        margin-bottom: var(--space-lg);
        font-size: var(--font-size-base);
        line-height: var(--line-height-relaxed);
        color: var(--color-text);

        &::before {
            content: '→';
            position: absolute;
            left: 0;
            color: var(--color-primary);
            font-weight: var(--font-weight-semibold);
            font-size: 1.2em;
            line-height: 1;
            top: 0.1em;
        }
    }

    &.ordered {
        list-style: decimal;
        padding-left: var(--space-xl);

        & li {
            padding-left: var(--space-sm);

            &::before {
                content: none;
            }
        }
    }
}

/* ========================================
   Services Landing: Card Grid, Engagements, Ideal
   ======================================== */

.engagements-list {
    margin: var(--space-lg) 0;

    & dt {
        font-weight: var(--font-weight-semibold);
        color: var(--color-text);
        margin-top: var(--space-lg);
        margin-bottom: var(--space-xs);

        &:first-child {
            margin-top: 0;
        }
    }

    & dd {
        margin: 0 0 0 var(--space-md);
        color: var(--color-text-secondary);
        line-height: var(--line-height-relaxed);
    }
}

.services-intro {
    background-color: var(--color-bg-alt);
}

.services-ideal {
    background-color: var(--color-bg-alt);
}

/* ========================================
   Nav Item and Footer Links Common Styles
   ======================================== */

.footer-links,
.nav-item {
    display: flex;
    gap: var(--space-lg);
    justify-content: center;
    align-items: center;

    @media (max-width: 480px) {
        gap: var(--space-md);
    }

    & a {
        font-size: var(--font-size-medium);
        font-weight: var(--font-weight-medium);
        color: var(--color-text-secondary);
        text-decoration: none;
        transition: color var(--transition-fast);
        border-bottom: 1px solid transparent;
        padding: var(--space-xs) var(--space-sm);
        margin: calc(-1 * var(--space-xs)) calc(-1 * var(--space-sm));
        min-height: 44px;
        display: inline-flex;
        align-items: center;

        &:hover {
            color: var(--color-primary);
            border-bottom-color: var(--color-primary);
        }

        &:focus-visible {
            outline: 4px solid var(--color-focus);
            outline-offset: 4px;
            border-bottom-color: transparent;
            box-shadow: 0 0 0 8px var(--color-focus-outline);
            border-radius: 3px;
        }

        @media print {
            &:after {
                content: none;
            }
        }
    }
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    :root {
        --font-size-base: 17px;
        --font-size-small: 14px;
        --font-size-medium: 15px;
        --font-size-large: 19px;
        --font-size-xl: 28px;
        --font-size-xxl: 40px;
        --space-lg: 2rem;
        --space-xl: 3rem;
        --space-xxl: 4.5rem;
        --space-xxxl: 6rem;
    }

    .section {
        padding: var(--space-xxl) 0;
    }

    .btn {
        width: 100%;
        max-width: 400px;
        text-align: center;
        min-height: 48px;
    }
}

@media (max-width: 480px) {
    :root {
        --font-size-base: 16px;
        --font-size-small: 13px;
        --font-size-medium: 14px;
        --font-size-large: 18px;
        --font-size-xl: 24px;
        --font-size-xxl: 34px;
        --space-xl: 2.5rem;
        --space-xxl: 3.5rem;
        --space-xxxl: 5rem;
    }

    .container {
        padding: 0 var(--space-md);
    }

    .section {
        padding: var(--space-xl) 0;
    }

    .btn {
        padding: 0.875rem 1.5rem;
        min-height: 48px;
    }
}

/* ========================================
   High Contrast Mode Support
   ======================================== */

@media (prefers-contrast: high) {
    :root {
        --color-primary: #0047b3;
        --color-border: #000000;
        --color-text: #000000;
        --color-text-secondary: #1a1a1a;

        /* Maintain button contrast in high contrast mode (same tokens, same names) */
        --btn-primary-bg: #000000;
        --btn-primary-bg-hover: #000000;
        --btn-primary-fg: #ffffff;

        --btn-secondary-border: #000000;
    }

    @media (prefers-color-scheme: dark) {
        :root {
            --color-primary: #66b3ff;
            --color-border: #ffffff;
            --color-text: #ffffff;
            --color-text-secondary: #e0e0e0;

            --btn-primary-bg: #ffffff;
            --btn-primary-bg-hover: #ffffff;
            --btn-primary-fg: #000000;

            --btn-secondary-border: #ffffff;
        }
    }

    .btn {
        border-width: 3px;

        &:hover {
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
        }
    }

    :focus,
    :focus-visible {
        outline-width: 4px;
        outline-offset: 4px;
    }

    a {
        border-bottom-width: 2px;
        text-decoration: underline;
    }
}

/* ========================================
   Print Styles (Accessibility)
   ======================================== */

@media print {
    /* Show all content clearly for printing */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }

    .skip-link {
        display: none;
    }

    /* Expand all sections */
    .section {
        page-break-inside: avoid;
        padding: 1rem 0;
        border-bottom: 1pt solid #ccc;
    }

    /* Show URLs for external links */
    a[href^='http']:after {
        content: ' (' attr(href) ')';
        font-size: 10pt;
        color: #666;
    }

    /* Hide interactive elements that don't make sense in print */
    .btn,
    .cta-group {
        display: none;
    }

    /* Ensure good contrast */
    * {
        color: #000 !important;
        background: #fff !important;
    }

    h1,
    h2,
    h3,
    dt {
        color: #000 !important;
        font-weight: bold;
    }
}
