/* Shared styles for every page with the top bar: /, /about/, /contact/, /project/*.
   Direction: clean engineering portfolio. Soft grey paper, ink, one blue, amber only on line work.
   Motion: one-shot entrances and scroll reveals; nothing loops. */

:root {
    color-scheme: light;
    /* Soft cool grey page instead of pure white (less glare); cards sit a step lighter */
    --bg: #f2f4f7;
    --surface: #e8ecf1;
    --raised: #fafbfc;
    --text: #0e1726;
    --muted: #475161;
    --border: #d5dce5;
    --primary: #1f4fd1;
    --primary-strong: #173da6;
    --primary-soft: #e1e8fa;
    --on-primary: #ffffff;
    --accent: #9a6a00; /* strokes only, never text */
    --field: #747d8c;  /* input borders, 3:1 against surface */
    --danger: #b42318;
    --shadow: 0 1px 2px rgba(14, 23, 38, .05), 0 8px 24px rgba(14, 23, 38, .06);
    --shadow-lift: 0 2px 4px rgba(14, 23, 38, .06), 0 16px 40px rgba(14, 23, 38, .10);
    --display: "Iceland", "IBM Plex Sans", sans-serif;
    --sans: "IBM Plex Sans", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --wrap: 70rem;
}
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1017;
    --surface: #121a24;
    --raised: #16202c;
    --text: #e7ebf1;
    --muted: #9aa6b4;
    --border: #222d3b;
    --primary: #82b1f2;
    --primary-strong: #a9c9f7;
    --primary-soft: #16263d;
    --on-primary: #0b1017;
    --accent: #f2c230;
    --field: #6f7c8e;
    --danger: #ff8f85;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lift: 0 12px 32px rgba(0, 0, 0, .45);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 400 1.0625rem/1.65 var(--sans);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s, color .2s;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
a[href], button, summary, label[for] { cursor: pointer; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--primary); color: var(--on-primary); }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }
@media (min-width: 640px) { .wrap { padding: 0 2rem; } }

.display { font-family: var(--display); font-weight: 400; line-height: .95; letter-spacing: .01em; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.skip {
    position: absolute; left: 1rem; top: -4rem; z-index: 100;
    background: var(--primary); color: var(--on-primary); padding: .6rem 1rem; text-decoration: none; border-radius: 6px;
}
.skip:focus { top: .5rem; }

/* ---------- Top bar (the only translucent surface) ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s, background-color .2s;
}
.topbar.scrolled, .topbar:has(.menu-panel.open) { border-bottom-color: var(--border); }
.topbar-inner { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wordmark {
    font-family: var(--display); font-size: 1.85rem; line-height: 1;
    text-decoration: none; display: inline-flex; align-items: center; min-height: 44px;
}
.wordmark:hover { color: var(--primary); }
.nav { display: flex; align-items: center; gap: .25rem; }
.nav-links { display: none; align-items: center; gap: .15rem; }
.nav-links a {
    position: relative; text-decoration: none; font-weight: 600; font-size: .95rem; color: var(--muted);
    padding: 0 .8rem; min-height: 44px; display: inline-flex; align-items: center; border-radius: 6px;
    transition: color .15s;
}
.nav-links a::after {
    content: ""; position: absolute; left: .8rem; right: .8rem; bottom: 8px; height: 2px;
    background: var(--primary); transform: scaleX(0); transform-origin: left; transition: transform .25s var(--ease);
}
.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after, .nav-links a[aria-current]::after { transform: scaleX(1); }
.nav-links a[aria-current] { color: var(--text); }
.icon-btn {
    width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid transparent; transition: background-color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-btn svg { transition: transform .4s var(--ease); }
.theme-btn:hover svg { transform: rotate(-20deg); }
.theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: block; }
.menu-panel { display: none; border-top: 1px solid var(--border); background: var(--bg); }
.menu-panel.open { display: block; animation: drop .25s var(--ease); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.menu-panel a {
    display: flex; align-items: center; min-height: 52px; padding: 0 1.25rem;
    text-decoration: none; font-weight: 600; border-bottom: 1px solid var(--border);
}
.menu-panel a:hover, .menu-panel a[aria-current] { color: var(--primary); background: var(--surface); }
@media (min-width: 640px) {
    .nav-links { display: flex; }
    .menu-btn { display: none; }
    .menu-panel, .menu-panel.open { display: none; }
}

/* ---------- Buttons and links ---------- */
.btn {
    display: inline-flex; align-items: center; gap: .6rem;
    min-height: 48px; padding: 0 1.35rem; border-radius: 8px;
    font-weight: 600; text-decoration: none;
    background: var(--primary); color: var(--on-primary); border: 1px solid var(--primary);
    transition: background-color .15s, border-color .15s, color .15s, transform .2s var(--ease), box-shadow .2s;
}
.btn:hover { background: var(--primary-strong); border-color: var(--primary-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn svg { width: 18px; height: 18px; transition: transform .2s var(--ease); }
.btn:hover svg.nudge { transform: translateX(3px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); border-color: var(--field); color: var(--text); }
.text-link {
    display: inline-flex; align-items: center; gap: .4rem; min-height: 44px;
    font-weight: 600; color: var(--primary); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}
.text-link:hover { text-decoration-thickness: 2px; }
.icon-link {
    width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; font-size: 1.1rem;
    transition: border-color .15s, color .15s, transform .2s var(--ease), background-color .15s;
}
.icon-link:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); transform: translateY(-2px); }

/* ---------- Motion system ---------- */
/* Scroll reveal: elements with data-reveal fade and rise once when they enter the viewport. */
.js [data-reveal] {
    opacity: 0; transform: translateY(22px);
    transition: opacity .8s var(--ease), transform .8s var(--ease);
    transition-delay: calc(var(--i, 0) * 90ms);
}
.js [data-reveal="left"] { transform: translateX(-28px); }
.js [data-reveal="scale"] { transform: scale(.96); }
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* Page-load entrance for hero content */
.enter { animation: rise .9s var(--ease) both; animation-delay: calc(var(--i, 0) * 110ms + 80ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.mask { display: block; overflow: hidden; padding-bottom: .06em; }
.mask > span { display: inline-block; animation: up 1s var(--ease) both; animation-delay: calc(var(--i, 0) * 110ms + 80ms); }
@keyframes up { from { transform: translateY(105%); } to { transform: none; } }

/* Section heading: amber rule draws in under the title when revealed */
.section-title { font-size: clamp(2.4rem, 6vw, 3.5rem); }
.section-head { display: grid; gap: .6rem; margin-bottom: 2.5rem; max-width: 40rem; }
.section-head .section-title::after {
    content: ""; display: block; width: 56px; height: 3px; margin-top: .9rem; background: var(--accent);
    transform: scaleX(1); transform-origin: left; transition: transform .9s var(--ease) .25s;
}
.js .section-head[data-reveal]:not(.is-in) .section-title::after { transform: scaleX(0); }
.kicker { font-family: var(--mono); font-size: .85rem; color: var(--primary); }

/* ---------- Landing hero ---------- */
.hero { padding: 3rem 0 3.5rem; overflow: hidden; }
.hero-grid { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 860px) {
    .hero { padding: 6rem 0 5.5rem; }
    .hero-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 3rem; }
}
.hero h1 { font-size: clamp(3.75rem, 12vw, 6.5rem); margin-top: .75rem; }
.lede { margin-top: 1.1rem; font-size: 1.2rem; max-width: 36ch; color: var(--muted); }
.hero-actions { margin-top: 2rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.hero-social { margin-top: 1.5rem; display: flex; gap: .5rem; }

/* The route: client, bot, firewall, server. One-shot draw-in. */
.route-card {
    position: relative; border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
    padding: 1.25rem; box-shadow: var(--shadow);
}
.route-card figcaption {
    display: flex; justify-content: space-between; gap: 1rem; font-family: var(--mono); font-size: .8rem; color: var(--muted);
    padding-bottom: .9rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border);
}
.route-card .ok { color: var(--primary); opacity: 0; animation: appear .4s ease-out 3.6s both; }
.route { width: 100%; height: auto; margin: 0 auto; }
.route .node rect, .route .node circle, .route .node path {
    stroke: var(--text); stroke-width: 1.5; fill: var(--raised); stroke-linejoin: round; stroke-linecap: round;
}
.route .node .detail { fill: none; }
.route .label { font: 400 12px var(--mono); fill: var(--muted); }
.route-line {
    stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; fill: none;
    stroke-dasharray: 1; stroke-dashoffset: 1;
    animation: draw 1.6s var(--ease) .2s both;
}
.route .node, .route .label { opacity: 0; animation: appear .45s ease-out both; }
.route .n1 { animation-delay: .2s; } .route .n2 { animation-delay: .7s; }
.route .n3 { animation-delay: 1.1s; } .route .n4 { animation-delay: 1.5s; }
.route .node .led { fill: var(--border); stroke: none; animation: on .3s linear both; }
.route .node .l1 { animation-delay: 2.1s; } .route .node .l2 { animation-delay: 2.3s; } .route .node .l3 { animation-delay: 2.5s; }
.route .packet {
    fill: var(--primary);
    offset-path: path("M76 268 H172 V170 H290 V92 H372");
    offset-distance: 0%; opacity: 0;
    animation: travel 1.4s ease-in-out 2.1s both;
}
.route .ping {
    fill: none; stroke: var(--primary); stroke-width: 2; opacity: 0;
    transform-box: fill-box; transform-origin: center;
    animation: ping 1s var(--ease) 3.45s both;
}
.route .node { transition: transform .25s var(--ease); transform-box: fill-box; transform-origin: center; }
.route .node:hover { transform: translateY(-3px); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes on { to { fill: var(--primary); } }
@keyframes travel {
    0% { opacity: 0; offset-distance: 0%; }
    8% { opacity: 1; }
    100% { opacity: 1; offset-distance: 100%; }
}
@keyframes ping { 0% { opacity: .9; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.5); } }

/* ---------- Sections ---------- */
.section { padding: 4.5rem 0; }
@media (min-width: 768px) { .section { padding: 6.5rem 0; } }
.section.alt { background: var(--surface); border-block: 1px solid var(--border); }

/* What I work on (landing): three items, each with its own small line drawing */
.focus-grid { display: grid; gap: 1rem; }
@media (min-width: 768px) { .focus-grid { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; } }
.focus {
    background: var(--raised); border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem;
    transition: border-color .2s, transform .3s var(--ease), box-shadow .3s;
}
.focus:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.focus svg { width: 56px; height: 56px; margin-bottom: 1.1rem; }
.focus h3 { font-size: 1.15rem; font-weight: 600; }
.focus p { margin-top: .35rem; color: var(--muted); font-size: .98rem; }
.glyph * { fill: none; stroke: var(--text); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.glyph .hl { stroke: var(--accent); stroke-width: 2; }
.glyph .draw { stroke-dasharray: 1; stroke-dashoffset: 0; }
.js [data-reveal]:not(.is-in) .glyph .draw { stroke-dashoffset: 1; }
.glyph .draw { transition: stroke-dashoffset 1.1s var(--ease) calc(var(--i, 0) * 90ms + .3s); }
.glyph .dot { fill: var(--border); stroke: none; transition: fill .3s; }
[data-reveal].is-in .glyph .dot { fill: var(--primary); }
[data-reveal].is-in .glyph .d1 { transition-delay: .9s; }
[data-reveal].is-in .glyph .d2 { transition-delay: 1.1s; }
[data-reveal].is-in .glyph .d3 { transition-delay: 1.3s; }
.glyph .gear { transform-box: fill-box; transform-origin: center; transition: transform 1.4s var(--ease) .4s; }
.js [data-reveal]:not(.is-in) .glyph .gear { transform: rotate(-120deg); }
.focus:hover .glyph .gear { transform: rotate(60deg); }

/* Tools list (landing) */
.tools-grid { display: grid; gap: 2rem; }
@media (min-width: 860px) { .tools-grid { grid-template-columns: 20rem 1fr; gap: 4rem; } .tools-grid .section-head { margin-bottom: 0; } }
.tool-list { border-top: 1px solid var(--border); }
.tool {
    position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem;
    padding: 1.15rem .75rem; border-bottom: 1px solid var(--border); text-decoration: none; isolation: isolate;
}
.tool::before {
    content: ""; position: absolute; inset: 0; z-index: -1; background: var(--surface);
    transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.tool:hover::before { transform: scaleX(1); }
.tool:hover .tool-name { color: var(--primary); }
.tool-name { font-weight: 600; font-size: 1.12rem; transition: color .15s; }
.tool-desc { color: var(--muted); font-size: .95rem; }
.tool-arrow { width: 22px; height: 22px; color: var(--primary); transition: transform .25s var(--ease); }
.tool:hover .tool-arrow { transform: translateX(5px); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 3.5rem 0 2.5rem; background: var(--surface); }
.footer-grid { display: grid; gap: 2rem; }
@media (min-width: 640px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.footer h2 { font-size: .9rem; font-weight: 600; color: var(--muted); margin-bottom: .5rem; }
.footer li a { display: inline-flex; align-items: center; min-height: 40px; text-decoration: none; }
.footer li a[aria-current] { color: var(--primary); font-weight: 600; }
.footer li a:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 4px; }
.footer .wordmark { font-size: 2.25rem; }

/* ---------- About ---------- */
.about-hero { padding: 3rem 0 4rem; overflow: hidden; }
@media (min-width: 860px) { .about-hero { padding: 6rem 0 6rem; } }
.about-grid { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 860px) { .about-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 4rem; } }
.about-hero h1 { font-size: clamp(3.75rem, 12vw, 6.5rem); }
.roles { margin-top: 1rem; font-family: var(--mono); font-size: 1.05rem; color: var(--primary); min-height: 1.7em; }
.roles .caret { display: inline-block; width: .55ch; height: 1.1em; vertical-align: -.15em; margin-left: 2px; background: var(--accent); }
.bio { margin-top: 1.25rem; font-size: 1.15rem; max-width: 52ch; color: var(--muted); }
.portrait {
    position: relative; justify-self: center; width: min(100%, 360px); aspect-ratio: 1;
}
/* Phones and tablets: profile first, then the text */
@media (max-width: 859px) {
    .about-grid .portrait { order: -1; width: min(72%, 260px); justify-self: start; }
}
/* Amber frame drawn once around the photo, with two ink corner ticks.
   No non-scaling-stroke: it broke the dash math and left the frame half drawn on phones. */
.portrait-frame { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
/* Each L stroke is about 118 units long; explicit dash length instead of pathLength, which some browsers ignore */
.portrait-frame .frame {
    fill: none; stroke: var(--accent); stroke-width: .6; stroke-linecap: round;
    stroke-dasharray: 120; stroke-dashoffset: 120; animation: draw 1.4s var(--ease) .4s both;
}
.portrait-frame .f2 { animation-delay: .7s; }
.portrait-frame .tick { fill: none; stroke: var(--text); stroke-width: .8; stroke-linecap: square; opacity: 0; animation: appear .5s ease-out 1.6s both; }
.portrait img.photo {
    position: absolute; inset: 7%; width: 86%; height: 86%; object-fit: cover; border-radius: 24px;
    box-shadow: var(--shadow-lift);
}
.portrait .mascot {
    position: absolute; right: -4%; bottom: -6%; width: 34%; height: auto;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .18)); transform-origin: bottom center;
    transition: transform .4s var(--ease);
}
.portrait:hover .mascot { transform: rotate(-6deg) translateY(-4px); }

/* Skills */
.skill-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
@media (min-width: 640px) { .skill-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .skill-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.skill {
    position: relative; display: flex; flex-direction: column; gap: .9rem;
    padding: 1.25rem; border: 1px solid var(--border); border-radius: 14px; background: var(--raised);
    transition: border-color .2s, transform .3s var(--ease), box-shadow .3s;
}
.skill:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.skill-logo {
    width: 48px; height: 48px; flex-shrink: 0; aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center;
    background: var(--surface); border: 1px solid var(--border); font-size: 1.5rem;
    transition: transform .35s var(--ease);
}
.skill:hover .skill-logo { transform: scale(1.08) rotate(-4deg); }
.skill-logo img { width: 26px; height: 26px; }
.skill-name { font-weight: 600; font-size: 1.05rem; line-height: 1.3; }
.skill-kind { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.skill.featured { grid-column: span 2; flex-direction: column; align-items: flex-start; gap: 1.25rem; background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.skill.featured .skill-logo { width: 72px; height: 72px; border-radius: 16px; background: var(--raised); }
.skill.featured .skill-logo img { width: 40px; height: 40px; }
.skill.featured .skill-name { font-family: var(--display); font-weight: 400; font-size: 2.25rem; line-height: 1; }
.skill.featured p { color: var(--muted); font-size: .95rem; margin-top: .3rem; }
.skill.featured .chips { margin-top: .9rem; }
.skill.featured .chip { background: var(--raised); }
@media (min-width: 640px) {
    .skill.featured { grid-row: span 2; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1.1rem; padding: 1.75rem; }
    .skill.featured .skill-name { font-size: 3rem; }
}

/* Journey: the spine fills as you scroll through it */
.journey { position: relative; padding-left: 2rem; --progress: 1; }
.journey::before, .journey::after {
    content: ""; position: absolute; left: 7px; top: .6rem; bottom: .6rem; width: 2px; border-radius: 2px;
}
.journey::before { background: var(--border); }
.journey::after { background: var(--accent); transform-origin: top; transform: scaleY(var(--progress)); }
.journey li { position: relative; display: grid; gap: .25rem 2rem; padding-bottom: 2.5rem; }
.journey li:last-child { padding-bottom: 0; }
.journey li::before {
    content: ""; position: absolute; left: calc(-2rem + 2px); top: .5rem; z-index: 1;
    width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--field);
    transition: background-color .3s, border-color .3s, transform .3s var(--ease);
}
.journey li.passed::before { background: var(--accent); border-color: var(--accent); transform: scale(1.15); }
.journey .year { font-family: var(--display); font-size: 2.5rem; line-height: 1; color: var(--primary); }
.journey h3 { font-size: 1.15rem; font-weight: 600; }
.journey p { color: var(--muted); max-width: 56ch; }
@media (min-width: 720px) {
    .journey li { grid-template-columns: 7rem 1fr; }
    .journey .year { position: sticky; top: 90px; align-self: start; grid-row: 1 / span 2; }
    .journey li > div { grid-column: 2; }
}

/* Projects */
.project { display: grid; gap: 1.5rem; padding: 2.5rem 0; }
.project + .project { border-top: 1px solid var(--border); }
.project-media {
    display: block; position: relative; overflow: hidden; border-radius: 14px; border: 1px solid var(--border);
    background: var(--surface); box-shadow: var(--shadow);
}
/* Ratio comes from each img width/height, so 4:3 and 16:9 screenshots both show uncropped */
.project-media img { width: 100%; height: auto; transition: transform .6s var(--ease); }
.project-media:hover img { transform: scale(1.035); }
/* The frame stays visible (so it can be observed); the screenshot wipes in from the left */
.js .project-media[data-reveal] { opacity: 1; transform: none; }
.js .project-media[data-reveal] img { clip-path: inset(0 0 0 0); transition: clip-path 1.1s var(--ease) .1s, transform .6s var(--ease); }
.js .project-media[data-reveal]:not(.is-in) img { clip-path: inset(0 100% 0 0); }
.project h3 { font-family: var(--display); font-weight: 400; font-size: clamp(2.25rem, 5vw, 2.85rem); line-height: 1; }
.project .desc { margin-top: .9rem; max-width: 44ch; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.chip { font-family: var(--mono); font-size: .8rem; padding: .3rem .6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.project .actions { margin-top: 1.25rem; }
@media (min-width: 820px) {
    .project { grid-template-columns: 1.1fr 1fr; gap: 3.5rem; align-items: center; }
    .project:nth-child(even) .project-media { order: 2; }
}

/* Contact band */
.cta {
    position: relative; display: grid; gap: 2rem; align-items: center;
    padding: 2.5rem 1.5rem; border: 1px solid var(--border); border-radius: 20px; background: var(--raised); box-shadow: var(--shadow);
    overflow: hidden;
}
@media (min-width: 720px) { .cta { grid-template-columns: 1fr auto; padding: 3.5rem; } }
.cta h2 { font-size: clamp(2.5rem, 7vw, 4rem); }
.cta p { margin-top: .75rem; color: var(--muted); max-width: 44ch; }
.cta .actions { margin-top: 1.75rem; }
.cta img { width: 150px; height: 150px; justify-self: center; transition: transform .4s var(--ease); }
.cta:hover img { transform: rotate(5deg) translateY(-4px); }

/* ---------- Reduced motion: show the final state ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; animation: none !important; }
    .js [data-reveal], .js [data-reveal] img { opacity: 1 !important; transform: none !important; clip-path: none !important; }
    .route-line, .portrait-frame .frame, .glyph .draw { stroke-dashoffset: 0 !important; }
    .route .node, .route .label, .route-card .ok, .portrait-frame .tick { opacity: 1; }
    .route .node .led, .glyph .dot { fill: var(--primary) !important; }
    .route .packet { opacity: 1; offset-distance: 100%; }
    .route .ping { opacity: 0; }
    .glyph .gear { transform: none !important; }
    .section-head .section-title::after { transform: none !important; }
    .journey { --progress: 1 !important; }
}

/* ---------- Tool pages (/project/*) and contact ---------- */
.page { padding: 2.5rem 0 4rem; }
@media (min-width: 768px) { .page { padding: 4rem 0 5rem; } }
.page-narrow { max-width: 44rem; }
.back-link {
    display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px;
    font-weight: 600; color: var(--muted); text-decoration: none;
}
.back-link:hover { color: var(--primary); }
.back-link svg { width: 18px; height: 18px; }
.page-title { font-size: clamp(2.75rem, 9vw, 4.25rem); margin-top: 0.5rem; }
.page-lede { margin-top: 0.75rem; color: var(--muted); max-width: 52ch; }

.panel { margin-top: 2rem; background: var(--raised); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; }
@media (min-width: 640px) { .panel { padding: 2rem; } }
.panel + .panel { margin-top: 1.25rem; }
.panel-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.stack > * + * { margin-top: 1.1rem; }
.grid-2 { display: grid; gap: 1.1rem; }
.grid-3 { display: grid; gap: 1.1rem; }
@media (min-width: 640px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.field label, .field .field-label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.35rem; }
.hint { font-size: 0.875rem; color: var(--muted); margin-top: 0.35rem; }
.hint a { color: var(--primary); }
.input {
    width: 100%; min-height: 48px; padding: 0.6rem 0.85rem;
    font: inherit; color: var(--text); background: var(--raised);
    border: 1px solid var(--field); border-radius: 6px;
}
.input::placeholder { color: var(--muted); opacity: 1; }
.input:hover { border-color: var(--text); }
.input:focus-visible { outline: 3px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
select.input { appearance: auto; }
.input.is-invalid, .dropzone.is-invalid { border-color: var(--danger); outline: 2px solid var(--danger); outline-offset: 1px; }
.input-pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.5rem; }
.input-pair span { color: var(--muted); font-family: var(--mono); }
.divider { border: 0; border-top: 1px solid var(--border); margin: 1.75rem 0; }
.btn-block { width: 100%; justify-content: center; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--field); }
.btn-secondary:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.dropzone {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem;
    min-height: 150px; padding: 1.25rem; text-align: center; overflow: hidden;
    border: 1px dashed var(--field); border-radius: 6px; background: var(--bg);
}
.dropzone:hover { border-color: var(--primary); }
.dropzone:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.dropzone svg { width: 32px; height: 32px; color: var(--primary); }
.dropzone strong { font-weight: 600; }
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.dropzone .preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 0.5rem; background: var(--bg); }
.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;
}

.result { margin-top: 1.5rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.result-label { font-size: 0.9rem; color: var(--muted); }
.result-value { font-family: var(--display); font-size: clamp(2.25rem, 8vw, 3rem); line-height: 1; color: var(--primary); margin-top: 0.35rem; overflow-wrap: anywhere; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.status { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--border); border-right-color: var(--primary); } }

.canvas-box { margin-top: 1.25rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); display: flex; justify-content: center; }
.canvas-box canvas, .canvas-box img { max-width: 100%; height: auto; border-radius: 4px; }

/* Contact page */
.contact-list { margin-top: 2rem; border-top: 1px solid var(--border); }
.contact-row {
    display: grid; grid-template-columns: 2.5rem 1fr auto; align-items: center; gap: 1rem;
    padding: 1rem 0.25rem; border-bottom: 1px solid var(--border); text-decoration: none;
}
.contact-row:hover { background: var(--surface); }
.contact-row:hover .contact-value { color: var(--primary); }
.contact-row > i { font-size: 1.35rem; color: var(--primary); text-align: center; }
.contact-name { font-weight: 600; }
.contact-value { display: block; color: var(--muted); font-family: var(--mono); font-size: 0.9rem; overflow-wrap: anywhere; }

/* ---------- Tool page motion ---------- */
/* Header: title rises from a mask, each tool has its own line glyph that draws in on load */
.tool-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-top: .5rem; }
.tool-head .page-title { margin-top: 0; }
.tool-glyph { width: 64px; height: 64px; flex-shrink: 0; margin-bottom: .35rem; }
@media (min-width: 640px) { .tool-glyph { width: 84px; height: 84px; } }
.js .tool-head[data-reveal] { opacity: 1; transform: none; }
.glyph .bar { fill: var(--primary); stroke: none; transform-box: fill-box; transform-origin: bottom; transition: transform .8s var(--ease); }
.glyph .bar.b2 { transition-delay: .15s; } .glyph .bar.b3 { transition-delay: .3s; }
.js [data-reveal]:not(.is-in) .glyph .bar { transform: scaleY(0); }
.glyph .float { transform-box: fill-box; transform-origin: center; }
[data-reveal].is-in .glyph .float { animation: bob 1.2s var(--ease) 1.2s 2; }
@keyframes bob { 0%, 100% { transform: none; } 50% { transform: translateY(-3px); } }

/* Results */
.pop { animation: pop .55s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.scrambling { color: var(--muted); }
.wipe { animation: wipe 1s var(--ease) both; }
@keyframes wipe { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
.dropzone svg { transition: transform .3s var(--ease); }
.dropzone:hover svg { transform: translateY(-4px); }
.dropzone .preview:not(.hidden) { animation: pop .45s var(--ease) both; }
.input { transition: border-color .15s, box-shadow .2s; }
.input:focus-visible { box-shadow: 0 0 0 4px var(--primary-soft); }
.panel { transition: border-color .2s; }
.panel:focus-within { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }

/* Contact rows */
.contact-row > i { transition: transform .3s var(--ease); }
.contact-row:hover > i { transform: translateY(-3px) rotate(-6deg); }
.contact-row::before { content: none; }
.contact-row { position: relative; isolation: isolate; }
.contact-row::after {
    content: ""; position: absolute; inset: 0; z-index: -1; background: var(--surface);
    transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.contact-row:hover { background: transparent; }
.contact-row:hover::after { transform: scaleX(1); }
.contact-row:hover .tool-arrow { transform: translateX(5px); }

@media (prefers-reduced-motion: reduce) {
    .pop, .wipe, .dropzone .preview:not(.hidden), [data-reveal].is-in .glyph .float { animation: none !important; }
    .glyph .bar { transform: none !important; }
}

/* Keep last so it wins over component display rules */
.hidden { display: none; }
