/*
 * Burn Time for Brands — dashboard foundation (F02).
 *
 * Plain CSS on the semantic tokens in tokens.css; Propshaft serves every file
 * in this directory, so there is no build step and no framework. Visual
 * decisions are traced to the iOS app in docs/brand-system.md and are
 * provisional until compared with running-app screenshots (F18).
 */

@import url("/assets/tokens-89cd8592.css");
@import url("/assets/fonts-9b4ce679.css");
@import url("/assets/custom-image-28f4633e.css");
@import url("/assets/landing-76e8b092.css");

/* Bootstrap sets scroll-behavior: smooth on :root, which
   interferes with Turbo's scroll preservation during morphs. */
:root {
  scroll-behavior: auto !important;
}

@media (max-width: 576px) {
  #dev-toolbar {
    display: none !important;
  }
}

/* ---- Base ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-body);
  overflow-wrap: anywhere;
}

h1, h2, h3 {
  color: var(--color-text-strong);
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  margin: 0 0 var(--space-3);
}
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); margin-top: var(--space-6); }
h3 { font-size: var(--text-md); }

p { margin: 0 0 var(--space-3); }
small { font-size: var(--text-sm); color: var(--color-text-muted); }
strong { font-weight: var(--weight-semibold); color: var(--color-text-strong); }

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
a:hover { color: var(--color-link-hover); }

img { max-width: 100%; height: auto; }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--color-focus-halo);
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  color: var(--color-text-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}
.skip-link:focus { top: var(--space-2); }

/* ---- Shell ----------------------------------------------------------- */
.site-header {
  background: var(--color-bg);
  border-bottom: var(--border-width) solid var(--color-border);
}

.site-header__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-2) var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-strong);
  text-decoration: none;
  min-height: var(--touch-min);
}
/* Logo.png is 298x206 with the cream page colour baked in; width and height
   are both set in the markup so the intrinsic 298:206 ratio is preserved. */
.brand-lockup__logo { width: 5.5rem; height: auto; aspect-ratio: 298 / 206; display: block; }
.brand-lockup__descriptor {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  padding-left: var(--space-3);
  border-left: var(--border-width) solid var(--color-border);
}

.site-nav { flex: 1 1 auto; min-width: 0; }
.site-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}
.site-nav__link, .site-nav__list .btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--color-text-strong);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
}
.site-nav__link:hover { background: var(--color-surface-muted); color: var(--color-text-strong); }
/* The current page is marked by weight, an underline and a fill — never by colour alone. */
.site-nav__link[aria-current="page"] {
  background: var(--color-action-bg);
  color: var(--color-action-text);
  font-weight: var(--weight-bold);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
.site-nav__item--end { margin-left: auto; }

/* Signed out, logging in is the only action in the header, so it is rendered
   as a button rather than one more nav link. The current-page treatment still
   marks it by fill, weight and underline while the login page is open. */
.site-nav__cta { padding: 0 var(--space-5); }
.site-nav__cta[aria-current="page"] {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text-strong);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

@media (max-width: 40rem) {
  .brand-lockup__descriptor { display: none; }
  .site-header__inner { gap: var(--space-1); }
  .site-nav__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1); }
  .site-nav__item--end { margin-left: 0; grid-column: 1 / -1; }
  .site-nav__link, .site-nav__list .btn { width: 100%; justify-content: center; border: var(--border-width) solid var(--color-border-soft); background: var(--color-surface); }
  .site-nav__link[aria-current="page"] { border-color: var(--color-action-bg); background: var(--color-action-bg); }
  /* Stacked, every nav item takes a white fill; the login CTA keeps the sage
     action fill so the one action a signed-out visitor has still reads as one. */
  .site-nav__list .site-nav__cta { background: var(--color-action-bg); border-color: transparent; color: var(--color-action-text); }
  .site-nav__list .site-nav__cta[aria-current="page"] { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text-strong); }
}

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-5) var(--gutter) var(--space-7);
}
.page > :last-child { margin-bottom: 0; }

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.back-link::before { content: "\2190"; margin-right: var(--space-2); text-decoration: none; display: inline-block; }

.page-lede { color: var(--color-text-muted); }

/* ---- Flash messages -------------------------------------------------- */
.flash {
  max-width: var(--page-max);
  margin: var(--space-4) auto 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: var(--border-width) solid;
  border-left-width: 6px;
  font-weight: var(--weight-medium);
}
.flash::before { font-weight: var(--weight-bold); margin-right: var(--space-2); }
.flash--notice { background: var(--color-success-bg); border-color: var(--color-success-line); color: var(--color-success-text); }
.flash--notice::before { content: "Notice:"; }
.flash--alert { background: var(--color-danger-bg); border-color: var(--color-danger-line); color: var(--color-danger-text); }
.flash--alert::before { content: "Alert:"; }
.flash-region { padding: 0 var(--gutter); }

/* ---- Cards ----------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* ---- Dashboard KPIs -------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-4);
  margin: var(--space-5) 0;
}
.kpi {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-soft);
  border-top: 4px solid var(--color-action-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-4) var(--space-5);
}
.kpi h2 { margin: 0 0 var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-muted); }
.kpi p.kpi-note { margin-top: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-regular); color: var(--color-text-muted); }
.kpi p { margin: 0; font-size: var(--text-xl); font-weight: var(--weight-bold); color: var(--color-text-strong); line-height: var(--leading-tight); }

/* ---- Forms ----------------------------------------------------------- */
fieldset {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-4) var(--space-5) var(--space-5);
  margin: 0 0 var(--space-5);
  min-width: 0;
}
legend { padding: 0 var(--space-2); font-weight: var(--weight-semibold); color: var(--color-text-strong); }

label { display: block; margin-bottom: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-strong); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  display: block;
  width: 100%;
  max-width: 28rem;
  min-height: var(--touch-min);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  color: var(--color-text-strong);
  border: var(--border-width) solid var(--bt-slate-muted);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-md);
}
input::placeholder { color: var(--color-text-muted); opacity: 1; }
input[type="checkbox"] { width: 1.25rem; height: 1.25rem; accent-color: var(--bt-leaf); vertical-align: middle; margin-right: var(--space-2); }

.field { margin-bottom: var(--space-4); }
.field--check label { display: flex; align-items: center; min-height: var(--touch-min); font-weight: var(--weight-regular); }

form p { margin-bottom: var(--space-4); }

.form-errors {
  background: var(--color-danger-bg);
  border: var(--border-width) solid var(--color-danger-line);
  border-left-width: 6px;
  border-radius: var(--radius-md);
  color: var(--color-danger-text);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}
.form-errors h2 { margin: 0 0 var(--space-2); font-size: var(--text-md); color: inherit; }
.form-errors ul { margin: 0; padding-left: var(--space-5); }

/* ---- Buttons --------------------------------------------------------- */
.btn, button, input[type="submit"], .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 0 var(--space-5);
  background: var(--color-action-bg);
  color: var(--color-action-text);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover, button:hover, input[type="submit"]:hover, .button:hover {
  background: var(--color-action-bg-hover);
  color: var(--color-action-text);
}
.btn--secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text-strong);
}
.btn--secondary:hover { background: var(--color-surface-muted); color: var(--color-text-strong); }
.btn--danger { background: var(--color-surface); border-color: var(--color-danger-line); color: var(--color-danger-text); }
.btn--danger:hover { background: var(--color-danger-bg); color: var(--color-danger-text); }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.button-row form, .button-row p { margin: 0; }
form.button_to { display: inline; }
form.button_to > button { margin: 0; }

/* Dashboard filter bar */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--space-4);
}
.filter-grid select, .filter-grid input { max-width: none; }
.filter-grid p { margin: 0; }
.filter-actions { margin-top: var(--space-4); }

/* ---- Tables ---------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-5);
  overflow: hidden;
}
.data-table caption { text-align: left; padding: 0 0 var(--space-2); font-weight: var(--weight-semibold); color: var(--color-text-strong); caption-side: top; }
.data-table th, .data-table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-width) solid var(--color-border-soft);
}
.data-table thead th {
  background: var(--color-surface-muted);
  color: var(--color-text-strong);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody th { font-weight: var(--weight-semibold); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td a { display: inline-block; min-height: 1.5rem; }

/* Narrow screens: each row becomes a labelled block (labels come from
   data-label), so no table ever scrolls the page sideways. */
@media (max-width: 40rem) {
  /* `caption` is in this list because a table-caption inside a block-level
     table collapses to one character per line; the dashboard's own captions
     are .sr-only, but the landing page shows one. */
  .data-table, .data-table caption, .data-table tbody, .data-table tr, .data-table th, .data-table td { display: block; width: 100%; }
  /* Stacked, the caption sits inside the table's own card, so it needs the
     cell padding rather than the desktop above-the-table offset. */
  .data-table caption { padding: var(--space-3) var(--space-4) var(--space-2); }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .data-table tbody tr { padding: var(--space-3) 0; border-bottom: var(--border-width) solid var(--color-border); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table th, .data-table td { border: 0; padding: var(--space-1) var(--space-4); }
  .data-table td[data-label]::before, .data-table th[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
  }
  .data-table .num { text-align: left; }
}

/* ---- Detail lists ---------------------------------------------------- */
.detail-list { margin: 0; display: grid; grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr); gap: var(--space-2) var(--space-5); }
.detail-list dt { font-weight: var(--weight-semibold); color: var(--color-text-muted); font-size: var(--text-sm); }
.detail-list dd { margin: 0; color: var(--color-text-strong); }
@media (max-width: 40rem) {
  .detail-list { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .detail-list dd { margin-bottom: var(--space-3); }
}

.plain-list { list-style: none; margin: 0 0 var(--space-5); padding: 0; background: var(--color-surface); border: var(--border-width) solid var(--color-border-soft); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.plain-list > li, .plain-list > p { margin: 0; padding: var(--space-3) var(--space-4); border-bottom: var(--border-width) solid var(--color-border-soft); }
.plain-list > :last-child { border-bottom: 0; }

/* ---- States ---------------------------------------------------------- */
/* Every state carries a text/icon prefix so colour is never the only signal. */
.state, .registry-freshness, .registry-empty {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: var(--border-width) dashed var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  margin: 0 0 var(--space-4);
}
.state::before { content: "\25CB\00a0"; color: var(--color-text-muted); }
.registry-freshness { border-style: solid; background: var(--color-surface-muted); font-size: var(--text-sm); }
.registry-freshness::before { content: "\1F552\00a0"; }
.registry-empty { border-color: var(--color-warn-line); background: var(--color-warn-bg); color: var(--color-warn-text); }
.registry-empty::before { content: "\26A0\00a0Insufficient data. "; font-weight: var(--weight-bold); }

.registry-stale {
  display: inline-block;
  padding: 0 var(--space-2);
  background: var(--color-warn-bg);
  color: var(--color-warn-text);
  border: var(--border-width) solid var(--color-warn-line);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semibold);
}
.registry-stale::before { content: "\26A0\00a0"; }
p.registry-stale { display: block; padding: var(--space-3) var(--space-4); }

.registry-decision {
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border-soft);
  border-left: 4px solid var(--color-action-bg);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}
.registry-decision > :last-child { margin-bottom: 0; }

.pill {
  display: inline-block;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border: var(--border-width) solid var(--color-success-line);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

code, pre { font-family: var(--font-mono); font-size: 0.9em; }
pre { overflow-x: auto; max-width: 100%; background: var(--color-surface-muted); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); white-space: pre-wrap; }

/* ---- Authentication (Devise) ----------------------------------------- */
.auth {
  max-width: 26rem;
  margin: var(--space-6) auto 0;
}
.auth__logo { display: block; margin: 0 auto var(--space-4); width: 10rem; height: auto; aspect-ratio: 298 / 206; }
.auth .card { padding: var(--space-6) var(--space-5); }
.auth h1 { text-align: center; }
.auth input[type="text"], .auth input[type="email"], .auth input[type="password"] { max-width: none; }
.auth .btn, .auth input[type="submit"] { width: 100%; }
.auth__links { text-align: center; margin-top: var(--space-4); }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Visually hidden, still announced by screen readers. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
