/* Shared Quick Reference surface for Spot Manager and Release Student.
   It reuses Home's Tag Color & Status Key and Car Entry's How to Enter Tags
   language: the workspace intro header, dark bordered rows, real swifty-tag
   chips, and the gold confirmation action. */

.app-theme.page-spot .spot-manager-title-row,
.app-theme.page-release .release-student-title-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 8px 0 18px;
}
.app-theme.page-spot .spot-manager-title-row > h1,
.app-theme.page-release .release-student-title-row > h1 {
    margin: 0;
}

/* Audit 4.1: at 320px there is not enough horizontal room for a centred
   title, the help control and the two-lane selector on one line. Keep the
   help control on the title's line (they share order 1, so the icon stays
   inline right beside the trailing title text); only the lane tools take
   their own centred row, so the absolutely positioned selector can never
   cover either control. */
@media (max-width: 480px) {
    .app-theme.page-spot .spot-manager-title-row,
    .app-theme.page-release .release-student-title-row {
        flex-wrap: wrap;
        row-gap: 6px;
    }
    .app-theme.page-spot .spot-manager-title-row > h1,
    .app-theme.page-release .release-student-title-row > h1 {
        flex: 0 1 auto;
        order: 1;
        min-width: 0;
        text-align: center;
    }
    .app-theme.page-spot .spot-manager-title-row > .quick-reference-trigger,
    .app-theme.page-release .release-student-title-row > .quick-reference-trigger {
        flex: 0 0 auto;
        order: 1;
    }
    .app-theme.page-spot .spot-manager-title-row > .page-title-tools,
    .app-theme.page-release .release-student-title-row > .page-title-tools {
        position: static;
        flex: 0 0 100%;
        order: 2;
        justify-content: center;
        transform: none;
    }
}

.app-theme .quick-reference-trigger {
    display: inline-grid;
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    place-items: center;
    margin: 0;
    padding: 0;
    color: rgba(255, 255, 255, .62);
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    font-size: 15px;
    line-height: 1;
    transition: color .18s ease, transform .18s ease;
}
.app-theme .quick-reference-trigger:hover,
.app-theme .quick-reference-trigger:focus-visible {
    color: var(--app-accent-bright);
    background: transparent;
    border: none;
    box-shadow: none;
    filter: none;
    transform: translateY(-2px);
}
.app-theme .quick-reference-trigger:focus-visible {
    outline: 3px solid var(--app-accent-pale);
    outline-offset: 2px;
}
.app-theme .quick-reference-trigger:active {
    background: transparent;
    border: none;
    box-shadow: none;
    transform: translateY(0);
}

.app-theme .quick-reference-modal .tag-key-content {
    width: min(100%, 620px);
    max-width: 620px;
}
.app-theme .quick-reference-modal .app-modal-content {
    max-height: min(94vh, calc(100dvh - 32px), 760px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
}
.app-theme .quick-reference-modal .app-modal-body { padding: 18px 22px 10px; }
.app-theme .quick-reference-modal .app-modal-footer { padding: 10px 22px 14px; }
.app-theme .quick-reference-modal .tag-key-body { min-width: 0; }
.app-theme .quick-reference-modal .tag-key-body .workspace-intro-head { margin-bottom: 8px; }
.app-theme .quick-reference-modal .tag-key-body .workspace-intro-eyebrow { flex: 1 1 auto; min-width: 0; }
.app-theme .quick-reference-modal .tag-key-content h2 { margin-bottom: 4px; font-size: 22px; }
.app-theme .quick-reference-modal .tag-key-body .workspace-intro-lede { margin-bottom: 12px; font-size: 13px; }

.app-theme .quick-reference-modal .tag-key-close {
    display: inline-grid;
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    place-items: center;
    margin: 0 0 0 auto;
    padding: 0;
    color: rgba(255, 255, 255, .85);
    background: transparent;
    border: none;
    border-radius: 999px;
    box-shadow: none;
    font-size: 14px;
    transition: color .16s ease, background-color .16s ease;
}
.app-theme .quick-reference-modal .tag-key-close:hover,
.app-theme .quick-reference-modal .tag-key-close:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, .08);
    border: none;
    box-shadow: none;
    filter: none;
    transform: none;
}
.app-theme .quick-reference-modal .tag-key-close:focus-visible {
    outline: 3px solid var(--app-accent);
    outline-offset: 2px;
}

.app-theme .quick-reference-modal .tag-key-list {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.app-theme .quick-reference-modal {
    /* One shared left visual column for every reference row: two-tag flows
       and the mini Display Board both center inside this exact width, so the
       text column starts on the same vertical edge in all three rows. */
    --qr-visual-column: 112px;
}
.app-theme .quick-reference-modal .tag-key-item {
    display: grid;
    grid-template-columns: var(--qr-visual-column) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--app-surface-elevated);
    border: 1px solid var(--app-border);
    border-radius: 9px;
}
.app-theme .quick-reference-modal .tag-key-sample {
    display: flex;
    flex: 0 0 var(--qr-visual-column);
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: var(--qr-visual-column);
    min-height: 36px;
}
.app-theme .quick-reference-modal .tag-key-tag[data-surface="tile"] {
    --swifty-tile-tag-font: 16px;
    --swifty-tile-tag-pad: 6px;
    min-height: 32px;
    border-radius: 7px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .22);
}
.app-theme .quick-reference-modal .reference-flow .tag-key-tag[data-surface="tile"] {
    --swifty-tile-tag-font: 14px;
    --swifty-tile-tag-pad: 4px;
    min-height: 28px;
}
.app-theme .quick-reference-modal .reference-arrow {
    display: inline-grid;
    place-items: center;
    color: rgba(255, 255, 255, .55);
    font-size: 10px;
    line-height: 1;
}
.app-theme .quick-reference-modal .tag-key-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.app-theme .quick-reference-modal .tag-key-copy strong {
    color: var(--app-ink);
    font: 800 13px/1.35 Manrope, sans-serif;
}
.app-theme .quick-reference-modal .tag-key-copy span {
    color: var(--app-ink-soft);
    font-size: 12.5px;
    line-height: 1.4;
}

/* Row 2 mirrors the Rows 1 and 3 tag flow: the same full-size 204 chip and
   arrow, then the top-bar dismissal flag in the right slot. Equal 1fr side
   columns keep the arrow on the exact same axis as the two-tag rows, and the
   42px flag badge starts exactly where those rows' right-hand tag starts. */
.app-theme .quick-reference-modal .release-session-sample {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    justify-items: center;
    flex-wrap: nowrap;
    gap: 6px;
}
.app-theme .quick-reference-modal .release-session-sample .release-session-tag {
    justify-self: end;
}
.app-theme .quick-reference-modal .release-session-flag {
    display: inline-grid;
    place-items: center;
    justify-self: start;
    width: 42px;
    min-width: 42px;
    height: 28px;
    min-height: 28px;
    color: #93a4b1;
    border-radius: 6px;
}
.app-theme .quick-reference-modal .release-session-flag-svg {
    grid-area: 1 / 1;
    width: 16px;
    height: 16px;
    fill: currentColor;
}
.app-theme .quick-reference-modal .release-session-flag-regular { color: #93a4b1; }
.app-theme .quick-reference-modal .release-session-flag-checkered { color: #a6e3c9; opacity: 0; }

/* One calm 4.8s loop: the 204 chip releases first, then the session flag
   follows the same transition the top bar shows, then both reset. */
.quick-reference-modal:not(.hidden) .release-session-tag { animation: qr-session-tag 4.8s ease-in-out infinite; }
.quick-reference-modal:not(.hidden) .release-session-flag-regular { animation: qr-session-flag-inactive 4.8s ease-in-out infinite; }
.quick-reference-modal:not(.hidden) .release-session-flag-checkered { animation: qr-session-flag-active 4.8s ease-in-out infinite; }

@keyframes qr-session-tag {
    0%, 42% {
        color: #24364a;
        background: #ffffff;
        border-color: transparent;
        box-shadow: 0 2px 6px rgba(0, 0, 0, .22);
    }
    46%, 86% {
        color: #ffffff;
        background: var(--app-released-green, var(--sem-released));
        border-color: transparent;
        box-shadow: 0 3px 8px rgba(0, 0, 0, .22);
    }
    90%, 100% {
        color: #24364a;
        background: #ffffff;
        border-color: transparent;
        box-shadow: 0 2px 6px rgba(0, 0, 0, .22);
    }
}
@keyframes qr-session-flag-inactive {
    0%, 46% { opacity: 1; }
    50%, 90% { opacity: 0; }
    94%, 100% { opacity: 1; }
}
@keyframes qr-session-flag-active {
    0%, 46% { opacity: 0; }
    50%, 90% { opacity: 1; }
    94%, 100% { opacity: 0; }
}

/* Car Entry's tag-format reference keeps the same 112px visual column as the
   Spot Manager and Release Student references, on desktop and mobile, so all
   three row titles start on one vertical edge. */
.app-theme .tag-format-modal {
    --qr-visual-column: 112px;
}

/* Row 2 types "104 203" into a 98x24 mini input, then swaps it for two 44x24
   white chips with a 6px gap (94px total) inside that same column. */
.app-theme.page-car .tag-format-modal .tag-format-batch {
    display: grid;
    flex: 0 0 var(--qr-visual-column);
    width: var(--qr-visual-column);
    max-width: var(--qr-visual-column);
    height: 24px;
    place-items: center;
    align-content: center;
}
.app-theme .tag-format-modal .tag-format-batch-field {
    grid-area: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 98px;
    min-width: 98px;
    height: 24px;
    min-height: 24px;
    padding: 0 7px;
    color: #e2e8f0;
    background: rgba(15, 23, 42, .55);
    border: 1px solid rgba(148, 163, 184, .45);
    border-radius: 6px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
    font: 700 11px/1 "DM Sans", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}
.app-theme .tag-format-modal .tag-format-batch-typed {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}
/* Each character is its own flex item that stays rendered at all times. The
   reveal animates font-size and opacity with step-end, so hidden characters
   are exactly zero-width (including the space) and every visible glyph appears
   whole with no clipping and the caret flush after it. */
.app-theme .tag-format-modal .qr-batch-char {
    display: inline-block;
    white-space: pre;
    font-variant-numeric: tabular-nums;
    font-size: 0;
    opacity: 0;
}
.app-theme .tag-format-modal .qr-batch-caret {
    flex: 0 0 auto;
    width: 2px;
    min-width: 2px;
    height: 12px;
    background: #7dd3fc;
    border-radius: 1px;
}
.app-theme .tag-format-modal .tag-format-batch-chips {
    grid-area: 1 / 1;
    display: flex;
    align-items: center;
    gap: 6px;
}
.app-theme.page-car .tag-format-modal .tag-format-batch-chip[data-surface="tile"] {
    width: 44px;
    min-width: 44px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border-radius: 6px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .22);
}
.app-theme .tag-format-modal .tag-format-batch-chip { opacity: 0; }

/* One calm 4.8s loop: the field types both tags, then swaps to the two chips
   and holds before the next loop resets to an empty input. */
.tag-format-modal:not(.hidden) .tag-format-batch-field { animation: qr-batch-field 4.8s ease-in-out infinite; }
.tag-format-modal:not(.hidden) .qr-batch-caret { animation: qr-batch-caret .48s steps(1, end) infinite; }
.tag-format-modal:not(.hidden) .qr-batch-char {
    animation-duration: 4.8s;
    animation-timing-function: step-end;
    animation-iteration-count: infinite;
}
.tag-format-modal:not(.hidden) .qr-batch-char-1 { animation-name: qr-batch-char-1; }
.tag-format-modal:not(.hidden) .qr-batch-char-2 { animation-name: qr-batch-char-2; }
.tag-format-modal:not(.hidden) .qr-batch-char-3 { animation-name: qr-batch-char-3; }
.tag-format-modal:not(.hidden) .qr-batch-char-4 { animation-name: qr-batch-char-4; }
.tag-format-modal:not(.hidden) .qr-batch-char-5 { animation-name: qr-batch-char-5; }
.tag-format-modal:not(.hidden) .qr-batch-char-6 { animation-name: qr-batch-char-6; }
.tag-format-modal:not(.hidden) .qr-batch-char-7 { animation-name: qr-batch-char-7; }
.tag-format-modal:not(.hidden) .tag-format-batch-chip-1 { animation: qr-batch-chip-1 4.8s ease-in-out infinite; }
.tag-format-modal:not(.hidden) .tag-format-batch-chip-2 { animation: qr-batch-chip-2 4.8s ease-in-out infinite; }

@keyframes qr-batch-field {
    0%, 48% { opacity: 1; transform: scale(1); }
    52%, 94% { opacity: 0; transform: scale(.94); }
    98%, 100% { opacity: 1; transform: scale(1); }
}
/* Seven whole-glyph reveals across the 0%-48% typing window: 1, 10, 104,
   104 , 104 2, 104 20, 104 203. Characters are never display-toggled (which
   Chromium/WebKit fail to animate); font-size 0 hides them completely. */
@keyframes qr-batch-char-1 {
    0%, 47.99% { font-size: inherit; opacity: 1; }
    48%, 100% { font-size: 0; opacity: 0; }
}
@keyframes qr-batch-char-2 {
    0%, 6.99% { font-size: 0; opacity: 0; }
    7%, 47.99% { font-size: inherit; opacity: 1; }
    48%, 100% { font-size: 0; opacity: 0; }
}
@keyframes qr-batch-char-3 {
    0%, 13.99% { font-size: 0; opacity: 0; }
    14%, 47.99% { font-size: inherit; opacity: 1; }
    48%, 100% { font-size: 0; opacity: 0; }
}
@keyframes qr-batch-char-4 {
    0%, 20.99% { font-size: 0; opacity: 0; }
    21%, 47.99% { font-size: inherit; opacity: 1; }
    48%, 100% { font-size: 0; opacity: 0; }
}
@keyframes qr-batch-char-5 {
    0%, 27.99% { font-size: 0; opacity: 0; }
    28%, 47.99% { font-size: inherit; opacity: 1; }
    48%, 100% { font-size: 0; opacity: 0; }
}
@keyframes qr-batch-char-6 {
    0%, 34.99% { font-size: 0; opacity: 0; }
    35%, 47.99% { font-size: inherit; opacity: 1; }
    48%, 100% { font-size: 0; opacity: 0; }
}
@keyframes qr-batch-char-7 {
    0%, 41.99% { font-size: 0; opacity: 0; }
    42%, 47.99% { font-size: inherit; opacity: 1; }
    48%, 100% { font-size: 0; opacity: 0; }
}
@keyframes qr-batch-caret {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}
@keyframes qr-batch-chip-1 {
    0%, 52% { opacity: 0; transform: scale(.6); }
    56%, 88% { opacity: 1; transform: scale(1); }
    92%, 100% { opacity: 0; transform: scale(.82); }
}
@keyframes qr-batch-chip-2 {
    0%, 55% { opacity: 0; transform: scale(.6); }
    59%, 88% { opacity: 1; transform: scale(1); }
    92%, 100% { opacity: 0; transform: scale(.82); }
}

/* The mini Display Board uses 5 real swifty-tag chips and 4 dashed empty
   slots. Three 34px tiles plus two 4px gaps total 110px, fitting the shared
   112px visual column with a 1px inset on each side. The grid stays three
   columns; tag slots animate their order through Phase 1, the 412 alert jump,
   and the reset back to Phase 1. */
.app-theme .quick-reference-modal .spot-board-reference {
    grid-template-columns: var(--qr-visual-column) minmax(0, 1fr);
}
.app-theme .quick-reference-modal .spot-mini-board-sample {
    display: flex;
    flex: 0 0 var(--qr-visual-column);
    align-items: center;
    justify-content: center;
    width: var(--qr-visual-column);
    min-height: 0;
}
.app-theme .quick-reference-modal .spot-mini-board {
    display: grid;
    grid-template-columns: repeat(3, 34px);
    gap: 4px;
    width: 110px;
    max-width: 110px;
    margin: 0 auto;
}
.app-theme .quick-reference-modal .spot-mini-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 20px;
    min-width: 34px;
    min-height: 20px;
    border-radius: 5px;
}
.app-theme .quick-reference-modal .spot-mini-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 20px;
    min-width: 34px;
    min-height: 20px;
    padding: 0;
    border-radius: 5px;
    font: 800 10px/1 "DM Sans", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.app-theme .quick-reference-modal .spot-mini-ghost {
    background: rgba(255, 255, 255, .03);
    border: 1px dashed rgba(255, 255, 255, .2);
}
.app-theme .quick-reference-modal .spot-mini-slot-104 { order: 1; }
.app-theme .quick-reference-modal .spot-mini-slot-203 { order: 2; }
.app-theme .quick-reference-modal .spot-mini-slot-318 { order: 3; }
.app-theme .quick-reference-modal .spot-mini-slot-412 { order: 4; }
.app-theme .quick-reference-modal .spot-mini-slot-241 { order: 5; }
.app-theme .quick-reference-modal .spot-mini-ghost-1 { order: 6; }
.app-theme .quick-reference-modal .spot-mini-ghost-2 { order: 7; }
.app-theme .quick-reference-modal .spot-mini-ghost-3 { order: 8; }
.app-theme .quick-reference-modal .spot-mini-ghost-4 { order: 9; }

.quick-reference-modal:not(.hidden) .spot-mini-slot-104 { animation: qr-mini-104 4.5s ease-in-out infinite; }
.quick-reference-modal:not(.hidden) .spot-mini-slot-203 { animation: qr-mini-203 4.5s ease-in-out infinite; }
.quick-reference-modal:not(.hidden) .spot-mini-slot-318 { animation: qr-mini-318 4.5s ease-in-out infinite; }
.quick-reference-modal:not(.hidden) .spot-mini-slot-412 { animation: qr-mini-412 4.5s ease-in-out infinite; }
.quick-reference-modal:not(.hidden) .spot-mini-slot-241 { animation: qr-mini-241 4.5s ease-in-out infinite; }
.quick-reference-modal:not(.hidden) .spot-mini-tag-412 { animation: qr-mini-412-color 4.5s ease-in-out infinite; }

@keyframes qr-mini-104 {
    0%, 44% { order: 1; transform: scale(1); }
    46% { order: 2; transform: scale(.9); }
    50%, 88% { order: 2; transform: scale(1); }
    90% { order: 1; transform: scale(.9); }
    94%, 100% { order: 1; transform: scale(1); }
}
@keyframes qr-mini-203 {
    0%, 44% { order: 2; transform: scale(1); }
    46% { order: 3; transform: scale(.9); }
    50%, 88% { order: 3; transform: scale(1); }
    90% { order: 2; transform: scale(.9); }
    94%, 100% { order: 2; transform: scale(1); }
}
@keyframes qr-mini-318 {
    0%, 44% { order: 3; transform: scale(1); }
    46% { order: 4; transform: scale(.9); }
    50%, 88% { order: 4; transform: scale(1); }
    90% { order: 3; transform: scale(.9); }
    94%, 100% { order: 3; transform: scale(1); }
}
@keyframes qr-mini-412 {
    0%, 44% { order: 4; transform: scale(1); }
    46% { order: 1; transform: scale(.9); }
    50%, 88% { order: 1; transform: scale(1); }
    90% { order: 4; transform: scale(.9); }
    94%, 100% { order: 4; transform: scale(1); }
}
@keyframes qr-mini-241 {
    0%, 44% { order: 5; transform: scale(1); }
    46% { transform: scale(.9); }
    50%, 88% { order: 5; transform: scale(1); }
    90% { transform: scale(.9); }
    94%, 100% { order: 5; transform: scale(1); }
}
@keyframes qr-mini-412-color {
    0%, 44% { background: #fff; color: #24364a; }
    50%, 88% { background: var(--sem-alert); color: #362d11; }
    94%, 100% { background: #fff; color: #24364a; }
}

@media (prefers-reduced-motion: reduce) {
    .quick-reference-modal .spot-mini-slot,
    .quick-reference-modal .spot-mini-tag { animation: none !important; }
    .quick-reference-modal .release-session-tag {
        animation: none !important;
        color: #fff;
        background: var(--app-released-green, var(--sem-released));
        border-color: transparent;
        box-shadow: 0 3px 8px rgba(0, 0, 0, .22);
    }
    .quick-reference-modal .release-session-flag-regular {
        animation: none !important;
        opacity: 0;
    }
    .quick-reference-modal .release-session-flag-checkered {
        animation: none !important;
        opacity: 1 !important;
    }
    .tag-format-modal .tag-format-batch-field {
        animation: none !important;
        opacity: 0;
    }
    .tag-format-modal .tag-format-batch-typed {
        display: none !important;
    }
    .tag-format-modal .qr-batch-char {
        animation: none !important;
    }
    .tag-format-modal .qr-batch-caret {
        animation: none !important;
        opacity: 0;
    }
    .tag-format-modal .tag-format-batch-chip {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .quick-reference-modal .spot-mini-slot-412 { order: 1; }
    .quick-reference-modal .spot-mini-slot-104 { order: 2; }
    .quick-reference-modal .spot-mini-slot-203 { order: 3; }
    .quick-reference-modal .spot-mini-slot-318 { order: 4; }
    .quick-reference-modal .spot-mini-slot-241 { order: 5; }
}

@media (max-width: 680px) {
    .app-theme .quick-reference-modal .tag-key-item {
        grid-template-columns: var(--qr-visual-column) minmax(0, 1fr);
        gap: 10px;
        padding: 8px 10px;
    }
    .app-theme .quick-reference-modal .tag-key-tag[data-surface="tile"] {
        --swifty-tile-tag-font: 15px;
        --swifty-tile-tag-pad: 5px;
        min-height: 30px;
    }
    .app-theme .quick-reference-modal .tag-key-copy span { font-size: 12px; }
    .app-theme .quick-reference-modal .spot-board-reference {
        grid-template-columns: var(--qr-visual-column) minmax(0, 1fr);
    }
    .app-theme .quick-reference-modal .spot-board-reference .tag-key-sample {
        width: var(--qr-visual-column);
    }
    .app-theme .quick-reference-modal .spot-mini-board { max-width: 110px; }
}
