/* Erreichbarkeit: who is away, how the target systems stand, and the settings. */

@layer availability {
    .availability-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
    }

    /* The first showcase follows the page header, which brings its own space. */
    .showcase--first {
        margin-top: clamp(24px, 4vw, 48px);
    }

    .availability-lead {
        max-width: 70ch;
        margin: -12px auto 24px;
        color: var(--text-secondary);
        text-align: center;
    }

    /* One tile per person. */
    .presence__head {
        display: flex;
        align-items: center;
        gap: 18px;
    }

    /* Whether the person can be reached now, large, as a line of text with its
       pictogram in it. */
    .presence__today {
        font-weight: 300;
        font-size: 22px;
        line-height: 1.25;
    }

    /* The pictogram never stands alone at the end of a line. The reason in
       brackets wraps on its own. */
    .reach {
        white-space: nowrap;
    }

    .reach__reason {
        color: var(--text-secondary);
    }

    /* Colours of the answer, always next to its word. Green only for reachable,
       the calm blue of the palette for the evening, and no gold or orange: being
       away or off is neither brand nor warning. */
    .reach--reachable {
        --hue: var(--ok);
    }

    .reach--after-hours {
        --hue: var(--kind-blue);
    }

    .reach--signed-off {
        --hue: var(--kind-teal);
    }

    .reach--meeting {
        --hue: var(--kind-plum);
    }

    .reach--not-reachable {
        --hue: var(--text-secondary);
    }

    .reach--unknown {
        --hue: var(--unknown);
    }

    /* Phone and mail, one line each, below the answer. */
    .presence__channels {
        display: grid;
        gap: 2px;
        font-size: 16px;
    }

    /* The pictogram of a line takes the colour of "an" or "aus": green where
       nothing stands between a caller and the person, the berry of the palette
       where a machine answers. Not the red of a failure: a machine that answers
       during a holiday is right. The word stands like the text around it. */
    .presence__channel--off {
        --hue: var(--ok);
    }

    .presence__channel--on {
        --hue: var(--kind-berry);
    }

    .presence__channel--unknown {
        --hue: var(--unknown);
    }

    .presence__deviation {
        font-size: 15px;
    }

    .presence__deviation .icon {
        width: 0.85em;
        height: 0.85em;
        margin-inline-end: 0.3em;
        vertical-align: -0.05em;
    }

    /* What comes is an aside: smaller and set back. */
    .presence__next {
        color: var(--text-secondary);
        font-size: 15px;
    }

    .presence__empty {
        color: var(--text-secondary);
        font-size: 17px;
    }

    /* Explains something and leads nowhere. */
    .tile--info {
        min-height: 0;
        background: transparent;
        border-color: var(--line);
    }

    /* The button of a tile stands at its foot, on one line across the tiles of a row. */
    .tile__action {
        margin-top: auto;
        padding-top: 8px;
    }

    /* Signing off and the team meeting: the state as large as the answer of a
       tile, the buttons side by side at the foot. */
    .switch__state {
        font-weight: 300;
        font-size: 22px;
        line-height: 1.25;
    }

    .switch__actions {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        margin-top: auto;
        padding-top: 8px;
    }

    /* The setup is incomplete. Orange, because it is a warning and not an error. */
    .setup-gaps {
        display: grid;
        gap: 10px;
        margin-bottom: 24px;
        padding: 16px 20px;
        background: var(--surface);
        border-left: 3px solid var(--warning);
    }

    .setup-gaps__lead {
        color: var(--text-secondary);
    }

    .setup-gaps__area {
        display: grid;
        gap: 4px;
    }

    .setup-gaps__link {
        font-weight: 500;
    }

    .setup-gaps__list,
    .availability-list {
        padding-left: 1.2em;
        list-style: disc;
    }

    .availability-list--spaced {
        display: grid;
        gap: 10px;
    }

    .availability-warning,
    .availability-missing {
        display: block;
        margin-top: 4px;
    }

    .availability-missing {
        margin-top: 16px;
    }

    .availability-error,
    .availability-write {
        display: block;
        color: var(--text-secondary);
    }

    .availability-block {
        display: block;
    }

    .availability-after {
        margin-top: 12px;
    }

    /* A person by picture and name. */
    .availability-heading {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 28px;
    }

    .availability-name {
        display: flex;
        align-items: center;
        gap: 14px;
    }

    .availability-panels {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
        gap: 24px;
        align-items: start;
    }

    .availability-panel__title {
        font-weight: 600;
        font-size: 22px;
        line-height: 1.2;
    }

    .findings {
        display: grid;
        gap: 8px;
        margin-top: 16px;
        padding-top: 14px;
        border-top: 1px solid var(--line);
    }

    .availability-panel__text {
        margin: 8px 0 18px;
        color: var(--text-secondary);
    }

    .availability-panel__actions {
        margin-top: 20px;
    }

    .facts--stacked {
        row-gap: 18px;
    }

    /* Settings forms */
    .settings-form {
        display: grid;
        gap: 22px;
        max-width: 880px;
    }

    .settings-form__group {
        display: grid;
        gap: 22px;
        margin: 0;
        padding: 0 0 26px;
        border: 0;
        border-bottom: 1px solid var(--line);
    }

    .settings-form__legend {
        margin-bottom: 4px;
        padding: 0;
        font-weight: 600;
        font-size: 20px;
    }

    .settings-form__actions {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
    }

    .field__label--large {
        color: var(--text-primary);
        font-weight: 500;
        font-size: 17px;
    }

    .field__help {
        max-width: 70ch;
        color: var(--text-secondary);
        font-size: 14px;
    }

    .field__input--short {
        max-width: 240px;
    }

    .field__input--code {
        width: 100%;
        font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
        font-size: 13px;
        line-height: 1.5;
        resize: vertical;
    }

    .field--invalid .field__input {
        border-color: var(--critical);
    }

    /* A note at a field that is no error, such as a suggestion to check. */
    .field__error,
    .field__note {
        display: flex;
        align-items: flex-start;
        gap: 6px;
        font-size: 14px;
    }

    .field__error .icon,
    .field__note .icon {
        flex: none;
        margin-top: 2px;
    }

    .field--check {
        display: flex;
        align-items: flex-start;
        gap: 10px;
    }

    .field--check input {
        flex: none;
        width: 18px;
        height: 18px;
        margin: 2px 0 0;
        accent-color: var(--gold-dark);
    }

    .field--check label {
        display: grid;
        gap: 2px;
    }

    .field__check-label {
        font-weight: 500;
    }


    /* The autoresponder as a recipient sees it, on white as in a mail program. */
    .preview {
        display: block;
        width: 100%;
        height: 440px;
        margin-top: 8px;
        background: #ffffff;
        border: 1px solid var(--line);
    }

    .preview__source {
        margin-top: 12px;
        color: var(--text-secondary);
        font-size: 13px;
    }

    .preview__source pre {
        margin: 8px 0 0;
        white-space: pre-wrap;
        word-break: break-word;
    }

    .panel > .filter {
        margin-bottom: 16px;
    }

    /* Colours of the kinds (KindColor, tokens in base.css). A class sets the
       strong tone and the wash, which a pictogram, a code or a day takes up. */
    .hue--sage {
        --hue: var(--kind-sage);
        --hue-wash: var(--kind-sage-wash);
    }

    .hue--blue {
        --hue: var(--kind-blue);
        --hue-wash: var(--kind-blue-wash);
    }

    .hue--berry {
        --hue: var(--kind-berry);
        --hue-wash: var(--kind-berry-wash);
    }

    .hue--terracotta {
        --hue: var(--kind-terracotta);
        --hue-wash: var(--kind-terracotta-wash);
    }

    .hue--plum {
        --hue: var(--kind-plum);
        --hue-wash: var(--kind-plum-wash);
    }

    .hue--teal {
        --hue: var(--kind-teal);
        --hue-wash: var(--kind-teal-wash);
    }

    .hue--neutral {
        --hue: var(--kind-neutral);
        --hue-wash: var(--kind-neutral-wash);
    }

    /*
     * A pictogram set in the text like an emoji, a little smaller than the letters
     * so that it accompanies the word instead of leading it. Font Awesome hangs a
     * 1em icon 0.125em below the baseline, which puts its centre at 0.375em, about
     * the middle of the lower-case letters; at 0.85em the same centre needs -0.05em.
     * The gap to the word comes on top of the space between them. Without the
     * colour of a kind it takes the colour of the text, as for a system.
     */
    .pictogram {
        margin-inline-end: 0.3em;
        color: var(--hue, currentColor);
    }

    .pictogram .icon {
        width: 0.85em;
        height: 0.85em;
        vertical-align: -0.05em;
    }

    /* A pictogram and its label wrap together. */
    .kind-label,
    .system-name {
        white-space: nowrap;
    }

    .absences__none {
        margin-top: 16px;
        color: var(--text-secondary);
    }

    /* What comes: the coming months. */
    .months {
        display: grid;
        grid-template-columns: 1fr;
        gap: 24px;
        align-items: start;
    }

    @media (min-width: 680px) {
        .months {
            grid-template-columns: repeat(2, 1fr);
        }
    }

    @media (min-width: 1040px) {
        .months {
            grid-template-columns: repeat(3, 1fr);
        }
    }

    .month {
        width: 100%;
        border-collapse: separate;
        border-spacing: 3px;
        table-layout: fixed;
        background: var(--surface);
        border: 1px solid var(--line);
    }

    .month__title {
        padding: 0 0 8px;
        font-weight: 500;
        font-size: 17px;
        text-align: left;
    }

    .month th {
        padding: 8px 0 4px;
        color: var(--text-secondary);
        font-weight: 400;
        font-size: 13px;
        text-align: center;
    }

    .month abbr {
        text-decoration: none;
    }

    .month__day {
        height: 46px;
        padding: 4px 2px;
        font-variant-numeric: tabular-nums;
        text-align: center;
        vertical-align: top;
    }

    .month__number {
        display: block;
        font-size: 13px;
        line-height: 1.3;
    }

    .month__day--weekend .month__number {
        color: var(--text-secondary);
    }

    .month__day--weekend:not(.month__day--marked) {
        background: var(--hover-wash);
    }

    .month__day--marked {
        background: var(--hue-wash);
    }

    .month__day--marked .month__number {
        color: var(--text-primary);
    }

    .month__code {
        display: block;
        font-weight: 600;
        font-size: 13px;
        line-height: 1.3;
        letter-spacing: 0.02em;
    }

    /* Gold marks today as the selected day, not as a state. */
    .month__day--today {
        box-shadow: inset 0 0 0 2px var(--gold-dark);
    }

    .month__day--today .month__number {
        font-weight: 600;
    }

    /* In the systems: one panel per system on the page of a person. */
    .systems {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr));
        gap: 24px;
        align-items: start;
    }

    .system {
        min-width: 0;
    }

    .system__name {
        font-weight: 600;
        font-size: 22px;
        line-height: 1.2;
    }

    .system__headline {
        margin-top: 2px;
        font-weight: 300;
        font-size: 18px;
    }

    .system__checked {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 10px;
        margin-top: 12px;
    }

    .system__note {
        margin-top: 12px;
        color: var(--text-secondary);
    }

    /* The autoresponders to come, one panel each, the text folded away. */
    .responders {
        display: grid;
        gap: 16px;
    }

    .responder__period {
        font-weight: 500;
        font-size: 19px;
    }

    .responder__kinds {
        margin-top: 6px;
    }

    .responder__text {
        margin-top: 12px;
    }

    .responder__text summary {
        color: var(--text-secondary);
        cursor: pointer;
    }

    /* The routings of a plan, folded away: only needed to hold the evaluation
       against the phone system. Six columns do not fit a narrow panel. */
    .plan {
        margin-top: 16px;
        overflow-x: auto;
    }

    .plan__summary {
        color: var(--text-secondary);
        cursor: pointer;
    }

    .plan__table {
        margin-top: 12px;
        font-size: 15px;
    }

    .system .availability-error {
        display: flex;
        align-items: flex-start;
        gap: 6px;
        margin-top: 10px;
    }

    .system .availability-error .icon {
        margin-top: 3px;
    }

    .items {
        display: grid;
        margin-top: 16px;
        border-top: 1px solid var(--line);
    }

    .item {
        display: grid;
        gap: 8px;
        min-width: 0;
        padding: 14px 0;
        border-bottom: 1px solid var(--line);
    }

    .item:last-child {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .item__head {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 4px 12px;
    }

    .item__label {
        font-weight: 500;
        overflow-wrap: anywhere;
    }

    .item__value {
        overflow-wrap: anywhere;
    }

    .item__value--empty {
        color: var(--text-secondary);
    }

    /* Should and is side by side, one below the other where there is no room. */
    .compare {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
        gap: 12px 20px;
    }

    .compare__side {
        display: grid;
        align-content: start;
        gap: 4px;
        min-width: 0;
    }

    .compare__term {
        color: var(--text-secondary);
        font-size: 13px;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    /* An autoresponder text as a recipient sees it, on white as in a mail program. */
    .item__frame {
        display: block;
        width: 100%;
        height: 260px;
        background: #ffffff;
        border: 1px solid var(--line);
    }

    .item__source {
        color: var(--text-secondary);
        font-size: 13px;
    }

    .item__source pre {
        max-height: 240px;
        margin: 8px 0 0;
        overflow: auto;
        font-size: 12px;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    /* Choices in a settings form: pictograms and colours as radio buttons. */
    .field--group {
        min-width: 0;
        margin: 0;
        padding: 0;
        border: 0;
    }

    .field--group > .field__label {
        margin-bottom: 4px;
        padding: 0;
    }

    .choices {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
        gap: 8px;
    }

    .choices--colors {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .choice {
        position: relative;
        display: block;
        cursor: pointer;
    }

    /* Hidden, but still the control that takes the focus and the keys. */
    .choice__input {
        position: absolute;
        width: 1px;
        height: 1px;
        opacity: 0;
    }

    .choice__box {
        position: relative;
        display: grid;
        align-content: start;
        justify-items: center;
        gap: 6px;
        height: 100%;
        padding: 14px 8px 10px;
        border: 1px solid var(--line);
        font-size: 13px;
        line-height: 1.3;
        text-align: center;
    }

    /* Larger than in the text, so that the glyphs can be told apart. */
    .choice__box .pictogram {
        margin-inline-end: 0;
        font-size: 24px;
        line-height: 1;
    }

    .choice__box--row {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        text-align: left;
    }

    .choice:hover .choice__box {
        border-color: var(--text-primary);
    }

    /* The choice is marked by the gold of a selection and by a tick. */
    .choice__input:checked + .choice__box {
        background: var(--accent-wash);
        border-color: var(--gold-dark);
        box-shadow: inset 0 0 0 1px var(--gold-dark);
    }

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

    .choice__mark {
        display: none;
    }

    .choice__box .choice__mark {
        position: absolute;
        top: 4px;
        right: 4px;
    }

    .choice__box--row .choice__mark {
        position: static;
        margin-left: auto;
    }

    .choice__input:checked + .choice__box .choice__mark {
        display: inline-flex;
    }

    .swatch {
        flex: none;
        width: 24px;
        height: 24px;
        background-color: var(--hue);
        background-image: var(--grain);
        background-size: var(--grain-size);
        background-blend-mode: soft-light;
    }
}
