:root {
  color-scheme: light;
  --maia-ink: #171a20;
  --maia-muted: #626b76;
  --maia-surface: #ffffff;
  --maia-background: transparent;
  --maia-border: #e0e4e9;
  --maia-focus: #8b5cf6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--maia-ink);
  background: transparent;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  padding: 0;
  place-items: stretch;
}

/* Dentro de WordPress el iframe ajusta su alto al contenido; evita un ciclo con 100vh. */
html.is-embedded .app-shell {
  min-height: 0;
}

.calculator-card {
  width: 100%;
  max-width: none;
  padding: clamp(28px, 5vw, 50px);
  background: var(--maia-surface);
  border: 1px solid var(--maia-border);
  border-radius: 18px;
  box-shadow: 0 16px 45px rgb(24 35 52 / 7%);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.72fr);
  align-items: center;
  gap: clamp(12px, 3vw, 36px);
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.hero-art {
  display: grid;
  min-height: 170px;
  place-items: center;
}

.hero-art img {
  display: block;
  width: min(100%, 330px);
  max-height: 250px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 8px;
  color: #4b5563;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.intro {
  max-width: 52ch;
  margin: 16px 0 0;
  color: var(--maia-muted);
  line-height: 1.6;
}

/* Se muestra sólo en móvil para mantener la respuesta visible al editar. */
.mobile-result-summary {
  display: none;
}

.profile-form {
  display: grid;
  gap: 30px;
  margin-top: 30px;
}

.selection-group {
  display: grid;
  gap: 24px;
  min-width: 0;
  padding: 0;
  border: 0;
}

.selection-group legend,
.measurements h2 {
  margin: 0;
  color: var(--maia-ink);
  font-size: 1rem;
  font-weight: 750;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.activity-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.choice-card {
  position: relative;
  display: grid;
  min-height: 48px;
  place-items: center;
  padding: 12px;
  color: var(--maia-ink);
  cursor: pointer;
  background: #fbfcfd;
  border: 1.5px solid var(--maia-border);
  border-radius: 10px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

/* Los iconos son elementos decorativos; los textos conservan contraste neutral. */
.choice-grid:not(.activity-grid) .choice-card {
  display: flex;
  gap: 9px;
}

.choice-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
}

.choice-icon svg,
.activity-icon svg,
.result-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.choice-label {
  color: var(--maia-ink);
}

.choice-card:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--maia-focus) 28%, transparent);
  outline-offset: 2px;
}

.choice-card input {
  position: absolute;
  opacity: 0;
}

/* Estados específicos para que la selección se entienda sin teñir la tipografía. */
.choice-card:has(input[value="hombre"]:checked) {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: inset 0 0 0 1px rgb(59 130 246 / 12%);
}

.choice-card:has(input[value="hombre"]) .choice-icon {
  color: #3b82f6;
}

.choice-card:has(input[value="mujer"]:checked) {
  background: #fff1f4;
  border-color: #ec6b83;
  box-shadow: inset 0 0 0 1px rgb(236 107 131 / 12%);
}

.choice-card:has(input[value="mujer"]) .choice-icon {
  color: #ec6b83;
}

.activity-card {
  min-height: 136px;
  align-content: center;
  justify-items: center;
  gap: 6px;
  overflow: hidden;
  padding: 16px;
  text-align: center;
}

/* La franja superior comunica la progresión de intensidad aun sin seleccionar. */
.activity-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  content: "";
  background: var(--activity-color);
}

.activity-card:has(input[value="sedentario"]) {
  --activity-color: #3b82f6;
  --activity-soft: #eff6ff;
}

.activity-card:has(input[value="ligero"]) {
  --activity-color: #14b8a6;
  --activity-soft: #ecfdf8;
}

.activity-card:has(input[value="moderado"]) {
  --activity-color: #f59e0b;
  --activity-soft: #fff7e8;
}

.activity-card:has(input[value="alto"]) {
  --activity-color: #f15b5b;
  --activity-soft: #fff0ee;
}

.activity-card:has(input:checked) {
  background: var(--activity-soft);
  border-color: var(--activity-color);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--activity-color) 12%, transparent);
}

.choice-title {
  color: var(--maia-ink);
  font-weight: 750;
}

.activity-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--activity-color);
}

.choice-description {
  color: var(--maia-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.measurements {
  display: grid;
  gap: 24px;
}

.range-control {
  display: grid;
  gap: 8px;
}

/* Cada medida tiene una identidad visual, sin afectar los valores de cálculo. */
.range-control:has(#weight-range) {
  --range-color: #3b82f6;
}

.range-control:has(#height-range) {
  --range-color: #14b8a6;
}

.range-control:has(#age-range) {
  --range-color: #8b5cf6;
}

.range-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.range-heading label {
  font-weight: 700;
}

.range-heading label span,
.range-limits {
  color: var(--maia-muted);
  font-weight: 400;
}

.numeric-field {
  display: flex;
  align-items: center;
  width: 144px;
  padding: 0 12px;
  background: #fff;
  border: 1.5px solid var(--maia-border);
  border-radius: 10px;
}

.numeric-field:focus-within {
  border-color: #8b5cf6;
  outline: 3px solid rgb(139 92 246 / 15%);
}

.numeric-field input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 28px 10px 4px;
  color: var(--maia-ink);
  font: inherit;
  font-weight: 750;
  text-align: right;
  border: 0;
  outline: 0;
}

/* Evita que los dígitos queden pegados a los controles nativos del campo numérico. */
.numeric-field input::-webkit-inner-spin-button {
  margin-left: 8px;
}

.numeric-field span {
  margin-left: 6px;
  color: var(--maia-muted);
  font-size: 0.85rem;
}

input[type="range"] {
  width: 100%;
  height: 44px;
  margin: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(
    to right,
    var(--range-color) 0 var(--range-progress, 0%),
    #dfe3e8 var(--range-progress, 0%) 100%
  );
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: transparent;
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -7px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--range-color);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgb(23 26 32 / 22%);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  background: #dfe3e8;
  border-radius: 999px;
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  background: var(--range-color);
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--range-color);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgb(23 26 32 / 22%);
}

.range-limits {
  display: flex;
  justify-content: space-between;
  margin: -8px 0 0;
  font-size: 0.82rem;
}

.results {
  display: grid;
  gap: 16px;
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--maia-border);
}

.results-heading .eyebrow {
  margin-bottom: 6px;
}

.results h2 {
  margin: 0;
  font-size: 1.35rem;
}

.results-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.result-item {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 16px;
  color: var(--maia-ink);
  background: #fbfcfd;
  border: 1.5px solid var(--maia-border);
  border-radius: 12px;
  text-align: center;
}

.result-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--result-color, #626b76);
  background: var(--result-icon-background, #f1f3f5);
  border-radius: 50%;
}

.result-copy {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.result-item span,
.result-item small,
.carbohydrate-range {
  color: var(--maia-muted);
}

.result-item span {
  font-size: 0.8rem;
  line-height: 1.35;
}

.result-item strong {
  color: var(--maia-ink);
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  line-height: 1;
}

.result-item small {
  font-size: 0.75rem;
}

/* Resultados con fondos suaves y bordes semánticos, manteniendo texto neutral. */
.result-item-highlight {
  --result-color: #c77800;
  --result-icon-background: #ffdfa0;
  background: #fff7e8;
  border-color: #f59e0b;
}

.result-item:has(#resting-metabolic-rate) {
  --result-color: #0f9a8b;
  --result-icon-background: #b8f2e8;
  background: #ecfdfb;
  border-color: #14b8a6;
}

.result-item:has(#estimated-daily-energy) {
  --result-color: #db5c12;
  --result-icon-background: #ffd1bd;
  background: #fff2ea;
  border-color: #f97316;
}

.carbohydrate-range {
  margin: 0;
  font-size: 0.9rem;
}

.carbohydrate-suggestion {
  max-width: 68ch;
  margin: -4px 0 0;
  color: var(--maia-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.carbohydrate-suggestion strong {
  color: var(--maia-ink);
}

.chart-panel {
  margin: 4px 0 0;
}

.carbohydrate-chart {
  width: 100%;
  height: 285px;
}

.chart-range-scale {
  --range-minimum-position: 0%;
  --range-reference-position: 0%;
  --range-maximum-position: 0%;
  margin-top: -18px;
}

.chart-range-title {
  display: block;
  margin-bottom: 8px;
  color: var(--maia-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.chart-range-track {
  position: relative;
  width: 100%;
  height: 16px;
  background: linear-gradient(
    to right,
    #3b82f6 0%,
    #14b8a6 22%,
    #22c55e 43%,
    #facc15 63%,
    #f59e0b 82%,
    #f15b5b 100%
  );
  border-radius: 999px;
}

.chart-range-limit,
.chart-range-reference {
  position: absolute;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
}

.chart-range-limit {
  width: 13px;
  height: 13px;
  background: #fff;
  border: 3px solid #334155;
  border-radius: 50%;
}

.chart-range-minimum {
  left: var(--range-minimum-position);
}

.chart-range-maximum {
  left: var(--range-maximum-position);
}

.chart-range-reference {
  left: var(--range-reference-position);
  width: 14px;
  height: 14px;
  background: var(--maia-ink);
  transform: translate(-50%, -50%) rotate(45deg);
}

.chart-range-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--maia-muted);
  font-size: 0.75rem;
}
}

.calorie-equivalent {
  margin: -2px 0 0;
  color: var(--maia-ink);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.chart-panel figcaption {
  margin-top: 8px;
  color: var(--maia-muted);
  font-size: 0.82rem;
  text-align: center;
}

@media (max-width: 768px) {
  .app-shell {
    min-height: auto;
    padding: 0 0 calc(112px + env(safe-area-inset-bottom));
    place-items: stretch;
  }

  .calculator-card {
    padding: 18px 16px 30px;
    border-radius: 14px;
  }

  .hero {
    display: block;
    text-align: center;
  }

  .hero .eyebrow,
  .hero-art {
    display: none;
  }

  h1 {
    max-width: none;
    font-size: clamp(1.25rem, 6vw, 1.6rem);
    line-height: 1.15;
    white-space: nowrap;
  }

  .intro {
    max-width: 38ch;
    margin: 8px auto 0;
    font-size: 0.95rem;
    line-height: 1.4;
  }

  .mobile-result-summary {
    /* El sticky se muestra en WordPress, fuera del iframe, para seguir el scroll real. */
    display: none;
  }

  .mobile-result-summary strong {
    font-size: 0.95rem;
  }

  .profile-form {
    gap: 20px;
    margin-top: 18px;
  }

  .selection-group {
    gap: 12px;
  }

  .selection-group legend,
  .measurements h2 {
    font-size: 0.95rem;
  }

  .activity-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .activity-card {
    min-height: 82px;
    gap: 3px;
    padding: 11px 8px 9px;
  }

  .activity-icon {
    display: none;
  }

  .choice-title {
    font-size: 0.84rem;
  }

  .choice-description {
    font-size: 0.68rem;
    line-height: 1.28;
  }

  .measurements {
    gap: 16px;
  }

  .range-control {
    gap: 3px;
  }

  .range-heading {
    gap: 12px;
  }

  .numeric-field {
    width: 140px;
    padding: 0 9px;
  }

  .numeric-field input {
    min-height: 38px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  input[type="range"] {
    height: 28px;
    background: transparent;
  }

  input[type="range"]::-webkit-slider-runnable-track {
    height: 5px;
    background: linear-gradient(
      to right,
      var(--range-color) 0 var(--range-progress, 0%),
      #dfe3e8 var(--range-progress, 0%) 100%
    );
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    margin-top: -6.5px;
  }

  input[type="range"]::-moz-range-track,
  input[type="range"]::-moz-range-progress {
    height: 5px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }

  .range-limits {
    margin-top: -3px;
    font-size: 0.7rem;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .result-item {
    min-height: 0;
    gap: 0;
    padding: 10px 12px;
  }

  .result-icon,
  .results-heading .eyebrow {
    display: none;
  }

  .result-copy {
    gap: 2px;
  }

  .result-item span {
    font-size: 0.76rem;
  }

  .result-item strong,
  .result-item-highlight strong {
    font-size: 1.45rem;
  }

  .results {
    gap: 10px;
    margin-top: 28px;
    padding-top: 20px;
  }

  .results-heading,
  .carbohydrate-range,
  .carbohydrate-suggestion {
    text-align: center;
  }

  .carbohydrate-suggestion {
    margin-top: -2px;
    font-size: 0.82rem;
  }

  .chart-panel {
    margin-top: 0;
  }

  .carbohydrate-chart {
    height: 245px;
  }

  .chart-range-scale {
    margin-top: -12px;
  }

  .chart-range-title {
    margin-bottom: 7px;
  }
}

@media (max-width: 359px) {
  h1 {
    font-size: 1.15rem;
  }

  .mobile-result-summary {
    font-size: 0.74rem;
  }
}
