/* ==========================================================================
   ScaleSiam — home hero: the headline and the ribbon that weaves through it.
   hero-ribbon.js measures the rendered letters and draws the flame, the
   ribbon and the circuit in one canvas; this file owns the type, the layer
   order and the colours.
   Since 13 October 2026 the live home page shows the headline alone and no
   longer loads hero-ribbon.js. The ribbon is kept, runnable, in
   design/archive/ribbon-hero-snake/.
   ========================================================================== */

/* The satin shades from deep (turned away from the light) through green
   (facing you) to light (turned towards it), with a glint at its brightest.
   The flame, the ribbon and the circuit all wear it. */
.ribbon-hero {
  --ribbon-deep: #0f3a2b;
  --ribbon-green: #1f6a4c;
  --ribbon-light: #5fb489;
  --ribbon-glint: #e6f9ee;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(40px, 5.5vw, 72px);
  min-height: min(calc(100svh - var(--header-h)), 820px);
  padding-top: clamp(72px, 11vh, 128px);
  padding-bottom: clamp(56px, 9vh, 112px);
  overflow-x: clip;
}

/* Sized to the viewport, not the content column: the flame and the circuit
   reach almost to both edges of the page. The headline stays in English on
   the Thai page too, so this also outranks the Thai heading rules. */
.ribbon-hero .ribbon-title {
  position: relative;
  isolation: isolate;
  margin: 0;
  padding: 0;
  font-family: Anuphan, sans-serif;
  font-size: clamp(40px, 12.6vw, 320px);
  font-weight: 700;
  /* 1 rather than the ribbon's 0.88: with nothing threading the lines, the
     g descenders need room to clear the h of "Thailand". */
  line-height: 1;
  letter-spacing: -0.05em;
  text-align: center;
  color: var(--ink);
  animation: ribbon-rise 900ms var(--ease-out) both;
}

/* Under reduced motion the entrance only fades: the same animations with
   no travel, so switching the preference does not restart them. */
.ribbon-hero {
  --ribbon-rise: 18px;
  --glyph-rise: 0.22em;
}

.ribbon-text,
.ribbon-glyphs,
.ribbon-line {
  display: block;
}

.ribbon-line {
  white-space: nowrap;
}

.ribbon-hero .actions {
  justify-content: center;
  animation: ribbon-rise 700ms var(--ease-out) 420ms both;
}

/* Layers, back to front: letters the ribbon crosses over, the canvas (the
   flame, the ribbon, the traces and their rings), then letters the ribbon
   passes behind. The real heading text stays underneath for layout,
   selection and assistive technology. */
.ribbon-title.is-woven .ribbon-text {
  color: transparent;
}

.ribbon-glyphs,
.ribbon-satin {
  position: absolute;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.ribbon-glyphs {
  inset: 0;
}

/* Once the ribbon is in, the letters come up one after another rather than
   as a block, a beat ahead of the ribbon that threads them. They move by
   `top`, which an inline box honours, so the kerning between them holds. */
.ribbon-title.is-woven {
  animation: none;
}

.ribbon-glyph {
  position: relative;
  animation: glyph-rise 760ms var(--ease-out) calc(var(--i, 0) * 30ms) both;
}

.ribbon-glyphs-back { z-index: 1; }
.ribbon-glyphs-back .is-front { color: transparent; }
.ribbon-glyphs-front { z-index: 4; color: transparent; }
.ribbon-glyphs-front .is-front { color: var(--ink); }

.ribbon-baseline {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: baseline;
}

.ribbon-satin {
  z-index: 3;
}

/* If the browser takes the WebGL context away, the headline stands alone
   until it comes back. */
.ribbon-title.is-lost .ribbon-glyphs,
.ribbon-title.is-lost .ribbon-satin {
  visibility: hidden;
}

@media (max-width: 560px) {
  .ribbon-hero {
    min-height: 0;
    padding-top: 88px;
    padding-bottom: 96px;
  }
}

@keyframes ribbon-rise {
  from {
    opacity: 0;
    transform: translateY(var(--ribbon-rise));
  }
}

@keyframes glyph-rise {
  from {
    opacity: 0;
    top: var(--glyph-rise);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ribbon-hero {
    --ribbon-rise: 0px;
    --glyph-rise: 0px;
  }
}
