/* run.events access control. A scanning app without chrome: the event's bar, the camera, the result, next.
   The event's color arrives as --event-primary with its readable text color --event-on-primary (EventColors.OnColor);
   results set --result-color and --result-on-color the same way. WCAG 2.1 AA: 4.5:1 text contrast, 44 px targets, a visible
   focus ring, motion only where prefers-reduced-motion allows it. */

:root {
    --surface: #16181D;
    --surface-raised: #23262E;
    --surface-line: #2A2D35;
    --field-line: #3A3F47;
    --ink: #F5F6F8;
    --ink-muted: #C9CDD6;
    --camera: #0E0F12;
    --run-events: #6B4A9E;
    --entry: #1E7B34;
    --decline: #B3123F;
    color-scheme: dark;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--camera);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: 3px solid #111;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px #fff;
}

.ac-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Loading (index.html) */

.ac-loading {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 20px;
    background: var(--run-events);
}

.ac-loading img {
    border-radius: 16px;
    background: #fff;
    padding: 6px;
}

.ac-loading__spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    animation: ac-spin 1s linear infinite;
}

@keyframes ac-spin {
    to { transform: rotate(360deg); }
}

/* The scanner */

.ac {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    height: 100dvh;
}

.ac-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    background: var(--event-primary, var(--run-events));
    color: var(--event-on-primary, #fff);
}

.ac-bar__logo {
    flex: none;
    width: 44px;
    height: 44px;
    padding: 4px;
    border: 0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

.ac-bar__logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ac-bar__event {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ac-bar__status {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.ac-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.ac-chip--offline {
    background: var(--decline);
}

.ac-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-line);
}

.ac-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: var(--surface-raised);
}

.ac-segmented__option {
    min-height: 44px;
    padding: 0 14px;
    border: 2px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-muted);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

/* The chosen option: the event color, a light border and a check, so it reads with any event color (WCAG 1.4.11). */
.ac-segmented__option[aria-pressed="true"] {
    border-color: var(--ink);
    background: var(--event-primary, var(--run-events));
    color: var(--event-on-primary, #fff);
}

.ac-segmented__option[aria-pressed="true"]::before {
    content: "\2713" / "";
    margin-inline-end: 6px;
}

.ac-select {
    min-height: 44px;
    max-width: 100%;
    padding: 0 12px;
    border: 1px solid var(--field-line);
    border-radius: 12px;
    background: var(--surface-raised);
    color: var(--ink);
    font: inherit;
}

.ac-main {
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* Camera */

.ac-camera {
    position: absolute;
    inset: 0;
    background: #000;
}

.ac-camera__video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ac-camera__frame {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(70vw, 60vh, 360px);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.ac-camera__corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 0 solid #fff;
}

.ac-camera__corner--tl { top: 0; left: 0; border-top-width: 5px; border-left-width: 5px; border-top-left-radius: 14px; }
.ac-camera__corner--tr { top: 0; right: 0; border-top-width: 5px; border-right-width: 5px; border-top-right-radius: 14px; }
.ac-camera__corner--bl { bottom: 0; left: 0; border-bottom-width: 5px; border-left-width: 5px; border-bottom-left-radius: 14px; }
.ac-camera__corner--br { bottom: 0; right: 0; border-bottom-width: 5px; border-right-width: 5px; border-bottom-right-radius: 14px; }

.ac-camera__line {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 10%;
    height: 3px;
    border-radius: 3px;
    background: var(--event-primary, var(--run-events));
    box-shadow: 0 0 12px var(--event-primary, var(--run-events));
    animation: ac-sweep 2.4s ease-in-out infinite alternate;
}

@keyframes ac-sweep {
    to { top: 88%; }
}

.ac-camera__message {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    margin: 0;
    padding: 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    text-align: center;
}

.ac-camera__switch {
    position: absolute;
    top: 12px;
    right: 12px;
}

.ac-icon-button {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    cursor: pointer;
}

/* Typed codes */

.ac-code {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--surface-line);
}

.ac-input {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--field-line);
    border-radius: 12px;
    background: var(--camera);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
}

.ac-input::placeholder {
    color: #9CA1AB;
}

/* Buttons */

.ac-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 48px;
    min-height: 48px;
    padding: 0 20px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
}

.ac-button:disabled {
    opacity: 0.6;
    cursor: default;
}

.ac-button--primary {
    padding: 0 14px;
    background: var(--event-primary, var(--run-events));
    color: var(--event-on-primary, #fff);
}

.ac-button--admit,
.ac-button--decline {
    flex: 1;
    min-height: 72px;
    font-size: 1.3rem;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9);
}

.ac-button--admit { background: var(--entry); }
.ac-button--decline { background: var(--decline); }

.ac-button--light {
    background: rgba(255, 255, 255, 0.94);
    color: #111;
}

/* Results */

.ac-result {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 24px 16px;
    background: var(--result-color);
    color: var(--result-on-color);
}

.ac-result--confirm {
    background: var(--surface);
    color: var(--ink);
}

.ac-result__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 560px;
    text-align: center;
}

.ac-result__icon {
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.ac-result__title {
    margin: 0;
    font-size: clamp(1.8rem, 6vw, 2.8rem);
    font-weight: 800;
    line-height: 1.15;
}

.ac-result__attendee {
    margin: 0;
    font-size: clamp(1.4rem, 5vw, 2.2rem);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.ac-result__detail {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.ac-result__photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.7);
    object-fit: cover;
}

.ac-result--returns::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 6px;
    width: 100%;
    background: currentColor;
    opacity: 0.55;
    animation: ac-countdown 2.5s linear forwards;
}

@keyframes ac-countdown {
    from { width: 100%; }
    to { width: 0; }
}

.ac-decision {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.ac-decision__label {
    font-weight: 700;
    text-align: left;
}

.ac-decision .ac-input {
    border-color: transparent;
    background: rgba(255, 255, 255, 0.96);
    color: #111;
}

.ac-decision__actions {
    display: flex;
    gap: 14px;
    width: 100%;
    padding: 4px;
    box-sizing: border-box;
}

.ac-decision__failed {
    margin: 0;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
}

/* Set-up */

.ac-setup {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-height: 100dvh;
    padding: 24px 16px;
    background: var(--run-events);
    color: #fff;
}

.ac-setup__logo {
    width: 72px;
    height: 72px;
    padding: 6px;
    border-radius: 16px;
    background: #fff;
}

.ac-setup__title {
    margin: 0;
    font-size: clamp(1.4rem, 5vw, 2rem);
    text-align: center;
}

.ac-setup__camera {
    position: relative;
    width: min(100%, 420px);
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 20px;
    background: #000;
}

.ac-code--setup {
    width: min(100%, 420px);
    padding: 0;
    border: 0;
    background: transparent;
}

.ac-setup__message {
    min-height: 1.5em;
    margin: 0;
    font-weight: 700;
    text-align: center;
}

.ac-setup__hint {
    max-width: 420px;
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    text-align: center;
}

/* Larger screens: tablets and laptops */

@media (min-width: 900px) {
    .ac-controls {
        padding: 10px 20px;
    }

    .ac-result__icon {
        width: 128px;
        height: 128px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ac-camera__line,
    .ac-loading__spinner {
        animation: none;
    }

    .ac-camera__line {
        display: none;
    }

    .ac-result--returns::after {
        animation: none;
        width: 0;
    }
}

/* Blazor's own error bar (index.html) */

#blazor-error-ui {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
}

#blazor-error-ui .reload {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--decline);
    color: #fff;
}
