/*
 * Shared look of Mission Control. It follows postyou.de and starts from the
 * stylesheet of the server monitoring: the Outfit typeface in light weights,
 * warm black on white, hairlines in "Creme", square boxes and pill-shaped
 * buttons. Colours are defined once as roles and switch with the operating
 * system between light and dark.
 *
 * Everything in here is in the layer "base". Each module adds its own file
 * under styles/modules/ in its own layer, so a rule of one module can never
 * override another module by accident, whatever its specificity.
 */

@layer base, core, connector, availability, maintenance, mailing;

@font-face {
    font-family: Outfit;
    font-weight: 300;
    font-display: swap;
    src: url("../fonts/outfit-v6-latin-300-53HaQzx.woff2") format("woff2");
}

@font-face {
    font-family: Outfit;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/outfit-v6-latin-regular-QVpDxLE.woff2") format("woff2");
}

@font-face {
    font-family: Outfit;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/outfit-v6-latin-500-uGa40wr.woff2") format("woff2");
}

@font-face {
    font-family: Outfit;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/outfit-v6-latin-600-XGZ_Asp.woff2") format("woff2");
}

:root {
    color-scheme: light;

    /* Postyou brand colours */
    --ink: #1f1d1b;
    --paper: #f5f4f1;
    --creme: #d9d6d1;
    --gold: #ceaf58;
    --gold-dark: #bd9e49;

    --page: var(--paper);
    --surface: #ffffff;
    --line: var(--creme);
    --text-primary: var(--ink);
    --text-secondary: #6b665f;

    /* Gold is the brand and marks what is selected. It never signals a
       state: warnings are orange, so that the two cannot be confused. */
    --accent: var(--gold);
    --accent-wash: rgba(206, 175, 88, 0.16);
    --hover-wash: rgba(31, 29, 27, 0.04);

    /* Status colours. A state is never shown by colour alone. */
    --ok: #008c5d;
    --caution: #e0b20f;
    --warning: #d9701a;
    --critical: #c8321f;
    --critical-wash: rgba(200, 50, 31, 0.07);
    --unknown: #a8a39b;

    /* Colours of the kinds of absence (KindColor), from postyou.de. Each has a
       strong tone for a pictogram and a wash for the background of a day. The
       washes keep text in --text-primary above a contrast of 13:1, the strong
       tones stay above 4.5:1 on --surface. Terracotta is darker and redder than
       --warning, so that a team outing never reads as a warning. No gold. */
    --kind-sage: #31855e;
    --kind-sage-wash: #dae9e2;
    --kind-blue: #3e7ab5;
    --kind-blue-wash: #dce7f2;
    --kind-berry: #b35c69;
    --kind-berry-wash: #f1e2e4;
    --kind-terracotta: #a5532f;
    --kind-terracotta-wash: #efe0da;
    --kind-plum: #7d5a96;
    --kind-plum-wash: #e8e1ec;
    --kind-teal: #2b7f86;
    --kind-teal-wash: #d9e8e9;
    --kind-neutral: #77716a;
    --kind-neutral-wash: #e7e5e4;

    --font: Outfit, system-ui, -apple-system, "Segoe UI", sans-serif;
    --gutter: clamp(16px, 4vw, 56px);

    /*
     * The grain of postyou.de, taken from its stylesheet: a tile of SVG noise.
     * It makes a coloured or dark surface read as material. A surface opts in
     * with its background-color and these three lines:
     *
     *   background-image: var(--grain);
     *   background-size: var(--grain-size);
     *   background-blend-mode: soft-light;
     *
     * --grain is grey noise for coloured surfaces such as gold. --grain-fine is
     * white specks for dark surfaces and needs no blend mode. --grain-paper is
     * --grain at a third of its strength, for the paper of the page. White panels
     * and anything behind small text stay without grain, so that text stays crisp.
     */
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0.55'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --grain-fine: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.4' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0.22 0 0 0 -0.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --grain-paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0.18'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --grain-size: 160px 160px;

    /* Depth: a plate of the diagram of the connections lies on the page and
       lifts a little towards the pointer. Tiles do not move. Lift and shadow
       only, no gradients and no rounded corners. */
    --shadow-plate: 0 1px 2px rgb(31 29 27 / 0.06), 0 4px 12px rgb(31 29 27 / 0.05);
    --shadow-lifted: 0 2px 4px rgb(31 29 27 / 0.06), 0 14px 32px rgb(31 29 27 / 0.12);

    /* Movement is slow and calm, as on postyou.de. Nothing bounces. */
    --ease: cubic-bezier(0.65, 0, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --page: #151311;
        --surface: #1f1d1b;
        --line: #3b3733;
        --text-primary: #f5f4f1;
        --text-secondary: #a8a39b;

        --accent-wash: rgba(206, 175, 88, 0.2);
        --hover-wash: rgba(245, 244, 241, 0.05);

        --ok: #22c790;
        --caution: #f2c94c;
        --warning: #ee8a35;
        --critical: #ee5b47;
        --critical-wash: rgba(238, 91, 71, 0.12);
        --unknown: #6b665f;

        /* Lighter tones and dark washes: above 5:1 on --surface and above 8.5:1
           for --text-primary on the wash. */
        --kind-sage: #56a87f;
        --kind-sage-wash: #304739;
        --kind-blue: #5b93cc;
        --kind-blue-wash: #314050;
        --kind-berry: #cc7480;
        --kind-berry-wash: #533739;
        --kind-terracotta: #cf7a52;
        --kind-terracotta-wash: #54392c;
        --kind-plum: #a487c0;
        --kind-plum-wash: #473d4c;
        --kind-teal: #4fa6ac;
        --kind-teal-wash: #2d4646;
        --kind-neutral: #a8a39b;
        --kind-neutral-wash: #484541;

        --shadow-plate: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 12px rgb(0 0 0 / 0.25);
        --shadow-lifted: 0 2px 4px rgb(0 0 0 / 0.3), 0 14px 32px rgb(0 0 0 / 0.45);
    }
}

/* Forced colours replace every colour, and noise would only be dirt there or on paper. */
@media print, (forced-colors: active) {
    :root {
        --grain: none;
        --grain-fine: none;
        --grain-paper: none;
    }
}

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

    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        margin: 0;
        background-color: var(--page);
        background-image: var(--grain-paper);
        background-size: var(--grain-size);
        background-blend-mode: soft-light;
        color: var(--text-primary);
        font: 400 15px/1.5 var(--font);
        -webkit-font-smoothing: antialiased;
    }

    h1,
    h2,
    h3,
    p,
    ul,
    ol,
    dl,
    dd {
        margin: 0;
    }

    ul,
    ol {
        padding: 0;
        list-style: none;
    }

    strong {
        font-weight: 500;
    }

    code {
        font-size: 0.92em;
    }

    a {
        color: inherit;
        text-decoration-color: var(--gold-dark);
        text-underline-offset: 3px;
    }

    /* The display values set by the component classes below would otherwise
       override the hidden attribute. */
    [hidden] {
        display: none !important;
    }

    .visually-hidden {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    :focus-visible {
        outline: 2px solid var(--gold-dark);
        outline-offset: 2px;
    }

    /* Brand */

    .logo {
        display: block;
        width: auto;
        height: 15px;
    }

    .masthead {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px 16px;
        padding: 14px var(--gutter);
        background: var(--surface);
        border-bottom: 1px solid var(--line);
    }

    .masthead__brand {
        display: flex;
        align-items: center;
        gap: 18px;
        color: inherit;
        text-decoration: none;
    }

    .masthead__nav {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin-right: auto;
        margin-left: 12px;
    }

    .masthead__link {
        padding: 6px 14px;
        border-radius: 100px;
        color: inherit;
        text-decoration: none;
    }

    .masthead__link:hover {
        background: var(--accent-wash);
    }

    .masthead__link[aria-current="page"] {
        background-color: var(--gold);
        background-image: var(--grain);
        background-size: var(--grain-size);
        background-blend-mode: soft-light;
        color: #1f1d1b;
        font-weight: 500;
    }

    .masthead__product {
        padding-left: 18px;
        border-left: 1px solid var(--line);
        font-weight: 300;
        font-size: 17px;
        letter-spacing: 0.02em;
    }

    .masthead__account {
        display: flex;
        align-items: center;
        gap: 14px;
        color: var(--text-secondary);
    }

    /* Page frame */

    .page {
        flex: 1;
        width: 100%;
        /* Wide enough for four tiles side by side, see .tiles. */
        max-width: 1560px;
        margin: 0 auto;
        padding: 32px var(--gutter) 48px;
    }

    /* Pages that belong together, with their navigation at the side. */
    .area {
        display: grid;
        grid-template-columns: 220px minmax(0, 1fr);
        gap: 24px 56px;
        align-items: start;
    }

    .area__nav {
        position: sticky;
        top: 24px;
        display: grid;
        gap: 2px;
        padding-top: 14px;
    }

    .area__link {
        padding: 10px 14px;
        border-left: 3px solid transparent;
        color: var(--text-secondary);
        font-size: 18px;
        text-decoration: none;
    }

    .area__link:hover {
        color: var(--text-primary);
    }

    /* Gold marks what is chosen, here as in the masthead. */
    .area__link[aria-current="page"] {
        border-left-color: var(--gold);
        color: var(--text-primary);
        font-weight: 500;
    }

    @media (max-width: 900px) {
        .area {
            grid-template-columns: minmax(0, 1fr);
        }

        .area__nav {
            position: static;
            display: flex;
            flex-wrap: wrap;
            padding-top: 0;
        }

        .area__link {
            border-left: 0;
            border-bottom: 3px solid transparent;
        }

        .area__link[aria-current="page"] {
            border-bottom-color: var(--gold);
        }
    }

    .page__header {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
        justify-content: space-between;
        gap: 12px 24px;
        margin-bottom: 28px;
    }

    .page__title {
        font-weight: 300;
        font-size: 30px;
        line-height: 1.15;
    }

    .page__lead {
        max-width: 70ch;
        margin-top: 6px;
        color: var(--text-secondary);
    }

    .section {
        margin-top: 36px;
    }

    .section__header {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        gap: 8px 20px;
        margin-bottom: 12px;
    }

    .section__title {
        font-weight: 500;
        font-size: 17px;
    }

    .section__hint {
        color: var(--text-secondary);
        font-size: 14px;
    }

    .footer {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 24px;
        padding: 14px var(--gutter);
        border-top: 1px solid var(--line);
        color: var(--text-secondary);
        font-size: 14px;
    }

    /* Controls */

    .button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 7px 18px;
        border: 1px solid transparent;
        border-radius: 100px;
        font: inherit;
        text-decoration: none;
        cursor: pointer;
    }

    .button--primary {
        background-color: var(--gold);
        background-image: var(--grain);
        background-size: var(--grain-size);
        background-blend-mode: soft-light;
        color: #1f1d1b;
        font-weight: 500;
    }

    .button--primary:hover {
        background-color: var(--gold-dark);
    }

    .button--quiet {
        background: transparent;
        border-color: var(--line);
        color: var(--text-primary);
    }

    .button--quiet:hover {
        border-color: var(--text-primary);
    }

    .field {
        display: grid;
        gap: 4px;
    }

    .field--inline {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .field__label {
        color: var(--text-secondary);
        font-size: 14px;
    }

    .field__input {
        padding: 8px 12px;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 0;
        color: var(--text-primary);
        font: inherit;
    }

    .field__input:focus {
        border-color: var(--text-primary);
    }

    /* Status marks. A state is never shown by colour alone: an icon and a word
       always go with it. */

    /* The glyphs come from Font Awesome (assets/icons) and are filled with
       currentColor, so a status sets the colour, not the shape. */
    .icon {
        flex: none;
        width: 16px;
        height: 16px;

        /* A round icon fills its box to the edge. At a size that is no whole number
           of pixels the box would cut its outline. */
        overflow: visible;
        fill: currentColor;
        vertical-align: -3px;
    }

    .icon--ok {
        color: var(--ok);
    }

    .icon--warning {
        color: var(--warning);
    }

    .icon--critical {
        color: var(--critical);
    }

    .icon--unknown {
        color: var(--unknown);
    }

    /* The words give the flag its baseline, so that text next to it stands on the
       same line. With the icon centred as the first item, the baseline would be the
       lower edge of the icon and the neighbour would hang below. */
    .flag {
        display: inline-flex;
        align-items: baseline;
        gap: 5px;
        color: var(--text-primary);
        font-weight: 500;
        white-space: nowrap;
    }

    .flag .icon {
        align-self: center;
        vertical-align: 0;
    }

    /* Names what something is, unlike .flag, which reports a state. */
    .tag {
        display: inline-block;
        padding: 0 6px;
        border: 1px solid var(--text-secondary);
        color: var(--text-primary);
        font-size: 13px;
        font-weight: 500;
        line-height: 1.5;
        white-space: nowrap;
    }

    .tag--quiet {
        border-color: var(--line);
        color: var(--text-secondary);
        font-weight: 400;
    }

    .notice {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 14px;
        background: var(--critical-wash);
        border-left: 3px solid var(--critical);
    }

    /* A hint rather than a problem: no status colour. */
    .notice--quiet {
        margin-bottom: 20px;
        background: var(--surface);
        border-left-color: var(--text-secondary);
    }

    /* A plain box for the content of a page section. */

    .panel {
        padding: 20px 24px 22px;
        background: var(--surface);
        border: 1px solid var(--line);
    }

    .panel--flush {
        padding: 0;
        overflow-x: auto;
    }

    /* Tiles: a grid of large boxes that each lead somewhere. They are meant to
       be big: a tile is a destination, not a list entry. */

    .tiles {
        display: grid;
        /* Four in a row from a window of about 1300 pixels on, and never five:
           at the full page width a fifth column would need 1496 pixels of the
           1448 there are. */
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
        gap: 24px;
    }

    .tile {
        display: flex;
        flex-direction: column;
        gap: 10px;
        min-height: 210px;
        padding: 30px 32px 26px;
        background: var(--surface);
        border: 1px solid transparent;
        color: inherit;
        text-decoration: none;
    }

    /* A tile that leads somewhere stays where it is: only its border answers the
       pointer. The keyboard focus keeps the gold outline of every other link. */
    a.tile {
        transition: border-color 0.15s;
    }

    a.tile:hover,
    a.tile:focus-visible {
        border-color: var(--text-primary);
    }

    .tile__title {
        font-weight: 600;
        font-size: 24px;
        line-height: 1.2;
    }

    .tile__text {
        color: var(--text-secondary);
        font-size: 16px;
    }

    /* Sits at the bottom edge, whatever the length of the text above it. */
    .tile__foot {
        display: flex;
        align-items: center;
        margin-top: auto;
        padding-top: 16px;
    }

    .arrow {
        width: 24px;
        height: 24px;
        color: var(--gold-dark);
        transition: transform 0.15s;
    }

    a.tile:hover .arrow,
    a.tile:focus-visible .arrow {
        transform: translateX(4px);
    }

    /* A tile that leads nowhere yet. */
    .tile--planned {
        background: transparent;
        border: 1px dashed var(--line);
    }

    .tile--planned .tile__title {
        color: var(--text-secondary);
    }

    @media (prefers-reduced-motion: reduce) {
        a.tile,
        .arrow {
            transition: none;
        }
    }

    /* Tables */

    .table {
        width: 100%;
        border-collapse: collapse;
    }

    .table th,
    .table td {
        padding: 9px 16px;
        border-bottom: 1px solid var(--line);
        text-align: left;
        vertical-align: top;
    }

    .table th {
        color: var(--text-secondary);
        font-weight: 400;
        font-size: 14px;
        white-space: nowrap;
    }

    .table tbody tr:last-child td {
        border-bottom: 0;
    }

    .table tbody tr:hover {
        background: var(--hover-wash);
    }

    .table__number {
        text-align: right !important;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .table__nowrap {
        white-space: nowrap;
    }

    .table__empty {
        padding: 20px 24px;
        color: var(--text-secondary);
    }

    /* Key facts side by side: a term above its value. */

    .facts {
        display: flex;
        flex-wrap: wrap;
        gap: 14px 40px;
    }

    .facts__term {
        color: var(--text-secondary);
        font-size: 14px;
    }

    /* A value is often a status flag followed by plain text. The flag is a flex
       box whose baseline is the bottom edge of its icon, so on a shared text
       line the words after it would sit lower than the words in it. As items of
       one centred row they line up. */
    .facts dd {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 8px;
    }

    /* What comes after the value itself, e.g. when it was last seen. Set back
       by its colour, so it needs no separating character. */
    .facts__note {
        color: var(--text-secondary);
    }

    /* Login */

    .login {
        display: grid;
        flex: 1;
        place-items: center;
        padding: 24px;
    }

    .login__form {
        display: grid;
        gap: 18px;
        width: 100%;
        max-width: 380px;
        padding: 36px;
        background: var(--surface);
        border: 1px solid var(--line);
    }

    .login__brand {
        display: grid;
        gap: 14px;
        margin-bottom: 6px;
    }

    .login__brand .logo {
        height: 18px;
    }

    .login__title {
        font-weight: 300;
        font-size: 26px;
        line-height: 1.15;
    }

    .login__form .button {
        justify-self: start;
        margin-top: 4px;
    }
}
