/* www.gabriel-vergara.com: sin dependencias externas (CSP: solo 'self') */
:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --text: #1b2420;
  --muted: #56635d;
  --border: #dbe2dc;
  --accent: #2c6a4c;        /* verde: sostenibilidad */
  --accent-strong: #1f5139;
  --accent-soft: #e2efe7;
  --navy: #1e3a5f;          /* azul: seguridad */
  --warn-bg: #fff4e0;
  --warn-border: #e0a23a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 6px 24px rgba(16, 24, 20, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512;
    --surface: #161e1a;
    --surface-2: #1b2520;
    --text: #e4ebe7;
    --muted: #9aaaa2;
    --border: #27332d;
    --accent: #72c497;
    --accent-strong: #9adbb6;
    --accent-soft: #1d2f26;
    --navy: #9cc0ea;
    --warn-bg: #2b2414;
    --warn-border: #b8862f;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--font);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 .4em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); margin: 2.2em 0 .6em; }
h3 { font-size: 1.12rem; margin: 0 0 .4em; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(760px, 100% - 32px); margin-inline: auto; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Cabecera */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); text-decoration: none; margin-right: auto; }
.monogram {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .85rem; font-weight: 700; letter-spacing: .02em;
}
@media (prefers-color-scheme: dark) { .monogram { color: #0f1512; } }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a, .lang-switch a {
  color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: .95rem;
}
.main-nav a:hover, .lang-switch a:hover { background: var(--surface-2); color: var(--text); }
.main-nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }
.lang-switch { display: flex; gap: 2px; border-left: 1px solid var(--border); padding-left: 12px; }
.lang-switch a[aria-current="true"] { color: var(--accent); font-weight: 650; }
body { overflow-wrap: break-word; }
@media (max-width: 640px) {
  .header-inner { gap: 4px 12px; }
  .brand { width: 100%; }
  .main-nav { flex: 1; }
  .main-nav a, .lang-switch a { padding: 6px 8px; }
  .lang-switch { padding-left: 8px; }
  .site-footer { margin-top: 48px; }
}

/* Portada */
.hero { padding: clamp(48px, 9vw, 96px) 0 clamp(32px, 6vw, 64px); }
.hero .eyebrow { color: var(--accent); font-weight: 650; text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; margin-bottom: .8em; }
.hero .lead { font-size: clamp(1.1rem, 2.2vw, 1.3rem); color: var(--muted); max-width: 46em; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 10px;
  text-decoration: none; font-weight: 600; border: 1px solid var(--border); color: var(--text); background: var(--surface);
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary, .btn.primary:hover { color: #0f1512; } }

/* Tarjetas */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card p { color: var(--muted); margin: 0; font-size: .97rem; }
.card .tag { display: inline-block; font-size: .75rem; font-weight: 650; color: var(--navy); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.card.draft .tag { color: var(--muted); }

.band { background: var(--surface); border-block: 1px solid var(--border); padding: 48px 0; margin-top: 56px; }
.band h2 { margin-top: 0; }
.band + .site-footer, main > .band:last-child { margin-bottom: 0; }
.split { display: grid; gap: 32px; grid-template-columns: 1.3fr 1fr; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 18px 20px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .55em; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.timeline .when { font-size: .85rem; color: var(--muted); display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.chips li { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 4px 12px; font-size: .9rem; }

blockquote { margin: 2em 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--accent); font-size: 1.15rem; color: var(--muted); font-style: italic; }

.page { padding: 48px 0 24px; }
.page > .narrow > h1 + .lead { font-size: 1.15rem; color: var(--muted); }

/* Pie */
.site-footer { margin-top: 72px; border-top: 1px solid var(--border); background: var(--surface); font-size: .93rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 16px 40px; justify-content: space-between; align-items: center; padding-block: 28px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* Página de emergencia (Vammaiskortti) */
body.bare .site-footer { margin-top: 32px; }
.emergency { padding: 24px 0; }
.emergency .alert {
  background: var(--warn-bg); border: 2px solid var(--warn-border); border-radius: var(--radius);
  padding: 18px 20px; font-size: 1.15rem; margin-bottom: 24px;
}
.emergency .alert strong { font-size: 1.4rem; }
.emergency section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.emergency h2 { margin: 0 0 .5em; font-size: 1.25rem; }
.emergency .lang-label { font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .08em; }
.emergency .jump { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

@media print {
  .site-header, .site-footer, .jump, .skip { display: none; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .card, .emergency section { box-shadow: none; border-color: #999; }
}

/* Portada con foto */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.portrait img { display: block; width: 100%; max-width: 380px; margin-left: auto; border-radius: 24px; box-shadow: var(--shadow); aspect-ratio: 4 / 5; object-fit: cover; }
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .portrait { order: -1; }
  .portrait img { max-width: 220px; margin: 0; border-radius: 50%; aspect-ratio: 1; object-position: 50% 15%; }
}

/* Escudo familiar (Sobre mí) */
.roots { display: grid; grid-template-columns: 160px 1fr; gap: 24px; align-items: center; }
.roots img { width: 160px; height: auto; }
@media (max-width: 560px) { .roots { grid-template-columns: 1fr; } .roots img { width: 120px; } }

/* Artículos */
.article-meta { font-size: .9rem; color: var(--muted); margin-bottom: 1.2em; }
.article-meta a { text-decoration: none; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose li { margin-bottom: .35em; }
.prose code { font: .9em/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.prose pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0 1.5em; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { color: var(--muted); font-weight: 650; }
.prose .callout { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 8px; padding: 14px 18px; margin: 1.5em 0; }
.prose .callout p:last-child { margin-bottom: 0; }
.byline { margin-top: 3em; padding-top: 1em; border-top: 1px solid var(--border); font-size: .92rem; }
a.card { display: block; text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); }
a.card h3 { color: var(--text); }
a.card:hover h3 { color: var(--accent); }

/* Texto solo para lectores de pantalla (aviso de "se abre en otra pestaña") */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* Indicador visual de enlace externo */
a[target="_blank"]::after { content: "\2197"; font-size: .8em; margin-left: .15em; text-decoration: none; display: inline-block; }
.btn[target="_blank"]::after, a.card[target="_blank"]::after { margin-left: .3em; }

/* Vammaiskortti: diagnósticos en lista, fáciles de leer en una emergencia */
.emergency .conditions { margin: 0 0 12px; padding-left: 1.2em; font-size: 1.08rem; }
.emergency .conditions li { margin-bottom: 6px; }
