/*
  Submission-site additions on top of site.css and app.css (copied from ReportsToLegAdmin.Web so both apps look the
  same; they move to a shared ReportsToLeg.UI library in plan phase U2). Uses the same tokens.
*/

/* The hidden attribute must win over component display rules (.field-row is flex, .upload-progress is grid),
   or the script's show/hide of "Pursuant to" fields and the upload progress bar does nothing. */
[hidden] {
    display: none !important;
}

/* The yellow focus outline is only 1.6:1 against white, so a dark ring fills the 2px outline-offset gap and gives
   the indicator 3:1 against the page (WCAG 1.4.11). main is focused only as the skip-link target. */
:focus-visible:not(main) {
    box-shadow: 0 0 0 2px #0b0c0c;
}

/* Header user menu links sit on the blue gradient. */
.user-menu a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.user-menu a:hover,
.user-menu a:focus-visible {
    color: #ffe9a8;
}

.user-menu a:focus-visible {
    outline: var(--focus-outline);
    outline-offset: 2px;
}

/* ── Buttons and links ─────────────────────────────────────────────────────────────────────── */

button.link-button {
    min-height: 0;
    padding: 0;
    background: none;
    border: 0;
    color: var(--color-primary);
    font: inherit;
    font-weight: 400;
    text-decoration: underline;
    cursor: pointer;
}

button.link-button:hover {
    background: none;
    color: var(--color-primary-hover);
}

.button-link-secondary {
    background: var(--color-bg);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

.button-link-secondary:hover,
.button-link-secondary:focus-visible {
    background: var(--color-surface);
    color: var(--color-primary-hover);
}

.btn-compact,
button.btn-compact {
    min-height: 36px;
    padding: 0.3rem 0.75rem;
    font-size: 0.9rem;
}

summary.btn-compact {
    display: inline-block;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
    cursor: pointer;
    list-style: none;
}

summary.btn-compact::-webkit-details-marker {
    display: none;
}

.link-list {
    padding-left: 1.25rem;
}

.link-list li {
    margin: 0.35rem 0;
}

.inline-form {
    display: inline;
}

/* ── Forms ──────────────────────────────────────────────────────────────────────────────────── */

.submit-form fieldset.card {
    min-width: 0;
}

.submit-form legend {
    font-size: 1.15rem;
    font-weight: 600;
    padding: 0 var(--space-1);
}

.form-stack textarea {
    width: 100%;
    max-width: 48rem;
    padding: 0.5rem 0.75rem;
    font: inherit;
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius);
    resize: vertical;
}

.form-stack input[type="date"],
.form-stack input[type="search"],
.form-stack input[type="file"] {
    max-width: 24rem;
}

.form-stack .field-year input {
    max-width: 7rem;
}

.form-stack [aria-invalid="true"] {
    border-color: var(--color-error);
    border-width: 2px;
}

.pursuant-item {
    padding: var(--space-1) 0;
    border-top: 1px solid var(--color-border);
}

.pursuant-item:first-of-type {
    border-top: 0;
}

.pursuant-item > .field,
.pursuant-item > .field-row {
    margin: var(--space-1) 0 0 2rem;
}

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.field-row > .field:first-child {
    flex: 1 1 18rem;
}

.kept-file {
    margin: 0.25rem 0;
    padding: 0.5rem 0.75rem;
    background: var(--color-surface);
    border-radius: var(--radius);
}

.password-field {
    display: flex;
    gap: var(--space-1);
    align-items: center;
    max-width: 24rem;
}

.password-field input {
    flex: 1;
}

.code-input {
    max-width: 10rem !important;
    font-size: 1.4rem;
    letter-spacing: 0.3em;
    font-variant-numeric: tabular-nums;
}

.measure-preview {
    background: var(--color-surface);
}

.measure-preview p {
    margin: 0;
}

.upload-progress {
    display: grid;
    gap: 0.25rem;
    max-width: 32rem;
    margin-top: var(--space-2);
}

.upload-progress progress {
    width: 100%;
    height: 1rem;
}

/* ── Error summary ──────────────────────────────────────────────────────────────────────────── */

.error-summary-title {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.error-summary ul {
    margin: 0;
    padding-left: 1.25rem;
}

.error-summary a {
    color: var(--color-error);
    font-weight: 600;
}

.error-summary:focus {
    outline: var(--focus-outline);
}

/* ── Confirmation, details, status ─────────────────────────────────────────────────────────── */

.confirmation h1 {
    margin-top: 0;
    font-size: 1.5rem;
}

.status-review {
    background: #dbe9f7;
    color: #0a3d73;
}

.submissions-table td .help {
    display: block;
}

.request-deletion[open] {
    min-width: 16rem;
}

.request-deletion form {
    margin-top: var(--space-1);
}

.pager {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    margin-top: var(--space-2);
}

/* ── Small screens: table rows become cards ────────────────────────────────────────────────── */

@media (max-width: 48rem) {
    /* Each cell shows its own label (data-label), so the header row goes entirely: hidden off-screen, its sort links
       would still take keyboard focus with nothing visible (WCAG 2.4.7). */
    .submissions-table thead {
        display: none;
    }

    /* Cards flow with the page; a 75vh scroll box inside the page scroll is cramped on phones and at 400% zoom. */
    .table-scroll {
        max-height: none;
        overflow: visible;
        border: 0;
    }

    .submissions-table,
    .submissions-table tbody,
    .submissions-table tr,
    .submissions-table td {
        display: block;
        width: 100%;
    }

    .submissions-table tr {
        margin-bottom: var(--space-2);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        padding: var(--space-1);
    }

    /* table.data-table td (site.css) is more specific than .submissions-table td. */
    table.submissions-table td {
        border: 0;
        padding: 0.25rem 0;
    }

    .submissions-table caption {
        display: block;
    }

    .submissions-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--color-muted);
    }

    .pursuant-item > .field,
    .pursuant-item > .field-row {
        margin-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
    }
}

/* ── Confirmation dialog (app.js) ──────────────────────────────────────────────────────────── */

dialog.confirm-dialog {
    max-width: 32rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    padding: var(--space-3);
}

dialog.confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

/* Non-submit buttons (e.g. Show password) get the same look as submit buttons. */
button[type="button"].btn-secondary {
    min-height: 44px;
    padding: 0.4rem 0.9rem;
    font: inherit;
    font-weight: 600;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-primary);
    cursor: pointer;
}

/* ── My account ──────────────────────────────────────────────────────────────────────────────────── */

details.request-change > summary {
    cursor: pointer;
    color: var(--color-primary);
}

details.request-change[open] > summary {
    margin-bottom: var(--space-1);
}

.account-details dd {
    overflow-wrap: anywhere;
}

/* ── Header menu: inline on wide screens, a drawer on phones (signed in, with JavaScript; app.js) ─────────────── */

/* The wrapper adds no box on wide screens, so the nav and user menu stay flex items of the header as before. */
.site-menu {
    display: contents;
}

.menu-toggle,
.site-menu-head,
.menu-backdrop {
    display: none;
}

@media (max-width: 40rem) {
    .js .has-drawer.header-inner {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        min-height: 0;
    }

    .js .has-drawer .header-brand {
        flex: 1 1 auto;
        min-width: 0;
        gap: 0.75rem;
    }

    .js .has-drawer .header-seal {
        width: 48px;
        height: 48px;
    }

    .js .has-drawer .header-title-lg {
        font-size: 1.05rem;
        line-height: 1.3;
    }

    .js .has-drawer .header-title-sm {
        font-size: 0.8rem;
    }

    .js .has-drawer .menu-toggle {
        display: inline-flex;
        flex: 0 0 auto;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.1rem;
        min-width: 48px;
        min-height: 48px;
        padding: 0.25rem 0.5rem;
        color: #fff;
        background: rgba(255, 255, 255, 0.12);
        border: 1px solid rgba(255, 255, 255, 0.6);
        border-radius: var(--radius);
        font: inherit;
        font-size: 0.75rem;
        font-weight: 600;
        line-height: 1.2;
        cursor: pointer;
    }

    .js .has-drawer .menu-toggle:hover {
        background: rgba(255, 255, 255, 0.24);
    }

    /* Off-screen and hidden (so out of the tab order and the accessibility tree) until opened. */
    .js .has-drawer .site-menu {
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1001;
        width: min(20rem, 85vw);
        padding: var(--space-2);
        overflow-y: auto;
        overscroll-behavior: contain;
        background: #124d78;
        color: #fff;
        box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0s linear 0.2s;
    }

    .js .has-drawer .site-menu.is-open {
        transform: none;
        visibility: visible;
        transition: transform 0.2s ease;
    }

    .js .has-drawer .site-menu-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-1);
        padding-bottom: var(--space-1);
        border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    }

    .site-menu-title {
        font-size: 1.1rem;
        font-weight: 700;
    }

    .menu-close {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        min-height: 44px;
        padding: 0.25rem 0.75rem;
        color: #fff;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.6);
        border-radius: var(--radius);
        font: inherit;
        font-weight: 600;
        cursor: pointer;
    }

    .menu-close:hover {
        background: rgba(255, 255, 255, 0.15);
    }

    .js .has-drawer .site-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    .js .has-drawer .site-nav a {
        display: flex;
        align-items: center;
        min-height: 48px;
        padding: 0.5rem 0.75rem;
        font-size: 1rem;
        border-bottom: 0;
        border-left: 4px solid transparent;
        border-radius: var(--radius);
    }

    .js .has-drawer .site-nav a:hover {
        background: rgba(255, 255, 255, 0.12);
    }

    .js .has-drawer .site-nav a[aria-current="page"] {
        border-left-color: #fff;
        background: rgba(255, 255, 255, 0.12);
    }

    .js .has-drawer .user-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        padding-top: var(--space-2);
        border-top: 1px solid rgba(255, 255, 255, 0.3);
        font-size: 0.95rem;
    }

    .js .has-drawer .user-menu > span {
        padding: 0 0.75rem;
    }

    .js .has-drawer .user-menu a {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 0 0.75rem;
    }

    .js .has-drawer .user-menu form {
        margin-top: var(--space-1);
    }

    .js .menu-backdrop.is-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.45);
    }

    /* The page behind an open drawer doesn't scroll. */
    .js.menu-open,
    .js.menu-open body {
        overflow: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-menu {
        transition: none !important;
    }
}

/* ── Parallel run: sign-in page link to the classic site (Links:ClassicSiteUrl) ──────────────────────────────── */

.site-switch {
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
    color: var(--color-muted);
}
