/* ============================================================
   R3 JOB · base — reset, tipografía, primitivas
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* El scroll-snap del keynote se declara aquí y lo apaga .is-app */
  scrollbar-color: var(--line-2) transparent;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--t-md);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
h1 { font-size: var(--t-xxl); }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }
h4 { font-size: var(--t-md); letter-spacing: -0.012em; line-height: 1.25; }

p { text-wrap: pretty; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
ul, ol { padding-left: 1.15em; }
li + li { margin-top: 0.2em; }
img, svg, canvas { display: block; max-width: 100%; }
b, strong { font-weight: 650; }
small { font-size: var(--t-xs); }

:focus-visible {
  outline: 2px solid var(--acc-hi);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--acc); color: var(--acc-ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }

/* ---------------- utilidades tipográficas ---------------- */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.eyebrow {
  font-size: var(--t-2xs);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--acc);
}
.eyebrow.data { color: var(--data); }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.lede { font-size: var(--t-lg); color: var(--ink-2); line-height: 1.45; letter-spacing: -0.014em; }
.tight { letter-spacing: -0.04em; }

/* Degradado de marca sobre texto grande */
.grad {
  background: linear-gradient(96deg, var(--cobre-200) 0%, var(--cobre-400) 34%, var(--acero-300) 88%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
:root[data-theme="light"] .grad {
  background: linear-gradient(96deg, var(--cobre-600) 0%, #C4600A 40%, var(--acero-600) 92%);
  -webkit-background-clip: text;
  background-clip: text;
}

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Cualquier clase con `display` explícito (.grid, .row…) gana al valor
   por defecto de [hidden]. Sin esto, ocultar un panel no oculta nada. */
[hidden] { display: none !important; }

.skip {
  position: fixed; top: -100px; left: var(--sp-4); z-index: var(--z-toast);
  background: var(--acc); color: var(--acc-ink); padding: 10px 16px;
  border-radius: var(--r-sm); font-weight: 650; transition: top var(--d-sm) var(--ease-out);
}
.skip:focus { top: var(--sp-4); text-decoration: none; }

/* ---------------- controles ---------------- */
button, input, select, textarea { font: inherit; color: inherit; }

.btn {
  --btn-bg: var(--acc);
  --btn-ink: var(--acc-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--btn-bg); color: var(--btn-ink);
  border: 1px solid transparent; border-radius: var(--r-full);
  padding: 12px 22px; font-size: var(--t-sm); font-weight: 650; letter-spacing: -0.01em;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform var(--d-xs) var(--ease-out), filter var(--d-xs) var(--ease-out),
              background-color var(--d-xs) var(--ease-out), border-color var(--d-xs) var(--ease-out);
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn.ghost { --btn-bg: transparent; --btn-ink: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); filter: none; border-color: var(--ink-3); }
.btn.quiet { --btn-bg: var(--surface-3); --btn-ink: var(--ink); }
.btn.data { --btn-bg: var(--data); --btn-ink: var(--ink-inv); }
.btn.danger { --btn-bg: transparent; --btn-ink: var(--grave); border-color: var(--grave); }
.btn.danger:hover { background: var(--grave-soft); filter: none; }
.btn.sm { padding: 8px 15px; font-size: var(--t-xs); }
.btn.lg { padding: 15px 30px; font-size: var(--t-md); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.42; pointer-events: none; }
.btn .ico { font-size: 1.1em; line-height: 1; }

input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="search"], select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  width: 100%;
  transition: border-color var(--d-xs) var(--ease-out), background-color var(--d-xs) var(--ease-out);
}
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { border-color: var(--acc); outline: none; background: var(--surface); }
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--acc); width: 18px; height: 18px; cursor: pointer; }

/* El campo es un <label class="field"> con un <span> de rótulo dentro. */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span,
.field > label {
  font-size: var(--t-xs); font-weight: 650; color: var(--ink-2);
  letter-spacing: 0.01em; line-height: 1.3;
}
.field small {
  display: block; font-weight: 400; color: var(--ink-3);
  letter-spacing: 0; font-size: var(--t-2xs); margin-top: 1px;
}
.field-row { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* Segmentado tipo iOS */
.seg {
  display: inline-flex; background: var(--surface-3); border-radius: var(--r-full);
  padding: 3px; gap: 2px; position: relative;
}
.seg button {
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  padding: 7px 15px; border-radius: var(--r-full); font-size: var(--t-xs); font-weight: 650;
  transition: color var(--d-xs) var(--ease-out);
}
.seg button[aria-pressed="true"] { color: var(--acc-ink); background: var(--acc); }
.seg.data button[aria-pressed="true"] { background: var(--data); color: var(--ink-inv); }

/* Píldoras de estado */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-2xs); font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--ink-2);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.aviso { background: var(--aviso-soft); color: var(--aviso); }
.pill.grave { background: var(--grave-soft); color: var(--grave); }
.pill.acc { background: var(--acc-soft); color: var(--acc); }
.pill.dat { background: var(--data-soft); color: var(--data); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
