/* ============================================================
   Display page - big screen layout
   ============================================================ */

/* --- Layout ------------------------------------------------- */

body {
    background: #111;
    display: block;
    padding: 0;
}

.display-header {
    position: relative;
    text-align: center;
    padding: 0.6rem 1rem;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
}

.display-header h1 {
    font-size: 1.4rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-accent);
    font-weight: normal;
}

/* Global spotlight toggle button — subtle, top-right of the header */
.display-spotlight-toggle {
    position: absolute;
    top: 50%;
    right: 0.8rem;
    transform: translateY(-50%);
    background: none;
    border: 1px solid #444;
    color: #888;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s, color 0.2s, border-color 0.2s;
}
.display-spotlight-toggle:hover {
    opacity: 1;
    color: #d4b800;
    border-color: #d4b800;
}
/* When spotlight is disabled, the button becomes visually muted */
.display-spotlight-toggle.is-spotlight-off {
    color: #444;
    border-color: #333;
    opacity: 0.4;
}
.display-spotlight-toggle.is-spotlight-off:hover {
    opacity: 0.9;
    color: #888;
    border-color: #666;
}

.heats-grid {
    display: grid;
    /* Responsive: auto-fill columns of min 220px */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.8rem;
    padding: 0.8rem;
}

/* --- Heat card --------------------------------------------- */

.heat-card {
    border-radius: 6px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border: 3px solid transparent;
    transition: opacity 0.3s;
}

/* State: not yet started - fade only the card content, not the popup */
.heat-card.state-waiting > :not(.heat-popup) {
    opacity: 0.75;
}

/* State: running */
.heat-card.state-running {
    box-shadow: 0 0 12px 2px var(--heat-glow);
}

/* State: stopped by admin */
.heat-card.state-stopped > :not(.heat-popup) {
    opacity: 0.45;
    filter: grayscale(40%);
}

.heat-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
}

.heat-category {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.6;
}

.heat-name {
    font-weight: bold;
}

/* Red blinking dot - visible only when card is state-running */
.heat-live {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e02020;
    flex-shrink: 0;
    /* Hidden by default */
    opacity: 0;
    pointer-events: none;
}

.heat-card.state-running .heat-live {
    animation: live-blink 1.2s ease-in-out infinite;
}

@keyframes live-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

.heat-start-time {
    font-family: monospace;
    font-size: 0.8rem;
}

.heat-timer {
    font-family: monospace;
    font-size: 2rem;
    text-align: center;
    letter-spacing: 0.05em;
    line-height: 1.1;
}

.heat-status {
    font-size: 0.7rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.7;
    min-height: 1em;
}

/* --- Heat details popup ------------------------------------ */

.heat-card {
    position: relative; /* anchor for popup */
}

.heat-popup {
    display: none;
    /* Detached from card flow - positioned via JS relative to viewport.
       pointer-events disabled so it never steals the card hover (which would
       flicker the popup open/closed when the cursor reaches it). */
    pointer-events: none;
    position: fixed;
    z-index: 1000;
    min-width: 200px;
    max-width: 280px;
}

.heat-popup.is-open {
    display: block;
}

.heat-popup.is-open {
    display: block;
}

.heat-popup__inner {
    background: #0f0f0f;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 0.7rem 0.9rem;
    font-size: 0.75rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    color: #ccc;
}

.heat-popup__title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #888;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid #333;
    padding-bottom: 0.4rem;
}

.heat-popup__team {
    margin-bottom: 0.6rem;
}

.heat-popup__team:last-child {
    margin-bottom: 0;
}

.heat-popup__team-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #aaa;
    margin-bottom: 0.2rem;
}

.heat-popup__athlete {
    display: flex;
    gap: 0.5rem;
    padding: 0.1rem 0;
}

.heat-popup__bib {
    color: #666;
    font-family: monospace;
    min-width: 2.5rem;
}

.heat-popup__athlete-name {
    color: #ddd;
}

.heat-popup__empty {
    color: #555;
    font-style: italic;
}

/* ============================================================
   Spotlight — card zoomed to center 30 s before start, back 10 s after
   ============================================================ */

/* Dark overlay behind the spotlight card */
#spotlight-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 500;
}

#spotlight-overlay.is-active {
    display: block;
}

.heat-card.state-spotlight {
    position: fixed;
    z-index: 600;
    /* Center on screen */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* Large format */
    width: min(480px, 90vw);
    /* Reset grid sizing */
    height: auto;
    /* Enhance visuals */
    box-shadow: 0 0 60px 10px var(--heat-glow), 0 0 0 2px var(--heat-glow);
    font-size: 1.4em;
}

.heat-card.state-spotlight .heat-timer {
    font-size: 3.5rem;
}

/* Team list hidden in normal grid view */
.heat-spotlight-teams {
    display: none;
}

/* Shown only during spotlight */
.heat-card.state-spotlight .heat-spotlight-teams {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.8rem;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 0.6em; /* relative to the 1.4em card zoom */
}

.heat-spotlight-team {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.heat-spotlight-team__name {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.95;
}

.heat-spotlight-team__athlete {
    opacity: 0.6;
    font-size: 0.85em;
}

/* ============================================================
   Color themes - each heat-card gets a color class
   Background is a dark tint of the color; text is legible.
   ============================================================ */

.heat-yellow  { --heat-glow: #d4b800; background: #2e2a00; border-color: #d4b800; color: #f5e44a; }
.heat-black   { --heat-glow: #888;    background: #1c1c1c; border-color: #666;    color: #cccccc; }
.heat-orange  { --heat-glow: #e06000; background: #2e1500; border-color: #e06000; color: #ff9940; }
.heat-navy    { --heat-glow: #2255cc; background: #080f2e; border-color: #2255cc; color: #7aaaff; }
.heat-red     { --heat-glow: #cc2222; background: #2e0808; border-color: #cc2222; color: #ff6b6b; }
.heat-gold    { --heat-glow: #c8960c; background: #2a1e00; border-color: #c8960c; color: #ffd060; }
.heat-cyan    { --heat-glow: #00b4cc; background: #002a30; border-color: #00b4cc; color: #4de8ff; }
.heat-pink    { --heat-glow: #cc2288; background: #2e0820; border-color: #cc2288; color: #ff80cc; }
.heat-green   { --heat-glow: #22aa44; background: #042010; border-color: #22aa44; color: #55ee80; }
.heat-purple  { --heat-glow: #8822cc; background: #1a042e; border-color: #8822cc; color: #cc88ff; }
