/* ============================================================
   RUGBY XV DRAFT — STYLESHEET
   ============================================================ */

/* Global tokens */
:root {
    --bg-main: #0f1115;
    --bg-card: #161920;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --brand-gold: #c5a059;
    --brand-gold-hover: #e0b86d;
    --pitch-green: #1b4329;
    --pitch-lines: rgba(255, 255, 255, 0.25);
}

.light-theme {
    --bg-main: #f4f5f7;
    --bg-card: #ffffff;
    --border-color: rgba(0, 0, 0, 0.1);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --brand-gold: #b0873a;
    --brand-gold-hover: #946f2f;
    --pitch-green: #27633d;
    --pitch-lines: rgba(255, 255, 255, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 20px;
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Header ── */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto 20px auto;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}
.utility-controls { display: flex; gap: 10px; }

/* ── Buttons ── */
button, .btn {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
button:hover:not(:disabled) { border-color: var(--brand-gold); color: var(--brand-gold); }
button:disabled, button.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--brand-gold); color: #000; border: 1px solid var(--brand-gold); }
.btn-primary:hover:not(:disabled) { background: var(--brand-gold-hover); border-color: var(--brand-gold-hover); color: #000; }

.btn-full { width: 100%; padding: 14px; margin-top: 10px; font-size: 1rem; }

/* ── Setup card ── */
.card-container {
    max-width: 550px;
    margin: 40px auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
}
.setup-title { margin-bottom: 16px; }
.setup-title h2 { font-size: 1.4rem; }

/* ── Explainer box ── */
.explainer-box {
    background: rgba(197,160,89,0.08);
    border: 1px solid rgba(197,160,89,0.3);
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 24px;
}
.explainer-lead {
    font-size: 0.93rem;
    font-weight: 700;
    color: var(--brand-gold);
    margin-bottom: 10px;
    line-height: 1.4;
}
.explainer-body {
    font-size: 0.81rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 8px;
}
.explainer-rules {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.explainer-rule {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-left: 16px;
    position: relative;
    line-height: 1.4;
}
.explainer-rule::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--brand-gold);
}

.control-group { margin-bottom: 24px; }
.control-group > label {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-weight: 700;
}
.control-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 7px;
    padding-left: 2px;
}

/* Team selector */
.team-select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239ca3af' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.team-select:focus { outline: none; border-color: var(--brand-gold); }

/* Slider toggles */
.slider-track {
    width: 100%;
    height: 42px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 21px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
}
.slider-handle {
    position: absolute;
    width: calc(50% - 4px);
    height: 36px;
    background: var(--brand-gold);
    border-radius: 18px;
    left: 2px;
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    z-index: 1;
}
.slider-track.right-state .slider-handle { transform: translateX(100%); }
.slider-options {
    position: absolute;
    width: 100%; height: 100%;
    left: 0; top: 0;
    display: flex;
    z-index: 2;
    pointer-events: none;
}
.slider-opt {
    flex: 1;
    text-align: center;
    line-height: 42px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
}
.slider-opt.active { color: #000; }

/* Radio buttons */
.radio-options { display: flex; flex-direction: column; gap: 10px; }
.radio-box { position: relative; width: 100%; }
.radio-box input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.radio-label {
    display: block;
    text-align: left;
    padding: 14px 20px;
    background: rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}
.radio-box input:checked + .radio-label {
    border-color: var(--brand-gold);
    background: rgba(197,160,89,0.1);
    color: var(--brand-gold);
}

/* ── Draft dashboard layout ── */
.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
}

/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; text-align: center; }
.stat-box {
    background: rgba(0,0,0,0.15);
    padding: 10px 5px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.stat-val { font-size: 1.4rem; font-weight: 800; color: var(--brand-gold); }
.stat-lbl { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); }

/* Action cluster */
.action-cluster { display: flex; gap: 10px; margin-bottom: 15px; }
.action-cluster button { flex: 1; padding: 12px; }

/* Status feed */
.status-feed-box {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.85rem;
    border-left: 3px solid var(--brand-gold);
}
.flag-wrapper { flex-shrink: 0; line-height: 1; }

/* ── Roster list ── */
.roster-scroll-boundary { overflow-y: auto; }
.roster-group { margin-bottom: 12px; }
.group-header {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--brand-gold);
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.player-row {
    display: grid;
    grid-template-columns: 1fr auto 36px;
    align-items: center;
    gap: 6px;
    padding: 7px 8px;
    background: rgba(0,0,0,0.1);
    margin-bottom: 3px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
}
.player-row:hover:not(.claimed-lockout) { background: rgba(255,255,255,0.05); }
.player-row.selected { background: rgba(197,160,89,0.2) !important; border-color: var(--brand-gold); }
/* player-num removed */
.player-name { font-size: 0.85rem; font-weight: 600; }
.player-pos-label { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; }
.player-rating { font-family: monospace; font-weight: 700; color: var(--brand-gold); font-size: 0.85rem; text-align: right; }

.claimed-lockout { opacity: 0.28; cursor: not-allowed; pointer-events: none; }

/* ── Pitch positional stagger ── */
/* Number 8: top aligns with midpoint of flankers (offset down by half circle height) */
.pitch-circle[data-num="8"]  { margin-top: calc(var(--circle-size, 68px) * 0.5); }

/* Fly-half: top aligns with midpoint of scrum-half */
.pitch-circle[data-num="10"] { margin-top: calc(var(--circle-size, 68px) * 0.5); }

/* Outside centre: top aligns with midpoint of inside centre */
.pitch-circle[data-num="13"] { margin-top: calc(var(--circle-size, 68px) * 0.5); }

/* Wingers: top aligns with midpoint of outside centre (so offset = 1.5x circle height from row top) */
.pitch-circle[data-num="11"],
.pitch-circle[data-num="14"] { margin-top: calc(var(--circle-size, 68px) * 1.5); }
.pitch-card { display: flex; justify-content: center; align-items: center; padding: 20px; }
.rugby-pitch-canvas {
    width: 100%;
    max-width: 720px;
    aspect-ratio: 1 / 1.35;
    background-color: var(--pitch-green);
    border: 4px solid #ffffff;
    border-radius: 12px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 5% 0;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.4);
}
.pitch-line-marking { position: absolute; width: 100%; border-top: 2px dashed var(--pitch-lines); pointer-events: none; }
.line-dead-top   { top: 0;    border-top-style: solid; border-top-width: 4px; }
.line-10m-top    { top: 22%; }
.line-22m-top    { top: 36%; }
.line-halfway    { top: 50%;  border-top-style: solid; border-top-width: 3px; }
.line-22m-bottom { bottom: 36%; }
.line-10m-bottom { bottom: 22%; }
.line-dead-base  { bottom: 0;   border-top-style: solid; border-top-width: 4px; }

.pitch-row-tier { display: flex; justify-content: center; align-items: flex-start; width: 100%; z-index: 5; gap: 4%; }

.pitch-circle {
    --circle-size: 68px;
    width: var(--circle-size); height: var(--circle-size);
    border-radius: 50% !important;
    background: rgba(0,0,0,0.75);
    border: 2px dashed rgba(255,255,255,0.5);
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: all 0.15s ease;
    padding: 4px;
}
.pitch-circle::before {
    content: attr(data-num);
    font-size: 1rem; font-weight: 800;
    color: rgba(255,255,255,0.6);
}
.pitch-circle::after {
    content: attr(data-label);
    font-size: 0.44rem; font-weight: 700;
    color: rgba(255,255,255,0.9);
    text-align: center; line-height: 1.1;
    width: 95%; display: block;
}
.pitch-circle.highlight-eligible {
    border-color: var(--brand-gold); border-style: solid;
    background: rgba(197,160,89,0.35);
    transform: scale(1.1);
    box-shadow: 0 0 12px var(--brand-gold);
    cursor: pointer;
}
.pitch-circle.highlight-forbidden {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}
/* ── OOP tooltip ── */
.oop-tooltip {
    position: fixed;
    background: #1a1a1a;
    color: #f87171;
    border: 1px solid rgba(248,113,113,0.5);
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
/* ── OOP warning icon ── */
.oop-icon {
    cursor: pointer;
    font-size: 0.65rem;
    margin-left: 2px;
    vertical-align: super;
    color: #f59e0b;
    user-select: none;
}
.oop-icon:hover { color: #fbbf24; }
.pitch-circle.occupied {
    background: #111317;
    border: 2px solid var(--brand-gold); border-style: solid;
    cursor: pointer;
    border-radius: 50% !important;
}
.pitch-circle.occupied::before,
.pitch-circle.occupied::after { display: none; }
/* Unlocked occupied nodes pulse subtly to show they're clickable to unselect */
.pitch-circle.occupied:not([data-locked]):hover {
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239,68,68,0.4);
}

.circle-num  { font-size: 1.1rem; font-weight: 800; color: var(--brand-gold); font-family: monospace; }
.circle-name {
    font-size: 0.52rem; font-weight: 700;
    text-align: center;
    overflow: hidden; text-overflow: ellipsis;
    width: 90%; color: #fff; margin-top: 1px;
    white-space: nowrap;
}

/* ── Simulation screen ── */
.sim-layout-container {
    max-width: 1000px; margin: 20px auto;
    display: grid; grid-template-columns: 4fr 5fr; gap: 25px;
}
.terminal-window-shell {
    background: #07080a;
    border: 1px solid var(--border-color);
    border-radius: 8px; padding: 15px;
    display: flex; flex-direction: column;
    height: 460px;
}
.terminal-header-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.terminal-title { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.terminal-logs-viewport {
    flex: 1; overflow-y: auto;
    font-family: monospace; font-size: 0.85rem;
    color: #e5e7eb; line-height: 1.6;
    padding-right: 5px;
}
.sim-log-line { display: block; margin-bottom: 5px; }

/* Manifest */
.manifest-header {
    font-size: 1rem; font-weight: 700; color: var(--brand-gold);
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color); padding-bottom: 8px;
}
.manifest-row {
    display: grid;
    grid-template-columns: 22px 1fr auto 36px;
    gap: 8px; align-items: center;
    padding: 5px 0;
    font-size: 0.82rem;
    border-bottom: 1px dashed rgba(255,255,255,0.04);
}
.manifest-num  { color: var(--text-muted); font-weight: 700; font-size: 0.72rem; }
.manifest-pos  { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; }
.manifest-name { font-weight: 500; }
.manifest-nation { font-size: 0.72rem; color: var(--text-muted); }

/* ── Roster panel stretches, abandon button anchored at bottom ── */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
}
.roster-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow: hidden;
}
.roster-scroll-boundary {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.abandon-btn {
    background: #db5a42;
    color: #fff;
    border: none;
    padding: 11px;
    width: 100%;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
}
.abandon-btn:hover { background: #c44e38; color: #fff; }

/* Dashboard fills full viewport height */
.dashboard-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 100px);
    min-height: 600px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    body { padding: 12px; }
    .dashboard-grid {
        grid-template-columns: 1fr;
        height: auto;
        min-height: unset;
    }
    .left-panel { min-height: unset; }
    .roster-panel { min-height: 300px; }
    .roster-scroll-boundary { max-height: 300px; }
    .sim-layout-container { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    body { padding: 8px; }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 12px;
    }
    header h1 { font-size: 1.1rem; }
    .utility-controls { width: 100%; }
    .utility-controls button { flex: 1; }

    /* Setup card full-width */
    .card-container {
        margin: 12px auto;
        padding: 18px;
        border-radius: 8px;
    }

    /* Stats row — still 3 col but tighter */
    .stat-val { font-size: 1.1rem; }
    .stat-lbl { font-size: 0.65rem; }

    /* Action cluster stack on very small */
    .action-cluster { gap: 8px; }
    .action-cluster button { padding: 10px 8px; font-size: 0.85rem; }

    /* Pitch circles smaller on mobile */
    .pitch-circle { --circle-size: 48px; width: 48px; height: 48px; }
    .pitch-circle::before { font-size: 0.85rem; }
    .pitch-circle::after { font-size: 0.38rem; }
    .circle-name { font-size: 0.44rem; }
    .pitch-row-tier { gap: 2.5%; }
    .pitch-card { padding: 10px; }

    /* Player rows more compact */
    .player-name { font-size: 0.8rem; }
    .player-pos-label { font-size: 0.64rem; }
    .player-rating { font-size: 0.8rem; }

    /* Roster panel on mobile — fixed sensible height */
    .roster-panel { min-height: 280px; }
    .roster-scroll-boundary { max-height: 280px; }

    /* Sim screen */
    .sim-layout-container { margin: 8px auto; gap: 12px; }
    .terminal-window-shell { height: 350px; }
    .manifest-row { font-size: 0.76rem; gap: 5px; }
}

@media (max-width: 400px) {
    .pitch-circle { --circle-size: 40px; width: 40px; height: 40px; }
    .pitch-circle::after { font-size: 0.32rem; }
    .pitch-row-tier { gap: 2%; }
}

/* ── Out-of-position pitch nodes ── */
.pitch-circle.highlight-outofpos {
    border-color: #d97706;
    border-style: solid;
    background: rgba(217,119,6,0.25);
    transform: scale(1.07);
    box-shadow: 0 0 10px rgba(217,119,6,0.6);
    cursor: pointer;
}
.pitch-circle.occupied-oop {
    background: #1c1208;
    border: 2px solid #d97706;
    border-style: solid;
    cursor: pointer;
    border-radius: 50% !important;
}
.pitch-circle.occupied-oop:not([data-locked]):hover {
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239,68,68,0.4);
}
.oop-num {
    color: #d97706 !important;
    display: flex;
    align-items: center;
    gap: 2px;
}
.oop-icon {
    font-size: 0.65rem;
    line-height: 1;
}

/* Manifest out-of-position badge */
.manifest-oop {
    font-size: 0.68rem;
    color: #d97706;
    font-weight: 700;
    margin-left: 5px;
    cursor: help;
}
.oop-rating {
    color: #d97706 !important;
}
