/* Base styles ported from docs/design/canvas/Main.dc.html. Colors come only from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--k-paper);
  color: var(--k-text);
  font-family: var(--k-font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--k-text); text-decoration: none; }
a:hover { color: var(--k-tag-health-fg); }
button, input, select, textarea { font-family: inherit; }
button { color: inherit; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 2px solid var(--k-violet); outline-offset: 2px; }

.disp { font-family: var(--k-font-display); letter-spacing: -0.03em; }
.mono { font-family: var(--k-font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--k-text-muted); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- shell (mobile first) ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: var(--k-ink);
  font-weight: 800;
  font-size: 22px;
}
.logo:hover { color: var(--k-ink); }
.logo svg { width: 40px; height: 32px; flex: none; }
.logo .wordmark { display: none; }

.wrap {
  max-width: 1232px;
  margin: 0 auto;
  padding: 4px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.footer {
  max-width: 1232px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 13px;
  color: var(--k-text-muted);
}
.footer a { color: var(--k-text-muted); }

/* ---------- cards ---------- */
.card {
  background: var(--k-card);
  border: 1px solid var(--k-line);
  border-radius: var(--k-r-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--k-shadow-card);
  transition: transform var(--k-dur) var(--k-ease-out), box-shadow var(--k-dur) var(--k-ease-out);
}

/* ---------- buttons ---------- */
.btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--k-r-md);
  border: 0;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform var(--k-dur-fast) var(--k-ease-out), box-shadow var(--k-dur-fast) ease, background var(--k-dur-fast) ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn-lime { background: var(--k-lime); color: var(--k-ink-night); }
.btn-lime:hover { color: var(--k-ink-night); box-shadow: 0 8px 24px -8px var(--k-lime-strong); }
.btn-ink { background: var(--k-ink); color: var(--k-card); }
.btn-ink:hover { color: var(--k-card); }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .topbar { padding: 16px 32px; }
  .logo .wordmark { display: inline; }
  .wrap { padding: 8px 32px 56px; gap: 20px; }
  .footer { padding: 24px 32px 40px; }
  .card { padding: 24px 26px; }
  .card:hover { transform: translateY(-3px); box-shadow: var(--k-shadow-hover); }
}

/* ---------- landing ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--k-ink-night);
  color: var(--k-card);
  border-radius: var(--k-r-hero);
  padding: 28px 20px;
}
.blob { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .75; pointer-events: none; }
.b1 { width: 260px; height: 260px; background: var(--k-violet); right: -90px; top: -110px; animation: drift1 14s ease-in-out infinite; }
.b2 { width: 200px; height: 200px; background: var(--k-coral); left: -60px; bottom: -130px; opacity: .5; animation: drift2 18s ease-in-out infinite; }
.b3 { width: 160px; height: 160px; background: var(--k-lime); right: -40px; bottom: -70px; opacity: .3; animation: drift1 22s ease-in-out infinite reverse; }
@keyframes drift1 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-30px, 24px) scale(1.12); } }
@keyframes drift2 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(40px, -24px); } }
.grain {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(color-mix(in srgb, var(--k-card) 7%, transparent) 1px, transparent 1px);
  background-size: 4px 4px;
  pointer-events: none;
}
.hero-body { position: relative; display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.hero h1 { font-size: 34px; line-height: 1.05; font-weight: 800; }
.hero-lead { color: var(--k-on-ink-muted); font-size: 16px; line-height: 1.5; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--k-on-ink-muted); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--k-lime); box-shadow: 0 0 0 0 var(--k-lime); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-ghost { background: transparent; color: var(--k-card); border: 1px solid var(--k-on-ink-muted); }
.btn-ghost:hover { color: var(--k-card); }
.ic { width: 20px; height: 20px; flex: none; }

.section { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.section h2 { font-size: 26px; font-weight: 700; }
.section h3 { font-size: 17px; font-weight: 600; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.step-n { color: var(--k-text-soft); font-size: 13px; }
.grid-3 { display: grid; gap: 12px; }
.note { font-size: 13px; }
.tag { align-self: flex-start; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: var(--k-r-pill); }
.tag-health { background: var(--k-tag-health-bg); color: var(--k-tag-health-fg); }
.tag-food { background: var(--k-tag-food-bg); color: var(--k-tag-food-fg); }
.tag-care { background: var(--k-tag-care-bg); color: var(--k-tag-care-fg); }
.tag-skin { background: var(--k-tag-skin-bg); color: var(--k-tag-skin-fg); }
.about-card { flex-direction: row; align-items: flex-start; }
.about-mark { flex: none; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.field input[type=email], .field input[type=text], .field input[type=tel], .field textarea, .field select {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--k-r-md);
  border: 1px solid var(--k-line);
  background: var(--k-paper);
  font: inherit;
  color: var(--k-text);
}
.field-check { flex-direction: row; align-items: center; gap: 10px; }
.field-check input { width: 22px; height: 22px; accent-color: var(--k-ink); }
.field-check label { font-weight: 400; }
.field-check a { text-decoration: underline; }
.field-error { margin: 0; font-size: 13px; color: var(--k-tag-skin-fg); }

.flash { padding: 12px 16px; border-radius: var(--k-r-md); background: var(--k-tag-food-bg); color: var(--k-tag-food-fg); font-weight: 600; }
.flash-alert { background: var(--k-tag-skin-bg); color: var(--k-tag-skin-fg); }

/* ---------- long text ---------- */
.prose { max-width: 760px; line-height: 1.6; }
.prose h1 { font-size: 30px; }
.prose h2 { font-size: 19px; margin-top: 8px; }
.prose ul { margin: 0; padding-left: 20px; }
.prose a { text-decoration: underline; }

@media (min-width: 900px) {
  .hero { padding: 48px; }
  .hero h1 { font-size: 52px; }
  .b1 { width: 380px; height: 380px; right: -80px; top: -140px; }
  .b2 { width: 280px; height: 280px; left: auto; right: 240px; bottom: -170px; }
  .b3 { width: 220px; height: 220px; right: 40px; bottom: -60px; }
  .steps, .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .section h2 { font-size: 32px; }
}

/* ---------- local WhatsApp simulator (dev/test only) ---------- */
.simulator { max-width: 640px; }
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 10px 12px; border-radius: var(--k-r-md); display: flex; flex-direction: column; gap: 4px; white-space: pre-line; overflow-wrap: anywhere; }
.msg.in { align-self: flex-end; background: var(--k-tag-food-bg); }
.msg.out { align-self: flex-start; background: var(--k-paper); border: 1px solid var(--k-line); }
.msg time { font-size: 11px; color: var(--k-text-soft); align-self: flex-end; }
.msg-photo { font-size: 13px; font-weight: 600; }
.mail { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--k-line); padding-top: 12px; }
.mail h2 { font-size: 16px; }
.mail-frame { width: 100%; height: 520px; border: 1px solid var(--k-line); border-radius: var(--k-r-md); background: var(--k-card); }

/* ---------- shared dog record (/f/:token) ---------- */
.record-hero { display: flex; flex-direction: column; gap: 18px; }
.hero-top { position: relative; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dog-avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--k-ear-light); color: var(--k-ink); display: inline-flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; flex: none; }
.record-hero h1 { font-size: 34px; font-weight: 800; line-height: 1; }
.dog-meta { color: var(--k-on-ink-muted); font-size: 14px; margin-top: 6px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: var(--k-r-pill); background: color-mix(in srgb, var(--k-card) 12%, transparent); color: var(--k-card); }
.chips { position: relative; list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: var(--k-r-pill); background: var(--k-tag-skin-bg); color: var(--k-tag-skin-fg); }
.kpis { position: relative; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: color-mix(in srgb, var(--k-card) 8%, transparent); border-radius: var(--k-r-md); padding: 12px 14px; }
.kpi dt { font-size: 12px; color: var(--k-on-ink-muted); }
.kpi dd { margin: 4px 0 0; font-size: 20px; }
.record-grid { display: grid; gap: 16px; }
.record-grid h2, .timeline-title { font-size: 20px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.list li { display: flex; gap: 12px; align-items: flex-start; }
.medication { flex-direction: column; gap: 2px !important; }
.date-tile { flex: none; font-size: 12px; padding: 6px 8px; border-radius: var(--k-r-sm); background: var(--k-paper); border: 1px solid var(--k-line); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--k-line-soft); }
.timeline li:first-child { border-top: 0; }
.tl-icon { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--k-r-sm); font-weight: 700; }
.tl-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tl-date { font-size: 13px; color: var(--k-text-soft); }

@media (min-width: 900px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .record-grid { grid-template-columns: 1fr 1fr; }
  .record-hero h1 { font-size: 44px; }
}

/* ---------- operator view (/ops) ---------- */
.ops-head h1 { font-size: 30px; }
.kpi-card .big { font-size: 30px; }
.kpi-card.ok { border-color: var(--k-lime-strong); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--k-text-muted); padding: 8px; border-bottom: 1px solid var(--k-line); white-space: nowrap; }
.table td { padding: 8px; border-bottom: 1px solid var(--k-line-soft); vertical-align: top; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 12px; background: var(--k-paper); border: 1px solid var(--k-line); color: var(--k-text); }
form.inline { display: inline-block; margin: 0; }
.mcp-token { display: block; padding: 12px; border-radius: var(--k-r-md); background: var(--k-paper); font-family: var(--k-font-mono); word-break: break-all; }

/* ---------- language switch (I18N-4): ES | EN segmented control ---------- */
/* Works without JS: .is-current marks the active option. The locale-switch controller slides
   .locale-switch__pill under it; until then the pill stays hidden and .is-current gets the fill. */
.locale-switch { display: inline-flex; margin: 0; }
.locale-switch__group {
  position: relative;
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--k-line);
  border-radius: var(--k-r-pill);
  background: var(--k-card);
}
.locale-switch__pill {
  position: absolute;
  inset: 3px auto 3px 3px;
  width: 0;
  border-radius: var(--k-r-pill);
  background: var(--k-ink);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--k-dur) var(--k-ease-out), width var(--k-dur) var(--k-ease-out);
}
.locale-switch__option {
  position: relative;
  z-index: 1;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--k-r-pill);
  background: transparent;
  color: var(--k-text-muted);
  font: 600 13px/1 var(--k-font-mono);
  letter-spacing: .04em;
  cursor: pointer;
}
.locale-switch__option:hover { color: var(--k-ink); }
.locale-switch__option.is-current { background: var(--k-ink); color: var(--k-card); }
/* With JS the controller adds .is-enhanced to the form and moves the pill (width + translateX). */
.locale-switch.is-enhanced .locale-switch__pill { opacity: 1; }
.locale-switch.is-enhanced .locale-switch__option.is-current { background: transparent; }
@media (prefers-reduced-motion: reduce) {
  .locale-switch__pill { transition: none; }
}
