/* ==================================================
   AI ENGINEERING CASE STUDY (the story component)
   ==================================================
   Everything inside a project page's <article class="vibe-story">: the
   head (labels, title, one-liner, proof, buttons), the hero walkthrough,
   the project facts and the long-form story. The markup is baked at build
   time by scripts/lib/vibe-story.mjs; js/vibe-project.js reveals, loads and
   plays it. The page around it (breadcrumb bar, wraps, the hero band, more
   projects) lives in css/vibe-project.css.

   Editorial language: paper, hairline rules, mono marginalia, ink inversion
   on hover, no shadows, no radius, no soft fades for entrances.

   One grid runs the whole story: 5 / 7 columns on wide containers. Headings
   and labels sit in the left column, prose in the right, media spans both.
   Spacing is a scale, so distance says what belongs together:
     --vs-space-section  between numbered sections (the largest)
     --vs-space-group    between sub-sections inside a section
     --vs-space-part     between a block of prose and its media
     18px                between paragraphs
   Sizes follow the container (.vibe-page__wrap, container "vstory"), so one
   set of rules serves phones, tablets and wide screens.

   Reveals wait for html.vs-js (set in the page head), so without scripts
   the story is plain, readable text.
   ================================================== */

[data-vibe-project] {
    --vs-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --vs-ink: var(--ink, #0a0a0a);
    --vs-paper: var(--paper, #ffffff);
    --vs-hairline: var(--hairline, rgba(10, 10, 10, 0.14));
    --vs-hairline-strong: var(--hairline-strong, rgba(10, 10, 10, 0.32));
    --vs-ink-60: var(--ink-60, rgba(10, 10, 10, 0.6));
    --vs-ink-40: var(--ink-40, rgba(10, 10, 10, 0.4));
    --vs-frame: var(--hairline, rgba(10, 10, 10, 0.14));
    --vs-slate: #f2f2f2;
    --vs-accent: var(--vs-ink);
    --vs-font-ui: var(--font-ui, "Rido Neue Haas Text", "Helvetica Neue", Helvetica, Arial, sans-serif);
    --vs-font-display: var(--font-display, var(--vs-font-ui));
    --vs-font-serif: var(--font-serif, "Rido Tiempos Text", Georgia, "Times New Roman", serif);
    --vs-font-mono: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);

    /* cqw values resolve where they are used, against the nearest wrap */
    --vs-col-gap: clamp(28px, 4cqw, 64px);
    --vs-space-section: clamp(84px, 11cqw, 160px);
    --vs-space-group: clamp(56px, 7.5cqw, 112px);
    --vs-space-part: clamp(28px, 3.4cqw, 48px);
    --vs-fig-gap: clamp(14px, 1.8cqw, 24px);
    --vs-row-max: min(76vh, 680px);
    --vs-hero-max: min(74vh, 720px);
    --vs-stage: var(--vs-slate);
    --vs-stage: color-mix(in srgb, var(--vs-accent) 8%, var(--vs-paper));
}

.vibe-story {
    display: block;
    color: var(--vs-ink);
    font-family: var(--vs-font-ui);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: normal;
    text-align: left;
    -webkit-font-smoothing: antialiased;
}

.vibe-story__icon {
    display: block;
    width: 18px;
    height: 18px;
}

/* Hairline rules are elements (not borders) so they can draw themselves in. */
.vibe-story__rule {
    display: block;
    height: 1px;
    background: var(--vs-hairline);
    transform-origin: 0 50%;
}

/* Line masks: copy slides up from behind the mask. The mask leaves room for
   descenders so tight leading is never clipped at rest. */
.vibe-story__mask {
    display: block;
    overflow: hidden;
    padding-bottom: 0.14em;
    margin-bottom: -0.14em;
}

.vibe-story__line {
    display: block;
}

/* ==================================================
   HEAD
   ================================================== */
.vibe-story__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: clamp(22px, 2.8cqw, 36px);
    padding: clamp(36px, 5.2cqw, 76px) 0 clamp(36px, 4.6cqw, 64px);
}

.vibe-story__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 0;
}

.vibe-story__tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 6px 8px 5px;
    border: 1px solid #d8d8d8;
    background: #fbfbfb;
    color: var(--vs-ink);
    font-family: var(--vs-font-mono);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
}

.vibe-story__tag--fill {
    border-color: var(--vs-ink);
    background: var(--vs-ink);
    color: var(--vs-paper);
    font-weight: 700;
}

.vibe-story__tag--status::before {
    content: "";
    width: 6px;
    height: 6px;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--vs-accent);
}

.vibe-story__meta-end {
    display: inline-flex;
    align-items: center;
    gap: 18px;
    margin-left: auto;
}

.vibe-story__read,
.vibe-story__date {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--vs-font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--vs-ink-60);
    white-space: nowrap;
}

.vibe-story__read {
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.vibe-story__read .vibe-story__read-icon {
    width: 14px;
    height: 14px;
}

/* Too narrow for one row: reading time and date start their own line at the
   left edge instead of hanging off the right. */
@container vstory (max-width: 459px) {
    .vibe-story__meta-end {
        flex-basis: 100%;
        margin-left: 0;
    }
}

.vibe-story__intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px var(--vs-col-gap);
    align-items: start;
}

.vibe-story__title {
    margin: 0;
    font-family: var(--vs-font-display);
    font-weight: 700;
    font-size: clamp(40px, 6.2cqw, 90px);
    line-height: 0.95;
    letter-spacing: -0.035em;
    text-transform: none;
    text-wrap: balance;
    color: var(--vs-ink);
    /* tabular figures steady the width while the decrypt glyphs cycle */
    font-variant-numeric: tabular-nums;
}

/* The project's symbol sits above its title; a section's icon above its
   number. Still files that their moving twins replace while on screen
   (js/vibe-project.js, initGlyphs). */
.vibe-story__glyph {
    display: block;
    max-width: none;
}

.vibe-story__symbol {
    display: block;
    width: clamp(52px, 5cqw, 64px);
    height: clamp(52px, 5cqw, 64px);
    margin-bottom: clamp(16px, 2cqw, 24px);
}

.vibe-story__symbol .vibe-story__glyph {
    width: 100%;
    height: 100%;
}

.vibe-story__section-icon {
    width: clamp(44px, 4cqw, 52px);
    height: clamp(44px, 4cqw, 52px);
    margin-bottom: 4px;
}

.vibe-story__lede {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    min-width: 0;
}

/* While the title decrypts, every word holds its resting width (set by
   js/vibe-project.js), so the lines never re-wrap mid-scramble. */
.vibe-story__title-word {
    display: inline-block;
    white-space: nowrap;
}

.vibe-story__desc {
    margin: 0;
    max-width: 50ch;
    font-family: var(--vs-font-serif);
    font-style: italic;
    font-weight: 400;
    font-size: clamp(18px, 1.9cqw, 24px);
    line-height: 1.42;
    letter-spacing: 0;
    color: var(--vs-ink-60);
}

.vibe-story__proof {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    max-width: 56ch;
    font-size: 15px;
    line-height: 1.45;
    color: var(--vs-ink);
}

.vibe-story__proof .vibe-story__proof-icon {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    color: var(--vs-accent);
}

.vibe-story__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 4px;
}

.vibe-story__cta,
.vibe-story__link {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 48px;
    margin: 0;
    padding: 14px 18px;
    font-family: var(--vs-font-ui);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    transition:
        background-color 220ms var(--vs-ease),
        border-color 220ms var(--vs-ease),
        color 220ms var(--vs-ease);
}

.vibe-story__cta {
    border: 1px solid var(--vs-ink);
    background: var(--vs-ink);
    color: var(--vs-paper);
}

.vibe-story__link {
    border: 1px solid var(--vs-hairline-strong);
    background: transparent;
    color: var(--vs-ink);
}

.vibe-story__cta:hover,
.vibe-story__cta:focus-visible {
    background: var(--vs-paper);
    color: var(--vs-ink);
    text-decoration: none;
}

.vibe-story__link:hover,
.vibe-story__link:focus-visible {
    background: var(--vs-ink);
    border-color: var(--vs-ink);
    color: var(--vs-paper);
    text-decoration: none;
}

.vibe-story .vibe-story__cta:focus-visible,
.vibe-story .vibe-story__link:focus-visible {
    outline: 2px solid var(--vs-ink);
    outline-offset: 3px;
    border-radius: 0;
}

.vibe-story__cta .vibe-story__icon,
.vibe-story__link .vibe-story__icon {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    transition: transform 240ms var(--vs-ease);
}

.vibe-story__cta:hover .vibe-story__icon,
.vibe-story__cta:focus-visible .vibe-story__icon,
.vibe-story__link:hover .vibe-story__icon,
.vibe-story__link:focus-visible .vibe-story__icon {
    transform: translate(3px, -3px);
}

@container vstory (min-width: 860px) {
    .vibe-story__intro {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    }

    /* the lede's first line sits level with the title's cap height */
    .vibe-story__lede {
        padding-top: 0.5em;
    }
}

/* ==================================================
   HERO: the walkthrough at its true proportions
   ==================================================
   The page lays it on a full-bleed band tinted with the project accent
   (css/vibe-project.css). The figure is as wide as the media, so the caption
   starts at the media's left edge. */
.vibe-story__hero {
    width: min(100%, calc(var(--vs-hero-max) * var(--vs-r-hero, 1.778)));
    margin: 0 auto;
}

.vibe-story__hero-stage {
    display: block;
}

.vibe-story__hero-media {
    width: 100%;
    background: var(--vs-ph, var(--vs-slate));
}

.vibe-story__hero-img {
    object-fit: cover;
}

.vibe-story__hero-caption {
    margin-top: 14px;
}

/* ==================================================
   PROJECT FACTS
   ================================================== */
.vibe-story__specs {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px var(--vs-col-gap);
    padding: clamp(44px, 5.6cqw, 84px) 0 0;
}

.vibe-story__specs-kicker,
.vibe-story__sub-kicker {
    margin: 0;
    font-family: var(--vs-font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.vibe-story__specs-kicker {
    color: var(--vs-ink-60);
}

.vibe-story__spec-list {
    margin: 0;
    border-top: 1px solid var(--vs-ink);
}

.vibe-story__spec {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px 24px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--vs-hairline);
}

.vibe-story__spec dt {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--vs-font-mono);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--vs-ink-60);
}

.vibe-story__spec .vibe-story__spec-icon {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    color: var(--vs-ink);
}

.vibe-story__spec dd {
    margin: 0;
    min-width: 0;
    font-size: 15px;
    line-height: 1.45;
    color: var(--vs-ink);
}

.vibe-story__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.vibe-story__chip {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 7px 11px 6px;
    border: 1px solid var(--vs-hairline-strong);
    background: var(--vs-paper);
    font-family: var(--vs-font-ui);
    font-size: 13px;
    line-height: 1;
    color: var(--vs-ink);
    white-space: nowrap;
}

@container vstory (min-width: 600px) {
    .vibe-story__spec {
        grid-template-columns: 180px minmax(0, 1fr);
    }
}

@container vstory (min-width: 860px) {
    .vibe-story__specs {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    }

    .vibe-story__specs-kicker {
        padding-top: 15px;
    }
}

/* ==================================================
   STORY
   ================================================== */
.vibe-story__story {
    padding: 0 0 clamp(88px, 11cqw, 160px);
}

.vibe-story__lead {
    margin-top: var(--vs-space-part);
}

/* Full padding shorthand: css/style.css gives every <section> 120px top and
   bottom, which would open a gap under each one. */
.vibe-story__section {
    display: block;
    padding: var(--vs-space-section) 0 0;
}

.vibe-story__story > .vibe-story__section:first-child {
    padding-top: clamp(64px, 8cqw, 120px);
}

.vibe-story__section-rule {
    margin-bottom: clamp(28px, 3.6cqw, 48px);
    background: var(--vs-ink);
}

.vibe-story__group {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--vs-space-part) var(--vs-col-gap);
    align-items: start;
}

.vibe-story__group + .vibe-story__group {
    margin-top: var(--vs-space-group);
}

/* Two prose-only groups in a row (a run of decisions, say) sit closer: the
   full group gap is sized to follow a row of images, not a paragraph. */
.vibe-story__group:not(:has(.vibe-story__stack)) + .vibe-story__group:not(:has(.vibe-story__stack)) {
    margin-top: clamp(44px, 5.4cqw, 76px);
}

.vibe-story__section-head {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.vibe-story__section-index {
    font-family: var(--vs-font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--vs-ink-40);
    font-variant-numeric: tabular-nums;
}

.vibe-story__section-title {
    margin: 0;
    font-family: var(--vs-font-display);
    font-weight: 700;
    font-size: clamp(34px, 4.6cqw, 64px);
    line-height: 1;
    letter-spacing: -0.03em;
    text-transform: none;
    text-wrap: balance;
    color: var(--vs-ink);
}

.vibe-story__section-title:focus {
    outline: none;
}

/* "## Label | Heading": the short label rides beside the number, and the
   heading is a sentence, so it is set a step smaller than a one-word title. */
.vibe-story__section-label {
    margin-left: 12px;
    color: var(--vs-ink-60);
    text-transform: uppercase;
}

.vibe-story__section-title--heading {
    font-size: clamp(30px, 3.5cqw, 48px);
    line-height: 1.04;
    letter-spacing: -0.028em;
}

/* Sub-sections: a short rule, a kicker in the project accent, a title. */
.vibe-story__sub-head {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--vs-hairline-strong);
}

.vibe-story__sub-kicker {
    color: var(--vs-accent);
}

.vibe-story__sub-title {
    margin: 0;
    font-family: var(--vs-font-display);
    font-weight: 700;
    font-size: clamp(22px, 2.5cqw, 32px);
    line-height: 1.08;
    letter-spacing: -0.02em;
    text-transform: none;
    text-wrap: balance;
    color: var(--vs-ink);
}

/* Prose */
.vibe-story__flow {
    min-width: 0;
    max-width: 68ch;
}

.vibe-story__flow > * {
    margin: 0;
}

.vibe-story__flow > * + * {
    margin-top: 18px;
}

.vibe-story__flow > * + .vibe-story__quote,
.vibe-story__flow > * + .vibe-story__callout,
.vibe-story__flow > * + .vibe-story__metrics,
.vibe-story__flow > .vibe-story__quote + *,
.vibe-story__flow > .vibe-story__callout + *,
.vibe-story__flow > .vibe-story__metrics + * {
    margin-top: 32px;
}

.vibe-story__p,
.vibe-story__list {
    font-size: clamp(16px, 1.5cqw, 18px);
    line-height: 1.68;
    color: var(--vs-ink);
    color: color-mix(in srgb, var(--vs-ink) 84%, transparent);
}

.vibe-story__p strong,
.vibe-story__list strong {
    font-weight: 700;
    color: var(--vs-ink);
}

.vibe-story__story a {
    color: var(--vs-ink);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--vs-hairline-strong);
}

.vibe-story__story a:hover {
    text-decoration-color: currentColor;
}

.vibe-story__story code {
    padding: 1px 5px;
    background: var(--vs-slate);
    font-family: var(--vs-font-mono);
    font-size: 0.86em;
    color: var(--vs-ink);
}

.vibe-story__list {
    padding: 0;
    list-style: none;
}

.vibe-story__list li {
    position: relative;
    padding-left: 28px;
}

.vibe-story__list li + li {
    margin-top: 12px;
}

.vibe-story__list li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 0.78em;
    width: 6px;
    height: 6px;
    background: var(--vs-accent);
}

.vibe-story__list--ol {
    counter-reset: vs-step;
}

.vibe-story__list--ol li {
    counter-increment: vs-step;
    padding-left: 38px;
}

.vibe-story__list--ol li::before {
    content: counter(vs-step, decimal-leading-zero);
    top: 0.42em;
    left: 0;
    width: auto;
    height: auto;
    background: none;
    font-family: var(--vs-font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    line-height: 1.4;
    color: var(--vs-accent);
}

.vibe-story__quote {
    margin: 0;
    padding: 4px 0 4px clamp(18px, 2cqw, 28px);
    border-left: 2px solid var(--vs-accent);
}

.vibe-story__quote p {
    margin: 0;
    font-family: var(--vs-font-serif);
    font-style: italic;
    font-size: clamp(21px, 2.3cqw, 28px);
    line-height: 1.35;
    color: var(--vs-ink);
}

.vibe-story__quote p + p {
    margin-top: 12px;
}

.vibe-story__quote cite {
    display: block;
    margin-top: 14px;
    font-family: var(--vs-font-mono);
    font-style: normal;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--vs-ink-60);
}

.vibe-story__callout {
    padding: 20px 24px 22px;
    border-left: 2px solid var(--vs-ink);
    background: var(--vs-slate);
}

.vibe-story__callout-title {
    margin: 0 0 10px;
    font-family: var(--vs-font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--vs-ink);
}

.vibe-story__callout p:not(.vibe-story__callout-title) {
    margin: 0;
    font-size: 15.5px;
    line-height: 1.6;
    color: var(--vs-ink);
}

/* matches the specificity of the margin reset above, so the gap survives */
.vibe-story__callout p:not(.vibe-story__callout-title) + p {
    margin-top: 12px;
}

/* Tables (| pipe | tables | in the story): the facts' language, hairline rules
   and a mono header, no boxes. The first column names each row. */
.vibe-story__flow > * + .vibe-story__table-wrap,
.vibe-story__flow > .vibe-story__table-wrap + * {
    margin-top: 28px;
}

.vibe-story__table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.vibe-story__table-wrap:focus-visible {
    outline: 2px solid var(--vs-accent);
    outline-offset: 4px;
}

.vibe-story__table {
    width: 100%;
    border-collapse: collapse;
    border-top: 1px solid var(--vs-ink);
    font-size: clamp(14px, 1.3cqw, 15.5px);
    line-height: 1.5;
    color: var(--vs-ink);
}

.vibe-story__table th,
.vibe-story__table td {
    padding: 13px 18px 13px 0;
    border-bottom: 1px solid var(--vs-hairline);
    text-align: left;
    vertical-align: top;
}

.vibe-story__table th:last-child,
.vibe-story__table td:last-child {
    padding-right: 0;
}

.vibe-story__table thead th {
    padding-top: 12px;
    padding-bottom: 10px;
    font-family: var(--vs-font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--vs-ink-60);
}

.vibe-story__table tbody th {
    font-weight: 700;
}

.vibe-story__table td {
    color: color-mix(in srgb, var(--vs-ink) 84%, transparent);
}

/* a long id or timestamp in a cell breaks instead of crushing the next column */
.vibe-story__table td code {
    overflow-wrap: anywhere;
}

/* two columns: the first a little narrower (a decision and its reason) */
.vibe-story__table--c2 tbody th {
    width: 44%;
}

/* three columns: a short row name, then the two sides */
.vibe-story__table--c3 tbody th {
    width: 22%;
}

@media (max-width: 599px) {
    .vibe-story__table th,
    .vibe-story__table td {
        padding-right: 12px;
    }

    .vibe-story__table--c2 tbody th {
        width: 42%;
    }
}

.vibe-story__metrics {
    display: grid;
    /* two across in the prose column (four metrics read 2 x 2), so a value
       like "13 days" never breaks onto two lines */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    border-top: 1px solid var(--vs-ink);
}

.vibe-story__metric {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 16px 20px 0;
    border-bottom: 1px solid var(--vs-hairline);
}

.vibe-story__metric-value {
    font-family: var(--vs-font-display);
    font-weight: 700;
    font-size: clamp(32px, 4cqw, 54px);
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--vs-ink);
    font-variant-numeric: tabular-nums;
    /* a long value ("5 to 22 seconds") breaks between words, in balanced
       lines, rather than running into its neighbour in a narrow cell */
    white-space: normal;
    text-wrap: balance;
}

.vibe-story__metric-label {
    font-family: var(--vs-font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--vs-ink-60);
}

@container vstory (min-width: 860px) {
    .vibe-story__group {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    }

    .vibe-story__section-head,
    .vibe-story__sub-head {
        grid-column: 1;
    }

    .vibe-story__flow {
        grid-column: 2;
    }

    /* the first line of prose sits level with the sub-section kicker */
    .vibe-story__sub-head + .vibe-story__flow {
        padding-top: 15px;
    }

    .vibe-story__stack {
        grid-column: 1 / -1;
    }
}

/* Gallery (projects without a long-form story) */
.vibe-story__gallery {
    display: block;
    padding: clamp(64px, 8cqw, 120px) 0 clamp(88px, 11cqw, 160px);
}

.vibe-story__gallery-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 0 0 14px;
}

.vibe-story__gallery-title {
    margin: 0;
    font-family: var(--vs-font-display);
    font-weight: 700;
    font-size: clamp(30px, 4cqw, 52px);
    line-height: 1;
    letter-spacing: -0.03em;
    text-transform: none;
    color: var(--vs-ink);
}

.vibe-story__count {
    font-family: var(--vs-font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--vs-ink-40);
    font-variant-numeric: tabular-nums;
}

.vibe-story__gallery .vibe-story__rule {
    margin-bottom: var(--vs-space-part);
    background: var(--vs-ink);
}

/* ==================================================
   MEDIA: stacks of justified rows
   ==================================================
   A figure's flex-grow is its aspect ratio, so a row shares one height and
   nothing is cropped. Rows are capped in height (--vs-row-max) and centred,
   so a single screen or a tall pair never fills more than most of the
   viewport. */
.vibe-story__stack {
    display: flex;
    flex-direction: column;
    gap: clamp(24px, 3cqw, 40px);
    min-width: 0;
}

.vibe-story__figs {
    display: flex;
    flex-direction: column;
    gap: var(--vs-fig-gap);
    width: 100%;
    margin: 0 auto;
}

.vibe-story__figs > .vibe-story__item {
    min-width: 0;
}

.vibe-story__figs--tall {
    flex-direction: row;
    align-items: flex-start;
}

/* Grow in proportion to each figure's ratio, scaled up so a row whose ratios
   add up to less than 1 (a portrait pair, one tall clip) still fills its
   capped, centred row instead of stopping short of its right edge. */
.vibe-story__figs--tall > .vibe-story__item {
    flex: calc(var(--vs-r, 1) * 100) 1 0;
}

@container vstory (min-width: 720px) {
    .vibe-story__figs {
        flex-direction: row;
        align-items: flex-start;
        max-width: calc(var(--vs-sum, 9) * var(--vs-row-max) + (var(--vs-n, 1) - 1) * var(--vs-fig-gap));
    }

    .vibe-story__figs > .vibe-story__item {
        flex: calc(var(--vs-r, 1.6) * 100) 1 0;
    }
}

.vibe-story__item {
    margin: 0;
    min-width: 0;
}

.vibe-story__media {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    aspect-ratio: var(--vs-ar, 16 / 10);
    border: 1px solid var(--vs-frame);
    /* each frame paints its picture's average colour until the pixels land */
    background: var(--vs-ph, var(--vs-slate));
}

.vibe-story__media img,
.vibe-story__media video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.vibe-story__media > img:not(.vibe-story__media-poster) {
    z-index: 1;
}

/* Poster underlay paints first; the clip shows over it once it plays, so a
   warming-up video never shows a black frame. */
.vibe-story__media-poster {
    z-index: 1;
}

.vibe-story__media video {
    z-index: 2;
    background: transparent;
    opacity: 0;
    transition: opacity 420ms var(--vs-ease);
}

.vibe-story__media video.is-playing {
    opacity: 1;
}

/* Per-clip Play / Pause. Shown on hover or focus on fine pointers, always on
   touch and under reduced motion (where it is the opt-in). */
.vibe-story__media-toggle {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 6;
    margin: 0;
    padding: 7px 10px 6px;
    border: 1px solid var(--vs-ink);
    border-radius: 0;
    background: var(--vs-ink);
    color: var(--vs-paper);
    font-family: var(--vs-font-mono);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 200ms var(--vs-ease),
        background-color 200ms var(--vs-ease),
        color 200ms var(--vs-ease);
}

.vibe-story__media:hover .vibe-story__media-toggle,
.vibe-story__media-toggle:focus-visible,
.vibe-story__media-toggle[aria-pressed="false"] {
    opacity: 1;
}

/* A film (a clip too long to loop) waits for its Play. At rest the button
   sits in the middle of the frame, large, with a play mark and the running
   time, and the whole frame is its target. Once the film runs it steps down
   to the corner as Pause; the corner arrows still open it full screen. */
.vibe-story__item--film .vibe-story__media[data-vs-zoom] {
    cursor: pointer;
}

.vibe-story__item--film .vibe-story__media-toggle {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.vibe-story__item--film .vibe-story__media-toggle[aria-pressed="false"] {
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 18px 24px 17px 22px;
    font-size: 13px;
    letter-spacing: 0.14em;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55), 0 18px 44px rgba(10, 10, 10, 0.24);
}

.vibe-story__item--film .vibe-story__media-toggle[aria-pressed="false"]::before {
    content: "";
    width: 0;
    height: 0;
    margin-right: 13px;
    border-left: 12px solid currentColor;
    border-top: 7.5px solid transparent;
    border-bottom: 7.5px solid transparent;
}

/* the frame answers the pointer anywhere, not only on the button */
.vibe-story__item--film .vibe-story__media:hover .vibe-story__media-toggle[aria-pressed="false"] {
    background: var(--vs-paper);
    color: var(--vs-ink);
}

.vibe-story__media-length {
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid currentColor;
    font-variant-numeric: tabular-nums;
    opacity: 0.72;
}

@container vstory (max-width: 520px) {
    .vibe-story__item--film .vibe-story__media-toggle[aria-pressed="false"] {
        padding: 14px 18px 13px 16px;
        font-size: 12px;
    }
}


.vibe-story__media-toggle:hover,
.vibe-story__media-toggle:focus-visible {
    background: var(--vs-paper);
    color: var(--vs-ink);
}

.vibe-story .vibe-story__media-toggle:focus-visible {
    outline: 2px solid var(--vs-ink);
    outline-offset: 3px;
    border-radius: 0;
}

@media (hover: none) {
    .vibe-story__media-toggle {
        opacity: 1;
    }
}

/* Pictures open full screen (js/vibe-project.js, the viewer): the whole
   frame is the target; the corner button is the keyboard way in. */
.vibe-story__media[data-vs-zoom] {
    cursor: zoom-in;
}

.vibe-story__zoom {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 6;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--vs-ink);
    border-radius: 0;
    background: var(--vs-ink);
    color: var(--vs-paper);
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 200ms var(--vs-ease),
        background-color 200ms var(--vs-ease),
        color 200ms var(--vs-ease);
}

.vibe-story__zoom .vibe-story__icon {
    width: 15px;
    height: 15px;
}

.vibe-story__media:hover .vibe-story__zoom,
.vibe-story__zoom:focus-visible {
    opacity: 1;
}

.vibe-story__zoom:hover,
.vibe-story__zoom:focus-visible {
    background: var(--vs-paper);
    color: var(--vs-ink);
}

.vibe-story .vibe-story__zoom:focus-visible {
    outline: 2px solid var(--vs-ink);
    outline-offset: 3px;
    border-radius: 0;
}

/* touch: tapping the picture opens it, so the corner button only adds noise */
@media (hover: none) {
    .vibe-story__zoom {
        display: none;
    }
}

.vibe-story__caption {
    display: flex;
    align-items: baseline;
    gap: 12px;
    max-width: 76ch;
    margin: 10px 0 0;
    font-family: var(--vs-font-ui);
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--vs-ink-60);
}

.vibe-story__caption-index {
    flex: 0 0 auto;
    font-family: var(--vs-font-mono);
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--vs-ink-40);
    font-variant-numeric: tabular-nums;
}

/* Narrow containers: the walkthrough label sits above its caption instead of
   squeezing it into a thin column; so do the numbers under a row of phone
   screens, where every column is narrow. */
@container vstory (max-width: 599px) {
    .vibe-story__hero-caption,
    .vibe-story__figs--tall .vibe-story__caption {
        flex-direction: column;
        gap: 4px;
    }
}

/* Diagrams (SVG figures) on narrow containers: hold a readable width and
   scroll sideways inside the frame instead of shrinking their labels. */
@container vstory (max-width: 719px) {
    .vibe-story__item--diagram .vibe-story__media {
        aspect-ratio: auto;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    .vibe-story__item--diagram .vibe-story__media img {
        position: static;
        width: 820px;
        height: auto;
        max-width: none;
    }

    .vibe-story__item--diagram .vibe-story__caption::after {
        content: "Swipe to read";
        margin-left: auto;
        font-family: var(--vs-font-mono);
        font-size: 10.5px;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--vs-ink-40);
        white-space: nowrap;
    }
}

/* ==================================================
   REVEALS (only with scripts: html.vs-js)
   ==================================================
   Figures unveil top to bottom as they scroll in (the curtain is on the
   inner wrapper, never on the observed figure), rules draw, headings slide
   up behind their masks. js/vibe-project.js adds .is-in. If it never runs,
   a failsafe shows everything after a few seconds. */
html.vs-js .vibe-story__item-inner {
    clip-path: inset(0 0 100% 0);
}

html.vs-js .vibe-story__item.is-in .vibe-story__item-inner {
    clip-path: inset(0 0 0 0);
    transition: clip-path 900ms var(--vs-ease);
}

html.vs-js .vibe-story__section-rule {
    transform: scaleX(0);
}

html.vs-js .vibe-story__section-rule.is-in {
    transform: scaleX(1);
    transition: transform 900ms var(--vs-ease);
}

html.vs-js .vibe-story__section-head .vibe-story__line,
html.vs-js .vibe-story__sub-head .vibe-story__line {
    transform: translate3d(0, 112%, 0);
}

html.vs-js .vibe-story__section-head.is-in .vibe-story__line,
html.vs-js .vibe-story__sub-head.is-in .vibe-story__line {
    transform: none;
    transition: transform 760ms var(--vs-ease);
}

/* The head holds its first frame until the page script takes over (it adds
   html.vs-ready while starting the entrances, so there is no gap). */
@media (prefers-reduced-motion: no-preference) {
    html.vs-js:not(.vs-ready):not([data-motion="reduced"]) .vibe-story__head [data-vs-enter="line"] {
        transform: translate3d(0, 112%, 0);
    }

    html.vs-js:not(.vs-ready):not([data-motion="reduced"]) .vibe-story__head [data-vs-enter="wipe-left"] {
        clip-path: inset(0 100% 0 0);
    }

    html.vs-js:not(.vs-ready):not([data-motion="reduced"]) .vibe-story__head [data-vs-enter="wipe-right"] {
        clip-path: inset(0 0 0 100%);
    }

    html.vs-js:not(.vs-ready) .vibe-story__head [data-vs-enter] {
        animation: vs-failsafe 1ms 3.2s both;
    }
}

html.vs-js:not(.vs-ready) .vibe-story__item-inner,
html.vs-js:not(.vs-ready) .vibe-story__section-rule,
html.vs-js:not(.vs-ready) .vibe-story__section-head .vibe-story__line,
html.vs-js:not(.vs-ready) .vibe-story__sub-head .vibe-story__line {
    animation: vs-failsafe 1ms 3.2s both;
}

@keyframes vs-failsafe {
    to {
        clip-path: none;
        transform: none;
    }
}

/* ==================================================
   LOADING: the plate develops
   ==================================================
   Anything still on its way is a quiet plate (js/vibe-project.js, the
   plates):
     pending     the frame holds its picture's average colour, and one
                 hairline in the project accent sweeps it slowly
     developing  the file has landed while you watched: the picture prints
                 top to bottom with the hairline riding its edge
     developed   plate gone; a frame that loaded before you scrolled to it
                 skips straight here, so nothing ever animates unseen
   No text, no marks, no fades: just colour, one line and a clip.
   The plate is an opaque layer over the picture and developing clips the
   PLATE away. The picture itself is never clipped, and story pictures do not
   use native lazy loading: the curtain clips each figure to nothing until it
   reveals, and Chrome reads a clipped image as invisible and never fetches
   it. The page fills their sources in about two screens ahead instead, so on
   a normal connection no plate is ever seen.
   ================================================== */
.vibe-story__plate {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: block;
    pointer-events: none;
    background: var(--vs-ph, var(--vs-slate));
    clip-path: inset(0 0 0 0);
}

/* developing: the plate lifts away top to bottom, printing the picture
   underneath in step with the scanner */
.vibe-story__media[data-vs-plate="developing"] .vibe-story__plate {
    clip-path: inset(100% 0 0 0);
    transition: clip-path 820ms var(--vs-ease);
}

/* the play/pause and zoom controls only appear once there is a picture: on
   an unprinted frame they would promise something still on its way */
.vibe-story__media[data-vs-plate="pending"] .vibe-story__media-toggle,
.vibe-story__media[data-vs-plate="developing"] .vibe-story__media-toggle,
.vibe-story__media[data-vs-plate="pending"] .vibe-story__zoom,
.vibe-story__media[data-vs-plate="developing"] .vibe-story__zoom {
    visibility: hidden;
    opacity: 0;
}

/* scanner: a full-frame layer carrying a hairline at its top edge and a
   short light trail behind it; moving the layer by its own height moves the
   line from the top edge to the bottom edge */
.vibe-story__scan {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    visibility: hidden;
}

.vibe-story__scan::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 1px;
    background: var(--vs-accent);
}

.vibe-story__scan::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -36px;
    height: 36px;
    background: linear-gradient(to top, color-mix(in srgb, var(--vs-accent) 18%, transparent), transparent);
}

.vibe-story__item.is-in .vibe-story__media[data-vs-plate="pending"] .vibe-story__scan,
.vibe-story__hero-media[data-vs-plate="pending"] .vibe-story__scan {
    visibility: visible;
    animation: vs-scan 2.4s cubic-bezier(0.65, 0, 0.35, 1) infinite alternate;
}

/* its own keyframes on purpose: reusing vs-scan would only retime the
   running sweep (same name, no restart) and park the line at the bottom
   instead of riding the print edge */
.vibe-story__media[data-vs-plate="developing"] .vibe-story__scan {
    visibility: visible;
    animation: vs-scan-print 820ms var(--vs-ease) 1 both;
}

.vibe-story__media[data-vs-plate="developed"] .vibe-story__plate,
.vibe-story__media[data-vs-plate="developed"] .vibe-story__scan,
.vibe-story__media[data-vs-plate="failed"] .vibe-story__scan {
    visibility: hidden;
}

@keyframes vs-scan {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}

@keyframes vs-scan-print {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}

/* Hero: a hairline meter along the bottom edge showing what is really
   buffered; it steps aside once the walkthrough plays */
.vibe-story__buffer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    height: 2px;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.45);
}

.vibe-story__buffer > span {
    display: block;
    height: 100%;
    background: var(--vs-accent);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 320ms linear;
}

.vibe-story__video.is-playing ~ .vibe-story__buffer {
    visibility: hidden;
    transition: visibility 0s 1.2s;
}

/* ==================================================
   REDUCED MOTION: everything lands in its final state
   ================================================== */
@media (prefers-reduced-motion: reduce) {
    .vibe-story__cta,
    .vibe-story__link,
    .vibe-story__cta .vibe-story__icon,
    .vibe-story__link .vibe-story__icon,
    .vibe-story__media video,
    .vibe-story__media-toggle,
    .vibe-story__zoom {
        transition: none !important;
    }

    html.vs-js .vibe-story__item-inner,
    html.vs-js .vibe-story__section-rule,
    html.vs-js .vibe-story__section-head .vibe-story__line,
    html.vs-js .vibe-story__sub-head .vibe-story__line {
        clip-path: none !important;
        transform: none !important;
        transition: none !important;
    }

    .vibe-story__media-toggle {
        opacity: 1 !important;
    }

    .vibe-story__scan,
    .vibe-story__item.is-in .vibe-story__media[data-vs-plate="pending"] .vibe-story__scan,
    .vibe-story__hero-media[data-vs-plate="pending"] .vibe-story__scan {
        visibility: hidden !important;
        animation: none !important;
    }

    .vibe-story__media[data-vs-plate] .vibe-story__plate {
        transition: none !important;
        animation: none !important;
    }
}

html[data-motion="reduced"] .vibe-story__cta,
html[data-motion="reduced"] .vibe-story__link,
html[data-motion="reduced"] .vibe-story__cta .vibe-story__icon,
html[data-motion="reduced"] .vibe-story__link .vibe-story__icon,
html[data-motion="reduced"] .vibe-story__media video,
html[data-motion="reduced"] .vibe-story__zoom {
    transition: none !important;
}

html[data-motion="reduced"].vs-js .vibe-story__item-inner,
html[data-motion="reduced"].vs-js .vibe-story__section-rule,
html[data-motion="reduced"].vs-js .vibe-story__section-head .vibe-story__line,
html[data-motion="reduced"].vs-js .vibe-story__sub-head .vibe-story__line {
    clip-path: none !important;
    transform: none !important;
    transition: none !important;
}

html[data-motion="reduced"] .vibe-story__media-toggle {
    opacity: 1 !important;
    transition: none !important;
}

html[data-motion="reduced"] .vibe-story__scan {
    visibility: hidden !important;
    animation: none !important;
}

html[data-motion="reduced"] .vibe-story__media[data-vs-plate] .vibe-story__plate {
    transition: none !important;
    animation: none !important;
}

/* ==================================================
   EMBEDS: a page of this site, live in a frame
   ==================================================
   The picture is the plate (and the whole figure without scripts); the
   frame sits over it, hidden until the page inside says it is ready, then
   opens top to bottom like a developing plate. 16 by 10, 4 by 5 on phones,
   where a tall frame leaves room to turn the model. */
.vibe-story__embed-frame {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    visibility: hidden;
}

.vibe-story__embed[data-vs-embed-state="live"] .vibe-story__embed-frame {
    visibility: visible;
    animation: vs-embed-open 820ms var(--vs-ease) both;
}

@keyframes vs-embed-open {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}

html[data-motion="reduced"] .vibe-story__embed[data-vs-embed-state="live"] .vibe-story__embed-frame {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    .vibe-story__embed[data-vs-embed-state="live"] .vibe-story__embed-frame {
        animation: none;
    }
}

html:not(.vs-js) .vibe-story__embed-poster {
    display: none;
}

.vibe-story__embed-fallback {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
}

@media (max-width: 639px) {
    .vibe-story__item--embed .vibe-story__media {
        aspect-ratio: 4 / 5;
    }
}

.vibe-story__item--embed .vibe-story__caption {
    flex-wrap: wrap;
    max-width: none;
}

.vibe-story__item--embed .vibe-story__caption-text {
    flex: 1 1 32ch;
    max-width: 76ch;
}

.vibe-story__caption-link {
    flex: 0 0 auto;
    margin-left: auto;
    white-space: nowrap;
}
