/* ==========================================================================
   BLOSSOM.CSS — hoja canónica de los blossoms de Waggle
   --------------------------------------------------------------------------
   Se enlaza DESPUÉS de public-home.css y public-pages.css y ANTES de
   public-typography.css y del app.css del blossom. Requiere los tokens
   públicos (--bee-*, --shadow-*, --public-font-*).

   PROHIBIDO editar este fichero desde un blossom concreto. Cambios: PR a
   evolution/blossoms/ con actualización de las directrices.
   ========================================================================== */

/* ---------- 1. Tokens blossom (derivados; ver directrices/02-tokens.md) --- */
:root {
  /* Radios */
  --bl-radius-xs: 8px;
  --bl-radius-sm: 10px;
  --bl-radius-md: 14px;
  --bl-radius-lg: 18px;
  --bl-radius-xl: 24px;
  --bl-radius-2xl: 26px;
  --bl-radius-pill: 999px;

  /* Bordes y superficies auxiliares */
  --bl-border-panel: 1px solid rgba(30, 40, 165, .12);
  --bl-border-button: 1px solid rgba(30, 40, 165, .16);
  --bl-row-line: rgba(30, 40, 165, .09);
  --bl-surface-hover: #fafaff;
  --bl-surface-soft: #f4f5ff;
  --bl-surface-thead: #f2f3ff;
  --bl-surface-input: #fdfdff;

  /* Sombras compuestas */
  --bl-shadow-panel: 0 18px 48px rgba(30, 40, 165, .09);
  --bl-shadow-toolbar: 0 18px 46px rgba(30, 40, 165, .11);
  --bl-shadow-modal: 0 32px 90px rgba(14, 20, 87, .3);
  --bl-shadow-primary-btn: 0 8px 20px rgba(250, 215, 65, .24);

  /* Focus universal */
  --bl-focus-border: rgba(30, 40, 165, .56);
  --bl-focus-ring: 0 0 0 4px rgba(30, 40, 165, .09);

  /* Series de datos (paleta categórica VALIDADA — orden fijo) */
  --bl-series-1: #3a47d4;
  --bl-series-2: #f55a78;
  --bl-series-3: #a87e00;
  --bl-series-4: #0e7fa5;
  --bl-series-5: #7a3ec2;
  --bl-series-6: #1d8a63;

  /* Semánticos de estado (reservados) */
  --bl-ok: #0b8442;      --bl-ok-bg: #dff7e8;
  --bl-info: #2055b5;    --bl-info-bg: #e6efff;
  --bl-warn: #b45309;    --bl-warn-bg: #fdf3e0;
  --bl-danger: #b42318;  --bl-danger-bg: #fdecea;

  /* Gráficos */
  --bl-grid-line: rgba(30, 40, 165, .09);
  --bl-axis-line: rgba(30, 40, 165, .12);
  --bl-axis-text: var(--bee-muted);

  /* Z-index */
  --bl-z-sticky: 30;
  --bl-z-backdrop: 1000;
  --bl-z-modal: 1010;
  --bl-z-toast: 1100;
}

/* ---------- 2. Página y contenedor ---------------------------------------- */
.blossom-page { background: var(--bee-off); color: var(--bee-blue-dark); }
.bl-container { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }

/* ---------- 3. Masthead ---------------------------------------------------- */
.bl-masthead {
  position: relative;
  overflow: hidden;
  padding: 54px 0 36px;
  background:
    radial-gradient(720px 380px at 12% 0%, rgba(250, 215, 65, .18), transparent 60%),
    linear-gradient(135deg, var(--bee-blue) 0%, var(--bee-blue-deep) 70%);
  color: #fff;
}
.bl-breadcrumb {
  display: inline-flex; align-items: center; gap: 6px;
  color: rgba(255, 255, 255, .82); font-weight: 800; font-size: 14px;
}
.bl-breadcrumb:hover { color: var(--bee-yellow); }
.bl-masthead .bl-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 18px 0 0; padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--bl-radius-pill);
  background: rgba(255, 255, 255, .1);
  color: var(--bee-yellow);
  font-family: var(--public-font-action);
  font-size: 12px; font-weight: 850;
  letter-spacing: .14em; text-transform: uppercase;
  backdrop-filter: blur(14px);
}
.bl-title {
  margin: 16px 0 12px; max-width: 920px;
  font-family: var(--public-font-display);
  font-size: clamp(30px, 4.4vw, 54px);
  line-height: 1.05; font-weight: 900; color: #fff;
  text-wrap: balance;
}
.bl-authors { max-width: 880px; color: rgba(255, 255, 255, .9); font-weight: 700; line-height: 1.6; }
.bl-authors a { color: var(--bee-yellow); font-weight: 800; }
.bl-authors a:hover { text-decoration: underline; }
.bl-pubmeta {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; color: rgba(255, 255, 255, .86); font-weight: 700;
}
.bl-pubmeta .material-symbols-outlined { color: var(--bee-yellow); }
.bl-version {
  margin-left: 10px; padding: 3px 10px;
  border-radius: var(--bl-radius-pill);
  background: rgba(255, 255, 255, .16);
  font-size: 12px; font-weight: 900;
}
.bl-masthead-meta {
  display: grid; grid-template-columns: repeat(4, minmax(130px, 180px));
  gap: 12px; max-width: 760px; margin-top: 34px;
}
.bl-masthead-meta > div {
  min-height: 94px; padding: 15px 17px;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--bl-radius-lg);
  background: rgba(255, 255, 255, .1);
  backdrop-filter: blur(14px);
}
.bl-masthead-meta strong {
  display: block; margin: 0 0 6px;
  color: var(--bee-yellow);
  font-family: var(--public-font-display);
  font-size: 29px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.bl-masthead-meta span { color: rgba(255, 255, 255, .86); font-size: 12px; font-weight: 700; }

/* ---------- 4. Paneles, cards y bloques de texto --------------------------- */
.bl-panel {
  border: var(--bl-border-panel);
  border-radius: var(--bl-radius-2xl);
  background: #fff;
  box-shadow: var(--bl-shadow-panel);
  padding: 24px;
}
.bl-card {
  border: var(--bl-border-panel);
  border-radius: var(--bl-radius-lg);
  background: #fff;
  box-shadow: var(--shadow-2);
  padding: 18px;
}
a.bl-card { transition: transform .2s var(--motion-ease), box-shadow .2s var(--motion-ease); }
a.bl-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-3); }

.bl-note {
  padding: 16px 20px;
  border-left: 3px solid var(--bee-blue);
  border-radius: var(--bl-radius-md);
  background: #f8f8ff;
  color: var(--bee-blue-dark);
  font-size: 14px; line-height: 1.6;
}
.bl-callout {
  padding: 22px 24px;
  border-radius: var(--bl-radius-lg);
  background: var(--bee-pink);
  font-size: 19px; font-weight: 600; line-height: 1.5;
}
.bl-kicker {
  display: block; margin-bottom: 10px;
  color: var(--bee-blue);
  font-family: var(--public-font-action);
  font-size: 12px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
}

/* ---------- 5. Arquetipo A: lectura con sidebar ---------------------------- */
.bl-reading {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 32px; align-items: start;
  padding-block: 36px 64px;
}
.bl-sidebar { position: sticky; top: 96px; display: grid; gap: 16px; }
.bl-toc { padding: 16px; }
.bl-toc a {
  display: block; padding: 8px 10px;
  border-radius: var(--bl-radius-sm);
  color: var(--bee-muted); font-size: 14px; font-weight: 600;
  transition: background .18s ease, color .18s ease;
}
.bl-toc a:hover { background: var(--bl-surface-hover); }
.bl-toc a.active { background: var(--bl-surface-soft); color: var(--bee-blue); font-weight: 700; }
.bl-prose { min-width: 0; }
.bl-prose > section { margin-bottom: 48px; }
.bl-prose p { max-width: 72ch; line-height: var(--public-line-body, 1.625); }
.bl-prose h2 { max-width: 30ch; text-wrap: balance; }

/* ---------- 6. Arquetipo B: presentación (deck) ---------------------------- */
.bl-deck { padding-block: 28px 64px; }
.bl-deck-progress {
  height: 4px; border-radius: var(--bl-radius-pill);
  background: var(--bee-line); overflow: hidden; margin-bottom: 16px;
}
.bl-deck-progress > i {
  display: block; height: 100%;
  background: var(--bee-yellow);
  transition: width .22s var(--motion-ease);
}
.bl-slide {
  min-height: min(72vh, 720px);
  padding: clamp(24px, 4vw, 56px);
  display: grid; align-content: center; gap: 18px;
}
.bl-slide.is-entering { animation: bl-slide-in .22s var(--motion-ease); }
@keyframes bl-slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.bl-slide-cover {
  background:
    radial-gradient(680px 360px at 86% 18%, rgba(245, 90, 120, .35), transparent 62%),
    linear-gradient(135deg, #1e28a5 0%, #18218c 55%, #0e1457 100%);
  color: #fff; border: 0;
}
.bl-slide-cover h2, .bl-slide-cover h3 { color: #fff; }
.bl-deck-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px;
}
.bl-deck-dots { display: flex; gap: 8px; }
.bl-deck-dots button {
  width: 10px; height: 10px; padding: 0;
  border: 0; border-radius: 50%;
  background: var(--bee-line); cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.bl-deck-dots button.active { background: var(--bee-blue); transform: scale(1.2); }
.bl-2up { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }

/* ---------- 7. Arquetipo C: dashboard -------------------------------------- */
.bl-toolbar {
  position: sticky; top: 84px; z-index: var(--bl-z-sticky);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  margin-bottom: 18px; padding: 14px;
  border: var(--bl-border-panel);
  border-radius: var(--bl-radius-xl);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--bl-shadow-toolbar);
  backdrop-filter: blur(18px);
}
.bl-toolbar .bl-field { display: grid; gap: 6px; min-width: 160px; flex: 1; }
.bl-toolbar label {
  color: var(--bee-blue-dark);
  font-family: var(--public-font-action);
  font-size: 12px; font-weight: 800;
}
.bl-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.bl-span-3 { grid-column: span 3; }
.bl-span-4 { grid-column: span 4; }
.bl-span-6 { grid-column: span 6; }
.bl-span-8 { grid-column: span 8; }
.bl-span-12 { grid-column: span 12; }

.bl-kpi { display: grid; gap: 8px; align-content: start; }
.bl-kpi .bl-kpi-label {
  color: var(--bee-muted);
  font-family: var(--public-font-action);
  font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
}
.bl-kpi .bl-kpi-value {
  color: var(--bee-blue-dark);
  font-family: var(--public-font-display);
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.bl-kpi .bl-kpi-delta {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: var(--bl-radius-pill);
  font-size: 12px; font-weight: 800;
}
.bl-kpi .bl-kpi-delta.up { background: var(--bl-ok-bg); color: var(--bl-ok); }
.bl-kpi .bl-kpi-delta.down { background: var(--bl-danger-bg); color: var(--bl-danger); }
.bl-kpi .bl-kpi-delta.flat { background: var(--bl-surface-soft); color: var(--bee-muted); }

/* ---------- 8. Figura (envoltorio universal de gráficos) ------------------- */
.bl-figure { display: grid; gap: 10px; }
.bl-figure > h3 {
  margin: 0;
  font-family: var(--public-font-display);
  font-size: 20px; font-weight: 800; line-height: 1.2;
  color: var(--bee-blue-dark);
  text-wrap: balance;
}
.bl-figure .bl-howto { margin: 0; color: var(--bee-muted); font-size: 14px; line-height: 1.5; }
.bl-figure .bl-plot { min-height: 320px; }
.bl-figure .bl-plot svg { display: block; width: 100%; height: auto; }
.bl-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.bl-legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--bee-blue-dark); }
.bl-legend i {
  width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto;
}
.bl-figure .bl-source {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--bee-muted); font-size: 12px;
}
.bl-figure .bl-source a { color: var(--bee-blue); font-weight: 700; }

/* Tooltip de gráfico */
.bl-tooltip {
  position: fixed; z-index: var(--bl-z-toast);
  pointer-events: none;
  min-width: 140px; max-width: 280px;
  padding: 10px 12px;
  border: var(--bl-border-panel);
  border-radius: var(--bl-radius-md);
  background: #fff;
  box-shadow: var(--shadow-3);
  font-size: 12px;
}
.bl-tooltip .bl-tooltip-title { font-weight: 800; margin-bottom: 6px; color: var(--bee-blue-dark); }
.bl-tooltip .bl-tooltip-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--bee-blue-dark);
}
.bl-tooltip .bl-tooltip-row b {
  font-family: var(--public-font-data);
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.bl-tooltip .bl-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* ---------- 9. Tabla de datos ---------------------------------------------- */
.bl-table-wrap { overflow: auto; border-radius: var(--bl-radius-2xl); }
.bl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bl-table thead th {
  position: sticky; top: 0; z-index: 2;
  padding: 15px 16px;
  border-bottom: 1px solid rgba(30, 40, 165, .12);
  background: var(--bl-surface-thead);
  color: var(--bee-blue);
  font-size: 10px; font-weight: 850;
  letter-spacing: .07em; text-transform: uppercase;
  text-align: left;
}
.bl-table tbody td {
  height: 64px; padding: 13px 16px;
  border-bottom: 1px solid var(--bl-row-line);
  color: #33385f;
}
.bl-table tbody tr { transition: background .18s ease; }
.bl-table tbody tr:hover { background: var(--bl-surface-hover); }
.bl-table tbody tr:last-child td { border-bottom: 0; }
.bl-table .num, .bl-table .mono {
  font-family: var(--public-font-data);
  font-size: 12px; font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- 10. Controles propios ------------------------------------------ */
.bl-segmented {
  display: inline-flex; padding: 3px;
  border: 1px solid var(--bee-line);
  border-radius: var(--bl-radius-pill);
  background: #fff;
}
.bl-segmented button {
  min-height: 34px; padding: 0 14px;
  border: 0; border-radius: var(--bl-radius-pill);
  background: transparent; color: var(--bee-muted);
  font-family: var(--public-font-action);
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.bl-segmented button.active { background: var(--bee-blue); color: #fff; }

.bl-input, .bl-select {
  min-height: 46px; padding: 0 13px;
  border: 1px solid var(--bee-line);
  border-radius: var(--bl-radius-md);
  background: var(--bl-surface-input);
  color: var(--bee-blue-dark);
  font-family: var(--public-font-body);
  font-size: 13px; font-weight: 650;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.bl-input:focus, .bl-select:focus,
.bl-segmented button:focus-visible, .bl-toc a:focus-visible {
  outline: none;
  border-color: var(--bl-focus-border);
  box-shadow: var(--bl-focus-ring);
}

/* ---------- 11. Estados ----------------------------------------------------- */
.bl-loading {
  display: grid; place-items: center; gap: 14px;
  min-height: 40vh; color: var(--bee-muted); font-weight: 700;
}
.bl-skeleton {
  border-radius: var(--bl-radius-md);
  background: var(--bl-surface-thead);
  animation: bl-pulse 1.2s ease-in-out infinite;
}
@keyframes bl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.bl-empty {
  display: grid; place-items: center; gap: 10px;
  padding: 72px 24px; text-align: center; color: var(--bee-muted);
}
.bl-empty .material-symbols-outlined { width: 2.4rem; height: 2.4rem; opacity: .6; }

/* ---------- 12. Pie científico ---------------------------------------------- */
.bl-scifooter { display: grid; gap: 16px; padding-block: 24px 64px; }
.bl-references { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.7; }
.bl-references a { color: var(--bee-blue); font-weight: 700; }
.bl-citation {
  font-size: 14px; line-height: 1.6; color: var(--bee-blue-dark);
  padding: 14px 16px; border-radius: var(--bl-radius-md);
  background: var(--bl-surface-soft);
}

/* CTA canónica hacia la aplicación compañera. Las primeras historias
   definían esta estructura localmente; mantenerla aquí evita que una nueva
   portada degrade a un enlace en línea si solo cambia su paleta. */
.bl-app-cta {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(100%, 650px);
  margin-top: 24px;
  padding: 13px 15px;
  border: 1px solid currentColor;
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
}
.bl-app-cta > span:first-child {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
}
.bl-app-cta > span:nth-child(2) { min-width: 0; }
.bl-app-cta strong, .bl-app-cta small { display: block; }
.bl-app-cta strong { font-size: .88rem; line-height: 1.25; }
.bl-app-cta small { margin-top: 3px; font-size: .68rem; line-height: 1.35; opacity: .8; }
.bl-app-cta > .material-symbols-outlined:last-child { transition: transform 150ms ease; }
.bl-app-cta:hover > .material-symbols-outlined:last-child { transform: translateX(4px); }

/* ---------- 13. Responsive -------------------------------------------------- */
@media (max-width: 1120px) {
  .bl-reading { grid-template-columns: 240px minmax(0, 1fr); }
  .bl-span-3 { grid-column: span 6; }
  .bl-span-4 { grid-column: span 6; }
}
@media (max-width: 820px) {
  .bl-reading { grid-template-columns: minmax(0, 1fr); }
  .bl-sidebar { position: static; }
  .bl-toolbar { position: static; }
  .bl-grid > [class*="bl-span-"] { grid-column: span 12; }
  .bl-masthead-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bl-2up { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .bl-container { width: calc(100% - 28px); }
  .bl-masthead-meta strong { font-size: 24px; }
  .bl-panel { padding: 18px; border-radius: 20px; }
}

/* ---------- 14. Reduced motion y print -------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .bl-slide.is-entering { animation: none; }
  .bl-skeleton { animation: none; }
  .bl-deck-progress > i { transition: none; }
  a.bl-card, .bl-toc a, .bl-segmented button { transition: none; }
}
@media print {
  .bl-toolbar, .bl-deck-nav, .bl-deck-dots, [data-public-header], [data-public-footer] { display: none !important; }
  .bl-panel, .bl-card { box-shadow: none; }
  .bl-slide { min-height: auto; page-break-inside: avoid; }
}
