/* =========================================
   DESIGN TOKENS
   Every colour lives here. Dark is the default;
   the inline script in <head> sets data-theme on
   <html> before first paint.
========================================= */

:root {

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

    /* ---- theme colours: DARK ---- */

    /* surfaces */
    --bg: #131417;
    --bg-alt: #191b20;
    --footer-bg: #0e0f12;
    --panel: #1e1f26;
    --panel-2: #262731;
    --border: #2e303b;

    /* text */
    --text: #eceef4;
    --muted: #a0a3b3;

    /* accents, used sparingly */
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --yellow: #ffd642;
    --blue: #5b9bff;
    --purple: #b18cff;
    --pink: #ff6b9d;
    --on-accent: #0b0c0f;

    /* editor / code look */
    --chrome: #181920;
    --stage: #1a1b22;
    --code-bg: #16171d;
    --code-text: #c9cbe0;
    --line-num: #5a5d6e;

    /* depth */
    --shadow-card: 0 0 0 0 transparent;
    --shadow-window: 0 30px 80px rgba(0, 0, 0, 0.5);
    --shadow-icon: 0 6px 16px rgba(0, 0, 0, 0.4);
    --photo-shadow: rgba(0, 0, 0, 0.55);
    --dot: rgba(255, 255, 255, 0.07);

    /* glow strengths (percent of the accent colour) */
    --glow-strength: 55%;
    --glow-1: 16%;
    --glow-2: 10%;
    --glow-stage: 35%;

    /* type scale */
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-md: 1rem;
    --fs-lg: 1.25rem;
    --fs-xl: clamp(1.4rem, 4vw, 2rem);
    --fs-2xl: clamp(2rem, 5vw, 3rem);
    --fs-hero: clamp(2.5rem, 13vw, 5.5rem);

    /* spacing */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 16px;
    --s-4: 24px;
    --s-5: 40px;
    --s-6: 64px;
    --s-7: 96px;

    --radius: 14px;
    --container: 1180px;
    --header-h: 64px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    /* motion: tune all animation speeds here */
    --dur-fast: 0.25s;
    --dur-base: 0.45s;
    --dur-slow: 0.7s;
    --dur-zoom: 0.6s;
    --dur-theme: 0.3s;
    --stagger: 80ms;

    color-scheme: dark;
}

/* ---- theme colours: LIGHT ----
   Off-white page, white cards with soft shadows, dark text.
   Accents are darkened so they keep at least 4.5:1 contrast
   on white and off-white (white text sits on the accent fills). */

:root[data-theme="light"] {

    --bg: #f5f6fa;
    --bg-alt: #ebedf4;
    --footer-bg: #e1e4ee;
    --panel: #ffffff;
    --panel-2: #eef0f6;
    --border: #dcdfea;

    --text: #14161d;
    --muted: #565b6e;

    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --yellow: #9a5a06;
    --blue: #1d4ed8;
    --purple: #6d28d9;
    --pink: #cc1f66;
    --on-accent: #ffffff;

    --chrome: #eceef5;
    --stage: #eef0f8;
    --code-bg: #f3f4fa;
    --code-text: #2d3142;
    --line-num: #6a6f84;

    --shadow-card: 0 2px 10px -2px rgba(20, 24, 50, 0.1);
    --shadow-window: 0 24px 60px -20px rgba(20, 24, 50, 0.25);
    --shadow-icon: 0 4px 12px rgba(20, 24, 50, 0.18);
    --photo-shadow: rgba(20, 24, 50, 0.28);
    --dot: rgba(20, 24, 50, 0.07);

    --glow-strength: 28%;
    --glow-1: 10%;
    --glow-2: 7%;
    --glow-stage: 18%;

    color-scheme: light;
}


/* =========================================
   RESET & BASE
========================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    line-height: 1.65;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

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

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    color: inherit;
}

h1,
h2,
h3 {
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text);
}

section[id] {
    scroll-margin-top: var(--header-h);
}

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

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


/* =========================================
   ACCESSIBILITY
========================================= */

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

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

.skip-link {
    position: absolute;
    top: -60px;
    left: 16px;
    z-index: 4000;
    padding: 10px 18px;
    border-radius: 0 0 9px 9px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 700;
}

.skip-link:focus {
    top: 0;
}


/* =========================================
   LAYOUT
========================================= */

.container {
    width: min(var(--container), calc(100% - 32px));
    margin: auto;
}

.section {
    position: relative;
    padding: var(--s-6) 0;
}

.about,
.journey {
    background: var(--bg-alt);
}

.section-heading {
    max-width: 720px;
    margin-bottom: var(--s-5);
}

.section-heading span {
    display: block;
    margin-bottom: var(--s-2);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--accent);
}

.section-heading span::before {
    content: "// ";
    color: var(--muted);
}

.section-heading h2 {
    font-size: var(--fs-2xl);
    font-weight: 800;
}

.section-heading p {
    margin-top: var(--s-2);
    color: var(--muted);
}

.section-heading p a {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--accent);
    border-bottom: 1px dashed currentColor;
}

.section-heading p a:hover {
    color: var(--text);
}


/* =========================================
   BUTTONS
========================================= */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 22px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    font-size: 0.9375rem;
    font-weight: 700;
    transform: translate(var(--mx, 0px), var(--my, 0px));
    scale: 1;
    transition: scale 0.15s var(--ease), background-color 0.3s, border-color 0.3s, color 0.3s;
}

.btn:hover {
    border-color: var(--accent);
}

.btn:active {
    scale: 0.97;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* text roll: the label and its copy slide up together */

.btn-roll {
    position: relative;
    display: inline-block;
    overflow: hidden;
    line-height: 1.5;
}

.btn-roll > span {
    display: block;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-roll > span:last-child {
    position: absolute;
    top: 100%;
    left: 0;
    white-space: nowrap;
}

.btn:hover .btn-roll > span {
    transform: translateY(-100%);
}

/* arrow: the old one leaves in its direction, a new one enters from the opposite side */

.btn-arrow {
    --out-x: 0%;
    --out-y: 0%;
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 1em;
    height: 1em;
    overflow: hidden;
}

.btn-arrow-down  { --out-y: 150%; }
.btn-arrow-right { --out-x: 150%; }

.btn-arrow i {
    grid-area: 1 / 1;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-arrow i:last-child {
    transform: translate(calc(var(--out-x) * -1), calc(var(--out-y) * -1));
}

.btn:hover .btn-arrow i:first-child {
    transform: translate(var(--out-x), var(--out-y));
}

.btn:hover .btn-arrow i:last-child {
    transform: none;
}

@media (prefers-reduced-motion: reduce) {

    .btn,
    .btn:active {
        transform: none;
        scale: 1;
    }

    .btn-roll > span:last-child,
    .btn-arrow i:last-child {
        display: none;
    }

    .btn:hover .btn-roll > span,
    .btn:hover .btn-arrow i:first-child {
        transform: none;
    }
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}


/* =========================================
   TOP BAR
========================================= */

.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    transition: transform 0.35s var(--ease), background-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

/* smart header: slides away on scroll down, returns on scroll up */
.header.is-hidden {
    transform: translateY(-100%);
}

.header.is-scrolled {
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
    .header {
        transition: none;
    }
}

.nav-container {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    margin-right: auto;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.logo span {
    color: var(--accent);
}

.nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    padding: 8px 16px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);

    /* closed: wiped up, faded out, and removed from the tab order */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    clip-path: inset(0 0 100% 0);
    transform: translateY(-8px);
    transition:
        opacity var(--dur-base) var(--ease),
        transform var(--dur-base) var(--ease),
        clip-path var(--dur-base) var(--ease),
        visibility 0s linear var(--dur-base);
}

.nav.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    clip-path: inset(0 0 -40px 0);
    transform: none;
    transition-delay: 0s;
}

.nav a {
    padding: 14px 12px;
    border-radius: 8px;
    font-size: var(--fs-md);
    font-weight: 500;
    color: var(--muted);
    transition: color 0.2s;
}

.nav a:hover,
.nav a.active {
    color: var(--text);
}

/* active link: wrapped in code brackets, <About />.
   The brackets are absolutely positioned, so link widths never change. */

.nav a {
    position: relative;
}

.nav a::before,
.nav a::after {
    position: absolute;
    top: 50%;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    color: var(--accent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.nav a::before {
    content: "<";
    left: 8px;
    transform: translate(-6px, -50%);
}

.nav a::after {
    content: "/>";
    right: 4px;
    transform: translate(6px, -50%);
}

.nav a.active::before,
.nav a.active::after,
.nav a:not(.active):hover::before,
.nav a:not(.active):hover::after {
    transform: translate(0, -50%);
}

.nav a.active::before,
.nav a.active::after {
    opacity: 1;
}

.nav a:not(.active):hover::before,
.nav a:not(.active):hover::after {
    opacity: 0.4;
}

@media (max-width: 859px) {

    .nav a {
        align-self: flex-start;
        padding-left: 26px;
        padding-right: 30px;
    }

    .nav a::before,
    .nav a::after {
        font-size: 0.875rem;
    }

    .nav a::before {
        left: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .nav a::before,
    .nav a::after {
        transition: none;
    }
}

.theme-toggle {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    font-size: 17px;
    cursor: pointer;
    transition: color 0.3s var(--ease);
}

.theme-toggle svg {
    grid-area: 1 / 1;
    width: 20px;
    height: 20px;
    transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
}

.theme-toggle:hover {
    color: var(--accent);
}

.theme-toggle:focus {
    outline: none;
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* hamburger: no box, just three lines that morph into an X.
   The button keeps a 44x44 tap area. */

.menu-toggle {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.menu-icon {
    position: relative;
    display: block;
    width: 22px;
    height: 16px;
}

.menu-icon span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition:
        transform var(--dur-base) var(--ease),
        opacity var(--dur-base) var(--ease),
        background-color var(--dur-fast) ease;
}

.menu-icon span:nth-child(1) {
    top: 0;
}

.menu-icon span:nth-child(2) {
    top: 7px;
}

.menu-icon span:nth-child(3) {
    top: 14px;
}

.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.menu-toggle:hover .menu-icon span,
.menu-toggle[aria-expanded="true"] .menu-icon span {
    background: var(--accent);
}

/* clear ring for keyboard users only */
.menu-toggle:focus {
    outline: none;
}

.menu-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* dark mode shows the sun, light mode the moon; the old icon
   rotates and fades out while the new one rotates in */

.theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0deg);
}

.theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(-90deg);
}

:root[data-theme="light"] .theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(90deg);
}

:root[data-theme="light"] .theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}

@media (prefers-reduced-motion: reduce) {
    .theme-toggle svg {
        transition: none;
    }
}


/* =========================================
   HERO
========================================= */

.hero {
    position: relative;
    overflow: hidden;
    padding: var(--s-5) 0 var(--s-6);
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(600px 300px at 85% 10%, color-mix(in srgb, var(--accent) var(--glow-1), transparent), transparent 70%),
        radial-gradient(500px 300px at 0% 90%, color-mix(in srgb, var(--accent) var(--glow-2), transparent), transparent 70%);
    pointer-events: none;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--dot) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: linear-gradient(#000, transparent 80%);
    -webkit-mask-image: linear-gradient(#000, transparent 80%);
    pointer-events: none;
}

.hero-container {
    position: relative;
    z-index: 1;
    display: grid;
    gap: var(--s-5);
    align-items: center;
}

.hero-small {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--panel);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--accent);
}

.hero-small::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    50% {
        opacity: 0.35;
    }
}

.hero h1 {
    margin: 20px 0 14px;
    font-size: var(--fs-hero);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.05em;
}

.hero h1 span {
    color: var(--accent);
}

.hero h2 {
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.hero-content p {
    max-width: 520px;
    margin: 16px 0 28px;
    color: var(--muted);
}

.hero-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.social-links {
    display: flex;
    gap: 10px;
    margin-top: var(--s-4);
}

.social-links a {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    font-size: 22px;
    color: var(--text);
    transition: color 0.3s, transform 0.3s var(--ease);
}

.social-links a:hover {
    color: var(--accent);
    transform: translateY(-3px);
}

.social-links a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* editor window */
.window {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-window);
}

.win-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    background: var(--chrome);
    border-bottom: 1px solid var(--border);
}

.win-bar .dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}

.dot.r {
    background: #ff5f57;
}

.dot.y {
    background: #febc2e;
}

.dot.g {
    background: #28c840;
}

.win-tab {
    align-self: flex-end;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 14px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 9px 9px 0 0;
    background: var(--panel);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 500;
}

.win-tab i {
    color: var(--accent);
    font-size: 11px;
}

.win-tab-ghost {
    margin-left: 6px;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--muted);
}

.image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    min-height: 300px;
    padding: 28px 20px 0;
    background:
        radial-gradient(260px 260px at 50% 55%, color-mix(in srgb, var(--accent) var(--glow-stage), transparent), transparent 70%),
        var(--stage);
}

.image-wrapper picture {
    width: min(260px, 62%);
}

.image-wrapper img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 20px 24px var(--photo-shadow));
}

.chip {
    position: absolute;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(6px);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    animation: bob 5s ease-in-out infinite alternate;
}

.chip-a {
    top: 22px;
    left: 16px;
    color: var(--accent);
}

.chip-b {
    bottom: 60px;
    right: 14px;
    color: var(--accent);
    animation-delay: -2.5s;
}

@keyframes bob {
    to {
        transform: translateY(-8px);
    }
}

.code {
    display: grid;
    grid-template-columns: auto 1fr;
    padding: 14px 0;
    border-top: 1px solid var(--border);
    background: var(--code-bg);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.9;
}

.code-ln {
    padding: 0 14px;
    text-align: right;
    color: var(--line-num);
    user-select: none;
}

.code-src {
    padding-right: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--code-text);
}

.tk-k {
    color: var(--accent);
}

.tk-v {
    color: var(--text);
}

.tk-s {
    color: var(--accent);
}

.tk-b {
    color: var(--muted);
}

.caret {
    display: inline-block;
    width: 8px;
    height: 15px;
    background: var(--accent);
    vertical-align: -2px;
    animation: blink 1s steps(1) infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}


/* =========================================
   REVEAL ON SCROLL
========================================= */

.js .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}

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

@media (prefers-reduced-motion: reduce) {

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


/* =========================================
   ABOUT (editor pane)
========================================= */

.about-grid {
    display: grid;
    gap: var(--s-4);
    align-items: start;
}

.editor {
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
}

.editor-body {
    padding: var(--s-4) var(--s-3) var(--s-3) 0;
    counter-reset: line;
}

.editor-body p {
    position: relative;
    margin-bottom: var(--s-3);
    padding-left: 56px;
    color: var(--muted);
    counter-increment: line;
}

.editor-body p::before {
    content: counter(line);
    position: absolute;
    left: 0;
    width: 38px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.95;
    color: var(--line-num);
}

.editor-body p:first-child {
    color: var(--text);
    font-size: 1.125rem;
    font-weight: 500;
}

.about-image .window {
    position: relative;
}

.about-image img {
    width: 100%;
    height: auto;
}


/* =========================================
   SERVICES
========================================= */

.services-grid {
    display: grid;
    gap: var(--s-3);
}

.service-card {
    --a: var(--accent);
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: var(--shadow-card);
    transition:
        transform var(--dur-base) var(--ease),
        box-shadow var(--dur-base) var(--ease),
        border-color var(--dur-base) var(--ease);
}

.service-card:hover {
    border-color: color-mix(in srgb, var(--a) 40%, var(--border));
    box-shadow: 0 12px 28px -12px color-mix(in srgb, var(--a) 22%, transparent);
}

.service-num {
    position: absolute;
    top: 24px;
    right: 28px;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--muted);
}

.service-icon {
    display: block;
    width: 28px;
    height: 28px;
    margin-bottom: var(--s-3);
    color: var(--a);
    transition: transform var(--dur-base) var(--ease);
}

.service-icon svg {
    display: block;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {

    .service-card {
        --tilt: -2deg;
        transform-origin: center;
        transition:
            transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
            box-shadow var(--dur-base) var(--ease),
            border-color var(--dur-base) var(--ease);
    }

    .service-card:nth-child(even) {
        --tilt: 2deg;
    }

    .service-card:hover {
        z-index: 2;
        transform: rotate(var(--tilt)) scale(1.02);
    }

    .service-icon {
        transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .service-card:hover .service-icon {
        transform: rotate(-6deg);
    }
}

.service-card h3 {
    margin-bottom: var(--s-2);
    font-size: 1.2rem;
    line-height: 1.3;
}

.service-card p {
    font-size: var(--fs-sm);
    line-height: 1.65;
    color: var(--muted);
}

@media (min-width: 1200px) {
    .service-card h3 {
        font-size: 1.0625rem;
        white-space: nowrap;
    }
}


/* =========================================
   JOURNEY
========================================= */

.timeline {
    position: relative;
    max-width: 960px;
    margin: auto;
}

.timeline::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 19px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    --a: var(--accent);
    position: relative;
    padding: 0 0 var(--s-4) 60px;
}

.timeline-item[data-type="work"] {
    --a: var(--accent);
}

.timeline-marker {
    position: absolute;
    top: 6px;
    left: 0;
    z-index: 2;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 2px solid var(--a);
    border-radius: 50%;
    background: var(--bg-alt);
    color: var(--a);
    font-size: 15px;
    box-shadow: 0 0 18px -4px var(--a);
}

.timeline-content {
    padding: var(--s-3) var(--s-4);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    transition: transform 0.25s var(--ease), border-color 0.25s;
}

.timeline-content:hover {
    transform: translateY(-3px);
    border-color: var(--a);
}

.timeline-year {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid color-mix(in srgb, var(--a) 45%, transparent);
    border-radius: 7px;
    background: color-mix(in srgb, var(--a) 10%, transparent);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--a);
}

.timeline-tag {
    margin-left: var(--s-2);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--muted);
}

.timeline-content h3 {
    margin: var(--s-3) 0 var(--s-2);
    font-size: 1.2rem;
}

.timeline-content p {
    font-size: var(--fs-sm);
    color: var(--muted);
}


/* sticky year (script.js keeps it in sync with the entry in view).
   Mobile: a compact bar pinned under the header. */

.journey-layout {
    display: block;
}

.year-col {
    --a: var(--accent);
    position: sticky;
    top: var(--header-h);
    z-index: 5;
    display: flex;
    align-items: baseline;
    gap: var(--s-3);
    margin: 0 -16px var(--s-4);
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.year-col[data-type="work"]      { --a: var(--accent); }

.year-big {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.04em;
    color: var(--a);
    transition: opacity 0.2s ease, transform 0.2s var(--ease), color var(--dur-base) ease;
}

/* year change: fade/slide out, swap, slide in (about 0.4s in total) */
.year-big.leaving {
    opacity: 0;
    transform: translateY(-10px);
}

.year-big.entering {
    opacity: 0;
    transform: translateY(10px);
    transition: none;
}

.year-kind {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--muted);
}

.year-kind::before {
    content: "// ";
}

/* entries: the one in view is highlighted, the others fade slightly */
.journey-layout .timeline-item {
    opacity: 0.55;
    transition: opacity 0.4s var(--ease);
}

.journey-layout .timeline-item.is-current {
    opacity: 1;
}

/* without JS (or before it runs) every entry stays fully visible */
.journey-layout:not(.year-ready) .timeline-item {
    opacity: 1;
}


/* =========================================
   TOOLS (compact "pen" cards)
   Shared by index.html (.tool-card) and
   tools.html (.tool-section).
========================================= */

.tools-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.tool-card,
.tool-section {
    --a: var(--accent);
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    box-shadow:
        0 0 0 0 transparent,
        var(--shadow-card);
    transition:
        transform var(--dur-base) var(--ease),
        box-shadow var(--dur-base) var(--ease),
        border-color var(--dur-base) var(--ease),
        background var(--dur-base) var(--ease);
}

.tool-card:hover,
.tool-card:focus-visible,
.tool-section:hover,
.tool-section:focus-within {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--a) 40%, var(--border));
    box-shadow: 0 12px 28px -12px color-mix(in srgb, var(--a) 22%, transparent);
}

.tool-card:focus-visible {
    outline: 1px solid var(--a);
    outline-offset: 3px;
}

.tool-preview {
    position: relative;
    aspect-ratio: 16 / 10;
    border-bottom: 1px solid var(--border);
    border-radius: 13px 13px 0 0;
    background: var(--panel-2);
}

.tool-clip {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 13px 13px 0 0;
}

.tool-clip::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 40%;
    background: linear-gradient(transparent, color-mix(in srgb, var(--panel) 85%, transparent));
    pointer-events: none;
}

.tool-clip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    transition: transform var(--dur-zoom) var(--ease);
}

.tool-card:hover .tool-clip img,
.tool-card:focus-visible .tool-clip img,
.tool-section:hover .tool-clip img {
    transform: scale(1.05);
}

/* small badge in the bottom-right corner, over the fade,
   so it never covers the top of the screenshot */
.tool-number {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 2;
    padding: 1px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    line-height: 1.6;
    color: var(--muted);
}

.tool-icon {
    position: absolute;
    left: 14px;
    bottom: -20px;
    z-index: 2;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 2px solid var(--panel);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: var(--shadow-icon);
}

.tool-icon img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.tool-content,
.tool-section-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 28px 16px 16px;
}

.tool-top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}

.tool-top .tool-tag {
    order: -1;
    margin-top: 0;
}

.tool-content h3,
.tool-section h2 {
    font-size: 1.125rem;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.tool-tag {
    --t: var(--accent);
    margin-top: 2px;
    padding: 1px 8px;
    border: 1px solid color-mix(in srgb, var(--t) 30%, transparent);
    border-radius: 99px;
    background: color-mix(in srgb, var(--t) 14%, transparent);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    line-height: 1.7;
    color: var(--t);
    white-space: nowrap;
}

.tool-tag.tag-image { --t: var(--blue); }
.tool-tag.tag-security { --t: var(--purple); }
.tool-tag.tag-text { --t: var(--yellow); }
.tool-tag.tag-utility { --t: var(--pink); }
.tool-tag.tag-fun { --t: var(--pink); }
.tool-tag.tag-productivity { --t: var(--yellow); }

.tool-content p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    margin-bottom: 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--muted);
}

.tool-link,
.tool-visit {
    margin-top: auto;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: none;
    border: 0;
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.4;
    background-image: linear-gradient(currentColor, currentColor);
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 0% 1px;
    transition: background-size 0.3s var(--ease), color 0.3s var(--ease);
}

.tool-link i,
.tool-visit i {
    font-size: 0.75rem;
    transition: transform 0.3s var(--ease);
}

.tool-card:hover .tool-link,
.tool-card:focus-visible .tool-link,
.tool-visit:hover,
.tool-visit:focus-visible,
.tool-section:hover .tool-visit {
    background-size: 100% 1px;
}

.tool-card:hover .tool-link i,
.tool-card:focus-visible .tool-link i,
.tool-visit:hover i,
.tool-visit:focus-visible i,
.tool-section:hover .tool-visit i {
    transform: translateX(4px);
}

/* whole tools.html card is clickable through the visit link */

.tool-visit::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 14px;
}

.tool-visit:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 4px;
}

.back-to-tools {
    position: relative;
    z-index: 1;
}

/* "View all tools" button under the home page cards */

.tools-more {
    display: flex;
    justify-content: center;
    margin-top: var(--s-5);
}


/* =========================================
   FOOTER
========================================= */

.footer {
    position: relative;
    overflow: hidden;
    padding: var(--s-7, 96px) 0 0;
    background: var(--footer-bg);
}

/* huge faint logo, cut off at the bottom edge */
.footer::after {
    content: "Yogi.";
    position: absolute;
    left: 50%;
    bottom: -0.1em;
    z-index: 0;
    transform: translateX(-50%);
    font-size: clamp(6rem, 34vw, 26rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1;
    color: var(--text);
    opacity: 0.04;
    pointer-events: none;
    user-select: none;
}

.footer .container {
    position: relative;
    z-index: 1;
}

.footer-label {
    display: block;
    margin-bottom: var(--s-2);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
}

.footer-cta h2 {
    font-size: clamp(2.25rem, 7vw, 4.5rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.footer-cta h2 span {
    color: var(--accent);
}

.footer-cta p {
    margin-top: var(--s-2);
    color: var(--muted);
}

.footer-cols {
    display: grid;
    gap: var(--s-5);
    margin-top: var(--s-7, 80px);
    padding-bottom: var(--s-6, 56px);
}

.footer-col h3 {
    margin-bottom: var(--s-2);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--muted);
}

.footer-col ul {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ft-link {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 0;
    color: var(--text);
    transition: color 0.3s var(--ease);
}

.ft-link > span:first-child {
    background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
    transition: background-size 0.35s var(--ease);
}

.ft-link::before {
    content: "›";
    position: absolute;
    left: -14px;
    color: var(--accent);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
    pointer-events: none;
}

.ft-link:hover,
.ft-link:focus-visible {
    color: var(--accent);
}

.ft-link:hover > span:first-child,
.ft-link:focus-visible > span:first-child {
    background-size: 100% 1px;
}

.ft-link:hover::before,
.ft-link:focus-visible::before {
    opacity: 1;
    transform: none;
}

.ft-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

.footer-bottom {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    padding: var(--s-3) 0 96px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--muted);
}

.footer-code {
    color: var(--accent);
}

@media (min-width: 620px) {

    .footer-cols {
        grid-template-columns: repeat(3, 1fr);
    }

    .footer-bottom {
        flex-direction: row;
        justify-content: space-between;
        /* leave room for the back-to-top button */
        padding: var(--s-3) 72px var(--s-3) 0;
    }
}

@media (prefers-reduced-motion: reduce) {

    .ft-link,
    .ft-link > span:first-child,
    .ft-link::before {
        transition: none;
    }
}


/* =========================================
   TABLET & DESKTOP
========================================= */

@media (min-width: 620px) {

    .services-grid,
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }


}

@media (min-width: 860px) {

    .menu-toggle {
        display: none;
    }

    .nav {
        position: static;
        display: flex;
        flex-direction: row;
        gap: 4px;
        padding: 0;
        background: none;
        border: 0;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        clip-path: none;
        transform: none;
        transition: none;
    }

    .nav a {
        padding: 8px 12px;
        font-size: var(--fs-sm);
    }

    .nav a::before {
        left: 1px;
    }

    .nav a::after {
        right: -6px;
    }
}

@media (min-width: 960px) {

    .section {
        padding: var(--s-7) 0;
    }

    .section-heading {
        margin-bottom: var(--s-6);
    }

    .hero {
        padding: 80px 0 100px;
    }

    .hero-container {
        grid-template-columns: 1.1fr 0.9fr;
        gap: var(--s-6);
    }

    .about-grid {
        grid-template-columns: 1.25fr 0.75fr;
        gap: var(--s-5);
    }



    /* journey: large sticky year on the left, entries on the right */
    .journey-layout {
        display: grid;
        grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr);
        gap: var(--s-6);
        align-items: start;
    }

    .year-col {
        top: calc(var(--header-h) + var(--s-5));
        display: block;
        margin: 0;
        padding: 0;
        border: 0;
        background: none;
    }

    .year-big {
        display: block;
        font-size: clamp(4rem, 9vw, 7.5rem);
        line-height: 1;
    }

    .year-kind {
        display: block;
        margin-top: var(--s-2);
        font-size: var(--fs-sm);
    }

    .timeline {
        max-width: none;
        margin: 0;
    }

}


@media (min-width: 1200px) {

    .services-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {

    .tools-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}


/* =========================================
   THEME SWITCH TRANSITION
   theme.js adds .theme-transition to <html>
   for a moment while the theme changes.
========================================= */

@media (min-width: 860px) {

    .nav-container {
        gap: 4px;
    }
}

html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition:
        background-color var(--dur-theme) ease,
        color var(--dur-theme) ease,
        border-color var(--dur-theme) ease,
        box-shadow var(--dur-theme) ease,
        fill var(--dur-theme) ease !important;
}

@media (prefers-reduced-motion: reduce) {

    html.theme-transition *,
    html.theme-transition *::before,
    html.theme-transition *::after {
        transition: none !important;
    }
}


/* =========================================
   CUSTOM CURSOR (js/cursor.js)
   Only on fine pointers, never with reduced motion.
========================================= */

.cursor-dot,
.cursor-ring {
    display: none;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {

    html.has-cursor,
    html.has-cursor *:not(input):not(textarea):not(select):not([contenteditable="true"]) {
        cursor: none;
    }

    .cursor-dot,
    .cursor-ring {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 100000;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.25s ease;
    }

    html.has-cursor .cursor-dot,
    html.has-cursor .cursor-ring {
        opacity: 1;
    }

    html.has-cursor.cursor-hidden .cursor-dot,
    html.has-cursor.cursor-hidden .cursor-ring,
    html.has-cursor.cursor-text .cursor-dot,
    html.has-cursor.cursor-text .cursor-ring {
        opacity: 0;
    }

    /* the position is set on the element; size and look live on ::before */

    .cursor-dot::before,
    .cursor-ring::before {
        content: "";
        position: absolute;
        border-radius: 50%;
        transform: translate(-50%, -50%);
        transition:
            width 0.3s var(--ease),
            height 0.3s var(--ease),
            background-color 0.3s var(--ease),
            border-color 0.3s var(--ease);
    }

    .cursor-dot::before {
        width: 8px;
        height: 8px;
        background: var(--accent);
        transition: width 0.3s var(--ease), height 0.3s var(--ease);
    }

    .cursor-ring::before {
        width: 32px;
        height: 32px;
        border: 1px solid color-mix(in srgb, var(--accent) 70%, transparent);
        background: transparent;
    }

    html.cursor-active .cursor-dot::before {
        width: 4px;
        height: 4px;
    }

    html.cursor-active .cursor-ring::before {
        width: 48px;
        height: 48px;
        background: color-mix(in srgb, var(--accent) 12%, transparent);
    }

    html.cursor-down .cursor-ring::before {
        width: 24px;
        height: 24px;
    }

    html.cursor-active.cursor-down .cursor-ring::before {
        width: 38px;
        height: 38px;
    }
}


/* =========================================
   CARD SPOTLIGHT (js/spotlight.js)
   A soft accent glow and a lit border that follow the cursor.
========================================= */

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {

    .tool-card,
    .tool-section,
    .service-card {
        --x: 50%;
        --y: 50%;
    }

    .tool-card::before,
    .tool-card::after,
    .tool-section::before,
    .tool-section::after,
    .service-card::before,
    .service-card::after {
        content: "";
        position: absolute;
        inset: -1px;
        z-index: 1;
        border-radius: inherit;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.5s var(--ease);
    }

    /* glow inside the card */
    .tool-card::before,
    .tool-section::before,
    .service-card::before {
        background: radial-gradient(
            320px circle at var(--x) var(--y),
            color-mix(in srgb, var(--accent) 10%, transparent),
            transparent 70%
        );
    }

    /* 1px border lit up near the cursor */
    .tool-card::after,
    .tool-section::after,
    .service-card::after {
        padding: 1px;
        background: radial-gradient(
            200px circle at var(--x) var(--y),
            color-mix(in srgb, var(--accent) 65%, transparent),
            transparent 70%
        );
        -webkit-mask:
            linear-gradient(#000 0 0) content-box,
            linear-gradient(#000 0 0);
        -webkit-mask-composite: xor;
        mask:
            linear-gradient(#000 0 0) content-box exclude,
            linear-gradient(#000 0 0);
    }

    .tool-card:hover::before,
    .tool-card:hover::after,
    .tool-section:hover::before,
    .tool-section:hover::after,
    .service-card:hover::before,
    .service-card:hover::after {
        opacity: 1;
    }
}


/* =========================================
   BACK TO TOP (js/back-to-top.js)
========================================= */

.back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 900;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    color: var(--text);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition:
        opacity 0.3s var(--ease),
        transform 0.3s var(--ease),
        visibility 0s linear 0.3s,
        border-color 0.3s var(--ease);
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
}

.back-to-top svg {
    grid-area: 1 / 1;
}

.btt-ring {
    position: absolute;
    inset: -1px;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    transform: rotate(-90deg);
    fill: none;
    pointer-events: none;
}

.btt-progress {
    stroke: var(--accent);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 132;
    stroke-dashoffset: 132;
}

.btt-arrow {
    transition: color 0.3s var(--ease), transform 0.3s var(--ease);
}

.back-to-top:hover .btt-arrow {
    color: var(--accent);
    transform: translateY(-2px);
}

.back-to-top:focus {
    outline: none;
}

.back-to-top:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

@media (max-width: 619px) {

    /* keep the footer's last line clear of the button */
    .footer {
        padding-bottom: calc(var(--s-4) + 64px);
    }
}

@media (prefers-reduced-motion: reduce) {

    .back-to-top,
    .btt-arrow {
        transition: none;
    }
}
