/* Carbon footprint: the product page of Loamline, a made-up sustainable label. A still stage, as tall as the screen;
   in the middle a warm white card with the footprint of one jacket. The script draws the bar in the SVG and rolls
   the numbers; the CSS here only sets the materials: hairlines, soft layered shadows, one moss accent. */
:root {
  --page: #f3efe7;          /* the page, a warm white */
  --card: #fffdf9;          /* the card */
  --edge: rgba(43, 38, 30, 0.08); /* the card's hairline edge */
  --ink: #23211d;           /* the words and the bar before it splits */
  --muted: #8c867b;         /* the small words */
  --line: #e6e0d5;          /* the thin rules and the empty tracks */
  --tone-1: #23211d;        /* materials */
  --tone-2: #57524a;        /* manufacturing */
  --tone-3: #8a8378;        /* transport */
  --tone-4: #b3ac9f;        /* packaging */
  --tone-5: #d2cbbf;        /* end of life */
  --average: #ede8df;       /* the industry average bar */
  --average-edge: #cfc7b9;  /* its outline */
  --accent: #56743a;        /* moss: the only colour, for what is saved */
  --accent-soft: #e5ead9;   /* the moss, faint, under the hatching */
  --alto-grande: 100vh;
}
@supports (height: 100lvh) {
  :root { --alto-grande: 100lvh; }
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

p { margin: 0; }

.storia {
  position: relative;
  height: calc(var(--alto-grande) * 5);
}

.palco {
  position: sticky;
  top: 0;
  height: var(--alto-grande);
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 40px) clamp(10px, 4vw, 40px) clamp(26px, 7vh, 64px);
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 60%),
    var(--page);
}

/* ---------------------------------------------------------------- the card */
.card {
  position: relative;
  width: min(100%, 600px);
  max-height: 100%;
  padding: clamp(14px, 3.4vh, 36px) clamp(14px, 4.5vw, 40px);
  border-radius: clamp(14px, 3vh, 24px);
  background: var(--card);
  box-shadow:
    0 0 0 1px var(--edge),
    0 1px 1px rgba(43, 38, 30, 0.04),
    0 4px 10px -4px rgba(43, 38, 30, 0.06),
    0 24px 48px -24px rgba(43, 38, 30, 0.16);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2.6vh, 26px);
  opacity: 0;
}
/* a thin highlight on the top edge, where the light lands */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 3px);
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.marca {
  font-size: clamp(13px, 2.4vh, 16px);
  font-weight: 640;
  font-stretch: 112%;
  letter-spacing: -0.01em;
}
.prodotto {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: clamp(10.5px, 1.9vh, 13px);
  color: var(--muted);
  white-space: nowrap;
}
.prodotto__nome { color: var(--ink); font-weight: 520; }

.totale {
  position: relative;
  display: grid;
  gap: clamp(2px, 0.8vh, 8px);
}
.etichetta {
  font-size: clamp(10.5px, 1.9vh, 13px);
  color: var(--muted);
  letter-spacing: 0.01em;
}
.cifra {
  display: flex;
  align-items: baseline;
  gap: 0.18em;
  font-size: clamp(42px, min(14vw, 12.5vh), 112px);
  line-height: 1;
  letter-spacing: -0.035em;
  font-weight: 330;
  font-stretch: 88%;
}
.unita {
  font-size: 0.2em;
  letter-spacing: 0;
  font-weight: 480;
  font-stretch: 100%;
  color: var(--muted);
}
.unita sub { font-size: 0.72em; vertical-align: -0.2em; }

/* the badge that lights up in moss at the end */
.badge {
  position: absolute;
  right: 0;
  bottom: 0.4em;
  font-size: clamp(10.5px, 1.9vh, 13px);
  opacity: 0;
}
.badge__face {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.42em 0.75em 0.42em 0.6em;
  border-radius: 99px;
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(86, 116, 58, 0.18);
  font-weight: 560;
  white-space: nowrap;
}
.badge svg { width: 0.95em; height: 0.95em; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- the numbers that roll */
.num {
  display: inline-flex;
  line-height: 1;
}
.num__col {
  display: inline-block;
  /* a little taller than the line, so the digits are not cut while they roll */
  height: 1.2em;
  margin: -0.1em 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 14%, #000 86%, transparent);
}
.num__strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}
.num__strip > span { display: block; height: 1.2em; line-height: 1.2em; text-align: center; }
.num__dot { display: inline-block; }

/* ---------------------------------------------------------------- the bar */
.grafico {
  position: relative;
  height: clamp(36px, 8vh, 52px);
}
.barre {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.parte__seg { cursor: default; }
.media__fondo { fill: var(--average); }
.media__bordo { fill: none; stroke: var(--average-edge); stroke-width: 1; }
.media__riga { fill: none; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 1; opacity: 0.5; }
.nostra__riga { fill: none; stroke: var(--accent); stroke-width: 1.25; }
.tratteggio__fondo { fill: var(--accent-soft); }
.tratteggio__riga { stroke: var(--accent); stroke-width: 1.1; opacity: 0.55; }

/* the tooltip */
.tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  min-width: 128px;
  max-width: 190px;
  padding: 8px 10px 9px;
  border-radius: 10px;
  background: var(--ink);
  color: #f6f2ea;
  box-shadow: 0 10px 24px -10px rgba(20, 18, 14, 0.45), 0 2px 4px rgba(20, 18, 14, 0.12);
  font-size: 11.5px;
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 3;
}
.tip__nome { font-weight: 600; font-stretch: 108%; }
.tip__valore { margin-top: 1px; color: #cfc8bb; }
.tip__nota { margin-top: 4px; color: #a39c8f; font-size: 10.5px; }

/* ---------------------------------------------------------------- the parts */
.parti {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.parte {
  display: grid;
  grid-template-columns: 7.4em minmax(24px, 1fr) 4.6em;
  align-items: center;
  gap: clamp(8px, 2vw, 18px);
  padding: clamp(3px, 0.95vh, 8px) 0;
  border-top: 1px solid var(--line);
  font-size: clamp(11px, 2.05vh, 14px);
  line-height: 1.2;
}
.parte:last-child { border-bottom: 1px solid var(--line); }
.parte__nome { white-space: nowrap; }
.parte__pista {
  position: relative;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.parte__pieno {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--ink);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.parte__kg {
  justify-self: end;
  white-space: nowrap;
  font-weight: 520;
}

/* ---------------------------------------------------------------- the comparison */
.confronto {
  display: grid;
  gap: clamp(2px, 0.7vh, 6px);
  font-size: clamp(11px, 2.05vh, 14px);
}
.confronto p {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.confronto__media { color: var(--muted); }
.confronto__kg { font-weight: 520; white-space: nowrap; }
.confronto__salvo { color: var(--accent); font-weight: 560; }

/* ---------------------------------------------------------------- the hint */
.cenno {
  position: absolute;
  left: 50%;
  bottom: clamp(6px, 2.4vh, 24px);
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translateX(-50%);
  font-size: clamp(10.5px, 1.9vh, 12.5px);
  color: var(--muted);
  white-space: nowrap;
}
.cenno svg { width: 9px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

@media (hover: hover) {
  .parte { cursor: default; }
}
