/* ===========================================================================
   OpenBench - board analyser ( event page )
   Loaded after ux.css. Layout: the board on the left, the moves and the
   evaluation graph on the right, with both columns the same height.
   =========================================================================== */

:root {
    --bd-light: #E3E8F1;
    --bd-dark:  #7A8FB3;
}

/* ---------- Layout ---------- */

.bd-layout {
    display: grid;
    grid-template-columns: minmax(0, 640px) minmax(0, 1fr);
    gap: 20px;
    align-items: stretch;
    margin-bottom: 20px;
}

.bd-layout .card {
    margin-bottom: 0;
}

.bd-card {
    display: flex;
    flex-direction: column;
}

.bd-body {
    padding: 16px;
}

/* The right column does not add to the row height, so it always matches the board */
.ev-right {
    position: relative;
    min-width: 0;
    min-height: 560px;
}

.ev-right-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ev-moves-card {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 0;
}

.ev-moves-card .ev-movelist {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
}

.bd-graph-card {
    flex: none;
}

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

.bd-grid {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 10px;
}

#bd-top    { grid-column: 2; grid-row: 1; }
.bd-eval   { grid-column: 1; grid-row: 2; }
.bd-board  { grid-column: 2; grid-row: 2; }
#bd-bottom { grid-column: 2; grid-row: 3; }

.bd-board {
    aspect-ratio: 1;
    border-radius: var(--radius);
    box-shadow: 0 0 0 1px var(--line-strong), 0 8px 22px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.bd-board svg {
    display: block;
    width: 100%;
    height: 100%;
}

.bd-nojs {
    margin: 0;
    padding: 24px;
    color: var(--muted);
}

.bd-light { fill: var(--bd-light); }
.bd-dark  { fill: var(--bd-dark);  }

.bd-hl-from { fill: rgba(250, 204, 21, 0.38); }
.bd-hl-to   { fill: rgba(250, 204, 21, 0.55); }
.bd-hl-bad  { fill: rgba(248, 113, 113, 0.5); }

.bd-check-in  { stop-color: #F87171; stop-opacity: 0.95; }
.bd-check-out { stop-color: #F87171; stop-opacity: 0; }

.bd-coord {
    font: 600 17px var(--font-sans);
    pointer-events: none;
    user-select: none;
}

.bd-coord.on-dark  { fill: var(--bd-light); }
.bd-coord.on-light { fill: var(--bd-dark);  }

.bd-arrow          { opacity: 0.92; }
.bd-arrow line     { stroke: #F87171; }
.bd-arrow polygon  { fill: #F87171; }

/* ---------- Evaluation bar ---------- */

.bd-eval {
    position: relative;
    align-self: stretch;
    background-color: #161B26;
    border-radius: var(--radius);
    box-shadow: 0 0 0 1px var(--line-strong);
    overflow: hidden;
}

.bd-eval::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: rgba(120, 130, 150, 0.55);
}

.bd-eval-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 50%;
    background-color: #EDF0F6;
    transition: height 0.25s ease;
}

.bd-eval.is-flipped .bd-eval-fill {
    top: 0;
    bottom: auto;
}

.bd-eval-label {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 1;
    font: 600 10.5px var(--font-mono);
    letter-spacing: -0.03em;
    text-align: center;
}

.bd-eval-label.on-white { bottom: 6px; color: #161B26; }
.bd-eval-label.on-black { top: 6px;    color: #E6EAF2; }

.bd-eval.is-flipped .bd-eval-label.on-white { top: 6px;    bottom: auto; }
.bd-eval.is-flipped .bd-eval-label.on-black { bottom: 6px; top: auto;    }

/* ---------- Players, captured pieces ---------- */

.bd-player {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    min-height: 34px;
}

.bd-player .ev-piece {
    flex: none;
    width: 12px;
    height: 12px;
}

.bd-player.is-white .ev-piece { background-color: #F1F4FA; }
.bd-player.is-black .ev-piece { background-color: #0B0E14; }

.bd-player.is-turn .ev-piece {
    box-shadow: 0 0 0 2px var(--color2), 0 0 0 4px var(--accent);
}

.bd-name {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--color-font1);
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bd-caps {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    min-width: 0;
    padding-left: 6px;
    overflow: hidden;
}

.bd-cap {
    flex: none;
    width: 20px;
    height: 20px;
}

.bd-cap + .bd-cap {
    margin-left: -9px;
}

.bd-mat {
    flex: none;
    color: var(--muted);
    font: 600 12px var(--font-mono);
}

/* ---------- Status, controls, FEN ---------- */

.bd-status {
    min-height: 20px;
    margin: 14px 0 0;
    color: var(--color-font2);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.bd-status.is-bad  { color: var(--bad);  }
.bd-status.is-warn { color: var(--warn); }

.bd-controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)) 52px;
    gap: 8px;
    margin-top: 12px;
}

.bd-card .bd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0;
    background-color: var(--color3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--color-font1);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.bd-card .bd-btn:hover:not(:disabled) {
    background-color: var(--surface-hover);
    border-color: var(--accent);
}

.bd-card .bd-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.bd-card .bd-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.bd-card .bd-btn-main {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
}

.bd-card .bd-btn-main:hover:not(:disabled) {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.bd-card .bd-btn-main.is-playing {
    background-color: var(--accent-soft);
    border-color: var(--accent);
    color: var(--color-font1);
}

.bd-card .bd-btn-flip {
    margin-left: 4px;
}

.bd-fen {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 5px 5px 5px 12px;
    background-color: var(--color1);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.bd-fen-label {
    flex: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
}

.bd-fen code {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    background: none;
    color: var(--color-font2);
    font-family: var(--font-mono);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bd-card .bd-btn-icon {
    flex: none;
    width: 32px;
    height: 32px;
}

/* ---------- Moves card ---------- */

.ev-moves-card .ev-sel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.ev-moves-card .ev-sel-main {
    flex: 1 1 auto;
    min-width: 0;
}

.ev-moves-card .ev-sel-san {
    font-size: 24px;
}

.ev-sel-counter {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
}

.ev-moves-card .ev-sel-stats {
    grid-template-columns: repeat(3, minmax(64px, auto));
    margin-top: 0;
}

.ev-moves-card .ev-sel-note {
    flex-basis: 100%;
    margin: 0;
}

.ev-moves-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.ev-moves-foot kbd {
    display: inline-block;
    min-width: 20px;
    padding: 1px 6px;
    background-color: var(--color3);
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: var(--radius);
    color: var(--color-font2);
    font: 11px var(--font-mono);
    text-align: center;
}

/* ---------- Evaluation graph ---------- */

.bd-graph-wrap {
    padding: 14px 16px 16px;
}

.bd-graph {
    height: 132px;
    background-color: #363F54;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    cursor: crosshair;
    overflow: hidden;
    touch-action: none;
}

.bd-graph svg {
    display: block;
    width: 100%;
    height: 100%;
}

.bd-area-white { fill: rgba(237, 240, 246, 0.88); }
.bd-area-black { fill: rgba(11, 14, 20, 0.92); }

.bd-mid {
    stroke: rgba(255, 255, 255, 0.28);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.bd-curve {
    fill: none;
    stroke: var(--accent-hover);
    stroke-width: 2;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.bd-cursor {
    stroke: var(--accent);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {

    .bd-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .bd-card {
        width: 100%;
        max-width: 640px;
        justify-self: center;
    }

    .ev-right {
        min-height: 0;
    }

    .ev-right-inner {
        position: static;
    }

    .ev-moves-card {
        flex: none;
    }

    .ev-moves-card .ev-movelist {
        flex: none;
        max-height: 420px;
    }
}

@media (max-width: 767px) {

    .bd-body {
        padding: 12px;
    }

    .bd-grid {
        grid-template-columns: 22px minmax(0, 1fr);
        column-gap: 8px;
    }

    .bd-eval-label {
        font-size: 9px;
    }

    .bd-controls {
        grid-template-columns: repeat(5, minmax(0, 1fr)) 44px;
        gap: 6px;
    }
}
