/* Shared components (web/app/components.mjs). Tokens only: design/tokens.css. */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.icon { flex: none; display: block; }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── BigButton ─────────────────────────────────────────────────────── */
.big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--h-button);
  padding: var(--space-2) var(--space-6);
  border: 0;
  border-radius: var(--r-button);
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-size: var(--fs-button);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--t-fast) var(--ease);
}
.big.secondary {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.big:disabled { opacity: 0.5; cursor: default; }
.big:active:not(:disabled) { opacity: 0.8; }

/* ── Link ──────────────────────────────────────────────────────────── */
.link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-2);
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-size: var(--fs-link);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ── Back link ─────────────────────────────────────────────────────── */
.back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap-min);
  margin-left: calc(-1 * var(--space-2));
  padding-right: var(--space-2);
  color: var(--muted);
  font-size: var(--fs-small);
  text-decoration: none;
}

/* ── ModuleBox ─────────────────────────────────────────────────────── */
.module {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6);
  border-radius: var(--r-box);
  box-shadow: inset 0 0 0 1px var(--line);
}
.module.tone-blue  { background: var(--p-blue);  box-shadow: none; }
.module.tone-green { background: var(--p-green); box-shadow: none; }
.module.tone-peach { background: var(--p-peach); box-shadow: none; }
.module.tone-lilac { background: var(--p-lilac); box-shadow: none; }
.module-header { margin: 0; color: var(--muted); font-size: var(--fs-min); }
.module-title { margin: 0; font-size: var(--fs-h2); line-height: 1.3; font-weight: 700; }
.module p { margin: 0; }
.module .link { align-self: center; }

/* ── Row ───────────────────────────────────────────────────────────── */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--h-row);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-label { overflow-wrap: anywhere; }
.row .avatar + .row-text .row-label { font-weight: 600; }
.row-sub { color: var(--muted); font-size: var(--fs-small); }
.row-value { font-weight: 700; text-align: right; }
.row > .icon { color: var(--muted); }

/* ── Chips ─────────────────────────────────────────────────────────── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.chips-legend { margin-bottom: var(--space-2); padding: 0; color: var(--muted); font-size: var(--fs-small); }
.chip { position: relative; flex: 1 1 0; min-width: max-content; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--h-chip);
  padding: 0 var(--space-5);
  border-radius: var(--r-chip);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 600;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.chip input:checked + span { background: var(--accent-fill); color: #FFFFFF; box-shadow: none; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── AskBar ────────────────────────────────────────────────────────── */
.askbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--h-ask);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-6);
  border-radius: var(--r-button);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.askbar input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-min);
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.askbar input::placeholder { color: var(--muted); }
.askbar input:focus { outline: none; }
.askbar:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.askbar .send {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--h-button);
  height: var(--h-button);
  max-height: calc(var(--h-ask) - var(--space-2));
  max-width: calc(var(--h-ask) - var(--space-2));
  border: 0;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  cursor: pointer;
}

/* ── Tabs ──────────────────────────────────────────────────────────── */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: var(--h-tabs);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: var(--tap-min);
  color: var(--muted);
  font-size: var(--fs-tab);
  font-weight: 500;
  text-decoration: none;
}
.tab[aria-current="page"] { color: var(--text); font-weight: 700; }

/* ── Sheet ─────────────────────────────────────────────────────────── */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--bg);
  color: var(--text);
  overflow: auto;
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: sheet-in var(--t-sheet) var(--ease); }
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-3) var(--margin) calc(var(--margin) + env(safe-area-inset-bottom));
}
.grab {
  align-self: center;
  width: 44px;
  height: 6px;
  border-radius: 4px;
  background: var(--line);
}
.sheet-title:focus { outline: none; }
.sheet-title { margin: 0; font-size: var(--fs-h2); line-height: 1.3; font-weight: 700; }
.sheet-close { align-self: center; }
.small-print { margin: 0; color: var(--muted); font-size: var(--fs-small); text-align: center; }

/* ── Avatar ────────────────────────────────────────────────────────── */
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--avatar);
  height: var(--avatar);
  border-radius: 50%;
  object-fit: cover;
  color: var(--text);
  font-weight: 700;
  font-size: var(--fs-body);
}
.avatar.large { width: var(--avatar-large); height: var(--avatar-large); font-size: var(--fs-title); }
.avatar.tone-blue  { background: var(--p-blue); }
.avatar.tone-green { background: var(--p-green); }
.avatar.tone-peach { background: var(--p-peach); }
.avatar.tone-lilac { background: var(--p-lilac); }

@media (prefers-reduced-motion: reduce) {
  .sheet[open] { animation: none; }
}

/* ── Toggle ────────────────────────────────────────────────────────── */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  min-height: var(--h-row);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 34px;
  border-radius: 18px;
  background: var(--line);
  transition: background var(--t-fast) var(--ease);
}
.toggle .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.16);
  transition: transform var(--t-fast) var(--ease);
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(22px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
