/*
 * Carbon visibility animation (A8). Renders inside Webflow's Shadow DOM: colours and fonts come
 * in through custom properties set from props. Sizes are stage pixels (1208 x 906), scaled to
 * the component width; positions the cursor aims at are set inline from charts.ts.
 * Frame 0 is the rail and an empty content area: every moving part starts off-stage or hidden
 * here, the same from-states the timeline tweens from (OFFSTAGE and CURSOR.start in charts.ts).
 * --hud (>= 1) enlarges titles, legend, percentage and cursor on narrow screens; data-narrow
 * switches scene 2 to its phone layout.
 */

.shc-root {
  --shc-bg: var(--_default---swatch--neutral, #ffffff);
  --shc-nav: var(--_default---primary--ocean, #1c213d);
  --shc-nav-icons: var(--_default---swatch--neutral, #ffffff);
  --shc-nav-accent: var(--_default---primary--sky, #00b2ff);
  --shc-text: var(--_default---primary--ocean, #1c213d);
  --shc-card: var(--_default---swatch--neutral, #ffffff);
  --shc-card-border: var(--_default---primary--cloud-3, #e7e7e7);
  --shc-data: var(--_default---primary--sky, #00b2ff);
  --shc-selection: var(--_default---primary--ocean, #1c213d);
  --shc-target: var(--_default---primary--ocean, #1c213d);
  --shc-missing: #ff7373;
  --shc-cursor: var(--_default---primary--sky, #00b2ff);
  --shc-font: var(--_typography---font--primary-family, "Fg Futurist", Arial, sans-serif);
  --shc-frame-radius: 8px;
  --shc-frame-border-color: var(--_default---primary--cloud-3, #e7e7e7);
  --shc-frame-border-width: 1px;
  --hud: 1;
  --shc-muted: color-mix(in srgb, var(--shc-text) 60%, transparent);
  --shc-soft: color-mix(in srgb, var(--shc-text) 80%, transparent);
  --shc-shadow: 0 8px 32px color-mix(in srgb, var(--_default---primary--ocean, #1c213d) 8%, transparent);

  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--shc-frame-radius);
  /* The rail strip (120 of 1208 px) is drawn here too, so it shows before the stage is ready */
  background: linear-gradient(to right, var(--shc-nav) calc(100% * 120 / 1208), var(--shc-bg) 0);
  font-family: var(--shc-font);
  color: var(--shc-text);
  isolation: isolate;
  contain: layout paint;
  -webkit-font-smoothing: antialiased;
  line-height: 1.2;
}

.shc-root *,
.shc-root *::before,
.shc-root *::after {
  box-sizing: border-box;
}

.shc-root[data-shadow="false"] {
  --shc-shadow: none;
}

/* Sidebar navigation off: no rail strip before the stage is ready, and the scene 1 title holds frame 0 */
.shc-root[data-sidebar="false"] {
  background: var(--shc-bg);
}

.shc-root[data-sidebar="false"] [data-el="emissionsTitle"] {
  transform: none;
}

/* Webflow wraps the component in a div inside its shadow root; let it fill the parent's width */
:host > div:has(> .shc-root) {
  display: block;
  width: 100%;
}

/* ---------- stage and first load ---------- */

.shc-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1208px;
  height: 906px;
  transform-origin: 0 0;
}

/* Until the script has scaled the stage, only the root background (rail strip and frame) shows */
/* Frame border over everything, so the dark rail stands apart from a dark page background */
.shc-root::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: inherit;
  box-shadow: inset 0 0 0 var(--shc-frame-border-width) var(--shc-frame-border-color);
  pointer-events: none;
}

.shc-root:not([data-ready="true"]) .shc-stage {
  opacity: 0;
}

/* ---------- scenes, titles, cards ---------- */

.shc-scene {
  position: absolute;
  inset: 0;
}

.shc-title {
  position: absolute;
  margin: 0;
  font-size: calc(40px * var(--hud));
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--shc-text);
}

.shc-card {
  position: absolute;
  overflow: hidden;
  background: var(--shc-card);
  border: 2px solid var(--shc-card-border);
  border-radius: 24px;
  box-shadow: var(--shc-shadow);
}

.shc-axis-label {
  position: absolute;
  font-size: 22px;
  color: var(--shc-muted);
  white-space: nowrap;
}

/* ---------- rail ---------- */

/* Rail sizes and positions come inline from RAIL in charts.ts */
.shc-rail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 2;
  background: var(--shc-nav);
  color: var(--shc-nav-icons);
}

.shc-logo {
  position: absolute;
  left: 50%;
  display: block;
  width: 44px;
  height: 56px;
  margin-left: -22px;
  background: var(--shc-nav-icons);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.shc-logo--image {
  background: none;
  object-fit: contain;
}

.shc-rail__icons {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shc-rail__item {
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: color-mix(in srgb, var(--shc-nav-icons) 60%, transparent);
}

.shc-rail__item[data-active="true"] {
  background: color-mix(in srgb, var(--shc-nav-accent) 20%, transparent);
  color: var(--shc-nav-icons);
}

.shc-rail__item svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Pill next to the active item; top is the item's centre */
.shc-nav-label {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  height: calc(44px * var(--hud));
  margin-top: calc(-22px * var(--hud));
  padding: 0 calc(16px * var(--hud));
  border-radius: 10px;
  background: var(--shc-nav);
  color: var(--shc-nav-icons);
  font-size: calc(22px * var(--hud));
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-12px);
}

.shc-nav-label::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  margin-top: -8px;
  border: 8px solid transparent;
  border-left: 0;
  border-right-color: var(--shc-nav);
}

/* ---------- scene 1: monthly emissions ---------- */

[data-el="emissionsTitle"] {
  transform: translateX(-1000px);
}

[data-el="emissionsCard"] {
  transform: translateY(800px);
}

.shc-grid {
  position: absolute;
  right: 0;
  height: 0;
  border-top: 2px solid var(--shc-card-border);
}

.shc-grid .shc-axis-label {
  right: calc(100% + 16px);
  top: 0;
  transform: translateY(-50%);
}

.shc-bar {
  position: absolute;
  background: var(--shc-data);
  transform: scaleY(0);
  transform-origin: 50% 100%;
}

.shc-bar__sel,
.shc-hbar__sel {
  position: absolute;
  inset: 0;
  background: var(--shc-selection);
  opacity: 0;
}

.shc-month {
  position: absolute;
  font-size: 22px;
  color: var(--shc-muted);
  white-space: nowrap;
  transform: translateX(-50%);
}

.shc-target {
  position: absolute;
  right: 0;
  height: 0;
}

.shc-target__line {
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 4px;
  background: var(--shc-target);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.shc-target__label {
  position: absolute;
  left: 0;
  bottom: 12px;
  font-size: 24px;
  font-weight: 500;
  color: var(--shc-target);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
}

.shc-tooltip {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 0 20px;
  border: 2px solid var(--shc-card-border);
  border-radius: 12px;
  background: var(--shc-card);
  box-shadow: var(--shc-shadow);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.85);
  transform-origin: 50% 100%;
}

.shc-tooltip strong {
  font-size: 28px;
  font-weight: 500;
}

.shc-tooltip span {
  font-size: 22px;
  color: var(--shc-soft);
}

/* ---------- click ripple (left/top inline: the click point) ---------- */

.shc-ripple {
  position: absolute;
  z-index: 3;
  width: calc(96px * var(--hud));
  height: calc(96px * var(--hud));
  margin: calc(-48px * var(--hud)) 0 0 calc(-48px * var(--hud));
  border: 4px solid var(--shc-cursor);
  border-radius: 50%;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.3);
}

/* ---------- scene 2: details by carrier ---------- */

[data-el="carriers"] {
  transform: translateX(-1240px);
}

.shc-carrier {
  position: absolute;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 24px;
  color: var(--shc-soft);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
}

.shc-hchart {
  position: absolute;
  top: 0;
  bottom: 0;
}

.shc-hchart__axis {
  position: absolute;
  left: 0;
  border-left: 2px solid color-mix(in srgb, var(--shc-text) 25%, transparent);
}

.shc-hbar {
  position: absolute;
  left: 0;
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.shc-hbar[data-shade="0"] {
  background: color-mix(in srgb, var(--shc-data) 30%, var(--shc-card));
}

.shc-hbar[data-shade="1"] {
  background: color-mix(in srgb, var(--shc-data) 55%, var(--shc-card));
}

.shc-hbar[data-shade="2"] {
  background: color-mix(in srgb, var(--shc-data) 80%, var(--shc-card));
}

/* Gridlines sit over the bars, as in the WebM */
.shc-hchart__grid {
  position: absolute;
  border-left: 2px solid var(--shc-card-border);
}

.shc-hchart__grid .shc-axis-label {
  top: calc(100% + 14px);
  left: 0;
  font-size: 16px;
  transform: translateX(-50%);
}

.shc-hchart__name {
  position: absolute;
  left: 0;
  right: 0;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  color: var(--shc-soft);
}

/* Month chosen in scene 1, next to the title */
.shc-chip {
  display: inline-block;
  margin-left: 0.5em;
  padding: 0.12em 0.5em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--shc-data) 18%, transparent);
  font-size: 0.6em;
  vertical-align: 0.25em;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.6);
  transform-origin: 0 50%;
}

.shc-hbar__value {
  position: absolute;
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: 500;
  color: var(--shc-selection);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
}

.shc-hbar__value[data-inside="true"] {
  color: var(--_default---swatch--neutral, #ffffff);
  transform: translateX(-100%);
}

/* Phone layout: tick labels go, names and values grow (otherwise about 7 px on a 343 px phone) */
.shc-root[data-narrow="true"] .shc-hchart__grid .shc-axis-label {
  display: none;
}

.shc-root[data-narrow="true"] .shc-carrier {
  font-size: 28px;
}

.shc-root[data-narrow="true"] .shc-hchart__name {
  font-size: 30px;
  transform: translateY(-36px);
}

.shc-root[data-narrow="true"] .shc-hbar__value {
  font-size: 26px;
}

/* ---------- scene 3: data completeness ---------- */

[data-el="completeness"] {
  transform: translateX(1240px);
}

.shc-donut {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
}

.shc-donut__data {
  fill: none;
  stroke: var(--shc-data);
  stroke-width: 66px;
}

.shc-donut__missing {
  fill: var(--shc-missing);
}

/* The count is right-aligned in a fixed box, so the "%" never moves while it counts */
.shc-donut__value {
  position: absolute;
  font-size: calc(64px * var(--hud));
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transform: translate(-50%, -50%);
  opacity: 0;
  visibility: hidden;
}

.shc-donut__count {
  display: inline-block;
  text-align: right;
}

.shc-legend {
  position: absolute;
  left: 520px;
  right: 40px;
  top: 150px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shc-legend__row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: 28px 0;
  border-bottom: 2px solid var(--shc-card-border);
  opacity: 0;
  visibility: hidden;
  transform: translateX(60px);
}

.shc-legend__row:first-child {
  border-top: 2px solid var(--shc-card-border);
}

.shc-legend__swatch {
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: calc(4px * var(--hud));
  border-radius: 4px;
}

.shc-legend__swatch--missing {
  background: var(--shc-missing);
}

.shc-legend__swatch--data {
  background: var(--shc-data);
}

.shc-legend strong {
  display: block;
  font-size: calc(30px * var(--hud));
  font-weight: 500;
}

.shc-legend p {
  margin: 12px 0 0;
  font-size: calc(28px * var(--hud));
  line-height: 1.35;
  text-wrap: pretty;
}

.shc-root[data-narrow="true"] .shc-legend {
  top: 80px;
}

.shc-root[data-narrow="true"] .shc-legend__row {
  padding: 18px 0;
}

.shc-root[data-narrow="true"] .shc-legend p {
  font-size: calc(26px * var(--hud));
}

/* ---------- cursor ---------- */

.shc-cursor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  width: 0;
  height: 0;
  transform: translate(820px, 960px);
  opacity: 0;
  visibility: hidden;
}

/* --hud lives on a wrapper GSAP never animates, so the press scale does not overwrite it */
.shc-cursor__hud {
  transform: scale(var(--hud));
  transform-origin: 0 0;
}

.shc-cursor__press {
  position: relative;
  transform-origin: 0 0;
}

/* Same arrow and hand as Ocean (Figma anim assets), placed so the arrow tip and fingertip sit at (0, 0) */
.shc-cursor__arrow {
  position: absolute;
  left: -21px;
  top: -7px;
  width: 112px;
  height: 123px;
  overflow: visible;
  filter: drop-shadow(0 11px 4px rgb(4 22 39 / 0.3));
}

.shc-cursor__hand {
  position: absolute;
  left: -34px;
  top: -6px;
  width: 92px;
  height: 100px;
  overflow: visible;
  opacity: 0;
  visibility: hidden;
  filter: drop-shadow(0 4px 4px rgb(18 19 26 / 0.25));
}

.shc-cursor__fill {
  fill: #ffffff;
}

.shc-cursor__outline {
  fill: none;
  stroke: var(--shc-cursor);
}

.shc-cursor__line {
  fill: var(--shc-cursor);
}

