/* ===========================================================================
 * PORTAL EXTENSIONS
 *
 * Loaded after site.css. Everything here is either (a) a class the shared
 * design system references but never defines, or (b) a pattern specific to a
 * records-search portal that the payments app has no use for.
 *
 * Rule of thumb: if a style would also make sense in CISARKANSAS PAY, it
 * belongs upstream in site.css — not here.
 * ===========================================================================
 */

/* ---------------------------------------------------------------------------
 * Gaps in the shared system.
 * _Layout.cshtml applies .main-shell but no stylesheet defines it; the toast
 * dismiss animation in site.js references a keyframe that site.css omits.
 * Both are reported upstream — defined here so the portal behaves correctly
 * in the meantime.
 * ------------------------------------------------------------------------ */
.main-shell {
    flex: 1 0 auto;
    padding-top: 1.5rem;
    padding-bottom: 2.5rem;
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ---------------------------------------------------------------------------
 * Page shell
 * site.css sets `body { margin-bottom: 60px }` for a fixed footer. This portal
 * uses a natural flow footer pinned by flexbox instead, so that margin would
 * leave a gap below it.
 * ------------------------------------------------------------------------ */
body {
    min-height: 100vh;
    margin-bottom: 0;
}

.topbar-title {
    /* Longer than the payments app's title; keep it from crowding the logo. */
    line-height: 1.25;
}

/* ---------------------------------------------------------------------------
 * Empty state
 * Lifted from admin.css, which the portal does not load (it is the back-office
 * design system and collides with site.css on badges, tokens and .btn-danger).
 * This is the one pattern from it the portal genuinely needs.
 * ------------------------------------------------------------------------ */
.empty-state {
    text-align: center;
    padding: 3rem 1.25rem;
    color: var(--gray-primary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9375rem;
    margin: 0;
}

.empty-state .empty-state-hint {
    font-size: 0.8125rem;
    margin-top: 0.5rem;
    opacity: 0.8;
}

/* ---------------------------------------------------------------------------
 * Document links
 * These open a scanned PDF in a new tab. site.css deliberately has no
 * .btn-danger — red is reserved for destructive actions — so a neutral,
 * icon-sized affordance is used instead of Bootstrap's red button.
 * ------------------------------------------------------------------------ */
.pdf-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--navy-primary);
    border-radius: 0.375rem;
    color: var(--navy-primary);
    background: transparent;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.pdf-link:hover,
.pdf-link:focus-visible {
    background: var(--navy-primary);
    color: var(--white);
}

.pdf-link i {
    font-size: 1rem;
}

/* Shown in place of .pdf-link when a record's image is withheld from public
   view (tblLicense.HideImage). Communicates "deliberately unavailable" rather
   than "missing". */
.pdf-unavailable {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 2.25rem;
    color: var(--gray-primary);
    opacity: 0.55;
}

/* ---------------------------------------------------------------------------
 * Result tables
 * The marriage table pairs groom and bride column groups; a faint tint keeps
 * the two readable across a wide row without adding borders.
 * ------------------------------------------------------------------------ */
.groom-header,
.groom-col {
    background-color: rgba(0, 102, 204, 0.05);
}

.bride-header,
.bride-col {
    background-color: rgba(0, 31, 63, 0.05);
}

.table .wrap-header {
    white-space: normal;
    word-break: break-word;
}

/* Action cells hold a single icon control; keep them tight and centred. */
.table .action-cell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}

/* Result count / summary line above a table. */
.result-summary {
    font-size: 0.875rem;
    color: var(--gray-primary);
    margin-bottom: 0.75rem;
}

/* ---------------------------------------------------------------------------
 * County footer
 * The per-county logo is fetched from that county's S3 bucket and its
 * dimensions are not under our control, so constrain it explicitly.
 * ------------------------------------------------------------------------ */
.county-logo {
    width: auto;
    max-width: 150px;
    max-height: 90px;
    object-fit: contain;
}

.county-footer-contact {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ---------------------------------------------------------------------------
 * Blazor infrastructure
 * ------------------------------------------------------------------------ */
#blazor-error-ui {
    background: #f8d7da;
    color: #721c24;
    border-top: 2px solid #f5c6cb;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-weight: 500;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
    color: #721c24;
    font-size: 1.2rem;
}

.validation-message {
    color: #dc3545;
    font-size: 0.875rem;
}

/* ---------------------------------------------------------------------------
 * Print
 * Searches are routinely printed as proof of record; drop the chrome and the
 * controls, keep the results.
 * ------------------------------------------------------------------------ */
@media print {

    .filter-card,
    .pdf-link,
    #blazor-error-ui {
        display: none !important;
    }

    .county-logo {
        max-width: 110px;
    }
}


/* ---------------------------------------------------------------------------
 * Navigation progress
 * With no circuit there is no built-in busy indicator, and a search across 886k
 * records is not instant. portal.js toggles .portal-navigating on <html> from
 * Blazor enhanced-navigation events; this is the only thing that reacts to it.
 * ------------------------------------------------------------------------ */
.nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    z-index: 3000;
    transform: scaleX(0);
    transform-origin: left;
    background: var(--accent-blue);
    opacity: 0;
}

.portal-navigating .nav-progress {
    opacity: 1;
    /* Eases toward "nearly done" without ever completing, since the duration of
       the request is unknown. The bar disappears when navigation ends. */
    animation: nav-progress-grow 8s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes nav-progress-grow {
    0% { transform: scaleX(0); }
    50% { transform: scaleX(0.7); }
    100% { transform: scaleX(0.95); }
}

/* The results table is replaced wholesale on each search; dimming it while a
   navigation is in flight keeps stale rows from reading as current. */
.portal-navigating .table-responsive {
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

/* Sortable column headers -------------------------------------------------
 *
 * The header *is* the control, so it has to read as a header first and a link
 * second: it inherits the header's colour and weight rather than taking link
 * styling, and earns an underline only on hover and focus.
 *
 * The direction arrow is always rendered, never only on hover — a control whose
 * current state is invisible until you point at it is not discoverable, and on a
 * touch screen there is no hover at all.
 * ------------------------------------------------------------------------ */
.sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.sort-link:hover,
.sort-link:focus-visible {
    color: inherit;
    text-decoration: underline;
}

.sort-link:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: 2px;
}

.sort-link .bi {
    font-size: 0.85em;
    opacity: 0.65;
}

.sort-link:hover .bi,
.sort-link:focus-visible .bi {
    opacity: 1;
}

/* Stacked tables on mobile ------------------------------------------------
 *
 * site.css hides the header and prefixes each cell with its data-label. That
 * turns a row into a labelled list, which is what makes the marriage table
 * usable on a phone at all: its header is a two-row column group (Groom and
 * Bride each spanning three columns), which no stacking rule can express — but
 * hiding the header entirely and fully qualifying each label ("Groom
 * birthplace" rather than "Birthplace") says the same thing.
 *
 * Records are frequently missing a field, and a stacked row would otherwise
 * show a label with nothing after it. An empty cell carries no information, so
 * it is dropped rather than rendered as a dangling label.
 * ------------------------------------------------------------------------ */
@media (max-width: 576px) {
    .table-mobile-stack td:empty {
        display: none;
    }

    /* The groom/bride column tints read as noise once the columns are gone. */
    .table-mobile-stack .groom-col,
    .table-mobile-stack .bride-col {
        background: none;
    }
}
