/* ===========================================================================
   Landing page (templates/main/hub.html)

   A hero (headline, prompt box, live product demo), the model marquee, a
   pricing strip and a bento grid of the four services, each with a small
   looping illustration. The demo is
   driven by static/js/motion.js (module "demo"); everything else is CSS.
   All loops are transform/opacity only and stop with reduced motion.
   =========================================================================== */

/* ── Hero typeface: Vazirmatn without the swap ────────────────────────
   Everything above the fold — headline, lede, buttons and the demo window —
   sits in .hero, so when the hero text re-wraps the demo window moves. With
   font-display: swap it re-wrapped on every cold load: each machine's own
   fallback face (unknowable: PageSpeed's lab, every phone) is narrower than
   Vazirmatn, so the headline and lede gained a line when the font arrived
   and PageSpeed measured CLS 0.11–0.16 on .demo-window.

   Same files as fonts.css (the hashed URLs and the preloads are shared), but
   `optional`: Vazirmatn is used when it is ready at first paint (cached, or
   a fast connection), otherwise the hero keeps the fallback for that view
   and never moves. Only the hero opts in; the rest of the page still swaps.
   Must stay in a render-blocking sheet so it is known at first paint. */
@font-face {
    font-family: 'Vazirmatn Hero';
    font-display: optional;
    font-weight: 400;
    src: url("../fonts/vazirmatn-arabic-400-normal.49c0cc018008.woff2") format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'Vazirmatn Hero';
    font-display: optional;
    font-weight: 500;
    src: url("../fonts/vazirmatn-arabic-500-normal.b58020ccff5c.woff2") format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'Vazirmatn Hero';
    font-display: optional;
    font-weight: 600;
    src: url("../fonts/vazirmatn-arabic-600-normal.6da23f69b4f7.woff2") format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'Vazirmatn Hero';
    font-display: optional;
    font-weight: 700;
    src: url("../fonts/vazirmatn-arabic-700-normal.51265c214faf.woff2") format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'Vazirmatn Hero';
    font-display: optional;
    font-weight: 800;
    src: url("../fonts/vazirmatn-arabic-800-normal.a21cf35d2db3.woff2") format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'Vazirmatn Hero';
    font-display: optional;
    font-weight: 400;
    src: url("../fonts/vazirmatn-latin-400-normal.274c04027519.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.hero.hero-hub { font-family: 'Vazirmatn Hero', 'Vazirmatn Fallback', ui-sans-serif, system-ui, sans-serif; }

/* ── Hero: headline + prompt box beside the product demo ──────────────────
   Plain on purpose: no aurora, no dot grid, no gradient word. The page
   accent appears only on the things you can press. */
.hero.hero-hub {
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    padding-top: clamp(40px, 9vh, 96px);
    padding-bottom: clamp(32px, 6vh, 72px);
}
.hero-hub::before, .hero-hub::after { content: none; }
@media (min-width: 1024px) {
    .hero.hero-hub { grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr); column-gap: clamp(40px, 5vw, 72px); }
}
.hero-hub .hero-main { max-width: 620px; }
.hero-hub h1 {
    margin: 0;
    font-size: clamp(34px, 4vw, 56px);
    line-height: 1.3;
    letter-spacing: -.015em;
}
.hero-hub h1 .line { display: block; }
/* The three names stay on one line; the size is set so they fit. */
.hero-hub h1 .line:first-child { white-space: nowrap; }
.hero-hub h1 .line + .line::before { content: none; }
.hero-hub h1 .quiet { color: var(--color-text-muted); font-weight: 700; font-size: .72em; margin-top: .25em; }
/* Vazirmatn ships Latin in 400 only: a synthetic 800 smears the model names. */
.hero-hub h1 bdi { font-family: ui-sans-serif, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; letter-spacing: -.03em; }
.hero-hub .sub { margin-top: 18px; max-width: 46ch; }

/* Prompt box */
.ask {
    margin-top: 28px;
    padding: 8px;
    border-radius: 18px;
    border: 1px solid var(--border-strong);
    background: var(--color-surface);
    box-shadow: 0 1px 0 rgb(255 255 255 / .03) inset, 0 18px 40px -28px rgb(0 0 0 / .6);
    transition: border-color .2s ease, box-shadow .2s ease;
}
.ask:focus-within { border-color: rgb(var(--primary-rgb) / .55); box-shadow: 0 0 0 4px rgb(var(--primary-rgb) / .12); }
.ask-modes { display: flex; gap: 4px; padding: 2px 2px 6px; overflow-x: auto; scrollbar-width: none; }
.ask-modes label { position: relative; flex: 0 0 auto; cursor: pointer; }
.ask-modes input { position: absolute; opacity: 0; pointer-events: none; }
.ask-modes span {
    display: block;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: background-color .15s ease, color .15s ease;
}
.ask-modes label:hover span { color: var(--color-text-main); }
.ask-modes input:checked + span { background: var(--color-hover-strong); color: var(--color-text-main); }
.ask-modes input:focus-visible + span { outline: 2px solid rgb(var(--primary-rgb)); outline-offset: 1px; }
.ask-field { display: flex; align-items: flex-end; gap: 8px; }
.ask-field textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 56px;
    max-height: 160px;
    padding: 8px 10px;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: var(--color-text-main);
    font: inherit;
    font-size: 16px;   /* below 16px iOS zooms the page on focus */
    line-height: 1.75;
}
.ask-field textarea::placeholder { color: var(--color-text-muted); opacity: .8; }
.ask-go {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    height: 46px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: rgb(var(--primary-rgb));
    color: var(--color-text-on-primary);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease;
}
.ask-go:hover { filter: brightness(1.06); }
.ask-go:active { transform: scale(.98); }
.ask-go svg { width: 16px; height: 16px; }
[dir="rtl"] .ask-go svg { transform: scaleX(-1); }

.hero-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin: 16px 2px 0;
    font-size: 13.5px;
    color: var(--color-text-muted);
}
/* Every item carries its own dot, so a wrapped row never starts with one. */
.hero-facts > * { display: inline-flex; align-items: center; gap: 8px; }
.hero-facts > *::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--color-text-muted); opacity: .6; }
.hero-facts a { color: var(--color-text-main); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 5px; }
.hero-facts a:hover { text-decoration-color: currentColor; }

@media (max-width: 560px) {
    .hero-hub h1 { font-size: clamp(26px, 8.4vw, 40px); }
    .ask-field { flex-direction: column; align-items: stretch; }
    .ask-go { justify-content: center; }
}

/* ── Product demo: one agent chat, drawn like the real one ────────────── */
.demo { position: relative; width: 100%; max-width: 560px; justify-self: center; }
.demo-window {
    position: relative;
    display: grid;
    grid-template-rows: auto 1fr;
    border-radius: 18px;
    border: 1px solid var(--border-strong);
    background: var(--color-surface);
    box-shadow: 0 1px 0 rgb(255 255 255 / .04) inset, 0 30px 60px -36px rgb(0 0 0 / .65);
    overflow: hidden;
    text-align: start;
}
.demo-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.demo-agent { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; }
.demo-agent small { display: block; font-size: 11.5px; font-weight: 400; color: var(--color-text-muted); }
.demo-av {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgb(var(--primary-rgb) / .14);
    color: rgb(var(--primary-ink-rgb));
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
}
.demo-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.demo-model {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border-radius: 99px;
    border: 1px solid var(--border-subtle);
    font-size: 12px;
    color: var(--color-text-muted);
    direction: ltr;
}
.demo-model img { width: 16px; height: 16px; border-radius: 4px; }

.demo-chat { display: flex; flex-direction: column; gap: 14px; padding: 20px 18px 14px; min-height: 420px; min-width: 0; }
.demo-msg.user {
    align-self: flex-end;
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    border-end-end-radius: 6px;
    background: var(--color-hover-strong);
    font-size: 14px;
    line-height: 1.85;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .35s var(--ease), transform .45s var(--ease);
}
.demo-msg.user.is-in { opacity: 1; transform: none; }

.demo-think {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--color-text-muted);
    /* Always 20px tall: growing it in would push the steps down (CLS). */
    height: 20px;
    margin-bottom: -6px;
    opacity: 0;
    overflow: hidden;
    transition: opacity .25s ease;
}
.demo-think.is-in { opacity: 1; }
.demo-think i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: demo-wave 1s ease-in-out infinite;
}
.demo-think i:nth-child(2) { animation-delay: .15s; }
.demo-think i:nth-child(3) { animation-delay: .3s; margin-inline-end: 4px; }
@keyframes demo-wave { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-3px); opacity: 1; } }

/* Tool calls: a quiet checklist, not a stack of cards. */
.demo-steps { display: grid; gap: 2px; margin: 0; padding: 0 2px; list-style: none; }
.demo-steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--color-text-muted);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .3s var(--ease), transform .4s var(--ease), color .3s ease;
}
.demo-steps li.is-in { opacity: 1; transform: none; }
.demo-steps li.is-done { color: var(--color-text-main); }
.demo-steps li code {
    font-family: 'Roboto Mono', ui-monospace, monospace;
    font-size: 12px;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--color-hover-strong);
    direction: ltr;
    unicode-bidi: isolate;
}
.demo-steps .st { width: 16px; height: 16px; flex: 0 0 auto; position: relative; }
.demo-steps .st::before {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: 50%;
    border: 2px solid rgb(var(--color-text-main-rgb) / .15);
    border-top-color: rgb(var(--color-text-main-rgb) / .6);
    animation: shell-spin .8s linear infinite;
}
.demo-steps li.is-done .st::before {
    border: 0;
    animation: none;
    background: #34D399;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px no-repeat;
}

.demo-reply {
    min-height: 3.6em;
    margin: 0;
    font-size: 14.5px;
    line-height: 1.95;
    color: var(--color-text-main);
    opacity: 0;
    transition: opacity .3s ease;
}
.demo-reply.is-in { opacity: 1; }
/* The whole answer is laid out from the start: streamed words move from
   .unsaid (invisible but occupying its lines) to .said, so the paragraph
   never re-wraps or grows while it "types". */
.demo-reply .unsaid { visibility: hidden; }
.demo-reply.is-in:not(.is-done) .said::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1.05em;
    /* Net advance of zero, or the caret itself would re-wrap the line. */
    margin-inline: 3px -5px;
    vertical-align: -.15em;
    background: currentColor;
    animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* The produced file: a small card with the chart itself. */
.demo-file {
    display: flex;
    align-items: center;
    gap: 12px;
    align-self: flex-start;
    padding: 8px;
    padding-inline-end: 16px;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    font-size: 12.5px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .35s var(--ease), transform .45s var(--ease);
}
[data-demo].is-done .demo-file { opacity: 1; transform: none; }
.demo-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    width: 92px;
    height: 56px;
    padding: 8px 10px;
    border-radius: 9px;
    background: var(--color-hover-strong);
    direction: ltr;
}
.demo-chart i { flex: 1 1 0; height: var(--h); border-radius: 2px 2px 0 0; background: rgb(var(--primary-rgb) / .45); }
.demo-chart i:last-child { background: rgb(var(--primary-rgb)); }
.demo-file-meta b { display: block; font-family: 'Roboto Mono', monospace; font-size: 12px; font-weight: 500; direction: ltr; text-align: start; }
.demo-file-meta small { color: var(--color-text-muted); font-size: 11.5px; }

.demo-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-inline: 14px 6px;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    background: var(--field-bg);
    min-height: 46px;
}
.demo-input [data-demo-input] { font-size: 14px; color: var(--color-text-main); white-space: nowrap; overflow: hidden; }
.demo-input [data-demo-input]:empty::before { content: attr(data-placeholder); color: var(--color-text-muted); }
.demo-input .caret {
    width: 2px;
    height: 18px;
    margin-inline-start: -6px;
    background: rgb(var(--color-text-main-rgb) / .7);
    animation: caret 1s steps(2) infinite;
}
.demo-input .send {
    margin-inline-start: auto;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--color-hover-strong);
    color: var(--color-text-muted);
    transition: transform .2s var(--ease), background-color .2s ease, color .2s ease;
}
.demo-input:has([data-demo-input]:not(:empty)) .send { background: rgb(var(--primary-rgb)); color: var(--color-text-on-primary); }
.demo-input .send svg { width: 16px; height: 16px; }
.demo-input:has(.is-sent) .send { transform: scale(.88); }

@media (max-width: 560px) {
    .demo-chat { min-height: 400px; padding: 16px 14px 12px; }
    .demo-steps li { font-size: 12.5px; }
}

:root[data-theme="light"] .ask { box-shadow: 0 18px 40px -30px rgb(14 17 22 / .35); }
:root[data-theme="light"] .demo-window { box-shadow: 0 30px 60px -36px rgb(14 17 22 / .3); }

/* ── Pricing strip: three credit plans, buy straight from here ────────── */
.price-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.price-card {
    display: flex;
    flex-direction: column;
    padding: 22px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--hair);
    background: var(--color-surface);
}
.price-card.is-pick { border-color: rgb(var(--primary-rgb) / .55); box-shadow: 0 0 0 1px rgb(var(--primary-rgb) / .25); }
.pc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pc-head h3 { font-size: 16px; font-weight: 700; }
.pc-tag {
    padding: 2px 10px;
    border-radius: 99px;
    background: rgb(var(--primary-rgb) / .14);
    color: rgb(var(--primary-ink-rgb));
    font-size: 12px;
    font-weight: 600;
}
.pc-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pc-price b { font-size: clamp(26px, 2.6vw, 32px); font-weight: 800; letter-spacing: -.02em; }
.pc-price s { color: var(--color-text-muted); font-size: 14px; }
.pc-price span { color: var(--color-text-muted); font-size: 13px; }
.pc-credits { margin-top: 4px; color: var(--color-text-muted); font-size: 13.5px; }
.pc-allow-h { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-subtle); color: var(--color-text-muted); font-size: 13px; }
.pc-allow-h b { color: var(--color-text-main); }
.pc-allow { display: grid; gap: 6px; margin: 10px 0 22px; padding: 0; list-style: none; font-size: 14px; }
.pc-allow li { display: flex; gap: 6px; align-items: baseline; }
.pc-allow li::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: rgb(var(--primary-rgb)); flex: 0 0 auto; transform: translateY(-2px); }
.pc-buy { margin-top: auto; width: 100%; justify-content: center; }
.price-more { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 18px; font-size: 13.5px; color: var(--color-text-muted); }
.price-more a { color: var(--color-text-main); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 5px; }
.price-more a:hover { text-decoration-color: currentColor; }
@media (max-width: 860px) {
    .price-grid { grid-template-columns: minmax(0, 1fr); }
    /* The recommended plan first on a phone. */
    .price-card.is-pick { order: -1; }
}

/* ── Model marquee ────────────────────────────────────────────────────── */
.models {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(20px, 4vh, 40px) clamp(18px, 5vw, 56px) clamp(36px, 7vh, 72px);
    text-align: center;
}
.models-t { font-size: 13.5px; color: var(--color-text-muted); margin-bottom: 18px; }
.marquee {
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
            mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
}
.marquee-track {
    display: flex;
    gap: 10px;
    width: max-content;
    animation: marquee 48s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(50%); } }
[dir="ltr"] .marquee-track { animation-name: marquee-ltr; }
@keyframes marquee-ltr { to { transform: translateX(-50%); } }
.model-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 7px 14px 7px 8px;
    padding-inline: 8px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: var(--color-surface);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--color-text-main);
    white-space: nowrap;
    direction: ltr;
}
.model-chip img {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    object-fit: contain;
    background: #fff;
    padding: 2px;
}
.model-chip small { color: var(--color-text-muted); font-weight: 400; font-size: 11.5px; }

/* ── Bento services grid ──────────────────────────────────────────────── */
.bento {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.bento-card {
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 8px;
    min-height: 300px;
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    background: var(--color-surface);
    overflow: hidden;
    color: var(--color-text-main);
}
.bento-card.wide { grid-column: span 2; }
.bento-card img.lockup { height: 22px; width: auto; justify-self: start; margin-bottom: 6px; }
.bento-card h3 { font-size: 18px; font-weight: 700; line-height: 1.5; }
.bento-card p { font-size: 14px; line-height: 1.85; color: var(--color-text-muted); max-width: 46ch; }
.bento-card .go-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: rgb(var(--primary-ink-rgb));
}
.bento-card .go-link svg { width: 14px; height: 14px; transition: transform .25s var(--ease); }
[dir="rtl"] .bento-card .go-link svg { transform: scaleX(-1); }
.bento-card:hover .go-link svg { transform: translateX(3px); }
[dir="rtl"] .bento-card:hover .go-link svg { transform: scaleX(-1) translateX(3px); }
.bento-vis { position: relative; align-self: end; margin-top: 14px; min-height: 120px; }
.bento-card.b-agents  { --primary-rgb: 34 211 238;  --primary-ink-rgb: 34 211 238; }
.bento-card.b-imagine { --primary-rgb: 214 120 255; --primary-ink-rgb: 214 120 255; }
.bento-card.b-storage { --primary-rgb: 250 204 21;  --primary-ink-rgb: 250 204 21; }
.bento-card.b-edits   { --primary-rgb: 255 138 76;  --primary-ink-rgb: 255 138 76; }
:root[data-theme="light"] .bento-card.b-agents  { --primary-rgb: 8 112 140;  --primary-ink-rgb: 8 112 140; }
:root[data-theme="light"] .bento-card.b-imagine { --primary-rgb: 134 46 190; --primary-ink-rgb: 134 46 190; }
:root[data-theme="light"] .bento-card.b-storage { --primary-rgb: 202 138 4;  --primary-ink-rgb: 133 90 0; }
:root[data-theme="light"] .bento-card.b-edits   { --primary-rgb: 194 65 12;  --primary-ink-rgb: 194 65 12; }
/* Each card glows faintly in its own colour from one corner. */
.bento-card::before {
    content: '';
    position: absolute;
    inset: auto -20% -40% auto;
    width: 70%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgb(var(--primary-rgb) / .12), transparent);
    pointer-events: none;
    transition: transform .6s var(--ease), opacity .4s ease;
}
[dir="rtl"] .bento-card::before { inset: auto auto -40% -20%; }
.bento-card:hover::before { transform: scale(1.25); }

/* Agents: a terminal that runs a task. */
.term {
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: var(--color-bg-dark);
    padding: 12px 14px;
    font-family: 'Roboto Mono', ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.9;
    direction: ltr;
    text-align: left;
    color: var(--color-text-muted);
}
.term p { margin: 0; white-space: nowrap; overflow: hidden; opacity: 0; animation: term-line 7s steps(1) infinite; }
.term p:nth-child(1) { animation-delay: 0s; }
.term p:nth-child(2) { animation-delay: .9s; }
.term p:nth-child(3) { animation-delay: 1.8s; }
.term p:nth-child(4) { animation-delay: 2.7s; }
.term b { color: rgb(var(--primary-ink-rgb)); font-weight: 500; }
.term .ok { color: #34D399; }
@keyframes term-line { 0% { opacity: 0; } 2%, 88% { opacity: 1; } 100% { opacity: 0; } }
.term .cursor { display: inline-block; width: 7px; height: 13px; vertical-align: -2px; background: rgb(var(--primary-rgb)); animation: caret 1s steps(2) infinite; }

/* Imagine: tiles render from noise into artwork. */
.tiles-gen { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tiles-gen i {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-hover-strong);
}
.tiles-gen i::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    animation: art-in 6s var(--ease) infinite;
}
.tiles-gen i:nth-child(1)::before { background: radial-gradient(circle at 30% 30%, #FDE68A, transparent 45%), linear-gradient(160deg, #F472B6, #7C3AED 70%); }
.tiles-gen i:nth-child(2)::before { background: radial-gradient(circle at 70% 25%, #FFF, transparent 25%), linear-gradient(200deg, #22D3EE, #1E3A8A 75%); animation-delay: .5s; }
.tiles-gen i:nth-child(3)::before { background: radial-gradient(ellipse at 50% 110%, #F97316, transparent 60%), linear-gradient(180deg, #312E81, #DB2777); animation-delay: 1s; }
.tiles-gen i::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / .12) 50%, transparent 70%);
    animation: tile-scan 1.2s linear infinite;
}
@keyframes art-in { 0%, 25% { opacity: 0; filter: blur(14px); transform: scale(1.1); } 40%, 88% { opacity: 1; filter: blur(0); transform: none; } 100% { opacity: 0; } }
@keyframes tile-scan { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.gen-prompt {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--color-bg-dark);
    font-size: 12px;
    color: var(--color-text-muted);
}
.gen-prompt b { margin-inline-start: auto; font-size: 11px; color: rgb(var(--primary-ink-rgb)); font-weight: 600; }

/* Storage: files uploading. */
.files-up { display: grid; gap: 8px; }
.files-up div {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 6px 10px;
    padding: 9px 12px;
    border-radius: 11px;
    border: 1px solid var(--border-subtle);
    background: var(--color-bg-dark);
    font-size: 12px;
}
.files-up .fic { width: 22px; height: 22px; border-radius: 6px; background: rgb(var(--primary-rgb) / .18); grid-row: span 2; }
.files-up b { font-family: 'Roboto Mono', monospace; font-weight: 500; font-size: 11.5px; direction: ltr; text-align: start; }
.files-up small { color: var(--color-text-muted); font-size: 11px; }
.files-up .bar { grid-column: 2 / 4; margin: 0; height: 3px; }
.files-up .bar i { width: 100%; transform-origin: right; transform: scaleX(0); animation: up-fill 5s var(--ease) infinite; }
[dir="ltr"] .files-up .bar i { transform-origin: left; }
.files-up div:nth-child(2) .bar i { animation-delay: .6s; }
.files-up div:nth-child(3) .bar i { animation-delay: 1.2s; }
@keyframes up-fill { 0% { transform: scaleX(0); } 55%, 90% { transform: scaleX(1); } 100% { transform: scaleX(1); opacity: 0; } }

/* Edits: a timeline with a moving playhead. */
.timeline { position: relative; display: grid; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--color-bg-dark); direction: ltr; }
.timeline .track { display: flex; gap: 6px; height: 22px; }
.timeline .clip { border-radius: 6px; background: rgb(var(--primary-rgb) / .55); }
.timeline .clip.alt { background: rgb(var(--color-text-main-rgb) / .14); }
.timeline .clip.soft { background: rgb(var(--primary-rgb) / .28); }
.timeline .wave {
    height: 22px;
    background:
        repeating-linear-gradient(90deg, rgb(var(--primary-rgb) / .6) 0 2px, transparent 2px 5px);
    -webkit-mask: radial-gradient(ellipse 50% 60% at 30% 50%, #000 40%, transparent 70%), radial-gradient(ellipse 40% 50% at 75% 50%, #000 40%, transparent 70%);
            mask: radial-gradient(ellipse 50% 60% at 30% 50%, #000 40%, transparent 70%), radial-gradient(ellipse 40% 50% at 75% 50%, #000 40%, transparent 70%);
    border-radius: 6px;
}
.timeline .head {
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 12px;
    width: 2px;
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 0 0 1px rgb(0 0 0 / .2);
    animation: playhead 6s linear infinite;
}
.timeline .head::before { content: ''; position: absolute; top: -5px; left: -4px; width: 10px; height: 8px; border-radius: 3px; background: #fff; }
@keyframes playhead { from { left: 12px; } to { left: calc(100% - 14px); } }
:root[data-theme="light"] .timeline .head,
:root[data-theme="light"] .timeline .head::before { background: #0E1116; }

@media (max-width: 900px) {
    .bento { grid-template-columns: 1fr; }
    .bento-card.wide { grid-column: auto; }
}
:root[data-theme="light"] .bento-card { box-shadow: var(--shadow-xs); }
:root[data-theme="light"] :is(.term, .gen-prompt, .files-up div, .timeline) { background: #F7F8FA; }

/* Loops only run once the grid is on screen. */
.bento:not(.is-in) :is(.term p, .files-up .bar i, .timeline .head) { animation-play-state: paused; }
.bento:not(.is-in) .tiles-gen i::before { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
    .marquee-track { animation: none; flex-wrap: wrap; justify-content: center; width: auto; }
    .marquee { -webkit-mask-image: none; mask-image: none; }
    .term p { animation: none; opacity: 1; }
    .tiles-gen i::before { animation: none; opacity: 1; }
    .tiles-gen i::after, .timeline .head, .files-up .bar i { animation: none; }
    .files-up .bar i { transform: scaleX(.8); }
}
