:root {
    --bg: #f6f6f4;
    --surface: #ffffff;
    --text: #121212;
    --text-muted: #4a4a4a;
    --accent: #1d4ed8;
    --border: #d4d4d0;
    --content-max: 42rem;
    --media-tile-mat: #e8e6e1;
}

html {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
}

@media (min-width: 48rem) {
    html {
        font-size: 17px;
    }
}

@media print {
    html {
        font-size: 10pt;
    }
}

body {
    padding: 0;
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

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

a:hover {
    text-decoration: underline;
}

@media print {
    a {
        text-decoration: none;
        color: var(--text);
    }

    .site-nav {
        display: none;
    }
}

.site-main {
    min-height: 100vh;
    background: var(--surface);
    overflow-x: clip;
}

.content {
    --content-pad-inline: 1.5rem;
    padding: 2rem var(--content-pad-inline);
    max-width: var(--content-max);
    margin: 0 auto;
}

@media (min-width: 48rem) {
    .content {
        --content-pad-inline: 4rem;
        --main-column-width: min(100vw, calc(var(--content-max) + 2 * var(--content-pad-inline)));
        --carousel-inset-left: calc((100vw - var(--main-column-width)) / 2 + var(--content-pad-inline));
        padding: 3rem var(--content-pad-inline);
    }
}

/* —— Home (full-width header + tile grid) —— */
body.home {
    background: var(--surface);
}

.site-header {
    display: flex;
    justify-content: center;
    padding: 1rem clamp(1rem, 3vw, 2.5rem);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-nav {
    width: 100%;
    max-width: 80rem;
}

.home-intro {
    display: flex;
    justify-content: center;
    padding: 1.25rem clamp(1rem, 3vw, 2.5rem) 0;
    background: var(--surface);
}

.home-intro .site-identity {
    max-width: 36rem;
}

.site-identity--sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.site-identity--sr-only a,
.site-identity--sr-only img {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.site-identity {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    flex: 1 1 18rem;
    max-width: 36rem;
    position: relative;
}

.site-identity .u-logo {
    display: block;
    width: 3.25rem;
    height: 3.25rem;
    object-fit: contain;
    flex-shrink: 0;
}

.site-identity .u-photo {
    display: none;
}

.site-identity-text {
    min-width: 0;
}

.site-identity .p-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.site-identity .p-note {
    display: block;
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.45;
    text-decoration: none;
}

.site-identity .p-note:hover {
    color: var(--accent);
}

.site-identity a[rel="me"]:not(.p-name) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.site-nav ul {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 1.25rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.site-nav a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    font-size: 0.95rem;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
    color: var(--accent);
}

.site-nav a img {
    height: 1.25em;
    vertical-align: middle;
}

.home-main {
    padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 3rem);
    max-width: 80rem;
    margin: 0 auto;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    gap: 1.5rem;
    align-items: stretch;
}

.tile {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(9.5rem, auto);
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tile-media {
    grid-row: 1;
    flex-shrink: 0;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.tile--text-only .tile-media {
    visibility: hidden;
    border-bottom-color: transparent;
}

.tile-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Media homepage tiles: full portrait cover on a solid mat */
.tile--media .tile-media {
    aspect-ratio: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 12rem;
    height: clamp(12rem, 32vw, 17.5rem);
    padding: 1rem 1.35rem;
    background: var(--media-tile-mat);
    border-bottom: 1px solid var(--border);
}

.tile--media .tile-image {
    width: auto;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    border-radius: 0.3rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.tile-body {
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 0;
    padding: 1.15rem 1.35rem 1.25rem;
}

.tile--text-only .tile-body {
    grid-row: 1 / -1;
    grid-column: 1;
}

.tile:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.tile-kind {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.tile-title {
    font-size: 1.15rem;
    margin: 0;
    line-height: 1.3;
    color: var(--text);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.tile-date {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.tile-desc,
.tile-excerpt {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin: 0.15rem 0 0;
    line-height: 1.45;
    max-height: calc(4 * 1.45em);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
}

.tile--text-only .tile-desc {
    flex: 1;
    max-height: none;
    -webkit-line-clamp: 9;
}

.tile-excerpt > :first-child {
    margin-top: 0;
}

.tile-excerpt > :last-child {
    margin-bottom: 0;
}

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

.tile-excerpt figure {
    display: block;
    margin: 0.75rem 0;
}

.tile-excerpt figure.right {
    float: none;
}

@media print {
    .site-header {
        border-bottom: 1px solid var(--border);
    }
}

.content-kind {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.page,
.post {
    padding: 1.25rem 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.page:last-child,
.post:last-child {
    border-bottom: none;
}

.page-title,
.post-title {
    font-size: 1.25rem;
    margin-top: 0;
    line-height: 1.3;
}

.post-title a,
.page-title a {
    color: var(--text);
    text-decoration: none;
}

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

.page-date,
.post-date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.page-description,
.post-description {
    font-style: italic;
    color: var(--text-muted);
}

.tags ul {
    display: inline;
    list-style: none;
    padding: 0;
    margin: 0;
}

.tags li {
    display: inline;
    font-size: 0.85rem;
}

.tags li::after {
    content: ", ";
}

.tags li:last-child::after {
    content: "";
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

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

.content .right {
    float: right;
}

.content .float-break {
    clear: both;
}

.content .float-pair {
    display: flow-root;
    margin-bottom: 1.25rem;
}

.content .float-pair > :first-child {
    margin-top: 0;
}

.content .float-pair > :last-child {
    margin-bottom: 0;
}

.content .half {
    max-width: 50%;
    padding: 1em;
}

.content .third {
    max-width: 33%;
    padding: 1em;
}

.content .image-matte {
    width: 100%;
    background: var(--media-tile-mat);
    border-radius: 0.3rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    margin: 0;
    padding: 0;
}

.content .image-matte__image {
    display: block;
    width: 100%;
    height: var(--image-fixed-height);
    box-sizing: border-box;
    max-width: none;
    object-fit: contain;
    object-position: center;
    margin: 0;
    padding: 0.5rem;
}

.content .image-matte.right {
    margin-left: 1em;
    clear: right;
}

.content .image-matte.left {
    margin-right: 1em;
    clear: left;
}

.content .image-matte.half,
.content .image-matte.third {
    padding: 0;
}

.content a.lightbox-trigger {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: zoom-in;
}

.content a.lightbox-trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.content a.lightbox-trigger img {
    width: 100%;
}

.lightbox {
    border: none;
    padding: 0;
    margin: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    background: transparent;
    overflow: visible;
}

.lightbox::backdrop {
    background: rgba(0, 0, 0, 0.88);
}

.lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox__image {
    display: block;
    max-width: min(95vw, 100%);
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

.lightbox__close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1;
    border: none;
    border-radius: 0.25rem;
    padding: 0.35rem 0.65rem;
    font-size: 2rem;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
}

.lightbox__close:hover {
    background: rgba(0, 0, 0, 0.75);
}

.youtube {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.youtube::after {
    display: block;
    content: "";
    padding-top: 56.25%;
}

.youtube iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.callout {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    background: #e8f0fe;
    color: var(--text);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-left: 4px solid var(--accent);
}

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

pre {
    white-space: pre-wrap;
    padding: 1rem;
    font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
    font-size: 0.88rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    background: var(--bg);
}

figure {
    display: table;
    max-width: 100%;
    margin: 1.5rem 0;
}

figcaption {
    font-size: 0.875rem;
    padding: 0.5rem 0;
    color: var(--text-muted);
    display: table-caption;
    caption-side: bottom;
}

/* Resume: each section flows in two columns on wide screens and print */
.h-resume .resume-section {
    column-count: 1;
    margin-bottom: 2rem;
}

@media (min-width: 52rem), print {
    .h-resume .resume-section {
        column-count: 2;
        column-gap: 2.5rem;
    }

    .h-resume .resume-section > h2 {
        column-span: all;
        break-after: avoid;
    }

    .h-resume .resume-section .h-event,
    .h-resume .resume-section .h-cite {
        break-inside: avoid;
    }
}

.h-cite cite {
    display: block;
    font-weight: bold;
    font-style: normal;
}

.h-resume .h-card .p-name {
    font-weight: bold;
    display: block;
    font-size: x-large;
}

.h-resume .h-card ul {
    list-style-type: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    padding: 0;
}

/* Media reviews */
.media-list {
    list-style: none;
    padding: 0;
}

.media-list li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.media-list img.u-photo {
    width: 3rem;
    height: 4.5rem;
    object-fit: cover;
    border-radius: 2px;
}

.media-review-layout {
    display: flow-root;
}

.content img.media-cover {
    float: right;
    width: auto;
    height: auto;
    max-width: 10rem;
    max-height: 15rem;
    margin: 0 0 1rem 1.35rem;
    object-fit: contain;
    object-position: center;
    background: var(--media-tile-mat);
    border-radius: 0.3rem;
    padding: 0.2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.media-byline {
    margin: -0.35rem 0 1.25rem;
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.media-list-meta {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: normal;
}

.h-review .p-rating {
    color: var(--accent);
    font-weight: 600;
}

/* Carousel (Embla) — bleed right on desktop, fixed image height */
.carousel.embla {
    --slide-height: clamp(18rem, 58vh, 34rem);
    --slide-gap: 1rem;
    position: relative;
    z-index: 1;
    margin: 2rem 0;
    margin-left: 0;
    width: 100%;
    background: var(--bg);
    border-block: 1px solid var(--border);
}

@media (min-width: 48rem) {
    .carousel.embla {
        width: calc(100vw - var(--carousel-inset-left, var(--content-pad-inline)));
        max-width: calc(100vw - var(--carousel-inset-left, var(--content-pad-inline)));
    }
}

.embla__viewport {
    overflow: hidden;
    height: var(--slide-height);
    overscroll-behavior-x: contain;
}

.embla__container {
    display: flex;
    touch-action: pan-y pinch-zoom;
    margin-left: calc(var(--slide-gap) * -1);
    height: 100%;
}

.embla__slide {
    flex: 0 0 auto;
    min-width: 0;
    padding-left: var(--slide-gap);
    height: 100%;
}

.embla__slide figure {
    display: block;
    margin: 0;
    height: 100%;
    max-width: none;
}

/* Override .content img / figure { display: table } so slides keep intrinsic width */
.carousel.embla img {
    max-width: none;
    height: 100%;
    width: auto;
    display: block;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.embla__prev,
.embla__next {
    position: absolute;
    top: 50%;
    z-index: 3;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    border-radius: 0.2rem;
    transition: background 0.15s ease;
}

.embla__prev:hover:not(:disabled),
.embla__next:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.7);
}

.embla__prev:disabled,
.embla__next:disabled {
    opacity: 0.35;
    cursor: default;
}

.embla__prev {
    left: 0.5rem;
}

.embla__next {
    right: 0.5rem;
}

.sketch-mount {
    min-height: 12rem;
    border: 1px dashed var(--border);
    margin: 1rem 0;
}

@media print {
    .content .page-title {
        display: none;
    }

    .embla__prev,
    .embla__next {
        display: none;
    }
}
