/* ==========================================================================
   theme.css - design tokens + base layer

   Loaded after Bootstrap on every page so it can override it.
   The palette is built around the site's original blue (#299ac5) which is kept
   as --brand-500 and used for accents. The navigation panel uses --brand-600,
   the same hue two steps darker, because white text on #299ac5 only reaches
   3.22:1 which is below the 4.5:1 WCAG AA minimum for body-sized text.
   ========================================================================== */

:root {
    /* --- brand blue scale (hue 196.5, same family as the original #299ac5) -- */
    --brand-050: #f2f9fd;
    --brand-100: #e3f2fa;
    --brand-200: #c5e5f3;
    --brand-300: #8fcde8;
    --brand-400: #54b3d7;
    --brand-500: #299ac5;
    /* the signature blue */
    --brand-600: #20799b;
    /* nav panel, 4.92:1 with white */
    --brand-700: #1a6480;
    --brand-ink: #0f6d91;
    /* blue text on white, 5.81:1 */

    /* --- neutrals ------------------------------------------------------- */
    --surface: #ffffff;
    --surface-sunken: #f7fafc;
    --surface-raised: #ffffff;
    --border: #e3e9ef;
    --border-strong: #cfd9e2;
    --text: #16202a;
    --text-muted: #5b6b7a;

    /* --- semantic accents for the project type tags --------------------- */
    --tag-brand-bg: #e8f5fb;
    --tag-brand-fg: #0f6d91;
    --tag-success-bg: #e9f7ef;
    --tag-success-fg: #15703f;
    --tag-neutral-bg: #f1f4f7;
    --tag-neutral-fg: #4a5866;
    --tag-danger-bg: #fdeeee;
    --tag-danger-fg: #b4232a;
    --tag-tech-bg: #fff8e6;
    --tag-tech-fg: #8a5a00;

    /* --- spacing (density 4/10: standard) ------------------------------- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;

    /* --- radii ---------------------------------------------------------- */
    --radius-sm: 6px;
    --radius: 10px;
    /* the original card radius */
    --radius-lg: 14px;
    --radius-pill: 999px;

    /* --- elevation (blue tinted so it sits in the palette) -------------- */
    --shadow-sm: 0 1px 2px rgba(16, 42, 67, 0.05);
    --shadow: 0 1px 2px rgba(16, 42, 67, 0.05), 0 10px 24px -14px rgba(16, 42, 67, 0.18);
    --shadow-lg: 0 2px 4px rgba(16, 42, 67, 0.06), 0 18px 40px -18px rgba(16, 42, 67, 0.24);

    /* --- motion (subtle tier) ------------------------------------------- */
    --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
    --dur-fast: 140ms;
    --dur: 220ms;

    /* --- layout --------------------------------------------------------- */
    --measure: 72ch;
}

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

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

html {
    scroll-behavior: smooth;
    /* keeps an anchored target clear of the sticky mobile nav bar */
    scroll-padding-top: 5rem;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--text);
    background-color: var(--surface);
    font-size: 1rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--text);
    line-height: 1.25;
    letter-spacing: -0.011em;
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

img {
    max-width: 100%;
}

a {
    color: var(--brand-ink);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
    transition: color var(--dur-fast) var(--ease);
}

a:hover {
    color: var(--brand-700);
}

/* ==========================================================================
   Focus - a single visible ring for every interactive control
   ========================================================================== */

:focus-visible {
    outline: 3px solid var(--brand-500);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* on the blue nav panel the ring needs to be light to stay visible */
.sidebar :focus-visible {
    outline-color: #ffffff;
}

/* ==========================================================================
   Skip link - first tab stop on every page
   ========================================================================== */

.skip-link {
    position: absolute;
    left: var(--space-4);
    top: 0;
    z-index: 100;
    transform: translateY(-120%);
    padding: var(--space-2) var(--space-4);
    background: var(--surface);
    color: var(--brand-ink);
    font-weight: 600;
    border: 1px solid var(--border-strong);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition: transform var(--dur) var(--ease);
}

/* :focus rather than :focus-visible - the link is only ever reachable by
   keyboard, so it must appear whenever it is focused at all */
.skip-link:focus {
    transform: translateY(0);
}

/* ==========================================================================
   Section headings
   ========================================================================== */

.section-head {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.section-head h2 {
    font-size: clamp(1.5rem, 1.2rem + 1vw, 1.9rem);
    font-weight: 700;
    margin: 0;
}

.section-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Tags - static labels. These replace the .btn markup the cards used to
   borrow, which looked clickable but did nothing.
   ========================================================================== */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.2em 0.65em;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0.005em;
    white-space: nowrap;
    background: var(--tag-neutral-bg);
    color: var(--tag-neutral-fg);
}

.tag--brand {
    background: var(--tag-brand-bg);
    color: var(--tag-brand-fg);
}

.tag--success {
    background: var(--tag-success-bg);
    color: var(--tag-success-fg);
}

.tag--neutral {
    background: var(--tag-neutral-bg);
    color: var(--tag-neutral-fg);
}

.tag--danger {
    background: var(--tag-danger-bg);
    color: var(--tag-danger-fg);
}

.tag--tech {
    background: var(--tag-tech-bg);
    color: var(--tag-tech-fg);
    white-space: normal;
    text-align: left;
}

.tag--solid {
    background: var(--brand-600);
    color: #ffffff;
}

.tag-dot {
    width: 0.45em;
    height: 0.45em;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

/* ==========================================================================
   Cards - shared surface for experience / project / blog / interactive items.
   The hover lift replaces the old transform: scale(1.05), which grew items
   into their neighbours and shifted the surrounding layout.
   ========================================================================== */

.card-surface {
    position: relative;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--dur) var(--ease),
        box-shadow var(--dur) var(--ease),
        transform var(--dur) var(--ease);
}

@media (hover: hover) {

    .card-surface:hover {
        border-color: var(--brand-300);
        box-shadow: var(--shadow);
        transform: translateY(-2px);
    }
}

/* keyboard users get the same affordance as pointer users */
.card-surface:focus-within {
    border-color: var(--brand-400);
    box-shadow: var(--shadow);
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    /* 44px minimum touch target */
    min-height: 2.75rem;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--brand-500);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--brand-ink);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
        color var(--dur-fast) var(--ease),
        border-color var(--dur-fast) var(--ease);
}

.button:hover {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #ffffff;
}

.button--primary {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #ffffff;
}

.button--primary:hover {
    background: var(--brand-700);
    border-color: var(--brand-700);
    color: #ffffff;
}

.button--ghost {
    border-color: var(--border-strong);
    color: var(--text-muted);
    min-height: 2.25rem;
    font-size: 0.875rem;
}

.button--ghost:hover {
    border-color: var(--brand-500);
    background: var(--brand-050);
    color: var(--brand-ink);
}

.button svg {
    flex: none;
}

/* ==========================================================================
   Icon links (social) - 44px targets with an accessible name
   ========================================================================== */

.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    transition: color var(--dur-fast) var(--ease),
        border-color var(--dur-fast) var(--ease),
        background var(--dur-fast) var(--ease);
}

.icon-link:hover {
    color: var(--brand-ink);
    border-color: var(--brand-300);
    background: var(--brand-050);
}

.icon-link svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* ==========================================================================
   Filter toolbar - chips + search, used by the projects section
   ========================================================================== */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    min-height: 2.25rem;
    padding: 0.3rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
        color var(--dur-fast) var(--ease),
        border-color var(--dur-fast) var(--ease);
}

.chip:hover {
    border-color: var(--brand-400);
    color: var(--brand-ink);
    background: var(--brand-050);
}

.chip[aria-pressed='true'] {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #ffffff;
}

.chip-count {
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
    font-size: 0.8em;
}

.search-field {
    position: relative;
    flex: 1 1 15rem;
    max-width: 22rem;
    display: flex;
    align-items: center;
}

.search-field svg {
    position: absolute;
    left: 0.75rem;
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-field input {
    width: 100%;
    min-height: 2.5rem;
    padding: 0.4rem 0.75rem 0.4rem 2.25rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    transition: border-color var(--dur-fast) var(--ease),
        box-shadow var(--dur-fast) var(--ease);
}

.search-field input::placeholder {
    color: var(--text-muted);
}

.search-field input:hover {
    border-color: var(--brand-400);
}

.search-field input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
}

.search-field input:focus-visible {
    outline: none;
}

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty-state {
    padding: var(--space-7) var(--space-4);
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-sunken);
}

.empty-state strong {
    display: block;
    color: var(--text);
    margin-bottom: var(--space-1);
}

.empty-state p {
    margin: 0 0 var(--space-4);
}

/* ==========================================================================
   Scroll reveal - progressive enhancement. Without JS, or with reduced
   motion, everything renders in its final readable state.
   ========================================================================== */

.js-reveal .reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 350ms var(--ease), transform 350ms var(--ease);
}

.js-reveal .reveal.is-visible {
    opacity: 1;
    transform: none;
}

/* ==========================================================================
   Back to top
   ========================================================================== */

.to-top {
    position: fixed;
    right: var(--space-4);
    bottom: var(--space-4);
    z-index: 30;
    width: 2.75rem;
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    color: var(--brand-ink);
    box-shadow: var(--shadow);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity var(--dur) var(--ease),
        transform var(--dur) var(--ease),
        visibility var(--dur) var(--ease),
        background var(--dur-fast) var(--ease);
}

.to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.to-top:hover {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #ffffff;
}

.to-top svg {
    width: 1.1rem;
    height: 1.1rem;
}

/* ==========================================================================
   Screen reader only
   ========================================================================== */

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Reduced motion - honour the OS setting everywhere
   ========================================================================== */

@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;
        scroll-behavior: auto !important;
    }

    .js-reveal .reveal {
        opacity: 1;
        transform: none;
    }

    .card-surface:hover {
        transform: none;
    }
}
