/* Design tokens shared by every page. Brand colours live in layout.css (:root) and are
   referenced here; do not redefine them. Component styles read these instead of literals. */
:root {
    /* Type scale */
    --fs-xs: .75rem;
    --fs-sm: .875rem;
    --fs-md: 1rem;
    --fs-lg: 1.25rem;
    --fs-xl: 1.75rem;

    /* Spacing (4px base) */
    --sp-1: .25rem;
    --sp-2: .5rem;
    --sp-3: .75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Elevation */
    --shadow-1: 0 1px 3px rgba(44, 26, 24, .08), 0 1px 2px rgba(44, 26, 24, .06);
    --shadow-2: 0 8px 20px rgba(44, 26, 24, .12);

    /* Semantic colours, text-safe (>= 4.5:1 on white and on --cream-bg) */
    --ink: #2c1a18;
    --ink-muted: #6b5d59;
    --line: rgba(75, 46, 43, .14);
    --c-success: #1e7a43;
    --c-success-bg: #e3f3e9;
    --c-danger: #b42318;
    --c-danger-bg: #fdeceb;
    --c-warning: #8a5a00;
    --c-warning-bg: #fff3d6;
    --c-info: #0b6580;
    --c-info-bg: #e0f2f7;

    /* Focus ring */
    --focus-ring: 0 0 0 .2rem #fff, 0 0 0 .4rem #1a5fd0;

    /* Motion */
    --dur-fast: 120ms;
    --dur-base: 200ms;
    --dur-slow: 320ms;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --transition-ui: background-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease),
        border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease),
        transform var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease), left var(--dur-base) var(--ease), padding-left var(--dur-base) var(--ease);
}

@media (prefers-reduced-motion: reduce) {
    :root { --dur-fast: 0ms; --dur-base: 0ms; --dur-slow: 0ms; }
    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}

/* Keyboard focus: one visible ring everywhere, mouse clicks stay quiet. */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible, summary:focus-visible,
.form-control:focus-visible, .form-select:focus-visible, .form-check-input:focus-visible,
.page-link:focus-visible, .dropdown-item:focus-visible, .nav-link:focus-visible,
.btn-close:focus-visible, .list-group-item-action:focus-visible, textarea:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Taps respond at once (no double-tap-zoom delay) and don't flash the browser's grey box. */
a, button, [role="button"], summary, label, .form-check-input, .form-select {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* A table placed straight in a card body scrolls sideways on narrow screens instead of overflowing. */
.card-body:has(> .table) { overflow-x: auto; }

/* Short headings wrap evenly instead of leaving a one-word last line. */
h1, h2, h3, .page-header h1, .card-header { text-wrap: balance; }

/* Scrolling the open mobile sidebar must not scroll the page behind it. */
.sidebar { overscroll-behavior: contain; }

/* Native controls follow the page palette, not the OS theme. */
:root { color-scheme: light; }

/* The sticky mobile top bar must not cover a focused field or anchor target. */
@media (max-width: 768px) {
    html { scroll-padding-top: 5rem; }
}

.skip-link {
    position: fixed; left: var(--sp-3); top: var(--sp-3); z-index: 2000;
    padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-sm);
    background: var(--coffee-primary); color: #fff; font-weight: 600; text-decoration: none;
    transform: translateY(-200%);
}
.skip-link:focus { transform: none; color: #fff; }

/* Shared numeric treatment */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Busy state for submit buttons (set by site.js on submit) */
.btn.is-busy { pointer-events: none; opacity: .85; }
.btn.is-busy::after {
    content: ""; display: inline-block; width: .9em; height: .9em; margin-left: .5em;
    vertical-align: -.1em; border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Semantic badges (AA-safe replacement for bg-info/bg-warning white-on-colour) */
.badge-soft { font-weight: 600; border: 1px solid transparent; }
.badge-soft.is-success { color: var(--c-success); background: var(--c-success-bg); border-color: rgba(30,122,67,.25); }
.badge-soft.is-danger  { color: var(--c-danger);  background: var(--c-danger-bg);  border-color: rgba(180,35,24,.25); }
.badge-soft.is-warning { color: var(--c-warning); background: var(--c-warning-bg); border-color: rgba(138,90,0,.25); }
.badge-soft.is-pending { color: #765400; background: #ffec99; border-color: rgba(118,84,0,.3); }
.badge-soft.is-info    { color: var(--c-info);    background: var(--c-info-bg);    border-color: rgba(11,101,128,.25); }
.badge-soft.is-neutral { color: var(--ink-muted); background: #efe9e3; border-color: var(--line); }
