/* Shared building blocks: cards, badges, list rows, tabs, stat tiles, key-value rows, timelines. */

/* ---------------------------------------------------------------- text */

.eyebrow {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--ink-muted);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-black);
    line-height: var(--leading-tight);
    letter-spacing: -0.01em;
}

@media (min-width: 900px) {
    .page-title {
        font-size: var(--text-3xl);
    }
}

.section-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
}

.lead {
    font-size: var(--text-lg);
    color: var(--ink-soft);
}

.muted {
    color: var(--ink-muted);
}

.small {
    font-size: var(--text-sm);
}

.italic {
    font-style: italic;
}

.text-link {
    font-weight: var(--weight-bold);
    color: var(--accent-ink);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.text-link:hover {
    color: var(--accent);
}

.stack > * + * {
    margin-top: var(--space-4);
}

.stack-sm > * + * {
    margin-top: var(--space-2);
}

.stack-lg > * + * {
    margin-top: var(--space-8);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

/* The heading wraps if it must; the link or button beside it never does. */
.section-head > :not(:first-child) {
    flex-shrink: 0;
    white-space: nowrap;
}

.row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.row-wrap {
    flex-wrap: wrap;
}

.row-between {
    justify-content: space-between;
}

.grow {
    flex: 1;
    min-width: 0;
}

/* ---------------------------------------------------------------- cards */

.card {
    padding: var(--space-5);
    border: var(--border-thin) solid var(--line);
    border-radius: var(--radius-card);
    background: var(--paper);
    box-shadow: var(--shadow-card);
}

/* Missing or not-yet-reviewed content, unclaimed profiles, empty slots. */
.card-dashed {
    border-style: solid;
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.55);
    box-shadow: none;
}

/* Candidate replies, disclosures, neutrality promise, share card: a tinted panel. */
.card-heavy {
    border-color: var(--accent-line);
    background: var(--accent-tint);
    box-shadow: none;
}

.card-link {
    display: block;
    text-decoration: none;
    transition: box-shadow 120ms ease, border-color 120ms ease;
}

.card-link:hover {
    border-color: var(--accent-line);
    box-shadow: var(--shadow-raised);
}

.card-grid {
    display: grid;
    gap: var(--space-4);
}

@media (min-width: 640px) {
    .card-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1000px) {
    .card-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.divider-dashed {
    border: 0;
    border-top: var(--border-thin) solid var(--line-strong);
    margin: var(--space-3) 0;
}

/* ---------------------------------------------------------------- badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px var(--space-3);
    border: var(--border-thin) solid var(--line-strong);
    border-radius: var(--radius-pill);
    background: var(--paper);
    color: var(--ink-soft);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    line-height: var(--leading-normal);
    white-space: nowrap;
}

.badge svg {
    width: 16px;
    height: 16px;
}

/* Teal and filled: Candidate reply, Candidate answer. */
.badge-solid {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--paper);
}

/* Uncertain or unknown: Pending, Unclaimed, Not verified, Label added. */
.badge-dashed {
    border-style: solid;
    background: transparent;
    color: var(--ink-muted);
}

/* Checked by someone: Verified, Credentials checked, Document checked, Current. */
.badge-ok {
    border-color: var(--accent-line);
    background: var(--accent-tint);
    color: var(--accent-ink);
}

.badge-feasible {
    border-color: var(--feasible-line);
    background: var(--feasible-bg);
    color: var(--feasible-ink);
}

.badge-vague {
    border-style: solid;
    border-color: var(--vague-line);
    background: var(--vague-bg);
    color: var(--vague-ink);
}

.badge-outside {
    border-color: var(--outside-line);
    background: var(--outside-bg);
    color: var(--outside-ink);
}

.badge-delivered {
    border-color: var(--delivered-line);
    background: var(--delivered-bg);
    color: var(--delivered-ink);
}

.badge-contradicted,
.badge-removed {
    border-color: var(--contradicted-line);
    background: var(--contradicted-bg);
    color: var(--contradicted-ink);
}

.badge-kept {
    border-color: var(--line-strong);
    background: var(--paper-tint);
    color: var(--ink-soft);
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* Legend dots for the tag table. */
.tag-mark {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 5px;
    flex-shrink: 0;
    background: var(--line-strong);
}

.tag-mark-feasible {
    background: var(--feasible-dot);
}

.tag-mark-vague {
    background: var(--vague-dot);
}

.tag-mark-outside {
    background: var(--outside-dot);
}

.tag-mark-delivered {
    background: var(--delivered-dot);
}

.tag-mark-contradicted {
    background: var(--contradicted-dot);
}

.tag-mark-none {
    border: var(--border-thin) solid var(--ink-muted);
    border-radius: 50%;
    background: transparent;
}

/* ---------------------------------------------------------------- list rows */

/* Flat rows split by hairlines: leading icon, plain label, muted count, ink chevron. */
.list {
    border: var(--border-thin) solid var(--line);
    border-radius: var(--radius-card);
    background: var(--paper);
    /* No overflow clipping: popups such as the date card must show. */
}

.list > * + *,
.list li + li {
    border-top: var(--border-thin) solid var(--line);
}

.list-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-height: 56px;
    padding: var(--space-3) var(--space-5);
    text-decoration: none;
}

/* Hover fills the whole row; the outer rows keep the card's corners. */
a.list-row:hover,
button.list-row:hover,
summary.list-row:hover {
    background: var(--accent);
    color: var(--paper);
}

.list > :first-child > .list-row,
.list > .list-row:first-child,
.list > :first-child.list-row {
    border-top-left-radius: calc(var(--radius-card) - 1px);
    border-top-right-radius: calc(var(--radius-card) - 1px);
}

.list > :last-child > .list-row,
.list > .list-row:last-child,
.list > details:last-child:not([open]) > .list-row {
    border-bottom-left-radius: calc(var(--radius-card) - 1px);
    border-bottom-right-radius: calc(var(--radius-card) - 1px);
}

a.list-row:hover :not(.badge, .badge *),
button.list-row:hover :not(.badge, .badge *),
summary.list-row:hover :not(.badge, .badge *) {
    color: var(--paper);
}

button.list-row {
    width: 100%;
    border: 0;
    background: var(--paper);
    text-align: left;
    font-size: var(--text-md);
    cursor: pointer;
}

/* A title with an optional detail line underneath. */
.list-row-label {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.list-row-value {
    font-weight: var(--weight-bold);
    text-align: right;
}

.list-row > svg {
    width: 20px;
    height: 20px;
    color: var(--ink);
    flex-shrink: 0;
}

/* Optional icon before the label. */
.list-row-icon {
    display: inline-flex;
    flex-shrink: 0;
    color: var(--accent);
}

.list-row-icon svg {
    width: 22px;
    height: 22px;
}

.list-row-count {
    color: var(--ink-muted);
    font-size: var(--text-sm);
}

/* ---------------------------------------------------------------- tabs */

.tabs {
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    border-bottom: var(--border-thin) solid var(--line);
}

.tab {
    flex-shrink: 0;
    padding: var(--control-pad-y) var(--control-pad-x);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    color: var(--ink);
    font-size: var(--control-font);
    font-weight: var(--weight-bold);
    text-decoration: none;
    white-space: nowrap;
}

.tab:hover,
.tab[aria-current='page'] {
    border-bottom-color: var(--accent);
    color: var(--accent);
}

/* ---------------------------------------------------------------- stat tiles */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

@media (min-width: 1000px) {
    .stat-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.stat {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
    padding: var(--space-4);
    border: var(--border-thin) solid var(--line);
    border-radius: var(--radius-card);
    background: var(--paper);
    box-shadow: var(--shadow-card);
}

/* Label gets two lines, then the number, then up to two lines of note: numbers line up across tiles. */
.stat > .eyebrow {
    display: -webkit-box;
    min-height: calc(2 * 1.35em);
    overflow: hidden;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.stat > .small {
    min-height: calc(2 * 1.4em);
    line-height: 1.4;
}

.stat-value {
    display: block;
    font-size: var(--text-3xl);
    font-weight: var(--weight-black);
    line-height: 1;
}

/* ---------------------------------------------------------------- key / value */

.kv {
    display: grid;
    /* The label column fits its longest label, up to 45% of the width. */
    grid-template-columns: fit-content(45%) minmax(0, 1fr);
    gap: var(--space-2) var(--space-4);
}

.kv dt {
    font-weight: var(--weight-bold);
    color: var(--ink-soft);
}

/* ---------------------------------------------------------------- timeline */

/* A light teal line with an open teal circle at each entry. Doubled class beats the
   ol[role=list] reset in base.css. */
.timeline.timeline {
    position: relative;
    padding-left: var(--space-10);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--accent-line);
}

.timeline > li {
    position: relative;
}

.timeline > li::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--space-10) + 2px);
    top: 4px;
    width: 20px;
    height: 20px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: var(--surface);
}

.timeline > * + * {
    margin-top: var(--space-6);
}

/* ---------------------------------------------------------------- avatars */

.avatar {
    position: relative;
    flex-shrink: 0;
    width: 88px;
    height: 88px;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--paper);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* No photo: a white panel with a teal person silhouette (the SVG is in the fragment). */
.avatar-empty {
    border: var(--border-thin) solid var(--accent);
    background: var(--paper);
    color: var(--accent);
}

.avatar-empty svg {
    width: 100%;
    height: 100%;
}

/* The silhouette stands in when there is no photo or it fails to load (app.js). */
.avatar img + svg {
    display: none;
}

.avatar.is-broken img {
    display: none;
}

.avatar.is-broken img + svg {
    display: block;
}

.avatar-round {
    border-radius: 50%;
}

.avatar-lg {
    width: 120px;
    height: 120px;
}

.avatar-sm {
    width: 64px;
    height: 64px;
}

.initials {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border: var(--border-thin) solid var(--accent-line);
    border-radius: 50%;
    background: var(--accent-tint);
    color: var(--accent-ink);
    font-weight: var(--weight-black);
}

.initials-sm {
    width: 44px;
    height: 44px;
    font-size: var(--text-sm);
}

.initials-dashed {
    border-style: solid;
}

/* ---------------------------------------------------------------- notices */

.notice {
    padding: var(--space-4) var(--space-5);
    border: var(--border-thin) solid var(--line-strong);
    border-radius: var(--radius-card);
}

.notice-error {
    border-style: solid;
    border-color: var(--contradicted-line);
    background: var(--contradicted-bg);
    color: var(--danger);
}

.empty {
    padding: var(--space-6);
    border: var(--border-thin) solid var(--line-strong);
    border-radius: var(--radius-card);
    color: var(--ink-muted);
    text-align: center;
}

/* ---------------------------------------------------------------- breadcrumb */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-2);
}

.breadcrumb-sep {
    color: var(--ink-muted);
}

.place-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: var(--border-thin) solid var(--line);
}

.place-bar svg {
    width: 26px;
    height: 26px;
    color: var(--accent);
    flex-shrink: 0;
}

/* ---------------------------------------------------------------- progress */

.progress-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
}

.progress-step {
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--line);
}

.progress-step-done {
    background: var(--progress);
}

a.badge {
    text-decoration: none;
}

a.badge:hover {
    border-color: var(--accent-line);
    color: var(--accent-ink);
}

/* Thumbnail or icon on the left, a title and a muted line stacked on the right. */
.media-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.media-row > .thumb {
    flex-shrink: 0;
}

.media-row-text {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

/* Keeps the line breaks people typed, e.g. in a statement. */
.pre-line {
    white-space: pre-line;
}

/* ---------------------------------------------------------------- feedback: loaders and toasts */
/* Markup and usage: templates/fragments/feedback.html. */

/* Four blocks shuffling. Takes the text colour, so it reads on filled and outlined buttons. */
.loader,
.is-loading::before,
.btn.htmx-request::before,
form.htmx-request [type='submit']::before {
    --c: no-repeat linear-gradient(currentColor 0 0);
    content: '';
    display: inline-block;
    flex: none;
    height: 60px;
    aspect-ratio: 2 / 3;
    background: var(--c), var(--c), var(--c), var(--c);
    background-size: 50% 33.4%;
    animation: loader-blocks 1.5s infinite linear;
}

/* In a button: as tall as the text, in place of the icon. */
.is-loading::before,
.btn.htmx-request::before,
form.htmx-request [type='submit']::before {
    height: 1.1em;
}

.is-loading,
.btn.htmx-request,
form.htmx-request [type='submit'] {
    cursor: progress;
    pointer-events: none;
}

.is-loading > svg,
.btn.htmx-request > svg,
form.htmx-request [type='submit'] > svg {
    display: none;
}

.loader-sm {
    height: 1.1em;
}

/* A search box while results load: the loader takes the icon's place. */
.input-with-icon:has(> .htmx-request) > svg {
    visibility: hidden;
}

.input-with-icon:has(> .htmx-request)::after {
    --c: no-repeat linear-gradient(currentColor 0 0);
    content: '';
    position: absolute;
    left: 17px;
    top: 50%;
    height: 18px;
    aspect-ratio: 2 / 3;
    color: var(--accent);
    background: var(--c), var(--c), var(--c), var(--c);
    background-size: 50% 33.4%;
    transform: translateY(-50%);
    animation: loader-blocks 1.5s infinite linear;
}

@keyframes loader-blocks {
    0%,
    5% {
        background-position: 0 25%, 100% 25%, 0 75%, 100% 75%;
    }
    33% {
        background-position: 0 50%, 100% 0, 0 100%, 100% 50%;
    }
    66% {
        background-position: 0 50%, 0 0, 100% 100%, 100% 50%;
    }
    95%,
    100% {
        background-position: 0 75%, 0 25%, 100% 75%, 100% 25%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .loader,
    .is-loading::before,
    .btn.htmx-request::before,
    form.htmx-request [type='submit']::before,
    .input-with-icon:has(> .htmx-request)::after {
        animation-duration: 4s;
    }
}

/* Toasts: success and error messages after an action, in the middle of the window. */
.toast-region {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: min(480px, calc(100vw - 2 * var(--space-4)));
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
    border: var(--border-thin) solid var(--line-strong);
    border-radius: var(--radius-card);
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-raised);
    pointer-events: auto;
    animation: toast-in 180ms ease-out;
}

.toast.is-leaving {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.toast-icon {
    display: inline-flex;
    flex: none;
    margin-top: 1px;
}

.toast-icon svg {
    width: 20px;
    height: 20px;
}

.toast-icon-success {
    color: var(--accent);
}

.toast-icon-error {
    color: var(--danger-fill);
}

.toast-success .toast-icon-error,
.toast-error .toast-icon-success {
    display: none;
}

.toast-message {
    flex: 1;
    margin: 0;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-normal);
}

.toast-close {
    display: inline-flex;
    flex: none;
    margin: -4px -4px -4px 0;
    padding: 6px;
    border: 0;
    border-radius: var(--radius-button);
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
}

.toast-close:hover {
    background: var(--accent-soft);
    color: var(--ink);
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}


/* The page loader: over the page while the next one (or an htmx update) loads. */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.55);
    color: var(--accent);
    cursor: progress;
    animation: page-loader-in 160ms ease-out;
}

@keyframes page-loader-in {
    from {
        opacity: 0;
    }
}

/* A page heading at the top of a page whose content otherwise starts flush under the header. */
.page-heading {
    padding: var(--space-5) 0 var(--space-3);
}
