:root {
    color-scheme: light dark;

    /* Layout */
    --measure: 48rem;

    /* Surfaces */
    --bg: #ffffff;
    --fg: #000000;

    /* Neutral scale (Tailwind neutral) */
    --neutral-800: rgb(38 38 38);
    --neutral-700: rgb(64 64 64);
    --neutral-600: rgb(82 82 82);
    --neutral-500: rgb(115 115 115);
    --neutral-400: rgb(163 163 163);
    --neutral-300: rgb(212 212 212);
    --neutral-200: rgb(229 229 229);

    /* Accent (swap-point for later theming) */
    --accent: var(--fg);
    --story-progress: #f2c94c;

    /* Overlay */
    --scrim: rgba(0, 0, 0, 0.78);
    --on-scrim: #ffffff;

    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@property --story-ring-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0b0b;
        --fg: #f5f5f5;

        --neutral-800: rgb(245 245 245);
        --neutral-700: rgb(212 212 212);
        --neutral-600: rgb(163 163 163);
        --neutral-500: rgb(140 140 140);
        --neutral-400: rgb(115 115 115);
        --neutral-300: rgb(82 82 82);
        --neutral-200: rgb(64 64 64);
    }
}

* {
    box-sizing: border-box;
}

body {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 3rem;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-mono);
}

.profile-story-toggle {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 0 0 2rem;
    border-radius: 9999px;
    cursor: default;
}

.has-profile-story .profile-story-toggle {
    width: 8.75rem;
    height: 8.75rem;
    margin: 0 0 1.625rem -0.375rem;
    cursor: pointer;
}

.profile-story-toggle:hover,
.profile-story-toggle:focus-visible {
    text-decoration: none;
}

.profile-story-toggle:focus-visible {
    outline: 1px solid var(--fg);
    outline-offset: 0.375rem;
}

.profile-story-ring {
    --story-ring-angle: 0deg;
    position: absolute;
    inset: 0.0625rem;
    display: none;
    border-radius: inherit;
    background:
        conic-gradient(
            from var(--story-ring-angle),
            var(--neutral-200),
            var(--neutral-400),
            var(--fg),
            var(--neutral-300),
            var(--neutral-200)
        );
    animation: story-ring-spin 10s linear infinite;
}

.has-profile-story .profile-story-ring {
    display: block;
}

.profile-story-ring::before {
    content: '';
    position: absolute;
    inset: 0.1875rem;
    border-radius: inherit;
    background: var(--bg);
}

.profile-story-ring::after {
    content: '';
    position: absolute;
    inset: -0.0625rem;
    border-radius: inherit;
    border: 1px solid var(--neutral-200);
    opacity: 0.9;
}

.profile-image-frame {
    display: block;
    width: 8rem;
    height: 8rem;
    margin-bottom: 2rem;
    border: 2px solid var(--fg);
    border-radius: 9999px;
    overflow: hidden;
    background: var(--fg);
}

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

.profile-story-toggle .profile-image-frame {
    position: relative;
    margin: 0;
}

.has-profile-story .profile-story-toggle .profile-image-frame {
    margin: 0.375rem;
}

.profile-story-viewed .profile-story-toggle {
    width: 8rem;
    height: 8rem;
    margin: 0 0 2rem;
}

.profile-story-viewed .profile-story-ring {
    display: none;
}

.profile-story-viewed .profile-story-toggle .profile-image-frame {
    margin: 0;
}

@keyframes story-ring-spin {
    to {
        --story-ring-angle: 360deg;
    }
}

h1 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 2rem;
}

.terminal-lowercase {
    text-transform: lowercase;
}

.tagline {
    margin: 0 0 2rem;
    color: var(--neutral-600);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.gallery-section {
    margin: 2.5rem 0 0;
}

.gallery-heading {
    margin: 0 0 0.5rem;
    color: var(--fg);
    font: inherit;
}

.gallery {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    cursor: grab;
    touch-action: pan-x pan-y pinch-zoom;
    user-select: none;
}

.gallery.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
}

.gallery::-webkit-scrollbar {
    display: none;
}

.gallery-item {
    flex: 0 0 auto;
    min-width: 0;
    background: transparent;
    overflow: hidden;
    scroll-snap-align: start;
}

.gallery-item:focus-visible {
    outline: 1px solid var(--fg);
    outline-offset: 2px;
}

.gallery-item img {
    display: block;
    width: auto;
    height: 6rem;
    max-width: 100%;
    border: 1px solid var(--neutral-200);
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.gallery-dots {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.625rem;
}

.gallery-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 9999px;
    background: var(--neutral-300);
}

.gallery-dot[aria-current="true"] {
    background: var(--accent);
}

.gallery-dot:hover,
.gallery-dot:focus-visible {
    outline: 0;
    background: var(--neutral-600);
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--fg);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

button:hover,
button.underline {
    text-decoration: underline;
}

.arrow-right::before {
    content: '→ ';
}

.arrow-down::before {
    content: '↓ ';
}

.section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 300ms ease-in-out;
}

.section-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

.project-entry {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    width: fit-content;
    max-width: 100%;
    column-gap: 0.25rem;
    color: var(--neutral-800);
    text-decoration: none;
}

.project-entry::before {
    content: '↳ ';
}

.project-entry:hover {
    color: var(--fg);
    text-decoration: underline;
}

.project-heading {
    display: inline-flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
    flex-wrap: wrap;
}

.unannounced-badge {
    display: inline;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

.project-separator {
    color: var(--neutral-400);
}

.project-kind {
    color: var(--neutral-700);
    font-size: 0.875rem;
}

.project-description {
    display: block;
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
    color: var(--neutral-500);
    font-size: 0.875rem;
    line-height: 1.45;
}

.contact-placeholder {
    color: var(--neutral-600);
    font-style: italic;
}

.contact-placeholder::before {
    content: '↳ ';
}

.location {
    margin: 0;
    color: var(--neutral-400);
    font-size: 0.75rem;
    line-height: 1rem;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
    background: var(--scrim);
}

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

.lightbox-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    padding: 0 3rem;
}

.lightbox-image {
    display: block;
    max-width: calc(100vw - 10rem);
    max-height: calc(100vh - 8rem);
    max-height: calc(100dvh - 8rem);
    min-height: 0;
    object-fit: contain;
}

.lightbox-description {
    max-width: calc(100vw - 10rem);
    margin: 1rem 0 0;
    color: var(--on-scrim);
    font-size: 0.875rem;
    line-height: 1.35;
    text-align: center;
    flex: 0 0 auto;
}

.lightbox-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    width: 3.5rem;
    color: var(--on-scrim);
    text-align: center;
    font-size: 1.5rem;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.lightbox-nav:hover,
.lightbox-nav:focus-visible {
    outline: 0;
    color: var(--on-scrim);
    text-decoration: underline;
}

.lightbox-prev {
    left: 0;
    justify-content: flex-start;
    padding-left: 2rem;
}

.lightbox-next {
    right: 0;
    justify-content: flex-end;
    padding-right: 2rem;
}

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    color: var(--on-scrim);
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
    outline: 0;
    color: var(--on-scrim);
    text-decoration: underline;
}

body.lightbox-open {
    overflow: hidden;
}

.story {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--scrim);
}

.story.is-open {
    display: flex;
}

.story-frame {
    position: relative;
    --story-duration: 7200ms;
    width: min(42rem, calc(100vw - 4rem), calc((100vh - 4rem) * 520 / 813));
    width: min(42rem, calc(100vw - 4rem), calc((100dvh - 4rem) * 520 / 813));
    aspect-ratio: 520 / 813;
    background: var(--fg);
    box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.story-close {
    position: absolute;
    top: 1.5rem;
    right: 0.75rem;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.22);
    color: var(--on-scrim);
    text-shadow: 0 1px 0 var(--fg);
}

.story-close svg {
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
}

.story-close:hover,
.story-close:focus-visible {
    outline: 0;
    background: rgba(0, 0, 0, 0.36);
    color: var(--on-scrim);
    text-decoration: none;
}

.story-progress {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 2;
    display: flex;
    gap: 0.25rem;
}

.story-progress span {
    display: block;
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.4);
    overflow: hidden;
}

.story-progress span::before {
    content: '';
    display: block;
    height: 100%;
    background: var(--story-progress);
    transform: scaleX(0);
    transform-origin: left;
}

.story-progress span.is-complete::before {
    transform: scaleX(1);
}

.story-progress span.is-active::before {
    animation: story-progress var(--story-duration) linear forwards;
}

.story-age {
    position: absolute;
    top: 1.5rem;
    left: 1rem;
    z-index: 2;
    color: var(--on-scrim);
    font-size: 0.75rem;
    line-height: 1rem;
    text-shadow: 0 1px 0 var(--fg), 0 0 0.75rem var(--fg);
}

.story-tap-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 1;
    width: 50%;
}

.story-tap-zone:hover,
.story-tap-zone:focus-visible {
    outline: 0;
    text-decoration: none;
}

.story-tap-previous {
    left: 0;
}

.story-tap-next {
    right: 0;
}

.story-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

body.story-open {
    overflow: hidden;
}

@keyframes story-progress {
    to {
        transform: scaleX(1);
    }
}

@media (max-width: 640px) {
    body {
        padding: 2rem;
    }

    .has-profile-story .profile-story-toggle {
        width: 8.5rem;
        height: 8.5rem;
    }

    .has-profile-story .profile-story-toggle .profile-image-frame {
        width: 7.75rem;
        height: 7.75rem;
    }

    .profile-story-viewed .profile-story-toggle,
    .profile-story-viewed .profile-story-toggle .profile-image-frame {
        width: 8rem;
        height: 8rem;
    }

    .gallery-item img {
        height: 4.75rem;
    }

    .lightbox {
        padding: 1rem;
    }

    .lightbox-frame {
        padding: 0 2rem;
    }

    .lightbox-image {
        max-width: calc(100vw - 6rem);
        max-height: calc(100vh - 5.5rem);
        max-height: calc(100dvh - 5.5rem);
    }

    .lightbox-description {
        max-width: calc(100vw - 6rem);
    }

    .lightbox-nav {
        width: 2.5rem;
    }

    .lightbox-prev {
        padding-left: 1rem;
    }

    .lightbox-next {
        padding-right: 1rem;
    }

    .story {
        padding: 1rem;
    }

    .story-frame {
        width: min(42rem, calc(100vw - 2rem), calc((100vh - 2rem) * 520 / 813));
        width: min(42rem, calc(100vw - 2rem), calc((100dvh - 2rem) * 520 / 813));
    }
}

@media (max-height: 480px) and (orientation: landscape) {
    .lightbox {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .story {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .story-frame {
        width: min(42rem, calc(100vw - 4rem), calc((100vh - 1.5rem) * 520 / 813));
        width: min(42rem, calc(100vw - 4rem), calc((100dvh - 1.5rem) * 520 / 813));
    }

    .lightbox-image {
        max-height: calc(100vh - 4.25rem);
        max-height: calc(100dvh - 4.25rem);
    }

    .lightbox-description {
        margin-top: 0.5rem;
        font-size: 0.8125rem;
        line-height: 1.25;
    }
}
