/* ==========================================================================
   /cv/assets/cv.css — Página pública del CV (autocontenida, sin CDNs)
   Colores dinámicos: --accent y --sidebar los inyecta cv.js desde cv-data.json
   ========================================================================== */

:root {
  --accent: #0f766e;
  --sidebar: #1f2937;
  /* Derivados (fallback si el navegador no soporta color-mix) */
  --accent-light: #6fc7bd;
  --accent-soft: rgba(15, 118, 110, 0.09);
  --accent-deep: var(--accent);
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-muted: #64748b;
  --line: #e2e8f0;
  --page-bg: #eef1f5;
  --sheet-bg: #ffffff;
  --side-text: rgba(255, 255, 255, 0.88);
  --side-soft: rgba(255, 255, 255, 0.72);
}

@supports (color: color-mix(in srgb, red 50%, white)) {
  :root {
    --accent-light: color-mix(in srgb, var(--accent) 45%, #ffffff);
    --accent-soft: color-mix(in srgb, var(--accent) 9%, #ffffff);
    --accent-deep: color-mix(in srgb, var(--accent) 82%, #000000);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Barra superior (no imprimible)
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.topbar-back {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.topbar-back:hover { color: var(--accent); }

.topbar-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-icon { width: 14px; height: 14px; flex: none; }

.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent-deep); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent-light); }

/* --------------------------------------------------------------------------
   Banner de vista previa del borrador
   -------------------------------------------------------------------------- */

.preview-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 14px;
  padding: 9px 16px;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}
.preview-banner a { color: inherit; font-weight: 700; }
.preview-banner[hidden] { display: none; }

/* --------------------------------------------------------------------------
   Hoja del CV — dos columnas
   -------------------------------------------------------------------------- */

.cv-page { padding: 28px 16px 56px; }

.cv-loading {
  text-align: center;
  color: var(--ink-muted);
  padding: 64px 0;
}

.cv-noscript {
  max-width: 480px;
  margin: 40px auto;
  text-align: center;
  color: var(--ink-soft);
}

.cv-sheet {
  max-width: 920px;
  margin: 0 auto;
  background: var(--sheet-bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 14px 36px rgba(15, 23, 42, 0.13);
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

/* --------------------------------------------------------------------------
   Sidebar oscuro
   -------------------------------------------------------------------------- */

.cv-side {
  background: var(--sidebar);
  color: var(--side-text);
  padding: 38px 28px 42px;
  min-width: 0;
}

.cv-photo-wrap { display: flex; justify-content: center; }

.cv-photo {
  width: 134px;
  height: 134px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-light);
  box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.08);
}

.cv-photo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #ffffff;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.cv-name {
  margin: 22px 0 6px;
  font-size: 25px;
  line-height: 1.22;
  font-weight: 700;
  color: #ffffff;
  text-align: center;
  text-wrap: balance;
}

.cv-role {
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-light);
}

/* Contacto */

.contact-list {
  list-style: none;
  margin: 26px 0 0;
  padding: 20px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  gap: 11px;
}

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: 13px;
  min-width: 0;
}
.contact-item .icon { flex: none; margin-top: 2px; color: var(--accent-light); }
.contact-item a,
.contact-item > span { color: var(--side-text); overflow-wrap: anywhere; min-width: 0; }
.contact-item a { text-decoration: none; }
.contact-item a:hover { color: #ffffff; text-decoration: underline; }

.icon svg { width: 15px; height: 15px; display: block; }

/* Secciones del sidebar */

.cv-side .cv-section { margin-top: 30px; }

.side-title {
  margin: 0 0 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-light);
}
.side-title::after {
  content: "";
  display: block;
  width: 26px;
  height: 2px;
  margin-top: 7px;
  border-radius: 1px;
  background: var(--accent-light);
}

.cv-summary {
  margin: 0;
  font-size: 13px;
  line-height: 1.68;
  color: var(--side-soft);
}

/* Enlaces sociales */

.social-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.social-item { display: flex; align-items: center; gap: 11px; font-size: 13px; min-width: 0; }
.social-item .icon { flex: none; color: var(--accent-light); }
.social-item a { color: var(--side-text); text-decoration: none; overflow-wrap: anywhere; min-width: 0; }
.social-item a:hover { color: #ffffff; text-decoration: underline; }

/* --------------------------------------------------------------------------
   Columna principal
   -------------------------------------------------------------------------- */

.cv-main { padding: 42px 42px 48px; min-width: 0; }

.cv-main .cv-section + .cv-section { margin-top: 34px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}
.section-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}

/* Timeline (experiencia / formación) */

.tl-item { position: relative; padding: 0 0 20px 27px; }
.tl-item:last-child { padding-bottom: 2px; }

.tl-item::before { /* punto */
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sheet-bg);
  border: 3px solid var(--accent);
}
.tl-item:not(:last-child)::after { /* línea vertical */
  content: "";
  position: absolute;
  left: 5px;
  top: 19px;
  bottom: -3px;
  width: 2px;
  background: var(--line);
}

.tl-period {
  display: inline-block;
  margin: 0 0 7px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.tl-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}
.tl-subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
}
.tl-desc {
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* Timeline dentro del sidebar (por si una sección timeline va en "side") */

.cv-side .tl-item::before { background: var(--sidebar); border-color: var(--accent-light); }
.cv-side .tl-item:not(:last-child)::after { background: rgba(255, 255, 255, 0.16); }
.cv-side .tl-period { color: var(--accent-light); background: rgba(255, 255, 255, 0.08); }
.cv-side .tl-title { color: #ffffff; }
.cv-side .tl-subtitle { color: var(--side-soft); }
.cv-side .tl-desc { color: var(--side-soft); }

/* Listas con viñetas */

.cv-list { list-style: none; margin: 0; padding: 0; }
.cv-list li {
  position: relative;
  padding: 0 0 9px 18px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  break-inside: avoid;
}
.cv-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.85;
}
.cv-side .cv-list li { color: var(--side-text); }
.cv-side .cv-list li::before { background: var(--accent-light); }

@media (min-width: 760px) {
  .cv-main .cv-list { columns: 2; column-gap: 34px; }
}

/* Chips (tags) */

.cv-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cv-main .cv-tags li {
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid var(--accent-light);
}
.cv-side .cv-tags li {
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--side-text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Texto libre */

.cv-text p {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.68;
  color: var(--ink-soft);
}
.cv-text p:last-child { margin-bottom: 0; }
.cv-side .cv-text p { color: var(--side-soft); font-size: 13px; }

/* Error de carga */

.cv-error {
  max-width: 460px;
  margin: 56px auto;
  padding: 34px 30px;
  text-align: center;
  background: var(--sheet-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}
.cv-error h2 { margin: 0 0 8px; font-size: 18px; color: var(--ink); }
.cv-error p { margin: 0 0 20px; font-size: 14px; color: var(--ink-muted); }

/* --------------------------------------------------------------------------
   Móvil: sidebar arriba, una sola columna
   -------------------------------------------------------------------------- */

@media (max-width: 759px) {
  .cv-page { padding: 0; }
  .cv-sheet {
    grid-template-columns: 1fr;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
  }
  .cv-side { padding: 32px 24px 34px; }
  .cv-main { padding: 30px 22px 44px; }
  .topbar { padding: 8px 12px; }
  .btn { padding: 8px 12px; }
}

/* --------------------------------------------------------------------------
   Impresión / exportar a PDF (A4)
   -------------------------------------------------------------------------- */

@media print {
  @page { size: A4; margin: 0; }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html, body { background: #ffffff; }
  body { font-size: 12.5px; }

  .topbar,
  .preview-banner { display: none !important; }

  .cv-page { padding: 0; }

  .cv-sheet {
    max-width: none;
    width: 210mm;
    min-height: calc(297mm - 1px); /* evita una segunda página en blanco por redondeo */
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    grid-template-columns: 68mm minmax(0, 1fr);
  }

  .cv-side { padding: 12mm 7mm 12mm 8mm; }
  .cv-main { padding: 12mm 9mm 12mm 8mm; }

  .cv-photo { width: 32mm; height: 32mm; box-shadow: none; }
  .cv-name { font-size: 21px; }
  .cv-summary { font-size: 11.5px; }
  .contact-item, .social-item { font-size: 11.5px; }

  .cv-main .cv-section + .cv-section { margin-top: 7mm; }
  .tl-item { padding-bottom: 4.5mm; break-inside: avoid; }
  .tl-title { font-size: 13.5px; }
  .tl-subtitle, .tl-desc { font-size: 12px; }
  .cv-list li { font-size: 12px; padding-bottom: 2.2mm; break-inside: avoid; }
  .section-title { break-after: avoid; }

  a { color: inherit; text-decoration: none; }
}
