/* iron.cat · sistema compartido de tickets
   La misma estructura vive en Home V3 y en el catálogo del Brand Kit. */

.ic-receipt {
  --ic-receipt-paper: var(--ic-surface-raised, var(--paper, #fff8ee));
  --ic-receipt-canvas: var(--ic-bg-page, var(--cream, #f7efe2));
  --ic-receipt-ink: var(--ic-color-petrol-950, var(--petrol-950, #193c43));
  --ic-receipt-body: rgb(var(--ic-petrol-rgb, 46 93 99) / 0.9);
  --ic-receipt-muted: rgb(var(--ic-petrol-rgb, 46 93 99) / 0.82);
  --ic-receipt-line: rgb(var(--ic-petrol-rgb, 46 93 99) / 0.16);
  --ic-receipt-coral: var(--ic-color-coral, var(--coral, #e97a6a));
  --ic-receipt-coral-text: var(--ic-color-coral-action, #9f453a);
  --ic-receipt-sage: var(--ic-color-sage, var(--sage, #b7c8be));
  --ic-receipt-mustard: var(--ic-color-mustard, var(--mustard, #f2c24e));
  --ic-receipt-display: var(--ic-font-display, var(--display, "Fraunces", Georgia, serif));
  --ic-receipt-body-font: var(--ic-font-body, var(--body, "Inter", system-ui, sans-serif));
  --ic-receipt-mono: var(--ic-font-mono, var(--mono, ui-monospace, monospace));
  --ic-receipt-chip-h: 26px;
  position: relative;
  display: flex;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  gap: 0;
  padding: clamp(22px, 2.6vw, 34px) clamp(18px, 2.4vw, 30px);
  border: 1px solid var(--ic-receipt-line);
  border-radius: 2px;
  background: var(--ic-receipt-paper);
  box-shadow: 0 20px 48px rgb(var(--ic-petrol-rgb, 46 93 99) / 0.1);
  color: var(--ic-receipt-ink);
  font-family: var(--ic-receipt-body-font);
  container-type: inline-size;
  isolation: isolate;
}

/* Muescas pequeñas de papel continuo. Se superponen a la superficie, sin
   recortar el contenido ni depender de mask-image. */
.ic-receipt::before,
.ic-receipt::after {
  position: absolute;
  z-index: 2;
  right: 0;
  left: 0;
  height: 8px;
  background: radial-gradient(circle at 4px 4px, var(--ic-receipt-canvas) 0 3px, transparent 3.3px) 0 0 / 12px 8px repeat-x;
  content: "";
  pointer-events: none;
}

.ic-receipt::before { top: -4px; }
.ic-receipt::after { bottom: -4px; }

.ic-receipt__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* La identidad se cuadra ópticamente con el chip de la derecha, no por la
   arista de arriba. El chip mide `--ic-receipt-chip-h` (borde + min-height) y
   la etiqueta sola sólo su interlínea: con `flex-start` los dos textos salían
   a alturas distintas — 4,9 px de desfase entre centros, medido. Igualando la
   caja mínima y centrando dentro, los dos rótulos se leen a la misma altura.

   Si la identidad crece (marca + tipo), `min-height` deja de morder y
   `align-content` no hace nada: el bloque vuelve a mandar. */
.ic-receipt__identity {
  display: grid;
  min-height: var(--ic-receipt-chip-h);
  align-content: center;
  gap: 2px;
}

.ic-receipt__brand {
  font-family: var(--ic-receipt-display);
  font-size: clamp(1.2rem, 1.8vw, 1.55rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1;
}

.ic-receipt__kind,
.ic-receipt__number,
.ic-receipt__eyebrow,
.ic-receipt__footer small,
.ic-receipt__total > span,
.ic-receipt__note > span {
  font-family: var(--ic-receipt-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  line-height: 1.35;
  text-transform: uppercase;
}

.ic-receipt__kind {
  margin: 0;
  color: var(--ic-receipt-muted);
}

.ic-receipt__number {
  display: inline-flex;
  min-height: var(--ic-receipt-chip-h);
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--ic-receipt-line);
  border-radius: 2px;
  color: var(--ic-receipt-body);
  white-space: nowrap;
}

.ic-receipt__divider {
  height: 1px;
  margin: clamp(16px, 2vw, 24px) 0;
  border: 0;
  background: repeating-linear-gradient(90deg, var(--ic-receipt-line) 0 5px, transparent 5px 9px);
}

.ic-receipt__eyebrow {
  margin: 0;
  color: var(--ic-receipt-muted);
}

.ic-receipt__title {
  margin: 6px 0 0;
  font-family: var(--ic-receipt-display);
  font-size: clamp(1.45rem, 2.7vw, 2.2rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.02;
  text-wrap: balance;
}

.ic-receipt__lede {
  max-width: 33ch;
  margin: 9px 0 0;
  color: var(--ic-receipt-body);
  font-size: clamp(0.875rem, 2.8cqi, 0.94rem);
  line-height: 1.45;
}

.ic-receipt__rows {
  display: grid;
  gap: 0;
  margin: auto 0 0;
}

.ic-receipt__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px dashed var(--ic-receipt-line);
}

.ic-receipt__row:first-child { border-top: 1px dashed var(--ic-receipt-line); }

.ic-receipt__row dt,
.ic-receipt__row dd { margin: 0; }

.ic-receipt__row dt {
  display: grid;
  gap: 3px;
  color: var(--ic-receipt-body);
  font-size: clamp(0.875rem, 2.8cqi, 0.94rem);
  line-height: 1.25;
}

.ic-receipt__row dt small {
  color: var(--ic-receipt-muted);
  font-family: var(--ic-receipt-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  line-height: 1.25;
  text-transform: uppercase;
}

.ic-receipt__row dd {
  font-family: var(--ic-receipt-display);
  font-size: clamp(1.16rem, 1.8vw, 1.48rem);
  line-height: 1;
  white-space: nowrap;
}

.ic-receipt__total {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
  padding: clamp(16px, 2vw, 22px) 0;
}

.ic-receipt__total > span { color: var(--ic-receipt-muted); }

.ic-receipt__total > small {
  grid-column: 1 / -1;
  margin-top: -10px;
  color: var(--ic-receipt-muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.ic-receipt__total strong {
  color: var(--ic-receipt-coral-text);
  font-family: var(--ic-receipt-display);
  font-size: clamp(1.8rem, 3vw, 2.55rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 0.9;
  white-space: nowrap;
}

.ic-receipt__note {
  display: grid;
  gap: 6px;
  margin-top: clamp(16px, 2vw, 22px);
  padding: 13px 14px;
  border-left: 3px solid var(--ic-receipt-mustard);
  background: rgb(var(--ic-sage-rgb, 183 200 190) / 0.24);
}

.ic-receipt__note > span { color: var(--ic-receipt-muted); }

.ic-receipt__note p {
  margin: 0;
  color: var(--ic-receipt-body);
  font-size: clamp(0.875rem, 2.8cqi, 0.94rem);
  line-height: 1.4;
}

.ic-receipt__footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
  margin-top: auto;
  padding-top: clamp(16px, 2vw, 22px);
  border-top: 1px solid var(--ic-receipt-line);
}

.ic-receipt__footer p {
  margin: 0 0 2px;
  color: var(--ic-receipt-ink);
  font-size: clamp(0.875rem, 2.8cqi, 0.94rem);
  font-weight: 600;
  line-height: 1.3;
}

.ic-receipt__footer small { color: var(--ic-receipt-muted); }

/* Variante editorial compacta. Recupera la lectura rápida de las primeras
   tarjetas y conserva el acabado de ticket sin llenar el papel de copy. */
.ic-receipt--compact {
  min-height: 0;
  gap: 0;
  transition:
    border-color 300ms ease,
    box-shadow 300ms ease;
}

.ic-receipt--compact .ic-receipt__divider {
  margin-block: clamp(18px, 2.4vw, 28px);
  background-size: 9px 1px;
}

.ic-receipt--compact .ic-receipt__title {
  max-width: 13ch;
  margin-top: 0;
  font-size: clamp(1.65rem, 3.2vw, 2.45rem);
}

.ic-receipt--compact .ic-receipt__rows,
.ic-receipt--compact .ic-receipt__compact-list {
  margin-top: clamp(24px, 4vw, 42px);
}

.ic-receipt--compact .ic-receipt__footer {
  margin-top: clamp(22px, 4vw, 40px);
}

.ic-receipt--compact .ic-receipt__footer p {
  max-width: 30ch;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
}

@media (hover: hover) {
  .ic-receipt--compact:hover {
    border-color: rgb(var(--ic-petrol-rgb, 46 93 99) / 0.24);
    box-shadow: 0 24px 56px rgb(var(--ic-petrol-rgb, 46 93 99) / 0.14);
  }
}

/* Lectura nutricional */
.ic-receipt__nutrients {
  display: grid;
  gap: 16px;
  margin: clamp(20px, 3vw, 30px) 0 0;
  padding: 0;
  list-style: none;
}

.ic-receipt__nutrient {
  display: grid;
  gap: 7px;
}

.ic-receipt__nutrient-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--ic-receipt-body);
  font-size: clamp(0.875rem, 2.8cqi, 0.94rem);
  line-height: 1.3;
}

/* PREVALENCIA: el mismo componente que la lectura nutricional, pero midiendo
   cuántos gatos lo tienen y no cuánto lleva la ración. Dos diferencias:
   no hay marca de objetivo —no existe un valor «al que llegar»— y cada línea
   dice a qué población se refiere, porque un porcentaje de salud sin su
   denominador no significa nada. */
/* La coletilla va EN LA MISMA LÍNEA que el nombre, no debajo. Con cinco filas,
   cinco líneas sueltas subían el panel a 658 px contra los 394 y 430 de sus
   vecinos, y el reloj de la sección reparte tercios iguales: una celda mucho
   más alta se queda en pantalla más tiempo del que dura su ventana. */
.ic-receipt__nutrient-qual {
  display: block;
  /* Pegada a SU barra. Medido antes: 12 px hasta la coletilla y 16 hasta la
     fila siguiente — casi lo mismo, así que la coletilla parecía el encabezado
     de la fila de abajo. Ahora la separación de dentro del grupo es cuatro
     veces menor que la de fuera. */
  margin-top: 3px;
  line-height: 1.2;
  color: var(--ic-receipt-muted, rgb(var(--ic-petrol-rgb, 46 93 99) / 0.55));
  font-family: var(--ic-receipt-mono);
  font-size: 0.625rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.ic-receipt--prevalence .ic-receipt__nutrients {
  gap: 22px;
}

.ic-receipt--prevalence .ic-receipt__meter::before {
  background: var(--ic-receipt-ink, rgb(var(--ic-petrol-rgb, 46 93 99)));
  opacity: 0.72;
}

/* La primera es la más frecuente y se lleva el acento; el resto acompaña. */
.ic-receipt--prevalence .ic-receipt__nutrient:first-child .ic-receipt__meter::before {
  opacity: 1;
}

.ic-receipt__nutrient-head b {
  white-space: nowrap;
  color: var(--ic-receipt-ink);
  font-family: var(--ic-receipt-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: right;
  text-transform: uppercase;
}

.ic-receipt__nutrient.is-watch .ic-receipt__nutrient-head b { color: var(--ic-receipt-coral-text); }

/* La misma pista que las barras del hero: sólida y en píldora, no de guiones.
   El punteado competía con las líneas de puntos del propio ticket (el divisor,
   los separadores de fila) y el conjunto se leía como interfaz, no como dato.

     ::before — relleno sólido de 0 a `--now`: dónde está hoy
     > i      — MARCA VERTICAL en `--goal`: dónde tendría que estar

   El objetivo pasa de punto a marca vertical, y es el cambio que hace que se
   entienda. Un punto de 8 px sobre la pista se pierde, y cuando el objetivo cae
   DENTRO del relleno —el caso de los hidratos, 12 % de meta contra 55 % de
   lectura— quedaba sage sobre coral, prácticamente invisible. La marca sobresale
   4 px por arriba y por abajo, así que se ve caiga donde caiga y no depende del
   contraste contra el relleno. */
.ic-receipt__meter {
  display: block;
  position: relative;
  height: 5px;
  border-radius: var(--ic-radius-pill, 999px);
  background: rgb(var(--ic-petrol-rgb, 46 93 99) / 0.14);
}

.ic-receipt__meter::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--now, 0%);
  border-radius: inherit;
  background: var(--ic-receipt-sage);
  /* La barra se llena al entrar en pantalla. `scaleX` y no `width`: animar el
     ancho recalcula layout en cada fotograma; la escala la resuelve el
     compositor. Origen a la izquierda para que crezca desde el arranque. */
  transform-origin: 0 50%;
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* El reloj lo publica el TICKET, no el medidor.
       Con `view()` sobre el propio medidor el llenado entero cabía en 40 px de
       scroll —medido— porque la barra mide 5 px de alto y su fase `entry` es
       cortísima. El ticket mide ~600 px, así que su `cover` da recorrido de
       verdad. Es la misma trampa que ya apareció con el escalonado de palabras
       de «No vendemos comida». */
    .ic-receipt {
      view-timeline-name: --ic-receipt-view;
      view-timeline-axis: block;
    }

    .ic-receipt__meter::before,
    .ic-receipt__meter i {
      animation-timeline: --ic-receipt-view;
      animation-fill-mode: both;
      animation-timing-function: linear;
    }

    /* Escalonadas: tres lecturas distintas, no un bloque. */
    .ic-receipt__meter::before {
      animation-name: ic-receipt-meter-fill;
      animation-range: cover 26% cover 50%;
    }

    .ic-receipt__nutrient:nth-child(2) .ic-receipt__meter::before {
      animation-range: cover 32% cover 56%;
    }

    .ic-receipt__nutrient:nth-child(3) .ic-receipt__meter::before {
      animation-range: cover 38% cover 62%;
    }

    /* El panel de prevalencia tiene CINCO líneas, no tres, y además son DATOS:
       una barra a medio llenar no es un reveal bonito, es una cifra falsa. Con
       los rangos de tres filas (26-50 escalonado hasta 50-74) el panel llegaba
       centrado y legible con las barras en 1 / 0,75 / 0,5 / 0,25 / 0 —medido—,
       o sea un escalón decreciente que no tiene nada que ver con la prevalencia
       real. Se adelantan y se comprimen para que las cinco estén completas
       antes de que el panel se lea. */
    .ic-receipt--prevalence .ic-receipt__nutrient:nth-child(1) .ic-receipt__meter::before { animation-range: cover 12% cover 30%; }
    .ic-receipt--prevalence .ic-receipt__nutrient:nth-child(2) .ic-receipt__meter::before { animation-range: cover 16% cover 34%; }
    .ic-receipt--prevalence .ic-receipt__nutrient:nth-child(3) .ic-receipt__meter::before { animation-range: cover 20% cover 38%; }
    .ic-receipt--prevalence .ic-receipt__nutrient:nth-child(4) .ic-receipt__meter::before { animation-range: cover 24% cover 42%; }
    .ic-receipt--prevalence .ic-receipt__nutrient:nth-child(5) .ic-receipt__meter::before { animation-range: cover 28% cover 46%; }

    /* El punto del objetivo llega DESPUÉS de que su barra termine: primero
       dónde está hoy, luego a dónde tiene que llegar. Ese orden es la lectura
       del componente. */
    .ic-receipt__meter i {
      animation-name: ic-receipt-meter-goal;
      animation-range: cover 52% cover 62%;
    }

    .ic-receipt__nutrient:nth-child(2) .ic-receipt__meter i {
      animation-range: cover 58% cover 68%;
    }

    .ic-receipt__nutrient:nth-child(3) .ic-receipt__meter i {
      animation-range: cover 64% cover 74%;
    }
  }
}

@keyframes ic-receipt-meter-fill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes ic-receipt-meter-goal {
  from { opacity: 0; transform: translateY(-2.5px) scaleY(0.4); }
  to { opacity: 1; transform: translateY(-2.5px) scaleY(1); }
}

.ic-receipt__meter i {
  position: absolute;
  /* la marca mide 2 px: se descuenta la mitad para que su EJE caiga en el valor,
     y se capa a los extremos para que no se salga de la pista */
  left: clamp(0px, calc(var(--goal, 50%) - 1px), calc(100% - 2px));
  top: -4px;
  bottom: -4px;
  width: 2px;
  border-radius: 1px;
  background: var(--ic-receipt-ink);
  /* Anillo de papel: sin él, el tramo de la marca que cruza el relleno se queda
     en 2,15:1 (medido) — el caso de los hidratos, donde la meta del 12 % cae
     dentro de la lectura del 55 %. El anillo la despega de CUALQUIER fondo, que
     es el mismo recurso que usaba el punto anterior con su `border`. */
  box-shadow: 0 0 0 1.5px var(--ic-receipt-paper);
}

/* Fuera de rango, el relleno se tiñe. En papel se usa el coral OSCURECIDO
   (`--ic-receipt-coral-text`, #9f453a) y no el coral de marca: sobre crema el
   coral puro se queda en ~1,9:1 y una barra es un gráfico con significado, que
   pide 3:1 (WCAG 1.4.11). La mostaza del hero funciona sobre vídeo oscuro, no
   sobre este papel. */
.ic-receipt__nutrient.is-watch .ic-receipt__meter::before {
  background: var(--ic-receipt-coral-text, var(--ic-color-coral-action, #9f453a));
}

.ic-receipt--nutrition .ic-receipt__note {
  margin-top: auto;
  border-left-color: var(--ic-receipt-sage);
}

/* Lectura compacta compartida entre los dos hero. No representa porcentajes
   cuando todavía faltan marca, receta o ración: comunica estado, no precisión. */
.ic-nutrition-compact {
  display: grid;
  gap: 0;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.ic-nutrition-compact li {
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 0;
  border-bottom: 1px solid rgb(var(--ic-petrol-rgb, 46 93 99) / 0.18);
}

.ic-nutrition-compact li::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ic-receipt-coral-text);
  content: "";
}

.ic-nutrition-compact li.is-ready::before { background: var(--ic-receipt-sage, var(--ic-color-sage, #b7c8be)); }

.ic-nutrition-compact span {
  min-width: 0;
  color: inherit;
  font: 500 0.75rem/1.25 var(--ic-receipt-body-font, var(--ic-font-body, var(--body, system-ui, sans-serif)));
}

.ic-nutrition-compact b {
  color: inherit;
  font: 600 0.75rem/1.25 var(--ic-receipt-mono, var(--ic-font-mono, var(--mono, ui-monospace, monospace)));
  letter-spacing: 0.02em;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}

.ic-receipt__compact-list {
  gap: 0;
}

.ic-receipt__compact-list li {
  min-height: 42px;
  padding-block: 10px;
}

.ic-receipt__compact-list li::before {
  box-shadow: 0 0 0 4px rgb(var(--ic-coral-rgb, 233 122 106) / 0.09);
}

.ic-receipt__compact-list li.is-ready::before {
  box-shadow: 0 0 0 4px rgb(var(--ic-sage-rgb, 183 200 190) / 0.18);
}

@container (max-width: 270px) {
  .ic-receipt__footer {
    grid-template-columns: minmax(0, 1fr);
  }

  }

@container (max-width: 220px) {
  .ic-receipt__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .ic-receipt__row dd {
    font-size: 1.18rem;
    white-space: normal;
  }

  .ic-receipt__total {
    align-items: start;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .ic-receipt__total > small {
    grid-column: auto;
    margin-top: 0;
  }

  .ic-receipt__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .ic-receipt__number {
    width: max-content;
    max-width: 100%;
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .ic-receipt {
    min-height: 430px;
    padding: 24px 20px;
  }

  .ic-receipt--compact { min-height: 0; }

  .ic-receipt__title { max-width: 11ch; }
}
