/**
 * CaskX Brackets — Frontend Stylesheet
 */

/* ── Outer wrapper ─────────────────────────────────────────────────────────── */
.caskx-bracket-wrap {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #222;
    overflow-x: auto;
    padding-bottom: 16px;
}

/* ── Voting dates ──────────────────────────────────────────────────────────── */
.caskx-voting-dates {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #555;
    font-style: italic;
}

/* ── Inner flex row ─────────────────────────────────────────────────────────── */
.caskx-bracket-inner {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
}

/* ── Round column ───────────────────────────────────────────────────────────── */
.caskx-round-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    width: 100%;
    min-width: 180px;
}

/* ── Round header ───────────────────────────────────────────────────────────── */
.caskx-round-header {
    width: 100%;
    background: #1a1a2e;
    color: #fff;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 4px;
    box-sizing: border-box;
    margin-bottom: 4px;
}

.row-has-dates .caskx-round-header {
    min-height: 46px;
}

.caskx-round-header.is-active {
    background: #2d2d6b;
}

/* ── Matches list within a column ───────────────────────────────────────────── */
.caskx-round-matches {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 100%;
    flex: 1;
    gap: 0;
}

/* ── Individual matchup block ───────────────────────────────────────────────── */
.caskx-matchup {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: 2px 8px;
    position: relative;
}

/* ── Bracket connectors ─────────────────────────────────────────────────────── */

/* Right arm: horizontal line from each matchup's midpoint toward the gap */
.caskx-matchup::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 8px;
    height: 1px;
    background: #bbb;
    transform: translateY(-50%);
}

/* Last round column matchups don't need a right arm */
.caskx-champion-col ~ * .caskx-matchup::after,
.caskx-round-col:last-of-type .caskx-matchup::after {
    display: none;
}

/* Left arm: horizontal line entering each matchup from the gap (rounds 2+) */
.caskx-round-col:not(:first-of-type) .caskx-matchup::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 8px;
    height: 1px;
    background: #bbb;
    transform: translateY(-50%);
}

/* Vertical bar on the TOP matchup of each pair — draws down to meet its partner */
.caskx-matchup.has-connector-top::after {
    width: 1px;
    height: calc( var(--matchup-h) / 2 + 50% );
    top: 50%;
    right: 0;
    transform: none;
    background: #bbb;
}

/* Vertical bar on the BOTTOM matchup of each pair — draws up to meet its partner */
.caskx-matchup.has-connector-bottom::after {
    width: 1px;
    height: calc( var(--matchup-h) / 2 + 50% );
    bottom: 50%;
    top: auto;
    right: 0;
    transform: none;
    background: #bbb;
}

/* Horizontal arm on top/bottom connector matchups */
.caskx-matchup.has-connector-bottom::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 8px;
    height: 1px;
    background: #bbb;
    transform: translateY(-50%);
}

/* ── Slot divider between two player slots ──────────────────────────────────── */
.caskx-slot-divider {
    height: 3px;
    position: relative;
}

.caskx-slot-divider::after {
    content: "";
    display: block;
    height: 1px;
    width: 6px;
    background-color: #bbb;
    position: absolute;
    right: -8px;
    top: 1px;
}

/* ── Individual player slot ─────────────────────────────────────────────────── */
.caskx-slot {
    display: flex;
    align-items: center;
    min-height: 28px;
    height: auto;
    padding: 4px 6px;
    background: #f7f7f7;
    border: 1px solid #bbb;
    border-radius: 3px;
    box-sizing: border-box;
    gap: 4px;
    line-height: 1.3;
}

/* Winner slot */
.caskx-slot.winner {
    border: 2px solid #f0a500;
    background: #fff8e6;
    font-weight: 700;
}

/* BYE slot */
.caskx-slot.bye {
    color: #999;
    font-style: italic;
    background: #f0f0f0;
    border-color: #d0d0d0;
}

/* TBD slot (future rounds) */
.caskx-slot.tbd {
    color: #aaa;
    font-style: italic;
    background: #fafafa;
    border-color: #e0e0e0;
}

/* ── Player name ─────────────────────────────────────────────────────────────── */
.caskx-player-name {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
    display: inline-block;
}

a.caskx-player-name {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: #bbb;
}

a.caskx-player-name:hover {
    text-decoration-color: currentColor;
}

/* ── Vote count ──────────────────────────────────────────────────────────────── */
.caskx-vote-count {
    font-size: 10px;
    color: #666;
    white-space: nowrap;
}

/* ── Vote button ─────────────────────────────────────────────────────────────── */
.caskx-vote-btn {
    font-size: 10px;
    padding: 2px 6px;
    margin-left: 4px;
    cursor: pointer;
    background: #1a1a2e;
    color: #fff;
    border: 1px solid #1a1a2e;
    border-radius: 3px;
    line-height: 1.4;
    transition: background 0.15s ease;
    white-space: nowrap;
    margin-left: auto;
}

.caskx-vote-btn:hover:not(:disabled) {
    background: #2d2d6b;
    border-color: #2d2d6b;
}

.caskx-vote-btn:disabled,
.caskx-vote-btn.voted {
    background: #ccc;
    border-color: #bbb;
    color: #888;
    cursor: default;
}

/* ── Champion column ─────────────────────────────────────────────────────────── */
.caskx-champion-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    width: 100%;
    align-self: stretch;
}

.caskx-champion-col .caskx-round-header.champion-header {
    background: #f0a500;
    color: #1a1a2e;
}

/* ── Round dates (inside header) ─────────────────────────────────────────────── */
.caskx-round-dates {
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    opacity: 0.85;
    margin-top: 2px;
}

/* ── Matchup category label (below both player slots) ────────────────────────── */
.caskx-matchup-label {
    width: 100%;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: #777;
    padding: 3px 4px 0;
    box-sizing: border-box;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin-bottom: -18px;
}

.caskx-champion {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex: 1;
}

.caskx-champion-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 56px;
    padding: 10px 8px;
    box-sizing: border-box;
    background: #fff8e6;
    border: 2px solid #f0a500;
    border-radius: 3px;
    text-align: center;
    margin: 0 auto;
}

.caskx-champion-name {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
    word-break: break-word;
}

.caskx-tbd-champion {
    font-size: 13px;
    color: #aaa;
    font-style: italic;
}

/* ── Vote modal ──────────────────────────────────────────────────────────────── */
.caskx-vote-modal {
    border: none;
    border-radius: 6px;
    padding: 0;
    width: min(480px, 92vw);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

.caskx-vote-modal::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.caskx-vote-modal-inner {
    padding: 28px 24px 24px;
    position: relative;
}

.caskx-vote-modal-close {
    all: unset !important;

    position: absolute !important;
    top: 12px !important;
    right: 14px !important;
    border: none !important;
    font-size: 22px !important;
    line-height: 0 !important;
    color: black !important;
    padding: 0 !important;
    background-color: #f8c113 !important;
    height: 24px !important;
    width: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding-left: 1px !important;
    border-radius: 5px !important;
    cursor: pointer !important;
}

.caskx-vote-modal-close:hover {
    opacity: 0.9 !important;
}

.caskx-vote-modal-content {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #222;
}

.caskx-vote-modal-form {
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .caskx-round-col,
    .caskx-champion-col {
        min-width: 180px;
        width: 180px;
    }

    .caskx-player-name {
        max-width: 60px;
    }

    .caskx-vote-btn {
        font-size: 9px;
        padding: 1px 4px;
    }
}
