/*
    Pages drawn as cards on the board pages' black (site.css): the
    admin pages and the user portal, each with class bp-cards on <body>.
    Titles, cards, buttons, fields, tags, figures, choice pills, label and
    field forms, and tables in a card. Sizes in px: Notifications sets the
    root font size to the board's.
*/

.bp-cards {
    --card: #1a1c23;
    --card-rule: #2b2d38;
    --hover: #22242d;
    --current: #18233a;
    --accent: #5b8def;
    --field: #0e0f13;
    --field-rule: #30313b;
    --bar: #0e0f13;
    --panel: #20222b;
    --highlight: #15233a;
    --highlight-rule: #35507f;
    --saved: #7bd88f;
    /* Good, near and bad: the badges' backgrounds (their text --saved, --amber, --bad). */
    --good-bg: #1b3a26;
    --amber-bg: #3f3416;
    --amber: #f0c45a;
    --bad-bg: #45201f;
    --bad: #ff8a80;
    --primary: #234a9a;
    --primary-rule: #3463c4;
    --danger: #d9464f;
    /* Locked, and the tips' bulb. */
    --gold: #f5c518;
    --gold-rule: #5c4d1a;
    /* Where the wordmark sits in the admin menu and the User Portal's bar. */
    --brand-x: 24px;
    --brand-y: 20px;
}

/* The page's title and its one line. */
.bp-cards .bp h1 {
    font-size: 26px;
    letter-spacing: -.01em;
    margin-bottom: 4px;
}

.bp-cards .bp-intro {
    margin-bottom: 24px;
}

/* A section: a card. */
.bp-cards .bp-section {
    margin: 0 0 20px;
    padding: 20px 24px;
    background: var(--card);
    border: 1px solid var(--card-rule);
    border-radius: 12px;
}

.bp-cards .bp h2 {
    font-size: 17px;
    margin-bottom: 12px;
}

/* Low specificity, so a class (bp-label) or a page's own rule wins. */
:where(.bp-cards .bp) h3 {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--bp-bright);
}

.bp-cards .bp-section > :last-child {
    margin-bottom: 0;
}

/* A card's title with something beside it on the right. */
.bp-cardhead {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 12px;
}

.bp-cards .bp-cardhead h2 {
    margin: 0;
}

/* Buttons, fields. */
.bp-cards .bp-button {
    padding: 5px 14px;
    border-color: var(--field-rule);
    border-radius: 8px;
    background: #252731;
    font-weight: 600;
    transition: border-color .12s, background .12s;
}

.bp-cards .bp-button:hover {
    background: #2d3039;
}

/*
    A button whose label changes (Play and Pause): both labels sit in one
    grid cell, the one not showing hidden, so the button is always as wide
    as the wider and nothing beside it moves. .is-on shows the second.
*/
.bp-swap {
    display: inline-grid;
}

.bp-swap > span {
    grid-area: 1 / 1;
}

.bp-swap > span + span,
.bp-swap.is-on > span:first-child {
    visibility: hidden;
}

.bp-swap.is-on > span + span {
    visibility: visible;
}

.bp-cards .bp-button.is-primary {
    background: var(--primary);
    border-color: var(--primary-rule);
}

.bp-cards .bp-button.is-primary:hover {
    background: #2a57b3;
    border-color: var(--accent);
}

.bp-cards .bp input[type=text],
.bp-cards .bp input[type=number],
.bp-cards .bp input[type=email],
.bp-cards .bp select {
    box-sizing: border-box;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--field-rule);
    border-radius: 8px;
    background: var(--field);
    color: var(--bp-bright);
    font: inherit;
    font-size: 14px;
}

/* Its own chevron (--bp-muted's colour, which a data URL can't take), with
   room right of it: the browser's sat against the edge. */
.bp-cards .bp select {
    padding-right: 30px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M2.5 5 7 9.5 11.5 5' fill='none' stroke='%23a4a4ae' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 12px 12px;
    cursor: pointer;
}

.bp-cards .bp input::placeholder {
    color: var(--bp-faint);
    opacity: 1;
}

/* A required list's disabled first choice ("Choose ...") is its placeholder,
   grey; the choices themselves bright. */
.bp-cards .bp select:invalid {
    color: var(--bp-faint);
}

.bp-cards .bp select option {
    color: var(--bp-bright);
}

.bp-cards .bp select:focus,
.bp-cards .bp input:focus {
    outline: none;
    border-color: var(--accent);
}

/* A column down the left (bp-side) beside the page, held in view as it
   scrolls (the admin pages, the User Portal): bp-sided on what holds both. */
.bp-sided {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
}

.bp-side {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;     /* iOS: 100vh runs under Safari's and Chrome's toolbar, hiding the menu's foot */
    box-sizing: border-box;
    overflow-y: auto;
    padding: var(--brand-y) 12px;
    background: var(--bar);
    border-right: 1px solid var(--bp-rule);
    font-size: 14px;
}

/* .bp's auto margins would shrink it to its content as a grid item. */
.bp-sided > .bp {
    width: 100%;
}

/* A menu in it: group headings, then links, the current one marked. */
.bp-navgroup {
    padding: 16px 10px 6px;
    color: var(--bp-faint);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.bp-nav a {
    display: block;
    padding: 7px 10px;
    margin: 1px 0;
    border-radius: 7px;
    color: var(--bp-muted);
    text-decoration: none;
}

.bp-nav a:hover {
    background: var(--hover);
    color: var(--bp-bright);
}

.bp-nav a[aria-current] {
    background: var(--current);
    color: var(--bp-bright);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}

/*
    A <details class="bp-fold"> folds away by its <summary>: a chevron
    before the title, turned down when open. Drawn centred in its box, so
    turning it keeps it on the title's middle. A page remembering which are
    folded does so itself.
*/
.bp-fold > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.bp-fold > summary::-webkit-details-marker {
    display: none;
}

.bp-fold > summary::before {
    content: "";
    flex: none;
    width: 14px;
    height: 14px;
    background: var(--bp-muted);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M5 2.5 9.5 7 5 11.5' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M5 2.5 9.5 7 5 11.5' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform .15s, background-color .15s;
}

.bp-fold > summary:hover::before {
    background: var(--bp-bright);
}

.bp-fold[open] > summary {
    margin-bottom: 12px;
}

.bp-fold[open] > summary::before {
    transform: rotate(90deg);
}

/* The card h2's margin would put the chevron below the title's middle. */
.bp-cards .bp .bp-fold > summary h2 {
    margin: 0;
    line-height: 1.2;
}

/* A small tag: Admin, Revoked. Spaced by what it sits in. */
.bp-tag {
    display: inline-block;
    padding: 0 7px;
    border-radius: 999px;
    background: #1d2a44;
    color: #b9d2ff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    vertical-align: 2px;
}

.bp-tag.is-on {
    background: var(--good-bg);
    color: var(--saved);
}

.bp-tag.is-off {
    background: #2a2b33;
    color: var(--bp-muted);
}

.bp-tag.is-amber {
    background: var(--amber-bg);
    color: var(--amber);
}

.bp-tag.is-red {
    background: var(--bad-bg);
    color: var(--bad);
}

/*
    Panels, one under another, each a box (the User Portal's club cards and
    their Advanced, /Admin/Docs/Transitions's Advanced). minmax(0, ...): a long
    address in one would stretch the column past the screen.
*/
.bp-panels {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.bp-panel {
    margin: 0;
    padding: 16px 18px;
    border: 1px solid var(--card-rule);
    border-radius: 10px;
    background: var(--panel);
}

.bp-panel > :last-child {
    margin-bottom: 0;
}

/*
    A segmented choice: radios drawn as a row of buttons, the chosen one
    filled (the User Portal's Sponsor Banner order and preview boards,
    /Admin/Docs/Transitions's Graphics). No margin of its own: what holds it spaces it.
    <div class="bp-segment" role="radiogroup"><label><input type="radio"
    ...><span>Label</span></label>...</div>
*/
.bp-segment {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--field-rule);
    border-radius: 9px;
    background: var(--field);
}

.bp-segment label {
    position: relative;
    cursor: pointer;
}

.bp-segment input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.bp-segment span {
    display: block;
    padding: 5px 14px;
    border-radius: 6px;
    color: var(--bp-muted);
    font-size: 14px;
    font-weight: 600;
    transition: background .12s, color .12s;
}

.bp-segment :checked + span {
    background: var(--primary);
    color: #fff;
}

.bp-segment :focus-visible + span {
    outline: 2px solid var(--saved);
    outline-offset: 1px;
}

/* Big figures in a row. */
.bp-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 20px;
}

.bp-stats > div {
    flex: 1 1 140px;
    padding: 14px 18px;
    background: var(--card);
    border: 1px solid var(--card-rule);
    border-radius: 12px;
}

.bp-stats strong {
    display: block;
    font-size: 26px;
    font-weight: 600;
    color: var(--bp-bright);
    font-variant-numeric: tabular-nums;
}

/* A row of choices, the chosen one lit: speeds, reload. */
.bp-pills {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--card-rule);
    border-radius: 9px;
    background: var(--field);
    font-size: 13px;
    vertical-align: middle;
}

.bp-pills a,
.bp-pills strong {
    padding: 2px 10px;
    border-radius: 6px;
}

.bp-pills a {
    color: var(--bp-muted);
}

.bp-pills a:hover {
    color: var(--bp-bright);
    background: var(--hover);
    text-decoration: none;
}

.bp-pills strong {
    background: var(--current);
    color: var(--bp-bright);
}

/* A label and its control, one row each. */
.bp-form {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    max-width: 560px;
    gap: 10px 16px;
    align-items: center;
}

.bp-form .bp-label {
    justify-self: end;
}

/* A field and its button on one line, wrapping on a phone. */
.bp-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.bp-inline input[type=text] {
    flex: 1 1 12rem;
}

/* A table: a rule above each row, none above the headings. */
.bp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.bp-table th,
.bp-table td {
    text-align: left;
    vertical-align: top;
    padding: 7px 14px 7px 0;
    border-top: 1px solid var(--bp-rule);
}

.bp-table th {
    color: var(--bp-faint);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    white-space: nowrap;
}

.bp-table thead th {
    border-top: 0;
}

.bp-table th:last-child,
.bp-table td:last-child {
    padding-right: 0;
}

.bp-table .bp-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.bp-nowrap {
    white-space: nowrap;
}

.bp-cards input[type=radio],
.bp-cards input[type=checkbox] {
    accent-color: var(--accent);
}

/* A button that destroys something: red. */
.bp-cards .bp-button.is-danger {
    background: #4a1a1e;
    border-color: #8c2f36;
    color: #ffd7da;
}

.bp-cards .bp-button.is-danger:hover {
    background: #6a2128;
    border-color: var(--danger);
}


@media (max-width: 820px) {
    .bp-cards {
        --brand-x: 16px;
        --brand-y: 12px;
    }

    .bp-cards .bp-section {
        padding: 16px;
    }

    .bp-form {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .bp-form .bp-label {
        justify-self: start;
        margin-top: 6px;
    }
}

/*
    The site's wordmark (img/brand), with the part of the site under it in
    small capitals, lined up with the wordmark's lettering rather than its
    bars: the top of a page's menu or bar, which places it by --brand-x and
    --brand-y.
*/
.bp-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-decoration: none;
}

.bp-brand img {
    display: block;
    height: 28px;
    width: auto;
}

.bp-brand small {
    /* The lettering starts 298 of the wordmark's 1341 in. */
    padding-left: calc(28px * 298 / 228);
    color: var(--bp-faint);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
}

/*
    How saving stands on a page that saves as things change (_SaveStatus,
    autosave.js), kept in view along the bottom as the page scrolls: a
    pill, its mark by data-state. Idle a grey dot, saving a turning ring, saved a green tick popping in, problem
    a red "!" (the pill red-edged, its message wrapping).
*/
.bp-statusbar {
    position: sticky;
    bottom: 0;
    z-index: 1;
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
    padding: 12px 0;
    background: linear-gradient(transparent, var(--bp-bg) 30%);
    pointer-events: none;
}

.bp-status {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    padding: 8px 15px 8px 12px;
    border: 1px solid var(--card-rule);
    border-radius: 999px;
    background: var(--card);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
    color: var(--bp-muted);
    font-size: 14px;
    transition: color .2s, border-color .2s;
}

.bp-status i {
    position: relative;
    flex: none;
    width: 16px;
    height: 16px;
    box-sizing: border-box;
    border-radius: 50%;
}

.bp-status[data-state="idle"] i {
    transform: scale(.5);
    background: var(--bp-faint);
}

.bp-status[data-state="saving"] i {
    border: 2px solid var(--accent);
    border-right-color: transparent;
    animation: bp-turn .7s linear infinite;
}

.bp-status[data-state="saved"] {
    color: var(--bp-bright);
}

.bp-status[data-state="saved"] i {
    background: var(--saved);
    animation: bp-pop .35s cubic-bezier(.3, 1.6, .5, 1);
}

.bp-status[data-state="saved"] i::after {
    content: "";
    position: absolute;
    left: 5.5px;
    top: 3px;
    width: 3.5px;
    height: 7px;
    border: solid var(--card);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.bp-status[data-state="problem"] {
    border-color: var(--danger);
    color: var(--bp-bright);
}

.bp-status[data-state="problem"] i {
    background: var(--danger);
}

.bp-status[data-state="problem"] i::after {
    content: "!";
    position: absolute;
    inset: 0;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

@keyframes bp-turn {
    to { transform: rotate(1turn); }
}

@keyframes bp-pop {
    from { transform: scale(.3); }
}
