/* =============================================================
   display.css — Whistle Display Mode (broadcast scoreboard)
   Completely separate from style.css — do not import or modify style.css.
   ============================================================= */

/* ---- Reset / base ---- */
#display-mode,
#display-mode * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---- Root container ---- */
#display-mode {
    position: fixed;
    inset: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1000;
    background: #106386;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-bottom: clamp(40px, 6vh, 80px);
    font-family: 'Barlow Condensed', 'Metropolis', sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#display-mode.hidden {
    display: none;
}

/* ---- Settings button (top-right cog) ---- */
.dm-settings-btn {
    position: absolute;
    top: clamp(12px, 2vh, 24px);
    right: clamp(12px, 2vw, 24px);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: clamp(40px, 5vw, 56px);
    height: clamp(40px, 5vw, 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.3s ease;
    z-index: 20;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

.dm-settings-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    transform: rotate(45deg);
}

.dm-settings-btn svg {
    width: clamp(20px, 2.4vw, 28px);
    height: clamp(20px, 2.4vw, 28px);
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---- Fullscreen button (below settings cog) ---- */
.dm-fullscreen-btn {
    position: absolute;
    top: calc(clamp(40px, 5vw, 56px) + clamp(12px, 2vh, 24px) + 8px);
    right: clamp(12px, 2vw, 24px);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: clamp(40px, 5vw, 56px);
    height: clamp(40px, 5vw, 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.3s ease;
    z-index: 20;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

.dm-fullscreen-btn svg {
    width: clamp(20px, 2.4vw, 28px);
    height: clamp(20px, 2.4vw, 28px);
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---- Main area (clock + down) ---- */
.dm-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0 20px 8px;
}

.dm-clock-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(4px, 1vh, 12px);
}

/* Period label */
.dm-period {
    font-size: clamp(0.9rem, 2vw, 1.6rem);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0;
    line-height: 1;
    text-transform: uppercase;
}

/* Big game clock */
.dm-game-clock {
    font-size: clamp(6rem, 22vw, 20rem);
    font-weight: 800;
    color: #ffffff;
    line-height: 0.9;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    min-width: 5ch;
    text-align: center;
    margin:-15px 0 15px 0 !important
}

/* Two-minute warning pulse */
.dm-game-clock.dm-warning {
    animation: dm-clock-warning-pulse 1s ease-in-out infinite;
}

@keyframes dm-clock-warning-pulse {
    0%, 100% { color: #ffffff; }
    50% { color: #ff6b6b; }
}

/* Down indicator */
.dm-down {
    font-size: clamp(1.2rem, 3.5vw, 3rem);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.03em;
    line-height: 1;
    text-transform: uppercase;;
}

/* Play clock pill */
.dm-play-clock-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: clamp(4px, 0.8vh, 12px) !important;
    padding: 4px 15px 6px 15px !important;
    border-radius: 8px;
    background: #ffffff;
}

.dm-play-clock-label {
    display: none;
}

.dm-play-clock {
    font-size: clamp(1.4rem, 2.8vw, 2.6rem);
    font-weight: 700;
    color: #106386;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* ---- Lower third strip ---- */
.dm-lower-third {
    width: 100%;
    background: transparent;
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
}

/* Team block (shared) */
.dm-team {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1.5vw, 24px);
    flex: 1;
    padding: clamp(10px, 1.5vh, 20px) clamp(14px, 2.5vw, 40px);
}

.dm-team-home {
    justify-content: center;
}

.dm-team-away {
    justify-content: center;
    flex-direction: row-reverse;
}

/* Team logo container */
.dm-team-logo-wrap {
    width: clamp(44px, 8vw, 88px);
    height: clamp(44px, 8vw, 88px);
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
}

.dm-team-logo {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dm-team-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Logo fallback initials circle */
.dm-logo-placeholder {
    width: clamp(40px, 7vw, 80px);
    height: clamp(40px, 7vw, 80px);
    border-radius: 50%;
    background: rgba(16, 99, 134, 0.3);
    border: 2px solid rgba(16, 99, 134, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.9rem, 2vw, 1.8rem);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1;
}

/* Team info block */
.dm-team-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(2px, 0.4vh, 6px);
}

.dm-team-away .dm-team-info {
    align-items: center;
    text-align: center;
}

.dm-team-name {
    font-size: clamp(0.75rem, 2vw, 1.6rem);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0;
    line-height: 1;
    white-space: normal;
    word-break: break-word;
    width: 100%;
    text-align: center;
    text-transform: uppercase;
}

.dm-team-score {
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.dm-team-timeouts {
    display: flex;
    gap: clamp(4px, 0.6vw, 8px);
    align-items: center;
}

.dm-timeout-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffffff;
    margin: 0 3px;
    opacity: 1;
    transition: background 0.3s ease, opacity 0.3s ease;
}

.dm-timeout-dot.dm-used {
    background: rgba(255, 255, 255, 0.25);
}

/* Centre divider — hidden; two-column layout needs no separator */
.dm-divider {
    display: none;
}

.dm-vs {
    display: none;
}

/* ---- Branding ---- */
.dm-branding {
    position: absolute;
    bottom: clamp(10px, 1.5vh, 20px);
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(0.75rem, 1.2vw, 1rem);
    color: #ffffff;
    font-weight: 500;
    letter-spacing: 0.04em;
    pointer-events: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* ---- Settings overlay ---- */
.dm-settings-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.dm-settings-overlay.hidden {
    display: none;
}

.dm-settings-panel {
    background: #151e30;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: clamp(16px, 3vw, 32px) !important;
    width: clamp(280px, 38vw, 440px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.dm-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: clamp(16px, 2.5vh, 28px);
    padding-bottom: clamp(12px, 1.5vh, 20px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dm-settings-header h2 {
    font-family: 'Barlow Condensed', 'Metropolis', sans-serif;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.dm-settings-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: clamp(32px, 3.5vw, 40px);
    height: clamp(32px, 3.5vw, 40px);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
}

.dm-settings-close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.dm-settings-body {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

/* Toggle row */
.dm-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    user-select: none;
}

.dm-toggle-row:last-child {
    border-bottom: none;
}

.dm-toggle-label {
    font-size: clamp(0.85rem, 1.4vw, 1.05rem);
    color: #d0d8e8;
    font-weight: 500;
    line-height: 1.3;
}

/* Hide real checkbox */
.dm-toggle-row input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    pointer-events: none;
}

/* Custom toggle track */
.dm-toggle-slider {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    flex-shrink: 0;
    transition: background 0.3s ease;
    cursor: pointer;
}

/* Toggle thumb */
.dm-toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: transform 0.25s ease, background 0.25s ease;
}

.dm-toggle-row input:checked + .dm-toggle-slider {
    background: #106386;
}

.dm-toggle-row input:checked + .dm-toggle-slider::after {
    transform: translateX(24px);
    background: #ffffff;
}

/* ---- State modifier classes ---- */

/* Clock-only mode: hide everything except game clock and period */
#display-mode.dm-clock-only .dm-lower-third,
#display-mode.dm-clock-only .dm-down,
#display-mode.dm-clock-only .dm-play-clock-wrap {
    display: none;
}

/* Hide play clock */
#display-mode.dm-hide-play-clock .dm-play-clock-wrap {
    display: none;
}

/* Hide timeouts */
#display-mode.dm-hide-timeouts .dm-team-timeouts {
    display: none;
}

/* ---- Responsive: portrait / small screens ---- */
@media (orientation: portrait) {
    .dm-game-clock {
        font-size: clamp(5rem, 28vw, 14rem);
        margin: 0 0 8px 0 !important;
    }
    .dm-period {
        margin-bottom: 0;
    }
    .dm-down {
        margin-top: 0;
    }

    .dm-lower-third {
        flex-direction: column;
        gap: 8px;
    }

    #display-mode.dm-scores-first .dm-lower-third {
        gap: clamp(16px, 4vh, 40px);
    }

    #display-mode {
        padding-top: clamp(60px, 10vh, 100px);
    }

    .dm-divider {
        display: none;
    }

    .dm-team {
        width: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .dm-team-info {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }

    .dm-team-name {
        text-align: left;
        flex: 1;
    }

    .dm-team-score {
        text-align: right;
        margin-left: auto;
    }

    #display-mode.dm-scores-first .dm-team {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    #display-mode.dm-scores-first .dm-team-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    #display-mode.dm-scores-first .dm-team-name {
        text-align: center;
        width: 100%;
    }

    #display-mode.dm-scores-first .dm-team-score {
        text-align: center;
        margin-left: 0;
        font-size: clamp(3rem, 20vw, 8rem);
    }

    #display-mode.dm-scores-first .dm-team-timeouts {
        justify-content: center;
    }

    .dm-team-logo-wrap {
        display: none;
    }
}

@media (orientation: portrait) and (max-width: 480px) {
    .dm-lower-third {
        flex-direction: column;
        padding: 0 16px;
    }

    .dm-team-logo-wrap {
        display: none;
    }

    #display-mode.dm-scores-first .dm-team {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
        padding-bottom: clamp(8px, 2vh, 16px);
    }

    #display-mode.dm-scores-first .dm-team-away {
        border-bottom: none;
    }

    #display-mode.dm-scores-first .dm-team-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    #display-mode.dm-scores-first .dm-team-name {
        text-align: center;
        font-size: clamp(0.9rem, 4.5vw, 1.3rem);
    }

    #display-mode.dm-scores-first .dm-team-score {
        text-align: center;
        font-size: clamp(3rem, 20vw, 8rem);
        margin: 0;
    }

    #display-mode.dm-scores-first .dm-team-timeouts {
        justify-content: center;
    }
}

/* ---- Landscape TVs / large displays ---- */
@media (min-width: 1920px) {
    .dm-game-clock {
        font-size: clamp(14rem, 18vw, 24rem);
    }

    .dm-team-score {
        font-size: clamp(5rem, 8vw, 9rem);
    }

    .dm-team-name {
        font-size: clamp(1.4rem, 2.2vw, 2.4rem);
        max-width: clamp(200px, 22vw, 440px);
    }

}

@media (max-width: 737px) {
    .dm-lower-third {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

/* ---- Score notification overlay ---- */
.dm-score-notify {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 2vh, 20px);
    animation: dm-notify-in 0.3s ease-out;
}
.dm-score-notify.hidden {
    display: none;
}
@keyframes dm-notify-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
.dm-score-notify-team {
    font-size: clamp(1rem, 3vw, 2rem);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    text-align: center;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.dm-score-notify-type {
    font-size: clamp(3rem, 12vw, 9rem);
    font-weight: 800;
    color: #ffffff;
    text-align: center;
    line-height: 1;
    letter-spacing: -0.02em;
}
@keyframes dm-flash-warning {
    0%   { background-color: #106386; }
    50%  { background-color: rgba(220, 40, 40, 0.5); }
    100% { background-color: #106386; }
}
#display-mode.dm-clock-warning {
    animation: dm-flash-warning 1s ease-in-out infinite;
}

/* ---- Scores First layout ---- */
#display-mode.dm-scores-first .dm-main {
    order: 2;
}
#display-mode.dm-scores-first .dm-lower-third {
    order: 1;
    margin-top: clamp(40px, 8vh, 120px);
    margin-bottom: clamp(16px, 3vh, 40px);
}
#display-mode.dm-scores-first .dm-team-score {
    font-size: clamp(5rem, 20vw, 14rem);
}
#display-mode.dm-scores-first .dm-team-name {
    font-size: clamp(1rem, 3vw, 2.5rem);
}
#display-mode.dm-scores-first .dm-game-clock {
    font-size: clamp(3rem, 10vw, 8rem);
    margin: clamp(16px, 3vh, 40px) 0 4px 0 !important;
}
#display-mode.dm-scores-first .dm-period {
    margin-top: clamp(8px, 2vh, 24px);
}
#display-mode.dm-scores-first .dm-down {
    font-size: clamp(0.9rem, 2vw, 1.6rem);
    margin-top: 2px;
}

/* ---- Period end overlay (Half Time / Full Time) ---- */
.dm-period-end {
    position: absolute;
    inset: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 99, 134, 0.92);
    animation: dm-notify-in 0.4s ease-out;
}
.dm-period-end.hidden {
    display: none;
}
.dm-period-end-label {
    font-size: clamp(3rem, 14vw, 10rem);
    font-weight: 800;
    color: #ffffff;
    text-align: center;
    letter-spacing: -0.02em;
    line-height: 1;
}
