/*
 * The tailwind scaffold theme's own stylesheet.
 *
 * Plain CSS on purpose: a scaffolded project has no build step, so this file is
 * served as written. Everything that needs a colour reads a **daisyUI token**
 * (`--color-base-100`, `--color-base-content`, `--color-primary`, …) rather than
 * a literal, because daisyUI redefines those per theme — a hardcoded `#fff` is
 * invisible under `data-theme="dark"`, and that is how it is usually found.
 */

html, body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* The page ground. daisyUI paints tokens, not elements. */
body {
    background-color: var(--color-base-200, #f3f4f6);
    color: var(--color-base-content, #1f2937);
}

/*
 * Tailwind v4 defaults a bare `border` to currentColor; v3 (which some of this
 * markup was written for) defaulted to gray-200. The theme uses bare `border`
 * utilities, so restore a sensible default — as a token, so it follows the
 * theme instead of staying light in the dark one.
 *
 * `@layer base` is the whole of the fix, and specificity is a red herring.
 *
 * The rule below is (0,0,1) and `.btn-ghost` is (0,1,0), so the obvious reading
 * is that the component wins. It did not: **an unlayered rule beats every
 * layered one, whatever the specificity**, and daisyUI 5 ships entirely inside
 * `@layer base / daisyui / utilities`. So this sat above all of it and drew a
 * border on every component that had asked for none — a `btn-ghost` setting
 * `--btn-border: #0000` still showed an outline, and so did inputs and cards.
 *
 * The way it was found is worth recording: a SPA does not load this file, so the
 * same markup with the same classes looked different on the two halves of one
 * application, and no amount of comparing class lists explained it.
 *
 * Inside `base` the intent still holds. Tailwind's Preflight `*` rule (0,0,0) is
 * in the same layer, where specificity does decide, so this still beats it; and
 * `base` is declared before `daisyui`, so a component's own border wins as it
 * always should have.
 */
@layer base {
    html *,
    html ::before,
    html ::after,
    html ::backdrop,
    html ::file-selector-button {
        border-color: var(--color-base-300, #e5e7eb);
    }
}

/*
 * Basic typography for the starter home page's bare semantic HTML. Tailwind's
 * Preflight strips heading sizes and list markers, so restore them — scoped to
 * .pf-home so the nav, cards and other utility-styled markup are untouched.
 */
.pf-home h1 { font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; margin-bottom: .5rem; }
.pf-home h2 { font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.pf-home p  { margin-bottom: 1rem; }
.pf-home ul { list-style: disc; padding-left: 1.5rem; margin-bottom: 1rem; }
.pf-home li { margin: .15rem 0; }
.pf-home a  { color: var(--color-primary, #2563eb); text-decoration: underline; }
.pf-home code {
    background: var(--color-base-200, #f3f4f6);
    padding: .1rem .35rem;
    border-radius: .25rem;
    font-size: .875rem;
}

/* ── Breadcrumbs (Pramnos\Html\Breadcrumb markup) ───────────────────────────
   That helper emits its own class names, not daisyUI's, so the two are bridged
   here rather than by rewriting the helper's markup in every view. */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    font-size: 0.85rem;
    color: var(--color-base-content, #6b7280);
    opacity: 0.7;
}
.breadcrumb-item h1, .breadcrumb-item h2, .breadcrumb-item h3,
.breadcrumb-item h4, .breadcrumb-item h5, .breadcrumb-item h6 {
    display: inline;
    margin: 0;
    padding: 0;
    font-size: inherit;
    font-weight: 400;
    line-height: inherit;
}
.breadcrumb-item { display: inline-flex; align-items: center; }
.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    margin-right: 0.35rem;
    opacity: 0.4;
}
.breadcrumb-item a { color: var(--color-primary, #2563eb); text-decoration: none; }
.breadcrumb-item a:hover { text-decoration: underline; }
.breadcrumb-item.active { opacity: 0.7; }

/* ── Cross-entity search box (Html\SearchBox + data-pf-omnibox) ──────────────
   Namespaced so it does not collide with a UI framework's own classes, and
   written with token fallbacks so the same block works in all three scaffold
   themes. The results panel is positioned, not laid out inline: an omnibox that
   pushes the header taller when results arrive moves the thing you were
   clicking. */
.pf-omnibox {
    position: relative;
    display: inline-block;
}

/* One recipe, two users: the omnibox label and a Datatable's caption are both text that
   must be read and not seen. */
.pf-omnibox-label,
.pf-visually-hidden {
    /* Visually hidden, not display:none — a screen reader must still read it. */
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.pf-omnibox-input {
    width: 100%;
    min-width: 12rem;
    padding: 0.45rem 0.75rem;
    font: inherit;
    color: var(--color-base-content, #1e293b);
    background: var(--color-base-100, #fff);
    border: 1px solid var(--color-base-300, #d1d5db);
    border-radius: 0.375rem;
}

.pf-omnibox-input:focus {
    outline: 2px solid var(--color-primary, #2563eb);
    outline-offset: 1px;
}

.pf-omnibox-results {
    position: absolute;
    top: calc(100% + 0.25rem);
    right: 0;
    z-index: 60;
    min-width: 20rem;
    max-height: 24rem;
    overflow-y: auto;
    color: var(--color-base-content, #1e293b);
    background: var(--color-base-100, #fff);
    border: 1px solid var(--color-base-300, #e5e7eb);
    border-radius: 0.375rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.pf-omnibox-results[hidden] {
    /* Explicit, because a `display` rule above would otherwise beat the
       attribute and leave the panel permanently open. */
    display: none;
}

.pf-omnibox-group + .pf-omnibox-group {
    border-top: 1px solid var(--color-base-300, #f1f5f9);
}

.pf-omnibox-group-label {
    margin: 0;
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.7;
}

.pf-omnibox-count {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.pf-omnibox-option {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--color-base-content, #1e293b);
    text-decoration: none;
    cursor: pointer;
}

.pf-omnibox-option:hover,
.pf-omnibox-option.is-active {
    background: var(--color-base-200, #f1f5f9);
}

.pf-omnibox-title {
    display: block;
    font-weight: 500;
}

.pf-omnibox-subtitle {
    display: block;
    font-size: 0.8125rem;
    opacity: 0.7;
}

.pf-omnibox-empty,
.pf-omnibox-loading {
    margin: 0;
    padding: 0.75rem;
    font-size: 0.875rem;
    opacity: 0.7;
}

/*
 * Datatable row actions, column filters and state pills.
 *
 * The markup comes from the framework — `Html\Icon` and `Html\Datatable` render it into
 * the JSON a table inserts — so the classes have to be styled by the theme rather than
 * carried as inline styles: a project whose CSP has no `'unsafe-inline'` for styles would
 * strip those, and the actions would be unreadable in exactly the strictest deployments.
 *
 * Two of these exist because a CSS reset removed something. Tailwind's preflight sets
 * `svg { display: block }`, which made a row of icons stack one per line; and a bare
 * `<input>` has no border, no padding and no background, which made a column filter a box
 * that was there and invisible.
 */
.pf-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: var(--radius-field, 0.375rem);
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.15s, background-color 0.15s, color 0.15s;
}

.pf-action:hover,
.pf-action:focus-visible {
    opacity: 1;
    background-color: color-mix(in oklab, currentColor 12%, transparent);
}

.pf-action + .pf-action {
    margin-inline-start: 0.125rem;
}

.pf-action-danger:hover,
.pf-action-danger:focus-visible {
    color: var(--color-error, #dc2626);
}

.pf-icon {
    display: inline-block;
    width: 1.05em;
    height: 1.05em;
}

.pf-footsearch {
    width: 100%;
    min-width: 6rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 400;
    border: 1px solid var(--color-base-300, #d4d4d8);
    border-radius: var(--radius-field, 0.375rem);
    background-color: var(--color-base-100, #fff);
    color: inherit;
}

.pf-footsearch:focus {
    outline: 2px solid var(--color-primary, #2563eb);
    outline-offset: -1px;
}

.pf-state {
    display: inline-block;
    padding: 0.0625rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    line-height: 1.4;
}

.pf-state-on {
    background-color: color-mix(in oklab, var(--color-success, #16a34a) 15%, transparent);
    color: var(--color-success, #16a34a);
}

.pf-state-off {
    background-color: color-mix(in oklab, currentColor 10%, transparent);
    opacity: 0.7;
}

.pf-muted {
    opacity: 0.55;
    font-size: 0.8125rem;
}

/* The first thing a keyboard reaches, and it must be visible once it has focus.
   Off-screen rather than hidden: `display:none` takes it out of the tab order, which
   is the whole of what it is for. */
.pf-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    padding: 8px 16px;
    background: #000;
    color: #fff;
    text-decoration: none;
}

.pf-skip-link:focus {
    left: 0;
}

/* The two components that used to emit no themeable hook at all.
   `Breadcrumb` emitted Bootstrap's own `breadcrumb`, which read as neutral and was not;
   `Pagination` emitted no class, so nothing here could reach it. Both are `pf-*` now, the
   same convention the omnibox and the rest already use — and written in the same tokens,
   so a palette change in app/themes/theme.css reaches them like everything else. */
.pf-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    font-size: 0.875rem;
    color: var(--color-base-content, #64748b);
}

.pf-breadcrumb a {
    color: var(--color-primary, #2563eb);
}

.pf-breadcrumb li + li::before {
    content: "/";
    padding-right: 0.5rem;
    color: var(--color-base-content, #64748b);
}

.pf-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

.pf-pagination a,
.pf-pagination span {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-base-300, #cbd5e1);
    border-radius: 0.25rem;
    text-decoration: none;
    color: var(--color-base-content, #1e293b);
    background: var(--color-base-100, #fff);
    /* Large enough to hit on a touch screen: WCAG 2.5.8 asks for 24px, and a pager is
       the control people tap most often on a phone. */
    min-width: 2.25rem;
    text-align: center;
}

.pf-pagination a:hover {
    border-color: var(--color-primary, #2563eb);
    color: var(--color-primary, #2563eb);
}

.pf-pagination .current,
.pf-pagination [aria-current="page"] {
    background: var(--color-primary, #2563eb);
    border-color: var(--color-primary, #2563eb);
    color: var(--color-primary-content, #fff);
    font-weight: 600;
    /* Not colour alone: WCAG 1.4.1. The weight carries it where colour cannot. */
    text-decoration: underline;
}

/* The brand logo, in the ink that reads on the navbar behind it.
   The scaffold ships two files — logo.png is dark ink, logo-inverse.png light — and the
   header renders a light/dark toggle, so one <img> cannot serve both: a near-black
   wordmark on a near-black navbar is simply not there, with nothing in any log.
   `content: url()` swaps the image on the element itself, so there is no second <img>
   to keep in sync and no JavaScript in the path.
   The selector is suffix-matched because the dark theme is named after the project —
   `<slug>-dark`, written by `init` into app/themes/theme.css — and this file is static.
   The media query is the other half: with nothing stored the toggle sets no attribute
   and the OS preference decides, which is the same scoping theme-tokens.css uses. */
[data-theme$="-dark"] .pf-logo {
    content: url("../img/logo-inverse.png");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .pf-logo {
        content: url("../img/logo-inverse.png");
    }
}

/* ── Phone width (below 640px) ───────────────────────────────────────────────
   The account menu scrolls sideways without drawing a scrollbar under it — the
   row itself says there is more. */
.pf-account-nav {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.pf-account-nav::-webkit-scrollbar { display: none; }

@media (max-width: 639px) {
    /* A 12rem search box and a 20rem panel anchored to its right edge are wider
       than what is left of a 390px header: the input shrinks, and the results
       span the screen instead of hanging off its left side. */
    .pf-omnibox-input { min-width: 7rem; }
    .pf-omnibox-results {
        position: fixed;
        top: 4rem;
        left: 0.5rem;
        right: 0.5rem;
        min-width: 0;
    }

    /* A long trail stays one line and scrolls, and a long crumb (an email
       address, a person's name) is cut with an ellipsis rather than pushing
       the page wider than the screen. */
    .pf-breadcrumb,
    .breadcrumb {
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
    }
    .pf-breadcrumb::-webkit-scrollbar,
    .breadcrumb::-webkit-scrollbar { display: none; }
    .pf-breadcrumb li,
    .breadcrumb li { flex-shrink: 0; }
    .pf-breadcrumb li > *,
    .breadcrumb li > * {
        display: inline-block;
        max-width: 12rem;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: bottom;
    }
}

/* glideday: the header's search takes the width its cell gives it on a phone
   (`max-sm:w-28` in app/themes/default/header.php), rather than its own minimum. */
@media (max-width: 639px) {
    .pf-omnibox-item .pf-omnibox { display: block; width: 100%; }
    .pf-omnibox-item .pf-omnibox-input { min-width: 0; }
}


/* Stat tiles — Pramnos\Html\StatTile. A figure with a label, the tile every dashboard draws.
   Tabular digits so a number that changes does not shift its neighbours; the state is a left
   border, so it reads without colour too (the data-state is on the element for scripts). */
.pf-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.75rem;
    margin: 0 0 1rem;
}
.pf-stat-tile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
    background: var(--color-base-100, #fff);
    color: var(--color-base-content, #1f2937);
    border: 1px solid var(--color-base-300, #e5e7eb);
    border-left-width: 4px;
    border-radius: 0.5rem;
    text-decoration: none;
}
a.pf-stat-tile:hover { border-color: var(--color-primary, #2563eb); }
.pf-stat-tile__label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.65;
}
.pf-stat-tile__value {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.pf-stat-tile__note { font-size: 0.8125rem; opacity: 0.65; }
.pf-stat-tile__progress { width: 100%; height: 0.5rem; accent-color: var(--color-primary, #2563eb); }
.pf-stat-tile--good { border-left-color: var(--color-success, #16a34a); }
.pf-stat-tile--good .pf-stat-tile__progress { accent-color: var(--color-success, #16a34a); }
.pf-stat-tile--warning { border-left-color: var(--color-warning, #d97706); }
.pf-stat-tile--critical { border-left-color: var(--color-error, #dc2626); }

/* What the last action said — "Saved.", or why not — above the page: \Pramnos\Html\Flash::render() in both themes. */
.pf-flash {
    display: grid;
    gap: .5rem;
    margin-bottom: 1rem;
}

.pf-flash-message,
.pf-flash-error {
    margin: 0;
    padding: .75rem 1rem;
    border-radius: .375rem;
    border-left: 4px solid currentColor;
}

.pf-flash-message {
    color: var(--color-success, #16a34a);
    background: color-mix(in oklab, var(--color-success, #16a34a) 12%, transparent);
}

.pf-flash-error {
    color: var(--color-error, #dc2626);
    background: color-mix(in oklab, var(--color-error, #dc2626) 12%, transparent);
}
