/* =====================================================================
   OSE · Planet row · styles/components/planet-row.css
   ---------------------------------------------------------------------
   The brand signature: the 8 planets in TRUE ORDER, Mercury → Neptune.
   Dot = Earth diameter d × ∛(diameter ÷ Earth's) (the --planet-row-*-scale
   tokens), gap between dots = d, all centred on one line. Flat fill only:
   no gradients, shadows or glow. The pale dots (Venus, Saturn, Uranus) get
   a hairline outline from --planet-row-outline, which is transparent on
   navy and night. Matches /brand/logo/OSE_planet_row_scaled.svg (18 d wide).
   Component tokens only: --planet-row-*.

   Markup (meaningful: a named list)
     <ul class="planet-row" role="list" aria-label="8 hành tinh của Hệ Mặt Trời, từ Sao Thuỷ đến Sao Hải Vương">
       <li class="planet-row__planet planet-row__planet--mercury"><span class="planet-row__dot"></span><span class="planet-row__name">Thuỷ</span></li>
       … --venus Kim · --earth Trái Đất · --mars Hoả · --jupiter Mộc ·
         --saturn Thổ · --uranus Thiên Vương · --neptune Hải Vương
     </ul>
   Decorative use (next to a logo, as an accent): add aria-hidden="true"
   on the <ul>. At most once per screen.

   Sizes      --sm (d 8px) · default (d 12px) · --lg (d 20px from 30em up,
              12px below). Fit: each planet is a flex item "dot + the gap
              after it", so in a container narrower than 18 d every item
              shrinks by the same factor: dots and gaps keep their ratios
              and the row never overflows.
              Needs a definite width to shrink into (a block, or a stretched
              grid/flex item); in shrink-to-fit boxes (inline-flex,
              start-aligned grid items) it keeps its natural 18 d width.
   Variants   --equal: every dot = d (15 d wide), for rows under ~110px
              --labelled: names shown under the dots on a shared baseline
   Names are visually hidden by default (still read by screen readers).
   Step 3 flies the dots in: each dot is its own element and the layout
   never depends on an animation. Static, no interactive states. No JS.
   ===================================================================== */

@layer components {
  .planet-row {
    --_d: var(--planet-row-d);
    --_row: calc(var(--_d) * var(--planet-row-jupiter-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 0; /* may shrink below its natural 18 d inside grid / flex parents */
    max-inline-size: 100%;
    padding: 0;
    list-style: none;
  }

  .planet-row--sm {
    --_d: var(--planet-row-d-sm);
  }

  @media (min-width: 30em) {
    .planet-row--lg {
      --_d: var(--planet-row-d-lg);
    }
  }

  /* Item = dot + the gap after it (none after Neptune). flex-shrink is
     weighted by flex-basis, so shrinking keeps every proportion. */
  .planet-row__planet {
    --_scale: var(--planet-row-earth-scale);
    --_g: var(--planet-row-gap-scale);
    --_fill: var(--planet-row-earth);
    --_outline: transparent;
    position: relative;
    display: flex;
    flex: 0 1 calc(var(--_d) * (var(--_scale) + var(--_g)));
    inline-size: calc(var(--_d) * (var(--_scale) + var(--_g))); /* intrinsic size for shrink-to-fit parents */
    align-items: center;
    justify-content: flex-start;
    min-inline-size: 0;
  }

  .planet-row__planet:last-child {
    --_g: 0;
  }

  .planet-row__planet--mercury {
    --_scale: var(--planet-row-mercury-scale);
    --_fill: var(--planet-row-mercury);
  }

  .planet-row__planet--venus {
    --_scale: var(--planet-row-venus-scale);
    --_fill: var(--planet-row-venus);
    --_outline: var(--planet-row-outline);
  }

  .planet-row__planet--earth {
    --_scale: var(--planet-row-earth-scale);
    --_fill: var(--planet-row-earth);
  }

  .planet-row__planet--mars {
    --_scale: var(--planet-row-mars-scale);
    --_fill: var(--planet-row-mars);
  }

  .planet-row__planet--jupiter {
    --_scale: var(--planet-row-jupiter-scale);
    --_fill: var(--planet-row-jupiter);
  }

  .planet-row__planet--saturn {
    --_scale: var(--planet-row-saturn-scale);
    --_fill: var(--planet-row-saturn);
    --_outline: var(--planet-row-outline);
  }

  .planet-row__planet--uranus {
    --_scale: var(--planet-row-uranus-scale);
    --_fill: var(--planet-row-uranus);
    --_outline: var(--planet-row-outline);
  }

  .planet-row__planet--neptune {
    --_scale: var(--planet-row-neptune-scale);
    --_fill: var(--planet-row-neptune);
  }

  /* Equal: every dot is d (the brand's small-size row). */
  .planet-row--equal {
    --_row: var(--_d);
  }

  .planet-row--equal .planet-row__planet {
    --_scale: var(--planet-row-earth-scale);
  }

  /* A flat disc. The outline is a border inside the box (border-box), so
     every dot keeps its exact size and transparent outlines show the fill. */
  .planet-row__dot {
    display: block;
    flex: none;
    inline-size: calc(100% * var(--_scale) / (var(--_scale) + var(--_g)));
    aspect-ratio: var(--planet-row-dot-ratio);
    border: var(--planet-row-outline-width) solid var(--_outline);
    border-radius: var(--planet-row-dot-radius);
    background-color: var(--_fill);
    forced-color-adjust: none;
  }

  /* Names: visually hidden, still in the accessibility tree. */
  .planet-row__name {
    position: absolute;
    inline-size: var(--planet-row-name-hidden-size);
    block-size: var(--planet-row-name-hidden-size);
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* Labelled: eight equal columns, dots centred on one line, names below
     on a shared baseline (two-word names wrap between the words). */
  .planet-row--labelled {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    align-items: start;
    gap: 0;
    max-inline-size: var(--planet-row-labelled-max-width);
    margin-inline: auto;
  }

  .planet-row--labelled .planet-row__planet {
    display: grid;
    grid-template-rows: var(--_row) auto;
    justify-items: center;
    align-items: center;
    row-gap: var(--planet-row-label-gap);
    inline-size: auto;
    min-inline-size: 0;
  }

  .planet-row--labelled .planet-row__dot {
    inline-size: calc(var(--_d) * var(--_scale));
  }

  .planet-row--labelled .planet-row__name {
    position: static;
    align-self: start;
    inline-size: auto;
    block-size: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    color: var(--planet-row-label-color);
    font-size: var(--planet-row-label-font-size);
    text-align: center;
  }
}
