/*
 * AllCalls notification app: the whole visual identity, in one stylesheet.
 *
 * The palette is the marketing site's palette (apps/platform/resources/css/
 * marketing.css), inverted for a dark interface, so the app, the website and
 * the emails are recognisably one product. It is dark because this is opened on
 * a phone at 06:00 in a van and at 23:00 in a kitchen, and a white screen at
 * either hour is unkind.
 *
 * EVERY CONTRAST FIGURE BELOW IS MEASURED, not estimated: it is the WCAG 2.2
 * sRGB relative luminance ratio for that pair of colours. WCAG 2.2 AA needs
 * 4.5:1 for body text, 3:1 for large text and for the boundary of a control.
 *
 * No web font. The system stack means no network request, no layout shift when
 * a font swaps in, and one less thing to fail on a weak signal. It also happens
 * to be the only option: the Content Security Policy allows 'self' only.
 *
 * Changelog
 *   1.0  First version.
 *   1.3  An operational alert is drawn as one, not as a call, and a card can say
 *        which topic it came from. Both only reach the screen of an account that
 *        reads more than one topic; a single topic app is unchanged.
 */

:root {
    /* Surfaces, darkest first. */
    --ac-bg: #00152f; /* brand-950, the page */
    --ac-surface: #002352; /* brand-900, the logo navy, cards */
    --ac-raised: #0b3a75; /* brand-700, inputs and chips */

    /* Text. */
    --ac-text: #ffffff; /* 18.29:1 on bg, 15.42:1 on surface */
    --ac-muted: #c7d7ef; /* brand-200, 12.54:1 on bg, 10.57:1 on surface */
    --ac-line: #5f7ba6; /* brand-400, 4.24:1 on bg, 3.58:1 on surface: control boundaries */

    /* Accent: the amber of the marketing site. Only ever a FILL behind navy
       text (navy on amber is 8.43:1) or a large non-text mark. */
    --ac-accent: #ffb020;
    --ac-accent-hover: #ffc14d;
    --ac-on-accent: #00152f; /* 10.0:1 on the accent fill */

    /* States. Each is a light tint so it can carry text on navy. */
    --ac-alert: #ffb4b4; /* 10.83:1 on bg, 9.13:1 on surface */
    --ac-ok: #8fe3a6; /* 11.94:1 on bg, 10.06:1 on surface */

    /* A phone's rounded corners and home indicator. */
    --ac-safe-top: env(safe-area-inset-top, 0px);
    --ac-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ac-safe-left: env(safe-area-inset-left, 0px);
    --ac-safe-right: env(safe-area-inset-right, 0px);

    --ac-radius: 0.75rem;

    --ac-font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial,
        sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    /* Stops iOS enlarging text when the phone is turned sideways. */
    -webkit-text-size-adjust: 100%;
    background-color: var(--ac-bg);
}

body,
h1,
h2,
h3,
p,
ol,
ul,
figure {
    margin: 0;
    padding: 0;
}

ol,
ul {
    list-style: none;
}

/*
 * The hidden attribute must win.
 *
 * A browser's own rule for [hidden] is display: none at the lowest possible
 * specificity, so ANY class here that sets display, and several do, silently
 * beats it. The app hides and shows panels with element.hidden, so without this
 * line the offline warning and the update banner are on screen permanently.
 * Found in a screenshot, not in code review.
 */
[hidden] {
    display: none !important;
}

.ac-body {
    min-height: 100dvh;
    background-color: var(--ac-bg);
    color: var(--ac-text);
    font-family: var(--ac-font);
    font-size: 1rem;
    line-height: 1.5;
    /* A long unbroken word, a URL in a summary, must not push the page sideways. */
    overflow-wrap: break-word;
    display: flex;
    flex-direction: column;
}

/*
 * One focus style for everything focusable, declared once so a control added
 * later cannot ship without one. Three pixels of amber at 2px offset clears the
 * WCAG 2.2 focus appearance minimum on every surface in this app.
 */
:is(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid var(--ac-accent);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

/* Visible only when tabbed to. */
.ac-skip {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10;
    padding: 0.75rem 1rem;
    background-color: var(--ac-accent);
    color: var(--ac-on-accent);
    font-weight: 700;
    text-decoration: none;
}

.ac-skip:focus {
    left: calc(var(--ac-safe-left) + 0.5rem);
    top: calc(var(--ac-safe-top) + 0.5rem);
}

/* Present to a screen reader, absent from the screen. */
.ac-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------- header */

.ac-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: calc(var(--ac-safe-top) + 0.75rem) calc(var(--ac-safe-right) + 1rem) 0.75rem
        calc(var(--ac-safe-left) + 1rem);
    background-color: var(--ac-surface);
    border-bottom: 1px solid var(--ac-line);
}

.ac-header__logo {
    /* Intrinsic 640x192, so the height fixes the width at 3.33 times it and
       nothing reflows while the image loads. */
    height: 1.75rem;
    width: auto;
}

.ac-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ac-muted);
    white-space: nowrap;
}

.ac-status__dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background-color: var(--ac-muted);
    flex: none;
}

/* The dot is a second, redundant signal. The words beside it are the real one,
   so nothing here depends on telling green from amber. */
.ac-status--live .ac-status__dot {
    background-color: var(--ac-ok);
}

.ac-status--offline .ac-status__dot {
    background-color: var(--ac-alert);
}

/* --------------------------------------------------------------- main */

.ac-main {
    flex: 1 1 auto;
    width: 100%;
    max-width: 40rem;
    margin-inline: auto;
    padding: 1rem calc(var(--ac-safe-right) + 1rem) 1.5rem calc(var(--ac-safe-left) + 1rem);
}

.ac-panel {
    background-color: var(--ac-surface);
    border: 1px solid var(--ac-line);
    border-radius: var(--ac-radius);
    padding: 1.25rem;
}

.ac-panel__heading {
    font-size: 1.375rem;
    line-height: 1.25;
    margin-bottom: 0.5rem;
}

.ac-panel__lead {
    color: var(--ac-muted);
    margin-bottom: 1.25rem;
}

.ac-note {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--ac-muted);
}

/* ------------------------------------------------------------- forms */

.ac-field {
    margin-bottom: 1rem;
}

.ac-label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 600;
}

.ac-input {
    display: block;
    width: 100%;
    /* 3rem is 48px: comfortably past the 44px minimum target, and the size a
       cold thumb can actually hit. 16px text stops iOS zooming on focus. */
    min-height: 3rem;
    padding: 0.625rem 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--ac-text);
    background-color: var(--ac-raised);
    border: 1px solid var(--ac-line);
    border-radius: 0.5rem;
}

.ac-error {
    margin-bottom: 1rem;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--ac-alert);
    border-radius: 0.5rem;
    color: var(--ac-alert);
    font-weight: 600;
}

/* ----------------------------------------------------------- buttons */

.ac-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 3rem;
    padding: 0.75rem 1.25rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 0.625rem;
    cursor: pointer;
    transition: background-color 120ms ease;
}

@media (prefers-reduced-motion: reduce) {
    .ac-btn {
        transition: none;
    }
}

.ac-btn--primary {
    width: 100%;
    background-color: var(--ac-accent);
    color: var(--ac-on-accent); /* 10.0:1 */
}

.ac-btn--primary:hover {
    background-color: var(--ac-accent-hover);
}

.ac-btn--ghost {
    background-color: transparent;
    color: var(--ac-text);
    border-color: var(--ac-line);
}

.ac-btn--ghost:hover {
    background-color: var(--ac-raised);
}

.ac-btn--sm {
    width: auto;
    min-height: 2.75rem; /* 44px exactly, the WCAG 2.2 minimum */
    padding: 0.5rem 1rem;
    font-size: 0.9375rem;
}

.ac-btn--inline {
    min-height: 2.75rem;
    padding: 0.375rem 0.75rem;
    background-color: transparent;
    color: var(--ac-text);
    border-color: var(--ac-line);
    font-size: 0.9375rem;
}

.ac-btn[disabled] {
    opacity: 0.6;
    cursor: default;
}

.ac-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

@media (min-width: 30rem) {
    .ac-actions {
        flex-direction: row;
    }

    .ac-actions .ac-btn {
        flex: 1 1 0;
    }
}

/* ----------------------------------------------------------- banners */

.ac-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.875rem;
    border-radius: 0.5rem;
    border: 1px solid var(--ac-line);
    background-color: var(--ac-surface);
    font-size: 0.9375rem;
}

.ac-banner__text {
    flex: 1 1 12rem;
}

.ac-banner--offline {
    border-color: var(--ac-alert);
    color: var(--ac-alert);
    font-weight: 600;
}

.ac-banner--update,
.ac-banner--push {
    border-color: var(--ac-accent);
}

/* ----------------------------------------------------------- filters */

.ac-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ac-chip {
    min-height: 2.75rem; /* 44px */
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ac-text);
    background-color: transparent;
    border: 1px solid var(--ac-line);
    border-radius: 2rem;
    cursor: pointer;
}

/* The chosen chip is amber filled with navy text. aria-pressed carries the same
   fact to a screen reader, so the colour is never the only signal. */
.ac-chip[aria-pressed='true'] {
    background-color: var(--ac-accent);
    border-color: var(--ac-accent);
    color: var(--ac-on-accent);
}

/* ------------------------------------------------------------- calls */

.ac-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ac-call {
    background-color: var(--ac-surface);
    border: 1px solid var(--ac-line);
    border-radius: var(--ac-radius);
    padding: 1rem;
}

/*
 * An operational alert, from airx-ops: uptime, a deploy, a monitor.
 *
 * It sits in the same list as the calls, for the one person whose account reads
 * both, and it must not be mistakable for a customer ringing. Four differences,
 * only one of which is colour: a bell instead of a handset, a left edge in the
 * muted line colour instead of amber, a label saying "Operations", and no call
 * back button, because there is nobody to ring. Compare SC 1.4.1: with the
 * colour removed the bell, the label and the missing button all still say it.
 */
.ac-call--ops {
    border-left: 4px solid var(--ac-line); /* 3.58:1 against the card */
}

/* An urgent call is marked three ways: a thicker amber left edge, an amber
   icon, and the word "Urgent" in the chip. Colour alone would fail SC 1.4.1.
   This follows the rule above on purpose: an urgent operational alert is urgent
   first, so the amber edge wins over the muted one. */
.ac-call--urgent {
    border-left: 4px solid var(--ac-accent);
}

/*
 * Which topic a card came from. Only ever rendered when the account reads more
 * than one, so a customer's app never carries it.
 *
 * Outlined rather than filled: the filled amber pill beside it means urgent, and
 * two filled pills would compete. The muted text is 10.57:1 on the card.
 */
.ac-call__source {
    display: inline-block;
    margin-top: 0.5rem;
    margin-right: 0.5rem;
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--ac-line);
    border-radius: 0.375rem;
    color: var(--ac-muted);
    font-size: 0.8125rem;
    font-weight: 700;
}

.ac-call__top {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.ac-call__icon {
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    color: var(--ac-muted);
}

.ac-call--urgent .ac-call__icon {
    color: var(--ac-accent);
}

.ac-call__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.ac-call__headings {
    flex: 1 1 auto;
    min-width: 0;
}

.ac-call__title {
    font-size: 1.125rem;
    line-height: 1.3;
    font-weight: 700;
}

.ac-call__when {
    margin-top: 0.125rem;
    font-size: 0.875rem;
    color: var(--ac-muted); /* 10.57:1 on the card */
}

.ac-call__flag {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    background-color: var(--ac-accent);
    color: var(--ac-on-accent);
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ac-call__reason {
    margin-top: 0.75rem;
    font-weight: 600;
}

.ac-call__summary {
    margin-top: 0.375rem;
    color: var(--ac-muted);
}

/*
 * The call back button. Deliberately the biggest thing on the card: the number
 * IS the button, so there is no step between reading who rang and ringing them.
 * 3.75rem is 60px tall, and it works with no signal, because a tel: link is
 * handed to the dialler by the phone itself.
 */
.ac-call__back {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 3.75rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.625rem;
    background-color: var(--ac-accent);
    color: var(--ac-on-accent); /* 10.0:1 */
    font-size: 1.25rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.ac-call__back:hover {
    background-color: var(--ac-accent-hover);
}

.ac-call__nonumber {
    margin-top: 1rem;
    padding: 0.75rem;
    border: 1px dashed var(--ac-line);
    border-radius: 0.625rem;
    text-align: center;
    color: var(--ac-muted);
    font-weight: 600;
}

.ac-call__open {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    margin-top: 0.75rem;
    color: var(--ac-text);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.ac-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--ac-muted);
}

/* -------------------------------------------------------------- footer */

.ac-footer {
    padding: 1rem calc(var(--ac-safe-right) + 1rem) calc(var(--ac-safe-bottom) + 1rem)
        calc(var(--ac-safe-left) + 1rem);
    text-align: center;
    font-size: 0.8125rem;
    color: var(--ac-muted);
}
