/* ==========================================================================
   About
   Desktop (RTL): [heading + text] | [image + 4 floating glass stats]
   The text column sets the row height; the image fills exactly that height,
   so both columns start and end on the same lines.
   Transparent section; edges align with the navbar's outermost elements
   (--nav-edge-left/right from navbar.js), same as the hero.
   ========================================================================== */

.about {
  --about-gutter: var(--space-4);
  --about-gap: var(--space-8);       /* 64px — text ↔ media */
  --copy-width: 440px;
  --card-hang: 168px;                /* how far a card sticks out past the image edge;
                                        cards are ~220–248px wide → ~80px rests on the photo */
  --card-height: 96px;               /* used to guarantee two stacked cards fit */

  padding-block: var(--space-8);
  scroll-margin-top: var(--header-height, 0px);
}

.about__inner {
  display: grid;
  grid-template-columns: minmax(0, var(--copy-width)) minmax(0, 1fr);
  align-items: stretch;
  gap: var(--about-gap);
  margin-left: var(--nav-edge-left, var(--about-gutter));
  margin-right: var(--nav-edge-right, var(--about-gutter));
}

/* ---- Copy ---- */
.about__title {
  margin: 0;
  color: var(--color-primary-700);
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-h3);
}

.about__title-line {
  display: block;
}

.about__title-line--accent {
  color: var(--color-primary);
}

.about__text {
  margin: var(--space-3) 0 0;
  color: var(--color-neutral-900);
  font-size: var(--font-size-b1);
  line-height: var(--line-height-b1);
  text-wrap: pretty;
}

/* ---- Media: sized by the text column, never taller ---- */
.about__media {
  contain: size; /* contributes no height → the row is exactly as tall as the text */
  min-height: calc(var(--card-height) * 2 + var(--space-3)); /* two stacked cards always fit */
  padding-inline: var(--card-hang); /* keeps hanging cards inside the section */
}

.about__stage {
  position: relative;
  height: 100%;
}

.about__image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 32px;
  object-fit: cover;
  object-position: 50% 72%; /* the desk + logo band of the portrait photo */
  background: color-mix(in srgb, var(--color-primary-100) 35%, #ffffff);
}

.about__stats {
  margin: 0;
}

/* ---- Glass statistic card: [number / label] beside a mini chart ---- */
.stat-card {
  position: absolute;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "value chart"
    "label chart";
  align-items: center;
  column-gap: var(--space-2);
  width: max-content; /* sized to number/label + chart, never cramped */
  min-height: var(--card-height);
  padding: var(--space-2);
  border: 1px solid rgb(255 255 255 / 0.55);
  border-radius: 24px;
  background: rgb(255 255 255 / 0.62);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow:
    0 8px 32px rgb(19 61 63 / 0.12),
    inset 0 1px 0 rgb(255 255 255 / 0.6);
}

/* No backdrop-filter → near-opaque white keeps text readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .stat-card {
    background: rgb(255 255 255 / 0.94);
  }
}

/* Two per side, flush with the image's top and bottom; hang depths differ
   so the composition doesn't feel mechanically mirrored. */
.stat-card--1 { top: 0;    right: calc(var(--card-hang) * -1); }
.stat-card--2 { top: 0;    left: calc((var(--card-hang) - var(--space-2)) * -1); }
.stat-card--3 { bottom: 0; right: calc((var(--card-hang) - var(--space-2)) * -1); }
.stat-card--4 { bottom: 0; left: calc(var(--card-hang) * -1); }

.stat-card__value {
  grid-area: value;
  align-self: end;
  margin: 0;
  text-align: start;
}

.stat-card__number {
  display: inline-block;
  color: var(--color-primary-700);
  font-size: var(--font-size-h5);
  font-weight: var(--font-weight-bold);
  line-height: var(--space-5); /* 40px */
  font-variant-numeric: tabular-nums;
  text-align: right; /* grows from the reading edge while counting */
}

.stat-card__label {
  grid-area: label;
  align-self: start;
  margin: 0;
  color: var(--color-neutral-900);
  font-size: var(--font-size-b3);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-b3);
  white-space: nowrap;
}

/* ---- Pulsing indicator dot (sits on the edge that faces the image) ---- */
.stat-card__pulse {
  position: absolute;
  top: 50%;
  width: var(--space-1);
  height: var(--space-1);
  margin-top: calc(var(--space-0-5) * -1);
  border-radius: var(--radius-circle);
  background: var(--color-primary);
  box-shadow:
    0 0 0 var(--space-0-5) rgb(175 228 231 / 0.5),
    0 0 12px rgb(46 146 151 / 0.45);
  pointer-events: none;
  animation: stat-dot 2.4s ease-in-out infinite;
}

.stat-card__pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgb(175 228 231 / 0.7);
  animation: stat-ring 2.4s ease-out infinite;
}

[data-pulse="end"] > .stat-card__pulse   { inset-inline-end: calc(var(--space-0-5) * -1); }
[data-pulse="start"] > .stat-card__pulse { inset-inline-start: calc(var(--space-0-5) * -1); }

@keyframes stat-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.75; transform: scale(0.85); }
}

@keyframes stat-ring {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(3); }
}

/* ==========================================================================
   Mini charts — decorative, drawn left → right
   ========================================================================== */
.mini-chart {
  --stripe-a: color-mix(in srgb, var(--color-primary-100) 80%, #ffffff);
  --stripe-b: color-mix(in srgb, var(--color-primary-100) 40%, #ffffff);
  --stripes: repeating-linear-gradient(135deg, var(--stripe-a) 0 3px, var(--stripe-b) 3px 6px);

  grid-area: chart;
  position: relative;
  width: var(--space-6);  /* 48px */
  height: var(--space-5); /* 40px */
  direction: ltr;
}

/* Vertical rounded bars */
.mini-chart--bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-0-5);
}

.mini-chart__bar {
  flex: 1;
  height: var(--h);
  border-radius: var(--radius-pill);
  background: var(--stripes);
}

.mini-chart__bar.is-accent {
  background: var(--color-primary);
}

.mini-chart--thin {
  gap: var(--space-0-5);
}

/* Rising line */
.mini-chart--line svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.mini-chart__line {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.mini-chart__point {
  position: absolute;
  top: 10%;   /* path end: (156, 4) of 160 × 40 */
  left: 97.5%;
  width: var(--space-1);
  height: var(--space-1);
  border: 2px solid #ffffff;
  border-radius: var(--radius-circle);
  background: var(--color-primary);
  transform: translate(-50%, -50%);
}

/* Progress (99%) */
.mini-chart--progress {
  display: flex;
  align-items: center;
}

.mini-chart__track {
  position: relative;
  width: 100%;
  height: var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--stripes);
  overflow: hidden;
}

.mini-chart__fill {
  position: absolute;
  inset-block: 0;
  left: 0;
  width: var(--value);
  border-radius: inherit;
  background: var(--color-primary);
  transform-origin: left;
}

/* ---- Reveal animation (armed by JS, played once on first view) ---- */
.about.is-armed .mini-chart__bar        { height: var(--space-0-5); } /* height, not scale: keeps the rounded ends round */
.about.is-armed .mini-chart__line       { stroke-dashoffset: 1; }
.about.is-armed .mini-chart__area       { opacity: 0; }
.about.is-armed .mini-chart__point      { opacity: 0; transform: translate(-50%, -50%) scale(0); }
.about.is-armed .mini-chart__fill       { transform: scaleX(0); }

.about.is-revealed .mini-chart__bar {
  height: var(--h);
  transition: height 1200ms var(--ease-smooth) calc(var(--i) * 80ms);
}

.about.is-revealed .mini-chart__line {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1400ms var(--ease-smooth);
}

.about.is-revealed .mini-chart__area {
  opacity: 1;
  transition: opacity 1000ms ease 400ms;
}

.about.is-revealed .mini-chart__point {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity 300ms ease 1200ms, transform 400ms var(--ease-smooth) 1200ms;
}

.about.is-revealed .mini-chart__fill {
  transform: scaleX(1);
  transition: transform 1400ms var(--ease-smooth);
}

@media (prefers-reduced-motion: reduce) {
  .stat-card__pulse,
  .stat-card__pulse::after {
    animation: none;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1599.98px) {
  .about {
    --about-gutter: var(--space-3);
    --about-gap: var(--space-6);
    --copy-width: 400px;
    --card-hang: 160px;
  }

  .about__text {
    font-size: var(--font-size-b2);
    line-height: var(--line-height-b2);
  }
}

@media (max-width: 1439.98px) {
  .about {
    --copy-width: 320px; /* gives the photo room between the cards */
  }

  .about__title {
    font-size: var(--font-size-h4);
    line-height: var(--line-height-h4);
  }
}

/* Tablet: text on top, image (fixed height) + cards below */
@media (max-width: 1279.98px) {
  .about__inner {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
  }

  .about__content {
    max-width: 640px;
  }

  .about__media {
    contain: none;
    height: 360px;
    padding-inline: 120px; /* narrower hang on tablet keeps the photo wide */
  }

  .about {
    --card-hang: 120px;
  }
}

/* Mobile: image full width, cards in a 2-column grid overlapping its bottom */
@media (max-width: 767.98px) {
  .about {
    --about-gutter: var(--space-2);

    padding-block: var(--space-6);
  }

  .about__inner {
    gap: var(--space-4);
  }

  .about__title {
    font-size: var(--font-size-h5);
    line-height: var(--line-height-h5);
  }

  .about__media {
    height: auto;
    min-height: 0;
    padding-inline: 0;
  }

  .about__image {
    aspect-ratio: 4 / 3;
    height: auto;
  }

  .about .about__stats { /* beats the global ul[role="list"] margin reset */
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin-top: calc(var(--space-6) * -1);
    padding-inline: var(--space-1);
  }

  .stat-card {
    position: relative;
    inset: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "value"
      "label"
      "chart";
    width: auto;
    padding: var(--space-2);
  }

  .stat-card__number {
    font-size: var(--font-size-h6);
    line-height: var(--space-4);
  }

  .stat-card__label {
    min-height: calc(var(--line-height-b3) * 2); /* equal card heights per row */
    white-space: normal;
  }

  .mini-chart {
    width: 100%;
    height: var(--space-5);
    margin-top: var(--space-1);
  }

  .mini-chart--thin .mini-chart__bar {
    flex: 0 0 var(--space-1);
  }

  /* Dots move to the top edge, pointing back at the image */
  .stat-card .stat-card__pulse {
    top: calc(var(--space-0-5) * -1);
    inset-inline: auto;
    left: 50%;
    margin: 0 0 0 calc(var(--space-0-5) * -1);
  }
}
