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

:root {
    --ink: #000;
    --paper: #fff;
    --page-pad: clamp(0.65rem, 1.75vw, 1.15rem);
    --row-pad-top: clamp(1.75rem, 4vw, 2.5rem);
    --row-pad-bottom: 0.75rem;
    --row-min-height: clamp(6.5rem, 16vh, 9.5rem);
    --font-mono: "SF Mono", "Menlo", "Monaco", "Consolas", "Liberation Mono",
        "Courier New", monospace;
    --font-sans: "Inter", system-ui, sans-serif;
}

html {
    scroll-behavior: smooth;
    height: 100%;
}

html:has(.assignment-layout) {
    overflow: hidden;
}

body {
    margin: 0;
    min-height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-mono);
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    line-height: 1.4;
    letter-spacing: 0.02em;
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

body:has(.assignment-layout) {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

/* —— Sticky header (stays fixed while content scrolls) —— */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem var(--page-pad);
    background: var(--paper);
    border-bottom: 1px solid var(--ink);
}

.header-name,
.header-class,
.header-term {
    margin: 0;
    font-size: inherit;
    font-weight: 400;
    text-transform: uppercase;
    white-space: nowrap;
}

.header-name {
    justify-self: start;
    color: inherit;
    text-decoration: none;
}

.header-name:hover {
    text-decoration: underline;
}

.header-back {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
}

.header-back:hover {
    text-decoration: none;
}

.header-back:hover .header-back-label {
    text-decoration: underline;
}

.header-back-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45em;
    line-height: 1;
    text-decoration: none;
}

.header-back-label {
    line-height: 1;
}

.header-class {
    justify-self: center;
    text-align: center;
}

.header-term {
    justify-self: end;
    text-align: right;
}

/* —— About page —— */
.about-page {
    padding: clamp(2rem, 6vw, 4rem) var(--page-pad);
    max-width: 58rem;
}

.about-heading {
    margin: 0 0 1rem;
    font-family: var(--font-sans);
    font-size: clamp(1.4rem, 2.8vw, 1.85rem);
    font-weight: 500;
    letter-spacing: 0;
}

.about-intro {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.about-photo {
    display: block;
    flex: 0 0 auto;
    width: min(38%, 16rem);
    height: auto;
    margin: 0;
}

.assignment-date-label {
    margin: 0 0 0.35rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0;
    opacity: 0.65;
}

.about-body {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-sans);
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.6;
}

@media (max-width: 640px) {
    .about-intro {
        flex-direction: column;
    }

    .about-photo {
        width: min(100%, 16rem);
    }
}

/* —— Assignment list —— */
.assignment-list {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

.assignment-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    min-height: var(--row-min-height);
    padding: var(--row-pad-top) var(--page-pad) var(--row-pad-bottom);
    border-bottom: 1px solid var(--ink);
    font-family: var(--font-sans);
    font-size: clamp(1.4rem, 2.8vw, 1.85rem);
    font-weight: 500;
    letter-spacing: 0;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.assignment-row:hover {
    background-color: #ecff6f;
    color: #00aaf3;
}

.assignment-title {
    flex: 1 1 auto;
    min-width: 0;
}

.assignment-date {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}

/* —— Assignment documentation layout —— */
.assignment-layout {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.assignment-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    width: clamp(16rem, 34%, 28rem);
    border-right: 1px solid var(--ink);
    overflow: hidden;
}

.assignment-meta {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 0.75rem clamp(1rem, 2.5vw, 1.5rem) clamp(1.25rem, 3vw, 2rem);
}

.assignment-back {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    align-self: flex-start;
    margin-left: -0.35rem;
    color: inherit;
    font-family: var(--font-mono);
    font-size: inherit;
    letter-spacing: 0.02em;
    line-height: 1;
    text-transform: uppercase;
    text-decoration: none;
}

.assignment-back:hover {
    text-decoration: none;
}

.assignment-back:hover .header-back-label {
    text-decoration: underline;
}

.assignment-meta-footer {
    margin-top: auto;
}

.assignment-date-large {
    margin: 0 0 0.55rem;
    font-family: var(--font-sans);
    font-size: clamp(1.35rem, 2.4vw, 1.75rem);
    font-weight: 500;
    line-height: 0.95;
    letter-spacing: -0.02em;
    color: #c8c8c8;
    font-variant-numeric: tabular-nums;
}

.assignment-titles {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-family: var(--font-sans);
    font-size: clamp(1.85rem, 3.4vw, 2.5rem);
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.2;
}

.todo-panel {
    margin-top: auto;
    flex: 0 0 auto;
    padding: clamp(1rem, 2.5vw, 1.35rem) clamp(1rem, 2.5vw, 1.5rem)
        clamp(1.25rem, 3vw, 1.75rem);
    background: #ecff6f;
    border-top: 1px solid var(--ink);
}

.todo-heading {
    margin: 0 0 0.75rem;
    font-family: var(--font-mono);
    font-size: clamp(0.8rem, 1.35vw, 0.95rem);
    font-weight: 400;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.todo-list {
    margin: 0;
    padding: 0 0 0 1.15rem;
    font-family: var(--font-mono);
    font-size: clamp(0.72rem, 1.2vw, 0.85rem);
    line-height: 1.45;
    letter-spacing: 0.01em;
}

.todo-list li + li {
    margin-top: 0.55rem;
}

.assignment-docs {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    min-height: 0;
    margin-left: clamp(16rem, 34%, 28rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.doc-section {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 0;
    border-bottom: 1px solid var(--ink);
}

.doc-section:last-child {
    border-bottom: none;
    flex: 1 1 auto;
}

.doc-section-title {
    margin: 0;
    padding: 0.85rem clamp(1rem, 2.5vw, 1.5rem);
    border-bottom: 1px solid var(--ink);
    font-family: var(--font-mono);
    font-size: clamp(0.8rem, 1.35vw, 0.95rem);
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.doc-body {
    flex: 1 1 auto;
    padding: clamp(1rem, 2.5vw, 1.5rem);
    font-family: var(--font-sans);
    font-size: clamp(0.95rem, 1.6vw, 1.05rem);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.6;
}

.doc-body > *:first-child {
    margin-top: 0;
}

.doc-body > *:last-child {
    margin-bottom: 0;
}

.doc-body img {
    display: block;
    max-width: 100%;
    height: auto;
}

.doc-media {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 0 0 50%;
    width: 50%;
    max-width: 50%;
    margin-top: 0;
}

.doc-media + .doc-media {
    margin-top: 0.75rem;
}

.doc-media img {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    height: auto;
    object-fit: contain;
}

.kit-flow::after {
    content: "";
    display: block;
    clear: both;
}

.kit-figure {
    float: left;
    clear: left;
    width: 34%;
    margin: 0.15rem 1rem 1.25rem 0;
}

.kit-figure.kit-hero {
    width: 52%;
}

.kit-figure img {
    display: block;
    width: 100%;
    height: auto;
}

.kit-pair {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    clear: both;
    width: 100%;
    margin: 1.35rem 0;
}

.kit-pair .kit-figure {
    float: none;
    clear: none;
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    margin: 0;
}

.kit-pair img {
    width: auto;
    height: 13rem;
    max-width: none;
}

.kit-pair-full .kit-figure {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
}

.kit-pair-full img {
    width: 100%;
    height: 20rem;
    object-fit: contain;
    object-position: center;
}

.embed-hero {
    display: block;
    width: 62%;
    max-width: 100%;
    height: auto;
    margin: 0 0 1.35rem;
    object-fit: contain;
}

.doc-caption + .embed-hero {
    margin-top: 1rem;
}

.embed-assemble {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.embed-assemble-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.print-intro {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.print-intro-copy {
    flex: 0 1 46%;
    max-width: 28rem;
    min-width: 0;
}

.print-intro-copy .doc-caption + .doc-caption {
    margin-top: 0.85em;
}

.print-intro-stack {
    display: flex;
    flex-direction: row;
    flex: 1 1 auto;
    align-items: flex-start;
    gap: 0.3rem;
    min-width: 0;
}

.print-intro-stack figure {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
}

.doc-body .print-intro-stack img {
    display: block;
    width: 100%;
    height: 12rem;
    object-fit: contain;
}

.print-tests {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    width: 100%;
    margin-top: 1rem;
}

.print-tests figure {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    margin: 0;
}

.print-intro-stack .fig-caption,
.print-tests .fig-caption {
    text-align: center;
}

.print-tests + .doc-caption {
    margin-top: 2rem;
}

.doc-body .print-tests img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
}

.fish-pair {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin: 0 0 1rem;
}

.fish-pair .doc-caption {
    flex: 1 1 34%;
    min-width: 0;
}

.fish-copy {
    flex: 1 1 34%;
    min-width: 0;
}

.fish-next {
    max-width: 34%;
    margin: 0;
}

.scan-stage {
    flex: 1 1 42%;
    min-width: 16rem;
    height: 16rem;
    background: #f4f4f4;
}

.scan-stage .scan-model {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
}

.fish-pair > figure {
    flex: 0 0 auto;
    margin: 0;
}

.doc-body .fish-pair > figure img {
    display: block;
    width: auto;
    max-width: 22rem;
    height: 13rem;
    object-fit: contain;
}

.fish-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    flex: 1 1 62%;
    min-width: 0;
    margin: 0;
}

.fish-feature {
    width: min(100%, 36rem);
    margin: 0 auto 1rem;
}

.doc-body .fish-feature img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
}

.fish-feature .fig-caption {
    text-align: center;
}

.fish-grid figure {
    margin: 0;
    min-width: 0;
}

.fish-grid .fig-caption {
    text-align: center;
}

.fish-pair .fish-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
}

.fish-pair .fish-grid.fish-grid-rows {
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: row;
}

.doc-body .fish-grid img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
}

.doc-body .embed-assemble .embed-solder {
    display: block;
    width: 100%;
    max-width: 24rem;
    height: auto;
    margin: 1rem 0 0;
    object-fit: contain;
}

.embed-assemble .embed-video {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

.doc-body .embed-assemble .doc-video {
    display: block;
    width: calc(26rem * 9 / 16);
    height: 26rem;
    max-width: none;
    margin: 0;
    object-fit: contain;
}

.embed-video .fig-caption {
    white-space: nowrap;
}

.doc-video {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 0;
}

.fish-pair > .embed-clip {
    flex: 0 1 36rem;
    width: min(100%, 36rem);
    margin: 0;
}

.embed-clip .fig-caption {
    text-align: center;
}

.doc-body .embed-clip .doc-video {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    margin: 0;
    object-fit: contain;
}

.doc-media-thumb {
    display: block;
    width: 5rem;
    max-width: 5rem;
    height: auto;
    margin-top: 0.75rem;
}

.doc-process {
    display: block;
    flex: 0 0 36%;
    width: 36%;
    max-width: 36%;
    height: auto;
    object-fit: contain;
}

.fig-caption {
    margin: 0.45rem 0 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.doc-split {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.doc-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.doc-caption {
    margin: 0;
    font-size: 0.85em;
    line-height: 1.5;
}

.doc-caption + .doc-caption {
    margin-top: 0.85em;
}

.intro-sketch {
    width: min(100%, 26rem);
    margin: 0;
}

.fish-pair > .intro-sketch {
    flex: 0 1 26rem;
}

.intro-sketch .fig-caption {
    text-align: center;
}

.doc-body .intro-sketch img,
.doc-body .fish-pair > .intro-sketch img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
}

.doc-list {
    margin: 0.65rem 0 0;
    padding: 0 0 0 1.15rem;
    font-size: 0.85em;
    line-height: 1.5;
}

.doc-list li + li {
    margin-top: 0.35rem;
}

ol.doc-list {
    list-style: decimal;
    padding-left: 1.35rem;
}

ol.doc-list li + li {
    margin-top: 0.85em;
}

.doc-list + .doc-caption {
    margin-top: 0.85em;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.85em 0 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.4;
}

.doc-table th,
.doc-table td {
    border: 1px solid var(--ink);
    padding: 0.4rem 0.55rem;
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.doc-table th {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.8rem;
}

.doc-table a {
    color: inherit;
}

.doc-table + .doc-caption {
    margin-top: 1.25rem;
}

.fish-pair > .doc-table {
    flex: 1 1 52%;
    width: auto;
    min-width: 0;
    margin-top: 0;
}

.fish-pair > .doc-table + .doc-caption {
    margin-top: 0;
}

.final-ideas {
    margin-bottom: 1.25rem;
}

.final-copy .doc-caption + .doc-caption {
    margin-top: 1.25rem;
}

.fish-pair > .synthia {
    flex: 0 1 32rem;
    width: min(100%, 32rem);
    margin: 0;
}

.doc-body .fish-pair > .synthia img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
}

.synthia .fig-caption {
    text-align: center;
}

.doc-caption + .eda-shot,
.doc-caption + .eda-pair,
.doc-caption + .fish-pair {
    margin-top: 1rem;
}

.eda-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
    margin: 0 0 0.75rem;
}

.eda-pair .eda-shot {
    width: 100%;
    min-width: 0;
    margin: 0;
}

.doc-body .eda-pair .eda-shot img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1024 / 558;
    max-width: none;
    object-fit: contain;
}

.eda-shot {
    width: min(100%, 32rem);
    margin: 0 0 0.75rem;
}

.fish-pair > .eda-shot {
    flex: 0 1 32rem;
    width: min(100%, 32rem);
    margin: 0;
}

.fish-pair > .prod-shot {
    flex: 0 1 28rem;
    width: min(100%, 28rem);
}

.prod-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    margin: 0;
}

.prod-grid .eda-shot {
    width: 100%;
    min-width: 0;
    margin: 0;
}

.doc-body .prod-grid .eda-shot img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
}

.prod-grid + .fish-grid,
.fish-grid + .fish-grid {
    margin-top: 1rem;
}

.prod-grid .embed-clip {
    margin: 0;
    min-width: 0;
}

.eda-shot + .prod-grid {
    margin-top: 1rem;
}

.doc-body .fish-pair > .eda-shot img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
}

.eda-shot:last-child {
    margin-bottom: 0;
}

.doc-body .eda-shot img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    object-fit: contain;
}

.eda-shot .fig-caption {
    text-align: center;
}

.doc-takeaway {
    display: inline;
    margin-right: 0.35em;
    padding: 0.1em 0.3em;
    font-family: var(--font-mono);
    font-size: 0.95em;
    letter-spacing: 0.02em;
    background: #ecff6f;
}

@media (max-width: 700px) {
    .doc-split {
        flex-direction: column;
    }

    .doc-media,
    .doc-process {
        flex-basis: auto;
        width: 100%;
        max-width: 100%;
    }

    .kit-figure,
    .kit-figure.kit-hero,
    .kit-pair .kit-sketch {
        float: none;
        flex-basis: auto;
        width: 100%;
        max-width: 100%;
        margin: 0 0 0.75rem;
    }

    .kit-pair {
        flex-direction: column;
        gap: 1.15rem;
        margin: 1.15rem 0;
    }

    .kit-pair img {
        width: 100%;
        height: auto;
        max-width: 100%;
    }
}

/* —— Tablet —— */
@media (max-width: 900px) {
    .site-header {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        row-gap: 0.35rem;
    }

    .header-name {
        grid-column: 1;
        grid-row: 1;
    }

    .header-back {
        white-space: normal;
    }

    .header-term {
        grid-column: 2;
        grid-row: 1;
    }

    .header-class {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: start;
        white-space: normal;
    }
}

/* —— Narrow: stack the left panel above the documentation —— */
@media (max-width: 640px) {
    html:has(.assignment-layout) {
        overflow: visible;
    }

    body:has(.assignment-layout) {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .assignment-layout {
        overflow: visible;
    }

    .assignment-sidebar {
        position: static;
        width: auto;
        border-right: none;
        border-bottom: 1px solid var(--ink);
        overflow: visible;
    }

    .assignment-docs {
        height: auto;
        margin-left: 0;
        overflow: visible;
    }

    .todo-panel {
        margin-top: 0;
    }

    .print-intro {
        flex-direction: column;
    }

    .print-intro-stack {
        flex-direction: row;
        width: 100%;
        max-width: none;
    }

    .fish-pair {
        flex-direction: column;
        align-items: stretch;
    }

    .eda-pair {
        grid-template-columns: 1fr;
    }

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

    .fish-next {
        max-width: none;
    }

    .scan-stage {
        width: 100%;
        min-width: 0;
    }

    .fish-pair .fish-grid,
    .fish-grid {
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .doc-body .fish-pair > figure img {
        width: 100%;
        max-width: none;
        height: auto;
    }

    .doc-body .fish-grid img {
        height: auto;
    }

    .embed-assemble {
        flex-direction: column;
    }

    .doc-body .embed-assemble .doc-video {
        height: auto;
        width: min(100%, 14rem);
    }
}

/* —— Mobile —— */
@media (max-width: 560px) {
    :root {
        --row-pad-top: 1.5rem;
        --row-pad-bottom: 0.6rem;
        --row-min-height: 5.5rem;
    }

    .site-header {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .header-name,
    .header-class,
    .header-term {
        justify-self: start;
        white-space: normal;
        text-align: left;
    }

    .header-class {
        max-width: 100%;
    }

    .assignment-row {
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-end;
        gap: 0.35rem;
    }

    .assignment-date {
        opacity: 0.65;
        font-size: 0.9em;
    }
}
