/*
 * Unio · sitio legal (estático, sin dependencias, sin scripts, sin cookies).
 * Paleta tomada de src/theme/index.ts (marfil cálido / santuario oscuro).
 * Los colores de texto y enlaces cumplen WCAG AA (≥ 4.5:1) sobre su fondo.
 */

:root {
  color-scheme: light dark;

  --bg: #f5f1e7;          /* colors.background.primary */
  --surface: #fcf8f0;     /* colors.background.secondary */
  --surface-2: #efe8da;   /* colors.background.tertiary */
  --text: #2f2a24;        /* colors.text.primary — 12.6:1 */
  --text-2: #5b5246;      /* colors.text.secondary — 6.8:1 */
  --muted: #6e6457;       /* más oscuro que text.tertiary para llegar a 5.1:1 */
  --link: #7a4f10;        /* bronce — 6.3:1 */
  --link-hover: #5e3c0b;
  --accent: #d9ae65;      /* vitral.gold — solo decorativo */
  --accent-2: #c8894d;    /* vitral.amber */
  --border: rgba(120, 106, 86, 0.22);
  --border-strong: rgba(120, 106, 86, 0.38);
  --focus: #7a4f10;
  --mark-bg: #f6e3b4;
  --mark-border: #c8894d;
  --callout-bg: #fbf4e6;  /* colors.background.warm */

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  --radius: 14px;
  --radius-sm: 8px;
  --gutter: 16px;
  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171c1a;
    --surface: #1e2421;
    --surface-2: #252c28;
    --text: #f7f2e8;      /* 15.5:1 */
    --text-2: #b8b6ae;    /* 8.5:1 */
    --muted: #9d9c96;     /* 6.3:1 */
    --link: #deb573;      /* 9.0:1 */
    --link-hover: #e7c995;
    --accent: #deb573;
    --accent-2: #d5985d;
    --border: rgba(233, 214, 183, 0.16);
    --border-strong: rgba(233, 214, 183, 0.3);
    --focus: #e7c995;
    --mark-bg: #4a3b17;
    --mark-border: #d5985d;
    --callout-bg: #1e2421;
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--mark-bg);
  color: var(--text);
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}

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

h1,
h2,
h3 {
  color: var(--text);
  line-height: 1.2;
  text-wrap: balance;
}

h1,
h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 7vw, 2.75rem);
  margin: 0 0 0.5rem;
}

h2 {
  font-size: clamp(1.4rem, 4.5vw, 1.7rem);
  margin: 2.75rem 0 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: 1rem;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 650;
  margin: 1.75rem 0 0.4rem;
  scroll-margin-top: 1rem;
}

p,
ul,
ol,
dl {
  margin: 0 0 1rem;
}

ul,
ol {
  padding-left: 1.4rem;
}

li + li {
  margin-top: 0.35rem;
}

strong {
  font-weight: 650;
}

small,
.small {
  font-size: 0.9375rem;
}

/* ---------- Layout ---------- */

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  color: var(--link);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 0.75rem;
}

.wrap {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.brand::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 3px var(--surface-2);
}

.brand:hover {
  color: var(--text);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav li + li {
  margin-top: 0;
}

.site-nav a {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.5;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--accent);
}

main.wrap {
  padding-top: 2.25rem;
  padding-bottom: 3rem;
}

.lede {
  font-size: 1.1875rem;
  color: var(--text-2);
  margin-bottom: 1.25rem;
}

.meta {
  color: var(--muted);
  font-size: 0.9375rem;
  margin-bottom: 1.75rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9375rem;
  padding: 1.75rem 0 2.5rem;
}

.site-footer p {
  margin-bottom: 0.5rem;
}

.site-footer a {
  color: var(--text-2);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

.footer-links li + li {
  margin-top: 0;
}

/* ---------- Components ---------- */

.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin: 0 0 1.5rem;
}

.box > :last-child {
  margin-bottom: 0;
}

.box h2:first-child,
.box h3:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.callout {
  background: var(--callout-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  margin: 1.25rem 0 1.5rem;
}

.callout > :last-child {
  margin-bottom: 0;
}

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 0 0 2rem;
}

.toc h2 {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
}

.toc ol {
  margin: 0;
  padding-left: 1.3rem;
}

.toc li + li {
  margin-top: 0.2rem;
}

@media (min-width: 40rem) {
  .toc ol {
    columns: 2;
    column-gap: 2rem;
  }

  .toc li {
    break-inside: avoid;
  }
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
  padding: 0;
  list-style: none;
}

.cards li + li {
  margin-top: 0;
}

.card {
  display: block;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  color: var(--text);
  text-decoration: none;
}

a.card:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface-2);
}

.card strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.card span {
  display: block;
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* Lista de proveedores / plazos: tarjetas en lugar de tablas (mejor en móvil). */
.entries {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  gap: 0.75rem;
}

.entries > li + li {
  margin-top: 0;
}

.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.15rem;
}

.entry h3 {
  margin: 0 0 0.35rem;
}

.entry dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem 1rem;
  margin: 0;
}

.entry dt {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.entry dd {
  margin: 0 0 0.5rem;
}

.entry dd:last-child {
  margin-bottom: 0;
}

@media (min-width: 36rem) {
  .entry dl {
    grid-template-columns: 9rem 1fr;
  }

  .entry dd {
    margin-bottom: 0.25rem;
  }
}

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.6rem;
  min-height: 2rem;
}

.steps > li + li {
  margin-top: 0.75rem;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1;
}

.path {
  font-weight: 650;
  color: var(--text);
}

kbd,
.ui {
  font-family: inherit;
  font-size: 0.95em;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.05em 0.4em;
  white-space: nowrap;
}

/* Preguntas frecuentes: <details> nativo, sin JavaScript. */
.faq {
  margin: 0 0 1.5rem;
}

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 0 0.6rem;
}

.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 0.8rem 2.75rem 0.8rem 1rem;
  position: relative;
  font-weight: 600;
  line-height: 1.45;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "";
  position: absolute;
  right: 1.1rem;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
}

.faq details[open] > summary::after {
  transform: translateY(-30%) rotate(-135deg);
}

.faq details[open] > summary {
  border-bottom: 1px solid var(--border);
}

.faq .answer {
  padding: 0.85rem 1rem 0.2rem;
}

/* Marcas para el propietario: deben desaparecer antes de publicar. */
mark.confirmar {
  background: var(--mark-bg);
  color: var(--text);
  border: 1px dashed var(--mark-border);
  border-radius: 4px;
  padding: 0 0.3em;
  font-size: 0.9em;
  font-weight: 600;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.url {
  overflow-wrap: anywhere;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

@media (prefers-reduced-motion: no-preference) {
  a,
  .site-nav a,
  .card {
    transition: color 120ms ease-out, background-color 120ms ease-out, border-color 120ms ease-out;
  }
}

@media print {
  .site-nav,
  .skip-link,
  .toc {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  a {
    color: #000;
  }

  .box,
  .entry,
  .callout,
  .faq details {
    break-inside: avoid;
  }
}
