/* Clock pages — player clock (/clock/{token}), the clock cell in the
   tournament match list, private clock entry (/clock/new) and the ZMF
   Clock Bridge (/clock-bridge/{broadcastId}).

   Served statically like css/broadcast.css: the WASM client project's
   scoped-CSS bundle is not imported by the host bundle in this solution
   (no @import is generated), so component .razor.css files under the
   Client project silently never load. Every selector here is rooted
   under a unique page class (.clock-root, .new-clock, .clock-bridge) or a
   shared cell class (.clock-cell), which gives the same isolation in practice. */

/* ── Player clock ────────────────────────────────────────────── */
/* DrawControl's geometry: the two player zones side by side with a slim
   vertical control strip between them — the phone lies flat between the
   players with the text running along its long side, so both read it the
   same way from their seats. Each zone stacks score → name → time → delay
   → time bar. Palette and type stay GammonBase (navy + gold). */

/* No body-level scrollbars on phones: 100vh overshoots the visible area
   while the URL bar is shown, which forces a phantom scroll. Lock the
   document to the dynamic viewport while the clock is mounted. */
html:has(.clock-root),
body:has(.clock-root) {
    height: 100dvh;
    min-height: 0 !important;
    overflow: hidden !important;
    margin: 0;
}

.clock-root {
    position: fixed;
    inset: 0;
    height: 100dvh;
    display: flex;
    flex-direction: row;
    background: #0e0e1a;
    color: #f4f1ea;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.clock-msg {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0e0e1a;
    color: #b9b2a3;
    font-size: 1.4rem;
}

/* ── Player zones ── */

.clock-root .zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #1a1a2e;
    transition: background 0.15s ease;
    min-width: 0;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.clock-root .zone.active {
    background: linear-gradient(180deg, #3a2f10, #2a2208);
}

.clock-root .zone.expired {
    background: #3a1414;
}

.clock-root .zone:active {
    background: rgba(255, 193, 7, 0.22);
}

.clock-root .zone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem 1.25rem;
}

.clock-root .score-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.clock-root .score {
    font-size: clamp(2.25rem, 7vmax, 4.5rem);
    font-weight: 700;
    color: #d8d2c4;
    min-width: 2ch;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.clock-root .score-btn {
    width: clamp(2rem, 6vmin, 3rem);
    height: clamp(2rem, 6vmin, 3rem);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
    color: #f4f1ea;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.clock-root .label {
    min-height: 2rem;
    display: flex;
    align-items: center;
    font-size: clamp(0.875rem, 2vmax, 1.25rem);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #9a9384;
    white-space: nowrap;
}

.clock-root .zone.active .label {
    color: #ffc107;
}

.clock-root .time {
    font-size: clamp(3rem, 8vmax, 6rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    letter-spacing: -0.02em;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.clock-root .zone.active .time {
    color: #ffc107;
}

.clock-root .zone.expired .time {
    color: #ff6347;
}

.clock-root .delay {
    font-size: clamp(0.85rem, 1.6vmax, 1.1rem);
    font-weight: 700;
    color: #9be39b;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Time bar ── */

.clock-root .bar {
    width: min(80%, 20rem);
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    overflow: hidden;
}

.clock-root .bar-fill {
    height: 100%;
    background: #ffc107;
    border-radius: 2px;
    transition: width 0.1s linear;
}

.clock-root .zone.expired .bar-fill {
    background: #ff6347;
}

/* ── Center control strip ── */

.clock-root .strip {
    flex: 0 0 auto;
    min-width: clamp(4rem, 10vw, 6rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    padding: 0.75rem 0.5rem;
    background: #0e0e1a;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.clock-root .target {
    font-size: clamp(0.9rem, 2vmax, 1.2rem);
    font-weight: 700;
    color: #d8d2c4;
    text-align: center;
    line-height: 1.2;
    max-width: 8rem;
}

.clock-root .ctrl {
    width: clamp(2.4rem, 6vmin, 3.2rem);
    height: clamp(2.4rem, 6vmin, 3.2rem);
    border-radius: 8px;
    border: 1px solid rgba(255, 193, 7, 0.4);
    background: rgba(255, 193, 7, 0.08);
    color: #ffc107;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

/* Pause/play is what a player actually slaps between turns — a chunky
   gold pill-circle, the strip's primary target. */
.clock-root .ctrl-primary {
    width: clamp(3.75rem, 12vmin, 4.5rem);
    height: clamp(3.75rem, 12vmin, 4.5rem);
    border-radius: 999px;
    border: none;
    background: linear-gradient(180deg, #ffcd3c, #f0a500);
    color: #1a1a2e;
    font-size: clamp(1.6rem, 5vmin, 2.2rem);
    box-shadow: 0 6px 18px rgba(255, 193, 7, 0.35);
}

/* Fullscreen — small and dim so it never competes during play. */
.clock-root .ctrl-dim {
    width: clamp(2rem, 5vmin, 2.4rem);
    height: clamp(2rem, 5vmin, 2.4rem);
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #b9b2a3;
    font-size: 0.95rem;
}

/* ── End-of-clock overlay ── */

.clock-root .finished-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.85);
    z-index: 10;
}

.clock-root .finished-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    font-size: clamp(1.6rem, 4vmax, 2.6rem);
    font-weight: 800;
    color: #ffc107;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: center;
}

.clock-root .reset-btn {
    background: linear-gradient(180deg, #ffcd3c, #f0a500);
    color: #1a1a2e;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    cursor: pointer;
    letter-spacing: normal;
    text-transform: none;
}

.clock-root .settings-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.clock-root .settings-panel {
    background: #20203a;
    border: 1px solid rgba(255, 193, 7, 0.35);
    border-radius: 12px;
    padding: 1.2rem 1.4rem;
    width: min(92vw, 22rem);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.clock-root .settings-panel h2 {
    margin: 0 0 0.2rem;
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffc107;
}

.clock-root .settings-panel label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.72rem;
    color: #9a9384;
    text-transform: uppercase;
}

.clock-root .settings-panel input,
.clock-root .settings-panel select {
    background: #161630;
    color: #f4f1ea;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font-size: 1rem;
}

.clock-root .settings-note {
    margin: 0;
    font-size: 0.8rem;
    color: #b9b2a3;
}

.clock-root .settings-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
}

.clock-root .settings-actions .apply {
    background: linear-gradient(180deg, #ffcd3c, #f0a500);
    color: #1a1a2e;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.clock-root .settings-actions .apply:disabled {
    opacity: 0.55;
    cursor: default;
}

.clock-root .settings-actions .cancel {
    background: transparent;
    color: #d8d2c4;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.clock-root .ctrl-text {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.clock-root .qr-panel {
    align-items: center;
    text-align: center;
}

.clock-root .qr-panel .qr {
    width: min(70vw, 280px);
    height: min(70vw, 280px);
    image-rendering: pixelated;
    border-radius: 8px;
    background: #ffffff;
    padding: 8px;
}

.clock-root .qr-link {
    word-break: break-all;
    user-select: text;
}

/* ── Clock QR button + popup (match list, MatchAdmin) ────────── */
/* Lives next to the Clock link on the light admin pages: pops the QR so
   the organizer points the table device at the screen. The image request
   get-or-creates the clock, so it only fires when the popup opens. */
.clock-qr-btn {
    border: 1px solid #6c757d;
    border-radius: 6px;
    background: transparent;
    color: #6c757d;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.45rem;
    cursor: pointer;
    vertical-align: baseline;
}

.clock-qr-btn:hover {
    background: #6c757d;
    color: #ffffff;
}

.clock-qr-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1060; /* above bootstrap card chrome on the admin pages */
}

.clock-qr-panel {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.2rem 1.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.35);
    text-align: center;
}

.clock-qr-panel h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #212529;
}

.clock-qr-img {
    width: min(70vw, 280px);
    height: min(70vw, 280px);
    image-rendering: pixelated;
}

.clock-qr-close {
    border: 1px solid #6c757d;
    border-radius: 8px;
    background: transparent;
    color: #212529;
    padding: 0.4rem 1rem;
    cursor: pointer;
}

.clock-qr-close:hover {
    background: #e9ecef;
}

/* ── Clock cell in the tournament match list ─────────────────── */
.clock-cell {
    white-space: nowrap;
}

.clock-cell .clock-qr-btn {
    margin-left: 0.45rem;
}

.clock-cell .clock-state {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    margin-right: 0.4rem;
}

.clock-cell .clock-state.running {
    color: #198754;
}

.clock-cell .clock-state.expired {
    color: #dc3545;
}

/* ── New private clock ───────────────────────────────────────── */
.new-clock {
    max-width: 640px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    color: #f4f1ea;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

.new-clock h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffc107;
    margin: 0 0 0.2rem;
}

.new-clock .subtitle {
    color: #b9b2a3;
    margin: 0 0 1.2rem;
}

.new-clock .form-card {
    background: #20203a;
    border: 1px solid rgba(255, 193, 7, 0.25);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.new-clock .row {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.new-clock .row label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.7rem;
    color: #9a9384;
    text-transform: uppercase;
    flex: 1 1 8rem;
}

.new-clock .hint {
    margin: 0;
    font-size: 0.8rem;
    color: #b9b2a3;
}

.new-clock .create-btn {
    align-self: flex-start;
    background: linear-gradient(180deg, #ffcd3c, #f0a500);
    color: #1a1a2e;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    cursor: pointer;
}

.new-clock .create-btn:hover {
    filter: brightness(1.05);
}

.new-clock .create-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.new-clock .error {
    background: rgba(255, 99, 71, 0.12);
    border: 1px solid rgba(255, 99, 71, 0.5);
    color: #ffb3a3;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* ── ZMF Clock Bridge ────────────────────────────────────────── */
.clock-bridge {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    color: #f4f1ea;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

.clock-bridge h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffc107;
    margin: 0 0 0.2rem;
}

.clock-bridge .subtitle {
    color: #b9b2a3;
    margin: 0 0 1.2rem;
}

.clock-bridge .warn {
    background: rgba(255, 99, 71, 0.12);
    border: 1px solid rgba(255, 99, 71, 0.5);
    color: #ffb3a3;
    padding: 0.8rem 1rem;
    border-radius: 8px;
}

.clock-bridge .add-btn {
    background: linear-gradient(180deg, #ffcd3c, #f0a500);
    color: #1a1a2e;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1rem;
    cursor: pointer;
}

.clock-bridge .add-btn:hover {
    filter: brightness(1.05);
}

.clock-bridge .empty {
    margin-top: 1rem;
    color: #b9b2a3;
}

.clock-bridge .clock-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 1.1rem;
}

.clock-bridge .clock-card {
    background: #20203a;
    border: 1px solid rgba(255, 193, 7, 0.25);
    border-radius: 10px;
    padding: 0.9rem 1rem;
}

.clock-bridge .clock-card.offline {
    opacity: 0.6;
}

.clock-bridge .head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.clock-bridge .head .name {
    font-weight: 700;
}

.clock-bridge .head .status {
    font-size: 0.78rem;
    color: #9be39b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.clock-bridge .clock-card.offline .head .status {
    color: #ff9a8a;
}

.clock-bridge .head .remove {
    margin-left: auto;
    background: transparent;
    border: none;
    color: #b9b2a3;
    cursor: pointer;
    font-size: 1rem;
}

.clock-bridge .head .remove:hover {
    color: #ff6347;
}

.clock-bridge .preview {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 0.7rem;
}

.clock-bridge .preview .side {
    flex: 1;
    background: #161630;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    border: 1px solid transparent;
}

.clock-bridge .preview .side.active {
    border-color: #ffc107;
    box-shadow: 0 0 0.6rem rgba(255, 193, 7, 0.4);
}

.clock-bridge .preview .side label {
    display: block;
    font-size: 0.7rem;
    color: #9a9384;
    text-transform: uppercase;
}

.clock-bridge .preview .side .time {
    font-size: 1.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.clock-bridge .bind {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.clock-bridge .bind label {
    font-size: 0.8rem;
    color: #b9b2a3;
}

.clock-bridge .bind select {
    flex: 1;
    background: #161630;
    color: #f4f1ea;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
}

.clock-bridge .swap {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    color: #d8d2c4;
    cursor: pointer;
}
