/*
 * Two stages that are the application's screens rather than its felt: the reports page's report, laid
 * out as the report designer lays one out and ordered by whichever heading is pressed, and the tables
 * page's monitor, its tables moving into the layout for however many are open.
 *
 * The report orders its rows with flex order: each row carries its place in every order as a custom
 * property, --by-{column}, and the heading pressed picks which is read. Each table carries where it
 * sits in every layout, --l, --t, --w, --h and --o for each count, and the count pressed - or, under
 * Auto-arrange, the clock - picks which.
 */

/* ── The report ─────────────────────────────────────────────────────────────── */

.report-shown { width: 100%; max-width: 1080px; }
.report-shown__window {
    overflow: hidden; border-radius: 18px; background: var(--bg-surface); border: 1px solid var(--border-subtle);
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8); font-size: 13px;
}
.report-shown__top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.report-shown__title { margin-right: 8px; font-size: 14px; font-weight: 600; }
.report-shown__chip { padding: 5px 11px; border-radius: 999px; background: var(--bg-raised); border: 1px solid var(--border-subtle); font-weight: 600; color: var(--text-secondary); }
.report-shown__chip--add { border-style: dashed; color: var(--accent-primary); }
.report-shown__export {
    display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 6px 12px; border-radius: 8px;
    background: var(--bg-raised); border: 1px solid var(--border-strong); font-weight: 600;
}
.report-shown__body { display: grid; grid-template-columns: 200px minmax(0, 1fr); }
.report-shown__toolbox { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-right: 1px solid var(--border-subtle); background: color-mix(in srgb, var(--bg-sidebar) 60%, transparent); }
.report-shown__toolbox .label { margin-bottom: 4px; }
.report-shown__tool { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg-raised); border: 1px solid var(--border-subtle); font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.report-shown__tool--dragged { animation: report-shown-grab 1.4s ease 0.5s both; }
.report-shown__sheet { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; align-items: start; padding: 16px; }

.report-shown__table { min-width: 0; overflow-x: auto; }
.report-shown__head, .report-shown__row { display: grid; grid-template-columns: minmax(8.5em, 1.7fr) repeat(6, minmax(3.4em, 1fr)); align-items: center; min-width: 32em; }
.report-shown__head { padding: 0 4px 6px; border-bottom: 1px solid var(--border-strong); }
.report-shown__heading {
    position: relative; padding: 6px; border-radius: 6px; cursor: pointer; text-align: right;
    font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted);
}
.report-shown__heading:first-child { text-align: left; }
.report-shown__heading input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.report-shown__heading:hover { color: var(--text-primary); background: var(--bg-raised); }
.report-shown__heading:has(input:checked) { color: var(--accent-primary); }
.report-shown__heading:has(input:checked)::after { content: " ▾"; }
.report-shown__heading:has(input:focus-visible) { outline: 2px solid var(--accent-primary); }
.report-shown__rows { display: flex; flex-direction: column; }
.report-shown__row { order: var(--by-hands); padding: 9px 10px; border-bottom: 1px solid var(--border-subtle); font-weight: 600; font-variant-numeric: tabular-nums; }
.report-shown__row > span:not(:first-child) { text-align: right; }
.report-shown__row:hover { background: var(--bg-raised); }
.report-shown__who { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-shown__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-muted); }
.report-shown__dot--fish { background: var(--marker-fish); }
.report-shown__dot--reg { background: var(--marker-reg); }
.report-shown__dot--whale { background: var(--marker-whale); }
.report-shown:has(input[value="player"]:checked) .report-shown__row { order: var(--by-player); }
.report-shown:has(input[value="vpip"]:checked) .report-shown__row { order: var(--by-vpip); }
.report-shown:has(input[value="pfr"]:checked) .report-shown__row { order: var(--by-pfr); }
.report-shown:has(input[value="3b"]:checked) .report-shown__row { order: var(--by-3b); }
.report-shown:has(input[value="wtsd"]:checked) .report-shown__row { order: var(--by-wtsd); }
.report-shown:has(input[value="wsd"]:checked) .report-shown__row { order: var(--by-wsd); }

.report-shown__chart {
    display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 12px;
    background: var(--bg-raised); border: 1px solid var(--border-subtle); animation: report-shown-land 0.8s ease 1.5s both;
}
.report-shown__chart-title { margin-bottom: 2px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.report-shown__chart-title b { color: var(--text-primary); }
.report-shown__bar { display: grid; grid-template-columns: 6.5em minmax(0, 1fr) 2em; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
.report-shown__bar > span:last-child { text-align: right; }
.report-shown__bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.report-shown__bar-track { height: 8px; border-radius: 4px; background: var(--bg-canvas); overflow: hidden; }
.report-shown__bar-fill { display: block; height: 100%; border-radius: 4px; }

@keyframes report-shown-grab {
    0% { transform: none; }
    30%, 60% { transform: translate(6px, -3px) rotate(-2deg); border-color: var(--accent-primary); box-shadow: 0 12px 24px -8px rgba(37, 198, 133, 0.6); }
    100% { transform: none; }
}
@keyframes report-shown-land {
    0% { opacity: 0; transform: translateX(-40px) scale(0.96); outline: 2px dashed var(--accent-primary); }
    70% { opacity: 1; outline: 2px dashed var(--accent-primary); }
    100% { opacity: 1; transform: none; outline: 2px dashed transparent; }
}

/* ── The tables on a monitor ────────────────────────────────────────────────── */

.tables-shown { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; max-width: 1000px; }
.tables-shown__monitor { width: 100%; padding: 12px; border-radius: 18px; background: #0b0f14; border: 1px solid var(--border-strong); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8); }
.tables-shown__screen {
    position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 8px;
    background: radial-gradient(ellipse at 30% 20%, #1b2a3a, #0d141c 70%);
}
.tables-shown__stand { display: block; width: 18%; height: 12px; margin: 10px auto -2px; border-radius: 0 0 8px 8px; background: #1a2029; }
.tables-shown__table {
    position: absolute; left: var(--l6); top: var(--t6); width: var(--w6); height: var(--h6); opacity: var(--o6);
    container-type: inline-size; display: flex; flex-direction: column; overflow: hidden;
    border-radius: 5px; background: #10161d; border: 1px solid #2b3440; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    transition: left 700ms cubic-bezier(.2, .7, .2, 1), top 700ms cubic-bezier(.2, .7, .2, 1), width 700ms cubic-bezier(.2, .7, .2, 1), height 700ms cubic-bezier(.2, .7, .2, 1), opacity 400ms ease;
}
.tables-shown:has(input[value="1"]:checked) .tables-shown__table { left: var(--l1); top: var(--t1); width: var(--w1); height: var(--h1); opacity: var(--o1); }
.tables-shown:has(input[value="2"]:checked) .tables-shown__table { left: var(--l2); top: var(--t2); width: var(--w2); height: var(--h2); opacity: var(--o2); }
.tables-shown:has(input[value="4"]:checked) .tables-shown__table { left: var(--l4); top: var(--t4); width: var(--w4); height: var(--h4); opacity: var(--o4); }
.tables-shown:has(input[value="auto"]:checked) .tables-shown__table { animation: tables-shown-auto 16s ease-in-out infinite; }
.tables-shown:has(input[value="auto"]:checked) .tables-shown__count--1 { animation: tables-shown-lit-1 16s infinite; }
.tables-shown:has(input[value="auto"]:checked) .tables-shown__count--2 { animation: tables-shown-lit-2 16s infinite; }
.tables-shown:has(input[value="auto"]:checked) .tables-shown__count--4 { animation: tables-shown-lit-4 16s infinite; }
.tables-shown:has(input[value="auto"]:checked) .tables-shown__count--6 { animation: tables-shown-lit-6 16s infinite; }
.tables-shown:has(.tables-shown__monitor:hover) * { animation-play-state: paused; }

.tables-shown__title { display: flex; align-items: center; gap: 2cqw; padding: 1.6cqw 3cqw; background: #1b232d; font-size: 4cqw; font-weight: 600; color: #c9d1d9; white-space: nowrap; overflow: hidden; }
.tables-shown__number { display: inline-flex; align-items: center; justify-content: center; width: 6cqw; height: 6cqw; border-radius: 50%; background: var(--accent-primary); color: #06130d; font-size: 3.4cqw; font-weight: 700; }
.tables-shown__felt { position: relative; flex: 1; }
.tables-shown__felt::before {
    content: ""; position: absolute; inset: 16% 12%; border-radius: 50%;
    background: radial-gradient(ellipse at 50% 40%, #1d6b51 0%, var(--bg-felt) 60%, #0a2a20 100%); box-shadow: 0 0 0 1.4cqw #1a2029;
}
.tables-shown__seat { position: absolute; width: 7cqw; height: 7cqw; border-radius: 50%; transform: translate(-50%, -50%); background: #2b3440; border: 0.6cqw solid #3d4a59; }
.tables-shown__seat--0 { left: 50%; top: 88%; }
.tables-shown__seat--1 { left: 11%; top: 66%; }
.tables-shown__seat--2 { left: 14%; top: 22%; }
.tables-shown__seat--3 { left: 50%; top: 9%; }
.tables-shown__seat--4 { left: 86%; top: 22%; }
.tables-shown__seat--5 { left: 89%; top: 66%; }
.tables-shown__panel { position: absolute; left: 5%; top: 34%; width: 22cqw; height: 9cqw; border-radius: 1cqw; background: rgba(20, 20, 20, 0.92); border-left: 1.2cqw solid var(--text-muted); }
.tables-shown__panel--right { left: auto; right: 5%; }
.tables-shown__panel--fish { border-left-color: var(--marker-fish); }
.tables-shown__panel--reg { border-left-color: var(--marker-reg); }
.tables-shown__panel--whale { border-left-color: var(--marker-whale); }
.tables-shown__hole { position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%); display: flex; gap: 1cqw; }
.tables-shown__hole span { width: 5.5cqw; height: 7.8cqw; border-radius: 0.8cqw; background: var(--card-face); }

@keyframes tables-shown-auto {
    0%, 20% { left: var(--l1); top: var(--t1); width: var(--w1); height: var(--h1); opacity: var(--o1); }
    25%, 45% { left: var(--l2); top: var(--t2); width: var(--w2); height: var(--h2); opacity: var(--o2); }
    50%, 70% { left: var(--l4); top: var(--t4); width: var(--w4); height: var(--h4); opacity: var(--o4); }
    75%, 95% { left: var(--l6); top: var(--t6); width: var(--w6); height: var(--h6); opacity: var(--o6); }
    100% { left: var(--l1); top: var(--t1); width: var(--w1); height: var(--h1); opacity: var(--o1); }
}
@keyframes tables-shown-lit-1 { 0%, 22% { color: var(--accent-primary); border-color: var(--accent-primary); } 25%, 100% { color: var(--text-secondary); } }
@keyframes tables-shown-lit-2 { 0%, 22% { color: var(--text-secondary); } 25%, 47% { color: var(--accent-primary); border-color: var(--accent-primary); } 50%, 100% { color: var(--text-secondary); } }
@keyframes tables-shown-lit-4 { 0%, 47% { color: var(--text-secondary); } 50%, 72% { color: var(--accent-primary); border-color: var(--accent-primary); } 75%, 100% { color: var(--text-secondary); } }
@keyframes tables-shown-lit-6 { 0%, 72% { color: var(--text-secondary); } 75%, 97% { color: var(--accent-primary); border-color: var(--accent-primary); } 100% { color: var(--text-secondary); } }

/* ── Tablets and phones ────────────────────────────────────────────────────── */

/* The chart steps under the table while the table still has room for every column beside the toolbox. */
@media (max-width: 1100px) {
    .report-shown__sheet { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .report-shown__body { grid-template-columns: minmax(0, 1fr); }
    .report-shown__toolbox { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border-subtle); }
    .report-shown__toolbox .label { display: none; }
}

@media (max-width: 640px) {
    .report-shown__sheet { padding: 12px; }
    .tables-shown__monitor { padding: 8px; }
}

/* ── For a reader who asks for less motion ──────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .report-shown *, .tables-shown * { animation: none !important; transition: none !important; }
}
