:root {
    --bg: #f3eee4;
    --paper: rgba(252, 247, 239, 0.84);
    --paper-strong: rgba(255, 251, 245, 0.96);
    --ink: #1a130e;
    --muted: #625145;
    --line: rgba(43, 30, 20, 0.1);
    --accent: #d05d28;
    --accent-deep: #842f1d;
    --teal: #1e7e7c;
    --gold: #f1c789;
    --shadow-soft: 0 26px 60px rgba(38, 23, 12, 0.12);
    --shadow-strong: 0 36px 80px rgba(38, 23, 12, 0.18);
    --radius-xl: 34px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --max-width: 1380px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 0%, rgba(241, 199, 137, 0.45), transparent 26%),
        radial-gradient(circle at 88% 12%, rgba(30, 126, 124, 0.18), transparent 22%),
        radial-gradient(circle at 50% 100%, rgba(208, 93, 40, 0.15), transparent 28%),
        linear-gradient(180deg, #faf4ec 0%, #efe4d4 100%);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    line-height: 1.6;
}

body.menu-open,
body.lightbox-open {
    overflow: hidden;
}

body.project-page::before,
body.project-page::after {
    content: "";
    position: fixed;
    width: 24rem;
    height: 24rem;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.45;
    pointer-events: none;
    z-index: -1;
}

body.project-page::before {
    top: -10rem;
    right: -8rem;
    background: rgba(208, 93, 40, 0.35);
}

body.project-page::after {
    bottom: 8%;
    left: -8rem;
    background: rgba(30, 126, 124, 0.18);
}

a {
    color: inherit;
}

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

.container {
    width: min(calc(100% - 2rem), var(--max-width));
    margin: 0 auto;
}

header {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(18px);
    background: rgba(250, 244, 236, 0.72);
    border-bottom: 1px solid var(--line);
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 82px;
}

.logo {
    margin: 0;
    font-family: "Bricolage Grotesque", "Space Grotesk", sans-serif;
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    line-height: 0.95;
    letter-spacing: -0.03em;
}

.header-project-label {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1rem;
    border-radius: 999px;
    background: rgba(255, 251, 245, 0.82);
    border: 1px solid rgba(43, 30, 20, 0.08);
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

nav a:hover,
nav a:focus-visible {
    background: rgba(208, 93, 40, 0.1);
    color: var(--ink);
    transform: translateY(-1px);
}

.project-hero {
    padding: 4.5rem 0 1.8rem;
}

.project-hero-card,
.case-card,
.project-footer .container {
    position: relative;
    overflow: hidden;
    background: var(--paper);
    border: 1px solid rgba(43, 30, 20, 0.08);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(14px);
}

.project-hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.7fr);
    gap: 1.4rem;
    padding: clamp(1.5rem, 4vw, 2.3rem);
    border-radius: var(--radius-xl);
}

.project-hero-card::before,
.case-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--gold) 45%, var(--teal) 100%);
}

.project-kicker {
    margin: 0 0 1rem;
    color: var(--accent-deep);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.project-hero h1 {
    margin: 0;
    font-family: "Bricolage Grotesque", "Space Grotesk", sans-serif;
    max-width: 18ch;
    font-size: clamp(2.6rem, 4.8vw, 4.9rem);
    line-height: 0.94;
    letter-spacing: -0.06em;
    text-wrap: balance;
}

.project-summary {
    max-width: 48rem;
    margin: 1.1rem 0 0;
    color: var(--muted);
    font-size: clamp(1.02rem, 1.6vw, 1.12rem);
}

.project-title-long .project-hero h1 {
    max-width: 20ch;
    font-size: clamp(2.2rem, 4.1vw, 4rem);
    line-height: 0.96;
}

.project-title-very-long .project-hero h1 {
    max-width: 24ch;
    font-size: clamp(1.95rem, 3.4vw, 3.2rem);
    line-height: 1;
    letter-spacing: -0.045em;
}

.project-tag-row,
.project-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.project-tag-row {
    margin-top: 1.4rem;
}

.project-tag,
.project-pill {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 0.9rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.project-tag {
    color: var(--accent-deep);
    background: rgba(241, 199, 137, 0.34);
    border: 1px solid rgba(208, 93, 40, 0.1);
}

.project-action-row {
    margin-top: 1.5rem;
}

.project-pill {
    color: #fff7ef;
    text-decoration: none;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
    box-shadow: 0 16px 28px rgba(132, 47, 29, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-pill:hover,
.project-pill:focus-visible,
.resource-link:hover,
.resource-link:focus-visible {
    transform: translateY(-2px);
}

.project-metric-grid {
    display: grid;
    gap: 0.9rem;
    align-content: start;
}

.project-metric {
    padding: 1rem 1.05rem;
    border-radius: var(--radius-md);
    background: rgba(255, 251, 245, 0.8);
    border: 1px solid rgba(43, 30, 20, 0.08);
    box-shadow: 0 14px 28px rgba(38, 23, 12, 0.08);
}

.project-metric span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.project-metric strong {
    display: block;
    margin-top: 0.28rem;
    font-family: "Bricolage Grotesque", "Space Grotesk", sans-serif;
    font-size: 1.05rem;
}

section {
    padding: 1rem 0 2rem;
}

section:first-of-type {
    padding-top: 1.2rem;
}

.case-card {
    padding: clamp(1.2rem, 3vw, 1.8rem);
    border-radius: var(--radius-xl);
}

.case-label {
    margin: 0 0 0.75rem;
    color: var(--accent-deep);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h2 {
    margin: 0 0 1rem;
    font-family: "Bricolage Grotesque", "Space Grotesk", sans-serif;
    font-size: clamp(1.9rem, 4vw, 3rem);
    line-height: 0.96;
    letter-spacing: -0.05em;
}

.case-card > p,
#project-code p {
    color: var(--muted);
}

.enhanced-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.project-kind-showcase .enhanced-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gallery-card {
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: var(--paper-strong);
    border: 1px solid rgba(43, 30, 20, 0.08);
    box-shadow: 0 18px 34px rgba(38, 23, 12, 0.12);
}

.gallery-card img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform 0.35s ease;
}

.gallery-card:hover img {
    transform: scale(1.03);
}

.gallery-card figcaption {
    padding: 0.85rem 1rem 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.feature-frame {
    grid-column: span 2;
}

.feature-frame img {
    aspect-ratio: 16 / 9;
}

.document-gallery {
    grid-template-columns: 1fr;
}

.document-frame {
    background: linear-gradient(180deg, rgba(255, 251, 245, 0.98) 0%, rgba(245, 239, 230, 0.98) 100%);
}

.document-frame img {
    aspect-ratio: auto;
    object-fit: contain;
    cursor: default;
    background: #fff;
}

.document-frame:hover img {
    transform: none;
}

.document-frame figcaption::before {
    content: "Embedded board";
    display: inline-flex;
    margin-right: 0.55rem;
    color: var(--accent-deep);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.very-tall-frame figcaption::before {
    content: "Scrollable document";
}

.photo-gallery {
    column-count: 2;
    column-gap: 1rem;
    display: block;
}

.photo-gallery .gallery-card {
    display: inline-block;
    width: 100%;
    margin-bottom: 1rem;
}

.photo-gallery .gallery-card img,
.photo-frame img {
    aspect-ratio: auto;
    object-fit: cover;
}

.video-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 20% 20%, rgba(208, 93, 40, 0.2), transparent 30%),
        linear-gradient(135deg, #18120d 0%, #22160f 100%);
    box-shadow: var(--shadow-strong);
}

.video-wrapper::before {
    content: "Playable / Watch";
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 0.8rem;
    border-radius: 999px;
    color: #fff8ef;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.video-wrapper iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
}

#project-code .container {
    display: grid;
    gap: 1rem;
}

.resource-stack {
    display: grid;
    gap: 0.9rem;
}

.resource-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.05rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 251, 245, 0.78);
    border: 1px solid rgba(43, 30, 20, 0.08);
    box-shadow: 0 16px 32px rgba(38, 23, 12, 0.08);
}

.resource-copy h3 {
    margin: 0;
    font-family: "Bricolage Grotesque", "Space Grotesk", sans-serif;
    font-size: 1.05rem;
}

.resource-copy p,
.resource-intro,
.resource-note {
    margin: 0;
    color: var(--muted);
}

.resource-copy p {
    margin-top: 0.2rem;
    font-size: 0.92rem;
}

.resource-note {
    padding-left: 1rem;
    border-left: 3px solid var(--accent);
}

.resource-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 1rem;
    border-radius: 999px;
    color: #fff7ef;
    text-decoration: none;
    background: linear-gradient(135deg, var(--teal) 0%, #165a65 100%);
    box-shadow: 0 16px 28px rgba(22, 90, 101, 0.18);
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#project-code img {
    width: 120px;
    border-radius: 24px;
    box-shadow: 0 18px 36px rgba(38, 23, 12, 0.16);
}

#back-to-top {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 30;
}

#back-to-top button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
    color: #fff8ef;
    box-shadow: 0 18px 30px rgba(132, 47, 29, 0.28);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#back-to-top button.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.project-footer .container,
footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius-lg);
}

.overview-grid,
.detail-grid {
    display: grid;
    gap: 1rem;
}

.overview-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
}

.detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-card,
.callout-card {
    padding: 1.15rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 251, 245, 0.82);
    border: 1px solid rgba(43, 30, 20, 0.08);
    box-shadow: 0 16px 32px rgba(38, 23, 12, 0.08);
}

.detail-card h3,
.callout-card strong {
    margin: 0 0 0.6rem;
    font-family: "Bricolage Grotesque", "Space Grotesk", sans-serif;
    font-size: 1.05rem;
}

.detail-card p,
.callout-card p {
    margin: 0;
    color: var(--muted);
}

.bullet-list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--muted);
}

.bullet-list li + li {
    margin-top: 0.45rem;
}

.portfolio-card {
    padding: clamp(1.4rem, 3vw, 2rem);
}

.portfolio-intro {
    max-width: 58rem;
    margin: 0 0 1.4rem;
    color: var(--muted);
    font-size: 1rem;
}

.portfolio-flow {
    display: grid;
    gap: 1.4rem;
}

.portfolio-sheet {
    margin: 0;
}

.portfolio-frame {
    overflow: hidden;
    border-radius: calc(var(--radius-xl) - 8px);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(246, 236, 222, 0.96)),
        linear-gradient(135deg, rgba(208, 93, 40, 0.1), rgba(30, 126, 124, 0.12));
    border: 1px solid rgba(43, 30, 20, 0.08);
    box-shadow: 0 28px 56px rgba(38, 23, 12, 0.12);
}

.portfolio-frame img {
    width: 100%;
    height: auto;
    cursor: zoom-in;
}

.portfolio-sheet figcaption {
    margin: 0.85rem 0 0;
    padding: 0 0.2rem;
    color: var(--muted);
    font-size: 0.97rem;
}

.portfolio-sheet-lead .portfolio-frame {
    box-shadow: 0 34px 68px rgba(38, 23, 12, 0.16);
}

.project-notes-section {
    padding-top: 0.3rem;
}

.notes-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 1rem;
    align-items: start;
}

.notes-grid > .note-card:first-child {
    grid-column: 1 / -1;
}

.note-card {
    height: 100%;
    padding: clamp(1.2rem, 2.2vw, 1.6rem);
}

.note-card h2 {
    margin-top: 0;
    max-width: 16ch;
    font-size: clamp(1.35rem, 1.9vw, 1.8rem);
    line-height: 1.06;
    letter-spacing: -0.04em;
}

.note-card .overview-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    align-items: start;
}

.note-card .detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: start;
}

.note-card .detail-card,
.note-card .callout-card {
    height: 100%;
}

.note-card .detail-card p,
.note-card .callout-card p,
.note-card .bullet-list {
    font-size: 0.98rem;
}

footer {
    padding: 0 0 2rem;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(13, 10, 7, 0.82);
    backdrop-filter: blur(10px);
    z-index: 50;
}

.close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 251, 245, 0.94);
    color: var(--ink);
    cursor: pointer;
    font-size: 1.3rem;
}

#imageContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(100%, 1120px);
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#imageContainer::-webkit-scrollbar {
    display: none;
}

.modal-content {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 2rem);
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-strong);
    transition: width 0.2s ease, height 0.2s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.modal.is-zoomed #imageContainer {
    align-items: flex-start;
    justify-content: flex-start;
    overflow: auto;
    touch-action: none;
    cursor: grab;
}

.modal.is-zoomed #imageContainer.is-dragging {
    cursor: grabbing;
}

.modal.is-zoomed .modal-content {
    max-width: none;
    max-height: none;
}


@media (max-width: 980px) {
    .project-hero-card,
    .enhanced-gallery {
        grid-template-columns: 1fr;
    }

    .feature-frame {
        grid-column: auto;
    }

    .photo-gallery {
        column-count: 1;
    }

    .overview-grid,
    .detail-grid,
    .notes-grid {
        grid-template-columns: 1fr;
    }

    .notes-grid > .note-card:first-child {
        grid-column: auto;
    }

    .note-card .overview-grid,
    .note-card .detail-grid {
        grid-template-columns: 1fr;
    }

    .project-hero h1,
    .project-title-long .project-hero h1,
    .project-title-very-long .project-hero h1 {
        max-width: 100%;
    }
}

@media (max-width: 760px) {
    header .container,
    footer .container,
    .project-footer .container {
        flex-direction: column;
        align-items: flex-start;
    }

    nav ul {
        width: 100%;
    }

    nav a {
        width: 100%;
        justify-content: center;
    }

    .project-hero {
        padding-top: 3.2rem;
    }

    .resource-card {
        flex-direction: column;
        align-items: flex-start;
    }
}
