/* frampifyd theme layer (2026-08-15 htmx+material plan WS-1).
 *
 * This file is FIRST-PARTY and load-bearing for the G-1 hybrid strategy:
 * every domain-specific style lives here as a .f-* class over Beer CSS's
 * MD3 custom properties, so beer-*.min.css can later be swapped for a
 * hand-rolled sheet without touching template semantics. Templates may use
 * only the Beer classes listed in BEER-SUBSET.md plus the .f-* classes
 * below (grep-guarded by ttu_template_assets_test.go).
 *
 * Light/dark: Beer CSS themes itself from the device color scheme; the
 * semantic tones below do the same via prefers-color-scheme. There is no
 * manual theme toggle (plan G-11).
 */

:root {
  --f-tone-ok-bg: #cdeed3;
  --f-tone-ok-fg: #0b5223;
  --f-tone-warn-bg: #ffe1b0;
  --f-tone-warn-fg: #6b4300;
  --f-tone-err-bg: #ffdad6;
  --f-tone-err-fg: #93000a;
  --f-tone-info-bg: #d6e3ff;
  --f-tone-info-fg: #1c438f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --f-tone-ok-bg: #1d4a29;
    --f-tone-ok-fg: #b6e8bf;
    --f-tone-warn-bg: #5c3a00;
    --f-tone-warn-fg: #ffdfa6;
    --f-tone-err-bg: #73342c;
    --f-tone-err-fg: #ffdad6;
    --f-tone-info-bg: #2b4678;
    --f-tone-info-fg: #d6e3ff;
  }
}

/* --- semantic status chips ------------------------------------------- */

.f-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.f-tone-ok   { background-color: var(--f-tone-ok-bg);   color: var(--f-tone-ok-fg); }
.f-tone-warn { background-color: var(--f-tone-warn-bg); color: var(--f-tone-warn-fg); }
.f-tone-err  { background-color: var(--f-tone-err-bg);  color: var(--f-tone-err-fg); }
.f-tone-info { background-color: var(--f-tone-info-bg); color: var(--f-tone-info-fg); }
.f-tone-muted { background-color: var(--surface-variant); color: var(--on-surface-variant); }

/* --- layout ------------------------------------------------------------ */

main {
  padding: 1rem;
  max-inline-size: 80rem;
}

/* Console-scale type: Beer's display-size headings are oversized for a
 * dense operator tool. */
main h1 {
  font-size: 1.75rem;
  line-height: 2.25rem;
  font-weight: 600;
  margin-block: 0.25rem 0.75rem;
}

main h2 {
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 600;
}

main h3 {
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 600;
}

.f-login h1 {
  font-size: 1.75rem;
  line-height: 2.25rem;
}

.f-appbar-title {
  display: inline-flex;
  flex-direction: row;
  align-items: baseline;
  gap: 0.4rem;
  white-space: nowrap;
  font-size: 1rem;
  overflow: visible;
}

/* Empty-field affordance: a RESTING floating label means "no value here
 * yet" — it must read as a placeholder, never as a value. Beer's own
 * states make the hook precise: resting = :placeholder-shown (every input
 * carries the guard-enforced blank placeholder) and not :focus. The
 * visual hierarchy becomes:
 *   focused label             -> primary color (Beer default)
 *   floated label (has value) -> normal label color, small, on the border
 *   resting label (empty)     -> muted italic placeholder styling, and
 *                                the empty field's own border goes dashed
 *                                (an "empty slot"), snapping solid on
 *                                focus or once a value exists. */
.field.label > :placeholder-shown:not(:focus) + label {
  color: var(--outline);
  font-style: italic;
}

.field.border > :is(input, textarea):placeholder-shown:not(:focus) {
  border-style: dashed;
}

/* Beer renders part of a labeled border-field's TOP edge with the label's
 * own ::after — a line that overlays the input's border after the label
 * text. In the resting/empty state the input's border is NOT clip-pathed
 * (Beer only cuts the label gap when floated/focused), so that overlay is
 * redundant — and two superimposed dashed lines with different dash
 * phases union into a solid-looking segment. Drop the overlay entirely in
 * the empty state; the input's own dashed border spans the full edge.
 * Floated/focused states keep Beer's line (there the input border IS
 * clipped and the ::after is load-bearing). */
.field.label.border:not(.fill) > :placeholder-shown:not(:focus) + label::after {
  border-block-start: none;
}

/* Links inside content tables/cards need visible affordance — since the
 * orduuid7-to-timestamp change they are often plain timestamps. */
main table a,
main article > p > a {
  color: var(--primary);
  font-weight: 500;
}

/* <details> summaries are interactive controls; make them read that way. */
summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  padding-block: 0.5rem;
  user-select: none;
}

/* Wide content scrolls inside its own wrapper; the page body never
 * scrolls horizontally (asserted by the WS-7 e2e resize tests). */
.f-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.f-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.f-stat {
  flex: 1 1 10rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background-color: var(--surface-container);
}

.f-stat > .f-stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 2.25rem;
}

.f-stat > .f-stat-label {
  color: var(--on-surface-variant);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.f-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem;
}

.f-muted {
  color: var(--on-surface-variant);
}

.f-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.f-filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: end;
}

.f-filter-form .field {
  margin-block: 0;
  min-inline-size: 9rem;
}

/* The nav rail collapses away on phones; the top app bar carries the home
 * affordance there (plan WS-1 responsive rules; e2e-asserted). */
@media only screen and (max-width: 600px) {
  nav.left {
    display: none;
  }
}

/* --- login pages (auth/clientauth const-string pages, WS-2) ------------ */

.f-login {
  min-block-size: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.f-login > form {
  inline-size: min(22rem, 100%);
  padding: 2rem;
  border-radius: 1rem;
  background-color: var(--surface-container);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* --- toasts (WS-4) ------------------------------------------------------ */

/* #toasts is the one fixed, viewport-top live region every layout renders.
 * Beer's .snackbar is repositioned from its default fixed placement into a
 * static stacking column so multiple toasts coexist. */
#toasts {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  inline-size: min(38rem, calc(100vw - 2rem));
  pointer-events: none;
}

#toasts > .snackbar {
  position: static;
  inset: auto;
  transform: none;
  visibility: visible;
  opacity: 1;
  inline-size: 100%;
  pointer-events: auto;
  animation: f-toast-in 0.2s ease-out;
}

#toasts > .snackbar.f-tone-err {
  background-color: var(--f-tone-err-bg);
  color: var(--f-tone-err-fg);
}

@keyframes f-toast-in {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to   { opacity: 1; transform: none; }
}

/* --- htmx ---------------------------------------------------------------- */

/* htmx's injected indicator <style> is disabled (CSP: no inline styles);
 * these rules replace it. */
.htmx-indicator {
  opacity: 0;
  transition: opacity 0.2s ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}
