/* Matt Komar — site theme. The only stylesheet index.html loads. */

/* Fonts ------------------------------------------------------------------- */

@font-face {
    font-family: "General Sans";
    src: url("../fonts/GeneralSans-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "General Sans";
    src: url("../fonts/GeneralSans-Semibold.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "General Sans";
    src: url("../fonts/GeneralSans-Bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

/* Tokens ------------------------------------------------------------------ */

:root {
    color-scheme: dark;
    --font-sans: "General Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

    --text-size-display: clamp(2.5rem, 6vw, 4.5rem);  /* hero, section titles */
    --text-size-heading: clamp(1.5rem, 2.5vw, 2.25rem); /* feature titles, article h2 */
    --text-size-lede: clamp(1.25rem, 1.8vw, 1.5rem);   /* nav, subtitles, pull quotes */
    --text-size-body: 1.0625rem;                       /* everything else */
    --text-size-prose: 1.125rem;                       /* long-form article text */

    /* Dark theme: page background, with content panels one step lighter. */
    --color-page: #2e2e2e;
    --color-surface: #4a4a4a;
    --color-text: #f2f2f2;
    --color-text-muted: #c4c4c4;   /* 5:1 on --color-surface */
    --color-text-on-media: #fff;
    /* Muted steel blue that sits with the neutral grays: 4.8:1 on
       --color-surface, 7.3:1 on --color-page. */
    --color-accent: #a3c1e3;
    --color-text-on-accent: var(--color-page);
    --shadow-nav: 0 4px 16px rgb(0 0 0 / 0.35);

    --space-xs: 8px;
    --space-sm: 16px;
    --space-md: 24px;
    --space-lg: 48px;
    --space-xl: 96px;

    /* Every section uses the same vertical spacing. */
    --section-space: clamp(64px, 10vw, 128px);
    /* Content caps at 1200px; past that the side gutters grow instead. */
    --content-max: 1200px;
    --page-gutter: max(7.5vw, (100% - var(--content-max)) / 2);
    --nav-height: 72px;
    --radius-card: 20px;
    --radius-tag: 6px;
}

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

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-height);
}

body {
    margin: 0;
    background: var(--color-page);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-size-body);
    line-height: 1.6;
}

h1, h2, h3, p {
    margin: 0;
}

h1, h2, h3 {
    font-size: var(--text-size-heading);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

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

a {
    color: inherit;
}

button {
    font: inherit;
}

/* Nav --------------------------------------------------------------------- */

.site-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    column-gap: var(--space-md);
    min-height: var(--nav-height);
    padding: var(--space-xs) var(--page-gutter);
    background: var(--color-page);
    box-shadow: var(--shadow-nav);
    font-size: var(--text-size-lede);
    font-weight: 700;
    line-height: 1.2;
}

.site-nav__links {
    display: flex;
    gap: var(--space-md);
}

.site-nav__brand,
.site-nav__link {
    text-decoration: none;
}

.site-nav__link:hover {
    color: var(--color-accent);
}

/* Hero -------------------------------------------------------------------- */

.hero {
    position: relative;
    display: grid;
    place-items: center;
    /* Fill the screen below the sticky nav. */
    height: calc(100vh - var(--nav-height));
    height: calc(100svh - var(--nav-height));
    overflow: hidden;
    color: var(--color-text-on-media);
}

/* Darkens the bottom of the video so the headline stays readable. */
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(to top, rgb(0 0 0 / 0.6), transparent 60%);
    pointer-events: none;
}

.hero__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero__title {
    position: relative;
    z-index: 2;
    max-width: 12ch;
    padding: 0 var(--space-sm);
    font-size: var(--text-size-display);
    line-height: 1.05;
    letter-spacing: -0.02em;
    text-align: center;
}

/* Featured + About: alternating text 1/3, image 2/3 ----------------------- */

.featured {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.featured,
.portfolio,
.about {
    padding: var(--section-space) var(--page-gutter) 0;
}

.about {
    padding-bottom: var(--section-space);
}

.feature {
    display: grid;
    grid-template-columns: 1fr 2fr;
    align-items: center;
    gap: 4vw;
    padding: var(--space-lg);
    border-radius: var(--radius-card);
    background: var(--color-surface);
}

.feature--flipped {
    grid-template-columns: 2fr 1fr;
}

.feature--flipped .feature__text {
    order: 2;
}

/* Small uppercase line above a title. */
.eyebrow {
    margin-bottom: var(--space-xs);
    color: var(--color-text-muted);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.feature__text p:not(.eyebrow) {
    max-width: 65ch;
    margin-top: 12px;
}

.pill-link {
    display: inline-block;
    margin-top: var(--space-md);
    padding: var(--space-xs) var(--space-md);
    border: 2px solid var(--color-accent);
    border-radius: 999px;
    color: var(--color-accent);
    font-weight: 600;
    text-decoration: none;
}

.pill-link:hover {
    background: var(--color-accent);
    color: var(--color-text-on-accent);
}

.feature__media {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: var(--radius-card);
}

/* The portrait photo keeps its own shape instead of the 16:9 crop. */
.feature--about .feature__media {
    aspect-ratio: auto;
    max-height: 80vh;
    object-position: top;
}

/* Portfolio: category tabs beside the card grid --------------------------- */

.portfolio__layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 4vw;
}

.portfolio__sidebar {
    position: sticky;
    top: calc(var(--nav-height) + var(--space-md));
    align-self: start;
}

.portfolio__title {
    margin-bottom: var(--space-md);
}

.tab-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.tab {
    padding: var(--space-sm);
    border: 0;
    border-radius: var(--radius-card);
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}

.tab[aria-selected="true"] {
    background: var(--color-accent);
    color: var(--color-text-on-accent);
}

.card-grid {
    display: grid;
    /* 3 columns at full width, dropping to 2 then 1 as space shrinks. */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-lg) var(--space-md);
}

.card-grid[hidden] {
    display: none;
}

/* Cards sit directly on the page: a rounded square image, then title and
   tags beneath it. */
.card {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    text-decoration: none;
}

.card__frame {
    overflow: hidden;
    border-radius: var(--radius-card);
}

.card__media {
    width: 100%;
    height: auto;
    /* Thumbnails are square; show them whole. */
    aspect-ratio: 1;
    object-fit: cover;
    transition: transform 200ms ease;
}

.card:hover .card__media {
    transform: scale(1.03);
}

.card__title {
    margin-bottom: 12px;
    font-size: var(--text-size-body);
    font-weight: 600;
    letter-spacing: 0;
    transition: color 200ms ease;
}

.card:hover .card__title {
    color: var(--color-accent);
}

.card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Square-cornered chips read as labels; round pills are reserved for links. */
.tag {
    padding: 2px 12px;
    border-radius: var(--radius-tag);
    background: var(--color-surface);
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Project pages ----------------------------------------------------------- */

/* Header, text and pager share one centered column; figures break out of it
   to --media-max. Both are in rem so every element resolves them alike. */
.project {
    --measure: 42rem;
    --media-max: 60rem;
    padding: var(--section-space) var(--page-gutter);
}

.project__header,
.project__pager {
    max-width: var(--measure);
    margin-inline: auto;
}

.project__title {
    font-size: var(--text-size-display);
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.project__subtitle {
    margin-top: var(--space-sm);
    color: var(--color-text-muted);
    font-size: var(--text-size-lede);
    line-height: 1.35;
}

.project__dates {
    margin-top: var(--space-xs);
    color: var(--color-text-muted);
}

.project__roles {
    margin-top: var(--space-md);
}

.project__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.project__pager {
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-surface);
}

.project__pager .pill-link {
    margin-top: 0;
}

/* Markdown body of a project page. */
.prose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min(var(--measure), 100%) minmax(0, 1fr);
    margin-top: var(--space-lg);
    font-size: var(--text-size-prose);
    line-height: 1.7;
}

.prose > * {
    grid-column: 2;
}

.prose > * + * {
    margin-top: 1em;
}

.prose h2 {
    margin-top: var(--space-lg);
}

.prose h3 {
    margin-top: var(--space-md);
    font-size: 1.25rem;
}

/* An opening "### " line is the article's lede, not a heading. */
.prose > h3:first-child {
    margin-top: 0;
    font-size: var(--text-size-lede);
    font-weight: 400;
    line-height: 1.4;
}

.prose ul,
.prose ol {
    margin-bottom: 0;
}

.prose ul {
    padding-left: 1.25em;
}

.prose ol {
    padding-left: 1.5em;
}

.prose li + li {
    margin-top: 0.25em;
}

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

/* "> " in Markdown: a pull quote. */
.prose blockquote {
    margin: var(--space-md) 0 var(--space-xs);
    padding-left: var(--space-md);
    border-left: 3px solid var(--color-accent);
    font-size: var(--text-size-lede);
    line-height: 1.4;
}

.prose blockquote > * + * {
    margin-top: 0.75em;
}

.prose code {
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: var(--color-surface);
}

.prose pre {
    overflow-x: auto;
    padding: var(--space-sm);
    border-radius: var(--radius-tag);
    background: var(--color-surface);
}

.prose pre code {
    padding: 0;
    background: none;
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--color-surface);
    margin-block: var(--space-lg);
}

.prose table {
    display: block;
    overflow-x: auto;
    border-collapse: collapse;
}

.prose th,
.prose td {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--color-surface);
    text-align: left;
}

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

/* Standalone images and videos span the full row, up to --media-max; an
   italic line under one is its caption. */
.prose > figure {
    grid-column: 1 / -1;
    justify-self: center;
    width: 100%;
    max-width: var(--media-max);
    margin: var(--space-lg) 0 var(--space-md);
}

.prose figure img,
.prose .embed iframe {
    display: block;
    width: 100%;
    border-radius: var(--radius-tag);
}

.prose .embed iframe {
    aspect-ratio: 16 / 9;
    height: auto;
    border: 0;
}

.prose figcaption {
    margin-top: var(--space-xs);
    color: var(--color-text-muted);
    font-size: var(--text-size-body);
}

/* Lightbox: a post image enlarged over the dimmed page. */
.prose figure img {
    cursor: zoom-in;
}

.lightbox {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: var(--space-md);
    border: 0;
    background: transparent;
    color: var(--color-text-on-media);
    cursor: zoom-out;
    /* showModal() focuses the dialog itself; a ring around the whole screen
       is noise. */
    outline: none;
}

.lightbox[open] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    animation: lightbox-in 150ms ease-out;
}

.lightbox::backdrop {
    background: rgb(0 0 0 / 0.85);
    animation: lightbox-in 150ms ease-out;
}

.lightbox__img {
    min-height: 0;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-tag);
}

.lightbox__caption {
    text-align: center;
}

@keyframes lightbox-in {
    from {
        opacity: 0;
    }
}

/* Keep the page from scrolling behind an open lightbox. */
html:has(.lightbox[open]) {
    overflow: hidden;
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-lg) var(--page-gutter);
    background: var(--color-surface);
}

.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* Pills already carry a top margin for their use under feature text. */
.site-footer__links .pill-link {
    margin-top: 0;
}

/* Small screens ----------------------------------------------------------- */

@media (max-width: 767px) {
    :root {
        --nav-height: 88px;
    }

    .site-nav {
        justify-content: center;
    }

    .feature {
        padding: var(--space-md);
    }

    .feature,
    .feature--flipped,
    .portfolio__layout {
        grid-template-columns: 1fr;
    }

    .feature--flipped .feature__text {
        order: 0;
    }

    .portfolio__sidebar {
        position: static;
        text-align: center;
    }

    .tab-list {
        flex-direction: row;
        justify-content: center;
    }
}

/* Accessibility ----------------------------------------------------------- */

a:focus-visible,
button:focus-visible,
.prose figure img:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

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

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
