/* ==========================================================================
   Rules Studio · 5 — As many decisions as you need
   The home page's platform design ("One platform", css/sections/platform.css):
   a dark band in both themes (deep navy, gradient mesh, fine grain),
   translucent tiles with a 52px icon well, and custom line icons that act
   out their decision on hover or focus (one short play, never looping).
   Each tile notes its rulebook's version and status (Draft grey, Tested
   blue, Live green).
   Prefixed .rd- and scoped to .rd; shared tokens are re-mapped for the
   dark surface, as on the home page.
   ========================================================================== */

.rd {
  --rd-bg:     #071735;
  --rd-glow-a: rgba(55,138,221,0.30);
  --rd-glow-b: rgba(21,101,192,0.22);
  --rd-glow-c: rgba(79,209,176,0.10);
  --rd-card:   rgba(255,255,255,0.045);
  --rd-well:   rgba(255,255,255,0.06);
  --rd-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 24px 48px -32px rgba(0,0,0,0.7);

  --text-primary:   #F1F6FD;
  --text-secondary: #A9BBD6;
  --text-muted:     #7A8DAB;
  --border:         rgba(255,255,255,0.09);
  --border-strong:  rgba(255,255,255,0.18);
  --accent:         #6FB1F2;
  --accent-text:    #9DC9F6;
  --accent-soft:    rgba(111,177,242,0.14);
  --accent-line:    rgba(157,201,246,0.45);
  --good:           #5AD8B6;
  --good-soft:      rgba(90,216,182,0.14);

  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(80px, 10vw, 136px) var(--page-px);
  background: var(--rd-bg);
  color: var(--text-secondary);
}
:root[data-theme="dark"] .rd {
  --rd-bg:     #030B1C;
  --rd-glow-a: rgba(55,138,221,0.26);
  --rd-glow-b: rgba(21,101,192,0.20);
}
.rd h2, .rd h3 { color: var(--text-primary); }

/* gradient mesh, then grain (as on the home page) */
.rd::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 60% at 85% 10%, var(--rd-glow-a), transparent 70%),
    radial-gradient(ellipse 45% 50% at 10% 90%, var(--rd-glow-b), transparent 70%),
    radial-gradient(ellipse 35% 35% at 50% 55%, var(--rd-glow-c), transparent 70%);
}
.rd::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

.rd-inner { max-width: var(--container); margin: 0 auto; }
.rd-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: clamp(32px, 4vw, 48px); }
.rd-title { font-size: var(--fs-section-title); font-weight: 600; line-height: 1.12; letter-spacing: -0.03em; text-wrap: balance; }
.rd-title em { font-style: normal; color: var(--accent); }
.rd-sub { max-width: 720px; font-size: var(--fs-section-sub); line-height: 1.6; color: var(--text-secondary); }

/* ─── Tiles ───────────────────────────────────────────────────────────── */
.rd-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.rd-tile {
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--rd-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--rd-shadow);
}
/* outrank the reveal's own transition (components.css) so hover eases too */
.has-js .rd-tile.anim-el {
  transition: opacity 0.65s var(--ease-out), transform 0.65s var(--ease-out), border-color 0.25s ease-out, background-color 0.25s ease-out, color 0.25s ease-out;
}
.rd-tile:hover { border-color: var(--accent-line); background: rgba(255,255,255,0.065); }

.rd-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  margin-bottom: 18px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.rd-tile-t { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.rd-tile-p { flex: 1; margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--text-secondary); }

/* the rulebook's version and status, in the home tiles' note slot */
.rd-note { display: inline-flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 12.5px; font-weight: 600; }
.rd-note b { font-family: var(--font-mono); font-weight: 500; color: var(--text-muted); }
.rd-st { --c: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; color: var(--c); }
.rd-st::before { content: ''; width: 7px; height: 7px; background: var(--c); border-radius: 50%; }
.rd-st--live   { --c: var(--good); }
.rd-st--tested { --c: var(--accent-text); }

/* ─── Icons ───────────────────────────────────────────────────────────────
   Custom line icons (Tabler-weight strokes, as on the home page). On tile
   hover or focus, each acts out its decision once (~0.5s, ease-out):
     tag      the hole punches, a check draws     → this client qualifies
     gauge    the needle swings to its band        → a risk band is set
     slider   the amount slides up to the cap      → how much, and where to stop
     bell     it swings, two rings go out          → attention, early
     target   an arrow lands, the bull lights      → pursue this one first
     person   an arrow leaves, then turns back     → may not come back      */
.rd-ic {
  width: 28px; height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.rd-ic * { transform-box: fill-box; }
.rd-g-check { stroke-dasharray: 1; stroke-width: 1.9; }
.rd-g-hole, .rd-g-bull { transform-origin: center; }
.rd-g-bull { fill: currentColor; }
.rd-g-needle { transform-origin: 0% 100%; stroke-width: 1.9; }
.rd-g-knob { fill: var(--rd-bg); stroke-width: 1.8; }
.rd-g-fill { stroke-width: 2.6; transform-origin: 0% 50%; }
.rd-g-cap { stroke-width: 2; transform-origin: 50% 0%; }
.rd-g-swing { transform-origin: 50% 0%; }
.rd-g-ring { transform-origin: center; }

.rd-tile:is(:hover, :focus-within) .rd-ic * {
  animation-duration: 0.5s;
  animation-timing-function: var(--ease-out);
  animation-fill-mode: both;
}
.rd-tile:is(:hover, :focus-within) .rd-g-hole   { animation-name: rd-pop; }
.rd-tile:is(:hover, :focus-within) .rd-g-check  { animation-name: rd-draw; animation-delay: 140ms; }
.rd-tile:is(:hover, :focus-within) .rd-g-tick   { animation-name: rd-blink; animation-duration: 0.3s; animation-delay: calc(var(--i) * 80ms); }
.rd-tile:is(:hover, :focus-within) .rd-g-needle { animation-name: rd-swing-needle; animation-duration: 0.7s; animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
.rd-tile:is(:hover, :focus-within) .rd-g-knob   { animation-name: rd-slide; animation-duration: 0.6s; }
.rd-tile:is(:hover, :focus-within) .rd-g-fill   { animation-name: rd-fill; animation-duration: 0.6s; }
.rd-tile:is(:hover, :focus-within) .rd-g-cap    { animation-name: rd-drop; animation-delay: 380ms; animation-duration: 0.35s; }
.rd-tile:is(:hover, :focus-within) .rd-g-swing  { animation-name: rd-ring; animation-duration: 0.7s; }
.rd-tile:is(:hover, :focus-within) .rd-g-ring   { animation-name: rd-wave; animation-delay: calc(120ms + var(--i) * 60ms); }
.rd-tile:is(:hover, :focus-within) .rd-g-arrow  { animation-name: rd-fly; animation-duration: 0.4s; }
.rd-tile:is(:hover, :focus-within) .rd-g-bull   { animation-name: rd-pop; animation-delay: 360ms; }
.rd-tile:is(:hover, :focus-within) .rd-g-out    { animation-name: rd-leave; animation-duration: 0.8s; }

@keyframes rd-pop   { from { transform: scale(0); } 70% { transform: scale(1.4); } }
@keyframes rd-draw  { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes rd-blink { 50% { opacity: 0.2; } }
@keyframes rd-swing-needle { from { transform: rotate(-100deg); } }
@keyframes rd-slide { from { transform: translateX(-6px); } }
@keyframes rd-fill  { from { transform: scaleX(0.05); } }
@keyframes rd-drop  { from { transform: scaleY(0); } }
@keyframes rd-ring  { 20% { transform: rotate(14deg); } 45% { transform: rotate(-10deg); } 70% { transform: rotate(5deg); } 100% { transform: none; } }
@keyframes rd-wave  { from { transform: scale(0.4); opacity: 0; } }
@keyframes rd-fly   { from { transform: translate(5px, -5px); opacity: 0; } }
@keyframes rd-leave { 45% { transform: translateX(3px); opacity: 0.2; } 50% { transform: translateX(-3px); opacity: 0; } 100% { transform: none; opacity: 1; } }

@media (max-width: 960px) {
  .rd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .rd-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .rd-ic * { animation: none !important; }
}
