/* ---------------------------------------------------------
   Tokens
   --------------------------------------------------------- */

:root {
    --bg: #ffffff;
    --bg-muted: #f2f2f0;
    --text: #111111;
    --text-muted: #6b6b6b;
    --rule: #e3e3e0;
    --placeholder: #ebebe8;
    --placeholder-text: #a3a3a0;
    --text-soft: #333333;
    --header-bg: rgba(255, 255, 255, 0.92);
    --overlay: rgba(255, 255, 255, 0.97);

    --font-display: "Poppins", "Helvetica Neue", Arial, sans-serif;
    --font-body: "Poppins", "Helvetica Neue", Arial, sans-serif;

    --max-width: 1200px;
    --gutter: clamp(16px, 4vw, 40px);
    --gap: clamp(12px, 2vw, 24px);
    --header-height: 72px;

    color-scheme: light;
}

/* Dark theme: follows the system unless the toggle picked one */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111111;
        --bg-muted: #1a1a1a;
        --text: #ededeb;
        --text-muted: #9a9a97;
        --rule: #2c2c2a;
        --placeholder: #1f1f1e;
        --placeholder-text: #5e5e5b;
        --text-soft: #cfcfcc;
        --header-bg: rgba(17, 17, 17, 0.92);
        --overlay: rgba(17, 17, 17, 0.97);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #111111;
    --bg-muted: #1a1a1a;
    --text: #ededeb;
    --text-muted: #9a9a97;
    --rule: #2c2c2a;
    --placeholder: #1f1f1e;
    --placeholder-text: #5e5e5b;
    --text-soft: #cfcfcc;
    --header-bg: rgba(17, 17, 17, 0.92);
    --overlay: rgba(17, 17, 17, 0.97);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    font-family: var(--font-body);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 16px;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.muted {
    color: var(--text-muted);
}


/* ---------------------------------------------------------
   Layout
   --------------------------------------------------------- */

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.container.narrow {
    max-width: 800px;
}

.section {
    padding: clamp(48px, 7vw, 88px) var(--gutter) 0;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;

    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--text);
}

.section-head h2,
.page-head h1 {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.section-head h2 {
    font-size: 1rem;
}

.page-head {
    padding-top: clamp(40px, 7vw, 80px);
    padding-bottom: clamp(28px, 4vw, 48px);
}

.page-head h1 {
    font-size: clamp(2rem, 5vw, 3.25rem);
}

.page-head p {
    max-width: 620px;
    margin: 14px 0 0;
    color: var(--text-muted);
    font-size: 1.05rem;
}

.eyebrow {
    display: block;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.more,
.back {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--text-muted);
    white-space: nowrap;
}

.more:hover,
.back:hover {
    color: var(--text);
}

.back {
    display: inline-block;
    margin-bottom: 20px;
}


/* ---------------------------------------------------------
   Header
   --------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;

    background: var(--header-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--rule);
}

.nav-container {
    max-width: var(--max-width);
    height: var(--header-height);
    margin: 0 auto;
    padding: 0 var(--gutter);

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-decoration: none;
}

.site-nav {
    display: flex;
    margin-left: auto;
    gap: clamp(18px, 2.5vw, 36px);
}

.site-nav a {
    position: relative;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.15s;
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--text);
}

.site-nav a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 1px;
    background: var(--text);
}

/* Keyboards dropdown: opens on hover or keyboard focus */
.nav-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: -16px;
    min-width: 180px;
    padding: 8px 0;
    margin-top: 12px;

    display: flex;
    flex-direction: column;

    background: var(--bg);
    border: 1px solid var(--rule);

    visibility: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

/* Invisible bridge so the menu stays open while the pointer moves down */
.dropdown-menu::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -13px;
    height: 13px;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu {
    visibility: visible;
    opacity: 1;
    transform: none;
}

.site-nav .dropdown-menu a {
    padding: 8px 16px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}

.dropdown-menu:empty {
    display: none;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: clamp(12px, 2vw, 28px);
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s;
}

.theme-toggle:hover {
    color: var(--text);
}

.nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    margin-right: -8px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 1.5px;
    margin: 6px auto;
    background: var(--text);
    transition: transform 0.2s;
}

.nav-toggle[aria-expanded="true"] span:first-child {
    transform: translateY(3.75px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:last-child {
    transform: translateY(-3.75px) rotate(-45deg);
}

@media (max-width: 760px) {
    .nav-toggle {
        display: block;
    }

    .theme-toggle {
        margin-left: auto;
    }

    .nav-dropdown {
        flex-direction: column;
        align-items: stretch;
    }

    /* On small screens the projects are listed under Keyboards */
    .dropdown-menu {
        position: static;
        min-width: 0;
        margin: 0;
        padding: 0 0 8px 16px;
        border: 0;
        visibility: visible;
        opacity: 1;
        transform: none;
    }

    .dropdown-menu::before {
        display: none;
    }

    .site-nav .dropdown-menu a {
        padding: 8px 0;
    }

    .site-nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;

        flex-direction: column;
        gap: 0;
        padding: 8px var(--gutter) 20px;

        background: var(--bg);
        border-bottom: 1px solid var(--rule);
    }

    .site-nav.open {
        display: flex;
    }

    .site-nav a {
        padding: 12px 0;
        font-size: 0.95rem;
    }

    .site-nav a.active::after {
        display: none;
    }
}


/* ---------------------------------------------------------
   Media placeholders
   An <img> sits over a grey box. If the file doesn't exist
   yet the image removes itself and the upload path shows.
   --------------------------------------------------------- */

.media {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    background: var(--placeholder);
}

.media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    transition: transform 0.6s ease;
}

.media-hint {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;

    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.72rem;
    text-align: center;
    word-break: break-all;
    color: var(--placeholder-text);
}

.media-hint::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 22px;
    margin: -44px 0 0 -14px;
    border: 1.5px solid currentColor;
    border-radius: 3px;
    background:
        radial-gradient(circle at 70% 30%, currentColor 2px, transparent 2.5px),
        linear-gradient(135deg, transparent 55%, currentColor 55% 60%, transparent 60%);
}

.media-hero {
    aspect-ratio: 16 / 9;
}

.media-portrait {
    aspect-ratio: 4 / 5;
}

[data-lightbox] {
    cursor: zoom-in;
}


/* ---------------------------------------------------------
   Home
   --------------------------------------------------------- */

.feature-link {
    position: relative;
    display: block;
    text-decoration: none;
}

.feature .media-hero {
    aspect-ratio: auto;
    height: min(78vh, 56.25vw);
    min-height: 320px;
}

.feature-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: clamp(20px, 4vw, 40px);
    z-index: 2;
    margin: 0 auto;
    pointer-events: none;
}

.feature-name {
    display: block;
    margin-top: 4px;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 600;
}

.feature-link:hover .media img {
    transform: scale(1.015);
}

.intro {
    padding-top: clamp(48px, 7vw, 88px);
}

.intro h1 {
    max-width: 760px;
    margin: 0;
    font-size: clamp(1.6rem, 3.6vw, 2.6rem);
    font-weight: 500;
}


/* ---------------------------------------------------------
   Grids
   --------------------------------------------------------- */

.grid {
    display: grid;
    gap: var(--gap);
}

.grid-projects {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    row-gap: clamp(28px, 4vw, 48px);
}

.grid-gallery {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-flow: dense;
}

.gallery-item {
    margin: 0;
}

/* Feature tile: takes a 2x2 block of the mosaic */
.gallery-item.wide {
    grid-column: span 2;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
}

.gallery-item.wide .media {
    flex: 1;
    aspect-ratio: auto;
    min-height: 240px;
}

.gallery-item figcaption {
    padding-top: 10px;
    font-size: 0.85rem;
}

.gallery-item figcaption:empty {
    display: none;
}

.gallery-item .media:hover img {
    transform: scale(1.02);
}

@media (max-width: 900px) {
    .grid-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .grid-gallery {
        grid-template-columns: 1fr;
    }

    .gallery-item.wide {
        grid-column: auto;
        grid-row: auto;
    }

    .gallery-item.wide .media {
        flex: none;
        aspect-ratio: 4 / 3;
        min-height: 0;
    }
}


/* ---------------------------------------------------------
   Project cards
   --------------------------------------------------------- */

.card {
    display: block;
    text-decoration: none;
}

.card:hover .media img {
    transform: scale(1.025);
}

.card-caption {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding-top: 14px;
}

.card-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.card-summary {
    margin: 6px 0 0;
    font-size: 0.92rem;
    color: var(--text-muted);
}


/* ---------------------------------------------------------
   Project page
   --------------------------------------------------------- */

.project-body {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) 2fr;
    gap: clamp(28px, 6vw, 80px);
    padding-top: clamp(36px, 5vw, 64px);
}

.specs {
    margin: 0;
    border-top: 1px solid var(--text);
}

.specs div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.9rem;
}

.specs dt {
    color: var(--text-muted);
}

.specs dd {
    margin: 0;
    text-align: right;
}

@media (max-width: 760px) {
    .project-body {
        grid-template-columns: 1fr;
    }
}


/* ---------------------------------------------------------
   Prose
   --------------------------------------------------------- */

.prose {
    max-width: 680px;
    font-size: 1.05rem;
}

.prose p {
    margin: 0 0 1.2em;
}

.prose a {
    text-underline-offset: 3px;
}

.lead {
    font-size: 1.25rem;
    line-height: 1.5;
}

article .media-hero {
    margin-bottom: clamp(28px, 4vw, 48px);
}


/* ---------------------------------------------------------
   Blog cards
   --------------------------------------------------------- */

.post-list {
    display: flex;
    flex-direction: column;
}

.post-card {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: clamp(20px, 4vw, 48px);
    align-items: center;
    padding: clamp(24px, 3vw, 36px) 0;
    border-bottom: 1px solid var(--rule);
}

.post-card:first-child {
    padding-top: 0;
}

.post-card .media {
    aspect-ratio: 16 / 9;
}

.post-card .media:hover img {
    transform: scale(1.02);
}

.post-card h3 {
    margin: 0;
    font-size: clamp(1.25rem, 2.4vw, 1.6rem);
}

.post-card h3 a {
    text-decoration: none;
}

.post-card h3 a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.post-date {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.post-excerpt {
    margin: 12px 0 16px;
    color: var(--text-soft);
}

@media (max-width: 640px) {
    .post-card {
        grid-template-columns: 1fr;
    }
}


/* ---------------------------------------------------------
   About / Contact
   --------------------------------------------------------- */

.about {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: clamp(28px, 6vw, 80px);
    align-items: start;
}

@media (max-width: 760px) {
    .about {
        grid-template-columns: 1fr;
    }
}

.contact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 40px;
    padding-top: 28px;
    border-top: 1px solid var(--text);
}

.contact-email {
    display: inline-block;
    margin-top: 10px;
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    text-underline-offset: 5px;
    word-break: break-all;
}

.contact-links {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.contact-links li {
    padding: 4px 0;
}


/* ---------------------------------------------------------
   Footer
   --------------------------------------------------------- */

.site-footer {
    margin-top: clamp(72px, 10vw, 128px);
    padding: 32px 0;
    border-top: 1px solid var(--rule);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.footer-inner p {
    margin: 0;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.socials {
    display: flex;
    gap: 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.socials a {
    text-decoration: none;
}

.socials a:hover {
    color: var(--text);
}


/* ---------------------------------------------------------
   Lightbox
   --------------------------------------------------------- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px var(--gutter) 24px;

    background: var(--overlay);
    cursor: zoom-out;
}

.lightbox[hidden] {
    display: none;
}

.lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 140px);
    object-fit: contain;
}

.lightbox-caption {
    margin: 16px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: 0;
    background: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--text);
    cursor: pointer;
}


/* ---------------------------------------------------------
   Project files (STEP / PDF downloads)
   --------------------------------------------------------- */

.downloads {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--text);
}

.downloads li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.9rem;
}

.downloads a + a {
    margin-left: 16px;
}


/* ---------------------------------------------------------
   References (NBPT)
   --------------------------------------------------------- */

.references {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 40px;
    padding-top: 28px;
    border-top: 1px solid var(--text);
}

.ref-list {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.ref-list li {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
    font-size: 0.9rem;
}

.ref-list a {
    text-underline-offset: 3px;
}

.ref-list .muted {
    font-size: 0.85rem;
}

.prose h3 {
    margin: 1.4em 0 0.4em;
    font-size: 1rem;
}


/* ---------------------------------------------------------
   Technical drawings: show the whole sheet, keep paper white
   --------------------------------------------------------- */

.media-drawing {
    aspect-ratio: 1191 / 842;
    background: #ffffff;
    border: 1px solid var(--rule);
}

.media-drawing img {
    object-fit: contain;
}

