:root {
    --bg: #0b1f17;
    --bg-alt: #0f2a1f;
    --panel: #102820;
    --copper: #c97c4a;
    --copper-bright: #e8a54b;
    --signal: #6fe7d4;
    --text: #edeae0;
    --text-dim: #8fa89a;
    --line: #234636;
    --line-bright: #2f5a44;
    --radius: 2px;
    --mono: 'IBM Plex Mono', monospace;
    --sans: 'IBM Plex Sans', sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.6;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* background trace texture */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 64px 64px;
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

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

a:focus-visible,
button:focus-visible,
.toggle:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 3px;
}

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 32px;
    position: relative;
    z-index: 1;
}

/* ---------- NAV ---------- */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(11, 31, 23, 0.88);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
}

nav.wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 18px;
    padding-bottom: 18px;
}

.logo {
    font-family: var(--mono);
    font-size: 14px;
    letter-spacing: 0.02em;
    color: var(--copper-bright);
    font-weight: 600;
}

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

.navlinks {
    display: flex;
    gap: 28px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.navlinks a {
    color: var(--text-dim);
    position: relative;
    padding-bottom: 2px;
    transition: color .2s;
}

.navlinks a:hover {
    color: var(--signal);
}

.navlinks a::before {
    content: attr(data-addr);
    color: var(--copper);
    margin-right: 6px;
}

/* ---------- HERO ---------- */
.hero {
    position: relative;
    padding: 120px 0 96px;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 48px;
    align-items: center;
}

.eyebrow {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--copper);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.eyebrow::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--signal);
    box-shadow: 0 0 8px var(--signal);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.35;
    }
}

h1.name {
    font-family: var(--mono);
    font-weight: 700;
    font-size: clamp(38px, 6vw, 64px);
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--text);
}

h1.name em {
    font-style: normal;
    color: var(--copper-bright);
}

.role {
    font-family: var(--sans);
    font-size: 19px;
    color: var(--text-dim);
    margin-top: 18px;
    max-width: 46ch;
}

.hero-links {
    margin-top: 32px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.btn {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.04em;
    padding: 11px 18px;
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    color: var(--text);
    transition: border-color .2s, color .2s, background .2s;
}

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

.btn.solid {
    background: var(--copper);
    border-color: var(--copper);
    color: #0b1f17;
    font-weight: 600;
}

.btn.solid:hover {
    background: var(--copper-bright);
    border-color: var(--copper-bright);
    color: #0b1f17;
}

/* schematic svg */
.schematic {
    width: 100%;
    height: auto;
}

.schematic path.trace {
    fill: none;
    stroke: var(--line-bright);
    stroke-width: 1.5;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: draw 1.8s ease forwards;
}

.schematic path.trace.hot {
    stroke: var(--copper);
}

.schematic path.trace:nth-child(2) {
    animation-delay: .15s;
}

.schematic path.trace:nth-child(3) {
    animation-delay: .3s;
}

.schematic path.trace:nth-child(4) {
    animation-delay: .45s;
}

@keyframes draw {
    to {
        stroke-dashoffset: 0;
    }
}

.schematic circle.node {
    fill: var(--bg);
    stroke: var(--copper-bright);
    stroke-width: 1.5;
}

.schematic circle.pulse {
    fill: var(--signal);
    animation: blink 2.4s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }
}

.schematic text {
    font-family: var(--mono);
    fill: var(--text-dim);
    font-size: 9px;
}

/* ---------- SECTION SHELL ---------- */
section {
    padding: 88px 0;
    border-bottom: 1px solid var(--line);
    position: relative;
}

.sec-head {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 48px;
}

.addr {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--copper);
    letter-spacing: 0.06em;
}

h2 {
    font-family: var(--mono);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}

.sec-rule {
    flex: 1;
    height: 1px;
    background: var(--line-bright);
}

/* ---------- ABOUT / EDU ---------- */
.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.about-grid p {
    color: var(--text-dim);
    font-size: 16px;
    max-width: 52ch;
}

.about-grid p+p {
    margin-top: 16px;
}

.edu-card {
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    padding: 24px;
    background: var(--panel);
}

.edu-card .school {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--copper-bright);
    font-size: 15px;
}

.edu-card .deg {
    color: var(--text-dim);
    margin-top: 4px;
    font-size: 14px;
}

.edu-card .dates {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 10px;
    letter-spacing: 0.04em;
}

.courses {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.courses span {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--signal);
    border: 1px solid var(--line-bright);
    padding: 4px 8px;
    border-radius: var(--radius);
    letter-spacing: 0.03em;
}

/* ---------- PROJECTS / EXPERIENCE CARDS ---------- */
/* .project is shared by both #projects and #experience — each entry (project
   or job) renders as its own bordered panel with a header row and a body. */
.project {
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    background: var(--panel);
    margin-bottom: 24px;
    overflow: hidden;
}

.project-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 26px 28px 0;
    gap: 20px;
    flex-wrap: wrap;
}

.project-title {
    font-family: var(--mono);
    font-size: 19px;
    font-weight: 600;
    color: var(--text);
}

.project-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.project-tags span {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--copper-bright);
    border: 1px solid var(--line-bright);
    padding: 3px 7px;
    border-radius: var(--radius);
}

.project-addr {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--copper);
    white-space: nowrap;
}

.project-body {
    padding: 18px 28px 28px;
}

.project-body ul {
    list-style: none;
}

.project-body li {
    position: relative;
    padding-left: 18px;
    color: var(--text-dim);
    font-size: 14.5px;
    margin-bottom: 8px;
}

.project-body li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--copper);
}

/* Org / dates / location text used inside experience entries */
.tl-org {
    color: var(--copper-bright);
    font-size: 14px;
    font-family: var(--mono);
    font-weight: 600;
}

.tl-dates {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    letter-spacing: 0.04em;
}

.tl-loc {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
    margin-bottom: 14px;
    letter-spacing: 0.02em;
}

.tl-loc+ul,
.tl-dates+ul {
    margin-top: 14px;
}

/* ---------- PROJECT / EXPERIENCE ENTRY WITH MEDIA ---------- */
/* Shared two-column layout: media on the left, text on the right. */
.project-body.has-media {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.3fr);
    gap: 28px;
    align-items: start;
}

/* Clickable variant — projects (opens a modal) */
.media-trigger {
    position: relative;
    display: block;
    width: 100%;
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    background: var(--bg);
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    line-height: 0;
    transition: border-color .2s;
}

.media-trigger:hover,
.media-trigger:focus-visible {
    border-color: var(--copper);
}

.media-trigger:hover .thumb-img,
.media-trigger:focus-visible .thumb-img {
    transform: scale(1.03);
    filter: brightness(0.75);
}

.media-trigger:hover .media-hint,
.media-trigger:focus-visible .media-hint {
    opacity: 1;
    transform: translateY(0);
}

/* Non-clickable variant — experience (photo only, no modal) */
.media-frame {
    display: block;
    width: 100%;
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    background: var(--bg);
    overflow: hidden;
    line-height: 0;
}

.thumb-img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transition: transform .4s ease, filter .4s ease;
}

.media-hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.05em;
    color: var(--text);
    background: linear-gradient(to top, rgba(11, 31, 23, 0.92), rgba(11, 31, 23, 0));
    transform: translateY(4px);
    opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
}

.hint-icon {
    color: var(--copper-bright);
}

/* ALU demo */
.alu-demo {
    margin-top: 20px;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}

.alu-label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--signal);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.alu-panel {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.bit-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bit-group .bg-label {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

.bits {
    display: flex;
    gap: 6px;
}

.bit {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line-bright);
    background: var(--bg);
    border-radius: var(--radius);
    font-family: var(--mono);
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    transition: all .15s;
}

.bit.on {
    background: var(--copper);
    border-color: var(--copper);
    color: #0b1f17;
    font-weight: 700;
}

.bit:hover {
    border-color: var(--copper-bright);
}

.op-select {
    font-family: var(--mono);
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    padding: 9px 10px;
    font-size: 13px;
}

.op-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.out-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.out-bits {
    display: flex;
    gap: 6px;
    align-items: center;
}

.out-bit {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text-dim);
    background: var(--bg);
}

.out-bit.lit {
    background: var(--signal);
    color: #0b1f17;
    border-color: var(--signal);
    font-weight: 700;
}

.flags {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
}

.flags .flag.active {
    color: var(--copper-bright);
}

/* ---------- MEDIA GALLERY / VIDEO MODALS ---------- */
/* Shared by every project modal. Three variants:
     .modal-panel                        — video/image top + desc, then image + video below
     .modal-panel--single                — single centered piece of media (Toy Reverse Engineering) */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(6, 16, 12, 0.86);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility 0s linear .3s;
}

.modal-overlay[hidden] {
    display: flex;
    /* keep flex so transition can run before hidden is reapplied */
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
    transition: opacity .3s ease;
}

.modal-panel {
    position: relative;
    width: 100%;
    max-width: 980px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    padding: 28px;
    transform: translateY(14px) scale(0.98);
    opacity: 0;
    transition: transform .3s ease, opacity .3s ease;
}

.modal-overlay.open .modal-panel {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-panel--single {
    max-width: 560px;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 14px;
    cursor: pointer;
    transition: color .2s, border-color .2s;
    z-index: 2;
}

.modal-close:hover {
    color: var(--copper-bright);
    border-color: var(--copper);
}

.modal-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: center;
    padding-right: 44px;
}

.modal-desc h3 {
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 600;
    color: var(--copper-bright);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 12px;
}

.modal-desc p {
    color: var(--text-dim);
    font-size: 14px;
    margin-top: 10px;
}

.modal-desc ul {
    list-style: none;
}

.modal-desc li {
    position: relative;
    padding-left: 18px;
    color: var(--text-dim);
    font-size: 14px;
    margin-top: 10px;
}

.modal-desc li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--copper);
}

.modal-desc--solo {
    margin-top: 20px;
    text-align: left;
}

.modal-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 28px;
}

.modal-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-cell figcaption {
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

.modal-media {
    display: block;
    width: 100%;
    border: 1px solid var(--line-bright);
    border-radius: var(--radius);
    background: #000;
}

.crop-square {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    /* Footage is shot 9:16 on mobile — adjust object-position per clip via
       the id rules below to keep the subject centered once cropped square. */
    object-position: center 38%;
}

/* Autonomous Wheelchair */
#wheelchairVideoMain {
    object-position: center 42%;
}

#wheelchairVideoMoving {
    object-position: center 30%;
}

/* Kinder Egg Rescue Boat Toy */
#kinderEggImageMain {
    object-position: center 40%;
}

#kinderEggImageSecondary {
    object-position: center 40%;
}

#kinderEggVideoMain {
    object-position: center 40%;
}

/* Mechanical Toy Reverse Engineering — single-video modal */
.modal-video-title {
    font-family: var(--mono);
    font-size: 17px;
    font-weight: 600;
    color: var(--copper-bright);
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 18px;
    padding-right: 34px;
}

.modal-video-solo {
    max-width: 420px;
    margin: 0 auto;
    object-position: center 40%;
}

/* ---------- BOTTOM SPACER ---------- */
.page-end-space {
    height: 96px;
}

@media (max-width:820px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .schematic {
        max-width: 340px;
        margin-top: 20px;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }

    .registers {
        grid-template-columns: 1fr;
    }

    .navlinks {
        display: none;
    }

    .alu-panel {
        gap: 18px;
    }

    .project-body.has-media {
        grid-template-columns: 1fr;
    }

    .thumb-img {
        aspect-ratio: 16 / 9;
    }

    .media-hint {
        opacity: 1;
        transform: translateY(0);
    }

    .modal-panel {
        padding: 20px;
        padding-top: 56px;
    }

    .modal-top {
        grid-template-columns: 1fr;
        padding-right: 0;
        gap: 16px;
    }

    .modal-top .crop-square {
        max-width: 320px;
        margin: 0 auto;
    }

    .modal-bottom {
        grid-template-columns: 1fr;
    }

    .modal-video-solo {
        max-width: 280px;
    }

    .page-end-space {
        height: 56px;
    }
}