/* Componentes compartidos: tarjetas, stepper, riesgo, chips, hojas, toast, seguridad, tabbar. */

.ico { flex: none; }

/* ---------- Pantalla clara ---------- */
.screen--light { background: var(--bg-app); color: var(--text-default); }

/* ---------- Botones extra ---------- */
.btn--lg { min-height: 56px; font-size: var(--fs-h1); border-radius: var(--radius-lg); }
.btn--danger { background: var(--error); color: var(--text-inverse); }
.btn small { font-weight: var(--fw-medium); opacity: 0.7; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: transparent; color: inherit; cursor: pointer;
}

/* ---------- Tarjetas ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: var(--space-5);
}
.card-dark {
  background: var(--route-surface);
  border: 1px solid var(--route-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.avatar-initials {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--initials-bg); color: var(--initials-fg);
  font-weight: var(--fw-extrabold); font-size: var(--fs-body);
}

.tag-yellow {
  display: inline-block; padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--warning-light); color: var(--warning-strong);
}

/* ---------- Riesgo (semáforo del kit) ---------- */
.risk {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-label); font-weight: var(--fw-bold);
}
.risk__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.risk--bajo  { background: rgba(30, 177, 0, 0.16);  color: #5fd84a; }
.risk--medio { background: rgba(255, 206, 0, 0.16); color: var(--warning); }
.risk--alto  { background: rgba(244, 50, 50, 0.18); color: #ff6b6b; }
[data-theme="light"] .risk--bajo  { background: var(--success-subtle); color: var(--success-strong); }
[data-theme="light"] .risk--medio { background: var(--warning-light);  color: var(--warning-strong); }
[data-theme="light"] .risk--alto  { background: var(--error-subtle);   color: var(--error-strong); }

.chip-info {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--chip-bg); color: var(--route-text);
  font-size: var(--fs-label); font-weight: var(--fw-bold);
}

/* ---------- Stepper (Prepárate → Cobra) ---------- */
.stepper {
  display: grid; grid-template-columns: repeat(5, 1fr);
  margin: var(--space-2) 0 var(--space-4); padding: 0; list-style: none;
}
.stepper__item { position: relative; display: grid; justify-items: center; gap: 6px; }
.stepper__item:not(:last-child)::after {
  content: ""; position: absolute; top: 9px; left: calc(50% + 12px); right: calc(-50% + 12px);
  height: 2px; border-radius: 2px; background: currentColor; opacity: 0.18;
}
.stepper__item.is-done:not(:last-child)::after { background: var(--primary-400); opacity: 1; }
.stepper__dot {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid currentColor; opacity: 0.35; color: inherit;
}
.stepper__item.is-done .stepper__dot { background: var(--primary-400); border-color: var(--primary-400); color: #fff; opacity: 1; }
.stepper__item.is-current .stepper__dot {
  border-color: var(--primary-300); opacity: 1;
  box-shadow: 0 0 0 4px rgba(102, 182, 150, 0.25);
}
.stepper__item.is-current .stepper__dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary-300); }
.stepper__label { font-size: var(--fs-caption); line-height: var(--lh-caption); font-weight: var(--fw-medium); opacity: 0.6; }
.stepper__item.is-current .stepper__label { opacity: 1; font-weight: var(--fw-bold); }
[data-theme="light"] .stepper__item.is-current .stepper__dot { border-color: var(--primary-500); }
[data-theme="light"] .stepper__item.is-current .stepper__dot::after { background: var(--primary-500); }

/* ---------- Chips seleccionables ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-grid; justify-items: start; gap: 2px;
  min-height: 48px; padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md); border: 1px solid var(--border-default);
  background: var(--bg-surface); color: var(--text-default);
  font-weight: var(--fw-bold); cursor: pointer; text-align: left;
  transition: transform var(--dur-press) var(--ease-out), border-color 160ms ease, background-color 160ms ease;
}
.chip small { font-weight: var(--fw-medium); color: var(--text-secondary); font-size: var(--fs-label); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { border-color: var(--primary-500); background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--primary-500); }

/* ---------- Datos (dl) ---------- */
.facts { display: grid; gap: var(--space-3); margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: var(--space-4); }
.facts dt { color: var(--text-secondary); }
.facts dd { margin: 0; font-weight: var(--fw-bold); text-align: right; }

.quote { margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--accent-bg); }
.bullets { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-1); }

/* ---------- Switch ---------- */
.switch {
  position: relative; flex: none;
  width: 60px; height: 34px; padding: 0;
  border: 0; border-radius: var(--radius-pill);
  background: var(--switch-off); cursor: pointer;
  transition: background-color 200ms ease;
}
.switch__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 240ms var(--ease-out);
}
.switch[aria-checked="true"] { background: var(--success); }
.switch[aria-checked="true"] .switch__thumb { transform: translateX(26px); }

/* ---------- Tabbar del kit ---------- */
.tabbar {
  position: sticky; bottom: calc(-1 * max(env(safe-area-inset-bottom), 16px));
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin: var(--space-4) -16px calc(-1 * max(env(safe-area-inset-bottom), 16px));
  padding: var(--space-2) var(--space-2) max(env(safe-area-inset-bottom), 12px);
  background: var(--bg-surface);
  box-shadow: 0 -1px 0 var(--border-default);
}
.tabbar__item {
  display: grid; justify-items: center; gap: 2px;
  min-height: var(--touch-min); padding: var(--space-1) 0;
  border: 0; background: none; cursor: pointer;
  color: var(--text-secondary); font-size: var(--fs-caption); font-weight: var(--fw-medium);
}
.tabbar__item.is-active { color: var(--primary-500); font-weight: var(--fw-bold); }
.tabbar__item.is-active span { color: var(--text-default); }

/* ---------- Toast (kit: Toast notifications) ---------- */
.toast {
  position: absolute; z-index: 30;
  left: 16px; right: 16px; top: max(env(safe-area-inset-top), 16px);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--info-subtle); color: var(--info-strong);
  box-shadow: var(--shadow-2);
  font-weight: var(--fw-medium);
  animation: toast-in 260ms var(--ease-out) both;
}
.toast.is-leaving { opacity: 0; transform: translateY(-8px); transition: opacity 200ms ease, transform 200ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } }

/* ---------- Hoja inferior ---------- */
.sheet { position: absolute; inset: 0; z-index: 20; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(0, 12, 6, 0.55); animation: fade 200ms ease both; }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 86%; overflow-y: auto;
  padding: var(--space-2) var(--space-5) max(env(safe-area-inset-bottom), 24px);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--bg-surface); color: var(--text-default);
  animation: sheet-in 320ms var(--ease-drawer) both;
}
.sheet.is-leaving .sheet__scrim { opacity: 0; transition: opacity 200ms ease; }
.sheet.is-leaving .sheet__panel { transform: translateY(100%); transition: transform 200ms var(--ease-out); }
.sheet__grip { width: 40px; height: 4px; margin: 0 auto var(--space-2); border-radius: 4px; background: var(--neutral-200); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.sheet__title { margin: 0; font-size: var(--fs-display-m); line-height: var(--lh-display-m); font-weight: var(--fw-extrabold); }
.sheet__sub { margin: var(--space-5) 0 var(--space-2); font-size: var(--fs-h1); }
.sheet--danger .sheet__panel { border-top: 4px solid var(--error); }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Seguridad ---------- */
.safety-btn {
  position: absolute; z-index: 5;
  top: max(env(safe-area-inset-top), 16px); right: 16px;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(244, 50, 50, 0.45);
  background: rgba(244, 50, 50, 0.14); color: #ff7a7a;
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out);
}
.safety-btn:active { transform: scale(0.94); }
[data-theme="light"] .safety-btn { background: var(--error-subtle); color: var(--error-strong); }
.safety__lead { margin: 0 0 var(--space-5); font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: var(--fw-medium); }
.safety__actions { display: grid; gap: var(--space-2); }
.safety__note { margin: var(--space-4) 0 0; text-align: center; color: var(--text-secondary); font-size: var(--fs-label); }

/* Con botón de seguridad, el stepper deja espacio a la derecha */
.screen:has(.safety-btn) .stepper { margin-right: 52px; }

.demo-link {
  align-self: center; margin-top: var(--space-2);
  border: 0; background: none; cursor: pointer;
  color: var(--text-link); font-weight: var(--fw-bold); text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  .sheet__panel, .sheet__scrim, .toast { animation-name: fade; }
}
