/*
 * the admin follows ../cleeq/ui/docs/DESIGN.md: Cinder Dark, a Studio "list" page that reads like a printed
 * statement. sections sit on the page with no boxes, rows have no dividers, type carries the hierarchy, coral is
 * spent once per page (the primary button). values (numbers, dates, titles) speak in Changa, everything else Rubik.
 */
@font-face {
    font-family: Rubik;
    src: url("/brand/email/rubik.woff2") format("woff2");
    font-weight: 300 900;
    font-display: swap;
}
@font-face {
    font-family: "Changa One";
    src: url("/brand/email/changa-one.woff2") format("woff2");
    font-display: swap;
}

/* Cinder Dark, from ../cleeq/ui/src/lib/styles/theme/palettes/_cleeq-cinder-dark.scss and theme/_semantic.scss */
:root {
    color-scheme: dark;
    --bg-darker: #060709;
    --bg-base: #080a0c;
    --bg-elevated: #0b0d11;
    --bg-tertiary: #13161b;
    --bg-hover: #1a1e24;
    --bg-active: #252a31;
    --field-bg: color-mix(in oklab, #aab4c4 7%, transparent);
    --field-hover: color-mix(in oklab, #aab4c4 11%, transparent);
    --ink: #000;
    --text: #e7e9ed;
    --text-2: #c0c6ce;
    --text-3: #919aa5;
    --text-4: #56606c;
    --on-accent: #040507;
    --coral: #e8755e;
    --coral-hi: #f08c74;
    --success: #74c69d;
    --warning: #e0b86b;
    --error: #f07882;
    --overlay: rgb(4 5 7 / 0.75);

    --radius: 2px; /* $radius-xs */
    --edge: 2px; /* $border-width-base */
    --body: Rubik, "Helvetica Neue", Arial, sans-serif;
    --value: "Changa One", Rubik, "Arial Black", sans-serif;
    --ease: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --gutter: 1.5rem;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    color: var(--text);
    font: 400 1rem/1.45 var(--body);
    -webkit-font-smoothing: antialiased;
}
h1,
h2,
p,
dl,
dd,
ul {
    margin: 0;
}
a {
    color: inherit;
}
button,
input,
select {
    font: inherit;
    color: inherit;
}
:focus-visible {
    outline: var(--edge) solid var(--text);
    outline-offset: var(--edge);
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---- voices */
.value {
    font-family: var(--value);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.meta {
    display: block;
    margin-top: 0.125rem;
    color: var(--text-3);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--body);
    letter-spacing: normal;
    white-space: normal;
}
.meta.danger {
    color: var(--error);
    max-width: 16rem;
}
.dim {
    color: var(--text-3);
}
.cap {
    text-transform: capitalize;
}
.note {
    color: var(--text-3);
    font-size: 0.875rem;
    line-height: 1.35;
}

/* ---- app shell: a flat top bar split from the page by the ink seam */
.topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 3.5rem;
    padding: 0.5rem var(--gutter);
    background: var(--bg-base);
    border-bottom: var(--edge) solid var(--ink);
}
.brand {
    display: block;
    line-height: 0;
}
.brand img {
    width: 104px;
    height: auto;
}
.area {
    color: var(--text-3);
    font-size: 0.875rem;
    font-weight: 600;
}
.signout {
    margin-inline-start: auto;
}

/* ---- page: one wide column, header lined up with the content */
.page {
    flex: 1;
    display: grid;
    /* minmax(0, 1fr): a wide table scrolls in its own box instead of widening the page */
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem var(--gutter) 3rem;
}
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.page-title {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}
h1 {
    font-family: var(--value);
    font-weight: 400;
    font-size: 2rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.sub {
    color: var(--text-3);
    font-size: 0.875rem;
    overflow-wrap: anywhere;
}
.back {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: -0.75rem;
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: color var(--ease);
}
.back:hover {
    color: var(--text);
}

/* ---- buttons (kit ui-button). one primary per page; it is the only thing that pushes */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0 1rem;
    border: var(--edge) solid transparent;
    border-radius: var(--radius);
    background: transparent;
    font-family: var(--body);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background-color var(--ease),
        color var(--ease),
        border-color var(--ease),
        transform var(--ease),
        box-shadow var(--ease);
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn--secondary {
    color: var(--text);
    border-color: var(--ink);
}
.btn--secondary:hover {
    background: var(--bg-tertiary);
}
.btn--ghost {
    color: var(--text-2);
}
.btn--ghost:hover:not(:disabled) {
    color: var(--text);
    background: var(--bg-tertiary);
}
.btn--primary {
    color: var(--on-accent);
    background: var(--coral);
    border-color: var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
    font-family: var(--value);
    font-weight: 400;
    font-size: 1rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}
.btn--primary:hover:not(:disabled),
.btn--primary:active:not(:disabled) {
    background: var(--coral-hi);
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 var(--ink);
}
.btn--primary:disabled {
    box-shadow: none;
}
/* destructive: outlined in error, never a block and never pushed. it asks first (the confirm panel) */
.btn--danger {
    color: var(--error);
    border-color: var(--error);
}
.btn--danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--error) 12%, transparent);
}
.confirm {
    position: relative;
}
.confirm > summary {
    list-style: none;
}
.confirm > summary::-webkit-details-marker {
    display: none;
}
.confirm[data-disabled] > summary {
    opacity: 0.5;
    pointer-events: none;
}
/* a flat sheet under the button: the elevated tone and the ink edge */
.confirm-panel {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 0.5rem);
    z-index: 100;
    display: grid;
    gap: 1rem;
    width: min(24rem, calc(100vw - 2rem));
    padding: 1rem;
    background: var(--bg-elevated);
    border: var(--edge) solid var(--ink);
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 0.875rem;
    line-height: 1.35;
    white-space: normal;
}
.confirm-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}
.btn--block {
    width: 100%;
    min-height: 2.75rem;
}
.link {
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 600;
    text-underline-offset: 3px;
}
.link:hover {
    color: var(--text);
}

/* ---- metrics: label on top, the value in Changa. no boxes, no icons */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 1.5rem;
}
.stats > div {
    display: grid;
    gap: 0.5rem;
    align-content: start;
}
.stats dt {
    order: -1;
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 600;
}
.stats dd {
    font-family: var(--value);
    font-size: 2rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.stats dd.danger {
    color: var(--error);
}

/* ---- notices: a wash of their tone and a word badge naming the kind. no side bar */
.notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 0.875rem;
    line-height: 1.35;
}
.notice p {
    flex: 1 1 18rem;
    min-width: 0;
}
.notice--warning {
    background: color-mix(in srgb, var(--warning) 14%, var(--bg-base));
}
.notice--danger {
    background: color-mix(in srgb, var(--error) 13%, var(--bg-base));
}

/* ---- badges: only for the exception. one treatment per meaning */
.badge {
    display: inline-flex;
    align-items: center;
    width: max-content;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    line-height: 1.3;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge--tone {
    color: var(--text-2);
    background: var(--bg-tertiary);
}
.badge--warning {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 16%, transparent);
}
.badge--danger {
    color: var(--error);
    background: color-mix(in srgb, var(--error) 14%, transparent);
}
.badge--success {
    color: var(--success);
    background: color-mix(in srgb, var(--success) 16%, transparent);
}

/* ---- fields: 44px wells, no edge at rest, the ink edge on focus */
.field {
    min-height: 2.75rem;
    min-width: 0;
    padding: 0 0.875rem;
    background: var(--field-bg);
    border: var(--edge) solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    transition:
        background-color var(--ease),
        border-color var(--ease);
}
.field:hover {
    background: var(--field-hover);
}
.field:focus,
.field:focus-visible {
    outline: none;
    border-color: var(--text);
}
.field::placeholder {
    color: var(--text-3);
}
select.field {
    appearance: none;
    padding-inline-end: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23919aa5' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    cursor: pointer;
}
select.field option {
    background: var(--bg-elevated);
}
.field[readonly] {
    color: var(--text-2);
    font-size: 0.875rem;
}
.check {
    appearance: none;
    display: block;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    background: var(--field-bg) center / 0.75rem no-repeat;
    border: var(--edge) solid var(--ink);
    border-radius: var(--radius);
    cursor: pointer;
    transition:
        background-color var(--ease),
        border-color var(--ease);
}
.check:hover {
    background-color: var(--field-hover);
}
.check:checked,
.check:indeterminate {
    background-color: var(--text);
    border-color: var(--text);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23040507' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2.5 6.25 2.25 2.25 4.75-5'/%3E%3C/svg%3E");
}
.check:indeterminate {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23040507' stroke-width='2.25' stroke-linecap='round'%3E%3Cpath d='M3 6h6'/%3E%3C/svg%3E");
}
.check:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- list toolbar: one row, no visible labels, search takes the free width, a count at the end */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.field--grow {
    flex: 1 1 16rem;
}
.toolbar select.field {
    flex: 0 0 12rem;
}
.count {
    margin-inline-start: auto;
    padding-inline-start: 0.5rem;
    color: var(--text-3);
    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.js .no-js,
html:not(.js) .js-only {
    display: none;
}

/* ---- bulk actions, then the rows. rows sit on the page: hover is one tone step, no dividers */
.bulk {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.bulk-count {
    margin-inline-end: auto;
    color: var(--text-3);
    font-size: 0.875rem;
}
.table-wrap {
    overflow-x: auto;
    margin-inline: -0.75rem;
}
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}
.table th {
    padding: 0.25rem 0.75rem 0.5rem;
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 600;
    text-align: start;
    white-space: nowrap;
}
.table td {
    padding: 0.75rem;
    color: var(--text);
    text-align: start;
    vertical-align: top;
    white-space: nowrap;
}
.table tbody tr {
    transition: background-color var(--ease);
}
.table tbody tr:hover {
    background: var(--bg-tertiary);
}
.table tbody tr.picked {
    background: var(--bg-hover);
}
.table td:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}
.table td:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}
.table .pick {
    width: 2.75rem;
    padding-inline-end: 0;
}
.table td.pick {
    padding-top: 0.875rem;
}
.table td.value {
    font-family: var(--value);
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}
.person {
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
}
.person:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}
.table .empty td {
    padding: 2rem 0.75rem;
    color: var(--text-3);
    white-space: normal;
}
.table .empty:hover {
    background: none;
}
.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}
.pager .count {
    margin: 0;
    padding: 0 0.5rem;
}

/* ---- sections and facts: a heavy title, one sentence, then label / value rows on the page */
.section {
    display: grid;
    align-content: start;
    gap: 1rem;
    margin-top: 1.5rem;
}
.section h2 {
    font-family: var(--value);
    font-weight: 400;
    font-size: 1.5rem;
    line-height: 1.25;
}
.section .note {
    margin-top: -0.625rem;
}
.facts {
    display: grid;
    gap: 0.25rem;
}
.facts > div {
    display: grid;
    grid-template-columns: minmax(9rem, 14rem) minmax(0, 1fr);
    gap: 0.25rem 1.5rem;
    align-items: baseline;
    padding: 0.625rem 0.75rem;
    margin-inline: -0.75rem;
    border-radius: var(--radius);
    transition: background-color var(--ease);
}
.facts > div:hover {
    background: var(--bg-tertiary);
}
.facts dt,
.facts dt label {
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 600;
}
.facts dd {
    min-width: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}
.facts dd.value {
    font-size: 1rem;
}
.facts dd > .link + .link {
    margin-inline-start: 1rem;
}
.facts dd.stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.375rem;
}
.facts dd.stack .field {
    width: 100%;
}
.prose {
    white-space: pre-wrap;
    max-width: 60ch;
}
.links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
    list-style: none;
}
.chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 2rem;
    padding: 0 0.75rem;
    color: var(--text-2);
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
    transition:
        background-color var(--ease),
        color var(--ease);
}
.chip:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* detail: answers and invitation side by side on wide screens */
.sections {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(18rem, 2fr);
    gap: 0 3rem;
    align-items: start;
}
.head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.foot {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem var(--gutter) 2rem;
    color: var(--text-3);
    font-size: 0.75rem;
    font-weight: 500;
}

/* ---- sign in: one flat sheet, the app's auth modal shape */
.login-body {
    display: grid;
    place-items: center;
    padding: 1rem;
}
.login {
    display: grid;
    justify-items: center;
    gap: 1.5rem;
    width: min(26rem, 100%);
}
.login-brand {
    width: 128px;
    height: auto;
}
.sheet {
    display: grid;
    gap: 0.75rem;
    width: 100%;
    padding: 1.5rem;
    background: var(--bg-elevated);
    border: var(--edge) solid var(--ink);
    border-radius: var(--radius);
}
.sheet h1 {
    font-size: 1.5rem;
}
.sheet form {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.sheet label {
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 600;
}
.sheet .btn--primary {
    margin-top: 0.75rem;
}

@media (max-width: 900px) {
    .sections {
        grid-template-columns: minmax(0, 1fr);
    }
}
@media (max-width: 640px) {
    :root {
        --gutter: 1rem;
    }
    .area {
        display: none;
    }
    .page {
        padding-top: 1.5rem;
    }
    h1 {
        font-size: 1.5rem;
    }
    .stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.25rem 1rem;
    }
    .stats dd {
        font-size: 1.5rem;
    }
    .toolbar select.field {
        flex: 1 1 10rem;
    }
    .bulk-count {
        flex-basis: 100%;
    }
    .facts > div {
        grid-template-columns: minmax(0, 1fr);
    }
    .head-actions {
        width: 100%;
    }
}
