/* RESET & WHD RUN 2026 VARIABLES */
:root {
    --whd-red: #E7192D;
    --font-heading: 'Oswald', sans-serif;
    
    /* CALIBRATION COORDINATES (Adjust these percentages to perfectly align with the artwork) */
    --bib-area-top: 38.5%;    /* Vertical center of the white BIB box */
    --name-area-top: 63%;   /* Vertical center of the blue Name box */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #000; /* Black borders if aspect ratio doesn't perfectly match screen */
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
}

/* 
 * ARTBOARD CONTAINER
 * Maintains the exact 933x1600 aspect ratio of the artwork.
 * It will scale to fill the height or width of the screen while preserving aspect ratio.
 */
.artboard {
    position: relative;
    width: 100vw;
    height: 100vh;
    /* CSS aspect-ratio ensures internal coordinate system is perfectly preserved */
    max-width: calc(100vh * (933 / 1600));
    max-height: calc(100vw * (1600 / 933));
    display: block;
    overflow: hidden;
}

/* BACKGROUND ARTWORK */
.bg-artwork {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    pointer-events: none;
}

/* STATE LAYERS */
.state-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
}

.state-layer.active {
    opacity: 1;
    pointer-events: auto;
}

.state-layer.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ==================================================
 * DYNAMIC OVERLAY AREAS 
 * Positioned absolutely based on percentage coordinates.
 * ================================================== */

.bib-area-overlay {
    position: absolute;
    top: var(--bib-area-top);
    left: 50%;
    width: 85%; /* Ensures text doesn't touch the edges of the white box */
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.name-area-overlay {
    position: absolute;
    top: var(--name-area-top);
    left: 50%;
    width: 80%; /* Keeps the name safely inside the blue area */
    transform: translate(-50%, -50%);
    text-align: center;
}

/* ==================================================
 * TYPOGRAPHY
 * ================================================== */

/* Dynamic BIB Number (Huge, Black, Bold) */
.bib-number {
    font-size: clamp(10rem, 38vw, 25rem);
    font-weight: 700;
    font-style: italic; /* Slanted athletic look */
    line-height: 1;
    letter-spacing: -0.02em;
    color: #000000; /* Must be black against the white artwork box */
    display: block;
    width: 100%;
}

/* Dynamic Participant Name (White, Scalable) */
.participant-name {
    font-size: clamp(2.5rem, 8vw, 5.5rem);
    font-weight: 700;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #FFFFFF;
    white-space: normal; /* Allow multiple lines */
    line-height: 1.1;
    text-overflow: clip;
    display: block;
    width: 100%;
}

/* Loading and Error Texts */
.status-msg {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 700;
    color: var(--whd-red);
    text-transform: uppercase;
}
.error-text {
    color: var(--whd-red);
}
.status-sub {
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 700;
    color: #FFFFFF;
    text-transform: uppercase;
}


/* ==================================================
 * READY STATE - SCANNER UI
 * ================================================== */
.scanner-ui {
    position: absolute;
    top: var(--bib-area-top);
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50vw;
    height: 50vw;
    max-width: 350px;
    max-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-target {
    width: 100%;
    height: 100%;
    position: relative;
    background: transparent;
}

.corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border-color: var(--whd-red); /* Using red scanner corners on white bg */
    border-style: solid;
}

.top-left { top: 0; left: 0; border-width: 6px 0 0 6px; }
.top-right { top: 0; right: 0; border-width: 6px 6px 0 0; }
.bottom-left { bottom: 0; left: 0; border-width: 0 0 6px 6px; }
.bottom-right { bottom: 0; right: 0; border-width: 0 6px 6px 0; }

.scan-line {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 6px;
    background: var(--whd-red);
    box-shadow: 0 0 25px 5px rgba(231, 25, 45, 0.5);
    animation: scanVertical 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes scanVertical {
    0% { top: 2%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 98%; opacity: 0; }
}


/* ==================================================
 * ANIMATIONS
 * ================================================== */
.slide-up {
    animation: slideUpAnim 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.reveal-vertical {
    clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
    animation: revealVertAnim 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.1s;
}

@keyframes slideUpAnim {
    from { transform: translate(-50%, 40px); opacity: 0; }
    to { transform: translate(-50%, -50%); opacity: 1; }
}

@keyframes revealVertAnim {
    from { clip-path: polygon(0 0, 100% 0, 100% 0, 0 0); transform: translate(-50%, -50%) scale(0.95); }
    to { clip-path: polygon(0 -20%, 100% -20%, 100% 120%, 0 120%); transform: translate(-50%, -50%) scale(1); }
}

.pulse-loading {
    animation: pulseLoadAnim 1.5s ease-in-out infinite;
}

@keyframes pulseLoadAnim {
    0% { opacity: 0.3; transform: translate(-50%, -50%) scale(0.98); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0.3; transform: translate(-50%, -50%) scale(0.98); }
}
