/* ============================================================
   Dashboard (shared role-aware home) page.
   Structure in @layer layout, paint in @layer design. Content-named
   classes only — no legacy/appearance names, no hardcoded color.
   Reuses .app-screen and .btn/.btn--outline/.btn--primary/.btn--block
   from elements.css.

   SHARED page: every desk role (system_admin / prosecutor /
   senior_prosecutor / recovery_coach / case_manager / officer, light)
   and participants (citizen dark) render their own branch of this same
   class vocabulary. This stylesheet only references --t-* semantic
   tokens, which app/theme.css rebinds per theme, so the page reskins
   without any role-specific color rules here. The donut/trend/caseload
   chart sizes and the progress-meter width are written via CSSOM from
   data (the documented dynamic exception); everything else is a class.
   See docs/FRONTEND-ARCHITECTURE.md.
   ============================================================ */

@layer layout {
  /* Page intro — heading + subtitle. */
  .dashboard__intro { display: grid; gap: var(--mea-space-1); }

  /* ── Participant: program progress meter ── */
  .program-progress { display: grid; gap: var(--mea-space-4);
                      padding: var(--mea-space-5); border-radius: var(--mea-radius-2xl); }
  .program-progress__header { display: flex; flex-wrap: wrap; align-items: flex-start;
                              justify-content: space-between; gap: var(--mea-space-3); }
  .program-progress__headline { display: grid; gap: var(--mea-space-1); }
  .program-progress__caption, .program-progress__pct,
  .program-progress__deadline, .program-progress__counts { margin: 0; }
  .program-progress__track { block-size: var(--mea-space-2); border-radius: var(--mea-radius-pill);
                             overflow: hidden; }
  .program-progress__fill { block-size: 100%; inline-size: 0; border-radius: var(--mea-radius-pill);
                            transition: inline-size var(--mea-dur-smooth, var(--mea-dur-normal)); }
  .program-progress__counts { display: flex; justify-content: space-between; gap: var(--mea-space-3); }

  /* ── Participant: active task timer ── */
  .active-timer { display: grid; grid-template-columns: auto 1fr auto; align-items: center;
                  gap: var(--mea-space-3); padding: var(--mea-space-4);
                  border-radius: var(--mea-radius-xl); }
  .active-timer__pulse { inline-size: .75rem; block-size: .75rem; border-radius: var(--mea-radius-circle); }
  .active-timer__info { display: grid; gap: var(--mea-space-1); min-inline-size: 0; }
  .active-timer__label, .active-timer__task, .active-timer__provider,
  .active-timer__value, .active-timer__elapsed { margin: 0; }
  .active-timer__readout { display: grid; gap: var(--mea-space-1); justify-items: end; text-align: end; }

  /* ── Generic block: header + a list ── */
  .dashboard-block { display: grid; gap: var(--mea-space-3); }
  .dashboard-block__header { display: flex; flex-wrap: wrap; align-items: center;
                             justify-content: space-between; gap: var(--mea-space-2); }
  .dashboard-block__title, .dashboard-block__link { margin: 0; }
  .dashboard-block__link { text-decoration: none; }

  /* ── Participant: upcoming task list ── */
  .upcoming-list { display: flex; gap: var(--mea-space-3); margin: 0; padding: 0; list-style: none;
                   overflow-x: auto; scroll-snap-type: x proximity; }
  .upcoming-list__empty { margin: 0; padding: var(--mea-space-4); }
  .upcoming-task { flex: 0 0 auto; inline-size: 11rem; display: grid; gap: var(--mea-space-2);
                  align-content: start; padding: var(--mea-space-4); border-radius: var(--mea-radius-xl);
                  scroll-snap-align: start; }
  .upcoming-task__icon { font-size: var(--mea-text-xl); line-height: 1; }
  .upcoming-task__title, .upcoming-task__date { margin: 0; }

  /* ── Participant: quick actions ── */
  .dashboard-actions { display: grid; gap: var(--mea-space-3);
                       padding: var(--mea-space-5); border-radius: var(--mea-radius-xl); }
  .dashboard-actions__header { display: grid; gap: var(--mea-space-1); }
  .dashboard-actions__title { margin: 0; }
  .dashboard-actions__list { display: grid; gap: var(--mea-space-3); margin: 0; padding: 0; list-style: none; }

  /* ── Officer: profile card ──
     Laid out like an ID card: the initials circle on top, then the name,
     where they serve and the badge. */
  .officer-profile { display: grid; justify-items: start; row-gap: var(--t-space-1);
                     padding: var(--t-space-6); border-radius: var(--t-radius-lg); }
  .officer-profile__avatar { display: inline-flex; align-items: center; justify-content: center;
                             inline-size: 4.5rem; block-size: 4.5rem;
                             margin-block-end: var(--t-space-5); border-radius: var(--t-radius-pill); }
  .officer-profile__name, .officer-profile__place { margin: 0; overflow-wrap: anywhere; }
  /* The badge sits apart from the name and place, as on an ID card. */
  .officer-profile__badge { margin: var(--t-space-6) 0 0; }

  /* Two-column desk layout that stacks when narrow: two equal columns. This
     is the only definition. web.css used to carry a second one (3fr 1fr)
     that won and squeezed the side pane to a quarter of the row. */
  .dashboard-columns { display: grid; gap: var(--t-space-6);
                       grid-template-columns: minmax(0, 1fr); align-items: start; }
  .dashboard-columns__col { display: grid; gap: var(--t-space-6); align-content: start; }
  @container (min-width: 52rem) {
    .dashboard-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  /* ── Panel empty state ── */
  .panel-empty { display: grid; gap: var(--mea-space-2); justify-items: center; text-align: center;
                 padding: var(--mea-space-8) var(--mea-space-4); }
  .panel-empty__icon, .panel-empty__title { margin: 0; }

  @media (max-width: 48rem) {
	  .actions {
		  & > * {
			  flex-grow: 1;
		  }
	  }
  }

  /* ── Officer: recent issues grouped by date. Each group's date heading
     sits above its rows, inset to line up with the row text. ── */
  .dashboard--officer section.pane > .body:has(> .case-group) { gap: 0; }
  .case-group {
	  & h3 {
		  margin: 0;
		  font-size: var(--t-font-size-xs);
		  font-weight: var(--t-font-weight-semibold);
		  padding-inline: var(--t-space-5);
		  padding-block: var(--t-space-3) var(--t-space-1);
		  border-block-end-width: var(--t-border-width-interactive);
	  }
  }

  /* ── Prosecutor: court tabs + info ── */
  .court-tabs { display: flex; flex-wrap: wrap; gap: var(--mea-space-2);
                margin-block-end: var(--mea-space-4); }
  .court-tab { display: inline-flex; align-items: center; min-height: var(--t-target-min, 44px);
               padding: var(--mea-space-2) var(--mea-space-4); border: 0;
               border-radius: var(--mea-radius-pill); cursor: pointer; white-space: nowrap; }
  .court-info { display: flex; flex-wrap: wrap; gap: var(--mea-space-5); margin: 0; }
  .court-info__pair { display: flex; align-items: baseline; gap: var(--mea-space-2); }
  .court-info__label, .court-info__value { margin: 0; }

  /* ── Charts: donut ── */
  .chart-donut { position: relative; display: grid; place-items: center; margin: 0; }
  .chart-donut svg { transform: rotate(-90deg); }
  .chart-donut__center { position: absolute; display: grid; gap: var(--mea-space-1);
                         justify-items: center; text-align: center; }
  .chart-donut__value, .chart-donut__label { margin: 0; }

  .chart-legend { display: grid; gap: var(--mea-space-2); inline-size: 100%;
                  margin: 0; padding: 0; list-style: none; }
  .chart-legend__item { display: flex; align-items: center; gap: var(--mea-space-2); }
  .chart-legend__item--wide { inline-size: 100%; }
  .chart-legend__dot { flex: 0 0 auto; inline-size: .75rem; block-size: .75rem;
                       border-radius: var(--mea-radius-circle); }
  .chart-legend__label { min-inline-size: 0; }
  .chart-legend__label--grow { flex: 1; }
  .chart-legend__value { margin-inline-start: auto; }

  /* ── Charts: 7-day trend bars ── */
  .trend-chart { display: flex; align-items: flex-end; gap: var(--mea-space-3); }
  .trend-chart__col { flex: 1; display: grid; gap: var(--mea-space-2); justify-items: center; align-content: end; }
  .trend-bar { display: flex; flex-direction: column; inline-size: 100%;
               border-radius: var(--mea-radius-sm); overflow: hidden; }
  .trend-bar__seg { inline-size: 100%; }
  .trend-chart__label { margin: 0; }
  .trend-legend { display: flex; flex-wrap: wrap; gap: var(--mea-space-4);
                  margin: var(--mea-space-3) 0 0; padding: 0; list-style: none; }
  .trend-legend__item { display: inline-flex; align-items: center; gap: var(--mea-space-2); }

  /* ── Charts: caseload bars ── */
  .caseload-chart { display: grid; gap: var(--mea-space-3); margin: 0; padding: var(--mea-space-5);
                    list-style: none; }
  .caseload-bar { display: grid; grid-template-columns: 8rem 1fr auto; align-items: center;
                  gap: var(--mea-space-3); }
  .caseload-bar__label { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .caseload-bar__track { block-size: var(--mea-space-2); border-radius: var(--mea-radius-pill); overflow: hidden; }
  .caseload-bar__fill { display: block; block-size: 100%; inline-size: 0; border-radius: var(--mea-radius-pill); }
  .caseload-bar__value { margin: 0; }
  @container (max-width: 30rem) { .caseload-bar { grid-template-columns: 6rem 1fr auto; } }

  /* ── System admin: the summary heading over its two cards ── */
  .admin-home .hub-summary { display: grid; gap: var(--t-space-4); }

  /* The summary names a section among the pane sections above it, so it takes
     their size. The heading component's own rule gives a page title the hero
     size, which here read as a second page title. */
  .admin-home .hub-summary-heading :is(h1, h2, h3, h4) {
    font-family: var(--t-font-family-heading);
    font-size: var(--t-font-size-lg);
    font-weight: var(--t-font-weight-bold);
  }

  /* ── Recent messages (participant) ── */
  .message-item { display: grid; gap: var(--mea-space-1);
                  padding-block: var(--mea-space-3); }
  .message-item__sender, .message-item__body, .message-item__time { margin: 0; }

  /* ── Audit / event list ── */
  .event-list { display: grid; margin: 0; padding: 0; list-style: none; }
  .event { display: grid; gap: var(--mea-space-1); padding: var(--mea-space-3) var(--mea-space-5); }
  .event__time, .event__actor, .event__action { margin: 0; }

  /* ── Drill-down modal ── */
  .dash-modal-overlay { position: fixed; inset: 0; display: grid; place-items: center;
                        padding: var(--mea-space-4); z-index: var(--mea-z-modal); }
  .drill-modal { inline-size: 100%; max-inline-size: 34rem; max-block-size: 85vh; display: grid;
                 grid-template-rows: auto 1fr; border-radius: var(--mea-radius-2xl); overflow: hidden; }
  .drill-modal__header { display: flex; align-items: center; justify-content: space-between;
                         gap: var(--mea-space-3); padding: var(--mea-space-4) var(--mea-space-5); }
  .drill-modal__title { margin: 0; }
  .drill-modal__close { border: 0; background: transparent; cursor: pointer; line-height: 1;
                        padding: var(--mea-space-1) var(--mea-space-2); }
  .drill-modal__body { display: grid; gap: var(--mea-space-2); align-content: start;
                       padding: var(--mea-space-4) var(--mea-space-5); overflow-y: auto; }

  .drill-row { display: grid; grid-template-columns: 1fr auto; align-items: center;
               gap: var(--mea-space-3); padding: var(--mea-space-3) 0; }
  .drill-row__main { display: grid; gap: var(--mea-space-1); min-inline-size: 0; }
  .drill-row__name, .drill-row__meta, .drill-row__time, .drill-empty { margin: 0; }

  .da-landing {
	  display: grid;
	  gap: var(--t-space-5);

	  & > header { display: grid; gap: var(--t-space-1); }

	  & .workflow-group { display: grid; gap: var(--t-space-3); }

	  & .card-grid {
		  display: grid;
		  gap: var(--t-space-3);
		  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	  }

	  /* A pane heading carries its own count (for screen-reader heading
	     navigation), so the heading fills the header and spreads the label
	     and the figure to the edges the aside used to reach. */
	  & .pane > header > :is(h1, h2, h3, h4) {
		  display: flex;
		  flex: 1;
		  flex-wrap: wrap;
		  align-items: baseline;
		  justify-content: space-between;
		  gap: var(--t-space-2);
	  }

	  & .caseload-search {
		  display: flex;
		  flex-wrap: wrap;
		  align-items: end;
		  gap: var(--t-space-3);
	  }

	  & .caseload-search .field { flex: 1 1 16rem; }

	  & .view-all { margin: 0; }
  }

}

@layer design {
  /* Page intro. */
  .dashboard__title { font-family: var(--mea-font-citizen); font-size: var(--mea-text-2xl);
                      font-weight: var(--mea-w-bold); color: var(--t-bg-text); }
  .dashboard__subtitle { font-size: var(--mea-text-md); color: var(--t-bg-text-secondary); }

  /* Participant: program progress (the dashboard hero card). */
  .program-progress { background: var(--t-hero-bg); border: 1px solid var(--t-card-border);
                      box-shadow: var(--t-hero-shadow); }
  .program-progress__caption { font-size: var(--mea-text-sm); color: var(--t-text-muted); }
  .program-progress__pct { font-family: var(--mea-font-citizen); font-size: var(--mea-text-3xl);
                           font-weight: var(--mea-w-extrabold); color: var(--t-text);
                           line-height: var(--mea-lh-tight); }
  .program-progress__deadline { font-size: var(--mea-text-sm); color: var(--t-text-muted); }
  .program-progress__track { background: var(--t-track); }
  .program-progress__fill { background: var(--t-accent); }
  .program-progress__counts { font-size: var(--mea-text-sm); color: var(--t-text-muted); }

  /* Participant: active timer. */
  .active-timer { background: var(--t-card-bg); border: 1px solid var(--t-card-border);
                  box-shadow: var(--mea-shadow-sm); }
  .active-timer__pulse { background: var(--t-success); }
  .active-timer__label { font-size: var(--mea-text-xs); font-weight: var(--mea-w-semibold);
                         color: var(--t-text-muted); text-transform: uppercase;
                         letter-spacing: var(--mea-ls-wide); }
  .active-timer__task { font-size: var(--mea-text-md); font-weight: var(--mea-w-semibold); color: var(--t-text); }
  .active-timer__provider { font-size: var(--mea-text-sm); color: var(--t-text-muted); }
  .active-timer__value { font-family: var(--mea-font-mono); font-size: var(--mea-text-xl);
                         font-weight: var(--mea-w-bold); color: var(--t-text); }
  .active-timer__elapsed { font-size: var(--mea-text-xs); color: var(--t-text-muted); }

  /* Generic block header. */
  .dashboard-block__title { font-family: var(--mea-font-citizen); font-size: var(--mea-text-lg);
                            font-weight: var(--mea-w-bold); color: var(--t-text); }
  .dashboard-block__link { font-size: var(--mea-text-sm); color: var(--t-link); }
  .dashboard-block__link:hover { color: var(--t-link-hover); }

  /* Participant: upcoming task. */
  .upcoming-list__empty { font-size: var(--mea-text-md); color: var(--t-text-muted); }
  .upcoming-task { background: var(--t-card-bg); border: 1px solid var(--t-card-border);
                   box-shadow: var(--mea-shadow-sm); }
  .upcoming-task__title { font-size: var(--mea-text-md); font-weight: var(--mea-w-semibold); color: var(--t-text); }
  .upcoming-task__date { font-size: var(--mea-text-xs); color: var(--t-text-muted); }

  /* Participant: quick actions. */
  .dashboard-actions { background: var(--t-card-bg); border: 1px solid var(--t-card-border);
                       box-shadow: var(--mea-shadow-sm); }
  .dashboard-actions__title { font-family: var(--mea-font-citizen); font-size: var(--mea-text-md);
                              font-weight: var(--mea-w-bold); color: var(--t-text); }

  /* Officer: profile header. It is the page's featured surface, as the
     participant's current task is on theirs, so its fill and inks are the
     surface's; the avatar is an inset circle on it. The featured surface has
     no dimmer ink, so the place and badge step down by size and weight. */
  .officer-profile__avatar { font-size: var(--t-font-size-lg); font-weight: var(--t-font-weight-bold); }
  .officer-profile__name { font-family: var(--t-font-family-heading); font-size: var(--t-font-size-2xl);
                           font-weight: var(--t-font-weight-bold); line-height: var(--t-line-height-tight); }
  .officer-profile__place, .officer-profile__badge { font-size: var(--t-font-size-md);
                                                     font-weight: var(--t-font-weight-normal); }

  /* Panel empty state. */
  .panel-empty__icon { font-size: var(--mea-text-3xl); line-height: 1; }
  .panel-empty__title { font-size: var(--mea-text-md); color: var(--t-text-muted); }

  /* Officer: recent issues grouped by date. */
	.case-group {
		& h3 {
			color: var(--c-surface-text-color-muted);
			border-block-end-style: solid;
			border-block-end-color: var(--t-border);
		}
	}

  /* Prosecutor: court tabs + info. */
  .court-tab { background: var(--t-bg-recessed); color: var(--t-text-secondary);
               font-size: var(--mea-text-sm); font-weight: var(--mea-w-semibold);
               transition: background var(--mea-dur-fast), color var(--mea-dur-fast); }
  .court-tab:hover { background: var(--t-bg-active); }
  .court-tab.is-active { background: var(--t-accent); color: var(--t-accent-text); }
  .court-info__label { font-size: var(--mea-text-md); color: var(--t-text-secondary); }
  .court-info__value { font-size: var(--mea-text-md); font-weight: var(--mea-w-bold); color: var(--t-text); }

  /* Charts: donut. */
  .chart-donut__value { font-size: var(--mea-text-xl); font-weight: var(--mea-w-extrabold); color: var(--t-text); }
  .chart-donut__label { font-size: var(--mea-text-xs); color: var(--t-text-muted); }

  .chart-legend__dot--green { background: var(--t-success); }
  .chart-legend__dot--red { background: var(--t-error); }
  .chart-legend__dot--amber { background: var(--t-warning); }
  .chart-legend__dot--blue, .chart-legend__dot--baby-blue { background: var(--t-accent); }
  .chart-legend__dot--gray { background: var(--t-text-muted); }
  .chart-legend__label { font-size: var(--mea-text-sm); color: var(--t-text-secondary); }
  .chart-legend__value { font-size: var(--mea-text-sm); font-weight: var(--mea-w-bold); color: var(--t-text); }

  /* Charts: trend bars. */
  .trend-bar__seg--approved { background: var(--t-success); }
  .trend-bar__seg--deferred { background: var(--t-warning); }
  .trend-bar__seg--denied { background: var(--t-error); }
  .trend-bar__seg--empty { background: var(--t-bg-recessed); }
  .trend-chart__label { font-size: var(--mea-text-xs); color: var(--t-text-muted); }
  .trend-legend__item { font-size: var(--mea-text-sm); color: var(--t-text-secondary); }

  /* Charts: caseload bars. */
  .caseload-bar__label { font-size: var(--mea-text-sm); color: var(--t-text-secondary); }
  .caseload-bar__track { background: var(--t-bg-recessed); }
  .caseload-bar__fill { background: var(--t-accent); }
  .caseload-bar__value { font-size: var(--mea-text-sm); font-weight: var(--mea-w-bold); color: var(--t-text); }




  /* Recent messages. */
  .message-item { border-block-end: 1px solid var(--t-border); }
  .message-item__sender { font-size: var(--mea-text-md); font-weight: var(--mea-w-semibold); color: var(--t-text); }
  .message-item__body { font-size: var(--mea-text-sm); color: var(--t-text-secondary);
                        line-height: var(--mea-lh-snug); }
  .message-item__time { font-size: var(--mea-text-xs); color: var(--t-text-muted); }

  /* Audit / event list. */
  .event { border-block-end: 1px solid var(--t-border); }
  .event__time { font-size: var(--mea-text-xs); color: var(--t-text-muted); }
  .event__actor { font-size: var(--mea-text-sm); font-weight: var(--mea-w-semibold); color: var(--t-text); }
  .event__action { font-size: var(--mea-text-sm); color: var(--t-text-secondary); }
  .event__resource { font-weight: var(--mea-w-semibold); color: var(--t-text); }

  /* Drill-down modal. */
  .dash-modal-overlay { background: var(--t-bg-active); }
  .drill-modal { background: var(--t-card-bg); border: 1px solid var(--t-card-border);
                 box-shadow: var(--mea-shadow-lg); }
  .drill-modal__header { border-block-end: 1px solid var(--t-border); }
  .drill-modal__title { font-family: var(--mea-font-citizen); font-size: var(--mea-text-lg);
                        font-weight: var(--mea-w-bold); color: var(--t-text); }
  .drill-modal__close { color: var(--t-text-muted); font-size: var(--mea-text-xl); }
  .drill-modal__close:hover { color: var(--t-text); }
  .drill-row { border-block-end: 1px solid var(--t-border); }
  .drill-row__name { font-size: var(--mea-text-sm); font-weight: var(--mea-w-semibold); color: var(--t-text); }
  .drill-row__meta { font-size: var(--mea-text-xs); color: var(--t-text-muted); }
  .drill-row__time { font-size: var(--mea-text-sm); font-weight: var(--mea-w-bold); color: var(--t-text); }
  .drill-empty { font-size: var(--mea-text-md); color: var(--t-text-muted); text-align: center;
                 padding: var(--mea-space-4); }

  .da-landing {
	  & .attribution { color: var(--t-bg-text-secondary); font-size: var(--t-font-size-sm); }

	  & .detail { color: var(--c-surface-text-color-muted); }

	  & .pane > header a { color: var(--c-surface-text-color-interactive); }

	  & .pane > header .count { font-size: var(--t-font-size-2xl);
	                            font-weight: var(--t-font-weight-extrabold); }
  }

}
