/* EVA app layout — built on the HAH Sensory tokens (design-system/styles.css). */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-sans);
  color: var(--text-body);
  background: var(--surface-app);
  line-height: var(--leading-normal);
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text-brand); text-decoration: none; }
h1, h2, h3, p { margin: 0; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--space-4);
  height: var(--topbar-height); padding: 0 var(--space-6);
  background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
}
.topbar .brand { display: flex; align-items: center; gap: var(--space-3); font-family: var(--font-display); font-weight: var(--fw-bold); font-size: var(--text-lg); color: var(--text-heading); letter-spacing: var(--tracking-tight); }
.topbar .brand .mark { width: 30px; height: 30px; border-radius: var(--radius-md); background: var(--brand); color: #fff; display: grid; place-items: center; font-size: var(--text-sm); }
.topbar .cycle-chip { color: var(--text-muted); font-size: var(--text-sm); }
.topbar nav { display: flex; gap: var(--space-1); margin-left: var(--space-4); }
.topbar nav a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 7px 12px; border-radius: var(--radius-md);
  color: var(--text-muted); font-weight: var(--fw-medium); font-size: var(--text-sm);
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}
.topbar nav a:hover { background: var(--surface-hover); color: var(--text-body); }
.topbar nav a.is-active { background: var(--brand-50); color: var(--brand-700); }
.topbar .spacer { flex: 1; }
.topbar .who { display: flex; align-items: center; gap: var(--space-2); text-align: right; }
.topbar .who .name { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-heading); line-height: 1.1; }
.topbar .who .role { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Page shell ──────────────────────────────────────────────────────────── */
.page { max-width: var(--content-max); margin: 0 auto; padding: var(--space-7) var(--space-6) var(--space-10); }
.page.is-narrow { max-width: 860px; }
.page-head { margin-bottom: var(--space-6); }
.page-head .eyebrow { color: var(--text-muted); font-size: var(--text-sm); }
.page-head h1 { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--fw-bold); color: var(--text-heading); letter-spacing: var(--tracking-tight); text-wrap: balance; }
.page-head .lede { color: var(--text-muted); margin-top: var(--space-2); max-width: 60ch; }

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }

/* ── Next-action card ────────────────────────────────────────────────────── */
.next-action {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  color: #fff; border-radius: var(--radius-xl); padding: var(--space-6);
  display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap;
}
.next-action .na-body { flex: 1; min-width: 240px; }
.next-action .na-kicker { font-size: var(--text-xs); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-wide); text-transform: uppercase; opacity: 0.85; }
.next-action h2 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--fw-bold); margin-top: 6px; text-wrap: balance; }
.next-action .na-meta { margin-top: var(--space-2); font-size: var(--text-sm); opacity: 0.9; display: flex; gap: var(--space-4); flex-wrap: wrap; }
.next-action .sensory-btn.is-primary { background: #fff; color: var(--brand-700); }
.next-action .sensory-btn.is-primary:hover:not(:disabled) { background: var(--brand-50); }
.next-action.is-done { background: linear-gradient(135deg, var(--green-600), var(--green-500)); }

/* ── Stat grid ───────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); }

/* ── Checklist ───────────────────────────────────────────────────────────── */
.checklist { display: flex; flex-direction: column; }
.checklist-item {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--pad-card);
  border-bottom: 1px solid var(--border-subtle); transition: background var(--dur-base) var(--ease-out);
  text-align: left; width: 100%; background: none; border-left: none; border-right: none; border-top: none; cursor: pointer; font: inherit; color: inherit;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item:hover { background: var(--surface-hover); }
.checklist-item .ci-icon { width: 38px; height: 38px; flex: none; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-muted); }
.checklist-item.is-submitted .ci-icon { background: var(--status-success-soft); color: var(--status-success-text); }
.checklist-item .ci-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.checklist-item .ci-title { display: block; font-weight: var(--fw-medium); color: var(--text-heading); }
.checklist-item .ci-sub { display: block; font-size: var(--text-sm); color: var(--text-muted); }
.checklist-item .ci-chev { color: var(--text-subtle); flex: none; }

/* ── Accordion (built on tokens — DS has none) ───────────────────────────── */
.accordion { display: flex; flex-direction: column; gap: var(--space-3); }
.acc-group { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); overflow: hidden; }
.acc-head {
  display: flex; align-items: center; gap: var(--space-3); width: 100%;
  padding: var(--space-4) var(--pad-card); background: none; border: none; cursor: pointer; font: inherit; text-align: left;
  transition: background var(--dur-base) var(--ease-out);
}
.acc-head:hover { background: var(--surface-hover); }
.acc-head:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.acc-head .acc-chev { color: var(--text-subtle); transition: transform var(--dur-base) var(--ease-out); flex: none; }
.acc-group.is-open .acc-head .acc-chev { transform: rotate(90deg); }
.acc-head .acc-title { flex: 1; font-family: var(--font-display); font-weight: var(--fw-semibold); color: var(--text-heading); }
.acc-head .acc-prog { display: flex; align-items: center; gap: var(--space-3); width: 180px; max-width: 40%; }
.acc-head .acc-prog .sensory-progress { flex: 1; }
.acc-panel { display: none; padding: 0 var(--pad-card) var(--space-2); }
.acc-group.is-open .acc-panel { display: block; }

/* ── Form items ──────────────────────────────────────────────────────────── */
.item { padding: var(--space-5) 0; border-top: 1px solid var(--border-subtle); }
.item:first-child { border-top: none; }
.item .item-label { font-weight: var(--fw-medium); color: var(--text-heading); }
.item .item-desc { font-size: var(--text-sm); color: var(--text-muted); margin-top: 3px; }
.item .item-rubrics { margin-top: var(--space-3); display: grid; gap: var(--space-2); }
.rubric { display: flex; gap: var(--space-3); font-size: var(--text-sm); background: var(--surface-sunken); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.rubric .rb-level { flex: none; width: 64px; font-weight: var(--fw-medium); color: var(--text-brand); text-transform: capitalize; }
.rubric .rb-content { color: var(--text-body); }

/* Score scale (1–4) as segmented buttons */
.scale { display: flex; gap: var(--space-2); margin-top: var(--space-4); flex-wrap: wrap; }
.scale button {
  min-width: 44px; height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-md);
  border: 1px solid var(--border-default); background: var(--surface-card); color: var(--text-body);
  font: inherit; font-weight: var(--fw-medium); cursor: pointer; font-variant-numeric: tabular-nums;
  transition: all var(--dur-base) var(--ease-out);
}
.scale button:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.scale button.is-selected { background: var(--brand); border-color: var(--brand); color: #fff; }
.scale button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* Rating scale (1–5) */
.rating { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.rating button { width: 44px; height: 44px; border-radius: var(--radius-md); border: 1px solid var(--border-default); background: var(--surface-card); color: var(--text-body); font: inherit; font-weight: var(--fw-semibold); cursor: pointer; transition: all var(--dur-base) var(--ease-out); }
.rating button:hover { border-color: var(--border-strong); }
.rating button.is-selected { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── Sticky submit bar ───────────────────────────────────────────────────── */
.submit-bar {
  position: sticky; bottom: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  margin-top: var(--space-6); padding: var(--space-4) var(--pad-card);
  background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.submit-bar .sb-status { color: var(--text-muted); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-2); }
.submit-bar .spacer { flex: 1; }

.locked-banner { display: flex; align-items: center; gap: var(--space-3); }

/* ── DEV switcher ────────────────────────────────────────────────────────── */
.dev-switch { position: relative; }
.dev-switch summary { list-style: none; cursor: pointer; }
.dev-switch summary::-webkit-details-marker { display: none; }
.dev-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 260px; max-height: 60vh; overflow: auto;
  background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: var(--space-2); z-index: var(--z-dropdown);
}
.dev-menu .dev-hd { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-subtle); padding: var(--space-2) var(--space-2) var(--space-1); }
.dev-user { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: 8px; border: none; background: none; border-radius: var(--radius-sm); cursor: pointer; text-align: left; font: inherit; color: var(--text-body); }
.dev-user:hover { background: var(--surface-hover); }
.dev-user.is-current { background: var(--brand-50); }
.dev-user .du-name { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-heading); }
.dev-user .du-meta { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Empty / loading ─────────────────────────────────────────────────────── */
.empty { text-align: center; padding: var(--space-10) var(--space-6); color: var(--text-muted); }
.empty h3 { font-family: var(--font-display); color: var(--text-heading); font-size: var(--text-lg); margin-bottom: var(--space-2); }
.skeleton { border-radius: var(--radius-md); background: linear-gradient(90deg, var(--surface-sunken), var(--surface-hover), var(--surface-sunken)); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-host { position: fixed; bottom: var(--space-5); left: 50%; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); align-items: center; }
.toast {
  display: flex; align-items: center; gap: var(--space-2); padding: 10px 16px; border-radius: var(--radius-pill);
  background: var(--surface-inverse); color: var(--text-on-inverse); font-size: var(--text-sm); box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-moderate) var(--ease-out);
}
.toast.tone-success { background: var(--status-success); color: #fff; }
.toast.tone-danger { background: var(--status-danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 720px) {
  .topbar { padding: 0 var(--space-4); gap: var(--space-2); }
  .topbar nav { display: none; }
  .topbar .cycle-chip { display: none; }
  .page { padding: var(--space-5) var(--space-4) var(--space-8); }
  .acc-head .acc-prog { width: 100px; }
}

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