/* Signal bits: styles for static/ds/bits.js (React Bits ports). */

.rb-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ClickSpark */
.rb-spark-canvas {
    position: fixed; inset: 0; width: 100vw; height: 100vh;
    pointer-events: none; z-index: 9998;
}

/* Counter: each place is one digit tall and clips its column. */
.rb-roll { display: inline-flex; vertical-align: baseline; }
.rb-roll-reel { display: inline-flex; }
.rb-roll-place {
    display: inline-block; height: 1em; line-height: 1; overflow: hidden;
    font-variant-numeric: tabular-nums;
    /* Soft top and bottom edges so digits read as passing a window. */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
            mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
}
.rb-roll-col {
    display: flex; flex-direction: column;
    transition-property: transform;
    transition-timing-function: cubic-bezier(.16, 1, .3, 1);
    will-change: transform;
}
.rb-roll-col > span { display: block; height: 1em; line-height: 1; text-align: center; }

/* Stack: the flashcard deck */
/* The bottom margin keeps the fanned sheets clear of the controls below. */
.rb-deck { isolation: isolate; margin-bottom: 18px; }
.rb-deck > .fc-card { z-index: 1; }
/* Horizontal drags belong to the card. The faces scroll long answers, and a
   scroll container resets touch-action, so every descendant needs it too. */
.rb-deck > .fc-card,
.rb-deck > .fc-card * { touch-action: pan-y; }
.rb-deck-sheet {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    border-radius: var(--workspace-radius-card, 20px);
    border: 1px solid var(--workspace-line, rgba(91, 80, 232, .16));
    background: var(--workspace-surface, var(--card-bg, #fff));
    box-shadow: 0 6px 18px rgba(17, 24, 39, .05);
    transform-origin: 50% 100%;
    transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), opacity .3s ease;
}
.rb-deck-sheet:nth-of-type(1) { transform: translateY(8px) rotate(-1.2deg) scale(.975); }
.rb-deck-sheet:nth-of-type(2) { transform: translateY(16px) rotate(1deg) scale(.95); opacity: .7; }
.rb-deck[data-behind="1"] .rb-deck-sheet:nth-of-type(2),
.rb-deck[data-behind="0"] .rb-deck-sheet { opacity: 0; transform: none; }

.rb-deck.rb-dragging > .fc-card { cursor: grabbing; -webkit-user-select: none; user-select: none; }
.rb-deck.rb-dragging > .fc-corner,
.rb-deck > .fc-card.rb-flinging ~ .fc-corner { opacity: 0; transition: opacity .15s; }
.rb-deck .fc-card.rb-snap { transition: none !important; }

/* The card leans toward the button it is about to press. The lean is set on
   the study area so the card face and both buttons can read it. */
#fcStudyArea[data-lean] .fc-card .fc-face { box-shadow: 0 0 0 calc(var(--rb-lean, 0) * 3px) var(--rb-lean-colour); }
#fcStudyArea[data-lean="right"] { --rb-lean-colour: var(--ds-mint, #0f9f6e); }
#fcStudyArea[data-lean="left"] { --rb-lean-colour: var(--ds-amber, #c27803); }
#fcStudyArea[data-lean="right"] .fc-btn-know,
#fcStudyArea[data-lean="left"] .fc-btn-again {
    transform: scale(calc(1 + var(--rb-lean, 0) * .06));
    box-shadow: 0 0 0 calc(var(--rb-lean, 0) * 3px) color-mix(in srgb, var(--rb-lean-colour) 45%, transparent);
}

@keyframes rb-deal {
    from { transform: translateY(8px) rotate(-1.2deg) scale(.975); }
    to { transform: none; }
}
.rb-deck .fc-card.rb-enter { animation: rb-deal .4s cubic-bezier(.34, 1.56, .64, 1); }

@media (prefers-reduced-motion: reduce) {
    .rb-roll-col, .rb-deck-sheet { transition: none; }
    .rb-deck .fc-card.rb-enter { animation: none; }
}

/* SplitFlapText: the exam countdown's day count */
.review-due-icon.is-flap {
    width: auto; min-width: 38px; padding: 0; background: none; box-shadow: none;
}
.review-due-icon.is-flap > svg,
.review-due-icon:not(.is-flap) > .rb-flap { display: none; }
.rb-flap {
    display: inline-flex; gap: 2px;
    font: 700 1.05rem/1 var(--ds-font-mono, ui-monospace, Menlo, monospace);
    font-variant-numeric: tabular-nums;
}
.rb-flap-tile {
    position: relative; display: block;
    width: 1.15em; height: 1.6em;
    border-radius: 5px;
    background: #222226; color: #f4f5fa;
    perspective: 160px;
}
[data-dark] .rb-flap-tile { background: #222226; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
/* The split between the two halves of a real flap. */
.rb-flap-tile::after {
    content: ''; position: absolute; left: 0; right: 0; top: 50%; z-index: 3;
    height: 1px; background: rgba(0, 0, 0, .55);
}
.rb-flap-half {
    position: absolute; left: 0; right: 0; height: 50%; overflow: hidden;
    background: inherit;
}
.rb-flap-top { top: 0; border-radius: 5px 5px 0 0; }
.rb-flap-bottom { bottom: 0; border-radius: 0 0 5px 5px; }
.rb-flap-half > span {
    position: absolute; left: 0; right: 0; height: 200%;
    display: flex; align-items: center; justify-content: center;
}
.rb-flap-top > span { top: 0; }
.rb-flap-bottom > span { bottom: 0; }
.rb-flap-leaf { z-index: 2; }
.rb-flap-fall { transform-origin: 50% 100%; animation: rb-flap-fall var(--rb-flap-ms, 110ms) ease-in both; }
.rb-flap-rise { transform-origin: 50% 0; animation: rb-flap-rise var(--rb-flap-ms, 110ms) ease-out both; }
@keyframes rb-flap-fall {
    from { transform: rotateX(0); filter: brightness(1); }
    50%, to { transform: rotateX(-90deg); filter: brightness(.55); }
}
@keyframes rb-flap-rise {
    from, 50% { transform: rotateX(90deg); filter: brightness(.6); }
    to { transform: rotateX(0); filter: brightness(1); }
}

/* HoldButton: a timed paper's "hand in" */
.rb-hold {
    position: relative; overflow: hidden; isolation: isolate;
    touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.rb-hold-fill {
    position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: rgba(255, 255, 255, .24);
    transform: scaleX(0); transform-origin: left center;
    transition: transform .2s ease-out;
}
.rb-hold.is-holding .rb-hold-fill { transform: scaleX(1); transition: transform var(--rb-hold-ms, 900ms) linear; }
.rb-hold.is-held .rb-hold-fill { transform: scaleX(1); }
.rb-hold-hint {
    display: block; margin-top: 6px;
    font-size: .75rem; line-height: 1.4;
    color: var(--ds-ink-3, #6b7280);
}
.rb-hold-hint.is-shown { color: var(--ds-amber, #c27803); font-weight: 600; }
.rb-hold:disabled + .rb-hold-hint { display: none; }

@media (prefers-reduced-motion: reduce) {
    .rb-flap-leaf { animation: none; display: none; }
}

/* ── Generating screens ─────────────────────────────────────────────── */

/* ShinyText: a band of violet light crosses the headline while Avi works.
   text-fill-color, not color, because the loaders set color inline. */
.rb-shiny {
    background-image: linear-gradient(110deg,
        var(--ds-ink, #0e1220) 0%, var(--ds-ink, #0e1220) 38%,
        var(--ds-violet-400, #b6a6ff) 50%,
        var(--ds-ink, #0e1220) 62%, var(--ds-ink, #0e1220) 100%);
    background-size: 250% 100%;
    background-position: 100% 0;
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rb-shiny 2.6s linear infinite;
}
@keyframes rb-shiny { to { background-position: -150% 0; } }

/* LatticeLoader */
.rb-lattice {
    display: inline-grid;
    grid-template-columns: repeat(var(--n, 3), 10px);
    gap: 5px;
    margin: 4px auto 18px;
    color: var(--ds-accent, #5b50e8);
}
[data-dark] .rb-lattice { color: #b6a6ff; }
.rb-lattice i {
    width: 10px; height: 10px; border-radius: 50%;
    background: currentColor; opacity: .14;
    animation: rb-lattice var(--cycle, 960ms) cubic-bezier(.77, 0, .175, 1) infinite;
}
.rb-lattice i.is-hole { animation: none; opacity: .06; }
@keyframes rb-lattice {
    0% { opacity: .14; transform: scale(.78); }
    9% { opacity: 1; transform: scale(1); box-shadow: 0 0 10px currentColor; }
    32%, 100% { opacity: .14; transform: scale(.78); box-shadow: none; }
}

/* CardSwap, small: the placeholders stack up and cycle (DSBits swapper). */
.rb-swap { display: grid; perspective: 900px; padding-top: 30px; }
.rb-swap > * {
    grid-area: 1 / 1;
    transform-origin: 50% 100%;
    transform: translate3d(calc(var(--slot, 0) * 12px), calc(var(--slot, 0) * -11px), calc(var(--slot, 0) * -48px));
    z-index: calc(10 - var(--slot, 0));
    opacity: calc(1 - var(--slot, 0) * .24);
    transition: transform .75s cubic-bezier(.34, 1.3, .64, 1), opacity .5s ease;
}
.rb-swap > .is-dropping {
    z-index: 20;
    transform: translate3d(0, 34px, 30px) rotate(-3deg);
    opacity: 0;
    transition: transform .38s cubic-bezier(.5, 0, .75, 0), opacity .38s ease-in;
}
/* The quiz sheet was a column that hid its third ghost on short screens;
   stacked, every ghost fits in one card's height. */
.gen-sheet.rb-swap > .gen-q { display: block; margin: 0; }

/* The flashcard deck being dealt. */
.rb-minideck { width: 150px; margin: 0 auto 18px; }
.rb-minicard {
    display: flex; flex-direction: column; justify-content: center; gap: 7px;
    height: 92px; padding: 0 16px;
    text-align: left;
    border-radius: 12px;
    border: 1px solid var(--ds-line-2, rgba(91, 80, 232, .16));
    background: var(--ds-surface, #fff);
    box-shadow: 0 8px 20px -10px rgba(17, 24, 39, .25);
}
.rb-minicard .gen-line { margin: 0; height: 8px; }
.rb-minicard b {
    font: 700 .625rem/1 var(--ds-font-mono, ui-monospace, monospace);
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--ds-accent, #5b50e8);
}
[data-dark] .rb-minicard { background: var(--ds-surface-2, #222226); border-color: rgba(255, 255, 255, .1); }
[data-dark] .rb-minicard b { color: #b6a6ff; }

/* The clock under a tool's loader: proof it is alive, as on the quiz screen. */
.rb-loader-time {
    margin: 10px 0 0;
    font: 500 .75rem/1 var(--ds-font-mono, ui-monospace, monospace);
    color: var(--ds-ink-3, #6b7280);
    font-variant-numeric: tabular-nums;
}
.rb-loader-time:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
    .rb-shiny { animation: none; background-position: 100% 0; }
    .rb-lattice i { animation: none; opacity: .5; }
    .rb-swap > * { transition: none; }
}

/* CodeSlots: the input sits invisibly on top; the slots draw its digits. */
.rb-slots {
    --rb-slots-accent: var(--violet, #5b50e8);
    --rb-slots-ink: var(--violet, #5b50e8);
    --rb-slots-surface: var(--card-bg, #fff);
    --rb-slots-line: rgba(91, 80, 232, .22);
    --rb-slots-digit: #fff;
    --rb-slots-danger: #dc2626;
    --rb-slots-height: 52px;
    --rb-settle: 300ms;
    position: relative;
    margin-top: 6px;
}
.rb-slots__row {
    position: relative;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    max-width: 360px;
    cursor: text;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.rb-slots__input {
    position: absolute; inset: 0; z-index: 4;
    width: 100%; height: 100%; margin: 0; padding: 0; border: 0; outline: 0;
    background: transparent; color: transparent; caret-color: transparent;
    font-size: 16px; /* below 16px iOS zooms the page on focus */
    opacity: 0; cursor: inherit;
    -webkit-appearance: none; appearance: none;
}
.rb-slots__slot {
    position: relative;
    height: var(--rb-slots-height);
    border-radius: 12px;
    overflow: hidden;
    background: var(--rb-slots-surface);
    box-shadow: inset 0 0 0 1.5px var(--rb-slots-line);
    transition: box-shadow .15s ease, background-color .2s ease;
    user-select: none; -webkit-user-select: none;
}
.rb-slots__input:focus ~ .rb-slots__slot[data-active] {
    box-shadow: inset 0 0 0 2px var(--rb-slots-accent), 0 0 0 3px rgba(91, 80, 232, .18);
}
.rb-slots__fill {
    position: absolute; inset: 0; border-radius: inherit;
    background: var(--rb-slots-accent);
    transform: scale(0);
    transition: transform var(--rb-settle) cubic-bezier(.34, 1.4, .64, 1) var(--rb-delay, 0ms),
                background-color .2s ease;
}
.rb-slots__digit {
    position: absolute; inset: 0; z-index: 2;
    display: grid; place-items: center;
    color: var(--rb-slots-digit);
    font-family: var(--font-ui, 'Plus Jakarta Sans', sans-serif);
    font-size: 1.25rem; font-weight: 800; line-height: 1;
    font-variant-numeric: tabular-nums;
    opacity: 0; transform: translateY(8px);
    transition: opacity var(--rb-settle) ease var(--rb-delay, 0ms),
                transform var(--rb-settle) cubic-bezier(.23, 1, .32, 1) var(--rb-delay, 0ms);
}
.rb-slots__slot[data-filled] .rb-slots__fill { transform: scale(1); }
.rb-slots__slot[data-filled] .rb-slots__digit { opacity: 1; transform: none; }
.rb-slots__caret {
    position: absolute; z-index: 3; top: 25%; left: 0;
    width: 2px; height: 50%; border-radius: 1px;
    background: var(--rb-slots-ink);
    opacity: 0; pointer-events: none;
    transition: transform .18s cubic-bezier(.23, 1, .32, 1);
}
.rb-slots__input:focus ~ .rb-slots__caret:not([data-full]) { animation: rb-slots-blink 1s steps(1) infinite; }
@keyframes rb-slots-blink { 0% { opacity: 1; } 50% { opacity: 0; } }
.rb-slots__row[data-status='error'] .rb-slots__slot {
    background: color-mix(in srgb, var(--rb-slots-danger) 12%, var(--rb-slots-surface));
    box-shadow: inset 0 0 0 1.5px var(--rb-slots-danger);
}
.rb-slots__row[data-status='error'] .rb-slots__fill { background: var(--rb-slots-danger); }
.rb-slots__row[data-status='error'] .rb-slots__caret { animation: none; }
.rb-slots__sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[data-dark] .rb-slots {
    --rb-slots-accent: #5940d6;
    --rb-slots-ink: #b6a6ff;
    --rb-slots-surface: #15151a;
    --rb-slots-line: rgba(157, 148, 255, .28);
    --rb-slots-danger: #f87171;
}
@media (max-width: 380px) {
    .rb-slots { --rb-slots-height: 46px; }
    .rb-slots__row { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
    .rb-slots__fill, .rb-slots__digit, .rb-slots__caret { transition: none !important; }
    .rb-slots__digit { transform: none !important; }
    .rb-slots__input:focus ~ .rb-slots__caret:not([data-full]) { animation: none; opacity: 1; }
}
