/* ==========================================================================
   FretNought / portfolio
   ========================================================================== */

:root {
    --bg: #f5f8fc;
    --bg-soft: #e8eef7;
    --bg-card: #ffffff;
    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b80;
    --muted-solid: #64748b;
    --rule: #d8e1ee;
    --rule-soft: #e7edf6;

    --accent: #2563eb;
    --accent-soft: #93c5fd;
    --accent-bg: #dbeafe;

    --font-display: "Space Grotesk", "Inter", "Helvetica Neue", sans-serif;
    --font-body: "Inter", "Helvetica Neue", sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", monospace;

    --max: 1040px;
    --pad: clamp(1.5rem, 4vw, 2.75rem);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 32rem), var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
}

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

/* ============== Top bar ============== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem var(--pad);
    background: rgba(245, 248, 252, 0.88);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--rule);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 16px var(--accent-soft);
    animation: dotPulse 2.6s ease-in-out infinite;
}

@keyframes dotPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.45;
    }
}

.topbar__nav {
    display: flex;
    gap: 1.6rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
}

.topbar__nav a {
    color: var(--muted-solid);
    text-decoration: none;
    transition: color 0.15s;
}

.topbar__nav a:hover {
    color: var(--accent);
}

@media (max-width: 720px) {
    .topbar__nav {
        display: none;
    }
}

/* ============== Masthead ============== */
.masthead {
    max-width: var(--max);
    margin: 0 auto;
    padding: 5rem var(--pad) 3.5rem;
}

.masthead__meta {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    color: var(--muted-solid);
    margin-bottom: 2rem;
}

.masthead__meta .sep {
    color: var(--rule);
    margin: 0 0.5rem;
}

.masthead__title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(3.8rem, 10vw, 7.6rem);
    line-height: 0.95;
    letter-spacing: -0.06em;
    margin-bottom: 1.75rem;
    color: var(--ink);
}

.masthead__accent {
    font-style: normal;
    color: var(--accent);
}

.masthead__lede {
    font-family: var(--font-body);
    font-style: normal;
    font-weight: 500;
    font-size: clamp(1.12rem, 2vw, 1.45rem);
    line-height: 1.4;
    color: var(--ink-soft);
    max-width: 50ch;
    margin-bottom: 3rem;
}

.facts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem 2.5rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--rule);
}

.facts>div {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.facts dt {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    color: var(--muted-solid);
}

.facts dd {
    font-size: 0.95rem;
    color: var(--ink);
}

@media (max-width: 640px) {
    .facts {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* ============== Section ============== */
.section {
    max-width: var(--max);
    margin: 0 auto;
    padding: 3.5rem var(--pad);
    border-top: 1px solid var(--rule);
}

.section__head {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.section__num {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    color: var(--accent);
    font-weight: 500;
}

.section__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.9rem, 3.6vw, 2.55rem);
    line-height: 1;
    letter-spacing: -0.045em;
    color: var(--ink);
}

.section p {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--ink-soft);
    margin-bottom: 1.25rem;
    max-width: 68ch;
}

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

.section code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--accent-bg);
    color: var(--accent);
    padding: 0.1em 0.45em;
    border-radius: 10px;
}

.kw {
    font-family: var(--font-body);
    font-style: normal;
    color: var(--accent);
    font-weight: 700;
    font-size: 1em;
}

/* ============== Architecture ============== */
.diagram {
    margin: 2rem 0 2.5rem;
    padding: 1.75rem;
    background: var(--bg-card);
    border: 1px solid var(--rule);
    border-radius: 14px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.05);
}

.diagram img {
    width: 100%;
}

.diagram figcaption {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--muted-solid);
    margin-top: 1rem;
    text-align: center;
}

.components {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.05);
}

.component {
    background: var(--bg-card);
    padding: 1.5rem 1.5rem 1.75rem;
}

.component h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-style: normal;
    font-size: 1.15rem;
    color: var(--accent);
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--rule-soft);
}

.component ul {
    list-style: none;
}

.component li {
    padding: 0.3rem 0;
    font-size: 0.92rem;
    color: var(--ink-soft);
    font-family: var(--font-mono);
    font-size: 0.84rem;
}

@media (max-width: 720px) {
    .components {
        grid-template-columns: 1fr;
    }
}

/* ============== Gallery ============== */
.gallery-group {
    margin-bottom: 2.5rem;
}

.gallery-group:last-child {
    margin-bottom: 0;
}

.gallery-group__heading {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-solid);
    font-weight: 500;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--rule-soft);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
}

.g {
    position: relative;
    overflow: hidden;
    background: var(--bg-soft);
    border: 1px solid var(--rule);
    border-radius: 10px;
    aspect-ratio: 4 / 3;
    transition: border-color 0.2s ease;
}

.g:hover {
    border-color: var(--accent-soft);
}

.g img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.g:hover img {
    transform: scale(1.03);
}

.g figcaption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}

@media (max-width: 720px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: 1fr;
    }
}

/* ============== Links ============== */
.link-list {
    list-style: none;
    border-top: 1px solid var(--rule-soft);
}

.link-list li {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: 1.5rem;
    align-items: baseline;
    padding: 1rem 0;
    border-bottom: 1px solid var(--rule-soft);
}

.link-list__label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--muted-solid);
}

.link-list a {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-style: normal;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.link-list a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

@media (max-width: 540px) {
    .link-list li {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
}

/* ============== Footer ============== */
.footer {
    max-width: var(--max);
    margin: 0 auto;
    padding: 2.5rem var(--pad);
    border-top: 1px solid var(--rule);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--muted-solid);
}

@media (max-width: 720px) {
    .footer {
        flex-direction: column;
        gap: 0.4rem;
    }
}

/* ============== Selection ============== */
::selection {
    background: var(--accent);
    color: var(--bg);
}

/* ============== Click-to-expand Gallery ============== */
.g {
    cursor: zoom-in;
}

.g:focus-visible {
    outline: 3px solid var(--accent-soft);
    outline-offset: 4px;
}

body.lightbox-open {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    place-items: center;
    padding: clamp(1rem, 4vw, 3rem);
    background: rgba(6, 12, 24, 0.9);
    backdrop-filter: blur(10px);
}

.lightbox.is-open {
    display: grid;
}

.lightbox__image {
    max-width: min(92vw, 1200px);
    max-height: 82vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

.lightbox__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.lightbox__close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.04);
}

.lightbox__caption {
    position: absolute;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    max-width: min(90vw, 720px);
    margin: 0;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-align: center;
}

.lightbox__caption:empty {
    display: none;
}

/* ============== Video CTA ============== */
.video-cta {
    border-top: 1px solid var(--rule);
}

.video-cta__inner {
    padding: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--rule);
    border-radius: 18px;
    text-align: center;
}

.video-cta__eyebrow {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.video-cta__title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1.1;
    margin-bottom: 0.75rem;
    color: var(--ink);
}

.video-cta__text {
    max-width: 55ch;
    margin: 0 auto 1.5rem;
    color: var(--ink-soft);
}

.video-cta__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.2rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--bg);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.video-cta__button:hover {
    transform: translateY(-2px);
    opacity: 0.88;
}