/**
 * ui-components-nav.css - Page tabs, in-page switch and section head (.ui-tabs, .ui-switch,
 * .ui-section-head). The rest of the shared components are in ui-components.css; the same
 * rules apply: clinician sizes are the var() fallbacks, patient-tokens.css sets the patient
 * sizes, colours come from the side tokens. See wiki/ui-standards.md, "Components".
 */

/* ------------------------------------------------------------------------------------------
   Page tabs: underlined text tabs (the case tabs, report_v6/panel.css). Keyboard: lib/ui-tabs.js.
   <div class="ui-tabs" role="tablist"><button class="ui-tab" role="tab" aria-selected="true">…
   ------------------------------------------------------------------------------------------ */
.ui-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.ui-tabs::-webkit-scrollbar {
  display: none;
}

.ui-tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: none;
  box-sizing: border-box;
  min-height: var(--ui-tab-h, 32px);
  padding: 5px var(--ui-tab-px, 10px) 5px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-family: var(--font-ui, "Inter", system-ui, sans-serif);
  font-size: var(--ui-tab-fs, 13px);
  font-weight: var(--fw-semibold, 600);
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}

.ui-tab:hover {
  color: var(--color-text);
}

.ui-tab[aria-selected="true"],
.ui-tab.is-active {
  border-bottom-color: var(--color-selected);
  color: var(--color-link);
}

.ui-tab:focus-visible {
  outline: 2px solid var(--color-selected);
  outline-offset: -2px;
}

/* An optional second line under the tab name ("Done", "Nov 16, 12:00 PM EST"). */
.ui-tab__note {
  font-size: var(--fs-12, 12px);
  font-weight: var(--fw-medium, 500);
  color: var(--color-muted);
}

/* ------------------------------------------------------------------------------------------
   In-page switch, 2-4 choices (.clin-case-mode, the Evidence switch). Keyboard: lib/ui-switch.js.
   <div class="ui-switch" role="radiogroup" aria-label="View"><button class="ui-switch__opt"
   role="radio" aria-checked="true">…
   ------------------------------------------------------------------------------------------ */
.ui-switch {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  box-sizing: border-box;
  padding: 3px;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: var(--color-panel);
}

.ui-switch__opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 8px;
  box-sizing: border-box;
  min-height: var(--ui-switch-h, 28px);
  padding: 0 var(--ui-switch-px, 14px);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-family: var(--font-ui, "Inter", system-ui, sans-serif);
  font-size: var(--ui-switch-fs, 13px);
  font-weight: var(--fw-semibold, 600);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.ui-switch__opt:hover {
  color: var(--color-text);
}

.ui-switch__opt[aria-checked="true"],
.ui-switch__opt[aria-pressed="true"],
.ui-switch__opt.is-active {
  background: var(--color-main);
  color: var(--color-on-main);
}

.ui-switch__opt:focus-visible {
  outline: 2px solid var(--color-selected);
  outline-offset: 2px;
}

.ui-switch__opt:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ------------------------------------------------------------------------------------------
   Section head: icon + CAPS title + "· summary" + fold arrow (the All evidence / Daily header,
   atlas-grid.css .atlas-section-head). Fold behaviour: lib/ui-section-head.js.
   <button class="ui-section-head" aria-expanded="true" aria-controls="body-id">
     <i class="ui-section-head__icon fa-solid fa-calendar-check"></i>
     <span class="ui-section-head__title">Daily</span>
     <span class="ui-section-head__sum">3 check-ins · Oct 29 – Nov 11</span>
     <span class="ui-section-head__arrow"><i class="fa-solid fa-chevron-down"></i></span>
   </button>
   ------------------------------------------------------------------------------------------ */
.ui-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  min-height: var(--ui-head-min-h, 48px);
  margin: 0;
  padding: 12px var(--ui-head-px, 20px);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-family: var(--font-ui, "Inter", system-ui, sans-serif);
  text-align: left;
  cursor: pointer;
  transition: background-color 160ms ease;
}

/* A head that does not fold (no arrow, no hover). */
.ui-section-head--static {
  cursor: default;
}

.ui-section-head:not(.ui-section-head--static):hover {
  background: var(--color-panel);
}

/* Inset ring: heads sit flush between hairlines. */
.ui-section-head:focus-visible {
  outline: 2px solid var(--color-selected);
  outline-offset: -2px;
}

/* Open head: a hairline between it and its contents. */
.ui-section-head[aria-expanded="true"] {
  border-bottom: 1px solid var(--color-line);
}

.ui-section-head__icon {
  flex: 0 0 18px;
  text-align: center;
  font-size: var(--ui-head-title-fs, 13px);
  color: var(--color-text);
}

.ui-section-head__title {
  flex: none;
  font-size: var(--ui-head-title-fs, 13px);
  font-weight: var(--fw-semibold, 600);
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
}

.ui-section-head__sum {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--color-muted);
  font-size: var(--ui-head-sum-fs, 12px);
  font-weight: var(--fw-regular, 400);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The "·" before the summary is drawn here so callers pass only the words. */
.ui-section-head__sum:not(:empty)::before {
  content: "·";
  margin-right: 6px;
  opacity: 0.55;
}

/* Things that sit at the right end before the arrow (a "2 new" marker, a chip). */
.ui-section-head__end {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin-left: auto;
}

.ui-section-head__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 20px;
  color: var(--color-muted);
  font-size: var(--fs-12, 12px);
  transition: transform 180ms ease;
}

.ui-section-head__sum + .ui-section-head__arrow {
  margin-left: auto;
}

.ui-section-head[aria-expanded="true"] .ui-section-head__arrow {
  transform: rotate(180deg);
}

.ui-section-head:hover .ui-section-head__arrow {
  color: var(--color-link);
}

/* One section = head + body; sections in a row are split by a hairline (as All evidence). */
.ui-section + .ui-section {
  border-top: 1px solid var(--color-line);
}

/* The body a head folds. JS sets [hidden] when folded. */
.ui-section-body[hidden] {
  display: none;
}

/* Phones: a switch never runs past the screen. The choices share the width, with tighter side
   padding, and a long one wraps to a second line inside its pill. */
@media (max-width: 480px) {
  .ui-switch__opt {
    flex: 0 1 auto;
    min-width: 0;
    padding: 0 12px;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
  }
}

@media (max-width: 700px) {
  .ui-section-head {
    padding-inline: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-tab,
  .ui-switch__opt,
  .ui-section-head,
  .ui-section-head__arrow {
    transition: none;
  }
}
