/* ---------- Tipografías alojadas en el propio sitio (carpeta fonts/, en minúsculas) ---------- */
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/public-sans-v21-latin-regular.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/public-sans-v21-latin-500.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/public-sans-v21-latin-600.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/public-sans-v21-latin-700.woff2") format("woff2"); }
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("../fonts/Fraunces-VariableFont.woff2") format("woff2");
}

/* ---------- Paleta: azul marino + turquesa mediterráneo + ámbar ---------- */
:root {
  --bg: #eef3f6;
  --surface: #ffffff;
  --surface-2: #e4ecf1;
  --text: #14283a;
  --muted: #4d6477;
  --line: #cfdbe3;
  --accent: #0b6f79;
  --accent-ink: #ffffff;
  --accent-soft: #d6eef0;
  --warm: #9a5a0d;
  --chip: #ffffff;
  --shadow: 0 1px 2px rgba(20, 40, 58, .06), 0 8px 24px rgba(20, 40, 58, .06);
  --radius: 14px;
  --head: #d5e7ec;
  --head-line: #bcd3db;
  --tab-hover: #b3ced7;
  --danger: #b3261e;
  --band-bg: #fff1d6;
  --band-line: #a8620f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0e1923;
    --surface: #15242f;
    --surface-2: #1c2f3d;
    --text: #e5edf2;
    --muted: #9db3c2;
    --line: #263d4d;
    --accent: #56c5cf;
    --accent-ink: #072229;
    --accent-soft: #17383f;
    --warm: #e9ac5a;
    --chip: #e5edf2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --head: #112430;
    --head-line: #1f3646;
    --tab-hover: #1c2f3d;
    --danger: #ff9a92;
    --band-bg: #2b2213;
    --band-line: #e9ac5a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1923;
  --surface: #15242f;
  --surface-2: #1c2f3d;
  --text: #e5edf2;
  --muted: #9db3c2;
  --line: #263d4d;
  --accent: #56c5cf;
  --accent-ink: #072229;
  --accent-soft: #17383f;
  --warm: #e9ac5a;
  --chip: #e5edf2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --head: #112430;
  --head-line: #1f3646;
  --tab-hover: #1c2f3d;
  --danger: #ff9a92;
  --band-bg: #2b2213;
  --band-line: #e9ac5a;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background-color .25s, color .25s;
}
h1, h2, h3 {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  line-height: 1.2;
  margin: 0 0 .5em;
  font-weight: 700;
}
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.wrap { width: min(100% - 2rem, 62rem); margin-inline: auto; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Cabecera ---------- */
.site-header { background: var(--head); padding: 1.5rem 0 1rem; }
.header-grid { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 1rem; row-gap: .15rem; }
.site-title { grid-column: 1; grid-row: 1; font-size: clamp(1.5rem, 4.5vw, 2.4rem); margin: 0; }
.header-tools { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: .5rem; }
.site-sub { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 1.05rem; }

.theme-toggle {
  flex: none; display: inline-flex; align-items: center; gap: .5rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: .5rem .9rem; font: 500 .9rem/1 inherit; font-family: inherit; cursor: pointer;
  box-shadow: var(--shadow);
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .i-sun { display: none; }
:root[data-resolved="dark"] .theme-toggle .i-sun { display: block; }
:root[data-resolved="dark"] .theme-toggle .i-moon { display: none; }

/* ---------- Pestañas ---------- */
.tabs-bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--head);
  border-bottom: 1px solid var(--head-line);
}
[role="tablist"] {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem; padding: .5rem 0;
}
[role="tab"] {
  flex: none;
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 999px;
  padding: .55rem 1.1rem; font: 600 .95rem/1.2 inherit; font-family: inherit; cursor: pointer;
  transition: background-color .2s, color .2s;
}
[role="tab"]:hover { color: var(--text); background: var(--tab-hover); }
[role="tab"][aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- Paneles ---------- */
main { padding: 1.75rem 0 3rem; }
[role="tabpanel"] { animation: reveal .3s ease; }
[role="tabpanel"][hidden] { display: none; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel-title { font-size: clamp(1.4rem, 3.5vw, 1.9rem); margin-bottom: 1.25rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem;
}

/* ---------- Perfil ---------- */
.profile-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
.portrait { display: block; width: 100%; height: auto; max-width: 15rem; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); }
.profile-intro { display: grid; gap: 1.25rem; grid-template-columns: 1fr; align-items: start; }
.bio p { max-width: 62ch; }
.data-list { margin: 0; display: grid; gap: 0; }
.data-list div { display: grid; grid-template-columns: 9.5rem 1fr; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.data-list div:last-child { border-bottom: 0; }
.data-list dt { color: var(--muted); font-weight: 500; }
.data-list dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .5rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
  border: 1px solid var(--accent); border-radius: 10px; padding: .65rem 1.1rem; cursor: pointer;
  font-family: inherit; font-size: 1rem; line-height: 1.2;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); filter: none; }

/* ---------- Diplomas ---------- */
.diplomas { margin-top: 1.5rem; }
.diplomas h3 { margin-bottom: .25rem; }
.diplomas .sub { color: var(--muted); margin: 0 0 1rem; }
.table-wrap { overflow-x: auto; }
.dip-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.dip-table th, .dip-table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.dip-table thead th { background: var(--accent-soft); font-weight: 600; }
.dip-table tbody tr:hover { background: var(--surface-2); }
.dip-table .num { white-space: nowrap; }
.dip-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.dip-links a { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; background: var(--chip); border: 1px solid var(--line); border-radius: 10px; color: #0b6f79; }
.dip-links a:hover { border-color: var(--accent); }
.dip-links img { width: 1.4rem; height: 1.4rem; object-fit: contain; }
@media (max-width: 52rem) {
  .dip-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dip-table, .dip-table tbody, .dip-table tr, .dip-table td { display: block; width: 100%; }
  .dip-table tr { border: 1px solid var(--line); border-radius: 12px; padding: .5rem .85rem; margin-bottom: .9rem; }
  .dip-table td { display: flex; gap: .75rem; border: 0; padding: .3rem 0; }
  .dip-table td::before { content: attr(data-label); flex: 0 0 7rem; color: var(--muted); font-weight: 500; }
  .dip-table td:empty { display: none; }
}

/* ---------- CV (cronología) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: .45rem; top: .6rem; bottom: .6rem; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 1.5rem 2rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: 0; top: .45rem; width: 1rem; height: 1rem;
  border-radius: 50%; background: var(--surface); border: 3px solid var(--accent);
}
.timeline .date { font-weight: 600; color: var(--warm); font-size: .9rem; margin-bottom: .15rem; }
.timeline .company { font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: 1.15rem; margin: 0; }
.timeline .title { margin: 0; color: var(--accent); font-weight: 600; }
.timeline .description { margin: .3rem 0 0; color: var(--muted); max-width: 65ch; }

/* ---------- Listas de enlaces (Proyecto, Descargas, Blog) ---------- */
.link-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; list-style: none; margin: 0 0 2rem; padding: 0; }
.link-card {
  display: flex; flex-direction: column; gap: .25rem; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.link-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.link-card strong { font-family: "Fraunces", Georgia, serif; font-size: 1.1rem; color: var(--accent); }
.link-card span { color: var(--muted); font-size: .9rem; }
.subhead { font-size: 1.1rem; color: var(--muted); margin: 0 0 .75rem; }

/* ---------- RGPD ---------- */
.notice {
  border: 2px solid var(--warm); border-radius: var(--radius); padding: 1.25rem 1.5rem;
  background: var(--surface); margin-bottom: 1.5rem;
}
.notice h3 { color: var(--warm); margin-bottom: .75rem; }
.notice dl, .legal-table { margin: 0; }
.notice dl div, .legal-table div { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.notice dl div:last-child, .legal-table div:last-child { border-bottom: 0; }
.notice dt, .legal-table dt { font-weight: 600; margin-bottom: .1rem; }
.notice dd, .legal-table dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.small { font-size: .9rem; color: var(--muted); }

/* ---------- Contacto ---------- */
.contact-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
.reverse { unicode-bidi: bidi-override; direction: rtl; }
.form-field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .3rem; }
input, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: .7rem .85rem;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus-visible, textarea:focus-visible { border-color: var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 7.5rem; }
.form-title { font-size: 1.3rem; }

.field-error { color: var(--danger); font-size: .875rem; margin: .3rem 0 0; }
.field-error:empty { display: none; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.form-status { margin: 1rem 0 0; font-weight: 500; }
.form-status:empty { display: none; }
.form-status.error { color: var(--danger); }
.form-status.success { color: var(--accent); }
.btn[disabled] { opacity: .65; cursor: wait; }
.btn[hidden] { display: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Banda de cookies ---------- */
.cookie-band {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--band-bg); color: var(--text);
  border-top: 3px solid var(--band-line);
  padding: 1rem 0 1.1rem; text-align: center;
  box-shadow: 0 -6px 24px rgba(20, 40, 58, .18);
}
.cookie-band[hidden] { display: none; }
.cookie-band p { margin: 0 0 .85rem; }
.cookie-band a { color: var(--accent); font-weight: 600; }
.cookie-actions { display: flex; justify-content: center; gap: .75rem; flex-wrap: wrap; }
.btn-cookie {
  font: 600 1rem/1.2 inherit; font-family: inherit; color: #fff; cursor: pointer;
  border: 0; border-radius: 10px; padding: .65rem 1.6rem; min-width: 8rem;
}
.btn-cookie.accept { background: #1b7f3b; }
.btn-cookie.reject { background: #c62828; }
.btn-cookie:hover { filter: brightness(1.1); }
.cookie-legal h3 { margin-top: 1.5rem; }
.cookie-legal table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.cookie-legal th, .cookie-legal td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.cookie-legal thead th { background: var(--accent-soft); }
.cookie-legal ul { padding-left: 1.2rem; }

/* ---------- Calendario ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cal-nav .cal-title { font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: 1.25rem; text-transform: capitalize; margin: 0; flex: 1; text-align: center; }
.cal-nav .btn { width: auto; }
.btn[disabled].cal-btn { opacity: .4; cursor: not-allowed; }
.cal-frame { width: 100%; height: 620px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }

/* ---------- Pie ---------- */
.site-footer { background: var(--head); border-top: 1px solid var(--head-line); padding: 1.5rem 0 2rem; color: var(--muted); font-size: .9rem; text-align: center; }
.site-footer .copy { margin: 0 0 .75rem; }
.social-icons { display: flex; justify-content: center; flex-wrap: wrap; align-items: center; gap: .5rem; }
.social-icons a { color: var(--text); display: inline-flex; padding: .5rem; border-radius: 10px; transition: color .2s ease, transform .2s ease; }
.social-icons a:hover { color: var(--accent); transform: translateY(-2px); }
.social-icons svg { width: 24px; height: 24px; }

/* ---------- Tablet y escritorio ---------- */
@media (min-width: 40rem) {
  .link-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 2rem; }
  .timeline li { display: grid; grid-template-columns: 11.5rem 1fr; gap: 1.25rem; padding-left: 2rem; }
  .timeline .date { margin: .25rem 0 0; }
}
@media (min-width: 52rem) {
  .profile-intro { grid-template-columns: 15rem 1fr; gap: 2rem; }
  .contact-grid { grid-template-columns: 1fr 1.3fr; gap: 2rem; }
  .link-grid.three { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 40rem) {
  [role="tab"] { padding: .45rem .8rem; font-size: .88rem; }
}
@media (max-width: 30rem) {
  .data-list div { grid-template-columns: 1fr; gap: 0; }
  .theme-toggle .label { display: none; }
  .lang-btn .code { display: inline; }
  .theme-toggle { padding: .6rem; }
  .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .tabs-bar, .theme-toggle, .site-footer, form, .cookie-band { display: none !important; }
  [role="tabpanel"] { display: block !important; break-inside: avoid; }
  body { background: #fff; color: #000; }
}

/* ---------- Selector de idioma (banderas) ---------- */
.lang { position: relative; }
.lang-btn img, .lang-list img { width: 22px; height: 15px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); flex: none; }
.lang-btn .code { font-weight: 600; letter-spacing: .03em; }
.lang-btn .chev { width: 12px; height: 12px; transition: transform .2s; }
.lang-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.lang-list {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 30;
  list-style: none; margin: 0; padding: .35rem; min-width: 10.5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.lang-list[hidden] { display: none; }
.lang-list a {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem;
  border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500;
}
.lang-list a:hover, .lang-list a:focus-visible { background: var(--accent-soft); }
@media print { .lang { display: none; } }


/* ---------- Foto de perfil: giro de bienvenida (solo la primera vez que se visita la web) ---------- */
.portrait.spin-once { animation: portraitSpin 1.4s cubic-bezier(.2, .8, .2, 1) both; will-change: transform, opacity; }
@keyframes portraitSpin {
  0%   { transform: rotate(-360deg) scale(.35); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: rotate(0) scale(1); opacity: 1; }
}

/* ---------- Calendario: impresora junto al enlace de Google Calendar ---------- */
.cal-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-top: .75rem; }
.cal-foot .small { margin: 0; }
.cal-print { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--accent); cursor: pointer; }
.cal-print:hover { border-color: var(--accent); background: var(--accent-soft); }
.cal-print svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media print { .cal-print { display: none !important; } }
