
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
}

/* Base responsive: evita desbordamientos horizontales en móvil */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
}

img,
canvas,
svg,
video {
  max-width: 100%;
}

.logo {
  max-width: min(320px, 88vw);
  height: auto;
}

.contacto p {
  margin: 0;
  padding: 4px 10px;
  overflow-wrap: anywhere;
  line-height: 1.35;
}


header {
  text-align: center;
  background-color: #f0f0f0;
}

.full-width-banner {
  width: 100%;
}

.contacto {
  background-color: #4CAF50;
  color: white;
  padding: 5px 0;
}

.logo {
  margin: 10px 0;
}

main {
  padding: 20px;
}

/* Mejora del espaciado entre radio y texto */
.question-block label {
  display: inline-flex;
  align-items: center;
  gap: 12px;              /* ← ajusta aquí si quieres más/menos espacio */
  margin: 4px 0;
  padding-left: 24px;   /* controla aquí el sangrado */
}

.question-block input[type="radio"] {
  margin: 0;             /* evita márgenes inconsistentes entre navegadores */
}


button {
  background-color: #90ee90;
  color: rgb(7, 0, 0);
  font-size: 1.1em;
  font-weight: bold;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #76c776;
}

/* Bloque introductorio y ayuda */
.intro {
  margin: 16px 0 24px 0;
}

.intro-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.intro-brief {
  margin: 0;
  padding: 12px 14px;
  background: #f6f8f6;
  border-left: 5px solid #4CAF50;
  border-radius: 6px;
  line-height: 1.4;
  flex: 1 1 520px;
}

.info-toggle {
  background: #e9f6ea;
  border: 1px solid #bfe0c1;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}

.info-toggle:hover {
  background: #dff1e0;
}

.info-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #d8e6d8;
  border-radius: 8px;
  background: #ffffff;
  line-height: 1.45;
}

.info-panel p {
  margin: 8px 0;
}

/* Resultado */
.resultado {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid #d8e6d8;
  border-left: 6px solid #4CAF50;
  border-radius: 10px;
  background: #f6f8f6;
}

.resultado-title {
  font-weight: 800;
  font-size: 1.35em;
  margin-bottom: 10px;
}

/* Header row in results: title + equivalences button */
.resultado-header-row{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;

  max-width: 720px;
  width: 100%;

  flex-wrap: nowrap;     /* ✅ clave: el botón no baja de línea */
}

/* El título puede ocupar el espacio disponible y partirse en 2 líneas si hace falta */
.resultado-header-row .resultado-title{
  flex: 1 1 auto;
  min-width: 0;
}

/* El botón mantiene su tamaño y se queda a la derecha */
.btn-equivalences{
  flex: 0 0 auto;
  white-space: nowrap;
}


.btn-equivalences{
  /* Uses global button styles; keep it visually consistent */
  white-space: nowrap;
}

.resultado-subtitle {
  font-weight: 600;
  font-size: 0.85em;
  opacity: 0.85;
}

.resultado-main {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
}

.resultado-number {
  font-size: 2.1em;
  font-weight: 800;
}

.resultado-unit {
  font-size: 0.95em;      /* más pequeño que el número */
  font-weight: 600;       /* menos pesado */
  opacity: 0.85;          /* más elegante */
  white-space: nowrap;
}


.resultado-sub {
  margin-top: 10px;
  font-size: 1.25em;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: baseline;
}

.resultado-sub-label {
  font-weight: 800;
}

.resultado-sub-value {
  font-weight: 800;
  font-size: 1.05em;
  font-variant-numeric: tabular-nums;
}


.resultado-note {
  margin-top: 6px;
  font-size: 0.95em;
  opacity: 0.85;
}

#resultado {
  scroll-margin-top: 22px;
}

/* Desglose por categorías */
.resultado-breakdown {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #d8e6d8;
}

.resultado-breakdown-title {
  font-weight: 800;
  margin-bottom: 8px;
}

.resultado-breakdown-list {
  display: grid;
  gap: 8px;
  justify-items: stretch;
  width: 100%;
  min-width: 0;
}

/* 3 columnas en escritorio, sin anchos fijos que rompan en móvil */
.breakdown-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, auto) minmax(180px, 260px);
  gap: 16px;
  padding: 8px 12px;
  border: 1px solid #e3eee3;
  border-radius: 8px;
  background: #ffffff;
  width: 100%;
  max-width: 100%;
  align-items: center;
  min-width: 0;
}

.breakdown-label {
  font-weight: 700;
}

.breakdown-value {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  justify-self: start; /* ancla la “columna roja” */
}

/* --- Recomendaciones desplegables --- */
.breakdown-row2 {
  width: 100%;
  max-width: 100%;
  padding: 0 12px;
  margin: -2px 0 12px 0;
  min-width: 0;
}

.reco-toggle {
  background: #eef7ef;
  border: 1px solid #cfe6d0;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95em;
  cursor: pointer;
  justify-self: start; /* ancla la “columna azul” */
}

.reco-toggle:hover {
  background: #e2f3e3;
}

.reco-toggle.inline {
  text-align: left;
  white-space: normal;
  max-width: 100%;
}

/* Panel con formato tipo Word */
.reco-panel {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid #d8e6d8;
  border-radius: 10px;
  background: #ffffff;
  line-height: 1.5;
}

.reco-title {
  font-weight: 800;
  font-size: 1.05em;
  margin-bottom: 10px;
}

/* Separadores entre bloques */
.reco-block {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid #e6efe6;
}

.reco-block:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.reco-block-title {
  font-weight: 800;
  margin-bottom: 8px;
}

.reco-list {
  margin: 0 0 0 18px;
  padding: 0;
}

.reco-list li {
  margin: 6px 0;
}

.reco-close {
  margin-top: 14px;
  padding: 8px 14px;
  background: #f3f3f3;
  border: 1px solid #d0d0d0;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.reco-close:hover {
  background: #e6e6e6;
}

/* Responsive */
@media (max-width: 640px) {
  .breakdown-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .breakdown-value {
    white-space: normal;
  }
}

/* ====== Layout gráfico + lista de categorías ====== */
.results-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 24px;
  align-items: start;
  width: 100%;
  max-width: 100%;
}

.results-groups {
  min-width: 0;
}

.results-chart {
  position: sticky;
  top: 110px; /* ajusta si tu cabecera es más alta/baja */
  background: #f6f8f5;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 14px 14px 10px 14px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.results-chart-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.results-chart-caption {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 6px;
}

/* El canvas necesita altura para que Chart.js sea estable */
#graficoCategorias {
  width: 100% !important;
  height: 360px !important;
  display: block;
  max-width: 100%;
}

@media (max-width: 900px) {
  .results-layout {
    grid-template-columns: 1fr;
  }
  .results-chart {
    position: static;
    top: auto;
  }
  #graficoCategorias {
    height: 260px !important;
  }
}

.info-buttons {
  display: flex;
  flex-wrap: wrap;       /* por si en pantallas pequeñas no caben */
  gap: 10px;             /* separación horizontal entre botones */
  margin: 12px 0;
}

.credits-list {
  margin-left: 1.2em;
  padding-left: 0.6em;
}

.credits-list li {
  margin-bottom: 6px;
  line-height: 1.4;
}

.credits-list a {
  word-break: break-word;
}


/* Language selector */
.lang-switch{
  display: flex;
  justify-content: flex-start;
  /*justify-content: flex-end;   flags to the right */
  align-items: center;
  margin: 10px 0 14px 0;
}

.lang-switch-flags{
  display: flex;
  justify-content: flex-start;
  flex-direction: row;       /* flags in a row */
  gap: 10px;
}

.lang-flag{
  background: #ffffff;
  border: 1px solid #cfe6d0;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 36px;
  transition: background-color 0.2s ease, transform 0.05s ease;
}

.lang-flag:hover{ background: #eef7ef; }
.lang-flag:active{ transform: translateY(1px); }
.lang-flag.is-active{
  outline: 2px solid #4CAF50;
  background: #e9f6ea;
}

/* Flag sprite (uses background-image set per language) */
.flag{
  display: inline-block;
  width: 28px;
  height: 18px;
  background-size: cover;
  background-position: center;
  border-radius: 3px;
}


/* Visually hidden (keeps accessibility) */
.sr-only{
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Tooltip icon */
.tooltip-icon {
  margin-left: 6px;
  cursor: help;
  font-size: 0.9em;
  opacity: 0.7;
  position: relative;
}

/* Tooltip text */
.tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.85em;
  line-height: 1.3;
  white-space: normal;
  width: 260px;
  max-width: 80vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

/* Show tooltip on hover */
.tooltip-icon:hover::after {
  opacity: 1;
}


/* ===== Top 3 categories (in chart area) ===== */
.top3-box{
  margin: 10px 0 8px;
  padding: 10px 12px;
  border: 1px solid #dfe7df;
  border-radius: 12px;
  background: #ffffff;
}
.top3-title{
  font-weight: 700;
  margin-bottom: 6px;
}
.top3-list{
  margin: 0;
  padding-left: 18px;
}
.top3-list li{
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0;
}
.top3-item-name{
  font-weight: 600;
}
.top3-item-metrics{
  white-space: nowrap;
}
@media (max-width: 900px){
  .top3-list li{flex-direction: column; align-items: flex-start;}
  .top3-item-metrics{white-space: normal;}
}


/* --- Flag icons (SVG data URIs) --- */
.flag{
  display:inline-block;
  width: 28px;
  height: 18px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.12) inset;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Spain (simplified) */
.flag-es{
  background-image: url("images/flags/es.svg");
}

/* Italy */
.flag-it{
  background-image: url("images/flags/it.svg");
}

/* UK (very simplified: blue field + red cross) */
.flag-en{
  background-image: url("images/flags/gb.svg");
}


/* Downloads panel */
.downloads-list { margin: 0.6rem 0 0; padding-left: 1.1rem; }
.downloads-list li { margin: 0.35rem 0; }
.downloads-list a { text-decoration: underline; }

/* Report button */
.result-actions { margin: 14px 0 6px; }
.report-btn { margin-top: 6px; }

/* === Equivalencias === */

.equiv-block {
  margin-top: 30px;
}

.equiv-block h2 {
  font-weight: 800;
  margin-bottom: 16px;
}

.equiv-item {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid #e3eee3;
  border-radius: 10px;
  background: #ffffff;
  max-width: 720px;
}

.equiv-item img {
  width: 250px;          /* 👈 clave */
  height: 250px;
  object-fit: contain;
  flex-shrink: 0;
}

.equiv-text {
  line-height: 1.4;
  font-size: 1.15em;
}

.equiv-value {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.equiv-intro-strong {
  font-size: 1.3em;
  font-weight: 600;
  margin-bottom: 14px;
}

main p {
  font-size: 1.05em;
}

.equiv-note {
  margin: 18px 0 26px 0;
  padding: 14px 18px;
  background: #f6f8f6;
  border-left: 5px solid #4CAF50;
  border-radius: 8px;
}

.equiv-note p {
  margin: 6px 0;
  font-size: 1.15em;   /* 👈 más visible */
  line-height: 1.5;
}

/* Ajustes específicos para móviles */
@media (max-width: 700px) {
  main {
    padding: 12px;
  }

  h1 {
    font-size: 1.6rem;
    line-height: 1.2;
  }

  .intro-row,
  .info-buttons,
  .resultado-main,
  .resultado-sub {
    gap: 8px;
  }

  .intro-brief {
    flex-basis: 100%;
  }

  .question-block label {
    display: flex;
    align-items: flex-start;
    padding-left: 0;
    gap: 10px;
    line-height: 1.35;
  }

  button,
  .info-toggle,
  .btn-equivalences,
  .btn-report,
  .report-btn {
    white-space: normal;
    max-width: 100%;
  }

  .resultado {
    padding: 14px 12px;
    margin-top: 18px;
    overflow: visible;
  }

  .resultado-header-row {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .resultado-header-row .resultado-title {
    flex-basis: 100%;
  }

  .btn-equivalences {
    width: 100%;
    text-align: center;
  }

  .resultado-sub {
    font-size: 1.05em;
    align-items: flex-start;
  }

  .resultado-separator {
    display: none;
  }

  .resultado-breakdown-list {
    justify-items: stretch;
  }

  .breakdown-item {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
  }

  .breakdown-label,
  .breakdown-value,
  .reco-toggle {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .breakdown-value {
    white-space: normal;
  }

  .reco-toggle.inline {
    width: 100%;
    border-radius: 12px;
  }

  .breakdown-row2 {
    padding: 0;
    margin: 0 0 12px 0;
  }

  .reco-panel {
    padding: 12px;
  }

  .results-chart {
    margin-top: 6px;
    padding: 12px;
    overflow: visible;
  }

  #graficoCategorias {
    height: 320px !important;
    max-height: 70vh;
  }

  .top3-list li {
    flex-direction: column;
    align-items: flex-start;
  }

  .top3-item-metrics {
    white-space: normal;
  }

  .tooltip-icon::after {
    left: auto;
    right: 0;
    transform: none;
    width: min(260px, 78vw);
  }
}

@media (max-width: 420px) {
  .lang-switch-flags {
    width: 100%;
  }

  .lang-flag {
    flex: 1 1 0;
    min-width: 0;
  }

  button {
    width: 100%;
  }

  .resultado-number {
    font-size: 1.8em;
  }

  #graficoCategorias {
    height: 300px !important;
  }
}
