/* ===========================================================================
   diagram.css — the "wow" layer
   • 3D tilt cards
   • Architecture system map (hub + nodes + connector lines + flow dots)
   • Decorative pure-CSS 3D objects (wireframe cube, layered planes, orbits)
   • Annotation pointers / callouts
   • Per-solution mini flow diagrams
   All monochrome + single blue accent, kept subtle to preserve the Apple feel.
   =========================================================================== */

/* ------------------------------ 1. 3D TILT ------------------------------- */
/* JS sets --rx / --ry from pointer position. transform-style:preserve-3d lets
   inner elements lift toward the viewer for layered depth on hover.
   Parallax (the `translate` property) is applied separately so it never
   conflicts with this `transform`. */
.tilt {
  transform-style: preserve-3d;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.18s var(--ease), box-shadow 0.4s var(--ease), border-color 0.3s var(--ease);
  will-change: transform;
}

/* Lift interior content for depth while tilted */
.tilt .tile-icon { transform: translateZ(36px); }
.tilt .tile-figure,
.tilt .tile-title { transform: translateZ(24px); }

/* Hover shadow on light-section tiles */
.section--white .tile.tilt:hover,
.section--gray  .tile.tilt:hover { box-shadow: 0 22px 48px rgba(0, 0, 0, 0.12); }
.principle.tilt:hover { border-color: rgba(255, 255, 255, 0.28); box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5); }

/* ------------------------- 2. ARCHITECTURE SECTION ----------------------- */
.arch-section { overflow: hidden; padding-bottom: clamp(32px, 4vw, 56px); }

/* When pinned (desktop + motion), the section is tall and the inner pins. */
html.arch-pinned .arch-section { padding: 0; height: 180vh; }
.arch-sticky { position: relative; }
html.arch-pinned .arch-sticky {
  position: sticky;
  top: var(--nav-h);
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(40px, 7vh, 90px) 22px;
}

.arch-head { max-width: 760px; }

.arch {
  position: relative;
  max-width: 1000px;
  margin: clamp(48px, 7vh, 90px) auto 0;
  width: 100%;
}

/* Connector SVG overlay (behind the cards) */
.arch-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}
.arch-lines .link {
  fill: none;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1.4;
  stroke-linecap: round;
  transition: stroke 0.5s var(--ease), filter 0.5s var(--ease);
}
.arch-lines .link.active {
  stroke: rgba(201, 168, 106, 0.95);
  filter: drop-shadow(0 0 6px rgba(201, 168, 106, 0.55));
}

/* Node grid: hub centred, five nodes around it (three above, two flanking) */
.arch-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr minmax(190px, 1.1fr) 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "n1 n2  n3"
    "n4 hub n5";
  gap: clamp(18px, 3vh, 40px) clamp(24px, 5vw, 84px);
  align-items: center;
}
.arch-node--n1 { grid-area: n1; }
.arch-node--n2 { grid-area: n2; }
.arch-node--n3 { grid-area: n3; }
.arch-node--n4 { grid-area: n4; }
.arch-node--n5 { grid-area: n5; }
.arch-hub      { grid-area: hub; }

/* Solution node card */
.arch-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: clamp(16px, 1.6vw, 22px) clamp(18px, 1.8vw, 24px);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-on-black);
  border-radius: 18px;
  color: var(--text-on-black);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.arch-node .arch-num { font-size: 13px; font-weight: 600; color: #c9a86a; font-variant-numeric: tabular-nums; }
.arch-node .arch-name { font-size: clamp(15px, 1.5vw, 18px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.arch-node .arch-tag { font-size: 13px; color: var(--text-2-on-black); }
.arch-node.dim { opacity: 0.4; }
.arch-node:focus-within { opacity: 1 !important; } /* keep focused node readable mid-scroll */
.arch-node.lit { border-color: rgba(201, 168, 106, 0.6); box-shadow: 0 0 0 1px rgba(201, 168, 106, 0.35), 0 16px 40px rgba(0, 0, 0, 0.5); }

/* Central hub */
.arch-hub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: clamp(22px, 2.4vw, 34px);
  text-align: center;
  background: radial-gradient(120% 120% at 50% 0%, rgba(201, 168, 106, 0.14), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(201, 168, 106, 0.4);
  border-radius: 22px;
  box-shadow: 0 0 0 1px rgba(201, 168, 106, 0.18), 0 24px 70px rgba(0, 0, 0, 0.55);
}
.arch-hub-mark { color: #c9a86a; }
.arch-hub-mark svg { width: clamp(34px, 4vw, 46px); height: clamp(34px, 4vw, 46px); }
.arch-hub-title { font-size: clamp(19px, 2vw, 26px); font-weight: 600; letter-spacing: -0.02em; color: var(--text-on-black); }
.arch-hub-sub { font-size: 12px; letter-spacing: 0.02em; color: var(--text-2-on-black); }

.arch-progress-hint { margin-top: clamp(28px, 4vh, 44px); transition: opacity 0.4s var(--ease); }
html:not(.arch-pinned) .arch-progress-hint { display: none; }

/* ----------------------------- 3. FLOW DOTS ------------------------------ */
/* Small dots travelling along the connector paths (offset-path set by JS). */
.flow-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c9a86a;
  box-shadow: 0 0 8px rgba(201, 168, 106, 0.95);
  offset-anchor: 50% 50%;
  offset-rotate: 0deg;
  z-index: 1;
  animation: flowAlong var(--flow-dur, 3s) linear infinite;
  animation-delay: var(--flow-delay, 0s);
}

/* --------------------------- 4. ANNOTATION POINTER ----------------------- */
.pointer {
  position: absolute;
  left: 50%;
  bottom: clamp(-8px, -1vw, 4px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 3;
  color: var(--text-2-on-black);
}
.pointer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9a86a;
  box-shadow: 0 0 8px rgba(201, 168, 106, 0.8);
}
.pointer-line {
  width: 1px;
  height: clamp(20px, 4vh, 38px);
  background: linear-gradient(rgba(201, 168, 106, 0.8), rgba(201, 168, 106, 0.1));
  transform-origin: top;
}
.pointer-label {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ---------------------- 5. DECORATIVE 3D — HERO CUBE --------------------- */
.deco { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }

.cube3d {
  position: absolute;
  top: 12%;
  right: 9%;
  width: 132px;
  height: 132px;
  transform-style: preserve-3d;
  animation: spin3d 26s linear infinite;
  opacity: 0.55;
}
.cube-face {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent; /* the 1px border defines the wireframe */
}
.cube-face--front  { transform: translateZ(66px); }
.cube-face--back   { transform: rotateY(180deg) translateZ(66px); }
.cube-face--right  { transform: rotateY(90deg)  translateZ(66px); }
.cube-face--left   { transform: rotateY(-90deg) translateZ(66px); }
.cube-face--top    { transform: rotateX(90deg)  translateZ(66px); }
.cube-face--bottom { transform: rotateX(-90deg) translateZ(66px); }

/* Faint orbit rings with a travelling accent dot */
.orbit {
  position: absolute;
  border: 1px solid var(--line);
  border-radius: 50%;
  opacity: 0.5;
}
.orbit--a {
  width: min(560px, 70vw);
  height: min(560px, 70vw);
  top: 50%; left: 50%;
  margin: calc(min(560px, 70vw) / -2) 0 0 calc(min(560px, 70vw) / -2);
  animation: spinZ 60s linear infinite;
}
.orbit--a::after {
  content: "";
  position: absolute;
  top: -3px; left: 50%;
  width: 6px; height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(173, 142, 98, 0.6);
}
.orbit--b {
  width: min(320px, 46vw);
  height: min(320px, 46vw);
  bottom: 6%; left: 4%;
  animation: spinZ 52s linear infinite reverse;
}

/* ------------------- 6. DECORATIVE 3D — APPROACH PLANES ------------------ */
.deco--approach { z-index: 1; }
.planes3d {
  position: absolute;
  right: 7%;
  top: 26%;
  width: clamp(160px, 18vw, 240px);
  height: clamp(110px, 12vw, 160px);
  transform: rotateX(56deg) rotateZ(44deg);
  transform-style: preserve-3d;
  animation: floatY 7s ease-in-out infinite;
  opacity: 0.85;
}
.plane {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line-on-black);
  border-radius: 16px;
  background: rgba(201, 168, 106, 0.05);
}
.plane--1 { transform: translateZ(0); }
.plane--2 { transform: translateZ(24px); border-color: rgba(201, 168, 106, 0.3); }
.plane--3 { transform: translateZ(48px); border-color: rgba(201, 168, 106, 0.5); background: rgba(201, 168, 106, 0.09); }

/* ---------------------- 7. PER-SOLUTION FLOW DIAGRAM --------------------- */
.flow {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  flex-wrap: nowrap;
  max-width: 760px;
  margin: clamp(32px, 4vw, 48px) auto 0;
}
.flow-step {
  position: relative;
  z-index: 0; /* own stacking context so the z-index:-1 connector stays visible */
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 12px;
  font-size: clamp(13px, 1.3vw, 15px);
  font-weight: 500;
  letter-spacing: -0.01em;
  text-align: center;
  color: var(--text);
}
.section--gray .flow-step { color: var(--text); }
.flow-step .flow-dot-mark {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
/* Connector: a static hairline by default; a single accent band sweeps across
   once when the flow scrolls into view (.flow gets .in from the reveal system).
   Two layered backgrounds: [0] the moving accent, [1] the static line. */
.flow-step + .flow-step::before {
  content: "";
  position: absolute;
  left: -50%;
  top: 50%;
  width: 100%;
  height: 1px;
  z-index: -1;
  background:
    linear-gradient(90deg, transparent, var(--accent), transparent),
    var(--line);
  background-size: 55% 100%, 100% 100%;
  background-repeat: no-repeat, no-repeat;
  background-position: -60% 0, 0 0;
}
.flow.in .flow-step + .flow-step::before {
  animation: flowDrawH 1.1s var(--ease) 0.15s 1;
}

/* ------------------------------ 8. RESPONSIVE ---------------------------- */
@media (max-width: 760px) {
  /* Architecture collapses to a clean vertical list with a centre line */
  html.arch-pinned .arch-section { height: auto; padding: var(--section-pad) 22px; }
  html.arch-pinned .arch-sticky { position: static; min-height: 0; padding: 0; }
  .arch-lines { display: none; }
  .pointer--hub { display: none; }

  .arch-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas: "hub" "n1" "n2" "n3" "n4" "n5";
    gap: 14px;
    max-width: 460px;
    margin-inline: auto;
  }
  .arch-grid::before {
    content: "";
    position: absolute;
    top: 8%; bottom: 8%;
    left: 50%;
    width: 1px;
    transform: translateX(-50%);
    background: linear-gradient(rgba(201, 168, 106, 0.5), var(--line-on-black));
    z-index: 0;
  }
}

@media (max-width: 640px) {
  /* Flow diagram stacks vertically with vertical connectors */
  .flow { flex-direction: column; gap: 0; max-width: 320px; }
  .flow-step { justify-content: flex-start; padding: 12px 0 12px 4px; }
  .flow-step + .flow-step::before {
    left: 8px; top: -50%;
    width: 1px; height: 100%;
    background:
      linear-gradient(180deg, transparent, var(--accent), transparent),
      var(--line);
    background-size: 100% 55%, 100% 100%;
    background-position: 0 -60%, 0 0;
  }
  .flow.in .flow-step + .flow-step::before { animation-name: flowDrawV; }
}

/* Hide heavy decorative 3D on small screens (keeps focus + performance) */
@media (max-width: 600px) {
  .cube3d { display: none; }
  .orbit--b { display: none; }
  .planes3d { opacity: 0.5; right: -4%; }
}
