html {
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.boot {
    padding: 2rem;
    color: var(--text-muted);
}

.shell {
    max-width: 1080px;
    margin: 32px auto;
    padding: 24px;
}

/* Page vertical rhythm lives HERE, at the layout level — the stage owns the spacing between
   top-level blocks, so no base component or grid carries an external margin (those leak and
   fight composition). Just two gaps, so the rhythm stays regular everywhere: one between
   blocks, a tighter one when a section-head's content hugs it. Both are tokens, so a page
   (or a single block) can override the rhythm by resetting a variable rather than fighting a
   hard-coded margin — e.g. `style="--flow-gap: 8px"` on the stage, or margin-top on one block. */
.morph-stage {
    --flow-gap: 28px;        /* between sibling blocks / groups */
    --flow-label-gap: 14px;  /* a section-head's own content hugs it */
}

.morph-stage > * + * {
    margin-top: var(--flow-gap);
}

.morph-stage > .section-head + * {
    margin-top: var(--flow-label-gap);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.nav {
    font-size: 14px;
    display: flex;
    gap: 6px;
}

.nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 10px;
}

.nav a.active {
    color: var(--accent);
    background: var(--surface);
    box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

.page-head {
    border-radius: 20px;
    padding: 18px 24px;
}

.page-title {
    font-size: 26px;
    margin: 0 0 4px;
}

.page-sub {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}

.section {
    font-size: 16px;
    margin: 0;
    color: var(--text-muted);
}

.section-head {
    border-radius: 16px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-head .section {
    margin: 0;
}

.section-head .swap {
    margin: 0;
}

.section-head .btn-row {
    margin: 0;
}

/* layout helpers */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.row {
    display: flex;
    gap: 14px;
    align-items: center;
}

.row.dial-row {
    flex-wrap: wrap;
    row-gap: 18px;
}

.col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.spread {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.wide {
    grid-column: 1 / -1;
}

/* MorphLayout demo — the caller owns the track; MorphLayout wraps each item in a host. */
.layout-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    align-items: start;
}

.layout-grid .card {
    margin: 0;
}

/* A starred card grows — a genuine size change so, when a survivor gains/loses the star
   across a reflow, it MOVES + RESIZES at once (the FLIP scale path) and neighbours reflow. */
.layout-grid .card.big {
    min-height: 160px;
    justify-content: center;
}

/* Shared-element hero — the promoted tile sorts to the front and grows; one element makes a
   large move + resize while the others slide one slot over. */
.hero-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    align-items: start;
}

.hero-grid .card {
    margin: 0;
}

.hero-grid .card.hero {
    min-height: 180px;
    justify-content: center;
}

/* shape variants — size + silhouette */
.card {
    border-radius: 24px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.inner {
    border-radius: 18px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.leaf {
    border-radius: 14px;
    padding: 14px;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tile {
    border-radius: 18px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pill {
    border-radius: 999px;
    padding: 12px 22px;
}

.circle {
    border-radius: 50%;
    width: 54px;
    height: 54px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.circle.big {
    width: 72px;
    height: 72px;
    font-size: 20px;
}

.leaf.small {
    padding: 10px;
    font-size: 12px;
}

/* content */
h2 {
    margin: 0;
    font-size: 20px;
}

.lead {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
}

.muted {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.stat-num {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.thumb {
    width: 100%;
    height: 120px;
    border-radius: 14px;
    display: block;
    object-fit: cover;
}

.chip {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface);
    color: var(--accent);
    box-shadow: 3px 3px 7px var(--shadow-dark), -3px -3px 7px var(--shadow-light);
}

/* buttons — content inside panels, plus the test triggers */
.btn-row {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 9px 16px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
}

.btn.primary {
    background: var(--accent);
    color: #fff;
}

.swap {
    margin-bottom: 18px;
    margin-right: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.status {
    padding: 12px 0;
    font-size: 14px;
    color: var(--text-muted);
}

.status.error {
    color: var(--orange);
    font-weight: 600;
}

/* cut-out demo content — sits on the floor's purple gradient, so light text */
.cutout-panel {
    max-width: 360px;
}

.cutout-body {
    padding: 20px;
}

.cutout-head {
    margin-bottom: 14px;
}

.cutout-head strong {
    display: block;
    font-size: 16px;
}

.cutout-head span {
    font-size: 12px;
    opacity: 0.8;
}

.cutout-grid {
    display: flex;
    gap: 12px;
}

.cutout-tile {
    flex: 1;
    background: rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cutout-tile b {
    font-size: 22px;
}

.cutout-tile span {
    font-size: 11px;
    opacity: 0.85;
}

.cutout-thin {
    max-width: 360px;
}

.cutout-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30px 18px;
}

.cutout-wide {
    max-width: 720px;
}

.cutout-wide .cutout-bar {
    padding: 6px 18px;
}

.cutout-bar strong {
    font-size: 14px;
}

.cutout-bar span {
    font-size: 12px;
    opacity: 0.8;
}

/* custom content motion — .morph-custom opts out of the engine's default fade.
   Naming is irrelevant: any one-shot animation inside a morph shell is awaited
   automatically (structural completion check), so the stage holds until the spin
   ends. --shell-hold (read by the engine on exit) keeps the card visible until the
   spin is done, then the card fades — one var drives both the spin and the hold. */
@keyframes spin-in {
    from { opacity: 0; transform: rotateZ(-360deg); }
    to { opacity: 1; transform: rotateZ(0); }
}

@keyframes spin-out {
    from { opacity: 1; transform: rotateZ(0); }
    to { opacity: 0; transform: rotateZ(360deg); }
}

.spin-card {
    --shell-hold: 1.1s;
}

.title-spin {
    display: inline-block;
    transform-origin: center;
}

.morph-stage[data-phase="enter"] .title-spin {
    animation: spin-in var(--shell-hold) var(--enter-ease) both;
}

.morph-stage[data-phase="exit"] .title-spin {
    animation: spin-out var(--shell-hold) var(--exit-ease) both;
}

#blazor-error-ui {
    display: none;
}

/* MorphSequence storyboard demo (/sequence) */
.seq-stage {
    max-width: 640px;
}

/* The items render under .morph-screen (the sequence cascades a timeline, adds no DOM node). */
.seq-stage .morph-screen {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.seq-bg {
    min-height: 80px;
}

.seq-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.swap.on {
    outline: 3px solid var(--orange);
    outline-offset: 2px;
}
