/* Mático — base visual compartida (portada y aplicación) */

/* Tipografías propias (licencia OFL, ver /assets/fonts/LICENSE-*.txt): servidas desde nuestro dominio. */
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/assets/fonts/bricolage-grotesque.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('/assets/fonts/instrument-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Color: blanco y grises neutros fríos, tinta casi negra y el naranja sólo para lo principal */
  --ivory: #f6f7f9; /* lienzo */
  --ivory-2: #eceef2;
  --paper: #ffffff; /* superficies */
  --sand: #f0f2f5; /* hover y selección */
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --carbon: #15171c; /* tinta: color dominante */
  --carbon-2: #262a31;
  --ink-2: #434a56;
  --ink-3: #697180;
  --orange: #ff5a1f; /* naranja Mático */
  --orange-press: #e8490f;
  --orange-ink: #b53a0a; /* naranja para texto (contraste AA) */
  --orange-wash: #ffe8dd;
  --green: #0e7a4f; /* verde billete: lo que entra */
  --green-wash: #ddf3e8;
  --red: #d92d20;
  --red-wash: #fde5e2;
  --amber: #8a5a00;
  --amber-wash: #fcf0d2;
  --blue-ink: #2442b8;
  --blue-wash: #e4e9fb;
  --on-dark: #ffffff;
  --on-dark-2: #a8afbb;
  /* Naranja oscuro: el foco tiene que contrastar 3:1 sobre el fondo claro (el naranja de marca no llega) */
  --focus: #b53a0a;

  /* Tipografía: Bricolage Grotesque para títulos y cifras; Instrument Sans para leer */
  --font: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Bricolage Grotesque', 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, Consolas, monospace;
  --fs-xs: 0.8125rem; /* 13 */
  --fs-sm: 0.875rem; /* 14 */
  --fs-base: 1rem; /* 16 */
  --fs-md: 1.125rem; /* 18 */
  --fs-lg: 1.375rem; /* 22 */
  --fs-xl: 1.75rem; /* 28 */
  --fs-2xl: 2.375rem; /* 38 */
  --fs-3xl: 3.25rem; /* 52 */

  /* Espaciado (múltiplos de 4) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Formas y profundidad: sombras en capas, como luz real */
  --r-xs: 6px;
  --r-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --pill: 999px;
  --control: 44px;
  --control-sm: 36px;
  --control-lg: 54px;
  --border: 1px solid var(--line);
  --shadow-1: 0 1px 0 rgba(16, 24, 40, 0.04);
  --shadow-soft: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 12px -6px rgba(16, 24, 40, 0.08);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 12px 28px -14px rgba(16, 24, 40, 0.18);
  --shadow-pop: 0 2px 6px rgba(16, 24, 40, 0.08), 0 28px 56px -24px rgba(16, 24, 40, 0.35);
  --ring: 0 0 0 3px rgba(255, 90, 31, 0.28);

  /* Movimiento: salidas rápidas, llegadas suaves */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 420ms;
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ivory);
  color: var(--carbon);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  font-feature-settings: 'ss01' on;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.4em;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h1 {
  letter-spacing: -0.035em;
  line-height: 1.04;
}

p {
  margin: 0 0 0.8em;
  text-wrap: pretty;
}

a {
  color: var(--carbon);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--orange-ink);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection {
  background: var(--orange);
  color: var(--carbon);
}

img,
svg {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

/* Encabezados que reciben el foco al cambiar de pantalla (para lectores de pantalla) */
[tabindex='-1']:focus {
  outline: none;
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--carbon);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius);
  z-index: 100;
}
.skip-link:focus {
  top: 12px;
  color: var(--paper);
}

/* Importes: siempre con cifras de igual ancho para que se alineen en columna */
.num,
.amount,
.tnum {
  font-variant-numeric: tabular-nums;
}

/* Íconos lineales: heredan el color del texto */
.ico {
  width: 20px;
  height: 20px;
  flex: none;
}

/* ---------- Marca ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--carbon);
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
}
.brand-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.04em;
}
/* Logotipo "Mático": la á en naranja, como las líneas del isotipo */
.brand-word span {
  color: var(--orange);
}
.mark-bar {
  fill: var(--carbon);
}
.mark-rule {
  fill: var(--orange);
}

/* ---------- Botones ---------- */

.btn {
  --h: var(--control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--h);
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--carbon);
  font: inherit;
  font-weight: 600;
  font-size: var(--fs-base);
  line-height: 1.2;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-1);
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out);
}
.btn:hover {
  border-color: var(--carbon);
  color: var(--carbon);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-1);
  transition-duration: 60ms;
}
.btn .ico {
  width: 18px;
  height: 18px;
  transition: transform var(--dur) var(--ease-spring);
}
.btn:hover .ico {
  transform: scale(1.08);
}
.btn-primary {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--carbon);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 1px 2px rgba(181, 58, 10, 0.25);
}
.btn-primary:hover {
  background: var(--orange-press);
  border-color: var(--orange-press);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 10px 22px -10px rgba(232, 73, 15, 0.7);
}
.btn-dark {
  background: var(--carbon);
  border-color: var(--carbon);
  color: var(--paper);
}
.btn-dark:hover {
  background: #000;
  border-color: #000;
  color: var(--paper);
  box-shadow: 0 10px 22px -12px rgba(20, 18, 15, 0.7);
}
.btn-quiet {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
  padding: 0 10px;
}
.btn-quiet:hover {
  background: var(--sand);
  border-color: transparent;
  box-shadow: none;
  text-decoration-color: currentColor;
  transform: none;
}
.btn-danger {
  border-color: var(--red);
  color: var(--red);
}
.btn-danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn-sm {
  --h: var(--control-sm);
  padding: 0 12px;
  font-size: var(--fs-sm);
  border-radius: 10px;
}
.btn-lg {
  --h: var(--control-lg);
  padding: 0 26px;
  font-size: var(--fs-md);
  border-radius: 14px;
}
.btn-block {
  width: 100%;
}
.btn[disabled],
.btn[aria-busy='true'] {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

/* ---------- Formularios ---------- */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: var(--sp-5);
  min-width: 0;
}
.field label,
.field legend,
.label {
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: 0.005em;
}
.field .optional {
  font-weight: 500;
  color: var(--ink-3);
}
.help {
  color: var(--ink-2);
  font-size: var(--fs-sm);
  margin: 0;
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--control);
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--carbon);
  font: inherit;
  box-shadow: inset 0 1px 2px rgba(20, 18, 15, 0.04);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}
.select {
  padding-right: 32px;
}
.textarea {
  min-height: 96px;
  resize: vertical;
}
.input::placeholder,
.textarea::placeholder {
  color: #a39b8d;
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--ink-3);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--carbon);
  box-shadow: var(--ring);
}
.input[aria-invalid='true'],
.select[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--red);
}
/* Con el error a la vista, la ayuda del campo sobra (suele decir lo mismo) */
.field:has(.field-error) > .help {
  display: none;
}
.field-error {
  display: flex;
  gap: 6px;
  color: var(--red);
  font-weight: 600;
  font-size: var(--fs-sm);
  margin: 0;
}
.field-error::before {
  content: '!';
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
}
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 500;
}
.check input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--carbon);
  flex: none;
}

/* ---------- Avisos ---------- */

.notice {
  display: grid;
  gap: 4px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-3);
  background: var(--paper);
}
.notice strong {
  font-weight: 700;
}
.notice p {
  margin: 0;
}
.notice-error {
  border-color: #f6c8c2;
  border-left-color: var(--red);
  background: var(--red-wash);
}
.notice-ok {
  border-color: #b9e3cd;
  border-left-color: var(--green);
  background: var(--green-wash);
}
.notice-review {
  border-color: #ecd9a8;
  border-left-color: var(--amber);
  background: var(--amber-wash);
}
.notice-info {
  border-color: #c9d3f5;
  border-left-color: var(--blue-ink);
  background: var(--blue-wash);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
