@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700;800&family=Geist+Mono:wght@400;500&display=swap');

:root {
  --bg: #f9fafb;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-soft: #eff6ff;
  --blue-border: #dbeafe;
  --code-bg: #f3f4f6;
  --code-text: #111827;
  --max-w: 768px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar (matches ia.gowy.es) */
header.site {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

header.site .nav-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header.site .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
}

header.site .brand .icon { color: var(--blue); font-size: 1.1rem; }

header.site nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.875rem;
}

header.site nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 150ms ease;
}

header.site nav a:hover { color: var(--text); }
header.site nav a.active { color: var(--text); font-weight: 600; }

header.site nav a.cta {
  background: var(--blue);
  color: white;
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  font-weight: 500;
  font-size: 0.875rem;
  transition: background 150ms ease;
}

header.site nav a.cta:hover { background: var(--blue-hover); }

/* Main wrapper */
main.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
  padding: 2.5rem 1.25rem 5rem;
  flex: 1;
}

/* Tipografía */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

h1 {
  font-size: 2.25rem;
  letter-spacing: -0.025em;
  margin-bottom: 1rem;
}

h1 .badge {
  display: inline-block;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25em 0.7em;
  margin-right: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  border-radius: 9999px;
  border: 1px solid var(--blue-border);
}

h2 {
  font-size: 1.5rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  letter-spacing: -0.01em;
}

h2:first-of-type, .hero + h2 { border-top: none; padding-top: 0; margin-top: 2.5rem; }

h3 {
  font-size: 1.1rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p { margin: 0 0 1rem; color: var(--text); }

a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover { color: var(--blue-hover); }

strong { font-weight: 600; }
em { font-style: italic; color: var(--text); }

ul, ol {
  margin: 0 0 1.25rem 1.5rem;
  padding: 0;
}

ul li, ol li { margin-bottom: 0.4rem; color: var(--text); }

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

blockquote {
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text);
  border-radius: 0 6px 6px 0;
}

blockquote p:last-child { margin-bottom: 0; }

code {
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', Monaco, Menlo, monospace;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--code-text);
  font-weight: 500;
}

pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.82rem;
  line-height: 1.55;
  font-family: 'Geist Mono', ui-monospace, 'SF Mono', Monaco, Menlo, monospace;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  font-weight: 400;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92em;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

th {
  font-weight: 600;
  background: #f9fafb;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Meta info bar */
.meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.meta span b {
  color: var(--text);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 0.4em;
}

/* Hero */
.hero {
  text-align: center;
  padding: 3rem 0 3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.hero .eyebrow {
  display: inline-block;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: 3rem;
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin-bottom: 1.25rem;
}

.hero h1 .accent { color: var(--blue); }

.hero .subtitle {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 38rem;
  margin: 0 auto 2rem;
  line-height: 1.55;
}

.hero .cta-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all 150ms ease;
  border: 1px solid transparent;
}

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

.btn-primary {
  background: var(--blue);
  color: white;
}
.btn-primary:hover { background: var(--blue-hover); color: white; }

.btn-secondary {
  background: #f3f4f6;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: #e5e7eb; color: var(--text); }

/* Stats strip */
.stats {
  background: var(--blue-soft);
  border: 1px solid var(--blue-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 2.5rem 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  text-align: center;
}

.stats .stat .num {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -0.02em;
  display: block;
}

.stats .stat .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Module grid */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 3rem;
}

.module-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: all 180ms ease;
  position: relative;
}

.module-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -8px rgba(37, 99, 235, 0.2);
  text-decoration: none;
  color: var(--text);
}

.module-card .num {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--blue);
  text-transform: uppercase;
  background: var(--blue-soft);
  padding: 0.2em 0.6em;
  border-radius: 9999px;
  border: 1px solid var(--blue-border);
  margin-bottom: 0.75rem;
}

.module-card .title {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0.5rem 0 0.75rem;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.01em;
}

.module-card .status {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.module-card.extra {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border-color: #1e293b;
  color: #e2e8f0;
}

.module-card.extra:hover {
  border-color: var(--blue);
  color: #e2e8f0;
}

.module-card.extra .title { color: #f1f5f9; }
.module-card.extra .num { background: rgba(37, 99, 235, 0.15); color: #60a5fa; border-color: rgba(37, 99, 235, 0.3); }
.module-card.extra .status { color: #94a3b8; }

/* Callout */
.callout {
  background: var(--blue-soft);
  border: 1px solid var(--blue-border);
  border-left: 4px solid var(--blue);
  padding: 1rem 1.25rem;
  margin: 1.75rem 0;
  border-radius: 0 8px 8px 0;
}

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

/* Module navigation */
.nav-modules {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.nav-modules a {
  text-decoration: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 45%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  border-radius: 10px;
  transition: all 150ms ease;
}

.nav-modules a:hover {
  border-color: var(--blue);
  color: var(--text-muted);
}

.nav-modules a span:first-child {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  color: var(--blue);
  font-weight: 600;
}

.nav-modules a span:last-child {
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
}

.nav-modules a.next { text-align: right; margin-left: auto; }

/* Diagrams */
.diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  text-align: center;
}

.diagram svg { max-width: 100%; height: auto; }

.diagram .caption {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Footer */
footer.site {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 1.75rem 1rem;
  margin-top: 4rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

footer.site .links {
  margin-top: 0.5rem;
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  font-size: 0.82rem;
}

footer.site .links a {
  color: var(--text-muted);
  text-decoration: none;
}

footer.site .links a:hover { color: var(--blue); }

/* Responsive */
@media (max-width: 640px) {
  html { font-size: 15.5px; }
  main.wrap { padding: 1.5rem 1rem 4rem; }
  .hero { padding: 2rem 0; }
  .hero h1 { font-size: 2.1rem; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.25rem; }
  pre { font-size: 0.75rem; padding: 0.9rem 1rem; }
  table { font-size: 0.82em; }
  header.site nav { gap: 0.9rem; }
  header.site nav a.cta { display: none; }
  .nav-modules { flex-direction: column; gap: 0.75rem; }
  .nav-modules a, .nav-modules a.next { max-width: 100%; text-align: left; }
  .stats { grid-template-columns: 1fr; gap: 1.25rem; padding: 1.25rem; }
}

@media print {
  html { font-size: 11.5pt; }
  body { background: white; color: black; }
  main.wrap { max-width: none; padding: 0; }
  header.site, .nav-modules, footer.site { display: none; }
  pre { background: #f5f5f5; color: #111; border: 1px solid #ddd; }
  a { color: black; text-decoration: underline; }
  .module-card { break-inside: avoid; box-shadow: none; }
}

/* Diagrams: keep readable on mobile via horizontal scroll instead of shrinking */
@media (max-width: 720px) {
  .diagram {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 1rem;
    position: relative;
  }
  .diagram svg {
    min-width: 600px;
    max-width: none;
    height: auto;
    display: block;
  }
  .diagram::after {
    content: "← desliza →";
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-soft);
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: sticky;
    left: 0;
  }
  .diagram .caption {
    position: sticky;
    left: 0;
  }
}

/* polish: keep brand badge readable on narrow phones */
@media (max-width: 480px) {
  header.site .brand { gap: 0.4rem; font-size: 0.95rem; }
}
