/* ==========================================================================
   shared.css — everything both pages use.
   Design tokens, base, navigation, chat widget (Popover API),
   project dialog (<dialog>), footer, "Coded with love" easter egg.
   Page-specific styles live inline in each HTML file.
   ========================================================================== */

/* ---------- Reset & tokens ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@font-face {
    font-family: 'Rimba Andalas';
    src: url('RimbaAndalas.ttf') format('truetype');
    font-display: swap;
}

/* Theme follows the system by default. The comfort panel pins it with
   data-theme on <html>; every color token below is a light-dark() pair so
   one attribute flips the whole site. */
html { color-scheme: light dark; }
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"]  { color-scheme: dark; }

:root {
    --r-xs: 4px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.05), 0 10px 28px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.07), 0 24px 60px rgba(0, 0, 0, 0.16);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    /*                     light      dark                                   */
    --paper:      light-dark(#F2F1EC, #1A1C1F);   /* cool stone ground        */
    --card:       light-dark(#FBFBF9, #23262B);   /* raised surface           */
    --ink:        light-dark(#24272B, #E8E6E0);   /* graphite / bone          */
    --ink-soft:   light-dark(#5D6470, #A4AAB4);   /* secondary text           */
    --steel:      light-dark(#34596E, #7FA7BF);   /* primary accent           */
    --steel-deep: light-dark(#27455A, #9DBFD3);   /* accent hover             */
    --steel-tint: light-dark(#E4EAEE, #2B3A45);   /* accent wash              */
    --rust-text:  light-dark(#8F5E12, #E0B06A);   /* AA-compliant ochre text  */
    --rust:       light-dark(#A5701F, #D19A3E);   /* signal / highlight       */
    --line:       light-dark(#DDDCD4, #343940);   /* hairlines                */
    --selection:  light-dark(rgba(52, 89, 110, 0.18), rgba(127, 167, 191, 0.30));
    --nav-link:        light-dark(#7E6358, #C2AEA2);
    --nav-link-hover:  light-dark(#6E5750, #E0D0C6);
    --logo-j:          light-dark(#997B6F, #C4AFA3);
    --logo-h:          light-dark(#C16630, #E08A5A);
    --logo-j-hover:    light-dark(#7E6358, #DCCFC7);
    --logo-h-hover:    light-dark(#9E5226, #F0A878);

    /* One variable pair: Archivo (width + weight axes) for display and body,
       JetBrains Mono (weight axis) for labels. Two font files instead of eight. */
    --display: 'Archivo', 'Segoe UI', system-ui, sans-serif;
    --sans: 'Archivo', 'Segoe UI', system-ui, sans-serif;
    --mono: 'JetBrains Mono', 'Courier New', monospace;

    /* Ruler ticks: minor every 8px, major every 40px. Layer major under minor. */
    --ticks: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px 8px);
    --ticks-major: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px 40px);
    --tick-row: var(--ticks) left top / 100% 4px no-repeat, var(--ticks-major) left top / 100% 8px no-repeat;
    --tick-row-bottom: var(--ticks) left bottom / 100% 4px no-repeat, var(--ticks-major) left bottom / 100% 8px no-repeat;
}

/* High contrast: set by the comfort panel (data-contrast) or, when the
   visitor hasn't chosen, by the OS preference. Same overrides either way. */
html[data-contrast="high"] {
    --paper:      light-dark(#FFFFFF, #000000);
    --card:       light-dark(#FFFFFF, #0E1013);
    --ink:        light-dark(#000000, #FFFFFF);
    --ink-soft:   light-dark(#3A3F47, #D5D9DF);
    --steel:      light-dark(#1F4257, #A9CDE3);
    --steel-deep: light-dark(#102A3A, #C8E2F2);
    --steel-tint: light-dark(#DDE6EC, #1C2A34);
    --rust-text:  light-dark(#6E4708, #F0C27A);
    --line:       light-dark(#8E8E88, #6E7580);
    --nav-link:        light-dark(#000000, #FFFFFF);
    --nav-link-hover:  light-dark(#1F4257, #A9CDE3);
}
@media (prefers-contrast: more) {
    html:not([data-contrast]) {
        --paper:      light-dark(#FFFFFF, #000000);
        --card:       light-dark(#FFFFFF, #0E1013);
        --ink:        light-dark(#000000, #FFFFFF);
        --ink-soft:   light-dark(#3A3F47, #D5D9DF);
        --steel:      light-dark(#1F4257, #A9CDE3);
        --steel-deep: light-dark(#102A3A, #C8E2F2);
        --steel-tint: light-dark(#DDE6EC, #1C2A34);
        --rust-text:  light-dark(#6E4708, #F0C27A);
        --line:       light-dark(#8E8E88, #6E7580);
        --nav-link:        light-dark(#000000, #FFFFFF);
        --nav-link-hover:  light-dark(#1F4257, #A9CDE3);
    }
}
html[data-contrast="high"] a:not([class]),
html[data-contrast="high"] .chat-bubble a,
html[data-contrast="high"] .timeline-link,
html[data-contrast="high"] .view-details-btn,
html[data-contrast="high"] .view-btn { text-decoration: underline; text-underline-offset: 3px; }

html {
    background: var(--paper);
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

body {
    font-family: var(--sans);
    font-stretch: 100%;
    background-color: var(--paper);
    color: var(--ink);
    line-height: 1.65;
    overflow-x: hidden;
    min-height: 100vh;
    font-size: 1.0625rem;
}

/* Paper grain: a fixed feTurbulence layer over everything at ~4%. The top
   layer (dialogs, popovers) sits above it. Dark mode inverts the specks;
   high contrast removes the layer entirely. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9990;
    pointer-events: none;
    opacity: 0.045;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
}
html[data-theme="dark"] body::before { filter: invert(1); opacity: 0.06; }
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) body::before { filter: invert(1); opacity: 0.06; }
}
html[data-contrast="high"] body::before { display: none; }
@media (prefers-contrast: more) {
    html:not([data-contrast]) body::before { display: none; }
}

::selection { background: var(--selection); color: var(--ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 8px;
    border: 3px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-soft); }

:focus:not(:focus-visible) { outline: none; }
:focus-visible {
    outline: 1px solid var(--steel);
    outline-offset: 4px;
    border-radius: var(--r-xs);
}

/* Bracket focus: four hairline corners instead of a box, on surfaces big
   enough to carry them. Needs position: relative on the element. */
.read-more-btn, .contact-btn, .modal-link, .filter-btn, .chat-chip,
.comfort-button, .chatbot-button, .timeline-step, .modal-close, .chatbot-close { position: relative; }

.read-more-btn:focus-visible, .contact-btn:focus-visible, .modal-link:focus-visible,
.filter-btn:focus-visible, .chat-chip:focus-visible, .comfort-button:focus-visible,
.chatbot-button:focus-visible, .timeline-step:focus-visible, .modal-close:focus-visible,
.chatbot-close:focus-visible, .tech-project-card:focus-visible, .project-card:focus-visible { outline: none; }

.read-more-btn:focus-visible::before, .contact-btn:focus-visible::before, .modal-link:focus-visible::before,
.filter-btn:focus-visible::before, .chat-chip:focus-visible::before, .comfort-button:focus-visible::before,
.chatbot-button:focus-visible::before, .timeline-step:focus-visible::before, .modal-close:focus-visible::before,
.chatbot-close:focus-visible::before, .tech-project-card:focus-visible::before, .project-card:focus-visible::before {
    content: '';
    position: absolute;
    inset: -6px;
    pointer-events: none;
    --b: var(--steel);
    --l: 12px;
    background:
        linear-gradient(var(--b), var(--b)) left top / var(--l) 1px,
        linear-gradient(var(--b), var(--b)) left top / 1px var(--l),
        linear-gradient(var(--b), var(--b)) right top / var(--l) 1px,
        linear-gradient(var(--b), var(--b)) right top / 1px var(--l),
        linear-gradient(var(--b), var(--b)) left bottom / var(--l) 1px,
        linear-gradient(var(--b), var(--b)) left bottom / 1px var(--l),
        linear-gradient(var(--b), var(--b)) right bottom / var(--l) 1px,
        linear-gradient(var(--b), var(--b)) right bottom / 1px var(--l);
    background-repeat: no-repeat;
}

.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: fixed;
    top: -48px;
    left: 16px;
    z-index: 2000;
    background: var(--steel);
    color: var(--card);
    font-family: var(--mono);
    font-size: 0.85rem;
    padding: 10px 18px;
    border-radius: var(--r-sm);
    text-decoration: none;
    transition: top 0.25s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- Navigation ---------- */
#navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: color-mix(in srgb, var(--paper) 78%, transparent);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid transparent;
    padding: 18px 0;
    z-index: 1000;
    transition: border-color 0.3s var(--ease), padding 0.3s var(--ease);
}

#navbar.scrolled {
    border-bottom-color: var(--line);
    padding: 12px 0;
}


.nav-container {
    max-width: 1060px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-family: 'Rimba Andalas', 'Finger Paint', var(--display), sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--logo-j);
    text-decoration: none;
    letter-spacing: 0.01em;
}

.logo-j { color: var(--logo-j); }
.logo-h { color: var(--logo-h); }
.nav-logo:hover .logo-j { color: var(--logo-j-hover); }
.nav-logo:hover .logo-h { color: var(--logo-h-hover); }

.nav-links {
    display: flex;
    gap: 34px;
    list-style: none;
    align-items: center;
}

.nav-links a {
    font-family: var(--mono);
    color: var(--nav-link);
    text-decoration: none;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    font-weight: 450;
    transition: color 0.2s var(--ease), font-weight 0.2s var(--ease);
    position: relative;
    padding: 8px 0;
}

.nav-links a::before {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--rust);
    transition: width 0.25s var(--ease);
}

.nav-links a:hover { color: var(--nav-link-hover); font-weight: 650; }
.nav-links a:hover::before { width: 100%; }
.nav-links a.active { color: var(--steel); font-weight: 650; }
.nav-links a.active::before { width: 100%; }

/* ---------- Chat launcher & widget (Popover API) ---------- */
.chatbot-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 58px;
    height: 58px;
    background: var(--steel);
    color: var(--card);
    border: 1px solid var(--steel-deep);
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.55;
    transition: background 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s var(--ease);
    z-index: 9999;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-button[hidden] { display: none; }

.chatbot-button:hover,
.chatbot-button:focus-visible {
    background: var(--steel-deep);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    opacity: 1;
}

.chatbot-icon { width: 28px; height: 28px; }

/* The widget is a manual popover: it lives in the top layer, so no z-index
   juggling, and the browser owns show/hide state. */
.chatbot-widget[popover] {
    position: fixed;
    inset: auto;
    bottom: 96px;
    right: 30px;
    margin: 0;
    padding: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: min(550px, calc(100vh - 130px));
    background: var(--card);
    color: var(--ink);
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.chatbot-widget:popover-open {
    opacity: 1;
    transform: translateY(0);
}

/* A closed popover must not take up space or catch clicks. The display:flex
   above would otherwise override the browser's own hiding rule. */
.chatbot-widget[popover]:not(:popover-open) { display: none; }

/* A little glass on the widget frame. Bubbles, chips and the input stay
   opaque, so no text ever sits on a translucent surface; only the frame
   and the gaps between bubbles let the page show through. */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .chatbot-widget[popover] {
        background: color-mix(in srgb, var(--card) 84%, transparent);
        -webkit-backdrop-filter: blur(18px) saturate(1.15);
        backdrop-filter: blur(18px) saturate(1.15);
    }
    .chatbot-widget[popover] .chatbot-header {
        background: color-mix(in srgb, var(--card) 40%, transparent);
    }
}
html[data-contrast="high"] .chatbot-widget[popover] { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
html[data-contrast="high"] .chatbot-widget[popover] .chatbot-header { background: var(--card); }
@media (prefers-contrast: more) {
    html:not([data-contrast]) .chatbot-widget[popover] { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
    html:not([data-contrast]) .chatbot-widget[popover] .chatbot-header { background: var(--card); }
}
@media (prefers-reduced-transparency: reduce) {
    .chatbot-widget[popover] { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
    .chatbot-widget[popover] .chatbot-header { background: var(--card); }
}

@supports (transition-behavior: allow-discrete) {
    .chatbot-widget[popover] {
        transition: opacity 0.25s var(--ease), transform 0.25s var(--ease),
                    overlay 0.25s allow-discrete, display 0.25s allow-discrete;
    }
    @starting-style {
        .chatbot-widget:popover-open {
            opacity: 0;
            transform: translateY(12px);
        }
    }
}

.chatbot-header {
    background: var(--card);
    padding: 14px 14px 10px;
    color: var(--ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    height: 52px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--line);
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.chatbot-close {
    background: none;
    border: none;
    color: var(--ink-soft);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.chatbot-close:hover { background: var(--paper); color: var(--ink); }

/* One-line disclosure strip under the header: what this widget is */
.chat-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
    background: var(--paper);
    flex-shrink: 0;
}
.chat-notice::before {
    content: '';
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rust);
}

.chatbot-iframe {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: none;
    background: var(--card);
}

.chatbot-iframe[hidden] { display: none; }

.chatbot-faq {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
}

.chat-bubble {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.86rem;
    line-height: 1.5;
}

.chat-bubble.bot {
    background: var(--paper);
    border-bottom-left-radius: 3px;
    align-self: flex-start;
    color: var(--ink);
}

.chat-bubble.user {
    background: light-dark(#34596E, #35586F);
    color: #F2F1EC;
    border-bottom-right-radius: 3px;
    align-self: flex-end;
}

.chat-bubble a { color: var(--steel); font-weight: 600; }
.chat-bubble.bot a:hover { color: var(--steel-deep); }

/* System bubbles: the widget talking about itself, not Joshua answering */
.chat-bubble.system {
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.02em;
    color: var(--ink-soft);
    background: transparent;
    padding: 2px 4px;
    max-width: 100%;
}

/* Source + confidence under an answer: one quiet mono line */
.chat-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    margin-top: 7px;
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
}

.chat-conf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
/* Confidence is encoded by the mark, not by a number:
   direct = filled dot, summary = hollow dot, outside = dashed rust dot */
.chat-conf::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    box-sizing: border-box;
}
.chat-conf-direct  { color: var(--steel); }
.chat-conf-direct::before  { background: var(--steel); }
.chat-conf-summary { color: var(--steel); }
.chat-conf-summary::before { border: 1.5px solid var(--steel); }
.chat-conf-outside { color: var(--rust-text); }
.chat-conf-outside::before { border: 1.5px dashed var(--rust); }

.chat-source { color: var(--ink-soft); text-decoration: none; font-weight: 450; }
a.chat-source { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
a.chat-source:hover { color: var(--steel); font-weight: 650; }

.chat-handoff { color: var(--steel); font-weight: 600; }

/* Status line while an answer is fetched: says where, not a spinner */
.chat-status {
    align-self: flex-start;
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    padding: 2px 4px;
}
.chat-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--rust);
    animation: chat-pulse 0.9s ease-in-out infinite alternate;
}
@keyframes chat-pulse { from { opacity: 0.3; } to { opacity: 1; } }

/* Autonomy dial in the header, same segmented style as the comfort panel */
.chat-mode {
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    overflow: hidden;
    margin-left: auto;
    background: var(--paper);
}
.chat-mode-opt { position: relative; }
.chat-mode-opt + .chat-mode-opt { border-left: 1px solid var(--line); }
.chat-mode-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chat-mode-opt span {
    display: block;
    padding: 5px 10px;
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.chat-mode-opt input:hover + span { color: var(--steel); }
.chat-mode-opt input:checked + span { background: var(--steel); color: var(--card); }
.chat-mode-opt input:focus-visible + span { outline: 2px solid var(--steel); outline-offset: -2px; }
.chat-mode-opt.is-disabled span { opacity: 0.4; cursor: not-allowed; }
.chat-mode-opt.is-disabled input { cursor: not-allowed; }

/* Free-text ask: one pill with the send arrow inside */
.chat-ask {
    flex-shrink: 0;
    position: relative;
    padding: 8px 12px 0;
    border-top: 1px solid var(--line);
}
.chat-ask-input {
    width: 100%;
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 40px 8px 14px;
}
.chat-ask-input::placeholder { color: var(--ink-soft); }
.chat-ask-input:focus-visible { outline: none; border-color: var(--steel); box-shadow: 0 0 0 1px var(--steel); }
.chat-ask-send {
    position: absolute;
    right: 16px;
    top: 12px;
    width: 28px;
    height: 28px;
    background: var(--steel);
    color: var(--card);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}
.chat-ask-send:hover { background: var(--steel-deep); }
.chat-ask-input:placeholder-shown + .chat-ask-send { opacity: 0.55; }

/* Question chips: a scrollable rail, one row, with a fade at the end */
/* Question chips wrap into rows, so every chip is a click away with a
   mouse as well as a trackpad. (A single sideways-scrolling row only
   works where horizontal scroll is easy.) Capped at ~3 rows; beyond that
   the row itself scrolls vertically. */
.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px 12px;
    flex-shrink: 0;
    max-height: 184px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.chat-chips:empty { display: none; }

.chat-chip {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.02em;
    padding: 6px 11px;
    background: var(--card);
    color: var(--steel);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    font-weight: 450;
    white-space: nowrap;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease), font-weight 0.15s var(--ease);
}
.chat-chip:last-child { margin-right: 20px; }

.chat-chip:hover {
    border-color: var(--steel);
    background: var(--steel);
    color: var(--card);
    font-weight: 650;
}

/* ---------- Project dialog (<dialog>) ---------- */
dialog.project-modal {
    margin: auto; /* the global reset zeroes the UA's centering margin */
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--card);
    color: var(--ink);
    padding: 0;
    width: min(800px, 90vw);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

dialog.project-modal[open] {
    opacity: 1;
    transform: scale(1);
}

/* Backdrop: a light blur behind the dialog. This is glass on chrome, not
   under text: the dialog itself stays opaque, only the page behind it
   softens. The blur does the separation work, so the tint can be lighter.
   Opaque dim instead when the visitor asks for high contrast or reduced
   transparency, or when the browser can't blur. */
dialog.project-modal::backdrop {
    background: rgba(36, 39, 43, 0.55);
    opacity: 0;
    transition: opacity 0.25s var(--ease);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    dialog.project-modal::backdrop {
        background: light-dark(rgba(36, 39, 43, 0.32), rgba(0, 0, 0, 0.45));
        -webkit-backdrop-filter: blur(7px) saturate(0.85);
        backdrop-filter: blur(7px) saturate(0.85);
    }
}

html[data-contrast="high"] dialog.project-modal::backdrop {
    background: light-dark(rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.85));
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}
@media (prefers-contrast: more) {
    html:not([data-contrast]) dialog.project-modal::backdrop {
        background: light-dark(rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.85));
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}
@media (prefers-reduced-transparency: reduce) {
    dialog.project-modal::backdrop {
        background: rgba(36, 39, 43, 0.62);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

dialog.project-modal[open]::backdrop { opacity: 1; }

@supports (transition-behavior: allow-discrete) {
    dialog.project-modal {
        transition: opacity 0.25s var(--ease), transform 0.25s var(--ease),
                    overlay 0.25s allow-discrete, display 0.25s allow-discrete;
    }
    dialog.project-modal::backdrop {
        transition: opacity 0.25s var(--ease),
                    overlay 0.25s allow-discrete, display 0.25s allow-discrete;
    }
    @starting-style {
        dialog.project-modal[open] { opacity: 0; transform: scale(0.97); }
        dialog.project-modal[open]::backdrop { opacity: 0; }
    }
}

/* View Transitions for the project dialog (projects.js sets data-vt on
   <html> for the duration). 220ms morph; 120ms crossfade under reduced
   motion. Pseudo-elements aren't matched by the global motion rules, so
   the durations are set here explicitly. */
::view-transition-group(*),
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 220ms;
    animation-timing-function: var(--ease);
}

/* Keep the travelling title's own aspect; crossfade old/new in place */
::view-transition-old(project-title),
::view-transition-new(project-title) {
    height: 100%;
    width: auto;
}

:root[data-vt="fade"]::view-transition-old(root),
:root[data-vt="fade"]::view-transition-new(root) {
    animation-duration: 120ms;
    animation-timing-function: ease;
}

/* Lock page scroll while a project is open */
body:has(dialog.project-modal[open]) { overflow: hidden; }

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease);
    z-index: 10;
}

.modal-close:hover { background: var(--steel); border-color: var(--steel); color: var(--card); }

.modal-body { padding: 48px 44px; }

.modal-title {
    font-family: var(--display);
    font-stretch: 108%;
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
    line-height: 1.2;
    padding-right: 48px;
}

.modal-subtitle {
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    color: var(--ink-soft);
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.modal-section { margin-bottom: 28px; }

.modal-section h4 {
    font-family: var(--mono);
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--steel);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-section h4::before {
    content: '';
    width: 14px;
    height: 2px;
    background: var(--rust);
}

.modal-section p { color: var(--ink); line-height: 1.75; margin-bottom: 12px; }
.modal-section ul { list-style: none; padding-left: 0; }
.modal-section li {
    padding-left: 22px;
    margin-bottom: 9px;
    position: relative;
    color: var(--ink);
    line-height: 1.6;
}

.modal-section li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--rust);
}

.modal-note {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--ink-soft);
    margin-top: 10px;
}

.modal-linkedin {
    width: 100%;
    max-width: 504px;
    height: 560px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--card);
}

.modal-linkedin iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Diagram under the overview */
.modal-figure { margin: 0 0 28px; }
.modal-figure-link { display: block; transition: opacity 0.15s var(--ease); }
.modal-figure-link:hover { opacity: 0.92; }
.modal-figure-img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: #fff; /* the diagram has a white ground; keep it so in dark mode */
}
.modal-figure-cap {
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--ink-soft);
}

.modal-poster-link { display: block; transition: opacity 0.15s var(--ease); }
.modal-poster-link:hover { opacity: 0.92; }

/* The figure and poster are buttons that open the full view */
button.modal-figure-link, button.modal-poster-link {
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: zoom-in;
    border-radius: var(--r-sm);
}
button.modal-figure-link:focus-visible, button.modal-poster-link:focus-visible {
    outline: 2px solid var(--steel);
    outline-offset: 3px;
}

/* ---------- Lightbox: full-view overlay for the poster / diagram ----------
   A second <dialog> stacked on the project dialog. Fit-to-screen first;
   one click (or the 1:1 button) switches to actual pixels, scrollable. */
dialog.lightbox {
    margin: 0;
    padding: 0;
    border: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    background: light-dark(rgba(242, 241, 236, 0.97), rgba(24, 25, 28, 0.97));
    color: var(--ink);
    opacity: 0;
    transition: opacity 0.2s var(--ease);
}
dialog.lightbox[open] {
    display: grid;
    grid-template-rows: auto 1fr;
    opacity: 1;
}
dialog.lightbox::backdrop { background: rgba(0, 0, 0, 0.55); }
@supports (transition-behavior: allow-discrete) {
    dialog.lightbox {
        transition: opacity 0.2s var(--ease), overlay 0.2s allow-discrete, display 0.2s allow-discrete;
    }
    @starting-style {
        dialog.lightbox[open] { opacity: 0; }
    }
}

.lightbox-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.lightbox-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lightbox-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease);
}
.lightbox-btn:hover { border-color: var(--steel); color: var(--steel-deep); }
.lightbox-btn:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }
.lightbox-zoom[aria-pressed="true"] { background: var(--steel); border-color: var(--steel); color: var(--card); }
.lightbox-close { width: 36px; padding: 0; font-size: 1.25rem; letter-spacing: 0; line-height: 1; }

.lightbox-stage {
    display: flex;            /* flex + margin:auto centres a small image and
                                 still scrolls to the corners of a large one */
    overflow: auto;
    min-height: 0;
    padding: 14px;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
}
.lightbox-img {
    display: block;
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: #fff;
    box-shadow: var(--shadow-lg);
    cursor: zoom-in;
}
dialog.lightbox.is-full .lightbox-img {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}
html[data-motion="off"] dialog.lightbox, html[data-motion="reduced"] dialog.lightbox { transition: none; }
@media (max-width: 480px) {
    .lightbox-title { display: none; }
    .lightbox-bar { justify-content: flex-end; }
}

.modal-poster {
    width: 100%;
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}

.modal-video {
    position: relative;
    aspect-ratio: 16 / 9;
    margin-bottom: 12px;
    border-radius: var(--r-sm);
    overflow: hidden;
    border: 1px solid var(--line);
    background: #000;
}

.modal-video iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.modal-tech { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-tech-tag {
    font-family: var(--mono);
    background: var(--paper);
    color: var(--ink-soft);
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-size: 0.8rem;
    border: 1px solid var(--line);
}

.modal-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.modal-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    color: var(--steel);
    padding: 9px 18px;
    border-radius: var(--r-sm);
    text-decoration: none;
    border: 1px solid var(--steel);
    transition: all 0.2s var(--ease);
    font-weight: 500;
    font-size: 0.95rem;
}

.modal-link:hover { background: var(--steel); color: var(--card); }
.modal-link svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Buttons shared across pages ---------- */
.read-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--steel);
    color: var(--card);
    padding: 13px 28px;
    border-radius: var(--r-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.read-more-btn:hover { background: var(--steel-deep); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* The one emphasized action per page: bigger, filled, on an instrument
   surface with tick rules top and bottom. Everything else on the page stays
   outlined or text-only. */
.cta-well {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 20px 28px;
    padding: 26px 28px;
    text-align: left;
    background:
        radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--steel) 14%, transparent), transparent 55%),
        var(--card);
    border: 1px solid color-mix(in srgb, var(--steel) 30%, var(--line));
    border-radius: var(--r-md);
}

.cta-well.centered { grid-template-columns: 1fr; justify-items: center; text-align: center; }

.cta-well p {
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 14px;
}
.cta-well .read-more-btn + .read-more-btn { margin-left: 12px; }

/* Readout: a counted number set like a dial reading, with category links */
.cta-stat { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.cta-stat-n {
    font-family: var(--display);
    font-stretch: 115%;
    font-weight: 700;
    font-size: 2.6rem;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}
.cta-stat-l {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    line-height: 1.55;
}

.read-more-btn.primary {
    padding: 16px 32px;
    font-size: 1.05rem;
    font-weight: 650;
    border-radius: var(--r-md);
    box-shadow: inset 0 1px 0 color-mix(in srgb, white 18%, transparent), 0 1px 2px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
}
.read-more-btn.primary svg { width: 20px; height: 20px; transition: transform 0.2s var(--ease); }
.read-more-btn.primary:hover { box-shadow: inset 0 1px 0 color-mix(in srgb, white 22%, transparent), 0 4px 14px color-mix(in srgb, var(--steel) 35%, transparent); }
.read-more-btn.primary:hover svg { transform: translateX(3px); }

/* Glass version of the primary button. The steel tint stays high (84%) so
   the label keeps its contrast; the blur and the edge highlight do the
   glass work. Solid again under high contrast or reduced transparency. */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    .read-more-btn.primary {
        background: color-mix(in srgb, var(--steel) 84%, transparent);
        -webkit-backdrop-filter: blur(14px) saturate(1.3);
        backdrop-filter: blur(14px) saturate(1.3);
        border: 1px solid color-mix(in srgb, white 28%, transparent);
        box-shadow:
            inset 0 1px 0 color-mix(in srgb, white 30%, transparent),
            inset 0 -1px 0 color-mix(in srgb, black 12%, transparent),
            0 2px 6px rgba(0, 0, 0, 0.14);
        transition: background 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
    }
    .read-more-btn.primary:hover {
        background: color-mix(in srgb, var(--steel) 92%, transparent);
        box-shadow:
            inset 0 1px 0 color-mix(in srgb, white 34%, transparent),
            inset 0 -1px 0 color-mix(in srgb, black 12%, transparent),
            0 6px 18px color-mix(in srgb, var(--steel) 38%, transparent);
    }
}
html[data-contrast="high"] .read-more-btn.primary,
html[data-contrast="high"] .read-more-btn.primary:hover {
    background: var(--steel);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-color: var(--steel);
}
@media (prefers-contrast: more) {
    html:not([data-contrast]) .read-more-btn.primary,
    html:not([data-contrast]) .read-more-btn.primary:hover { background: var(--steel); -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--steel); }
}
@media (prefers-reduced-transparency: reduce) {
    .read-more-btn.primary,
    .read-more-btn.primary:hover { background: var(--steel); -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--steel); }
}

@media (max-width: 640px) {
    .cta-well { grid-template-columns: 1fr; justify-items: start; padding: 24px 20px; }
    .cta-well .read-more-btn.primary { width: 100%; justify-content: center; }
}

/* ---------- Button tiers ----------
   Primary   .read-more-btn.primary   filled glass, one per page
   Secondary .read-more-btn.outline, .view-details-btn, .view-btn
             tinted at rest (8% steel), solid on hover
   Tertiary  text with an arrow: .timeline-link, .back-link, .comfort-why
   Arrows: → navigates within the site, ↗ leaves it, none for a dialog. */
.read-more-btn.outline,
.view-details-btn,
.view-btn {
    background: color-mix(in srgb, var(--steel) 8%, transparent);
    color: var(--steel);
    border: 1px solid color-mix(in srgb, var(--steel) 45%, var(--line));
    transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.read-more-btn.outline { margin-left: 12px; }
.read-more-btn.outline:hover,
.view-details-btn:hover,
.view-btn:hover,
.tech-project-card:hover .view-details-btn,
.project-card:hover .view-btn {
    background: var(--steel);
    border-color: var(--steel);
    color: var(--card);
}
.read-more-btn.outline:hover { transform: translateY(-2px); }
.read-more-btn svg { width: 18px; height: 18px; }

/* External secondary buttons carry ↗ (Substack, Photography, résumé) */
.read-more-btn.outline[target="_blank"]::after { content: '\2197'; font-family: var(--mono); font-size: 0.9em; margin-left: 2px; }

/* Small secondary: the "View details" button on both project pages.
   No arrow: it opens a dialog, it doesn't go anywhere. */
.view-details-btn,
.view-btn {
    position: relative;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--r-sm);
    padding: 7px 14px;
    font-family: var(--mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}

/* ---------- Footer ---------- */
footer {
    text-align: center;
    padding: 24px 20px 20px;
    color: var(--ink-soft);
    border-top: 1px solid var(--line);
    margin-top: 24px;
    font-size: 0.95rem;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-bottom: 20px; /* room for the labels */
}

.contact-btn {
    background: var(--card);
    color: var(--steel);
    padding: 14px;
    border-radius: 50%;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s var(--ease);
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    cursor: pointer;
}

.contact-btn svg { width: 22px; height: 22px; }

.contact-btn:hover {
    background: var(--steel);
    border-color: var(--steel);
    color: var(--card);
    transform: translateY(-2px);
}

/* Label under each circle, taken from its aria-label. Shown on hover and
   keyboard focus; always shown where there is no hover (touch). */
.contact-btn::after {
    content: attr(aria-label);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink-soft);
    opacity: 0;
    transition: opacity 0.15s var(--ease);
    pointer-events: none;
}
.contact-btn:hover::after,
.contact-btn:focus-visible::after { opacity: 1; }
@media (hover: none) { .contact-btn::after { opacity: 1; } }

.footer-line {
    display: flex;
    justify-content: center;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0 10px;
}
.footer-line a {
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: var(--steel);
    text-decoration: none;
    font-weight: 450;
    transition: color 0.15s var(--ease), font-weight 0.15s var(--ease);
}
.footer-line a:hover { color: var(--steel-deep); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.footer-line a[aria-current="page"] { color: var(--ink-soft); pointer-events: none; }
.footer-sep { color: var(--rust); }

.footer-scene {
    display: block;
    margin: 0 auto 8px;
    opacity: 0.9;
    image-rendering: pixelated;
}

.footer-love {
    position: relative;
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--ink-soft);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.footer-love .heart-glyph {
    display: inline-block;
    color: var(--rust);
    transition: transform 0.2s var(--ease);
}

.footer-love:hover .heart-glyph { transform: scale(1.35); }
.footer-love.is-raining .heart-glyph { color: var(--steel); }
.heart-stop { margin-left: 4px; color: var(--steel); font-weight: 650; }
.heart-stop[hidden] { display: none; }

/* Static burst for reduced / off motion: three hearts, no travel */
.heart-burst {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    gap: 6px;
    line-height: 1;
    pointer-events: none;
}

/* Pixel walker in the footer scene (index). Parked by the cactus unless walking. */
.footer-walker {
    transform: translateX(136px);
    cursor: pointer;
}
.footer-walker.walking { animation: walk 4.5s linear forwards; }
.footer-walker .fb { display: none; }
.footer-walker.walking .fa { animation: stride 0.5s steps(1, end) infinite; }
.footer-walker.walking .fb { display: block; animation: stride 0.5s steps(1, end) infinite reverse; }
@keyframes walk { from { transform: translateX(0); } to { transform: translateX(136px); } }
@keyframes stride { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* ---------- Easter egg: heart rain ---------- */
.heart-rain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 9997;
}

.heart-rain .hf {
    position: absolute;
    top: -6vh;
    left: var(--x);
    animation: hf-fall var(--d) linear var(--delay) forwards;
    will-change: transform;
}

.heart-rain .hf > span {
    display: block;
    font-size: var(--s);
    color: var(--c);
    opacity: 0.9;
    animation: hf-sway var(--w) ease-in-out infinite alternate;
}

@keyframes hf-fall {
    to { transform: translateY(118vh) rotate(var(--r)); }
}

@keyframes hf-sway {
    from { transform: translateX(calc(var(--a) * -1)); }
    to { transform: translateX(var(--a)); }
}

/* ---------- Shared animations ---------- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .nav-container { padding: 0 30px; }
}

@media (max-width: 768px) {
    .nav-container { padding: 0 20px; }
    .nav-logo { font-size: 1.1rem; }
    /* No mobile menu: the four short links sit in a compact row */
    .nav-links { gap: 12px; }
    .nav-links a { font-size: 0.72rem; letter-spacing: 0.02em; padding: 8px 0; }

    .chatbot-button { width: 54px; height: 54px; bottom: 20px; right: 20px; }
    .chatbot-widget[popover] {
        width: calc(100vw - 30px);
        right: 15px;
        bottom: 88px;
        height: min(70vh, calc(100vh - 120px));
    }

    .modal-body { padding: 30px 20px; }
}

@media (max-width: 480px) {
    .nav-container { padding: 0 15px; }
    .chatbot-button { width: 52px; height: 52px; bottom: 15px; right: 15px; }
    .chatbot-icon { width: 24px; height: 24px; }
    .contact-links { gap: 12px; }
    .contact-btn { width: 48px; height: 48px; padding: 12px; }
    footer { padding: 20px 15px 16px; }
}

@media (max-width: 360px) {
    .nav-links { gap: 10px; }
    .nav-links a { font-size: 0.66rem; }
}

@media (hover: none) and (pointer: coarse) {
    .nav-links a,
    .contact-btn,
    .read-more-btn,
    .modal-link {
        -webkit-tap-highlight-color: rgba(52, 89, 110, 0.15);
    }

    .nav-links a { padding: 15px 0; }
    .contact-btn { min-width: 48px; min-height: 48px; }
}

@media (max-width: 768px) and (orientation: landscape) {
    .chatbot-widget[popover] { height: calc(100vh - 110px); }
}

/* ---------- Motion modes ----------
   Set by the comfort panel as data-motion on <html>:
     full     everything as designed
     reduced  no keyframe animation (entrances, drifts, the ruler draw, heart
              rain); brief state transitions stay, since they signal state
     off      nothing moves at all
   When the visitor hasn't chosen, the OS preference decides. */
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
}

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
    animation: none !important;
    transition: none !important;
}
html[data-motion="off"] { scroll-behavior: auto; }

@media (prefers-reduced-motion: reduce) {
    html:not([data-motion]) *,
    html:not([data-motion]) *::before,
    html:not([data-motion]) *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html:not([data-motion]) { scroll-behavior: auto; }
}

/* ---------- Comfort panel ----------
   A small instrument strip, bottom-left, mirroring the chat launcher.
   Lets the visitor set motion, contrast and theme; comfort.js persists it. */
.comfort-button {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 46px;
    height: 46px;
    background: var(--card);
    color: var(--steel);
    border: 1px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.7;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: opacity 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.comfort-button:hover,
.comfort-button:focus-visible,
.comfort-button[aria-expanded="true"] {
    opacity: 1;
    border-color: var(--steel);
    transform: translateY(-2px);
}

.comfort-button svg { width: 20px; height: 20px; }

.comfort-panel[popover] {
    position: fixed;
    inset: auto;
    bottom: 86px;
    left: 30px;
    margin: 0;
    padding: 0;
    width: min(300px, calc(100vw - 30px));
    background: var(--card);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--mono);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.comfort-panel:popover-open { opacity: 1; transform: translateY(0); }

@supports (transition-behavior: allow-discrete) {
    .comfort-panel[popover] {
        transition: opacity 0.2s var(--ease), transform 0.2s var(--ease),
                    overlay 0.2s allow-discrete, display 0.2s allow-discrete;
    }
    @starting-style {
        .comfort-panel:popover-open { opacity: 0; transform: translateY(8px); }
    }
}

.comfort-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--line);
}

.comfort-title {
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.comfort-reset {
    background: none;
    border: none;
    padding: 0;
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    color: var(--steel);
    cursor: pointer;
}
.comfort-reset:hover { text-decoration: underline; text-underline-offset: 3px; }

.comfort-row {
    border: 0;
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    gap: 10px;
}
.comfort-row + .comfort-row { border-top: 1px solid var(--line); }

.comfort-row legend {
    float: left; /* keeps the legend inside the grid cell */
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rust-text);
    padding: 0;
}

.comfort-seg {
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--paper);
}

.comfort-seg label { flex: 1; position: relative; }
.comfort-seg label + label { border-left: 1px solid var(--line); }

.comfort-seg input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.comfort-seg span {
    display: block;
    text-align: center;
    padding: 6px 4px;
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.comfort-seg input:hover + span { color: var(--steel); }
.comfort-seg input:checked + span { background: var(--steel); color: var(--card); }
.comfort-seg input:focus-visible + span { outline: 2px solid var(--steel); outline-offset: -2px; }

.comfort-why {
    display: block;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--line);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    color: var(--steel);
    text-decoration: none;
}
.comfort-why::after { content: ' \2192'; }
.comfort-why:hover { text-decoration: underline; text-underline-offset: 3px; font-weight: 650; }
.comfort-why, .comfort-reset { font-weight: 450; transition: font-weight 0.15s var(--ease); }
.comfort-reset:hover { font-weight: 650; }

@media (max-width: 768px) {
    .comfort-button { width: 44px; height: 44px; bottom: 20px; left: 20px; }
    .comfort-panel[popover] { left: 15px; bottom: 76px; }
}

@media (max-width: 480px) {
    .comfort-button { bottom: 15px; left: 15px; }
}

/* ---------- Press state (all tiers) ----------
   Hover is absent on touch; :active gives every control a tap response:
   a slight scale and darker fill over 80ms. */
.read-more-btn:active, .view-details-btn:active, .view-btn:active, .contact-btn:active,
.chat-chip:active, .filter-btn:active, .timeline-step:active, .modal-link:active,
.modal-close:active, .chatbot-close:active, .comfort-button:active, .chatbot-button:active,
.timeline-year-label:active, .chat-ask-send:active, .comfort-reset:active,
.timeline-marker:active, .footer-love:active, .edu-toggle:active, .timeline-readmore:active {
    transform: scale(0.97);
    filter: brightness(0.94);
    transition-duration: 80ms;
}
.tech-project-card:active, .project-card:active { transform: scale(0.99); transition-duration: 80ms; }
html[data-theme="dark"] .read-more-btn:active,
html[data-theme="dark"] .contact-btn:active { filter: brightness(1.08); }

/* ---------- Hit targets ----------
   Visual sizes stay; the tappable area grows toward 44px with a pseudo-
   element. ::before is taken by the focus brackets on most controls, so the
   hit area uses whichever pseudo-element is free on each selector. */
.view-details-btn::after, .view-btn::after, .chat-chip::after, .filter-btn::after,
.timeline-step::after, .timeline-year-label::after, .footer-love::after,
.comfort-reset::after, .chat-ask-send::after, .chatbot-close::after, .modal-close::after,
.nav-links a::after, .footer-line a::after {
    content: '';
    position: absolute;
    inset: -6px;
}
.chat-chip::after { inset: -9px -4px; }
.timeline-step::after { inset: -8px; }
.timeline-year-label { position: relative; }
.timeline-year-label::after { inset: -8px -6px; }
.footer-love::after { inset: -10px -8px; }
.comfort-reset { position: relative; }
.comfort-reset::after { inset: -10px -6px; }
.chat-ask-send::after { inset: -8px; } /* stays position:absolute inside the input */
.chatbot-close::after { inset: -8px; }
.footer-line a { position: relative; }
.footer-line a::after { inset: -10px -4px; }
.nav-links a::after { inset: -8px -6px; }
.timeline-link, .edu-toggle, .timeline-readmore { position: relative; }
.timeline-link::before, .edu-toggle::before, .timeline-readmore::before {
    content: '';
    position: absolute;
    inset: -10px -6px;
}
