/* ==========================================================================
   Platform page · 5 — Where Finflow goes deeper
   A bento in the home principles' tile language: wide / narrow, then
   narrow / wide; each tile is heading, body, then a demo well.
   Each figure draws what its text says and labels itself only with words
   from the copy:
     products       12-month schedule (interest-only, EMI, seasonal skip,
                    EMI) with an emulator playhead running through it
     underwriting   cashflow / guarantors / collateral / house visits switch
                    per loan type; committee ↔ individual approval
     decisions      risk rating → product recommendations → amount limits
     architecture   services on one bus, two joining, traffic on the bus
   .dp-fig.is-play (js/platform/depth.js) plays a figure: on arrival, and
   again on hover. Without it figures show their final state.
   Prefixed .dp- and scoped to .dp.
   ========================================================================== */

.dp {
  --dp-tile:      #FFFFFF;
  --dp-frame:     #FFFFFF;
  --dp-well:      #F4F7FB;
  --dp-well-edge: rgba(10,47,107,0.06);
  --dp-shadow:    0 1px 2px rgba(10,47,107,0.04), 0 18px 40px -28px rgba(10,47,107,0.28);
  --dp-dot:       rgba(10,47,107,0.13);

  position: relative;
  padding: clamp(72px, 9vw, 120px) var(--page-px);
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
}
:root[data-theme="dark"] .dp {
  --dp-tile:      #0B1F42;
  --dp-frame:     #0B1F42;
  --dp-well:      #08193A;
  --dp-well-edge: rgba(255,255,255,0.05);
  --dp-shadow:    0 18px 40px -28px rgba(0,0,0,0.6);
  --dp-dot:       rgba(147,190,240,0.12);
}

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

/* ─── Bento: wide / narrow, then narrow / wide ────────────────────────── */
.dp-bento {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}
.dp-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 24px 20px 20px;
  background: var(--dp-tile);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--dp-shadow);
  transition: border-color 0.25s ease, transform 0.3s var(--ease-out);
}
.dp-card--wide   { grid-column: span 7; }
.dp-card--narrow { grid-column: span 5; }
.dp-card:hover { border-color: var(--accent-line); }

.dp-copy { padding: 0 4px; }
.dp-name {
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.dp-text { max-width: 560px; font-size: 14px; line-height: 1.65; color: var(--text-secondary); }
.dp-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 2px;
  font-weight: 600;
  color: var(--accent-text);
  text-decoration: none;
  white-space: nowrap;
}
.dp-link i { font-size: 15px; transition: transform 0.2s var(--ease-out); }
.dp-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.dp-link:hover i { transform: translateX(3px); }

/* the demo well */
.dp-well {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 210px;
  height: 210px;
  padding: 20px;
  background: var(--dp-well);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--dp-well-edge);
  overflow: hidden;
  isolation: isolate;            /* keeps the dots behind the figure */
}
/* a fine dot grid, as in the home principles' demo wells: strongest in the
   middle, fading toward the edges */
.dp-well::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--dp-dot) 0.9px, transparent 1.3px);
  background-size: 14px 14px;
  background-position: 7px 7px;
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 50%, #000 30%, transparent 85%);
          mask-image: radial-gradient(ellipse 75% 70% at 50% 50%, #000 30%, transparent 85%);
}
.dp-fig--underwriting, .dp-fig--decisions { padding: 20px clamp(16px, 3vw, 40px); }
.dp-fig--underwriting > *, .dp-fig--decisions > * { max-width: 380px; }

.dp-svg { display: block; width: 100%; height: 100%; min-height: 0; overflow: visible; }

/* products ─────────────────────────────────────────────────────────── */
.dp-chip {
  position: absolute;
  top: 12px; left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
}
.dp-chip i { font-size: 11px; }
.dp-base { stroke: var(--border-strong); stroke-width: 1; }
.dp-b { transform-box: fill-box; transform-origin: center bottom; }
.dp-b--io   { fill: var(--accent-line); }
.dp-b--emi  { fill: var(--accent); }
.dp-b--skip { fill: none; stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 3; }
.dp-brk path { fill: none; stroke: var(--text-muted); stroke-width: 1; }
.dp-lab text { font-family: var(--font-body); font-size: 14px; font-weight: 500; fill: var(--text-secondary); text-anchor: middle; }
.dp-ph { opacity: 0; }
.dp-ph line { stroke: var(--accent); stroke-width: 1.5; }
.dp-ph circle { fill: var(--accent); }
.dp-fig.is-play .dp-b { animation: dp-rise 0.45s var(--ease-out) calc(var(--i) * 45ms) backwards, dp-hit 0.32s ease-out calc(0.9s + var(--i) * 0.2s); }
.dp-fig.is-play .dp-ph { animation: dp-run-x 2.6s cubic-bezier(0.4, 0, 0.3, 1) 0.75s; }
@keyframes dp-rise  { from { transform: scaleY(0); } }
@keyframes dp-hit   { 40% { transform: scaleY(1.1); } }
@keyframes dp-run-x {
  0%   { opacity: 0; transform: translateX(38px); }
  8%   { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(401px); }
}

/* underwriting ──────────────────────────────────────────────────────── */
.dp-uw { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; }
.dp-uw-tile {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  transition: color 0.25s ease, background-color 0.25s ease, border-color 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.dp-uw-tile i { flex: none; font-size: 16px; }
.dp-uw-tile b { font-size: 12px; font-weight: 500; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-uw-tile.is-on { color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.dp-uw-tile.is-on i { color: var(--accent); }
.dp-uw-tile.is-flip { transform: scale(1.06); }

.dp-appr {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  margin-top: 12px;
  padding: 3px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.dp-appr-ind {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  background: var(--dp-frame);
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(10,30,60,0.10), 0 0 0 1px var(--border);
  transition: transform 0.3s var(--ease-out);
}
.dp-appr.is-b .dp-appr-ind { transform: translateX(100%); }
:root[data-theme="dark"] .dp-appr { background: rgba(4, 14, 34, 0.55); }
:root[data-theme="dark"] .dp-appr-ind { background: color-mix(in srgb, var(--accent) 24%, var(--dp-frame)); box-shadow: 0 0 0 1px var(--accent-line); }
.dp-appr-opt {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}
.dp-appr-opt.is-on { color: var(--text-primary); font-weight: 600; }
.dp-avs { display: inline-flex; }
.dp-avs i { width: 11px; height: 11px; margin-left: -4px; background: var(--accent-line); border: 1.5px solid var(--dp-frame); border-radius: 50%; }
.dp-avs i:first-child { margin-left: 0; }
.dp-appr-opt.is-on .dp-avs i { background: var(--accent); }

/* decisions ─────────────────────────────────────────────────────────── */
.dp-rules { position: relative; display: flex; flex-direction: column; gap: 7px; width: 100%; }
.dp-rules::before {
  content: '';
  position: absolute;
  left: 22px; top: 20px; bottom: 20px;
  border-left: 1px solid var(--border-strong);
}
.dp-rules::after {
  content: '';
  position: absolute;
  left: 19px; top: 16px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
}
.dp-rules li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--dp-frame);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
}
.dp-rules li > i {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  flex: none;
  width: 24px; height: 24px;
  font-size: 14px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}
.dp-rules b { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.25; font-weight: 500; color: var(--text-primary); }
.dp-ok {
  display: grid;
  place-items: center;
  flex: none;
  width: 18px; height: 18px;
  font-size: 11px;
  color: #FFFFFF;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 50%;
}
.dp-fig.is-play .dp-rules li  { animation: dp-rule-on 0.3s ease calc(0.5s + var(--i) * 0.55s) backwards; }
.dp-fig.is-play .dp-ok        { animation: dp-ok-on 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) calc(0.6s + var(--i) * 0.55s) backwards; }
.dp-fig.is-play .dp-rules::after { animation: dp-run-y 1.5s cubic-bezier(0.4, 0, 0.3, 1) 0.35s; }
@keyframes dp-rule-on { from { border-color: var(--border); } }
@keyframes dp-ok-on   { from { color: transparent; background: transparent; border-color: var(--border-strong); transform: scale(0.85); } }
@keyframes dp-run-y {
  0%   { opacity: 0; transform: translateY(0); }
  10%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(var(--dp-run, 140px)); }
}

/* architecture ──────────────────────────────────────────────────────── */
.dp-bus  { fill: none; stroke: var(--accent-line); stroke-width: 2; }
.dp-stub { fill: none; stroke: var(--accent-line); stroke-width: 1.5; }
.dp-svc  { fill: var(--dp-frame); stroke: var(--accent); stroke-width: 1.4; }
.dp-svc-g { transform-box: fill-box; transform-origin: center; }
.dp-svc-ln { fill: none; stroke: var(--accent-line); stroke-width: 3; stroke-linecap: round; }
.dp-svc--new  { fill: var(--accent-soft); stroke-dasharray: 4 3; }
.dp-stub--new { stroke-dasharray: 3 3; }
.dp-pkt2 {
  fill: var(--accent);
  opacity: 0;
  offset-path: path('M44 110.5 H396');
  offset-rotate: 0deg;
}
.dp-fig.is-live .dp-pkt2 { animation: dp-bus 2.8s linear 1.2s infinite; }
.dp-fig.is-live .dp-pkt2--b { animation-delay: 2.6s; animation-direction: reverse; }
.dp-fig.is-play .dp-svc-g { animation: dp-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) calc(var(--i) * 70ms) backwards; }
.dp-fig.is-play .dp-svc-g--new { animation-delay: calc(0.4s + var(--i) * 110ms); }
.dp-fig.is-play .dp-stub { animation: dp-fade 0.3s ease calc(var(--i) * 70ms + 0.15s) backwards; }
.dp-fig.is-play .dp-stub--new { animation-delay: calc(0.5s + var(--i) * 110ms); }
@keyframes dp-pop  { from { opacity: 0; transform: scale(0.6); } }
@keyframes dp-fade { from { opacity: 0; } }
@keyframes dp-bus {
  0%   { offset-distance: 0%;   opacity: 0; }
  6%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .dp-card--wide, .dp-card--narrow { grid-column: span 6; }
}
@media (max-width: 680px) {
  .dp-bento { grid-template-columns: minmax(0, 1fr); }
  .dp-card--wide, .dp-card--narrow { grid-column: auto; }
  .dp-well { height: 190px; min-height: 190px; }
  .dp-lab text { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .dp-card, .dp-uw-tile, .dp-appr-ind { transition: none; }
  .dp-fig *, .dp-fig *::before, .dp-fig *::after { animation: none !important; }
}
.dp-fig--products .dp-svg, .dp-fig--architecture .dp-svg { max-width: 460px; }
