/* =====================================================================
   Digital Portfolio 8 — restyled with Apple's design guidance
   (WWDC "Designing Fluid Interfaces", "The Details of UI Typography").
   The page content and markup are the originals; this file restyles them.
   The original 2025 look lives untouched in /legacy.
   ===================================================================== */

/* CSS Custom Properties (Variables) - DRY Principle */
:root {
    color-scheme: dark;

    /* Surfaces: Apple's dark system backgrounds */
    --bg: #000000;
    --bg-raised: #1c1c1e;
    --bg-raised-2: #2c2c2e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-hover: rgba(255, 255, 255, 0.08);
    --separator: rgba(84, 84, 88, 0.6);

    /* Text: label hierarchy */
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.68);
    --label-3: rgba(235, 235, 245, 0.42);

    /* Accent: the cyan from the SPS logo */
    --tint: #00c8ff;
    --tint-rgb: 0, 200, 255;
    --on-tint: #001018;
    --success: #30d158;
    --danger: #ff453a;

    /* Materials */
    --material-chrome: rgba(16, 16, 18, 0.72);
    --material-thick: rgba(44, 44, 46, 0.78);
    --blur-chrome: blur(20px) saturate(180%);
    --blur-thick: blur(32px) saturate(180%);

    /* Radii */
    --radius-s: 0.5rem;
    --radius-m: 0.875rem;
    --radius-l: 1.25rem;
    --radius-pill: 999px;

    /* Spacing in rem so the layout scales with the reader's text size */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4.5rem;
    --gutter: clamp(1rem, 4vw, 2rem);
    --measure: 61.25rem;

    /* Press feedback: fast, on pointer-down */
    --press: transform 100ms ease-out;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 6rem;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--label);
    /* System font first: it ships optical sizing and tracking tables */
    font: 100%/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
    font-size: 1.0625rem;
    letter-spacing: -0.008em;
    -webkit-font-smoothing: antialiased;
    font-optical-sizing: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a {
    color: var(--tint);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

:focus-visible {
    outline: 2px solid var(--tint);
    outline-offset: 3px;
    border-radius: var(--radius-s);
}

code,
pre {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Type scale ------------------------------------------------
   Tracking is size-specific: big text tightens, small text opens up.
   Leading runs inverse to size.                                        */
h1,
h2,
h3,
h4 {
    margin: 0;
    font-weight: 700;
}

h2 {
    font-size: clamp(1.5rem, 3.2vw, 2rem);
    line-height: 1.15;
    letter-spacing: -0.022em;
}

h3 {
    font-size: 1.25rem;
    line-height: 1.25;
    letter-spacing: -0.015em;
    font-weight: 650;
}

h4 {
    font-size: 1.0625rem;
    line-height: 1.35;
    letter-spacing: -0.008em;
    font-weight: 600;
}

p {
    margin: 0 0 var(--space-4);
}

/* ---------- Skip link ------------------------------------------------- */
.skip-link {
    position: absolute;
    left: var(--space-4);
    top: -3rem;
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    background: var(--tint);
    color: var(--on-tint);
    border-radius: var(--radius-pill);
    font-weight: 600;
}

.skip-link:focus {
    top: var(--space-3);
}

/* ---------- Header: a translucent layer content scrolls under --------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--material-chrome);
    -webkit-backdrop-filter: var(--blur-chrome);
    backdrop-filter: var(--blur-chrome);
}

/* Scroll-edge effect instead of a hard divider: only once content is underneath */
.site-header::after {
    content: "";
    position: absolute;
    inset: 100% 0 auto;
    height: 1.25rem;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
}

.site-header.is-scrolled::after {
    opacity: 1;
}

.site-header__inner {
    max-width: calc(var(--measure) + 2 * var(--gutter));
    margin: 0 auto;
    padding: var(--space-3) var(--gutter);
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--label);
    white-space: nowrap;
    flex-shrink: 0;
    transition: var(--press);
}

.brand:hover {
    text-decoration: none;
}

.brand:active {
    transform: scale(0.97);
}

.brand__logo {
    height: 1.5rem;
    width: auto;
}

.brand__name {
    font-weight: 650;
    letter-spacing: -0.012em;
}

.brand__sub {
    font-size: 0.8125rem;
    letter-spacing: 0.006em;
    color: var(--label-2);
}

.site-nav {
    margin-left: auto;
    min-width: 0;
}

.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.125rem;
}

.site-nav a {
    display: block;
    padding: 0.4375rem 0.8125rem;
    border-radius: var(--radius-pill);
    color: var(--label-2);
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: -0.004em;
    white-space: nowrap;
    transition: background-color 150ms ease, color 150ms ease, var(--press);
}

.site-nav a:hover {
    text-decoration: none;
    color: var(--label);
    background: var(--fill-hover);
}

.site-nav a:active {
    transform: scale(0.96);
    transition: var(--press);
}

.site-nav a[aria-current="page"] {
    color: var(--label);
    background: rgba(255, 255, 255, 0.14);
    font-weight: 600;
}

@media (max-width: 62rem) {
    .brand__sub {
        display: none;
    }
}

@media (max-width: 54rem) {
    .site-header__inner {
        flex-wrap: wrap;
        row-gap: var(--space-2);
        padding-bottom: var(--space-2);
    }

    .site-nav {
        margin-left: calc(-1 * var(--gutter));
        margin-right: calc(-1 * var(--gutter));
        width: calc(100% + 2 * var(--gutter));
        overflow-x: auto;
        scrollbar-width: none;
        /* Fade the edges so it's obvious the row scrolls */
        -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
        mask-image: linear-gradient(to right, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
    }

    .site-nav::-webkit-scrollbar {
        display: none;
    }

    .site-nav ul {
        padding: 0 var(--gutter);
        width: max-content;
    }
}

/* ---------- Page layout ----------------------------------------------- */
.page {
    flex: 1;
    width: 100%;
    max-width: calc(var(--measure) + 2 * var(--gutter));
    margin: 0 auto;
    padding: 0 var(--gutter) var(--space-8);
}

/* Page title: the first heading on each page */
.body > h1:first-child,
.body > h2:first-child {
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    line-height: 1.04;
    letter-spacing: -0.035em;
    padding-top: var(--space-7);
    margin-bottom: var(--space-2);
}

/* Teacher name / subtitle under the title */
.body > h2:first-child + h4 {
    font-size: clamp(1.1875rem, 2.4vw, 1.375rem);
    line-height: 1.4;
    letter-spacing: -0.012em;
    font-weight: 500;
    color: var(--label-2);
}

/* Page photo */
.body > img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 8;
    object-fit: cover;
    border-radius: var(--radius-l);
    background: var(--bg-raised);
    margin: var(--space-6) 0 0;
}

/* Section headings */
.body > h2:not(:first-child) {
    margin: var(--space-7) 0 var(--space-4);
}

/* Paragraphs */
.body > p,
.course-description,
#course-description {
    max-width: 42rem;
    color: var(--label-2);
}

.course-description p {
    margin-bottom: var(--space-4);
}

/* ---------- Grouped lists (inset, like iOS Settings) ------------------ */
.body > ul,
.assignment-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--bg-raised);
    border-radius: var(--radius-m);
    overflow: hidden;
}

.body > ul li,
.assignment-list li {
    position: relative;
    padding: 0.75rem var(--space-4);
    line-height: 1.35;
}

/* Inset separators stop short of the leading edge */
.body > ul li + li::before,
.assignment-list li + li::before {
    content: "";
    position: absolute;
    top: 0;
    left: var(--space-4);
    right: 0;
    border-top: 1px solid var(--separator);
}

/* Hidden class for assignment lists */
.hidden {
    display: none;
}

/* ---------- Assignment / project dropdowns (E&D) ---------------------- */
.assignment-dropdown {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-3);
}

.assignment-dropdown label {
    min-width: 7rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--label-2);
}

.assignment-dropdown select {
    -webkit-appearance: none;
    appearance: none;
    min-width: 14rem;
    min-height: 2.5rem;
    padding: 0 2.25rem 0 0.875rem;
    border: 1px solid transparent;
    border-radius: 0.625rem;
    font: inherit;
    font-size: 1rem;
    color: var(--label);
    cursor: pointer;
    /* Chevron drawn in CSS so it matches the type color */
    background:
        linear-gradient(45deg, transparent 50%, var(--label-2) 50%) right 1.125rem center / 0.3125rem 0.3125rem no-repeat,
        linear-gradient(-45deg, transparent 50%, var(--label-2) 50%) right 0.8125rem center / 0.3125rem 0.3125rem no-repeat,
        var(--bg-raised-2);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.assignment-dropdown select:focus {
    outline: none;
    border-color: var(--tint);
    box-shadow: 0 0 0 4px rgba(var(--tint-rgb), 0.28);
}

.assignment-list {
    margin-top: var(--space-4);
}

/* ---------- Buttons ---------------------------------------------------- */
.quiz-button,
.physics-button,
.chemistry-button,
.binary-btn,
.copy-btn,
.interactive-btn,
.analyze-btn,
.reset-btn,
.present-btn,
.code-toggle {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0 1.25rem;
    border: 0;
    border-radius: var(--radius-pill);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.008em;
    cursor: pointer;
    text-decoration: none;
    background: var(--tint);
    color: var(--on-tint);
    transition: transform 100ms ease-out, filter 150ms ease, background-color 150ms ease;
}

.quiz-button:hover,
.physics-button:hover,
.chemistry-button:hover,
.binary-btn:hover,
.interactive-btn:hover,
.analyze-btn:hover,
.present-btn:hover {
    filter: brightness(1.08);
    text-decoration: none;
}

/* Instant feedback the moment a button is pressed */
.quiz-button:active,
.physics-button:active,
.chemistry-button:active,
.binary-btn:active,
.copy-btn:active,
.interactive-btn:active,
.analyze-btn:active,
.reset-btn:active,
.present-btn:active,
.code-toggle:active {
    transform: scale(0.97);
    filter: brightness(0.92);
}

/* Secondary: a quiet fill for the lesser action */
.copy-btn,
.reset-btn,
.code-toggle {
    background: var(--fill);
    color: var(--label);
}

.copy-btn:hover,
.reset-btn:hover,
.code-toggle:hover {
    background: rgba(118, 118, 128, 0.34);
    text-decoration: none;
}

.reset-btn {
    color: var(--danger);
}

/* Copy confirmation (set by binary.js) */
.is-confirmed {
    background: var(--success) !important;
    color: #002508 !important;
}

.quiz-section {
    margin: var(--space-5) 0 0;
}

/* ---------- Photos ---------------------------------------------------- */
[data-zoom] {
    cursor: zoom-in;
}

/* ---------- Project pages --------------------------------------------- */
.project-section {
    padding-top: var(--space-7);
    margin-top: var(--space-7);
    border-top: 1px solid var(--separator);
}

.body > h1:first-child + .project-section {
    margin-top: var(--space-4);
    border-top: 0;
    padding-top: var(--space-4);
}

.project-section > h2 {
    margin-bottom: var(--space-1);
}

/* Date line under each project title */
.project-section > h2 + h4 {
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--label-2);
    margin-bottom: var(--space-4);
}

#project-image {
    border-radius: var(--radius-m);
    background: var(--bg-raised);
}

.project-section > #project-image {
    width: auto;
    max-width: min(100%, 36rem);
    max-height: 30rem;
    margin: var(--space-5) 0;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: var(--space-4);
    margin: var(--space-5) 0;
    align-items: start;
}

.gallery__item {
    display: flex;
    flex-direction: column-reverse; /* caption sits under the photo */
    gap: var(--space-2);
}

.gallery__item h4 {
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.006em;
    color: var(--label-2);
}

/* Uniform tiles keep the page scannable; tap a tile to see the whole photo */
.gallery__item img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.project-section h3 {
    margin: var(--space-6) 0 var(--space-3);
}

.project-section h3 ~ h4 {
    margin: var(--space-5) 0 var(--space-2);
}

.project-description {
    max-width: 42rem;
    color: var(--label-2);
}

/* Code dropdown */
.code-dropdown {
    margin: var(--space-5) 0;
}

.code-dropdown a.code-toggle {
    display: inline-flex !important;
}

.code-content pre {
    margin: var(--space-3) 0 0;
    padding: var(--space-4) var(--space-5);
    background: var(--bg-raised);
    border-radius: var(--radius-m);
    overflow-x: auto;
    font-size: 0.8125rem;
    line-height: 1.55;
    letter-spacing: 0;
    color: #e5e5ea;
    tab-size: 4;
}

/* ---------- Forms ------------------------------------------------------- */
input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    font: inherit;
    font-size: 1rem;
    color: var(--label);
    background: var(--bg-raised-2);
    border: 1px solid transparent;
    border-radius: 0.625rem;
    padding: 0.625rem 0.75rem;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--label-3);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--tint);
    box-shadow: 0 0 0 4px rgba(var(--tint-rgb), 0.28);
}

textarea {
    resize: vertical;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

textarea[readonly] {
    background: var(--bg);
    border-color: var(--separator);
}

/* ---------- Panels (Science calculators, Binary page) ---------------- */
.physics-calculator,
.chemistry-calculator,
.binary-section {
    background: var(--bg-raised);
    border-radius: var(--radius-l);
    padding: clamp(1.25rem, 3vw, 2rem);
    margin-top: var(--space-5);
}

.physics-calculator {
    margin-top: var(--space-7);
}

.physics-calculator > p,
.chemistry-calculator > p {
    color: var(--label-2);
    max-width: 40rem;
}

.physics-calculator h2,
.chemistry-calculator h2 {
    font-size: 1.25rem;
    letter-spacing: -0.015em;
    margin-bottom: var(--space-2);
}

.binary-section h3 {
    margin-bottom: var(--space-4);
}

.calculator-inputs {
    display: grid;
    gap: var(--space-4);
    margin: var(--space-5) 0;
}

@media (min-width: 40rem) {
    .physics-calculator .calculator-inputs {
        grid-template-columns: repeat(3, 1fr);
        align-items: end;
    }

    .physics-calculator .calculator-inputs > button {
        grid-column: 1 / -1;
        justify-self: start;
    }
}

.chemistry-calculator .calculator-inputs > button {
    justify-self: start;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--label-2);
    margin-bottom: var(--space-2);
}

.calculator-results {
    background: var(--bg-raised-2);
    border-radius: var(--radius-m);
    padding: var(--space-4) var(--space-5);
    color: var(--label-2);
}

.calculator-results h3,
.calculator-results h4,
.calculator-results strong {
    color: var(--label);
}

.calculator-results p:last-child {
    margin-bottom: 0;
}

.calculator-results ul {
    padding-left: 1.25rem;
}

.chemical-summary {
    display: grid;
    gap: var(--space-2);
}

.chemical-list {
    list-style: none;
    padding-left: 0 !important;
}

.chemical-list li {
    margin-bottom: var(--space-2);
}

.graph-container {
    margin-top: var(--space-5);
}

.graph-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

/* Calculation / Interactive mode reads as a segmented control */
.mode-toggle {
    display: inline-flex;
    padding: 0.125rem;
    border-radius: 0.5625rem;
    background: var(--fill);
}

.mode-btn {
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--label);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.875rem;
    min-height: 2rem;
    border-radius: 0.4375rem;
    cursor: pointer;
    transition: background-color 200ms ease, transform 100ms ease-out;
}

.mode-btn:active {
    transform: scale(0.96);
}

.mode-btn.active {
    background: #636366;
    font-weight: 600;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

.interactive-controls {
    background: var(--bg-raised-2);
    border-radius: var(--radius-m);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
}

.interactive-controls h4 {
    margin-bottom: var(--space-3);
}

.interactive-controls p {
    color: var(--label-2) !important;
}

.control-row {
    display: flex;
    gap: var(--space-3) var(--space-5);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
}

.control-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.control-group label {
    font-size: 0.875rem;
    color: var(--label-2);
    white-space: nowrap;
}

.control-group input {
    width: 4.5rem;
    padding: 0.375rem 0.5rem;
}

.control-group span {
    color: var(--label-2);
    font-size: 0.875rem;
}

.interactive-btn,
.analyze-btn,
.present-btn,
.reset-btn {
    min-height: 2.25rem;
    font-size: 0.9375rem;
    padding: 0 1rem;
}

.graph-section {
    background: var(--bg);
    border-radius: var(--radius-m);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
}

.graph-section h4 {
    margin-bottom: var(--space-3);
    color: var(--label-2);
    font-size: 0.9375rem;
}

.graph-section canvas {
    max-width: 100%;
}

/* Binary page */
.binary-container {
    margin-top: var(--space-6);
}

.binary-section .button-group {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin: var(--space-3) 0;
}

.binary-info {
    margin-top: var(--space-5);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-m);
    background: rgba(var(--tint-rgb), 0.1);
    color: var(--label-2);
}

.binary-info h4 {
    color: var(--label);
    margin-bottom: var(--space-2);
}

.binary-info ul {
    padding-left: 1.25rem;
    margin: 0;
}

.binary-info li {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875rem;
    overflow-wrap: anywhere;
    margin-bottom: var(--space-1);
}

.binary-info strong {
    color: var(--tint);
}

/* ---------- Contact page ------------------------------------------------ */
.contact-label {
    font-weight: 600;
    color: var(--label);
}

/* ---------- Data Measurement Chart (E&D) -------------------------------- */
.dmc-container {
    margin-top: var(--space-7);
}

.dmc-container > h1 {
    font-size: clamp(1.5rem, 3.2vw, 2rem);
    line-height: 1.15;
    letter-spacing: -0.022em;
    margin-bottom: var(--space-4);
}

.dmc-title-hover a {
    color: inherit;
}

.dmc-title-hover a::after {
    content: " ›";
    color: var(--tint);
}

.dmc-title-hover a:hover {
    color: var(--tint);
    text-decoration: none;
}

.dmc table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-raised);
    border-radius: var(--radius-m);
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

.dmc th {
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--label-2);
    padding: var(--space-3) var(--space-4);
}

.dmc td {
    padding: 0.8125rem var(--space-4);
    border-top: 1px solid var(--separator);
}

.dmc td:first-child {
    font-weight: 600;
}

.dmc td:last-child {
    color: var(--label-2);
}

.hover-row {
    cursor: help;
    transition: background-color 150ms ease;
}

.hover-row:hover,
.hover-row:focus-visible,
.hover-row.is-active {
    background: var(--fill-hover);
    outline: none;
}

.hover-row:focus-visible td:first-child {
    box-shadow: inset 3px 0 0 var(--tint);
}

/* Popover: a thick material that grows out of the row that owns it */
.fact-popover {
    position: fixed;
    z-index: 60;
    max-width: min(20rem, calc(100vw - 2rem));
    padding: var(--space-4);
    border-radius: var(--radius-m);
    background: var(--material-thick);
    -webkit-backdrop-filter: var(--blur-thick);
    backdrop-filter: var(--blur-thick);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    /* Vibrancy: heavier weight + a hair more tracking over glass */
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: 0.002em;
    color: var(--label);
    pointer-events: none;
    opacity: 0;
    transform: scale(0.94);
    filter: blur(6px);
    transition: opacity 180ms ease, transform 260ms var(--ease-out), filter 220ms ease;
}

.fact-popover.is-visible {
    opacity: 1;
    transform: none;
    filter: none;
}

/* ---------- CSS Box Model (E&D) ----------------------------------------- */
#boxmodelborder {
    margin-top: var(--space-7);
}

#boxmodelborder > h2 {
    margin-bottom: var(--space-4);
}

.box-model {
    max-width: 34rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: center;
}

.margin,
.border,
.padding {
    position: relative;
    padding: 2rem 1.75rem 1.5rem;
    border-radius: var(--radius-m);
}

.margin::before,
.border::before,
.padding::before {
    position: absolute;
    top: 0.625rem;
    left: 0;
    right: 0;
}

.margin::before {
    content: "MARGIN";
}

.border::before {
    content: "BORDER";
}

.padding::before {
    content: "PADDING";
}

.margin {
    background: rgba(var(--tint-rgb), 0.12);
    color: var(--tint);
    border: 1px dashed rgba(var(--tint-rgb), 0.5);
}

.border {
    background: var(--bg-raised-2);
    color: var(--label);
    box-shadow: inset 0 0 0 3px var(--label-2);
}

.padding {
    background: rgba(var(--tint-rgb), 0.24);
    color: var(--label);
}

.content {
    background: var(--bg);
    color: var(--label);
    padding: 1.5rem 1rem;
    border-radius: var(--radius-s);
}

/* ---------- DOM Tree (E&D) ----------------------------------------------- */
.node-section {
    margin-top: var(--space-7);
}

.node-section h2 {
    margin-bottom: var(--space-4);
}

.node-image {
    border-radius: var(--radius-m);
}

/* ---------- Personal projects ------------------------------------------ */
/* Buttons for each personal project */
.project-nav ul {
    list-style: none;
    margin: var(--space-5) 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.project-nav a {
    display: block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    background: var(--fill);
    color: var(--label);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background-color 150ms ease, var(--press);
}

.project-nav a:hover {
    text-decoration: none;
    background: rgba(118, 118, 128, 0.34);
}

.project-nav a:active {
    transform: scale(0.96);
}

.project-nav a[aria-current="true"] {
    background: var(--label);
    color: var(--bg);
    font-weight: 600;
}

.personal-project {
    margin-top: var(--space-6);
    padding: clamp(1.25rem, 3vw, 2rem);
    background: var(--bg-raised);
    border-radius: var(--radius-l);
}

.personal-project__header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

/* App icons get the rounded-square mask they have on macOS */
.personal-project__icon {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 22.5%;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
}

.personal-project__header h2 {
    margin: 0;
}

.personal-project__header h4 {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--label-2);
    margin-top: var(--space-1);
}

.download {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    margin-top: var(--space-5);
}

.download-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 2.75rem;
    padding: 0 1.375rem;
    border-radius: var(--radius-pill);
    background: var(--tint);
    color: var(--on-tint);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.008em;
    transition: transform 100ms ease-out, filter 150ms ease;
}

/* Down-arrow glyph drawn in CSS */
.download-button::before {
    content: "";
    width: 0.875rem;
    height: 0.875rem;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1v10M3.5 7 8 11.5 12.5 7M2 15h12' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1v10M3.5 7 8 11.5 12.5 7M2 15h12' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.download-button:hover {
    text-decoration: none;
    filter: brightness(1.08);
}

/* Instant feedback the moment it is pressed */
.download-button:active {
    transform: scale(0.97);
    filter: brightness(0.92);
}

.download__meta {
    font-size: 0.8125rem;
    letter-spacing: 0.006em;
    color: var(--label-2);
}

/* ---------- Footer ----------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--separator);
}

.site-footer__inner {
    max-width: calc(var(--measure) + 2 * var(--gutter));
    margin: 0 auto;
    padding: var(--space-5) var(--gutter) var(--space-6);
    font-size: 0.8125rem;
    letter-spacing: 0.006em;
}

.site-footer a {
    font-weight: 500;
}

/* ---------- Image viewer ------------------------------------------------ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    touch-action: none;
}

.lightbox__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    opacity: 0;
}

.lightbox__img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform-origin: 0 0;
    will-change: transform, clip-path;
    cursor: grab;
    -webkit-user-drag: none;
    user-select: none;
}

.lightbox.is-dragging .lightbox__img {
    cursor: grabbing;
}

.lightbox__chrome {
    position: absolute;
    inset: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
}

.lightbox.is-dragging .lightbox__chrome,
.lightbox.is-closing .lightbox__chrome {
    opacity: 0;
}

.lightbox__close {
    position: absolute;
    top: max(var(--space-4), env(safe-area-inset-top));
    right: var(--space-4);
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 50%;
    background: var(--material-thick);
    -webkit-backdrop-filter: var(--blur-thick);
    backdrop-filter: var(--blur-thick);
    color: var(--label);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 100ms ease-out;
}

.lightbox__close:active {
    transform: scale(0.92);
}

.lightbox__caption {
    position: absolute;
    left: 50%;
    bottom: max(var(--space-5), env(safe-area-inset-bottom));
    transform: translateX(-50%);
    max-width: calc(100% - 2rem);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-pill);
    background: var(--material-thick);
    -webkit-backdrop-filter: var(--blur-thick);
    backdrop-filter: var(--blur-thick);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.002em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.has-lightbox {
    overflow: hidden;
}

/* ---------- Accessibility preferences --------------------------------
   Reduced motion keeps feedback but swaps movement for cross-fades.    */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-property: opacity, background-color, color, border-color !important;
        transition-duration: 150ms !important;
        scroll-behavior: auto !important;
    }

    .fact-popover {
        transform: none;
        filter: none;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .site-header {
        background: #0b0b0c;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .fact-popover,
    .lightbox__close,
    .lightbox__caption {
        background: var(--bg-raised-2);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .lightbox__scrim {
        background: #000;
    }
}

@media (prefers-contrast: more) {
    :root {
        --label-2: rgba(235, 235, 245, 0.86);
        --label-3: rgba(235, 235, 245, 0.66);
        --separator: rgba(235, 235, 245, 0.4);
    }

    .site-header {
        background: #000;
        border-bottom: 1px solid var(--separator);
    }

    .body > ul,
    .assignment-list,
    .dmc table,
    .physics-calculator,
    .chemistry-calculator,
    .binary-section,
    .fact-popover {
        border: 1px solid var(--separator);
    }
}
