/* Vestaboard split-flap experiment */

.vb-scene {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding: clamp(2.5rem, 7vw, 5.5rem) 1.25rem clamp(2rem, 5vw, 3.5rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.75rem;
    color-scheme: light;
    background:
        radial-gradient(120% 90% at 50% 0%, #f5f5f3 0%, #eaeae8 55%, #e0e0de 100%);
}

.vb-scene::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(60% 30% at 50% 30%, rgba(255, 255, 255, 0.55), transparent 70%);
}

.vb-board {
    container-type: inline-size;
    position: relative;
    width: min(860px, 100%);
    padding: 3.8%;
    border-radius: clamp(6px, 1.1vw, 12px);
    background: linear-gradient(160deg, #17171a 0%, #0e0e10 55%, #0a0a0c 100%);
    box-shadow:
        0 34px 64px -20px rgba(20, 20, 24, 0.5),
        0 10px 22px rgba(20, 20, 24, 0.24),
        0 2px 5px rgba(20, 20, 24, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -2px 8px rgba(0, 0, 0, 0.65);
}

.vb-grid {
    display: grid;
    grid-template-columns: repeat(22, 1fr);
    gap: 0.55cqw;
    padding: 1cqw;
    border-radius: 0.7cqw;
    background: #060607;
    box-shadow:
        inset 0 0.25cqw 0.7cqw rgba(0, 0, 0, 0.9),
        inset 0 -0.12cqw 0 rgba(255, 255, 255, 0.03);
}

.vb-cell {
    position: relative;
    aspect-ratio: 11 / 15;
}

.vb-cell.is-flipping {
    perspective: 40cqw;
}

/*
  Each face is a full-cell layer with the glyph centered identically.
  Top/bottom only differ by clip-path, so halves always line up.
*/
.vb-face {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #1c1c20;
}

.vb-face--top {
    clip-path: inset(0 0 50% 0);
    border-radius: 0.45cqw 0.45cqw 0.14cqw 0.14cqw;
    background: linear-gradient(180deg, #2b2b30 0%, #202024 50%, #1b1b1f 100%);
    box-shadow: inset 0 0.14cqw 0 rgba(255, 255, 255, 0.06);
    z-index: 1;
}

.vb-face--bottom {
    clip-path: inset(50% 0 0 0);
    border-radius: 0.14cqw 0.14cqw 0.45cqw 0.45cqw;
    background: linear-gradient(180deg, #1e1e22 0%, #16161a 100%);
    box-shadow: inset 0 -0.22cqw 0.35cqw rgba(0, 0, 0, 0.55);
    z-index: 0;
}

.vb-face > span {
    font-family: 'IBM Plex Mono', 'SF Mono', ui-monospace, monospace;
    font-size: 2.9cqw;
    font-weight: 500;
    line-height: 1;
    color: #f2f2ef;
    text-shadow: 0 0 0.5cqw rgba(255, 255, 255, 0.16);
    user-select: none;
    -webkit-user-select: none;
}

/* Flap is only visible while flipping; parked hidden at rest */
.vb-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    z-index: 2;
    transform-origin: 50% 100%;
    transform-style: preserve-3d;
    will-change: transform;
}

.vb-flap .vb-face {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Faces inside the flap are sized to the flap half, so undo cell clip
       and show the matching half of a double-height centered glyph. */
    clip-path: none;
    inset: auto;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
}

.vb-flap .vb-face > span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 200%;
    display: grid;
    place-items: center;
}

.vb-flap__front > span {
    top: 0;
}

/* Back face is rotateX(180); top-half glyph reads as bottom half when flipped down */
.vb-flap__back {
    transform: rotateX(180deg);
}

.vb-flap__back > span {
    top: 0;
}

.vb-flap__front {
    border-radius: 0.45cqw 0.45cqw 0.14cqw 0.14cqw;
    background: linear-gradient(180deg, #2b2b30 0%, #202024 50%, #1b1b1f 100%);
}

.vb-flap__back {
    border-radius: 0.14cqw 0.14cqw 0.45cqw 0.45cqw;
    background: linear-gradient(180deg, #1e1e22 0%, #16161a 100%);
}

.vb-cell::after {
    content: '';
    position: absolute;
    left: -0.1cqw;
    right: -0.1cqw;
    top: 50%;
    height: max(1px, 0.16cqw);
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.85);
    z-index: 3;
    pointer-events: none;
}

.vb-controls {
    position: relative;
    display: flex;
    gap: 0.5rem;
    width: min(860px, 100%);
}

.vb-controls input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0.65rem 0.9rem;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    background: #fdfdfc;
    color: #1e1e1e;
    font-family: 'IBM Plex Mono', 'SF Mono', ui-monospace, monospace;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.vb-controls input::placeholder {
    color: rgba(30, 30, 30, 0.4);
    text-transform: none;
}

.vb-controls input:focus-visible {
    outline: 2px solid #141416;
    outline-offset: 1px;
}

.vb-controls button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.65rem 1.3rem;
    border: none;
    border-radius: 6px;
    background: #141416;
    color: #f2f2ef;
    font-family: 'IBM Plex Mono', 'SF Mono', ui-monospace, monospace;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    cursor: pointer;
}

.vb-controls button:hover {
    background: #2a2a2e;
}

.vb-controls button:focus-visible {
    outline: 2px solid #141416;
    outline-offset: 2px;
}

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

@media (max-width: 640px) {
    .vb-scene {
        padding: clamp(1.75rem, 6vw, 3rem) 0.75rem 1.75rem;
        gap: 1.25rem;
    }

    .vb-board,
    .vb-controls {
        width: 100%;
    }

    .vb-controls {
        flex-direction: column;
    }

    .vb-controls input {
        font-size: 16px;
    }

    .vb-controls button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .vb-scene {
        padding-left: 0.6rem;
        padding-right: 0.6rem;
    }

    .vb-face > span {
        font-size: 3.2cqw;
    }
}
