/* Tokens: ../assets/variables.css (cargar antes que este archivo) */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  margin: 0;
  color: var(--foreground);
  background: var(--background);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

a:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100%;
  z-index: 200;
  padding: 0.75rem 1rem;
  border-radius: 980px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
}

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

.shell {
  width: min(100% - 2.5rem, var(--shell));
  margin-inline: auto;
}

/* Header — mismo lenguaje que miuif.com */
.header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  min-height: var(--header-h);
  background: #ffffffeb;
  border-bottom: 1px solid var(--border-soft);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 76rem;
  min-height: var(--header-h);
  margin: 0 auto;
  padding: 0.5rem 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 550;
  letter-spacing: -0.04em;
  line-height: 0;
  text-decoration: none;
}

.brand img {
  width: 28px;
  height: 28px;
}

.brand b {
  color: var(--primary);
  font-weight: 450;
}

.brand:hover {
  text-decoration: none;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.header-nav > a {
  color: var(--ink);
}

.header-nav > a:hover {
  color: var(--primary);
  text-decoration: none;
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.625rem 1rem;
  border: 1px solid #d2d2d7;
  border-radius: 980px;
  background: #fff;
  font-weight: 550;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.nav-cta:hover {
  background: #f5f5f7;
  border-color: #b7cef3;
  color: var(--primary);
  text-decoration: none;
}

/* Hero documental */
.page-hero {
  padding: calc(var(--header-h) + 3.5rem) 0 1rem;
  background:
    linear-gradient(180deg, var(--muted) 0%, #fff 100%);
  border-bottom: 1px solid var(--border);
}

.page-hero h1 {
  margin: 0 0 1rem;
  color: var(--ink);
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  font-weight: 550;
  letter-spacing: -0.06em;
  line-height: 1.08;
}

.lede {
  color: var(--foreground);
  font-size: 1.0625rem;
  line-height: 1.65;
}

.meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--border);
}

.meta div {
  min-width: 0;
}

.meta dt {
  margin: 0 0 0.35rem;
  color: var(--muted-foreground);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Layout documento + TOC */
.doc-layout {
  display: grid;
  grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
  gap: 3rem;
  padding: 3rem 0 4.5rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--header-h) + 1.25rem);
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card, #fff);
}

.toc-label {
  margin: 0 0 0.85rem;
  color: var(--muted-foreground);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
  border-top: 1px solid var(--border);
}

.toc li:first-child {
  border-top: 0;
}

.toc a {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.5rem;
  padding: 0.75rem 0;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.toc a:hover,
.toc a.is-active {
  color: var(--primary);
}

.toc a.is-active {
  font-weight: 600;
}

.doc {
  max-width: 44rem;
  min-width: 0;
}

.doc-block {
  padding: 0 0 2.25rem;
  margin: 0 0 2.25rem;
  border-bottom: 1px solid var(--border);
}

.doc-block:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.doc h2 {
  margin: 0 0 1rem;
  color: var(--ink);
  font-size: 1.375rem;
  font-weight: 550;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.doc h3 {
  margin: 0 0 0.5rem;
  color: var(--primary);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.doc p {
  margin: 0 0 1rem;
  color: var(--foreground);
}

.doc p:last-child {
  margin-bottom: 0;
}

.data-list {
  margin: 0 0 1rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--foreground);
  list-style: none;
}

.data-list li {
  position: relative;
  padding-left: 1.15rem;
}

.data-list li + li {
  margin-top: 0.45rem;
}

.data-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--primary);
}

.data-list--numbered {
  counter-reset: data-item;
}

.data-list--numbered li {
  padding-left: 1.6rem;
  counter-increment: data-item;
}

.data-list--numbered li::before {
  content: counter(data-item) ".";
  top: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  color: var(--primary);
  font-weight: 600;
}

.rights {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
  overflow: hidden;
}

.rights article {
  padding: 1.35rem 1.4rem;
  background: #fff;
}

.rights .rights-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0 0 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.rights h3 {
  margin: 0 0 0.65rem;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 550;
  letter-spacing: -0.02em;
}

.rights p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.contact-card {
  padding: 1.5rem !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius);
  background: var(--accent);
}

.contact-card h2 {
  color: var(--primary);
}

.contact-card address {
  display: grid;
  gap: 1rem;
  margin: 1.25rem 0 0;
  font-style: normal;
}

.contact-card address p {
  display: grid;
  gap: 0.25rem;
  margin: 0;
}

.contact-card address span {
  color: var(--muted-foreground);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  color: var(--foreground);
}

.footer-shell {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.9fr;
  gap: 2rem;
  padding: 2.5rem 0 3rem;
  position: relative;
}

.footer-shell::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
}

.footer-brand .brand {
  margin-bottom: 1rem;
  line-height: 1;
}

.footer-brand p,
.footer-contact p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.65;
}

.footer-links,
.footer-contact {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.footer-links h2,
.footer-contact h2 {
  margin: 0 0 0.35rem;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-links a,
.footer-contact a {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.footer-links a:hover,
.footer-contact a:hover {
  color: var(--primary);
}

.footer-links a[aria-current="page"] {
  color: var(--primary);
  font-weight: 550;
}

@media (max-width: 900px) {
  .doc-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-top: 2rem;
  }

  .toc {
    position: static;
  }

  .toc ol {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
  }

  .toc li {
    border-top: 0;
  }

  .toc a {
    padding: 0.5rem 0;
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .footer-shell {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .header-inner {
    padding-inline: 1rem;
  }

  .shell {
    width: min(100% - 1.5rem, var(--shell));
  }
}

@media (max-width: 560px) {
  .toc ol {
    grid-template-columns: 1fr;
  }

  .page-hero {
    padding-top: calc(var(--header-h) + 2.25rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media print {
  @page {
    size: letter;
    margin: 1.4cm 1.7cm;
  }

  :root {
    --foreground: #000;
    --ink: #000;
    --muted-foreground: #333;
  }

  html {
    scroll-behavior: auto;
  }

  body {
    font: 10pt/1.38 Georgia, "Times New Roman", serif;
    color: #000;
    background: #fff;
  }

  .header,
  .skip-link,
  .toc,
  .eyebrow,
  .site-footer {
    display: none !important;
  }

  .shell {
    width: 100%;
    margin: 0;
  }

  .page-hero {
    padding: 0 0 8pt;
    background: none;
    border-bottom: 1.5pt solid #000;
  }

  .page-hero h1 {
    margin: 0 0 4pt;
    font-size: 16pt;
    letter-spacing: 0;
    text-transform: uppercase;
    text-align: center;
  }

  .lede {
    display: none;
  }

  .meta {
    grid-template-columns: repeat(3, 1fr);
    gap: 8pt;
    padding-top: 4pt;
    border-top: 0;
  }

  .meta dt {
    margin: 0 0 1pt;
    color: #333;
    font-size: 7pt;
  }

  .meta dd {
    font-size: 9pt;
  }

  .doc-layout {
    display: block;
    padding: 10pt 0 0;
  }

  .doc {
    max-width: none;
  }

  .doc-block {
    margin: 0 0 9pt;
    padding: 0;
    border: 0;
  }

  .doc h2 {
    margin: 0 0 3pt;
    font-size: 11pt;
    letter-spacing: 0;
    break-after: avoid;
    page-break-after: avoid;
  }

  .doc h3 {
    margin: 0 0 2pt;
    color: #000;
    font-size: 10pt;
    letter-spacing: 0;
    break-after: avoid;
    page-break-after: avoid;
  }

  .doc p {
    margin: 0 0 4pt;
    text-align: justify;
    orphans: 3;
    widows: 3;
  }

  .data-list {
    margin: 0 0 4pt;
    padding: 0 0 0 12pt;
    border: 0;
    background: none;
  }

  .data-list li + li {
    margin-top: 1pt;
  }

  .data-list li::before {
    background: #000;
  }

  .data-list--numbered li::before {
    background: none;
    color: #000;
  }

  .rights {
    display: block;
    border: 0;
    background: none;
    overflow: visible;
  }

  .rights {
    margin-top: 4pt;
  }

  .rights article {
    padding: 0 0 4pt;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .rights .rights-label {
    display: none;
  }

  .rights h3 {
    display: inline;
    font-size: 10pt;
    color: #000;
  }

  .rights h3::after {
    content: ". ";
  }

  .rights p {
    display: inline;
    color: #000;
    font-size: 10pt;
    line-height: 1.38;
  }

  .contact-card {
    padding: 7pt 9pt !important;
    border: 1pt solid #000 !important;
    border-radius: 0;
    background: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .contact-card h2 {
    color: #000;
  }

  .contact-card address {
    gap: 5pt;
    margin-top: 5pt;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}
