/*
 * Prime RoadRunners — store portal.
 * Builds on ../assets/css/rr.css (colours, buttons, fields, dialogs, toasts)
 * and ../assets/css/desk.css (menu, page frame, tables).
 *
 * Made for the counter of a busy shop: the order form is always at hand, the
 * open orders are read at a glance from a step away.
 *
 *   wide screen    form and orders side by side
 *   tablet, phone  form above the orders
 */

.sound[aria-pressed='false'] {
    color: var(--text-3);
}

.board {
    display: grid;
    grid-template-columns: clamp(340px, 32%, 400px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

/* ---------------------------------------------------------------- order form */

.compose {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}
.compose__title {
    font-size: 18px;
    font-weight: 700;
    line-height: 24px;
}
.compose__fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
    container: compose / inline-size;
}
.compose__pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
@container compose (max-width: 350px) {
    /* Too narrow for two fields with their labels on one line each */
    .compose__pair {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }
}
.compose .textarea {
    min-height: 68px;
}
.compose__send {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.compose__hint {
    color: var(--text-3);
    font-size: 12px;
    text-align: center;
}
@media (hover: none) {
    /* No keyboard, no shortcut */
    .compose__hint { display: none; }
}

/* -------------------------------------------------------------------- orders */

.lane {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    /* The rows arrange themselves by the room the list has, not by the screen */
    container: lane / inline-size;
}
.lane__head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap);
}
.lane__title {
    font-size: 18px;
    font-weight: 700;
    line-height: 24px;
}
.lane__count {
    flex-grow: 1;
    color: var(--text-3);
    font-size: 20px;
}
.lane__updated {
    color: var(--text-3);
    font-size: 13px;
}

.rows-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.line {
    border-radius: 14px;
    box-shadow: none;
}
.line.is-waiting-long {
    border-color: var(--danger-soft-text);
}
.line.is-changed {
    animation: line-flash 1.6s ease-out;
}
@keyframes line-flash {
    from { box-shadow: 0 0 0 3px var(--accent); }
    to { box-shadow: 0 0 0 3px transparent; }
}
.line.is-busy {
    opacity: 0.6;
    pointer-events: none;
}
.line__summary {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) var(--tap);
    grid-template-areas:
        'state where toggle'
        'state who   toggle';
    gap: 2px 16px;
    align-items: center;
    min-height: 76px;
    padding: 10px 8px 10px 16px;
    border-radius: 14px;
    cursor: pointer;
}
.line__state { grid-area: state; }
.line__where { grid-area: where; align-self: end; }
.line__who { grid-area: who; align-self: start; }
.line__toggle { grid-area: toggle; }
.line__summary:hover .line__toggle {
    background: var(--surface-2);
    color: var(--ink);
}
.line__state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.line__timer {
    color: var(--ink);
    font-size: 20px;
    font-weight: 700;
    line-height: 22px;
    white-space: nowrap;
}
.line__timer.is-calm { color: var(--text-2); }
.line__timer.is-late { color: var(--danger-soft-text); }
.line__where {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.line__address {
    overflow: hidden;
    font-size: 16px;
    font-weight: 600;
    line-height: 22px;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.line__meta {
    overflow: hidden;
    color: var(--text-3);
    font-size: 13px;
    line-height: 18px;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.line__who {
    display: flex;
    gap: 10px;
    min-width: 0;
    font-size: 14px;
    line-height: 20px;
}
.line__driver {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.line__nobody {
    color: var(--text-3);
}
.line__nobody.is-late {
    color: var(--danger-soft-text);
    font-weight: 600;
}
.line__who a {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.line__chevron {
    transition: transform 0.15s ease;
}
.line[data-open='true'] .line__chevron {
    transform: rotate(180deg);
}
.line[data-open='true'] .line__address {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* A wide list: state, address and driver side by side */
@container lane (min-width: 760px) {
    .line__summary {
        grid-template-columns: 172px minmax(0, 1fr) minmax(0, 210px) var(--tap);
        grid-template-areas: 'state where who toggle';
        gap: 16px;
    }
    .line__where,
    .line__who {
        align-self: center;
    }
    .line__who {
        flex-direction: column;
        gap: 0;
    }
}

.line__details {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
}
.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px 24px;
}
.fact {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    font-size: 15px;
    line-height: 20px;
    overflow-wrap: anywhere;
}
.fact__label {
    color: var(--text-3);
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
}
.line__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.done-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    margin-top: 6px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
}
.done-toggle > span:first-child {
    flex-grow: 1;
}
.done-toggle__count {
    color: var(--text-3);
    font-size: 18px;
}
.done-toggle .icon {
    transition: transform 0.15s ease;
}
.done-toggle[aria-expanded='true'] .icon {
    transform: rotate(180deg);
}

/* -------------------------------------------------------------------- tablet */

@media (max-width: 1180px) {
    .board {
        grid-template-columns: minmax(0, 1fr);
    }
    .compose {
        position: static;
    }
}

/* --------------------------------------------------------------------- phone */

@media (max-width: 640px) {
    .sound span {
        display: none;
    }
    .sound {
        width: var(--tap);
        padding: 0;
    }
    .compose {
        gap: 12px;
        padding: 16px;
    }
    .compose__pair {
        grid-template-columns: minmax(0, 1fr);
    }
    .compose__hint {
        display: none;
    }

    .line__summary {
        grid-template-columns: minmax(0, 1fr) var(--tap);
        grid-template-areas:
            'state toggle'
            'where toggle'
            'who   toggle';
        gap: 6px 8px;
        padding: 12px 6px 12px 14px;
    }
    .line__state {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
    .line__where,
    .line__who {
        align-self: center;
    }
    .line__address {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    /* Three to a row; the money takes what is left of the second row */
    .totals {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        row-gap: 14px;
        padding: 14px 4px;
    }
    .totals__item:nth-child(4) {
        border-left: 0;
    }
    .totals__item:nth-child(5) {
        grid-column: span 2;
    }
    .totals__value {
        font-size: 24px;
        line-height: 28px;
    }
    .totals__value--money {
        font-size: 22px;
    }

    /* The history becomes a list of cards: nothing to scroll sideways */
    .table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
    .table,
    .table tbody {
        display: block;
    }
    .table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            'address  status'
            'customer customer'
            'driver   money'
            'when     number';
        gap: 4px 12px;
        align-items: start;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
    }
    .table tbody tr:last-child {
        border-bottom: 0;
    }
    .table tbody tr:hover {
        background: transparent;
    }
    .table td {
        display: block;
        padding: 0;
        border: 0;
    }
    .table td.is-empty {
        display: none;
    }
    .table__address {
        grid-area: address;
        min-width: 0;
        max-width: none;
        font-size: 15px;
        font-weight: 600;
    }
    .table__address .table__sub {
        font-weight: 400;
    }
    .table__status { grid-area: status; }
    .table__customer { grid-area: customer; }
    .table__customer .table__sub {
        display: inline;
        margin-left: 8px;
        font-size: 14px;
    }
    .table__driver {
        grid-area: driver;
        color: var(--text-2);
    }
    .table__money {
        grid-area: money;
        font-weight: 600;
    }
    .table__when {
        grid-area: when;
        color: var(--text-3);
        font-size: 13px;
    }
    .table__when .table__sub {
        display: inline;
        margin-left: 6px;
    }
    .table__number {
        grid-area: number;
        color: var(--text-3);
        font-size: 13px;
        font-weight: 400;
        text-align: right;
    }
}
