/* ==========================================================================
   Joshua Chilapondwa — portfolio
   ========================================================================== */

:root {
    --bg: #05070d;
    --surface: rgba(13, 18, 30, 0.72);
    --surface-solid: #0d121e;
    --surface-hover: rgba(20, 27, 44, 0.85);
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.28);
    --text: #e6edf6;
    --text-muted: #94a3b8;
    --text-dim: #7c8aa0;
    --accent: #22d3ee;
    --accent-2: #a78bfa;
    --accent-3: #34d399;
    --accent-ink: #031418;
    --danger: #f87171;

    --tk-keyword: #c084fc;
    --tk-string: #86efac;
    --tk-number: #fbbf24;
    --tk-type: #67e8f9;
    --tk-comment: #7c8aa0;

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

    --radius: 14px;
    --radius-sm: 8px;
    --nav-h: 68px;
    --gutter: clamp(16px, 4vw, 32px);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-h) + 12px);
    -webkit-text-size-adjust: 100%;
}

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

body.menu-open { overflow: hidden; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
strong, b { color: var(--text); font-weight: 600; }
::selection { background: rgba(34, 211, 238, 0.3); color: #fff; }

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

.container {
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.accent { color: var(--accent); }

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: var(--radius-sm);
    font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* ---------- Background ---------- */

#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    display: block;
}

.bg-overlay {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 50% 40%, rgba(5, 7, 13, 0.45) 0%, rgba(5, 7, 13, 0.8) 70%, rgba(5, 7, 13, 0.92) 100%),
        linear-gradient(180deg, rgba(5, 7, 13, 0.35) 0%, rgba(5, 7, 13, 0.6) 100%);
}

/* Without WebGL we still want depth, so fall back to a soft gradient. */
.no-webgl #bg-canvas { display: none; }
.no-webgl .bg-overlay {
    background:
        radial-gradient(circle at 15% 20%, rgba(34, 211, 238, 0.12), transparent 40%),
        radial-gradient(circle at 85% 70%, rgba(167, 139, 250, 0.12), transparent 45%),
        var(--bg);
}

/* ---------- Navigation ---------- */

.nav {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 50;
    height: var(--nav-h);
}

/* The frosted bar lives on a pseudo-element: a backdrop-filter on .nav itself would
   make it the containing block for the fixed mobile menu and trap the menu in the bar. */
.nav::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-bottom: 1px solid transparent;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.nav.scrolled::before,
.menu-open .nav::before {
    background: rgba(5, 7, 13, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom-color: var(--border);
}

.nav-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.95rem;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: rgba(34, 211, 238, 0.08);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
}

.brand-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-links a {
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.92rem;
    color: var(--text-muted);
    transition: color 0.2s ease, background 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active { color: var(--text); background: rgba(148, 163, 184, 0.08); }

.nav-links .nav-cta {
    margin-left: 8px;
    color: var(--accent-ink);
    background: var(--accent);
    font-weight: 600;
}
.nav-links .nav-cta:hover { color: var(--accent-ink); background: #67e8f9; }

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    flex: none;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    position: relative;
}

.menu-toggle span {
    position: absolute;
    left: 11px;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    transition: transform 0.3s var(--ease), opacity 0.2s ease;
}
.menu-toggle span:nth-child(1) { top: 14px; }
.menu-toggle span:nth-child(2) { top: 20px; }
.menu-toggle span:nth-child(3) { top: 26px; }

.menu-open .menu-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.mobile-menu {
    display: none;
}

@media (max-width: 960px) {
    .nav-links { display: none; }
    .menu-toggle { display: block; }

    .mobile-menu {
        position: fixed;
        top: var(--nav-h);
        left: 0;
        right: 0;
        bottom: 0;
        height: calc(100vh - var(--nav-h));
        height: calc(100dvh - var(--nav-h));
        overflow-y: auto;
        overscroll-behavior: contain;
        display: flex;
        flex-direction: column;
        padding: 24px var(--gutter);
        gap: 4px;
        background: rgba(5, 7, 13, 0.96);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity 0.25s ease, transform 0.25s var(--ease), visibility 0.25s;
    }

    .mobile-menu a {
        padding: 14px 4px;
        font-size: 1.25rem;
        font-weight: 600;
        border-bottom: 1px solid var(--border);
    }

    .menu-open .mobile-menu {
        opacity: 1;
        visibility: visible;
        transform: none;
        /* Become visible immediately on open so the first link can take focus. */
        transition: opacity 0.25s ease, transform 0.25s var(--ease), visibility 0s;
    }
}

/* ---------- Shared ---------- */

.section {
    position: relative;
    padding: clamp(80px, 12vw, 128px) 0;
}

.section-head {
    margin-bottom: clamp(32px, 5vw, 56px);
    max-width: 720px;
}

.section-index {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 8px;
}
.section-index::before { content: "// "; color: var(--text-dim); }

h1, h2, h3, h4 {
    margin: 0;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 700;
}

h2 { font-size: clamp(1.9rem, 4.2vw, 2.75rem); }

.section-sub {
    margin: 12px 0 0;
    color: var(--text-muted);
    font-size: 1.05rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 22px;
    border-radius: 10px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s var(--ease), background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 8px 30px -10px rgba(34, 211, 238, 0.6);
}
.btn-primary:hover { background: #67e8f9; }

.btn-ghost {
    background: rgba(148, 163, 184, 0.06);
    border-color: var(--border-strong);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); background: rgba(34, 211, 238, 0.08); }

.btn-sm { padding: 9px 16px; font-size: 0.875rem; }
.btn[disabled] { opacity: 0.6; cursor: progress; transform: none; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-3);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
    animation: pulse 2.2s infinite;
    flex: none;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.lang-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--c, var(--accent));
    flex: none;
}

.mini-head {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 14px;
}

kbd {
    font-family: var(--font-mono);
    font-size: 0.8em;
    padding: 1px 6px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: rgba(148, 163, 184, 0.08);
}

code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--tk-type);
}

/* Reveal on scroll (only when JS is running) */
.js .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
    transition-delay: var(--delay, 0s);
}
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Hero ---------- */

.hero {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    padding-top: calc(var(--nav-h) + 40px);
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: clamp(32px, 5vw, 64px);
    align-items: center;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 24px;
    padding: 6px 14px 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.hero h1 {
    font-size: clamp(2.4rem, 6vw, 4.25rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.04;
}

.gradient-text {
    background: linear-gradient(100deg, var(--accent) 0%, var(--accent-2) 55%, var(--accent-3) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lead {
    margin: 24px 0 0;
    max-width: 56ch;
    font-size: clamp(1.02rem, 1.6vw, 1.15rem);
    color: var(--text-muted);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 32px;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 48px 0 0;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

/* Number first visually, label first in the markup (dt/dd order). */
.hero-stats div { margin: 0; display: grid; grid-template-rows: auto 1fr; align-content: start; }
.hero-stats dt { grid-row: 2; }
.hero-stats dd {
    grid-row: 1;
    font-family: var(--font-mono);
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    margin: 0;
}
.hero-stats dt {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.35;
}

/* Code window */
.code-window {
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: rgba(9, 13, 22, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(34, 211, 238, 0.04), 0 0 60px -20px rgba(34, 211, 238, 0.25);
    overflow: hidden;
    min-width: 0;
}

.code-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(148, 163, 184, 0.04);
}

.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.code-filename {
    margin-left: 10px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.code-body {
    margin: 0;
    padding: 20px 20px 22px;
    font-family: var(--font-mono);
    font-size: clamp(0.74rem, 1.1vw, 0.86rem);
    line-height: 1.75;
    color: var(--text);
    overflow-x: auto;
    white-space: normal; /* lines are block spans; ignore the newlines between them */
    counter-reset: line;
}

.code-body code { color: inherit; font-size: inherit; }

.code-body .ln {
    display: block;
    white-space: pre;
    counter-increment: line;
}
.code-body .ln::before {
    content: counter(line);
    display: inline-block;
    width: 2ch;
    margin-right: 18px;
    text-align: right;
    color: var(--text-dim);
    opacity: 0.6;
}

.js .code-body .ln {
    opacity: 0;
    transform: translateX(-6px);
    animation: line-in 0.45s var(--ease) forwards;
}
.js .code-body .ln:nth-child(1) { animation-delay: 0.35s; }
.js .code-body .ln:nth-child(2) { animation-delay: 0.45s; }
.js .code-body .ln:nth-child(3) { animation-delay: 0.55s; }
.js .code-body .ln:nth-child(4) { animation-delay: 0.65s; }
.js .code-body .ln:nth-child(5) { animation-delay: 0.75s; }
.js .code-body .ln:nth-child(6) { animation-delay: 0.85s; }
.js .code-body .ln:nth-child(7) { animation-delay: 0.95s; }
.js .code-body .ln:nth-child(8) { animation-delay: 1.05s; }
.js .code-body .ln:nth-child(9) { animation-delay: 1.15s; }
.js .code-body .ln:nth-child(10) { animation-delay: 1.25s; }

@keyframes line-in { to { opacity: 1; transform: none; } }

.tk-k { color: var(--tk-keyword); }
.tk-s { color: var(--tk-string); }
.tk-n { color: var(--tk-number); }
.tk-t { color: var(--tk-type); }
.tk-v { color: #93c5fd; }
.tk-c { color: var(--tk-comment); font-style: italic; }

.caret {
    display: inline-block;
    width: 8px;
    height: 1.1em;
    margin-left: 4px;
    vertical-align: text-bottom;
    background: var(--accent);
    animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.scroll-hint {
    position: absolute;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}
.scroll-hint i { animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(5px); } }

@media (max-width: 960px) {
    .hero-grid { grid-template-columns: minmax(0, 1fr); }
    .hero { min-height: auto; padding-bottom: 96px; }
    .scroll-hint { display: none; }
}

@media (max-width: 560px) {
    .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
    .hero-actions .btn { flex: 1 1 auto; }
}

/* ---------- About ---------- */

.about-grid {
    display: grid;
    grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
    gap: clamp(32px, 6vw, 72px);
    align-items: start;
}

.about-photo {
    margin: 0;
    position: relative;
    border-radius: var(--radius);
    padding: 6px;
    background: linear-gradient(140deg, rgba(34, 211, 238, 0.55), rgba(167, 139, 250, 0.35) 50%, rgba(52, 211, 153, 0.4));
}

.about-photo img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: calc(var(--radius) - 4px);
    filter: saturate(0.95) contrast(1.02);
}

.about-copy p {
    margin: 0 0 18px;
    color: var(--text-muted);
    font-size: 1.06rem;
}

.facts {
    list-style: none;
    margin: 28px 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.facts li {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
}

.facts i {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    flex: none;
    border-radius: 10px;
    background: rgba(34, 211, 238, 0.08);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 0.9rem;
}

.facts b { margin-right: 8px; }

.socials {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.socials a {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease);
}
.socials a:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

@media (max-width: 760px) {
    .about-grid { grid-template-columns: minmax(0, 1fr); }
    .about-photo { max-width: 280px; }
}

/* ---------- GitHub stats ---------- */

.gh-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 20px;
}

.gh-grid .panel { padding: clamp(20px, 3vw, 32px); }

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.panel-head h3 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.panel-head h3 i { color: var(--accent); }
.panel-head .muted { font-size: 0.82rem; }
.link:hover { color: var(--accent); }

.lang-bar {
    display: flex;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.1);
    gap: 2px;
}

.lang-bar span {
    display: block;
    height: 100%;
    background: var(--c);
    width: 0;
    min-width: 0;
    transition: width 1.2s var(--ease);
}
.lang-bar.in span { width: var(--w); min-width: 3px; }

.lang-legend {
    list-style: none;
    margin: 24px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 24px;
}

.lang-legend li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.92rem;
}

.lang-legend .lang-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-legend .lang-pct {
    font-family: var(--font-mono);
    font-size: 0.84rem;
    color: var(--text-muted);
}

.footnote {
    margin: 18px 0 0;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 26px;
}

.kpi {
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(148, 163, 184, 0.04);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.recent {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recent li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
.recent li:last-child { border-bottom: 0; }

.recent a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recent a:hover { color: var(--accent); }
.recent .muted { font-size: 0.82rem; flex: none; }

@media (max-width: 900px) {
    .gh-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 480px) {
    .lang-legend { grid-template-columns: 1fr; }
}

/* ---------- Stack ---------- */

.stack-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.stack-card {
    padding: 26px;
    transition: border-color 0.25s ease, transform 0.3s var(--ease), background 0.25s ease;
}
.stack-card:hover { border-color: var(--border-strong); background: var(--surface-hover); transform: translateY(-3px); }

.stack-card h3 {
    font-size: 1.02rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.stack-card h3 i {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    font-size: 0.85rem;
    color: var(--accent);
    background: rgba(34, 211, 238, 0.08);
    border: 1px solid var(--border);
}

.chips,
.tech {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chips li {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(148, 163, 184, 0.05);
    font-size: 0.84rem;
    color: var(--text);
}

@media (max-width: 960px) {
    .stack-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .stack-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Work ---------- */

/* Client and personal cards share one layout: equal-width columns, last row centred. */
.projects,
.clients {
    --cols: 3;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}
.projects > *,
.clients > * {
    flex: 0 0 calc((100% - (var(--cols) - 1) * 20px) / var(--cols));
    min-width: 0;
}

.project {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 22px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    transition: border-color 0.25s ease, transform 0.3s var(--ease);
}

.project::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.project:hover { border-color: var(--border-strong); transform: translateY(-4px); }
.project:hover::before { opacity: 1; }


.project-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: rgba(148, 163, 184, 0.05);
}
.tag-accent { color: var(--accent); border-color: rgba(34, 211, 238, 0.35); background: rgba(34, 211, 238, 0.08); }
.tag.live { color: var(--accent-3); border-color: rgba(52, 211, 153, 0.3); }
.tag .status-dot { width: 6px; height: 6px; }

.project h4 {
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.project-summary {
    margin: 0 0 14px;
    color: var(--text-muted);
}

.project-points {
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 10px;
}

.project-points li {
    position: relative;
    padding-left: 22px;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.project-points li::before {
    content: "▹";
    position: absolute;
    left: 0;
    color: var(--accent);
}

.tech { margin-top: auto; padding-top: 6px; }
.tech li {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--tk-type);
    padding: 3px 9px;
    border-radius: 6px;
    background: rgba(103, 232, 249, 0.07);
}

.project-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.more-work {
    margin-top: 48px;
}

.more-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 12px;
}

.more-list a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: border-color 0.2s ease, background 0.2s ease;
}
.more-list a:hover { border-color: var(--accent); background: var(--surface-hover); }

.more-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}
.more-title::after {
    content: "↗";
    margin-left: auto;
    color: var(--text-dim);
    font-weight: 400;
}

.more-desc {
    font-size: 0.86rem;
    color: var(--text-muted);
    padding-left: 20px;
}

@media (max-width: 1000px) {
    .projects, .clients { --cols: 2; }
}
@media (max-width: 560px) {
    .projects, .clients { --cols: 1; }
}

/* ---------- Experience ---------- */

.role { padding: clamp(22px, 3.5vw, 36px); }

.role-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.role-head h3 { font-size: clamp(1.2rem, 2.4vw, 1.5rem); }
.role-head .muted { font-weight: 500; }
.role-head a.accent:hover { text-decoration: underline; text-underline-offset: 4px; }

.role-meta {
    margin: 8px 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.role-summary {
    margin: 20px 0 24px;
    max-width: 70ch;
    color: var(--text-muted);
}

.role-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 220px);
    gap: 32px;
    align-items: start;
}

.role-grid .project-points { margin: 0; }

.role-stats {
    margin: 0;
    display: grid;
    gap: 12px;
}

.role-stats div {
    display: flex;
    flex-direction: column-reverse;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(148, 163, 184, 0.04);
}

.role-stats dd {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.role-stats dt {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

@media (max-width: 760px) {
    .role-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
    .role-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.inline-link {
    color: var(--text);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(34, 211, 238, 0.5);
    text-underline-offset: 4px;
}
.inline-link:hover { color: var(--accent); }

/* ---------- Client work ---------- */

.group-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 0 20px;
    font-size: 1.15rem;
    font-weight: 600;
}
.group-head .muted { font-size: 0.82rem; font-weight: 400; }
.projects + .more-work { margin-top: 48px; }
.clients + .group-head { margin-top: 64px; }

.client {
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    transition: border-color 0.25s ease, transform 0.3s var(--ease);
}
.client:hover { border-color: var(--border-strong); transform: translateY(-4px); }

.client-shot {
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    background: var(--surface-solid);
}

.client-shot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: left top;
    transition: transform 0.6s var(--ease);
}
.client:hover .client-shot img { transform: scale(1.03); }

.client-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 22px;
}

.client-body h4 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.client-body .project-meta { margin-bottom: 14px; }
.client-body .project-summary,
.project .project-summary { font-size: 0.94rem; }

.client-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    min-height: 40px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--accent);
    align-self: flex-start;
    overflow-wrap: anywhere;
}
.client-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.client-link i { font-size: 0.72rem; }



/* ---------- Contact ---------- */

.contact-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.contact-form {
    padding: clamp(22px, 3vw, 32px);
    display: grid;
    gap: 18px;
}

.field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.field input,
.field textarea {
    width: 100%;
    padding: 13px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: rgba(5, 7, 13, 0.6);
    color: var(--text);
    font: inherit;
    font-size: 16px; /* prevents iOS zoom on focus */
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    resize: vertical;
}

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.contact-form .btn { justify-self: start; }

.form-status {
    margin: 0;
    min-height: 1.5em;
    font-size: 0.92rem;
}
.form-status.success { color: var(--accent-3); }
.form-status.error { color: var(--danger); }

.contact-side {
    display: grid;
    gap: 12px;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    transition: border-color 0.2s ease, background 0.2s ease;
    min-width: 0;
}
a.contact-card:hover { border-color: var(--accent); background: var(--surface-hover); }

.contact-card i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: none;
    border-radius: 11px;
    background: rgba(34, 211, 238, 0.08);
    color: var(--accent);
}

.contact-card span {
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
    overflow-wrap: anywhere;
}
.contact-card b { font-size: 0.8rem; font-weight: 500; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }

@media (max-width: 860px) {
    .contact-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
    .field-row { grid-template-columns: 1fr; }
    .contact-card span { font-size: 0.85rem; }
    .contact-form .btn { justify-self: stretch; }
}

/* ---------- Footer ---------- */

.footer {
    border-top: 1px solid var(--border);
    background: rgba(5, 7, 13, 0.7);
    padding: 28px 0;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.footer p { margin: 0; font-size: 0.82rem; }

.to-top {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: color 0.2s ease, border-color 0.2s ease;
}
.to-top:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .js .reveal { opacity: 1; transform: none; }
    .js .code-body .ln { opacity: 1; transform: none; }
}
