/* ============================================================
   Primitiva Muay Thai — interactive.css
   NEXUS sub-brief 1013 of programme 1010, 2026-10-25.
   Research basis: Patterns 1, 3 and 12 of
   research_notes/primitiva-interactive-design-research-20261026-0254.

   THE SHARED INTERACTIVE LAYER for primitivamuaythai.com.
   This file is a contract for every page that links it:

     .rv                     scroll-driven reveal hook (Part A)
     @view-transition        cross-document page fade (Part A)
     .mi-press / .mi-ring    micro-interaction primitives (Part A)
     .review-deck ...        homepage reviews deck (Part B)

   Keep the class names above exactly; sibling workstreams and
   the coordinator's mechanical <link> rollout rely on them.

   PALETTE: this sheet declares no colours of its own. It reads
   the site tokens each page declares in its own :root —
   --micro-accent / --gold / --gold-bright (the lemon accent,
   #D7E237), --accent (orange), --field, --surface, --surface-2,
   --ink, --muted, --shadow-chip, --shadow-soft. Where a token
   might be absent, the lemon accent is the fallback.

   GATES, everywhere in this file:
   - Motion runs only inside
     @media (prefers-reduced-motion: no-preference), and the
     site's own reduce-motion setting (html.a11y-reduce-motion)
     neutralises it too.
   - Scroll-driven animation runs only inside
     @supports (animation-timeline: view()).
   - Base states are always the finished, fully visible state:
     if this sheet, the timeline support, or JavaScript fails,
     the page is exactly today's page. Nothing is ever hidden
     waiting for an effect.
   - Only transform and opacity are ever animated.
   ============================================================ */

/* ------------------------------------------------------------
   1. SCROLL-DRIVEN REVEALS — .rv  (Pattern 1)

   Base state: fully visible, no transform. The animation only
   exists where the browser supports a view() timeline AND the
   visitor has not asked for reduced motion. Because the
   animation is keyed to the element's own entry, an element
   already in view at load sits at its completed state — the
   range below (entry 0% to entry 60%, fill both) guarantees
   nothing can be left mid-fade.
   ------------------------------------------------------------ */
.rv {
  opacity: 1;
}

@keyframes rv-fade-rise {
  from {
    opacity: 0.01;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .rv {
      animation: rv-fade-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 60%;
    }
  }
}

/* The site's own reduce-motion setting wins over the effect. */
html.a11y-reduce-motion .rv {
  animation: none;
}

/* ------------------------------------------------------------
   2. CROSS-DOCUMENT VIEW TRANSITIONS  (Pattern 3)

   One opt-in line makes page-to-page navigation a short
   cross-fade in browsers that support cross-document view
   transitions; everywhere else navigation is today's instant
   change. The opt-in lives inside the no-preference gate, so a
   reduced-motion visitor never gets the fade at all.
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 280ms;
    animation-timing-function: ease;
  }
}

/* The site's own reduce-motion setting kills the fade too. */
html.a11y-reduce-motion ::view-transition-old(root),
html.a11y-reduce-motion ::view-transition-new(root) {
  animation: none !important;
}

/* ------------------------------------------------------------
   3. MICRO-INTERACTION PRIMITIVES  (Pattern 4 in the research)

   .mi-press  — tactile press feedback for buttons and tappable
                cards: scale .98 while active, 120 ms,
                transform only.
   .mi-ring   — the site focus-visible ring, for any element a
                sibling makes interactive. (.mi-press carries
                the same ring so a pressable element is never
                left without a visible keyboard focus state.)
   Both are neutralised under reduced motion.
   ------------------------------------------------------------ */
.mi-press {
  transition: transform 120ms ease;
}

.mi-press:active {
  transform: scale(0.98);
}

.mi-press:focus-visible,
.mi-ring:focus-visible {
  outline: 3px solid var(--micro-accent, #d7e237);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .mi-press {
    transition: none;
  }

  .mi-press:active {
    transform: none;
  }
}

html.a11y-reduce-motion .mi-press {
  transition: none;
}

html.a11y-reduce-motion .mi-press:active {
  transform: none;
}

@media (forced-colors: active) {
  .mi-press:focus-visible,
  .mi-ring:focus-visible {
    outline-color: Highlight;
  }
}

/* ------------------------------------------------------------
   3. MICRO-INTERACTION PRIMITIVES  (Pattern 4 in the research)

   .mi-press  — tactile press feedback for buttons and tappable
                cards: scale .98 while active, 120 ms,
                transform only.
   .mi-ring   — the site focus-visible ring, for any element a
                sibling makes interactive. (.mi-press carries
                the same ring so a pressable element is never
                left without a visible keyboard focus state.)
   Both are neutralised under reduced motion.
   ------------------------------------------------------------ */
.mi-press {
  transition: transform 120ms ease;
}

.mi-press:active {
  transform: scale(0.98);
}

.mi-press:focus-visible,
.mi-ring:focus-visible {
  outline: 3px solid var(--micro-accent, #d7e237);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .mi-press {
    transition: none;
  }

  .mi-press:active {
    transform: none;
  }
}

html.a11y-reduce-motion .mi-press {
  transition: none;
}

html.a11y-reduce-motion .mi-press:active {
  transform: none;
}

@media (forced-colors: active) {
  .mi-press:focus-visible,
  .mi-ring:focus-visible {
    outline-color: Highlight;
  }
}

/* ------------------------------------------------------------
   4. HOMEPAGE REVIEWS DECK  (Pattern 12; brief 1013 Part B)

   The deck is a REAL horizontal scroll container: a flex track
   with scroll-snap. The styles that used to live inline in
   index.html / fr/index.html (brief 1001's transform deck) have
   moved here — this section replaces them.

   Layout contract:
   - One card is centred; neighbours peek on both sides. Card
     width is --review-card-w: about 78vw on phones, capped at
     720px (the old deck's card max width) on desktop.
   - ::before / ::after flex spacers, each half the leftover
     track width, let the first and last cards reach the centre
     — spacer flex items are scrollable area in every engine,
     where trailing padding on a scroller is not.
   - The peek scale (.88 at the edges to 1 at the centre) is a
     scroll-driven animation on an inline view() timeline,
     gated exactly like .rv. Without support the cards are
     simply full-size in the snap track.
   - With JavaScript off there are no clones and no controls:
     the four real cards in a plain snap scroller, fully usable.
   - ::scroll-marker styles are a Chromium-only enhancement:
     a visual position indicator. The canonical controls are
     always the real prev/next buttons and the status text.
   ------------------------------------------------------------ */
.review-deck {
  --review-card-w: 78vw;
  --review-gap: 16px;
}

@media (min-width: 640px) {
  .review-deck {
    --review-card-w: min(64vw, 720px);
  }
}

@media (min-width: 1024px) {
  .review-deck {
    --review-card-w: min(84%, 720px);
  }
}

.review-deck .review-deck-track {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: var(--review-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding-block: 10px;
  scrollbar-width: none;
  scroll-marker-group: after;
}

.review-deck .review-deck-track::-webkit-scrollbar {
  display: none;
}

/* Centreing spacers: half the leftover width at each end. */
.review-deck .review-deck-track::before,
.review-deck .review-deck-track::after {
  content: "";
  flex: 0 0 max(0px, calc((100% - var(--review-card-w)) / 2 - var(--review-gap)));
}

/* While JavaScript silently re-centres the endless wrap, the
   jump must be instant even though steps are smooth. */
.review-deck .review-deck-track.deck-jumping {
  scroll-behavior: auto !important;
}

.review-deck .review-deck-track:focus-visible {
  outline: 3px solid var(--gold, #d7e237);
  outline-offset: 4px;
}

.review-deck .review-entry {
  flex: 0 0 var(--review-card-w);
  width: var(--review-card-w);
  max-width: 720px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

/* Chromium scroll markers: visual position dots only.
   Clone cards (see reviews-deck.js) get no marker. */
.review-deck .review-deck-track::scroll-marker-group {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-top: 14px;
}

.review-deck .review-entry::scroll-marker {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: transparent;
  border: 2px solid color-mix(in srgb, var(--gold, #d7e237) 55%, transparent);
}

.review-deck .review-entry::scroll-marker:target-current {
  background: var(--gold-bright, #d7e237);
  border-color: var(--gold-bright, #d7e237);
}

.review-deck .review-entry.review-deck-clone::scroll-marker {
  content: none;
}

/* Peek scale: .88 at the edges, 1 at the centre, keyed to each
   card's own inline view() timeline. The range entry 0% to
   exit 100% spans first-pixel-in to last-pixel-out, whose
   midpoint is exactly the card crossing the track's centre. */
@keyframes review-deck-zoom {
  from {
    transform: scale(0.88);
  }

  50% {
    transform: scale(1);
  }

  to {
    transform: scale(0.88);
  }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .review-deck .review-entry {
      animation: review-deck-zoom linear both;
      animation-timeline: view(inline);
      animation-range: entry 0% exit 100%;
    }
  }
}

/* The site's own reduce-motion setting removes the scale. */
html.a11y-reduce-motion .review-deck .review-entry {
  animation: none;
}

/* Controls: hidden until reviews-deck.js arms the deck, so a
   no-JS visitor never meets a button that does nothing. */
.review-deck-controls {
  display: none;
}

.review-deck.deck-on .review-deck-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 26px;
}

.review-deck.deck-single .review-deck-controls {
  display: none;
}

.review-deck-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--gold, #d7e237) 45%, transparent);
  background: var(--surface);
  color: var(--gold-bright, #d7e237);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-chip);
}

.review-deck-btn:hover {
  border-color: var(--orange, #f26430);
}

.review-deck-btn:focus-visible {
  outline: 3px solid var(--gold, #d7e237);
  outline-offset: 3px;
}

.review-deck-status {
  margin: 0;
  min-width: 110px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

html.a11y-high-contrast .review-deck-btn {
  border-color: rgba(255, 255, 255, 0.65);
  color: #ffffff;
}

/* Reduced motion: steps are instant, never a smooth scroll. */
@media (prefers-reduced-motion: reduce) {
  .review-deck .review-deck-track {
    scroll-behavior: auto;
  }
}

html.a11y-reduce-motion .review-deck .review-deck-track {
  scroll-behavior: auto;
}

@media (forced-colors: active) {
  .review-deck-btn {
    border: 1px solid ButtonText;
    color: ButtonText;
    background: transparent;
  }

  .review-deck .review-deck-track:focus-visible {
    outline-color: Highlight;
  }

  .review-deck-btn:focus-visible {
    outline-color: Highlight;
  }
}

/* GU-7 tabular figures (brief 7168) — staged candidate.
   Amounts, counts and figures in tables use tabular figures so decimals
   line up down the column; numeric columns right align. One CSS-level
   cure per dialect (DS-43, DS-1). Deploy rides the owner's tap. */
table { font-variant-numeric: tabular-nums; }
td[data-num], th[data-num], .num { text-align: right; }
