/* ==========================================================================
   oliwiahejduk.com - one stylesheet for every page
   Change colours and fonts here, in :root. Everything else reads from it.
   ========================================================================== */

:root {
    /* Colours */
    --ground: #F2EDE3;        /* bone background */
    --ink: #1F1B16;           /* main text */
    --ink-soft: #5C5447;      /* dates, captions, small print */
    --rule: #D9D1C1;          /* thin lines in tables */
    --tint: #E9E2D4;          /* boxes, code blocks */
    --accent: #1F5A3B;        /* links and the signal line (PCB green) */
    --accent-hover: #123B26;
    --accent-ink: #F2EDE3;    /* text on top of the accent colour */

    /* Fonts */
    --serif: "Times New Roman", Times, "Liberation Serif", "Noto Serif", serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    /* Old names still used inside the project pages */
    --bg: var(--ground);
    --surface: var(--tint);
    --text: var(--ink);
    --muted: var(--ink-soft);
    --line: var(--rule);
    --brand: var(--accent);
    --radius: 4px;
}

/* ---------- Base ---------- */

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

[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1.25rem;       /* 20px */
    line-height: 1.55;
}

img, video { max-width: 100%; height: auto; }

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--accent-hover);
    text-decoration-thickness: 2px;
}

a:focus-visible, button:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
    border-radius: 2px;
}

/* One container for every page: wide enough for a laptop,
   with the text itself kept to a comfortable reading width. */
.wrap {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0 48px;
}

/* ---------- Header ---------- */

.site-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 32px;
    padding-top: 40px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    color: var(--ink);
    font-size: 1.3125rem;
    text-decoration: none;
}

.logo:hover { color: var(--ink); }

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--ink);
    color: var(--ground);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0 28px;
    font-size: 1.1875rem;
}

.site-nav a {
    padding: 10px 0;
    color: var(--ink);
    text-decoration: none;
}

.site-nav a:hover { text-decoration: underline; }

/* ---------- Homepage ---------- */

.intro { padding-top: 112px; }

.intro h1 {
    max-width: 13em;
    margin: 0;
    font-size: clamp(2.25rem, 1.1rem + 3.3vw, 4.25rem);
    font-weight: 400;
    line-height: 1.06;
    letter-spacing: -0.015em;
}

.lead {
    max-width: 34em;
    margin: 28px 0 0;
    color: var(--ink-soft);
    font-size: 1.375rem;
}

/* The signal line under the headline */
.signal {
    margin-top: 72px;
    padding: 12px 0;
    touch-action: pan-y;
    cursor: crosshair;
}

.signal svg {
    display: block;
    width: 100%;
    height: 96px;
    overflow: visible;
}

.trace {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.5px;
    stroke-linejoin: miter;
    vector-effect: non-scaling-stroke;
}

.sweep { animation: sweep 1.6s cubic-bezier(.3, .6, .2, 1) both; }

@keyframes sweep {
    from { clip-path: inset(0 100% 0 0); }
    to   { clip-path: inset(0 0 0 0); }
}

@media (prefers-reduced-motion: reduce) {
    .sweep { animation: none; }
}

.signal-hint {
    margin: 10px 0 0;
    color: var(--ink-soft);
    font-size: 15px;
    font-style: italic;
}

.hint-touch { display: none; }

@media (hover: none), (pointer: coarse) {
    .hint-mouse { display: none; }
    .hint-touch { display: inline; }
}

/* Sections. On wide screens the section name sits in its own column
   on the left and the content on the right. */
.section { padding-top: 104px; }

.section > h2 {
    margin: 0 0 24px;
    font-size: 1.6875rem;
    font-weight: 400;
    line-height: 1.2;
}

.section > p { max-width: 36em; }

@media (min-width: 960px) {
    .section {
        display: grid;
        grid-template-columns: 12rem minmax(0, 1fr);
        column-gap: 64px;
        align-items: start;
    }

    .section > h2 { grid-column: 1; margin: 0; }
    .section > :not(h2) { grid-column: 2; }
}

/* Lists of projects and articles */
.items {
    display: flex;
    flex-direction: column;
    gap: 48px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.items.compact { gap: 16px; }
.items:empty { display: none; }

.item {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    column-gap: 32px;
    align-items: start;
}

.items.compact .item { display: block; }

.thumb {
    display: block;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: 4px;
    background: var(--tint);
}

.thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-text { max-width: 34em; }

.item-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 2px 24px;
}

.item-title { font-size: 1.375rem; line-height: 1.3; }
.items.compact .item-title { font-size: 1.25rem; }

.item-date {
    color: var(--ink-soft);
    font-size: 1rem;
}

.item p { margin: 6px 0 0; }

.item .parts {
    margin-top: 8px;
    color: var(--ink-soft);
    font-size: 1rem;
    font-style: italic;
}

.empty {
    margin: 0;
    color: var(--ink-soft);
    font-style: italic;
}

/* About */
.about {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 24px 40px;
}

.about-photo {
    flex: 0 0 auto;
    width: 12rem;
    height: auto;
    border-radius: 4px;
}

.about-text { flex: 1 1 300px; max-width: 34em; }
.about-text p { margin: 0 0 0.9em; }
.about-text p:last-child { margin-bottom: 0; }

.section p.contact-line { max-width: 36em; margin: 0; }
.section p.contact-line + p.contact-line { margin-top: 8px; }

/* Footer */
.site-footer {
    padding: 112px 0 48px;
    color: var(--ink-soft);
    font-size: 1rem;
}

/* ---------- Project pages and articles ---------- */

.back {
    display: inline-block;
    margin-top: 56px;
    padding: 10px 0;
    font-size: 1.0625rem;
}

.prose {
    max-width: 46rem;
    padding-top: 16px;
}

/* "On this page" sidebar, added by site.js on wide screens */
.toc { display: none; }

@media (min-width: 1100px) {
    main.has-toc {
        display: grid;
        grid-template-columns: minmax(0, 46rem) 14rem;
        column-gap: 80px;
    }

    main.has-toc > .back { grid-column: 1; }
    main.has-toc > .prose { grid-column: 1; grid-row: 2; }

    main.has-toc > .toc {
        display: block;
        position: sticky;
        top: 32px;
        grid-column: 2;
        grid-row: 2;
        align-self: start;
        max-height: calc(100vh - 64px);
        overflow-y: auto;
        padding-top: 32px;
        font-size: 1rem;
        line-height: 1.35;
    }

    main.has-toc .prose .section-menu { display: none; }
}

.toc-title {
    margin: 0 0 10px;
    color: var(--ink-soft);
    font-style: italic;
}

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

.toc a {
    display: block;
    padding: 5px 0;
    color: var(--ink-soft);
    text-decoration: none;
}

.toc a:hover { color: var(--accent); text-decoration: underline; }
.toc a[aria-current="true"] { color: var(--ink); }

.prose h1 {
    margin: 0.2em 0 0.3em;
    font-size: clamp(2rem, 1.4rem + 2vw, 2.6rem);
    font-weight: 400;
    line-height: 1.12;
    letter-spacing: -0.01em;
}

.prose h2, .prose h3, .prose h4 { scroll-margin-top: 24px; }

.prose h2 {
    margin: 2.2em 0 0.4em;
    font-size: 1.6875rem;
    font-weight: 400;
    line-height: 1.2;
}

.prose h3 {
    margin: 2em 0 0.4em;
    font-size: 1.45rem;
    font-weight: 400;
    line-height: 1.25;
}

.prose h4 {
    margin: 1.7em 0 0.3em;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
}

.prose p { margin: 0.8em 0; }

.prose ul, .prose ol { margin: 0.8em 0; padding-left: 1.3em; }
.prose li { margin: 0.25em 0; }

.prose figure { margin: 1.6em 0; }

.prose img, .prose video {
    display: block;
    border-radius: 4px;
}

.prose figcaption, .prose .muted {
    margin-top: 6px;
    color: var(--ink-soft);
    font-size: 1rem;
    font-style: italic;
}

.prose blockquote {
    margin: 1.4em 0;
    padding: 0 0 0 1em;
    color: var(--ink-soft);
    font-style: italic;
}

.prose hr {
    margin: 2.4em 0;
    border: 0;
    border-top: 1px solid var(--rule);
}

/* Tables */
.table-scroll, .wiring-scroll { overflow-x: auto; }

.prose table {
    width: 100%;
    margin: 1.2em 0;
    border-collapse: collapse;
    font-size: 1rem;
    line-height: 1.4;
}

.prose th, .prose td {
    padding: 8px 10px 8px 0;
    border-bottom: 1px solid var(--rule);
    text-align: left;
    vertical-align: top;
}

.prose th { font-weight: 700; }

.prose caption {
    padding-bottom: 6px;
    color: var(--ink-soft);
    font-style: italic;
    text-align: left;
}

/* Code */
.prose code {
    padding: 0.1em 0.3em;
    border-radius: 3px;
    background: var(--tint);
    font-family: var(--mono);
    font-size: 0.82em;
}

.prose pre {
    margin: 1.2em 0;
    padding: 14px 16px;
    overflow-x: auto;
    border-radius: 4px;
    background: var(--tint);
    font-size: 14px;
    line-height: 1.5;
}

.prose pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

/* Project page building blocks */
.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    margin: 0.4em 0 1em;
}

.meta > div { flex-basis: 100%; }

.badge {
    color: var(--ink-soft);
    font-size: 1rem;
    font-style: italic;
}

.prose .meta h4.note {
    margin: 1.2em 0 0.3em;
    font-size: 1.45rem;
    font-weight: 400;
}

.eyebrow {
    margin: 0;
    color: var(--ink-soft);
    font-size: 1.0625rem;
    font-style: italic;
}

.subtitle {
    margin: 0.3em 0 0;
    color: var(--ink-soft);
    font-size: 1.3125rem;
}

.callout, .info-box, .specs-card, .section-menu {
    margin: 1.4em 0;
    padding: 14px 18px;
    border-radius: 4px;
    background: var(--tint);
}

.callout > :first-child, .info-box > :first-child { margin-top: 0; }
.callout > :last-child, .info-box > :last-child { margin-bottom: 0; }

.specs-title, .section-menu-title {
    margin: 0 0 6px;
    font-weight: 700;
}

.specs-card table { margin: 0; }
.specs-card tr:last-child td { border-bottom: 0; }

.section-menu nav, .section-menu .links {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 18px;
    font-size: 1.0625rem;
}

.section-menu a { padding: 4px 0; }

.pinout-table td:nth-child(odd) {
    color: var(--ink-soft);
    white-space: nowrap;
}

.figure-inline.narrow img { max-width: min(100%, 560px); }

.wiring-block {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 28px;
    margin: 1.4em 0;
}

.wiring-tablewrap { flex: 1 1 320px; min-width: 0; }
.wiring-img { flex: 0 1 240px; }
.wiring-img img { width: 100%; }

.wiring-chip {
    padding: 0.05em 0.35em;
    border: 1px solid #BDB3A0;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 0.8em;
    white-space: nowrap;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 12px;
    margin: 1.4em 0;
}

.gallery figure { margin: 0; }
.gallery img { width: 100%; }

/* Article page */
.article-date {
    margin: 0;
    color: var(--ink-soft);
    font-size: 1rem;
}

/* ---------- Image zoom ---------- */

.zoom {
    display: block;
    width: 100%;
    padding: 0;
    text-align: left;
    border: 0;
    background: none;
    cursor: zoom-in;
}

.lightbox {
    max-width: 96vw;
    max-height: 96vh;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ground);
}

.lightbox::backdrop { background: rgba(31, 27, 22, 0.88); }

.lightbox img {
    display: block;
    max-width: 94vw;
    max-height: 84vh;
    margin: 0 auto;
    border-radius: 4px;
}

.lightbox p {
    margin: 10px 0 0;
    font-size: 1rem;
    font-style: italic;
    text-align: center;
}

.lightbox-close {
    display: block;
    min-height: 44px;
    margin: 0 0 8px auto;
    padding: 8px 14px;
    border: 1px solid var(--ground);
    border-radius: 4px;
    background: transparent;
    color: var(--ground);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
}

/* ---------- Tablets ---------- */

@media (max-width: 959px) {
    .wrap { padding: 0 32px; }
    .item { grid-template-columns: 12rem minmax(0, 1fr); column-gap: 24px; }
}

/* ---------- Phones ---------- */

@media (max-width: 600px) {
    body { font-size: 1.125rem; line-height: 1.5; }

    .wrap { padding: 0 22px; }

    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding-top: 28px;
    }

    .logo { font-size: 1.25rem; }
    .logo-mark { width: 34px; height: 34px; font-size: 15px; }
    .site-nav { gap: 0 20px; font-size: 1.125rem; }

    .intro { padding-top: 48px; }
    .lead { margin-top: 18px; font-size: 1.1875rem; }

    .signal { margin-top: 44px; padding: 10px 0; }
    .signal svg { height: 72px; }

    .section { padding-top: 72px; }
    .section > h2 { margin-bottom: 18px; font-size: 1.5rem; }

    .items { gap: 40px; }
    .item { display: block; }
    .thumb { aspect-ratio: 16 / 9; margin-bottom: 14px; }
    .item-title { font-size: 1.25rem; }
    .item .parts { font-size: 0.9375rem; }

    .about-photo { width: 150px; }

    .back { margin-top: 36px; }
    .prose h2 { font-size: 1.5rem; }
    .prose h3 { font-size: 1.3rem; }

    .site-footer { padding: 80px 0 40px; font-size: 0.9375rem; }
}
