/* A level in play: ascent rail, top chips, fretboard, messages,
   corner buttons. */

/* In-run ascent rail: the route drawn as a slope with camps. */
#ascent {
    width: min(860px, 100%);
    height: 56px;
}

#ascent-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.ascent-current {
    transform-box: fill-box;
    transform-origin: center;
    animation: ascent-pulse 1.8s ease-in-out infinite;
}

.ascent-pop {
    transform-box: fill-box;
    transform-origin: center;
    animation: ascent-pop 520ms ease-out;
}

@keyframes ascent-pulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

@keyframes ascent-pop {
    0% {
        transform: scale(0.3);
    }
    60% {
        transform: scale(1.6);
    }
    100% {
        transform: scale(1);
    }
}

/* Only a row on a phone held sideways (bottom of this file). Everywhere
   else it makes no box, and the chips sit in the page as if it were not
   there. */
#hud-row {
    display: contents;
}

#hud {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

#hud > div,
#hud button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(12, 16, 30, 0.55);
    border: 1px solid rgba(255, 240, 214, 0.14);
    color: rgba(255, 247, 234, 0.9);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

#hud span {
    font-weight: 800;
    color: #f2c46d;
}

#level span {
    letter-spacing: 0.08em;
    font-size: 12px;
}

#board-slot {
    position: relative;
    max-width: 100%;
}

#fretboard {
    display: block;
    background: #2d1810;
    border-radius: 14px;
    cursor: pointer;
    max-width: 100%;
    height: auto;
    touch-action: none;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 240, 210, 0.05);
}

#message {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    height: 26px;
    color: #f2c46d;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#system-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: min(440px, calc(100vw - 48px));
    max-width: min(640px, calc(100vw - 48px));
    padding: 12px 18px;
    border-radius: 14px;
    text-align: center;
    font-size: clamp(20px, 2.6vw, 30px);
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #f4fbff;
    background: rgba(14, 18, 32, 0.74);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.26);
    pointer-events: none;
    z-index: 80;
}

#system-message[data-kind='hit'] {
    border-color: rgba(126, 245, 167, 0.45);
    color: #dfffe8;
}

#system-message[data-kind='warn'] {
    border-color: rgba(255, 214, 102, 0.45);
    color: #fff5c8;
}

#system-message[data-kind='miss'] {
    border-color: rgba(255, 138, 128, 0.45);
    color: #ffe3de;
}

#hud button {
    cursor: pointer;
    font-size: 14px;
    transition:
        transform 120ms ease,
        border-color 120ms ease;
}

#hud button:hover {
    border-color: rgba(255, 226, 177, 0.45);
    transform: translateY(-1px);
}

/* Navigation and settings live in the corner — the top panel is for
   gameplay only. On a phone held sideways they move to the ends of the
   chip row (bottom of this file). */
#corner-controls {
    position: fixed;
    right: 14px;
    bottom: 36px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 40;
}

#corner-controls button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 13px;
    border-radius: 999px;
    background: rgba(12, 16, 30, 0.55);
    border: 1px solid rgba(255, 240, 214, 0.14);
    color: rgba(255, 247, 234, 0.9);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    font-size: 16px;
    transition:
        transform 120ms ease,
        border-color 120ms ease;
}

#corner-controls button:hover {
    border-color: rgba(255, 226, 177, 0.45);
    transform: translateY(-1px);
}

#chord-chip span {
    font-size: 17px;
    letter-spacing: 0.4px;
}

/* Chord windows: the sounding chord's note names ride next to its name. */
#chord-chip .chip-tones {
    margin-left: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.6px;
    opacity: 0.8;
}

/* Chord windows, count-off: the first chord is coming, not sounding. Dashed
   like the frame that shows where a window goes next. Nothing changes
   size, so the chips and the board stay where they are when the band comes
   in. */
#chord-chip:has(.coming) {
    border-style: dashed;
    border-color: rgba(242, 196, 109, 0.7);
}

#chord-chip .coming,
#chord-chip .coming + .chip-tones {
    opacity: 0.55;
}

/* Chord windows: each chord's dots. Three for the triad, which credits the
   chord, then a smaller one for each other spot of its tones (a bonus).
   Green triad: credited. Gold pill: nothing left to find. The pill's border
   and padding are there in every state, so no state changes the chip's
   size and the board under it never moves. */
#targets .cw-pips-row {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 2px;
    white-space: pre;
}

#targets .cw-pips {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border: 1px solid transparent;
    border-radius: 999px;
}

.cw-pips .pip {
    box-sizing: border-box;
    width: 9px;
    height: 9px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    opacity: 0.75;
}

.cw-pips .pip:first-of-type {
    margin-left: 3px;
}

.cw-pips .pip.extra {
    width: 6px;
    height: 6px;
    border-width: 1px;
}

.cw-pips .pip.on {
    background: currentColor;
    opacity: 1;
}

#targets .cw-pips.credited,
.cw-pips.credited .pip:not(.extra) {
    color: #7ef5a7;
}

.cw-pips.credited .pip.extra {
    color: #f2c46d;
}

#targets .cw-pips.full {
    color: #ffe9b0;
    background: rgba(242, 196, 109, 0.22);
    border-color: rgba(242, 196, 109, 0.85);
}

/* Transform and shadow only: neither takes part in layout. */
.cw-pips.flash {
    animation: cw-full-flash 900ms ease-out;
}

@keyframes cw-full-flash {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 233, 176, 0.9);
        background: rgba(255, 233, 176, 0.6);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(255, 233, 176, 0);
    }
}

/* The count itself, in the message strip under the board. */
.count-off {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.count-off small {
    font-size: 13px;
    opacity: 0.8;
}

.count-off b {
    font-size: 20px;
    line-height: 1;
    opacity: 0.35;
}

.count-off b.on {
    opacity: 1;
    transform: scale(1.35);
    text-shadow: 0 0 12px rgba(242, 196, 109, 0.8);
}

#accuracy span.has-nopes {
    color: #ef9a9a;
}

#hint-btn.used {
    opacity: 0.4;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    #hud {
        flex-wrap: wrap;
        justify-content: center;
        font-size: 14px;
        border-radius: 6px;
    }

    #hud > div {
        padding: 6px 12px;
    }

    #hud button {
        padding: 6px 12px;
    }

    #message {
        font-size: 18px;
        height: 30px;
    }
}

@media (max-width: 500px) {
    #hud {
        font-size: 12px;
        gap: 5px;
    }

    #hud > div {
        padding: 4px 8px;
    }

    #hud button {
        padding: 4px 8px;
        font-size: 14px;
    }
}

/* Nothing may cover the fretboard. In a wide window this short (a phone
   held sideways) the board fills the page from edge to edge, so the
   bottom corner is on it. The corner buttons take the two ends of the chip
   row instead: back to the map on the left, mixer on the right. 600px is
   where the tallest level (a route, with its ascent rail) stops reaching
   the corner; upright phones are never this short and wide at once. */
@media (orientation: landscape) and (max-height: 600px) {
    #hud-row {
        display: flex;
        align-items: center;
        align-self: stretch;
        gap: 8px;
    }

    /* Takes the room between the buttons, so chips that do not fit wrap
       to a second line rather than run under a button. */
    #hud {
        flex: 1;
        min-width: 0;
    }

    /* A chord-window level has the most chips in the row and no height
       for a second line: a row that wraps pushes the board down and the
       count under it off the screen. So the row never wraps there. The
       found-dots chip shows only as much as fits (pickChordWindowPipsForm
       in game/mode-chord-window.js), and the chips close up so that it
       can show more; the buttons keep their size for the thumb. */
    #hud:has(#targets:not(.hidden)) {
        flex-wrap: nowrap;
        gap: 4px;
    }

    #hud:has(#targets:not(.hidden)) > * {
        flex: none;
    }

    #hud:has(#targets:not(.hidden)) > div {
        padding-inline: 8px;
    }

    /* The last resort on a screen too narrow even for the shortest dots:
       the score is cut short before any chip leaves the line. */
    #hud:has(#targets:not(.hidden)) > #accuracy {
        flex: 0 1 auto;
        min-width: 0;
    }

    #hud:has(#targets:not(.hidden)) #accuracy span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* The two buttons become items of the row itself. */
    #corner-controls {
        display: contents;
    }

    /* One width, so the chips stay centred between them. The buttons are
       taller than the chips; the margin lets them overhang the row rather
       than push the board down a screen with no height to spare. */
    #corner-controls button {
        flex: none;
        min-width: 50px;
        margin-block: -6px;
    }

    #map-btn {
        order: -1;
    }
}

/* A route level on a phone held sideways is taller than the screen: under
   the rail and the chips the board reaches the bottom edge, so a strip
   below it would be off the screen. There the strip lies over the rail
   instead, which is not the board, and the board stays where it is. 450px
   is the height below which rail, chips, board and strip stop fitting. */
@media (orientation: landscape) and (max-height: 450px) {
    #game-container:has(#ascent:not(.hidden)) {
        position: relative;
    }

    #game-container:has(#ascent:not(.hidden)) #message {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: none;
    }
}
