/* =======================================================================================
   1807 — MAIN.CSS (UPDATED, COMPLETE)
   Scope: Reset, tokens, base, layout shells (header/footer), cursors, utilities
   Change: Explicit cascade layer order so .btn (components) cleanly overrides base <a> color
   ======================================================================================= */

/* ---- Global layer order (controls priority across ALL stylesheets) ---- */
@layer reset, base, buttons, navigation, cards, carousels, ai, robotics, home, projects, pages, motion, overrides;

/* ===== Reset ===== */
@layer reset {

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

    html,
    body {
        height: 100%;
    }

    [hidden] {
        display: none !important;
        pointer-events: none !important;
    }
}

/* ===== Tokens (unlayered so variables are always available) ===== */
:root {
    /* Blues */
    --blue-900: #0b1f4a;
    --blue-800: #1e40af;
    --blue-700: #1d4ed8;
    --blue-600: #2563eb;
    --blue-400: #60a5fa;

    /* Light brown / tan */
    --tan-700: #9e7743;
    --tan-600: #b68b4c;
    --tan-500: #d6a76a;
    --tan-100: #f5e9da;

    /* Neutrals */
    --black-true: #0b0f14;
    --black: #10151d;
    --ink: #0f141b;
    --white: #ffffff;
    --off-white: #f8fafc;

    /* Surfaces (dark default) */
    --bg: var(--black-true);
    --panel: var(--ink);
    --surface: #121822;
    --surface-2: #0e131b;

    /* Text */
    --text: #eaf1ff;
    --muted: #aab8d3;
    --accent-2: #c5d0e6;

    /* Accents */
    --primary: var(--blue-600);
    --primary-strong: var(--blue-800);
    --primary-soft: rgba(37, 99, 235, .12);
    --secondary: var(--tan-600);
    --secondary-soft: rgba(182, 139, 76, .14);

    /* Lines & effects */
    --border: rgba(255, 255, 255, .1);
    --radius: 16px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;
    --shadow: 0 8px 30px rgba(0, 0, 0, .35);
    --container: 1600px;
    --transition: all .15s ease;

    /* Focus */
    --focus: 0 0 0 3px rgba(37, 99, 235, .4);

    /* Typography */
    --font-size-base: 16px;
    --line-height-base: 1.6;
    --font-size-h1: clamp(2.5rem, 4vw, 4rem);
    --font-size-h2: clamp(2rem, 3.5vw, 3rem);
    --font-size-h3: clamp(1.75rem, 3vw, 2.5rem);
    --font-size-h4: clamp(1.5rem, 2.5vw, 2rem);

    /* Defaults */
    --panel-default-delay: 5000;

    --cursor-default: url('/assets/cursors/default.png') 6 6, auto;
    --cursor-pointer: url('/assets/cursors/pointer.png') 6 6, pointer;
    --cursor-editor: url('/assets/cursors/editor.png') 6 6, text;
    --cursor-typing: url('/assets/cursors/typing.png') 6 6, text;
}

/* Light theme tokens */
@layer base {
    body.theme-light {
        --bg: var(--tan-100);
        --panel: var(--off-white);
        --surface: #ffffff;
        --surface-2: #f1f3f6;
        --text: #0b1220;
        --muted: #374151;
        --accent-2: #4b5563;
        --border: rgba(0, 0, 0, .2);
        --primary-soft: rgba(37, 99, 235, .1);
        --secondary-soft: rgba(182, 139, 76, .14);
        --shadow: 0 4px 20px rgba(0, 0, 0, .15);
        --focus: 0 0 0 3px rgba(37, 99, 235, .3);
    }
}

/* ===== Base ===== */
@layer base {
    body {
        margin: 0;
        font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
        font-size: var(--font-size-base);
        line-height: var(--line-height-base);
        background: var(--bg);
        color: var(--text);
        cursor: var(--cursor-default);
    }

    /* Base links (in base layer so component buttons can override) */
    a {
        color: var(--primary);
        text-decoration: none;
        text-underline-offset: 3px;
        transition: var(--transition);
        cursor: var(--cursor-pointer);
    }

    a:hover {
        color: var(--blue-400);
    }

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

    p,
    span,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        cursor: var(--cursor-editor);
    }

    input,
    textarea {
        cursor: var(--cursor-typing);
    }

    .container {
        width: min(100% - 24px, var(--container));
        margin-inline: auto;
        padding-inline: 12px;
    }

    /* Brand bits */
    .logo {
        height: 40px;
        width: auto;
    }

    /* Accessibility helpers */
    .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 {
        position: absolute;
        left: -9999px;
        top: auto;
        width: 1px;
        height: 1px;
        overflow: hidden;
    }

    .skip-link:focus {
        position: fixed;
        left: 16px;
        top: 16px;
        width: auto;
        height: auto;
        padding: 8px 12px;
        background: var(--primary);
        color: var(--white);
        z-index: 9999;
        border-radius: var(--radius);
        outline: none;
        cursor: var(--cursor-pointer);
    }
}

/* ===== Header (layout component) ===== */
@layer components {
    .site-header {
        background: var(--panel);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 1000;
        color: var(--text);
    }

    .header-inner {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        width: min(100%, var(--container));
        margin-inline: auto;
        padding-inline: clamp(16px, 3.5vw, 40px);
        min-height: 64px;
        column-gap: clamp(12px, 2.5vw, 28px);
    }

    /* Brand (left) */
    .brand {
        display: inline-flex;
        align-items: center;
        gap: 12px;
        font-weight: 800;
        color: var(--text);
        text-decoration: none;
        cursor: var(--cursor-pointer);
    }

    .brand .logo {
        height: 28px;
        width: auto;
    }

    .brand .dot-o {
        color: var(--accent-2);
        font-weight: 700;
    }

    /* Animated brand GIF — always visible */
    .brand .logo-animated {
        height: 22px;
        width: auto;
        margin-left: 6px;
        transform: translateX(2px);
        display: inline-block;
        flex-shrink: 0;
        image-rendering: -webkit-optimize-contrast;
    }

    @media (max-width:420px) {
        .brand .logo-animated {
            height: 18px;
        }
    }

    /* Centered top navigation (desktop) */
    .top-nav {
        justify-self: center;
    }

    .top-nav__list {
        display: flex;
        gap: clamp(16px, 3vw, 36px);
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .top-nav__list a {
        color: var(--text);
        font-weight: 600;
        text-decoration: none;
        padding-block: 6px;
        border-bottom: 2px solid transparent;
        transition: var(--transition);
        cursor: var(--cursor-pointer);
    }

    .top-nav__list a:hover {
        color: var(--blue-400);
    }

    .top-nav__list a[aria-current="page"] {
        border-bottom-color: var(--blue-400);
    }

    /* Actions (right) */
    .header-actions {
        justify-self: end;
        display: inline-flex;
        align-items: center;
        gap: clamp(10px, 1.6vw, 20px);
    }

    .iconbtn {
        display: inline-grid;
        place-items: center;
        padding: 8px;
        border: 0;
        background: transparent;
        border-radius: var(--radius-sm);
        cursor: var(--cursor-pointer);
        transition: var(--transition);
    }

    .iconbtn:hover,
    .iconbtn:focus-visible {
        background: var(--primary-soft);
        outline: var(--focus);
        outline-offset: 2px;
    }

    .icon-static {
        width: 28px;
        height: 28px;
        display: inline-block;
        object-fit: contain;
        pointer-events: none;
        vertical-align: middle;
    }

    /* Responsive: show center links only on ≥1024px */
    @media (max-width:1023.98px) {
        .header-inner {
            grid-template-columns: 1fr auto;
            column-gap: 16px;
        }

        .top-nav {
            display: none;
        }

        .header-actions {
            justify-self: end;
        }
    }
}

/* ===== Footer (layout component) ===== */
@layer components {
    .site-footer {
        border-top: 1px solid var(--border);
        background: var(--panel);
        color: var(--text);
    }

    .footer-inner {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 24px 20px;
        gap: 16px;
        max-height: 400px;
    }

    .footer-right a {
        color: var(--accent-2);
        transition: var(--transition);
    }

    .footer-right a:hover {
        color: var(--blue-400);
    }

    .footer-right .dot {
        color: var(--muted);
        margin-inline: 8px;
    }
}

/* ===== Misc / Utils ===== */
@layer base {
    #typing-area {
        cursor: var(--cursor-typing);
    }

    [tabindex="0"],
    [role="button"] {
        cursor: var(--cursor-pointer);
    }
}

/* ===== Motion prefs ===== */
@layer motion {
    @media (prefers-reduced-motion: reduce) {

        .iconbtn,
        a {
            transition: none !important;
        }
    }
}

/* ===== High-DPI cursors ===== */
@layer base {
    @media (min-resolution: 2dppx) {
        :root {
            --cursor-default: url('/assets/cursors/default@2x.png') 6 6, auto;
            --cursor-pointer: url('/assets/cursors/pointer@2x.png') 6 6, pointer;
            --cursor-editor: url('/assets/cursors/editor@2x.png') 6 6, text;
            --cursor-typing: url('/assets/cursors/typing@2x.png') 6 6, text;
        }
    }
}