/* ================================================================
   FILE: static/css/landing/virtual_piano.css
   Realistic full-page piano stage for PitchFit.
   Uses vars from main.css (--primary-color, --text-color, --font-family)
   ================================================================ */

/* ── Stage container ────────────────────────────────────────── */
.vp-stage {
    position: relative;
    width: 100%;
    height: min(100vh, 820px);
    min-height: 560px;
    background:
        radial-gradient(ellipse 120% 80% at 50% 0%, #1b1d2a 0%, #0a0b14 58%, #05060c 100%);
    color: #e6e9f2;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: var(--font-family);
}

.vp-stage:fullscreen,
.vp-stage:-webkit-full-screen {
    height: 100vh;
    max-height: none;
}

/* Pseudo-fullscreen fallback (iOS Safari — see virtual_piano.js) */
.vp-stage.vp-stage--pseudo-fullscreen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width:  100vw;
    height: 100vh;
    height: 100dvh;     /* dynamic viewport — handles iOS URL bar */
    max-height: none;
    margin: 0;
    z-index: 9999;
}
body.vp-is-pseudo-fs { overflow: hidden; }

/* ── Top toolbar ─────────────────────────────────────────────── */
.vp-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    gap: 16px;
    background: linear-gradient(180deg, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, 0) 100%);
    flex: 0 0 auto;
    z-index: 5;
}

.vp-toolbar__left {
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 0 1 auto;
    min-width: 0;
}

.vp-toolbar__center {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    justify-content: center;
    flex-wrap: nowrap;
}

.vp-toolbar__right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

/* Brand */
.vp-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}

.vp-brand__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #d84b37, #8a1f14);
    color: #fff;
    border-radius: 8px;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(216, 75, 55, .4), inset 0 1px 0 rgba(255, 255, 255, .2);
}

.vp-brand__title {
    font-family: "Urbanist", sans-serif;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: .06em;
    color: #fff;
    line-height: 1.1;
}

.vp-brand__sub {
    font-size: 0.66rem;
    color: rgba(255, 255, 255, .45);
    letter-spacing: .18em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* LCD display */
.vp-display {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 14px;
    background: #0a1527;
    border: 1px solid #1f3a6b;
    border-radius: 6px;
    min-width: 200px;
    box-shadow:
        inset 0 0 18px rgba(0, 90, 200, .12),
        0 1px 2px rgba(0, 0, 0, .4);
    font-family: "JetBrains Mono", "SF Mono", Menlo, monospace;
}

.vp-display__row {
    display: flex;
    gap: 10px;
    font-size: 0.74rem;
    line-height: 1.3;
}

.vp-display__lbl {
    color: rgba(120, 180, 255, .45);
    font-weight: 600;
    width: 50px;
    flex-shrink: 0;
}

.vp-display__val {
    color: #7dbcff;
    font-weight: 500;
    text-shadow: 0 0 6px rgba(120, 180, 255, .35);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tool buttons (Settings / Sounds / Metronome / Sustain) */
.vp-tool-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: rgba(255, 255, 255, .7);
    font-family: inherit;
    font-size: 0.64rem;
    letter-spacing: .09em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    min-width: 64px;
}

.vp-tool-btn:hover {
    background: rgba(255, 255, 255, .05);
    color: #fff;
}

.vp-tool-btn--active {
    background: linear-gradient(180deg, rgba(255, 184, 77, .2), rgba(255, 120, 40, .1));
    border-color: rgba(255, 184, 77, .4);
    color: #ffcc77;
}

.vp-tool-btn__icon {
    display: block;
    font-size: 1.25rem;
    line-height: 1;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .5));
}

.vp-tool-btn__lbl {
    font-weight: 700;
}

/* Icon-only buttons (fullscreen / exit) */
.vp-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .03);
    color: rgba(255, 255, 255, .7);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s, border-color .15s;
    font-family: inherit;
}

.vp-icon-btn:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.vp-icon-btn--exit:hover {
    background: rgba(220, 38, 38, .2);
    border-color: rgba(220, 38, 38, .6);
    color: #ffb4b4;
}

/* ── Centre area ─────────────────────────────────────────────── */
.vp-centre {
    flex: 1 1 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 18px;
    padding: 20px;
    min-height: 0;
}

.vp-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(120, 180, 255, .18) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
}

.vp-pulse.active {
    animation: vp-pulse-anim .7s ease-out;
}

@keyframes vp-pulse-anim {
    0%   { opacity: .9; transform: translate(-50%, -50%) scale(.5); }
    100% { opacity: 0;  transform: translate(-50%, -50%) scale(1.6); }
}

.vp-hint {
    color: rgba(255, 255, 255, .32);
    font-size: 0.82rem;
    text-align: center;
    max-width: 460px;
    line-height: 1.5;
    z-index: 2;
    transition: opacity .4s;
}

.vp-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, .7);
    font-size: 0.85rem;
    z-index: 2;
}

.vp-loading__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #7dbcff;
    animation: vp-dot 1.2s infinite ease-in-out;
}

.vp-loading__dot:nth-child(2) { animation-delay: .15s; }
.vp-loading__dot:nth-child(3) { animation-delay: .3s; }

@keyframes vp-dot {
    0%, 80%, 100% { transform: scale(.3); opacity: .3; }
    40%           { transform: scale(1);  opacity: 1; }
}

/* ── Red LED strip ────────────────────────────────────────────── */
.vp-led {
    flex: 0 0 auto;
    height: 4px;
    background: linear-gradient(180deg, #ff5a4d 0%, #c4170a 50%, #7a0f06 100%);
    box-shadow:
        0 0 14px rgba(255, 90, 77, .6),
        0 0 30px rgba(255, 50, 40, .3),
        inset 0 1px 0 rgba(255, 200, 180, .4);
    position: relative;
    z-index: 3;
}

/* ── Keyboard ────────────────────────────────────────────────── */
.vp-kb-wrap {
    flex: 0 0 auto;
    background: linear-gradient(180deg, #141418 0%, #08080a 100%);
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
    height: clamp(230px, 42vh, 340px);
    box-shadow: 0 -2px 14px rgba(0, 0, 0, .6);
}

.vp-kb-wrap::-webkit-scrollbar { height: 0; }

.vp-kb {
    position: relative;
    display: flex;
    height: 100%;
    min-width: 100%;
}

/* White keys */
.vp-key-white {
    position: relative;
    flex: 1 1 0;
    min-width: 34px;
    background: linear-gradient(180deg, #fffef8 0%, #f0ece0 48%, #d6d0be 92%, #a8a295 100%);
    border-right: 1px solid #7a7468;
    border-bottom: 5px solid #403a31;
    border-radius: 0 0 6px 6px;
    box-shadow:
        inset 0 -3px 4px rgba(120, 100, 60, .2),
        inset 0 0 0 1px rgba(255, 255, 255, .55);
    cursor: pointer;
    transition: background .04s, box-shadow .04s, transform .04s, border-bottom-width .04s;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    padding-bottom: 10px;
    font-family: "Inter", system-ui, sans-serif;
    user-select: none;
}

.vp-key-white:last-child { border-right: none; }

.vp-key-white.pressed,
.vp-key-white:active {
    background: linear-gradient(180deg, #d9d3c2 0%, #c0b9a5 55%, #a59e8a 100%);
    box-shadow:
        inset 0 4px 6px rgba(60, 40, 20, .4),
        inset 0 0 14px rgba(100, 80, 40, .25);
    transform: translateY(2px);
    border-bottom-width: 3px;
}

/* Black keys */
.vp-key-black {
    position: absolute;
    top: 0;
    width: 60%;
    height: 62%;
    background: linear-gradient(180deg, #3e3e44 0%, #1a1a1c 40%, #0a0a0b 80%, #000 100%);
    border-radius: 0 0 5px 5px;
    box-shadow:
        inset 0 -3px 3px rgba(255, 255, 255, .15),
        inset 0 2px 3px rgba(70, 70, 80, .6),
        0 4px 8px rgba(0, 0, 0, .55),
        0 1px 0 rgba(255, 255, 255, .08);
    cursor: pointer;
    transition: background .04s, box-shadow .04s, transform .04s;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 3px;
    padding-bottom: 8px;
    font-family: "Inter", system-ui, sans-serif;
    color: #fff;
}

.vp-key-black::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 12%;
    right: 12%;
    height: 5px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .18), transparent);
    border-radius: 2px;
    pointer-events: none;
}

.vp-key-black.pressed,
.vp-key-black:active {
    background: linear-gradient(180deg, #1a1a1c 0%, #050506 60%, #000 100%);
    box-shadow:
        inset 0 3px 6px rgba(0, 0, 0, .85),
        0 1px 2px rgba(0, 0, 0, .5);
    transform: translateY(2px);
}

/* Key label (note name) */
.vp-key-label {
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    opacity: .8;
    pointer-events: none;
}

.vp-key-white .vp-key-label { color: #555; }

.vp-key-black .vp-key-label {
    color: rgba(255, 255, 255, .55);
    font-size: 0.62rem;
}

/* QWERTY hint chip */
.vp-key-kbhint {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    letter-spacing: .02em;
    pointer-events: none;
}

.vp-key-white .vp-key-kbhint {
    background: #eceae2;
    border: 1px solid #c8c4b4;
    color: #555;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}

.vp-key-black .vp-key-kbhint {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .22);
    font-size: 0.64rem;
    padding: 1px 5px;
}

/* Global visibility toggles */
.vp-stage[data-labels="none"]  .vp-key-label  { display: none; }
.vp-stage[data-kbhints="off"]  .vp-key-kbhint { display: none; }

/* ── Drawers (settings / sounds / metronome) ─────────────────── */
.vp-drawer {
    position: absolute;
    top: 74px;
    right: 18px;
    width: 360px;
    max-width: calc(100vw - 36px);
    background: rgba(18, 20, 32, .97);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 20;
    overflow: hidden;
    animation: vp-drawer-in .18s ease-out;
}

@keyframes vp-drawer-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.vp-drawer__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.vp-drawer__head h3 {
    margin: 0;
    font-size: 0.95rem;
    color: #fff;
    font-weight: 700;
}

.vp-drawer__close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .5);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: inherit;
}

.vp-drawer__close:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.vp-drawer__body {
    padding: 16px 18px 20px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Field row */
.vp-field {
    margin-bottom: 18px;
}

.vp-field:last-child { margin-bottom: 0; }

.vp-field > label {
    display: block;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, .5);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 8px;
    font-weight: 600;
}

.vp-field--inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vp-field--inline > label {
    margin: 0;
    text-transform: none;
    letter-spacing: normal;
    color: rgba(255, 255, 255, .85);
    font-size: 0.85rem;
    font-weight: 500;
    flex: 1 1 auto;
}

/* Segmented control */
.vp-seg {
    display: flex;
    width: 100%;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.vp-seg button {
    flex: 1 1 0;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .6);
    padding: 8px 10px;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background .14s, color .14s;
    font-family: inherit;
}

.vp-seg button:hover { color: #fff; }

.vp-seg button.active {
    background: linear-gradient(180deg, var(--primary-color, #134BA1), #0d3576);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

/* Range slider */
.vp-range {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, .1);
    border-radius: 2px;
    outline: none;
    padding: 0;
    margin: 0;
}

.vp-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color, #134BA1);
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

.vp-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color, #134BA1);
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

/* Toggle switch */
.vp-toggle {
    display: inline-block;
    position: relative;
    flex-shrink: 0;
}

.vp-toggle input { display: none; }

.vp-toggle label {
    display: inline-block;
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, .1);
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transition: background .16s;
    margin: 0;
}

.vp-toggle label::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: left .16s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

.vp-toggle input:checked + label {
    background: var(--primary-color, #134BA1);
}

.vp-toggle input:checked + label::after {
    left: 23px;
}

/* Sound grid */
.vp-sound-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 16px;
}

.vp-sound {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 10px;
    color: rgba(255, 255, 255, .75);
    cursor: pointer;
    transition: all .14s;
    font-family: inherit;
}

.vp-sound:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
    transform: translateY(-1px);
}

.vp-sound.active {
    background: linear-gradient(180deg, rgba(19, 75, 161, .4), rgba(19, 75, 161, .15));
    border-color: rgba(120, 180, 255, .45);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(120, 180, 255, .25) inset;
}

.vp-sound__icon {
    font-size: 1.6rem;
    line-height: 1;
}

.vp-sound__name {
    font-size: 0.76rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

/* BPM controls */
.vp-bpm {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
}

.vp-bpm-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 6px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: background .14s;
}

.vp-bpm-btn:hover { background: rgba(255, 255, 255, .12); }

.vp-bpm-val {
    flex: 1;
    text-align: center;
    font-family: "Urbanist", sans-serif;
    font-weight: 800;
    font-size: 2rem;
    color: #fff;
    min-width: 80px;
    line-height: 1;
}

.vp-btn-big {
    display: block;
    width: 100%;
    background: var(--primary-color, #134BA1);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
    transition: background .14s;
}

.vp-btn-big:hover { background: #0d3576; }

.vp-btn-big.active {
    background: linear-gradient(180deg, #d84b37, #8a1f14);
}

/* ── Responsive ─────────────────────────────────────────────── */

/* Tablets and narrow desktops */
@media (max-width: 920px) {
    .vp-brand__sub,
    .vp-tool-btn__lbl { display: none; }

    .vp-tool-btn { padding: 6px 10px; min-width: 44px; }
    .vp-display { min-width: 150px; padding: 4px 10px; }
    .vp-display__lbl { width: 42px; }
}

/* Medium mobile — drawers become bottom sheets */
@media (max-width: 760px) {
    .vp-drawer {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: auto;
        max-width: none;
        border-radius: 12px 12px 0 0;
        max-height: 70vh;
    }

    .vp-key-kbhint { display: none; }
}

/* Small mobile — toolbar wraps to 2 rows
   Brand + right-side icons stay on row 1, the 4 tool buttons
   drop to row 2. LCD display is hidden to save space. */
@media (max-width: 640px) {
    .vp-toolbar {
        flex-wrap: wrap;
        row-gap: 8px;
        padding: 10px 12px 8px;
        gap: 8px;
    }

    .vp-toolbar__left  { flex: 1 1 auto; min-width: 0; }
    .vp-toolbar__right { flex: 0 0 auto; }

    .vp-toolbar__center {
        order: 3;            /* push below row 1 */
        flex: 1 1 100%;      /* full width on row 2 */
        justify-content: space-around;
        gap: 2px;
    }

    .vp-display { display: none; }

    .vp-toolbar__center .vp-tool-btn {
        flex: 1 1 0;
        min-width: 0;
        max-width: 25%;
        padding: 6px 4px;
    }

    .vp-tool-btn__icon { font-size: 1.15rem; }

    .vp-brand__title { font-size: 0.88rem; }
    .vp-hint { font-size: 0.72rem; }
    .vp-icon-btn { width: 34px; height: 34px; font-size: 0.9rem; }

    /* Reclaim vertical space the extra row takes from the keyboard */
    .vp-kb-wrap { height: clamp(170px, 34vh, 240px); }
}