:root {
    --ink: #0e1b2a;
    --concrete: #e9ecef;
    --paper: #ffffff;
    --amber: #f5a300;
    --steel: #52626f;
    --line: #cdd3d9;
    --radius: 4px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--ink);
    background: var(--concrete);
}

h1, h2, h3, .brand {
    font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
    line-height: 1.05;
    margin: 0 0 .5em;
}

h1 {
    font-size: clamp(2.6rem, 6vw, 4.6rem);
    font-weight: 700;
    letter-spacing: -.01em;
}

h2 {
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 700;
}

h3 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: .3em;
}

p {
    max-width: 62ch;
    margin: 0 0 1em;
}

a {
    color: inherit;
}

:focus-visible {
    outline: 3px solid var(--amber);
    outline-offset: 3px;
}

.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
.site-header {
    background: var(--ink);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    gap: 1rem;
}

.brand {
    font-size: 1.9rem;
    font-weight: 700;
    text-decoration: none;
    margin: 0;
}

    .brand span {
        color: var(--amber);
    }

nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

    nav a {
        text-decoration: none;
        font-weight: 600;
    }

        nav a:not(.btn):hover {
            color: var(--amber);
        }

/* Buttons */
.btn {
    display: inline-block;
    background: var(--amber);
    color: var(--ink);
    font: 600 1rem "Source Sans 3", sans-serif;
    padding: .8em 1.5em;
    border: 2px solid var(--amber);
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
}

    .btn:hover {
        background: #ffb81f;
        border-color: #ffb81f;
    }

.btn-small {
    padding: .45em 1em;
}

.btn-ghost {
    background: transparent;
    color: inherit;
    border-color: currentColor;
}

    .btn-ghost:hover {
        background: rgba(255,255,255,.1);
        border-color: currentColor;
    }

/* Hero */
.hero {
    background: var(--ink);
    color: #fff;
    padding: 5rem 0 6rem;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 4rem;
    align-items: center;
}

.lead {
    font-size: 1.25rem;
    color: #c9d3dc;
}

.actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* Control panel */
.panel {
    background: #14283c;
    border: 2px solid #2a4258;
    border-radius: 8px;
    padding: 1.75rem;
    font-family: "Barlow Condensed", sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
}

.panel-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #2a4258;
}

    .panel-row span:nth-child(2) {
        flex: 1;
    }

.lamp {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3a5168;
}

    .lamp.on {
        background: var(--amber);
        box-shadow: 0 0 12px var(--amber);
        animation: glow 2.4s ease-in-out infinite alternate;
    }

.switch {
    width: 46px;
    height: 24px;
    border-radius: 12px;
    background: #3a5168;
    position: relative;
}

    .switch::after {
        content: "";
        position: absolute;
        top: 3px;
        left: 3px;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #fff;
        transition: transform .2s;
    }

    .switch.on {
        background: var(--amber);
    }

        .switch.on::after {
            transform: translateX(22px);
        }

.trace {
    height: 3px;
    margin: 1.5rem 0 .75rem;
    background: linear-gradient(90deg, var(--amber) 0 40%, #3a5168 40% 100%);
}

.panel-note {
    font-size: 1.1rem;
    color: #9fb0bf;
    font-weight: 400;
}

@keyframes glow {
    from {
        opacity: .55;
    }

    to {
        opacity: 1;
    }
}

/* Divisions */
.division {
    padding: 5rem 0;
}

.division-alt {
    background: var(--paper);
}

.split {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 4rem;
}

.split-head p {
    color: var(--steel);
}

.service-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

    .service-list li {
        padding: 1.5rem 0;
        border-top: 3px solid var(--ink);
    }

        .service-list li:first-child {
            padding-top: 1.5rem;
        }

    .service-list p {
        margin: 0;
        color: var(--steel);
    }

/* About */
.about {
    padding: 5rem 0;
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 4rem;
}

/* Contact */
.contact {
    background: var(--ink);
    color: #fff;
    padding: 5rem 0;
}

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 4rem;
}

.contact-lines a {
    color: var(--amber);
    font-weight: 600;
    text-decoration: none;
}

.form {
    display: grid;
    gap: 1rem;
}

    .form label {
        display: grid;
        gap: .35rem;
        font-weight: 600;
    }

    .form input, .form select, .form textarea {
        font: inherit;
        padding: .7em .8em;
        border: 2px solid #2a4258;
        border-radius: var(--radius);
        background: #14283c;
        color: #fff;
    }

    .form button {
        justify-self: start;
    }

/* Footer */
.site-footer {
    background: #08121d;
    color: #9fb0bf;
    padding: 1.5rem 0;
    font-size: .95rem;
}

    .site-footer .wrap {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        flex-wrap: wrap;
    }

@media (max-width: 860px) {
    .hero-grid, .split, .about-grid, .contact-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }

    .hero {
        padding: 3rem 0 4rem;
    }

    nav a:not(.btn) {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .lamp.on {
        animation: none;
    }
}

/* ============ Motion ============ */
.site-header {
    transition: box-shadow .2s;
}

    .site-header.scrolled {
        box-shadow: 0 4px 18px rgba(0,0,0,.35);
    }

/* Hero: drifting blueprint grid, headline rises once, current runs along the trace */
.hero {
    position: relative;
    overflow: hidden;
}

    .hero::before {
        content: "";
        position: absolute;
        inset: -60px;
        opacity: .5;
        background-image: linear-gradient(#1b3147 1px, transparent 1px), linear-gradient(90deg, #1b3147 1px, transparent 1px);
        background-size: 56px 56px;
        animation: drift 14s linear infinite;
    }

    .hero .wrap {
        position: relative;
    }

@keyframes drift {
    to {
        transform: translate(56px, 56px);
    }
}

.hero h1, .hero .lead, .hero .actions, .hero .panel {
    animation: rise .8s cubic-bezier(.2,.7,.2,1) both;
}

.hero .lead {
    animation-delay: .15s;
}

.hero .actions {
    animation-delay: .3s;
}

.hero .panel {
    animation-delay: .4s;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(28px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.trace {
    position: relative;
    overflow: hidden;
}

    .trace::after {
        content: "";
        position: absolute;
        top: 0;
        left: -30%;
        width: 30%;
        height: 100%;
        background: #fff;
        box-shadow: 0 0 14px 4px var(--amber);
        animation: run 2.2s linear infinite;
    }

@keyframes run {
    to {
        left: 100%;
    }
}

/* Switches flip in turn */
.switch.on {
    animation: swbg 6s infinite;
}

    .switch.on::after {
        animation: swknob 6s infinite;
    }

.panel-row:nth-child(2) .switch, .panel-row:nth-child(2) .switch::after {
    animation-delay: 1.2s;
}

@keyframes swbg {
    0%,40% {
        background: var(--amber);
    }

    50%,60% {
        background: #3a5168;
    }

    70%,100% {
        background: var(--amber);
    }
}

@keyframes swknob {
    0%,40% {
        transform: translateX(22px);
    }

    50%,60% {
        transform: none;
    }

    70%,100% {
        transform: translateX(22px);
    }
}

/* Scroll reveal */
.reveal {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1);
}

    .reveal.in {
        opacity: 1;
        transform: none;
    }

.service-list li {
    transition: border-color .2s, padding-left .25s;
}

    .service-list li:hover {
        border-color: var(--amber);
        padding-left: .75rem;
    }

/* ============ Section illustrations ============ */
.art {
    width: 100%;
    max-width: 440px;
    height: auto;
    margin-top: 2rem;
    display: block;
}

    .art .ink {
        fill: var(--ink);
    }

    .art.paused * {
        animation-play-state: paused !important;
    }

/* Industrial */
.breakers rect {
    fill: #24415c;
    stroke: var(--amber);
    stroke-width: 2;
}

.led {
    fill: var(--amber);
    animation: blink 1.8s infinite;
}

    .led.l2 {
        animation-delay: .6s;
    }

    .led.l3 {
        animation-delay: 1.2s;
    }

@keyframes blink {
    0%,100% {
        opacity: 1;
    }

    50% {
        opacity: .2;
    }
}

.gauge {
    fill: #24415c;
    stroke: #3a5168;
    stroke-width: 2;
}

.wire {
    fill: none;
    stroke: var(--amber);
    stroke-width: 4;
    stroke-dasharray: 10 8;
    animation: flow .8s linear infinite;
}

@keyframes flow {
    to {
        stroke-dashoffset: -18;
    }
}

.ring {
    fill: #24415c;
    stroke: #3a5168;
    stroke-width: 3;
}

.spin {
    stroke: #fff;
    stroke-width: 6;
    stroke-linecap: round;
    transform-box: fill-box;
    transform-origin: center;
    animation: spin 1.4s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hub {
    fill: var(--amber);
}

.bolt {
    fill: var(--amber);
    transform-origin: 330px 85px;
    animation: zap 2.4s infinite;
}

@keyframes zap {
    0%,70%,100% {
        opacity: .25;
    }

    75%,85% {
        opacity: 1;
        transform: scale(1.12);
    }
}

/* Software */
.win {
    fill: #fff;
    stroke: var(--ink);
    stroke-width: 3;
}

.winbar {
    fill: var(--ink);
}

.dot {
    fill: var(--amber);
}

.code rect {
    fill: var(--steel);
    transform-box: fill-box;
    transform-origin: left;
    animation: type 4.8s infinite;
    animation-delay: var(--d);
}

@keyframes type {
    0% {
        transform: scaleX(0);
    }

    20%,85% {
        transform: scaleX(1);
    }

    100% {
        transform: scaleX(0);
    }
}

.bars rect {
    fill: var(--amber);
    transform-box: fill-box;
    transform-origin: bottom;
    animation: grow 3s ease-in-out infinite alternate;
    animation-delay: var(--d);
}

@keyframes grow {
    from {
        transform: scaleY(.25);
    }

    to {
        transform: scaleY(1);
    }
}

.screen {
    fill: #24415c;
}

.pulse {
    fill: var(--amber);
    transform-box: fill-box;
    transform-origin: center;
    animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(.8);
        opacity: 1;
    }

    100% {
        transform: scale(1.35);
        opacity: .5;
    }
}

.line {
    fill: #3a5168;
}

.packet {
    fill: var(--amber);
    animation: send 1.6s ease-in-out infinite;
}

@keyframes send {
    0% {
        transform: translateX(0);
        opacity: 0;
    }

    20%,80% {
        opacity: 1;
    }

    100% {
        transform: translateX(20px);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }

    .code rect, .bars rect {
        transform: none;
    }
}

/* ============ Portfolio ============ */
.works {
    margin-top: 4rem;
    padding-top: 2.5rem;
    border-top: 3px solid var(--ink);
}

.works-title {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.work {
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .25s, border-color .25s;
}

.division-alt .work {
    background: var(--concrete);
}

.work:hover {
    transform: translateY(-6px);
    border-color: var(--amber);
}

.work-img {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--ink);
}

    .work-img img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transition: transform .5s;
    }

.work:hover .work-img img {
    transform: scale(1.06);
}

.work-body {
    padding: 1.1rem 1.2rem 1.3rem;
}

.work h4 {
    font: 700 1.45rem/1.1 "Barlow Condensed", sans-serif;
    margin: 0 0 .25rem;
}

.work-meta {
    color: var(--steel);
    font-size: .95rem;
    margin-bottom: .6rem;
}

.work-body p {
    margin-bottom: .6rem;
}

.work-link {
    font-weight: 600;
    color: var(--ink);
    text-decoration-color: var(--amber);
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
}

.notice {
    color: var(--amber);
    font-weight: 600;
    margin: 0;
}

/* ============ Admin ============ */
.admin {
    padding: 3rem 1.5rem 5rem;
}

    .admin.narrow {
        max-width: 640px;
    }

    .admin h1 {
        font-size: 2.4rem;
    }

.admin-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.inline {
    display: inline;
}

.btn-dark {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

    .btn-dark:hover {
        background: #1c3249;
        border-color: #1c3249;
    }

.aform {
    display: grid;
    gap: 1rem;
}

    .aform label {
        display: grid;
        gap: .35rem;
        font-weight: 600;
    }

    .aform input, .aform select, .aform textarea {
        font: inherit;
        padding: .65em .8em;
        border: 2px solid var(--line);
        border-radius: var(--radius);
        background: #fff;
    }

.err {
    color: #b3261e;
    font-weight: 600;
}

.table-scroll {
    overflow-x: auto;
}

.atable {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

    .atable th, .atable td {
        text-align: left;
        padding: .7rem .9rem;
        border-bottom: 1px solid var(--line);
        vertical-align: middle;
    }

    .atable img {
        border-radius: 3px;
        display: block;
    }

.actions-cell {
    white-space: nowrap;
}

    .actions-cell a {
        margin-right: .8rem;
        font-weight: 600;
    }

.link-danger {
    background: none;
    border: 0;
    padding: 0;
    font: 600 1rem "Source Sans 3", sans-serif;
    color: #b3261e;
    cursor: pointer;
}

/* ============ Contact form extras ============ */
.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.notice.error {
    color: #ff8a80;
}

/* ============ Admin nav and inbox ============ */
.anav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--line);
}

    .anav a {
        font-weight: 600;
        text-decoration: none;
        padding-bottom: .2rem;
        border-bottom: 3px solid transparent;
    }

        .anav a.on {
            border-color: var(--amber);
        }

    .anav .inline {
        margin-left: auto;
    }

.link-btn {
    background: none;
    border: 0;
    padding: 0;
    font: 600 1rem "Source Sans 3", sans-serif;
    color: var(--steel);
    cursor: pointer;
    text-decoration: underline;
}

.badge {
    display: inline-block;
    min-width: 1.4em;
    padding: 0 .4em;
    margin-left: .35rem;
    border-radius: 1em;
    background: var(--amber);
    color: var(--ink);
    font-size: .85rem;
    text-align: center;
}

.btn-danger {
    background: #b3261e;
    border-color: #b3261e;
    color: #fff;
}

    .btn-danger:hover {
        background: #8f1d17;
        border-color: #8f1d17;
    }

.inbox-bar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}

.tabs {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

    .tabs a {
        padding: .4em .9em;
        border: 2px solid var(--ink);
        border-radius: var(--radius);
        text-decoration: none;
        font-weight: 600;
    }

        .tabs a.on {
            background: var(--ink);
            color: #fff;
        }

.search {
    display: flex;
    gap: .5rem;
}

    .search input {
        font: inherit;
        padding: .45em .7em;
        border: 2px solid var(--line);
        border-radius: var(--radius);
        min-width: 220px;
    }

.bulk {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.inbox tr.unread td {
    font-weight: 700;
    background: #fff8e6;
}

.inbox .preview {
    color: var(--steel);
    font-weight: 400;
    max-width: 320px;
}

.inbox tr.unread .preview {
    font-weight: 400;
}

.nowrap {
    white-space: nowrap;
}

.star {
    background: none;
    border: 0;
    font-size: 1.3rem;
    color: #b8c0c7;
    cursor: pointer;
    line-height: 1;
}

    .star.on {
        color: var(--amber);
    }

.pager {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
    margin-top: 1.5rem;
}

.msg {
    background: #fff;
    border: 2px solid var(--ink);
    border-radius: 6px;
    padding: 1.5rem;
}

    .msg h1 {
        font-size: 2rem;
    }

.msg-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: .25rem 1rem;
    margin: 0 0 1.25rem;
}

    .msg-meta dt {
        font-weight: 700;
        color: var(--steel);
    }

    .msg-meta dd {
        margin: 0;
    }

.msg-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    border-top: 1px solid var(--line);
    padding-top: 1.25rem;
}

.msg-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}
.notice {
    padding: 14px 18px;
    margin: 15px 0;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.6;
}

    .notice.success {
        background: #e8f7ed;
        color: #18733b;
        border: 1px solid #b7e4c7;
    }

    .notice.error {
        background: #fff0f0;
        color: #b42318;
        border: 1px solid #f5c2c0;
    }