/* VT-split-flap: page, board frame and flap modules. */

@font-face {
    font-family: "Roboto Condensed";
    src: url("fonts/roboto-condensed-latin-400-normal.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --sf-slot-w: 64px;
    --sf-slot-h: 78px;
    --sf-module-w: 58px;
    --sf-module-h: 68px;
    --sf-hinge: 2px;
    --sf-half: calc((var(--sf-module-h) - var(--sf-hinge)) / 2);
    --sf-outer-radius: 8px;
    --sf-inner-radius: 2px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ---- Page ---------------------------------------------------------------------------------- */

html {
    height: 100%;
    background-color: #0f0d0c;
    background-image:
        radial-gradient(circle at top, rgba(205, 162, 72, 0.18), transparent 30%),
        linear-gradient(180deg, #26211d 0%, #181513 45%, #0f0d0c 100%);
    background-repeat: no-repeat;
}

body {
    margin: 0;
    min-height: 100%;
    display: flex;
    overflow: hidden;
    font-family: "Roboto Condensed", "Arial Narrow", sans-serif;
}

/* Faint fixed backdrop texture: soft vertical light bands and a gentle lift in the middle. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(ellipse at center, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0) 65%),
        repeating-linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0px,
            rgba(255, 255, 255, 0.015) 70px,
            rgba(255, 255, 255, 0) 140px);
}

.container {
    position: relative;
    z-index: 1;
    margin: auto;
}

/* ---- Board frame --------------------------------------------------------------------------- */

.sf-board {
    position: relative;
    width: max-content;
    margin: 0 auto;
    padding: 28px;
    border: 1px solid rgba(255, 236, 184, 0.08);
    border-radius: 18px;
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 16%),
        linear-gradient(180deg, #4a4338, #191715);
    box-shadow:
        0 32px 80px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -18px 30px rgba(0, 0, 0, 0.35);
    transform: perspective(1400px) rotateX(8deg);
}

/* Inner hairline, 12px in from the edge. */
.sf-board::before {
    content: "";
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    pointer-events: none;
}

.sf-grid {
    display: grid;
    grid-template-columns: repeat(var(--sf-columns, 12), var(--sf-slot-w));
    grid-auto-rows: var(--sf-slot-h);
}

/* ---- Modules ------------------------------------------------------------------------------- */

.sf-slot {
    position: relative;
    width: var(--sf-slot-w);
    height: var(--sf-slot-h);
}

.sf-module {
    position: absolute;
    top: 0;
    left: calc((var(--sf-slot-w) - var(--sf-module-w)) / 2);
    width: var(--sf-module-w);
    height: var(--sf-module-h);
    border-radius: var(--sf-outer-radius);
    box-shadow: 0 10px 12px rgba(0, 0, 0, 0.28);
    perspective: 300px;
}

/* A flap surface: half the module tall, clipping a full-module-tall glyph to its own half. */
.sf-panel {
    position: absolute;
    left: 0;
    width: 100%;
    height: var(--sf-half);
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.09),
        inset 0 -1px 0 rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(0, 0, 0, 0.3);
}

.sf-panel--top {
    border-radius: var(--sf-outer-radius) var(--sf-outer-radius) var(--sf-inner-radius) var(--sf-inner-radius);
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.18)),
        linear-gradient(180deg, #69645f 0%, #54504c 40%, #494541 100%);
}

.sf-panel--bottom {
    border-radius: var(--sf-inner-radius) var(--sf-inner-radius) var(--sf-outer-radius) var(--sf-outer-radius);
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.18)),
        linear-gradient(180deg, #3b3734 0%, #35322f 58%, #24211f 100%);
}

/* Glossy band near the top edge of every upper surface. */
.sf-panel--top::after {
    content: "";
    position: absolute;
    top: 5px;
    left: 3px;
    right: 3px;
    height: 14px;
    border-radius: 6px 6px 3px 3px;
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
    opacity: 0.35;
    pointer-events: none;
}

.sf-upper {
    top: 0;
}

.sf-lower {
    top: calc(var(--sf-half) + var(--sf-hinge));
}

.sf-hinge {
    position: absolute;
    z-index: 3;
    top: var(--sf-half);
    left: 0;
    width: 100%;
    height: var(--sf-hinge);
    background-color: #0c0b0a;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ---- The turning leaf ---------------------------------------------------------------------- */

/* Sits over the upper half and rotates about the middle of the hinge gap, so after half a turn
   it lies exactly over the lower half. Hidden except while a step is running. */
.sf-leaf {
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--sf-half);
    visibility: hidden;
    transform-style: preserve-3d;
    transform-origin: 50% calc(100% + var(--sf-hinge) / 2);
}

.sf-module.is-turning .sf-leaf {
    visibility: visible;
}

.sf-leaf > .sf-panel {
    top: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Pre-turned so that, once the leaf has fallen, this face is upright over the lower half. */
.sf-leaf-back {
    transform: rotateX(180deg);
}

/* ---- Glyphs -------------------------------------------------------------------------------- */

/* Every glyph box is the full module height, anchored to the module's top edge (upper panels)
   or bottom edge (lower panels), so the two halves of a character line up across the hinge. */
.sf-glyph {
    position: absolute;
    left: 0;
    width: 100%;
    height: var(--sf-module-h);
    font-size: 56px;
    font-weight: 700;
    line-height: var(--sf-module-h);
    letter-spacing: 0.05em;
    text-indent: 0.05em; /* balances the trailing letter-spacing so the glyph sits centred */
    text-align: center;
    white-space: pre;
    color: #f1d25f;
    text-shadow: 0 0 10px rgba(255, 203, 76, 0.15);
    -webkit-user-select: none;
    user-select: none;
}

.sf-panel--top > .sf-glyph {
    top: 0;
}

.sf-panel--bottom > .sf-glyph {
    bottom: 0;
}

/* ---- Small screens ------------------------------------------------------------------------- */

@media (max-width: 980px) {
    body {
        overflow: auto;
        padding: 12px;
    }

    .container {
        max-width: calc(100vw - 24px);
        overflow-x: auto;
    }

    .sf-board {
        transform: none;
    }
}
