/* ============================================
   SPLIT-FLAP BOARD (.buk-sf)
   Markup: section.buk-sf > .buk-sf__inner > a.buk-sf__link > .buk-sf__board[data-buk-split-flap]
   Tiles are generated by assets/js/split-flap.js.
   ============================================ */
.buk-sf {
    --buk-sf-bg: #120f17;
    --buk-sf-tile-bg: #111827;
    --buk-sf-tile-text: #f8fafc;
    --buk-sf-accent: #ff7a00;
    --buk-sf-gap: .11em;
    --buk-sf-radius: .11em;
    --buk-sf-flap-duration: 120ms;
    display: block;
    width: 100%;
    margin: 0;
    padding: clamp(28px, 3.4vw, 56px) clamp(10px, 2.8vw, 40px);
    background: var(--buk-sf-bg);
    box-sizing: border-box;
    overflow: hidden;
}

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

.buk-sf__inner {
    display: flex;
    justify-content: center;
    max-width: 1610px;
    margin: 0 auto;
    container-type: inline-size;
}

.buk-sf__link,
.buk-sf__link:hover,
.buk-sf__link:focus {
    display: inline-block;
    max-width: 100%;
    color: inherit;
    text-decoration: none;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
}

.buk-sf__link:focus-visible {
    outline: 3px solid var(--buk-sf-accent);
    outline-offset: 10px;
}

/* 19 tiles x .78em + 18 gaps x .11em = 16.8em, so 5.8cqi always fits the container. */
.buk-sf__board {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--buk-sf-gap);
    width: max-content;
    max-width: 100%;
    min-height: 1.08em;
    font-family: "SFMono-Regular", "Roboto Mono", "Cascadia Code", "Liberation Mono", Menlo, monospace;
    font-weight: 760;
    font-size: clamp(12px, 4.4vw, 67px);
    font-size: min(67px, 5.8cqi);
    letter-spacing: .035em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
    text-transform: uppercase;
    -webkit-user-select: none;
    user-select: none;
}

.buk-sf__fallback {
    color: var(--buk-sf-tile-text);
    line-height: 1.08em;
}

.buk-sf__tile {
    position: relative;
    flex: none;
    width: .78em;
    height: 1.08em;
    overflow: hidden;
    border-radius: var(--buk-sf-radius);
    isolation: isolate;
    background: var(--buk-sf-tile-bg);
    background:
        radial-gradient(circle at 50% 0%, rgba(255,255,255,.16), transparent 44%),
        linear-gradient(180deg, color-mix(in srgb, var(--buk-sf-tile-bg) 82%, white), var(--buk-sf-tile-bg));
    box-shadow:
        0 .035em .08em rgba(255,255,255,.08) inset,
        0 -.05em .1em rgba(0,0,0,.38) inset,
        0 .16em .38em rgba(0,0,0,.28);
    perspective: 520px;
    transform-style: preserve-3d;
}

.buk-sf__tile::before {
    content: "";
    position: absolute;
    inset: calc(50% - .5px) 0 auto;
    height: 1px;
    z-index: 8;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.18) 18%, rgba(0,0,0,.64) 50%, rgba(255,255,255,.14) 82%, transparent);
    box-shadow: 0 -1px 0 rgba(255,255,255,.08), 0 1px 0 rgba(0,0,0,.5);
    pointer-events: none;
}

.buk-sf__tile::after {
    content: "";
    position: absolute;
    z-index: 9;
    inset: 0;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: inherit;
    box-shadow: 0 0 0 1px rgba(0,0,0,.2) inset;
    pointer-events: none;
}

.buk-sf__half,
.buk-sf__flap {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    background: linear-gradient(180deg, rgba(255,255,255,.07), transparent 34%), var(--buk-sf-tile-bg);
}

.buk-sf__half--top,
.buk-sf__flap--front {
    top: 0;
}

.buk-sf__half--bottom,
.buk-sf__flap--back {
    bottom: 0;
    background: linear-gradient(0deg, rgba(255,255,255,.06), transparent 38%), #10151f;
    background: linear-gradient(0deg, rgba(255,255,255,.06), transparent 38%), color-mix(in srgb, var(--buk-sf-tile-bg) 92%, black);
}

.buk-sf__char {
    position: absolute;
    left: 0;
    width: 100%;
    height: 200%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--buk-sf-tile-text);
    text-shadow: 0 .025em 0 rgba(255,255,255,.16), 0 .09em .16em rgba(0,0,0,.42);
}

.buk-sf__half--top .buk-sf__char,
.buk-sf__flap--front .buk-sf__char { top: 0; }

.buk-sf__half--bottom .buk-sf__char,
.buk-sf__flap--back .buk-sf__char { bottom: 0; }

.buk-sf__flap {
    z-index: 5;
    display: none;
    transform-style: preserve-3d;
}

.buk-sf__tile.is-flipping .buk-sf__flap { display: block; }

.buk-sf__tile.is-flipping .buk-sf__flap--front {
    transform-origin: 50% 100%;
    animation: buk-sf-flip-front var(--buk-sf-flap-duration) cubic-bezier(.45,0,.75,.6) both;
}

.buk-sf__tile.is-flipping .buk-sf__flap--back {
    transform-origin: 50% 0;
    animation: buk-sf-flip-back var(--buk-sf-flap-duration) cubic-bezier(.2,.35,.5,1) both;
}

@keyframes buk-sf-flip-front {
    from { transform: rotateX(0deg); filter: brightness(1); }
    to   { transform: rotateX(-90deg); filter: brightness(.46); }
}

@keyframes buk-sf-flip-back {
    0%, 48% { transform: rotateX(90deg); filter: brightness(.52); }
    100%    { transform: rotateX(0deg); filter: brightness(1); }
}

@media (max-width: 600px) {
    .buk-sf {
        --buk-sf-flap-duration: 110ms;
        padding: 24px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .buk-sf__flap,
    .buk-sf__tile.is-flipping .buk-sf__flap {
        display: none !important;
        animation: none !important;
    }
}
