/*
 * Calm-Clinical design system — epic #137
 *
 * Component utility classes built on the design tokens defined in
 * app/assets/tailwind/application.css (@theme). Mirrors design/styles.css
 * (Nov 2026 brand refresh: Loop blue actions, Inter Tight caps labels).
 */

/* Web fonts — Google Fonts hosted. Phase 11 cleanup will self-host. */
@import url("https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400&family=Inter+Tight:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

/* === Surfaces === */
.surf {
  background: #fff;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-lg);
}
.surf-flat {
  background: #fff;
  border-bottom: 1px solid var(--color-rule);
}
.divider { height: 1px; background: var(--color-rule); }
.divider-soft { height: 1px; background: var(--color-rule-soft); }

/* === Page modal (replaces DaisyUI .modal/.modal-box) === */
.page-modal {
  padding: 0;
  border: 0;
  background: transparent;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  inset: 0;
  margin: 0;
  color: inherit;
}
.page-modal::backdrop {
  background: rgba(14, 22, 38, 0.45);
  backdrop-filter: blur(2px);
}
.page-modal[open] {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}
.page-modal-box {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 50px rgba(14, 22, 38, 0.18);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}
@media (max-width: 743px) {
  .page-modal[open] { padding: 0; }
  .page-modal-box { border-radius: 0; max-height: 100vh; height: 100vh; }
}

/* === Buttons === */
.btn-ds {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary-ds { background: var(--color-blue-600); color: #fff; }
.btn-primary-ds:hover { background: var(--color-blue-700); }
.btn-ghost-ds { color: var(--color-ink); border-color: var(--color-rule-strong); background: #fff; font-weight: 500; }
.btn-ghost-ds:hover { background: var(--color-paper-2); }
.btn-sm-ds { height: 26px; padding: 0 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg-ds { height: 40px; padding: 0 18px; font-size: 14px; }
.btn-ds:disabled { opacity: .5; cursor: default; pointer-events: none; }

/* === Tags — pills, Inter Tight caps === */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 8px;
  font-family: var(--font-sans);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  border-radius: 999px; text-transform: uppercase;
  white-space: nowrap;
}
.tag-blue  { background: var(--color-blue-50);  color: var(--color-blue-700); }
.tag-lav   { background: var(--color-lav-50);   color: var(--color-lav-700); }
.tag-moss  { background: var(--color-moss-50);  color: var(--color-moss); }
.tag-amber { background: var(--color-amber-50); color: #8F5A15; } /* darker amber text for 4.5:1 */
.tag-rose  { background: var(--color-coral-50); color: var(--color-coral-700); }
.tag-ink   { background: var(--color-paper-2); color: var(--color-ink-3); }
.tag-navy  { background: var(--color-navy); color: #fff; } /* agency Owner */

/* === Tinted surfaces — pair with .surf for callouts (errors, warnings) ===
   Declared after .surf so they win over its background/border. */
.surf-rose {
  background: var(--color-rose-50);
  border-color: color-mix(in srgb, var(--color-rose) 25%, transparent);
}

/* === Avatars === */
.av {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background-color: var(--color-paper-3); color: var(--color-ink-2);
  font-family: var(--font-sans); font-weight: 600; font-size: 10px; letter-spacing: 0.02em;
  flex-shrink: 0;
}
/* Photo avatars pass their image inline. The tones below set only background-color:
   the `background` shorthand would reset this size and position, and the photo would
   show its top-left corner at full size instead of filling the circle. */
.av-img { background-size: cover; background-position: center; }
.av-paper { background-color: var(--color-paper-3); color: var(--color-ink-2); }
.av-blue  { background-color: var(--color-blue-100); color: var(--color-blue-700); }
.av-lav   { background-color: var(--color-lav-100);  color: var(--color-lav-700); }
.av-moss  { background-color: #DCE6D5; color: var(--color-moss); }
.av-amber { background-color: #F2E2C2; color: var(--color-amber); }
.av-ink   { background-color: var(--color-ink); color: var(--color-paper); }

/* === Dot indicator === */
.dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; }
.dot-blue  { background: var(--color-blue-500); }
.dot-lav   { background: var(--color-lav-500); }
.dot-moss  { background: var(--color-moss); }
.dot-amber { background: var(--color-amber); }
.dot-rose  { background: var(--color-rose); }
.dot-ink   { background: var(--color-ink); }

/* === Striped placeholder (for empty states / coming-soon UI) === */
.placeholder-strip {
  background-image: repeating-linear-gradient(135deg, var(--color-paper-2) 0 8px, var(--color-paper-3) 8px 9px);
  color: var(--color-ink-4);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
}

/* === Sidebar nav row (active = 2px ink rail + paper-2 fill) === */
.nav-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; margin: 1px 0;
  border-radius: var(--radius-md);
  font-size: 13px; color: var(--color-ink-3);
  position: relative;
  text-decoration: none;
}
.nav-row:hover { background: var(--color-paper-2); }
.nav-row-active {
  background: var(--color-paper-2);
  color: var(--color-ink);
  font-weight: 500;
}
.nav-row-active::before {
  content: ''; position: absolute; left: -8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--color-blue-600); border-radius: 2px;
}
.nav-row .nav-icon { color: var(--color-ink-4); flex-shrink: 0; }
.nav-row-active .nav-icon { color: var(--color-ink); }
.nav-row-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--color-blue-600); color: #fff;
  font-family: var(--font-sans); font-size: 10.5px; font-weight: 600;
  border-radius: 999px;
  margin-left: auto;
}

/* === Timeline rail (Care Log spine) === */
.rail { position: relative; }
.rail::before {
  content: ''; position: absolute; left: 11px; top: 8px; bottom: 8px;
  width: 1px; background: var(--color-rule);
}
.rail-node {
  position: relative; padding-left: 36px;
}
.rail-node::before {
  content: ''; position: absolute; left: 7px; top: 8px;
  width: 9px; height: 9px; border-radius: 999px;
  background: #fff; border: 1.5px solid var(--color-ink-5);
}
.rail-node.is-blue::before { border-color: var(--color-blue-600); background: var(--color-blue-600); }
.rail-node.is-lav::before  { border-color: var(--color-lav-500);  background: var(--color-lav-500); }
.rail-node.is-moss::before { border-color: var(--color-moss);     background: var(--color-moss); }
.rail-node.is-ink::before  { border-color: var(--color-ink);      background: var(--color-ink); }

/* === Type scale === */
.t-eyebrow {
  font-family: var(--font-sans);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-ink-3);
}
.t-meta {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--color-ink-4);
  letter-spacing: 0.01em;
}
.t-meta-strong {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--color-ink-3);
  letter-spacing: 0.01em;
}
.t-label    { font-size: 12px; color: var(--color-ink-3); }
.t-body     { font-size: 14px; color: var(--color-ink-2); }
.t-body-lg  { font-size: 15px; color: var(--color-ink-2); line-height: 1.55; }
.t-h3 {
  font-family: var(--font-sans);
  font-size: 16px; font-weight: 600; color: var(--color-ink);
}
.t-h2 {
  font-family: var(--font-sans);
  font-size: 22px; font-weight: 600; color: var(--color-ink);
  letter-spacing: -0.015em;
}
.t-h1 {
  font-family: var(--font-serif);
  font-size: 32px; font-weight: 400; color: var(--color-ink);
  letter-spacing: -0.02em; line-height: 1.1;
}
.t-display {
  font-family: var(--font-serif);
  font-size: 44px; font-weight: 400; color: var(--color-ink);
  letter-spacing: -0.03em; line-height: 1.05;
}

/* === Segmented filter (design/agency .seg) ===
   Links or buttons in a paper track; the current one is a white chip. .seg-lg is the phone
   size: full width, 44px targets. */
.seg {
  display: inline-flex; gap: 4px; padding: 3px;
  background: var(--color-paper-2); border-radius: var(--radius-md);
}
.seg > a, .seg > button {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 12px; border-radius: var(--radius-sm);
  font-size: 12px; color: var(--color-ink-3); white-space: nowrap;
}
.seg > a:hover, .seg > button:hover { color: var(--color-ink); }
.seg > .is-on {
  background: #fff; color: var(--color-ink); font-weight: 500;
  box-shadow: 0 1px 2px rgba(14, 22, 38, 0.06);
}
.seg-lg { display: flex; width: 100%; padding: 4px; border-radius: 10px; }
.seg-lg > a, .seg-lg > button { flex: 1; min-height: 40px; font-size: 15px; border-radius: var(--radius-md); }

/* === Visit blocks (design/agency Schedule .v) ===
   One per visit on the master schedule, styled by Visit#state. Not started softly pulses
   (off under prefers-reduced-motion); the selected one gets a dark outline. .vb-swatch is the
   legend's sample of each. */
.vb {
  position: absolute; display: flex; flex-direction: column; justify-content: center;
  padding: 4px 8px; border-radius: 6px; overflow: hidden;
  font-size: 11.5px; line-height: 1.25; white-space: nowrap; text-align: left;
}
.vb-chip { position: relative; }
.vb .vb-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.vb .vb-sub { font-family: var(--font-mono); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; }
.vb-in_progress, .vb-swatch.vb-in_progress { background: var(--color-blue-600); color: #fff; }
.vb-upcoming, .vb-swatch.vb-upcoming { background: var(--color-blue-50); border: 1px solid var(--color-blue-300); color: var(--color-blue-700); }
.vb-done, .vb-swatch.vb-done { background: var(--color-paper-2); border: 1px solid var(--color-rule); color: var(--color-ink-3); }
.vb-unstaffed, .vb-swatch.vb-unstaffed { background: var(--color-amber-50); border: 1px dashed var(--color-amber); color: var(--color-amber-ink); }
.vb-not_started, .vb-swatch.vb-not_started {
  background: var(--color-coral-50); border: 1.5px solid var(--color-coral-ink); color: var(--color-coral-700);
}
.vb-not_started { animation: vb-attention 2.4s ease-in-out infinite; }
@keyframes vb-attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 47, 58, 0); }
  50% { box-shadow: 0 0 0 4px rgba(185, 47, 58, 0.22); }
}
@media (prefers-reduced-motion: reduce) { .vb-not_started { animation: none; } }
/* A live-in shift (E9): striped blue while it's on or coming up; the other states keep their look. */
.vb-live.vb-in_progress { background: repeating-linear-gradient(135deg, var(--color-blue-600) 0 10px, #3a63b4 10px 20px); }
.vb-live.vb-upcoming { background: repeating-linear-gradient(135deg, var(--color-blue-50) 0 10px, #e3ebf8 10px 20px); }
/* Cut where it runs past the timeline's edge (from last night, on into tomorrow, or outside 7a–9p). */
.vb-cut-l { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dotted; }
.vb-cut-r { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-style: dotted; }
.vb.is-selected { outline: 2px solid var(--color-ink); outline-offset: 1px; }
.vb:focus-visible { outline: 2px solid var(--color-blue-600); outline-offset: 2px; }
.vb-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* === Week bars (family calendar week, design/agency family/CalendarWeek .mbar) ===
   The week's top row: all-day and multi-day events, each drawn once across the days it covers.
   .week-bars draws the day lines and tints the night hours (before 6a, after 9p) of each day.
   A bar the week cuts gets a dotted edge (from before) or fades out (on past it). */
.week-bars {
  background-image:
    repeating-linear-gradient(to right, transparent 0 calc(100% / 7 - 1px), var(--color-rule) calc(100% / 7 - 1px) calc(100% / 7)),
    repeating-linear-gradient(to right, rgba(19, 32, 63, 0.04) 0 calc(100% / 28), transparent calc(100% / 28) calc(100% * 21 / 168),
                              rgba(19, 32, 63, 0.04) calc(100% * 21 / 168) calc(100% / 7));
}
.week-bar {
  position: absolute; height: 22px; display: flex; align-items: center; gap: 4px; padding: 0 6px;
  border-radius: 5px; font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden;
}
.week-bar:hover { opacity: 0.9; }
.week-bar:focus-visible { outline: 2px solid var(--color-blue-600); outline-offset: 1px; }
/* An overnight's "9p–7a": never narrower than its label. */
.week-bar-mono { font-family: var(--font-mono); font-size: 10px; padding: 0 4px; justify-content: center; min-width: max-content; }
.week-bar-cut-l { border-left-style: dotted; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.week-bar-cut-r {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 10px), rgba(0, 0, 0, 0.35));
  mask-image: linear-gradient(90deg, #000 calc(100% - 10px), rgba(0, 0, 0, 0.35));
}

/* === Data table (design/agency .tbl) === */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-ink-3); padding: 10px 16px; border-bottom: 1px solid var(--color-rule); white-space: nowrap;
}
.tbl td { padding: 11px 16px; border-bottom: 1px solid var(--color-rule-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }

/* === Overlapping avatar stack (staff on a household) === */
.av-stack { display: flex; }
.av-stack > .av { width: 24px; height: 24px; font-size: 9px; border: 2px solid #fff; margin-left: -6px; }
.av-stack > .av:first-child { margin-left: 0; }
.av-stack-lg > .av { width: 30px; height: 30px; font-size: 10px; }
