/* Kidney Navigator /app: stage look (2026-11-17). Styles only; rollback: delete this file and its <link>.
   <html data-stage="pre|post"> is set by kn-transplant.js from the saved stage.
   Pre  = "Dialysis and waiting": deep navy band, deep red accent, a week strip of dialysis days.
   Post = "Life after transplant": deep green band, gold rule, a day counter.
   Contrast AA in light and dark; html.contrast turns both into black on white with 2px borders. */

html[data-stage='pre'] {
  --st-band: #16233f;
  --st-fg: #ffffff;
  --st-acc: #8e1b22; /* accent text on light surfaces, 8:1 on white */
  --st-rule: #c4282e;
  --st-wash: #f3eeee;
}
html[data-stage='post'] {
  --st-band: #164a33;
  --st-fg: #ffffff;
  --st-acc: #1f6b45; /* 6.3:1 on white */
  --st-rule: #f4c542; /* gold, used as a shape only, never as text on white */
  --st-wash: #edf3ee;
}
@media (prefers-color-scheme: dark) {
  html[data-stage='pre']:not(.contrast) {
    --st-band: #1b2542;
    --st-acc: #ff8a8f;
    --st-rule: #ff6369;
    --st-wash: #26282d;
  }
  html[data-stage='post']:not(.contrast) {
    --st-band: #12392a;
    --st-acc: #4cc38a;
    --st-rule: #f4c542;
    --st-wash: #26282d;
  }
}
html.contrast[data-stage] {
  --st-band: #000;
  --st-fg: #fff;
  --st-acc: #000;
  --st-rule: #000;
  --st-wash: #fff;
}

/* The app's own accent follows the stage (Post turns the red buttons green; Pre deepens the red). */
html[data-stage='pre']:not(.contrast) {
  --blue: #8e1b22;
}
html[data-stage='post']:not(.contrast) {
  --blue: #1f6b45;
}
html[data-stage='post']:not(.contrast) .btn:not(.ghost):not(.danger) {
  background: #1f6b45;
  color: #fff;
}
@media (prefers-color-scheme: dark) {
  html[data-stage='pre']:not(.contrast) {
    --blue: #ff6369;
  }
  html[data-stage='post']:not(.contrast) {
    --blue: #4cc38a;
  }
}

/* ---------- banner ---------- */
#kn-stage-banner {
  background: var(--st-band);
  color: var(--st-fg);
  border-bottom: 4px solid var(--st-rule);
  position: relative;
  overflow: hidden;
}
#kn-stage-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
}
/* Pre: a quiet row of day ticks along the foot, like a calendar you are counting down. */
html[data-stage='pre'] #kn-stage-banner::before {
  background: repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.16) 0 2px,
      transparent 2px 28px
    )
    left bottom / 100% 10px no-repeat;
}
/* Post: one soft gold glow in the corner, no pattern. */
html[data-stage='post'] #kn-stage-banner::before {
  background: radial-gradient(60% 140% at 100% 0, rgba(244, 197, 66, 0.28), transparent 70%);
}
html.contrast #kn-stage-banner::before {
  display: none;
}
.kns-sb-in {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px max(20px, env(safe-area-inset-left)) 18px max(20px, env(safe-area-inset-left));
  display: flex;
  gap: 16px 32px;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
}
.kns-sb-k {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.92;
}
.kns-sb-h {
  margin: 2px 0 0;
  font-size: clamp(1.75rem, 5.2vw, 2.6rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.kns-sb-s {
  margin: 6px 0 0;
  font-size: 1.0625rem;
  line-height: 1.4;
  max-width: 36em;
  letter-spacing: -0.005em;
}
#kn-stage-banner[data-home='0'] .kns-sb-s,
#kn-stage-banner[data-home='0'] .kns-sb-x {
  display: none;
}
#kn-stage-banner[data-home='0'] .kns-sb-in {
  padding-top: 10px;
  padding-bottom: 10px;
}
#kn-stage-banner[data-home='0'] .kns-sb-h {
  font-size: 1.375rem;
}
.kns-sb-x {
  text-align: right;
}
.kns-sb-c {
  margin: 6px 0 0;
  font-size: 1rem;
  font-weight: 600;
}
.kns-wk {
  display: inline-flex;
  gap: 6px;
}
.kns-wk-d {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.55);
  color: var(--st-fg);
}
.kns-wk-d.on {
  background: #fff;
  color: #16233f;
  border-color: #fff;
}
.kns-wk-d.now {
  box-shadow:
    0 0 0 3px var(--st-band),
    0 0 0 5px #fff;
}
html.contrast .kns-wk-d.on {
  color: #000;
}
.kns-sb-n {
  margin: 0;
  font-family: var(--num, ui-rounded, 'SF Pro Rounded', system-ui, sans-serif);
  font-size: clamp(2.5rem, 8vw, 3.75rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.04em;
}
html[data-stage='post'] .kns-sb-n {
  color: var(--st-rule);
}
html.contrast .kns-sb-n {
  color: #fff;
}
@media (max-width: 520px) {
  .kns-sb-x {
    text-align: left;
  }
}

/* ---------- Post: same tools, stage tile and medicines first, gold rule on the tile ---------- */
html[data-stage='post'] .kn-dash #kn-dc-row {
  order: -1;
}
html[data-stage='post'] #kn-dc-stage {
  box-shadow:
    inset 4px 0 0 var(--st-rule),
    0 1px 2px rgba(22, 24, 28, 0.04),
    0 8px 24px -12px rgba(22, 24, 28, 0.12);
}
html[data-stage='post'] .kn-dash h2 {
  color: var(--st-acc);
}
html.contrast[data-stage='post'] .kn-dash h2 {
  color: inherit;
}

/* ---------- Pre Home ---------- */
#kn-pre-home {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0;
}
.kns-pc {
  margin: 0;
  box-shadow:
    inset 4px 0 0 var(--st-rule),
    0 1px 2px rgba(22, 24, 28, 0.04),
    0 8px 24px -12px rgba(22, 24, 28, 0.12);
}
html.contrast .kns-pc {
  box-shadow: none;
}
.kns-k {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--st-acc);
}
.kns-k2 {
  margin: 14px 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}
.kns-pc h2 {
  margin: 2px 0 0;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: -0.025em;
}
.kns-big {
  margin: 6px 0 0;
  font-family: var(--num, ui-rounded, 'SF Pro Rounded', system-ui, sans-serif);
  font-size: clamp(2.25rem, 7vw, 3rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--ink);
}
.kns-mid {
  margin: 2px 0 0;
  font-family: var(--num, ui-rounded, 'SF Pro Rounded', system-ui, sans-serif);
  font-size: 1.75rem;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.kns-unit {
  font-family: var(--hig-font, system-ui, sans-serif);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted);
}
.kns-pc .sub {
  margin: 6px 0 0;
}
.kns-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0 24px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.kns-cell {
  padding-top: 4px;
}
.kns-cell .btn {
  margin-top: 10px;
}
.kns-pc .chips {
  margin-top: 12px;
}
.kns-h3 {
  margin: 16px 0 4px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.kns-lbl {
  margin: 10px 0 2px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--st-acc);
}
.kns-ul {
  margin: 4px 0;
  padding-left: 22px;
}
.kns-ul li {
  padding: 3px 0;
  line-height: 1.45;
}
.kns-src a {
  color: var(--st-acc);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.kns-draft {
  margin: 10px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #e2b25a;
  background: #fff7e6;
  color: #4a3500;
  font-size: 1rem;
  line-height: 1.5;
}
html.contrast .kns-draft {
  background: #fff;
  color: #000;
  border: 2px solid #000;
}
@media (prefers-color-scheme: dark) {
  html:not(.contrast) .kns-draft {
    background: #2d2410;
    color: #f5dfae;
    border-color: #7a5a1c;
  }
}

/* minerals: a ledger, not boxes */
.kns-led {
  margin: 10px 0 0;
}
.kns-led-r {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  min-height: 44px;
}
.kns-led dt {
  font-weight: 700;
  font-size: 1.0625rem;
}
.kns-led dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.kns-led dd strong {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

/* progress */
.kns-prog {
  margin-top: 4px;
}
.kns-prog-n {
  margin: 0 0 8px;
  font-size: 1.0625rem;
  font-weight: 600;
}
.kns-prog-n strong {
  font-family: var(--num, ui-rounded, 'SF Pro Rounded', system-ui, sans-serif);
  font-size: 2.5rem;
  letter-spacing: -0.04em;
  margin-right: 2px;
  color: var(--ink);
}
.kns-bar {
  height: 12px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.kns-bar i {
  display: block;
  height: 100%;
  background: var(--st-acc);
  border-radius: 999px;
}
html.contrast .kns-bar {
  border: 2px solid #000;
  background: #fff;
}
html.contrast .kns-bar i {
  background: #000;
}
@media (prefers-reduced-motion: no-preference) {
  .kns-bar i {
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

/* grouped rows (like a Settings list): hairlines, a chevron, 44px targets */
.kns-list {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}
.kns-row {
  border-bottom: 1px solid var(--line);
}
.kns-row > summary,
.kns-meal > summary {
  list-style: none;
  cursor: pointer;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}
.kns-row > summary::-webkit-details-marker,
.kns-meal > summary::-webkit-details-marker {
  display: none;
}
.kns-row > summary::after,
.kns-meal > summary::after {
  content: '';
  flex: none;
  width: 10px;
  height: 10px;
  border-right: 2.5px solid var(--st-acc);
  border-bottom: 2.5px solid var(--st-acc);
  transform: rotate(-45deg);
}
.kns-row[open] > summary::after,
.kns-meal[open] > summary::after {
  transform: rotate(45deg);
}
@media (prefers-reduced-motion: no-preference) {
  .kns-row > summary::after,
  .kns-meal > summary::after {
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }
}
.kns-row-b {
  padding: 0 0 14px;
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.kns-ck {
  border: 0;
  padding: 0;
  margin: 0;
}
.kns-ck legend {
  padding: 0;
}
.kns-ck label.ck {
  align-items: flex-start;
  padding: 4px 0;
  line-height: 1.4;
}
.kns-ck input {
  margin-top: 2px;
  accent-color: var(--st-acc);
}
.kns-note {
  margin-top: 12px;
}
.kns-note textarea,
.kns-ctr input {
  width: 100%;
  font-size: 1.0625rem;
  line-height: 1.45;
}
.kns-ctr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 12px 0 0;
  padding: 8px 0 0;
}
.kns-ctr legend {
  font-weight: 700;
  padding: 0 6px 0 0;
}
.kns-gd {
  padding-top: 4px;
}
.kns-saved {
  min-height: 1.5em;
  margin: 0;
  text-align: center;
}

/* meals */
.kns-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}
.kns-chip {
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--fieldline, #c9cdd3);
  background: var(--card, #fff);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.kns-chip[aria-pressed='true'] {
  background: var(--st-acc);
  border-color: var(--st-acc);
  color: #fff;
}
.kns-chip[aria-pressed='true']::before {
  content: '\2713\00a0';
}
html.contrast .kns-chip[aria-pressed='true'] {
  background: #000;
  border-color: #000;
}
@media (prefers-color-scheme: dark) {
  html:not(.contrast) .kns-chip[aria-pressed='true'] {
    color: #000;
  }
}
.kns-count {
  margin: 6px 0;
  font-weight: 600;
}
.kns-meals {
  list-style: none;
  margin: 0;
  padding: 0;
}
.kns-li {
  border-top: 1px solid var(--line);
}
.kns-mn {
  flex: 1;
  min-width: 0;
}
.kns-tag {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

/* Medicare timeline: a vertical line with round stops */
.kns-tl {
  list-style: none;
  margin: 6px 0 0;
  padding: 0 0 0 22px;
  border-left: 3px solid var(--st-acc);
}
.kns-tl li {
  position: relative;
  padding: 8px 0 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.45;
}
.kns-tl li::before {
  content: '';
  position: absolute;
  left: -33px;
  top: 12px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid var(--st-acc);
}
.kns-tl .kns-src {
  margin: 2px 0 0;
}
.kns-est {
  margin: 8px 0 0;
  line-height: 1.5;
}

/* ---------- feel: the press shows on pointer-down, springs back, and never blocks input ---------- */
.kns-pc .btn,
.kns-pc summary,
.kns-pc .kns-chip,
.kns-pc label.ck,
#kn-stage-bar button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.kns-pc .btn.kns-press,
.kns-pc .kns-chip.kns-press,
#kn-stage-bar button.kns-press {
  transform: scale(0.97);
  transition: transform 90ms ease-out;
}
.kns-pc summary.kns-press,
.kns-pc label.ck.kns-press {
  opacity: 0.72;
  transition: opacity 90ms ease-out;
}
@media (prefers-reduced-motion: no-preference) {
  .kns-pc .btn,
  .kns-pc .kns-chip,
  #kn-stage-bar button {
    transition:
      transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
      background-color 0.2s;
  }
  #kn-stage-banner {
    transition:
      background-color 0.35s ease,
      border-color 0.35s ease;
  }
}
@media (prefers-reduced-motion: reduce) {
  .kns-pc .btn.kns-press,
  .kns-pc .kns-chip.kns-press,
  #kn-stage-bar button.kns-press {
    transform: none;
    opacity: 0.8;
  }
}
/* a stage-colour focus ring that stays visible on the band and on cards */
#kn-pre-home :focus-visible,
#kn-stage-banner :focus-visible {
  outline: 3px solid var(--st-acc);
  outline-offset: 2px;
}
@media (prefers-contrast: more) {
  #kn-stage-banner {
    background: #000;
  }
}

/* Pre: the dialysis and fluid tiles of the Today dashboard are shown by the cards above, so they are not repeated. */
html[data-stage='pre'] #kn-dc-row > section[aria-labelledby='hd'],
html[data-stage='pre'] #kn-dc-row > section[aria-labelledby='hf'] {
  display: none;
}
