/* ==========================================================================
   Section 5 — Platform · "One platform. Or just the parts you need."
   A dark band in both themes: deep navy with a soft gradient mesh and a
   fine noise grain. A mode switch sits above six module tiles
   (js/sections/platform.js). Prefixed .pf- and scoped to .platform.
   The section re-maps the shared colour tokens so everything inside it
   reads light-on-dark without per-element overrides.
   ========================================================================== */

.platform {
  /* Local palette — the same in light and dark site themes */
  --pf-bg:       #071735;
  --pf-glow-a:   rgba(55,138,221,0.30);
  --pf-glow-b:   rgba(21,101,192,0.22);
  --pf-glow-c:   rgba(79,209,176,0.10);
  --pf-card:     rgba(255,255,255,0.045);
  --pf-well:     rgba(255,255,255,0.06);
  --pf-shadow:   0 1px 0 rgba(255,255,255,0.04) inset, 0 24px 48px -32px rgba(0,0,0,0.7);

  /* Shared tokens, re-mapped for a dark surface */
  --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(--pf-bg);
  color: var(--text-secondary);
}
:root[data-theme="dark"] .platform {
  /* Even deeper than the dark page so it still reads as its own band */
  --pf-bg:     #030B1C;
  --pf-glow-a: rgba(55,138,221,0.26);
  --pf-glow-b: rgba(21,101,192,0.20);
}
.platform h2, .platform h3 { color: var(--text-primary); }

/* Gradient mesh: soft light pools, top-right strongest */
.platform::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 60% at 85% 10%, var(--pf-glow-a), transparent 70%),
    radial-gradient(ellipse 45% 50% at 10% 90%, var(--pf-glow-b), transparent 70%),
    radial-gradient(ellipse 35% 35% at 50% 55%, var(--pf-glow-c), transparent 70%);
}
/* Noise grain over the mesh */
.platform::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;
}

.pf-inner { max-width: var(--container); margin: 0 auto; }

/* ─── Head (shared section scale) ─────────────────────────────────────── */
.pf-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: clamp(32px, 4vw, 48px); }
.pf-title {
  font-size: var(--fs-section-title);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.03em;
  white-space: nowrap;           /* one line from tablet up */
}
@media (max-width: 760px) {
  .pf-title { white-space: normal; text-wrap: balance; }
}
.pf-title em { font-style: normal; color: var(--accent); }
.pf-sub {
  max-width: 600px;
  font-size: var(--fs-section-sub);
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ─── Mode switch ─────────────────────────────────────────────────────── */
.pf-seg {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--pf-well);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.pf-seg button {
  position: relative;
  z-index: 1;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.2s ease-out;
}
.pf-seg button:hover { color: var(--text-primary); }
.pf-seg button[aria-checked="true"] { color: #fff; }
.pf-seg-thumb {
  position: absolute;
  top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  background: var(--pf-card);
  border-radius: 9px;
  box-shadow: 0 1px 2px rgba(10,47,107,0.1), 0 4px 10px -4px rgba(10,47,107,0.2);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.pf-seg-thumb { background: rgba(255,255,255,0.12); }
.pf-seg[data-value="keep"] .pf-seg-thumb { transform: translateX(100%); }


/* ─── Tiles ───────────────────────────────────────────────────────────── */
.pf-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.pf-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: var(--pf-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--pf-shadow);
  transition:
    opacity 0.25s ease-out,
    border-color 0.25s ease-out,
    background-color 0.25s ease-out,
    box-shadow 0.25s ease-out;
  transition-delay: var(--d, 0ms);
}
.pf-tile {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.pf-tile:hover { border-color: var(--accent-line); background: rgba(255,255,255,0.065); }

.pf-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);
  transition: color 0.25s ease-out, background-color 0.25s ease-out;
  transition-delay: var(--d, 0ms);
}

/* ─── Icons ───────────────────────────────────────────────────────────────
   Custom line icons (Tabler-weight strokes). On tile hover or keyboard
   focus, the icon's own parts act out the module — one short play
   (~0.5–0.7s, ease-out), never looping. The box itself stays still.
     bank      columns rise, then the roof settles  → built from the ground up
     phone     tasks land on screen, signal goes out → pushed to the field
     calc      keys tap in sequence, display fills  → the books add up
     rules     the branch draws, one outcome lights  → a decision is made
     chart     bars grow, a spark appears           → insight from your data
     road      lane markings run toward you         → what's coming next
     database  layers stack into place              → your system, intact   */
.pf-ic {
  width: 28px; height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.pf-ic * { transform-box: fill-box; }
.pf-g-col, .pf-g-bar { transform-origin: 50% 100%; }
.pf-g-key  { stroke-width: 2.4; transform-origin: center; }
.pf-g-bar  { stroke-width: 2.2; }
.pf-g-disp { stroke-width: 1.3; transform-origin: 100% 50%; }
.pf-g-node, .pf-g-spark { transform-origin: center; }
.pf-g-wave { transform-origin: 0% 50%; }
.pf-g-path { stroke-dasharray: 1; }
.pf-g-lane { stroke-dasharray: 2.2 3.2; }

.pf-tile:is(:hover, :focus-within) .pf-ic * {
  animation-duration: 0.42s;
  animation-timing-function: var(--ease-out);
  animation-fill-mode: both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.pf-tile:is(:hover, :focus-within) .pf-g-col   { animation-name: pf-rise; }
.pf-tile:is(:hover, :focus-within) .pf-g-roof  { animation-name: pf-drop; animation-delay: 260ms; }
.pf-tile:is(:hover, :focus-within) .pf-g-task  { animation-name: pf-land; }
.pf-tile:is(:hover, :focus-within) .pf-g-wave  { animation-name: pf-wave; animation-delay: calc(220ms + var(--i) * 90ms); }
.pf-tile:is(:hover, :focus-within) .pf-g-key   { animation-name: pf-tap; animation-duration: 0.3s; animation-delay: calc(var(--i) * 55ms); }
.pf-tile:is(:hover, :focus-within) .pf-g-disp  { animation-name: pf-type; animation-delay: 300ms; }
.pf-tile:is(:hover, :focus-within) .pf-g-path  { animation-name: pf-draw; animation-duration: 0.45s; }
.pf-tile:is(:hover, :focus-within) .pf-g-node  { animation-name: pf-pop; animation-delay: 340ms; }
.pf-tile:is(:hover, :focus-within) .pf-g-pick  { animation-name: pf-pop, pf-pick; animation-duration: 0.42s, 0.25s; animation-delay: 340ms, 560ms; }
.pf-tile:is(:hover, :focus-within) .pf-g-bar   { animation-name: pf-rise; }
.pf-tile:is(:hover, :focus-within) .pf-g-spark { animation-name: pf-spark; animation-delay: 280ms; }
.pf-tile:is(:hover, :focus-within) .pf-g-lane  { animation-name: pf-lane; animation-duration: 0.7s; }
.pf-tile:is(:hover, :focus-within) .pf-g-layer { animation-name: pf-stack; animation-delay: calc(var(--i) * 90ms); }

@keyframes pf-rise  { from { transform: scaleY(0); } }
@keyframes pf-drop  { from { transform: translateY(-3px); opacity: 0; } }
@keyframes pf-land  { from { transform: translateY(3px); opacity: 0; } }
@keyframes pf-wave  { from { transform: translateX(-2px) scale(0.6); opacity: 0; } }
@keyframes pf-tap   { 50% { transform: scale(1.9); stroke: var(--text-primary); } }
@keyframes pf-type  { from { transform: scaleX(0); } }
@keyframes pf-draw  { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes pf-pop   { from { transform: scale(0); } 70% { transform: scale(1.25); } }
@keyframes pf-pick  { to { fill: currentColor; } }
@keyframes pf-spark { from { transform: rotate(-90deg) scale(0); opacity: 0; } }
@keyframes pf-lane  { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -10.8; } }
@keyframes pf-stack { from { transform: translateY(-4px); opacity: 0; } }

/* Tiles that step back in keep mode stay quiet on hover */
.platform.is-keep .pf-tile.is-not-needed .pf-ic * { animation: none; }

.pf-tile-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.pf-tile-text {
  flex: 1;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Status note — rewrites itself per mode */
.pf-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-text);
}
.pf-note.is-swap { animation: pf-note-in 0.28s ease-out both; animation-delay: var(--d, 0ms); }
@keyframes pf-note-in { from { opacity: 0; transform: translateY(4px); } }

.pf-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  margin-top: 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
}
.pf-link i { font-size: 15px; transition: transform 0.22s var(--ease-sweep); }
.pf-tile:hover .pf-link i,
.pf-link:focus-visible i { transform: translateX(4px); }
.pf-link:hover { color: var(--accent-text); }
/* the whole tile is the link's hit area */
.pf-link::after { content: ''; position: absolute; inset: 0; border-radius: 16px; }

/* Roadmap */
.pf-tile--road {
  background: transparent;
  border-style: dashed;
  border-color: var(--border-strong);
  box-shadow: none;
}
.pf-tile--road .pf-icon { color: var(--text-secondary); background: var(--pf-well); }
.pf-road-list { flex: 1; display: grid; gap: 6px; margin-top: 10px; }
.pf-road-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.pf-road-list li::before { content: ''; width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--text-muted); }

/* ─── "Your current system" tile (keep mode only) ─────────────────────── */
.pf-tile--yours {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  background: rgba(90,216,182,0.07);
  border: 1.5px dashed var(--good);
  box-shadow: none;
}
.pf-tile--yours .pf-icon { margin: 0; color: var(--good); background: var(--good-soft); }
.pf-tile--yours .pf-tile-text { margin-top: 4px; }
.pf-tile--yours:hover { border-color: var(--good); }
.pf-plug {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--good);
  background: var(--good-soft);
  border-radius: 99px;
}
.pf-plug i { font-size: 15px; }

/* Collapsed until keep mode: height + fade so the grid shifts smoothly */
.pf-tile--yours {
  max-height: 0;
  margin-bottom: -16px;          /* cancel the grid gap while hidden */
  padding-top: 0; padding-bottom: 0;
  border-width: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    margin 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    padding 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.25s ease-out;
}
.platform.is-keep .pf-tile--yours {
  max-height: 160px;
  margin-bottom: 0;
  padding-top: 18px; padding-bottom: 18px;
  border-width: 1.5px;
  opacity: 1;
}

/* ─── Keep mode states ────────────────────────────────────────────────── */
/* Handled by their system: step back */
.platform.is-keep .pf-tile.is-not-needed {
  opacity: 0.5;
  box-shadow: none;
  background: transparent;
}
.platform.is-keep .pf-tile.is-not-needed .pf-icon { color: var(--text-muted); background: var(--pf-well); }
.platform.is-keep .pf-tile.is-not-needed .pf-note { color: var(--text-muted); }

/* Plug into their system: highlight */
.platform.is-keep .pf-tile--plug {
  border-color: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft), var(--pf-shadow);
}
.platform.is-keep .pf-tile--plug .pf-icon { color: var(--good); background: var(--good-soft); }
.platform.is-keep .pf-tile--plug .pf-note { color: var(--good); }
.platform.is-keep .pf-tile--plug .pf-note::before {
  content: '\f00a';                       /* ti-plug-connected glyph */
  font-family: 'tabler-icons';
  font-weight: normal;
  font-size: 14px;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .pf-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .pf-tiles { grid-template-columns: minmax(0, 1fr); }
  .pf-seg { display: grid; width: 100%; }
  .pf-seg button { padding: 10px 8px; font-size: 13px; }
  .pf-tile--yours { flex-wrap: wrap; }
  .platform.is-keep .pf-tile--yours { max-height: 280px; }
  .pf-plug { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pf-tile, .pf-icon, .pf-tile--yours, .pf-seg-thumb { transition: none; }
  .pf-note.is-swap { animation: none; }
  .pf-ic * { animation: none !important; }
}
