/* =====================================================================
   Saans — components: buttons, choices, cards, disclosures, controls.
   ===================================================================== */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur-ui) var(--ease-calm), border-color var(--dur-ui) var(--ease-calm), transform var(--dur-ui) var(--ease-calm), box-shadow var(--dur-ui) var(--ease-calm);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--primary); color: var(--text); }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-soft);
}
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }

.btn--hero {
  min-height: 3.75rem;
  padding: 0.9rem 2.2rem;
  font-size: var(--step-1);
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-lift);
}

.btn--quiet {
  border-color: transparent;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  font-weight: 500;
}
.btn--quiet:hover { border-color: transparent; background: var(--bg-soft); }

.btn--danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.btn--small { min-height: var(--tap); padding: 0.4rem 0.9rem; font-size: var(--step--1); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Feeling choices ---------- */
.feelings {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-5);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: var(--space-3);
}
.feelings li + li { margin-top: 0; }
.feeling {
  width: 100%;
  min-height: 4.25rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: border-color var(--dur-ui) var(--ease-calm), transform var(--dur-ui) var(--ease-calm), background-color var(--dur-ui);
  -webkit-tap-highlight-color: transparent;
}
.feeling:hover { border-color: var(--primary); color: var(--text); transform: translateY(-1px); }
.feeling:hover .feeling__label { text-decoration: underline; text-underline-offset: 0.2em; }
.feeling[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.feeling__emoji { font-size: 1.45rem; line-height: 1; flex: none; }
.feeling__label { font-weight: 550; line-height: 1.3; min-width: 0; overflow-wrap: break-word; hyphens: auto; }

/* ---------- Cards ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.card h3 { font-size: var(--step-1); margin: 0; }
.card p { margin: 0; }
.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  font-size: var(--step--1);
  color: var(--text-muted);
}
.card__meta div { display: flex; gap: 0.35em; }
.card__meta dt { font-weight: 600; color: var(--text); }
.card__meta dd { margin: 0; }
.card__actions { margin-top: auto; padding-top: var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

.card--feature {
  background: linear-gradient(160deg, var(--sky-top), var(--surface) 70%);
  border-color: var(--border-strong);
}

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
}

/* ---------- Evidence badge (dots + text, never colour alone) ---------- */
.evidence-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--step--1);
  color: var(--text-muted);
}
.evidence-badge__dots { display: inline-flex; gap: 3px; }
.evidence-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
}
.evidence-badge .dot.is-on { background: var(--primary); border-color: var(--primary); }

/* ---------- Tags ---------- */
.tag {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  font-size: var(--step--1);
  color: var(--text);
}

/* ---------- Disclosure ---------- */
.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  margin-bottom: var(--space-3);
}
.disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--tap);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  border-radius: var(--radius-m);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
  content: "";
  width: 0.55rem; height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--dur-ui) var(--ease-calm);
  flex: none;
}
.disclosure[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.disclosure__body { padding: 0 var(--space-4) var(--space-4); }
.disclosure__body > :last-child { margin-bottom: 0; }

/* ---------- Form controls ---------- */
.field { margin: 0 0 var(--space-5); padding: 0; border: 0; min-width: 0; }
.field legend, .field__label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--step-1);
  margin-bottom: var(--space-2);
  padding: 0;
}
.field__hint { font-size: var(--step--1); color: var(--text-muted); margin: 0 0 var(--space-3); }

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.segmented label {
  position: relative;
  display: inline-flex;
}
.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.segmented span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
  transition: background-color var(--dur-ui), border-color var(--dur-ui);
}
.segmented span::before {
  content: "";
  width: 0.9rem; height: 0.9rem;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  flex: none;
}
.segmented input:checked + span {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
  font-weight: 650;
}
.segmented input:checked + span::before {
  border-color: var(--primary);
  background: radial-gradient(circle, var(--primary) 45%, transparent 50%);
}
.segmented input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: var(--tap);
  cursor: pointer;
}
.check input {
  width: 1.4rem; height: 1.4rem;
  margin: 0.15rem 0 0;
  accent-color: var(--primary);
  flex: none;
}

.range {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1);
  margin: var(--space-2) 0 var(--space-3);
}
.range label { font-size: var(--step--1); color: var(--text-muted); }
.range input[type="range"] {
  width: 100%;
  min-height: var(--tap);
  accent-color: var(--primary);
  background: transparent;
}

select.select {
  min-height: var(--tap);
  padding: 0 2.2rem 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  inset-inline: 0;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 0 var(--space-4);
}
.toast {
  max-width: 30rem;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-m);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lift);
  font-size: var(--step--1);
  pointer-events: auto;
  animation: toast-in 300ms var(--ease-calm);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Notices ---------- */
.notice {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-m);
  background: var(--bg-soft);
  border-inline-start: 4px solid var(--primary);
}
.notice > :last-child { margin-bottom: 0; }
.notice--care { border-inline-start-color: var(--accent); }
.notice--urgent { border-inline-start-color: var(--danger); background: var(--danger-soft); }

/* ---------- Dialog ---------- */
dialog.dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: var(--space-6) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lift);
}
dialog.dialog::backdrop { background: rgb(20 15 10 / 0.45); }

/* ---------- Garden (history) ---------- */
.garden {
  display: block;
  width: 100%;
  max-width: 36rem;
  height: auto;
  border-radius: var(--radius-l);
  background: linear-gradient(180deg, var(--sky-top), var(--bg-soft));
  border: 1px solid var(--border);
  overflow: hidden;
}
.garden .ground { fill: var(--leaf); opacity: 0.22; }
.garden .stem { stroke: var(--leaf); stroke-width: 2; fill: none; stroke-linecap: round; }
.garden .petal { fill: var(--petal); }
.garden .petal--alt { fill: var(--calm); }
.garden .centre { fill: var(--breath-core); stroke: var(--accent); stroke-width: 1; }
.garden .bud { fill: var(--leaf); opacity: 0.7; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-m); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.table th, .table td { text-align: start; vertical-align: top; padding: var(--space-3); border-bottom: 1px solid var(--border); }
.table th { background: var(--bg-soft); font-weight: 650; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- References ---------- */
.refs { padding-inline-start: 1.2rem; font-size: var(--step--1); }
.refs li { margin-bottom: var(--space-3); }
.refs .ref-summary { display: block; color: var(--text-muted); margin-top: var(--space-1); }
.refs a { word-break: break-word; }
.notice + h2, .notice + section, .notice + .stack, .notice + div { margin-top: var(--space-5); }
.support-urgent { font-size: var(--step-1); }
