/* Advocate Connect - brand layer on top of Bootstrap.
 *
 * Colour tokens are sampled from brand/logo.png (see docs/17-brand-assets.md), so the UI
 * and the logo cannot drift apart. Nothing here loads from a third-party origin: the CSP in
 * web/app/security.py allows 'self' only.
 */

:root {
    --ac-navy: #001f44;
    --ac-navy-deep: #001731;
    --ac-navy-soft: #0a3a6b;
    --ac-gold: #c8861a;
    --ac-gold-light: #d9a03c;
    --ac-gold-deep: #935904;

    --ac-surface: #ffffff;
    --ac-surface-muted: #f6f8fb;
    --ac-border: #dde3ec;
    --ac-text: #12203a;
    --ac-text-muted: #5a6a85;

    /* Bootstrap overrides */
    --bs-primary: var(--ac-navy);
    --bs-link-color: var(--ac-navy-soft);
    --bs-link-hover-color: var(--ac-navy);
    --bs-body-color: var(--ac-text);
    --bs-border-color: var(--ac-border);
}

body {
    background-color: var(--ac-surface-muted);
    color: var(--ac-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------------------------------------------------------------- watermark
 * The emblem sits behind every page: fixed, centred, non-interactive and never in the
 * accessibility tree. It is painted on a pseudo-element rather than as a body background so
 * that its opacity is independent of the page background colour, and so it never intercepts
 * a click.
 *
 * The artwork itself is already pale (its own alpha was reduced when the asset was
 * generated), so the extra opacity here is deliberately gentle - enough to be present,
 * never enough to compete with body text.
 */
body.ac-watermark::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: image-set(
        url("../brand/watermark-soft.webp") type("image/webp"),
        url("../brand/watermark-soft.png") type("image/png")
    );
    background-repeat: no-repeat;
    background-position: center 45%;
    background-size: min(1000px, 78vw) auto;
    /* Deliberately restrained: on a sparse page the watermark must read as a texture, not
     * as content. Operators can override it via WATERMARK_OPACITY. */
    opacity: var(--ac-watermark-opacity, 0.5);
}

@media (max-width: 767.98px) {
    body.ac-watermark::before {
        background-image: image-set(
            url("../brand/watermark-soft-640.webp") type("image/webp"),
            url("../brand/watermark-soft-640.png") type("image/png")
        );
        background-size: 130vw auto;
        background-position: center 40%;
    }
}

/* Users who ask for reduced data or high contrast should not be served a decorative
 * background image at all. */
@media (prefers-contrast: more), (prefers-reduced-transparency: reduce) {
    body.ac-watermark::before {
        display: none;
    }
}

@media print {
    /* In print the watermark is the point - keep it, drop the chrome. */
    .ac-navbar,
    .ac-footer,
    .ac-no-print {
        display: none !important;
    }
}

/* ---------------------------------------------------------------- header */
.ac-navbar {
    background: linear-gradient(100deg, var(--ac-navy-deep), var(--ac-navy) 55%, var(--ac-navy-soft));
    border-bottom: 3px solid var(--ac-gold);
}

.ac-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding-block: 0.35rem;
}

/* The emblem is predominantly navy, and the navbar and footer are navy. Rather than
 * flattening the logo to a white silhouette (which destroys the gold and the detail), it is
 * placed on a light chip so the artwork keeps its real colours and stays legible. */
.ac-brand-chip {
    height: 38px;
    width: auto;
    display: block;
    background: #fff;
    border-radius: 0.5rem;
    padding: 0.2rem 0.4rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.ac-brand-wordmark {
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.05;
}

.ac-brand-wordmark small {
    display: block;
    font-weight: 500;
    font-size: 0.68rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--ac-gold-light);
}

.ac-navbar .nav-link {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}

.ac-navbar .nav-link:hover,
.ac-navbar .nav-link:focus {
    color: #fff;
}

/* ---------------------------------------------------------------- content */
main {
    flex: 1 0 auto;
}

.ac-card {
    background: var(--ac-surface);
    border: 1px solid var(--ac-border);
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 31, 68, 0.04), 0 8px 24px rgba(0, 31, 68, 0.05);
}

.ac-hero-logo {
    max-width: min(420px, 78vw);
    height: auto;
}

.ac-rule {
    height: 3px;
    width: 72px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--ac-gold), var(--ac-gold-light));
}

.ac-eyebrow {
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ac-gold-deep);
}

.btn-ac-primary {
    background-color: var(--ac-navy);
    border-color: var(--ac-navy);
    color: #fff;
}

.btn-ac-primary:hover,
.btn-ac-primary:focus {
    background-color: var(--ac-navy-soft);
    border-color: var(--ac-navy-soft);
    color: #fff;
}

.btn-ac-gold {
    background-color: var(--ac-gold);
    border-color: var(--ac-gold);
    color: #1a1200;
    font-weight: 600;
}

.btn-ac-gold:hover,
.btn-ac-gold:focus {
    background-color: var(--ac-gold-light);
    border-color: var(--ac-gold-light);
    color: #1a1200;
}

/* Evidence classes are a product-safety requirement, not decoration: a declaration must
 * never look like a verified fact. See docs/15-product-legal-safety.md. */
.ac-evidence {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.ac-evidence-system {
    background: #e8f0fb;
    color: #123a72;
    border-color: #c3d7f2;
}

.ac-evidence-declared {
    background: #fdf3e0;
    color: #7a5205;
    border-color: #f0dcb4;
}

.ac-evidence-confirmed {
    background: #e7f6ed;
    color: #1c5c36;
    border-color: #c2e4d1;
}

.ac-evidence-verified {
    background: var(--ac-navy);
    color: #fff;
    border-color: var(--ac-navy);
}

.ac-status-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    display: inline-block;
}

.ac-status-ok { background: #1c8a4b; }
.ac-status-error { background: #c0392b; }
.ac-status-unknown { background: #98a2b3; }

/* ---------------------------------------------------------------- footer */
.ac-footer {
    background: var(--ac-navy-deep);
    color: rgba(255, 255, 255, 0.72);
    border-top: 3px solid var(--ac-gold);
    font-size: 0.875rem;
}

.ac-footer a {
    color: var(--ac-gold-light);
    text-decoration: none;
}

.ac-footer a:hover {
    text-decoration: underline;
}

.ac-footer img {
    height: 30px;
}

/* ------------------------------------------------------- registration steps */
.ac-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: ac-step;
}

.ac-step {
    counter-increment: ac-step;
    color: #667085;
    font-size: 0.9rem;
}

.ac-step::before {
    content: counter(ac-step);
    display: inline-grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.5rem;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: 0.75rem;
    font-weight: 600;
}

.ac-step-current {
    color: var(--ac-navy);
    font-weight: 600;
}

.ac-step-done { color: #1c8a4b; }
.ac-step-done::before { content: "\2713"; }

/* The numbered markers on the "finish setting up" checklist. */
.ac-step-marker {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid #d0d5dd;
    color: #667085;
    font-weight: 600;
}

.ac-step-marker-done {
    background: #1c8a4b;
    border-color: #1c8a4b;
    color: #fff;
}

/* ------------------------------------------------------------- OTP entry */
.ac-otp-input {
    /* A code is read digit by digit off a phone screen; tracking makes that far easier
       to check against the message without losing your place. */
    letter-spacing: 0.5em;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* ------------------------------------------------------------- contextual help */
.ac-help-icon {
    /* A button, not a link: it performs an action rather than navigating, and it has to be
       reachable by keyboard in the same tab order as the field it explains. */
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border: 1px solid var(--ac-gold);
    border-radius: 50%;
    background: transparent;
    color: var(--ac-navy);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.ac-help-icon:hover,
.ac-help-icon:focus-visible {
    background: var(--ac-gold);
    color: #fff;
}

.ac-help-icon-inline {
    display: inline-grid;
    place-items: center;
    width: 1.2rem;
    height: 1.2rem;
    border: 1px solid var(--ac-gold);
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
}

/* --------------------------------------------------------------- location picker */
.ac-map {
    height: 22rem;
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 0.5rem;
    /* Leaflet and the Maps API both position children absolutely inside this box. */
    position: relative;
    z-index: 0;
    background: #eef1f5;
}

@media (max-width: 575.98px) {
    .ac-map { height: 16rem; }
}

/* Leaflet's own panes sit at z-index 400-700, which would otherwise cover a Bootstrap
   modal backdrop (1050). Containing them keeps the help video on top of the map. */
.ac-map-wrap .leaflet-pane,
.ac-map-wrap .leaflet-top,
.ac-map-wrap .leaflet-bottom {
    z-index: 1;
}

/* ------------------------------------------------- accessible secondary text
 *
 * Bootstrap's secondary grey is #6c757d, which gives 4.69:1 on white and passes AA - but
 * this application's page background is --ac-surface-muted (#f6f8fb), where the same grey
 * measures 4.41:1 and fails. axe found it on the landing copy, the status page and every
 * outline-secondary button.
 *
 * #5c6470 is the same hue, one step darker: 5.62:1 on the page background and 5.98:1 on a
 * card. Both comfortably clear AA for normal text, so it holds up wherever a component is
 * moved to.
 */
:root {
    --ac-secondary-accessible: #5c6470;
}

.text-secondary,
.text-body-secondary,
.form-text {
    color: var(--ac-secondary-accessible) !important;
}

.btn-outline-secondary {
    --bs-btn-color: var(--ac-secondary-accessible);
    --bs-btn-border-color: var(--ac-secondary-accessible);
    --bs-btn-hover-bg: var(--ac-secondary-accessible);
    --bs-btn-hover-border-color: var(--ac-secondary-accessible);
}

/* --------------------------------------------------------- visible focus
 *
 * The custom button classes set their own background on :focus and nothing else, so a
 * keyboard user tabbing through the sign-in form could not see which control they were on.
 * Bootstrap's own ring never applied: `.btn:focus-visible` reads --bs-btn-focus-box-shadow,
 * which these classes never define.
 *
 * axe does not catch this - focus visibility is not reliably automatable - so it is covered
 * by a keyboard test in e2e/tests/accessibility.spec.ts instead.
 *
 * The ring is two-tone on purpose. WCAG 1.4.11 wants 3:1 against what the indicator sits
 * on, and no single colour manages that against both a navy button and the near-white page:
 * gold is 5.4:1 on navy but 2.9:1 on the page. So a white halo separates the ring from the
 * button, and a navy ring reads against the page at 15.4:1 and against the gold button at
 * 5.4:1.
 */
.btn-ac-primary:focus-visible,
.btn-ac-gold:focus-visible,
.ac-help-icon:focus-visible {
    outline: 3px solid var(--ac-navy);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #fff;
}

/* Inside the navbar the page behind is navy, so the ring inverts to stay visible. */
.ac-navbar .btn-ac-gold:focus-visible {
    outline-color: #fff;
    box-shadow: 0 0 0 2px var(--ac-navy);
}

/* ------------------------------------------------------------ tap targets
 *
 * Bootstrap draws a check or radio at 1em - 16 CSS pixels at the default size - which is
 * below the 24x24 WCAG 2.2 asks for. The associated label extends the hit area, so this is
 * not unusable, but the channel choice on the sign-in page is a radio somebody taps on a
 * phone in a corridor, and 16px is a mean target for it.
 *
 * The input grows to 20px and the row gets enough vertical padding to clear 24px overall,
 * which keeps the visual weight of the form while making the thing actually hittable.
 */
.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.15rem;
}

.form-check {
    min-height: 1.75rem;
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}

.form-check-label {
    /* The label is part of the target; make it comfortably tappable rather than tight. */
    padding-left: 0.15rem;
    line-height: 1.5;
}

@media (pointer: coarse) {
    /* On a touch screen there is no hover to help you aim. */
    .form-check {
        min-height: 2.25rem;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }
}
