/*
 * ctnlist application styles: a thin layer over Bootstrap 6. Prefer Bootstrap
 * classes in templates; add rules here only for the shared layout and for
 * patterns Bootstrap has no utility for.
 *
 * Bootstrap 6 keeps its CSS in cascade layers and its utilities are not
 * !important, so anything outside a layer would beat every utility class.
 * These rules therefore live in Bootstrap's own "custom" layer: above its
 * components, below its helpers and utilities.
 */

:root {
    --app-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
    --bs-body-font-family: var(--app-font-sans);
}

@layer custom {

/* Header: the site navbar plus, for staff, the administration bar. */
.app-header .ctn-navbar-brand {
    font-weight: 600;
    letter-spacing: -0.01em;
}

.app-header .ctn-navbar-brand .app-icon {
    color: var(--bs-primary-fg);
}

.app-header .ctn-nav-link.active {
    font-weight: 600;
}

.app-navbar .ctn-nav-link.active {
    color: var(--bs-primary-fg);
}

/* The lg breakpoint, where the navigation leaves its drawer (Bootstrap 6: 1024px). */
@media (min-width: 1024px) {
    .app-navbar .ctn-navbar-nav > .ctn-nav-item > a.ctn-nav-link.active {
        box-shadow: inset 0 -2px 0 var(--bs-primary-base);
    }
}

.app-adminbar {
    font-size: 0.875rem;
}

/* The administration bar is a slim second row, not a second full-height navbar. */
.app-adminbar {
    --bs-navbar-min-height: 2.5rem;
    --bs-navbar-padding-y: 0.125rem;
}

/* Message boxes keep the space below them that Bootstrap 5 gave every alert. */
.app-content .ctn-alert {
    margin-bottom: var(--bs-spacer);
}

/* A message's close button (CattoPHP's, drawn) at the message's end. */
.ctn-alert > .cl-ui-close {
    margin-inline-start: auto;
}

/* Page content. Forms are grouped in bordered fieldsets or cards. */
.app-content fieldset > legend {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Data tables: compact, readable headings on a tinted row (Bootstrap 5's thead.table-light). */
.app-content .ctn-table {
    font-size: 0.9375rem;
}

.app-content .ctn-table > thead > tr > * {
    --bs-table-bg-type: var(--bs-bg-2);
}

/* Visually hidden headings (.visually-hidden is absolutely positioned) stay inside
   the scrolling wrapper instead of widening the page on narrow screens (CattoPHP's data table's box is the wrapper). */
.app-content .ctn-table-responsive,
.app-content .cl-ui-table {
    position: relative;
}

.app-content .ctn-table > thead th {
    font-weight: 600;
    white-space: nowrap;
}

/* A card's body (CattoPHP's surface in its card form) lays its parts out without their own margins, as Bootstrap's card
   body did, below any rule of this layer and any utility a part carries. */
:where(.cl-ui-surface--card:not(.cl-ui-surface--flush) > .cl-ui-surface-body > *) {
    margin-block: 0;
}

/* A part of a card whose body is flush (CattoPHP's surface with body 'flush': a list, a table and words in one card):
   padded and spaced as a card's body, its buttons starting at its left edge, and set off by a hairline from a part or a
   list before it, as Bootstrap's card body was. */
.app-card-part {
    display: flex;
    flex: auto;
    flex-direction: column;
    align-items: stretch;
    gap: calc(var(--bs-spacer-6) * .5);
    padding: var(--bs-spacer-6);
}

.app-card-part > * {
    margin-block: 0;
}

.app-card-part > .cl-ui-action {
    align-self: start;
}

.cl-ui-surface-body > :is(.app-card-part, .app-list) + :is(.app-card-part, .app-list) {
    border-block-start: var(--bs-border-width) solid var(--bs-border-color);
}

/* Lists of rows in one bordered box (Bootstrap's list group, ctnlist's own since B12: CattoPHP's list lays its items out
   as separate rows with their contents aligned to the top): app-list, its rows app-list-item, a row that is a link
   app-list-item-action, and app-list-flush inside a card, without the outer edge. */
.app-list {
    --app-list-border: var(--bs-border-width) solid var(--bs-border-color);
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    padding-inline-start: 0;
    border-radius: var(--bs-radius-5);
}

.app-list-item {
    position: relative;
    display: block;
    padding: var(--bs-spacer-2) var(--bs-spacer);
    color: var(--bs-fg-body);
    text-decoration: none;
    background-color: var(--bs-bg-body);
    border: var(--app-list-border);
}

.app-list-item:first-child {
    border-start-start-radius: inherit;
    border-start-end-radius: inherit;
}

.app-list-item:last-child {
    border-end-end-radius: inherit;
    border-end-start-radius: inherit;
}

.app-list-item + .app-list-item {
    border-block-start-width: 0;
}

.app-list-item-action {
    width: 100%;
    color: var(--bs-fg-2);
    text-align: inherit;
    text-decoration: none;
}

.app-list-item-action:hover,
.app-list-item-action:focus {
    z-index: 1;
    color: var(--bs-fg-1);
    text-decoration: none;
    background-color: var(--bs-bg-1);
}

.app-list-item-action:active {
    color: var(--bs-fg-body);
    background-color: var(--bs-bg-2);
}

.app-list-flush {
    border-radius: 0;
}

.app-list-flush > .app-list-item {
    border-width: 0 0 var(--bs-border-width);
}

.app-list-flush > .app-list-item:last-child {
    border-block-end-width: 0;
}

/* A list at the top or the foot of a card's flush body takes the card's inner corners, as Bootstrap's list group did. */
.cl-ui-surface--flush > .cl-ui-surface-body:first-child > .app-list:first-child {
    border-start-start-radius: calc(var(--bs-radius-7) - var(--bs-border-width));
    border-start-end-radius: calc(var(--bs-radius-7) - var(--bs-border-width));
}

.cl-ui-surface--flush > .cl-ui-surface-body:last-child > .app-list:last-child {
    border-end-end-radius: calc(var(--bs-radius-7) - var(--bs-border-width));
    border-end-start-radius: calc(var(--bs-radius-7) - var(--bs-border-width));
}

/* Joined buttons (Bootstrap's button group): CattoPHP's actions side by side, sharing their edges (the theme paints the
   joins). */
.app-btn-group {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}

/* An icon beside words (app-icon around CattoPHP's icon, drawn from the theme's sprite): the box and place the icon
   font's glyph had, 1em square, its foot .1458em below the baseline (in the words' size; the drawing is 1.1 of its own
   size, so its own em is the words' / 1.1), so every line and every label keeps its height. */
.app-icon > .cl-ui-icon,
.cl-group-tab-icon > .cl-ui-icon,
.cl-ui-pager-icon > .cl-ui-icon,
.cl-ui-menu-icon > .cl-ui-icon {
    font-size: calc(100% / 1.1);
    vertical-align: calc(-.1458em * 1.1);
}

/* Two glyphs the icon font advanced by less than their size, measured where they stand (B12): the top bar's envelope
   (15.84375px at 16px) and the administration bar's small chevrons (12px at 12.25px). The drawings keep their size and
   the words after them keep their place. */
.app-navbar .ctn-navbar-brand > .app-icon > .cl-ui-icon {
    margin-right: -.15625px;
}

.app-adminbar .app-icon.small > .cl-ui-icon {
    margin-right: -.25px;
}

/* Single-purpose forms (sign-in, consent, confirmations) stay readable on wide screens. */
.app-narrow {
    max-width: 40rem;
    margin-inline: auto;
}

/* The hidden trap field of the sign-in and subscribe forms (BotTrapType): off-screen, not display: none, which form bots skip. */
.app-trap {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* The acceptable use policy (rendered from docs/AUP.md): one readable column. */
.app-policy {
    max-width: 52rem;
    margin-inline: auto;
}
.app-policy h2 {
    margin-top: 2rem;
}
.app-policy li {
    margin-bottom: 0.25rem;
}

/* Tabs scroll sideways on narrow screens instead of wrapping (Settings), with a thin scroll bar. */
.app-tabs > .cl-group-nav {
    scrollbar-width: thin;
}

.border-dashed {
    border-style: dashed !important;
}

.app-footer a {
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* A label or legend drawn on its own for a required field (CattoPHP's field draws its own marker). */
.ctn-form-label.required::after {
    content: " *";
    color: var(--bs-danger-fg);
}

/* Help text written beside a control by hand (not CattoPHP's field's, which its grid spaces) keeps its small gap. */
:not(.ctn-form-group) > .ctn-form-text {
    margin-top: 0.25rem;
}

/* A menu of checkboxes under a select-like toggle (the message editor's lists: CattoPHP's menu of choices, as wide as
   the toggle and scrolling when long): its ticks a little apart. */
[data-checklist] > div + div {
    margin-top: 0.375rem;
}

/* Profile pictures: always round, always cropped to fill (the stored image is square). */
.app-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: var(--bs-secondary-bg);
}

.app-avatar-lg {
    width: 8rem;
    height: 8rem;
}

/* The profile picture editor (assets/profile_image.js): a square stage with a round mask. */
.app-image-stage {
    position: relative;
    width: 100%;
    max-width: 20rem;
    aspect-ratio: 1;
    touch-action: none;
    cursor: grab;
    border-radius: var(--bs-radius-4);
    overflow: hidden;
    background-color: var(--bs-secondary-bg);
}

.app-image-stage.is-dragging {
    cursor: grabbing;
}

.app-image-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Darkens what falls outside the circle the navbar and profile show. */
.app-image-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.45);
    outline: 2px solid rgb(255 255 255 / 0.85);
    pointer-events: none;
}

.app-image-preview {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
}

/* htmx (templates/CLAUDE.md, "htmx"). An indicator shows only while its request runs, after a
   short pause so that a quick answer never flashes it. */
.htmx-indicator {
    opacity: 0;
    visibility: hidden;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
    visibility: visible;
    transition: opacity 200ms ease-in 300ms;
}

/* A value with its copy button (layout/_copy.html.twig). */
.app-copy {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    max-width: 100%;
}

.app-copy > code {
    overflow-wrap: anywhere;
}

/* Set up sending: the steps, one open at a time. */
.app-steps > li + li {
    margin-top: 1rem;
}

.app-steps .app-step-mark {
    flex: none;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* A webhook event's body, opened under its id (Webhook events, administrators): wrapped inside the cell, scrolling past
   a screenful. */
.app-webhook-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 24rem;
    overflow: auto;
}

/* A region brought into view after a page turn stays clear of the sticky header. */
.app-region {
    scroll-margin-top: 8rem;
}

} /* @layer custom */
