/* Stack section styles: owned by the stack work.
   Markup lives between the STACK:START/END markers in index.html; icons come from
   /assets/icons/stack.svg, which stack.js fetches once and inlines as the section nears. */

/* ---------- Intro + orbit ---------- */
.stk-top { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(40px, 5vw, 80px); align-items: center; }
.stk-intro .lede { max-width: 44ch; }
.stk-total { margin-top: 34px; display: flex; align-items: center; gap: 18px; }
.stk-total strong {
  font-weight: 500; font-size: clamp(64px, 7.4vw, 108px); font-variant-numeric: lining-nums; line-height: .9; letter-spacing: -.05em;
  background: var(--spectrum); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stk-total span { max-width: 17ch; color: var(--muted); font-size: 18px; line-height: 1.35; font-weight: 300; }

.stk-legend ul { margin-top: 28px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.stk-legend a {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px 8px 12px; border-radius: 99px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .03); color: var(--text);
  font-size: 15px; text-decoration: none; transition: border-color .3s, background-color .3s;
}
.stk-legend a:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.stk-legend__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.stk-legend__n { font: 600 12px/1 var(--font-label); font-variant-numeric: lining-nums; letter-spacing: .1em; color: var(--muted); }
/* Keyboard focus shows the legend at once, whatever reveal delay main.js has set */
.js .stk-legend[data-reveal]:focus-within { transition-delay: 0s; }

/* Orbit: five brand-coloured tracks, three rotating rings of logo nodes, the logo at the core.
   Sizes are in container units so the whole thing scales as one. */
.stk-orbit { position: relative; width: min(100%, 640px); aspect-ratio: 1; margin-inline: auto; container-type: inline-size; }
.stk-halo {
  position: absolute; inset: 14%; border-radius: 50%; pointer-events: none; opacity: .2;
  background: conic-gradient(from 200deg, var(--yellow), var(--orange), var(--pink), var(--blue), var(--green), var(--yellow));
  -webkit-mask-image: radial-gradient(closest-side, #000, transparent); mask-image: radial-gradient(closest-side, #000, transparent);
}
.stk-track { --t: rgba(255, 255, 255, .2); position: absolute; left: 50%; top: 50%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; border: 1px solid var(--t); box-shadow: 0 0 22px -2px var(--t), inset 0 0 22px -2px var(--t); }
.stk-track--y { --t: rgba(245, 208, 16, .42); width: 31cqi; }
.stk-track--o { --t: rgba(248, 154, 28, .34); width: 42cqi; }
.stk-track--p { --t: rgba(229, 48, 146, .32); width: 65cqi; }
.stk-track--b { --t: rgba(45, 144, 207, .32); width: 88cqi; }
.stk-track--g { --t: rgba(113, 188, 125, .26); width: 99cqi; border-style: dashed; box-shadow: none; }

.stk-ring { --dur: 80s; position: absolute; inset: 0; animation: stk-spin var(--dur) linear infinite; }
.stk-ring--1 { --r: 21cqi; --glow: var(--orange); --dur: 70s; --rd: 0s; }
.stk-ring--2 { --r: 32.5cqi; --glow: var(--pink); --dur: 96s; --rd: .2s; animation-direction: reverse; }
.stk-ring--3 { --r: 44cqi; --glow: var(--blue); --dur: 130s; --rd: .4s; }
.stk-ring::before { /* a signal travelling with the ring */
  content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 10px 3px var(--glow); transform: rotate(14deg) translateY(calc(var(--r) * -1));
}
.stk-node {
  --s: 9.4cqi; position: absolute; left: 50%; top: 50%; width: var(--s); height: var(--s); margin: calc(var(--s) / -2);
  transform: rotate(var(--a)) translateY(calc(var(--r) * -1)) rotate(calc(var(--a) * -1));
}
.stk-ring--1 .stk-node { --s: 10.4cqi; }
.stk-node > span {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, .09), rgba(9, 12, 21, .94) 72%);
  border: 1px solid color-mix(in srgb, var(--c) 38%, rgba(255, 255, 255, .1));
  box-shadow: 0 0 20px -5px color-mix(in srgb, var(--c) 70%, transparent);
  animation: stk-spin var(--dur) linear infinite reverse; /* counter-rotate so logos stay upright */
}
.stk-ring--2 .stk-node > span { animation-direction: normal; }
.stk-node svg { width: 50%; height: 50%; color: var(--c); }
.stk-core {
  position: absolute; left: 50%; top: 50%; width: 27cqi; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid var(--line-strong);
  background: radial-gradient(circle, rgba(255, 255, 255, .08), rgba(5, 7, 13, .92) 70%);
  box-shadow: 0 0 60px -6px rgba(229, 48, 146, .28), 0 0 90px -10px rgba(45, 144, 207, .22);
}
.stk-core img { width: 78%; height: auto; }
/* Spins only while on screen (stack.js adds .is-live); without JS the orbit is a still image. */
.stk-orbit:not(.is-live) :is(.stk-ring, .stk-node > span) { animation-play-state: paused; }
@keyframes stk-spin { to { transform: rotate(360deg); } }

/* Orbit reveal (armed by stack.js only when it starts off screen) */
.stk-orbit.is-armed .stk-node > span { opacity: 0; scale: .3; }
.stk-orbit.is-armed :is(.stk-track, .stk-core) { opacity: 0; scale: .85; }
.stk-orbit.is-armed.is-in .stk-node > span { opacity: 1; scale: 1; transition: opacity .5s var(--ease-out), scale .8s var(--ease-out); transition-delay: calc(var(--rd) + var(--k) * 45ms + .3s); }
.stk-orbit.is-armed.is-in :is(.stk-track, .stk-core) { opacity: 1; scale: 1; transition: opacity .8s var(--ease-out), scale 1s var(--ease-out); }
.stk-orbit.is-armed.is-in .stk-track--o { transition-delay: .06s; }
.stk-orbit.is-armed.is-in .stk-track--p { transition-delay: .12s; }
.stk-orbit.is-armed.is-in .stk-track--b { transition-delay: .18s; }
.stk-orbit.is-armed.is-in .stk-track--g { transition-delay: .24s; }

/* ---------- Discipline panels ---------- */
.stk-groups { margin-top: clamp(56px, 7vw, 96px); display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(14px, 1.6vw, 20px); }
.stk-group { --pad: clamp(18px, 2.2vw, 30px); grid-column: span 12; padding: var(--pad); scroll-margin-top: calc(var(--header-h) + 16px); }
.stk-group--mobile, .stk-group--ai { grid-column: span 6; } /* software, hardware and cloud are full width */

.stk-group__head {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 6px 14px;
  padding-bottom: 18px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
}
.stk-group__head::before { /* accent line along the top edge */
  content: ""; position: absolute; left: 0; top: calc(var(--pad) * -1 - 1px); width: 88px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), transparent); box-shadow: 0 0 14px var(--accent);
}
.stk-group__num { font: 600 12px/1 var(--font-label); font-variant-numeric: lining-nums; letter-spacing: .24em; color: var(--accent-text, var(--accent)); }
.stk-group__title { font-weight: 500; font-size: clamp(24px, 2.2vw, 32px); line-height: 1.1; letter-spacing: -.02em; }
.stk-group__count {
  justify-self: end; white-space: nowrap; padding: 6px 11px; border-radius: 99px; border: 1px solid var(--line-strong);
  font: 600 11px/1.2 var(--font-label); font-variant-numeric: lining-nums; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.stk-group__blurb { grid-column: 1 / -1; color: var(--muted); font-weight: 300; font-size: 16px; line-height: 1.5; max-width: 60ch; }

.stk-sub { padding-top: 18px; }
.stk-sub__title { margin-bottom: 12px; font: 600 12px/1.4 var(--font-label); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.stk-sub__n { margin-left: 6px; font-variant-numeric: lining-nums; color: var(--accent-text, var(--accent)); }
/* Software: label column + tiles on wide screens */
@media (min-width: 900px) {
  .stk-group--software .stk-sub { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
  .stk-group--software .stk-sub + .stk-sub { border-top: 1px solid var(--line); margin-top: 18px; }
  .stk-group--software .stk-sub__title { margin: 16px 0 0; }
}

@media (min-width: 900px) and (max-width: 1100px) {
  .stk-group--software .stk-sub { grid-template-columns: 130px minmax(0, 1fr); }
  .stk-group--software .stk-tiles { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
  .stk-group--software .stk-tile { font-size: 14px; }
}

/* Hardware & IoT: a headline panel, laid out as a device-to-cloud flow of three columns */
.stk-group--hardware .stk-tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.stk-group--hardware .stk-tile { min-height: 68px; gap: 14px; padding: 12px 14px; font-size: 16px; }
.stk-group--hardware .stk-tile .stk-ico { width: 30px; height: 30px; }
.stk-tile small { display: block; margin-top: 4px; font-size: 13px; line-height: 1.35; font-weight: 300; color: var(--muted); }
@media (min-width: 960px) {
  .stk-group--hardware .stk-group__body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stk-group--hardware .stk-sub { position: relative; padding: 22px 26px 0; }
  .stk-group--hardware .stk-sub:first-child { padding-left: 0; }
  .stk-group--hardware .stk-sub:last-child { padding-right: 0; }
  .stk-group--hardware .stk-sub + .stk-sub { border-left: 1px solid var(--line); }
  .stk-group--hardware .stk-sub__title { margin-bottom: 16px; }
  .stk-group--hardware .stk-tiles { grid-template-columns: 1fr; }
  /* flow connector between columns: a small ring with a chevron, sitting on the divider */
  .stk-group--hardware .stk-sub:not(:last-child)::before,
  .stk-group--hardware .stk-sub:not(:last-child)::after { content: ""; position: absolute; pointer-events: none; }
  .stk-group--hardware .stk-sub:not(:last-child)::before {
    right: -14px; top: 18px; width: 28px; height: 28px; border-radius: 50%; z-index: 1;
    border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); background: var(--bg-raise);
    box-shadow: 0 0 16px -4px var(--accent);
  }
  .stk-group--hardware .stk-sub:not(:last-child)::after {
    right: -3px; top: 29px; width: 7px; height: 7px; z-index: 2;
    border-top: 1.6px solid var(--accent); border-right: 1.6px solid var(--accent); rotate: 45deg;
  }
}

/* ---------- Tiles ---------- */
.stk-tiles { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.stk-group--ai .stk-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stk-group--cloud .stk-tiles { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.stk-tile {
  display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .08); background-color: rgba(255, 255, 255, .03);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .035), transparent);
  font-size: 15px; line-height: 1.2; color: var(--text);
  transition: border-color .3s, background-color .3s, box-shadow .35s var(--ease-out);
}
.stk-ico, .stk-node svg { fill: currentColor; }
.stk-tile > span { min-width: 0; overflow-wrap: break-word; hyphens: auto; }
.stk-ico { flex: none; width: 24px; height: 24px; color: var(--c); opacity: 0; transition: opacity .4s, transform .35s var(--ease-out), filter .35s; }
.stk-tile--line .stk-ico { width: 26px; height: 26px; }
.has-icons .stk-ico { opacity: 1; }
@media (hover: hover) {
  .stk-tile:hover {
    border-color: color-mix(in srgb, var(--c) 62%, transparent);
    background-color: color-mix(in srgb, var(--c) 9%, rgba(255, 255, 255, .02));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent), 0 10px 34px -12px color-mix(in srgb, var(--c) 80%, transparent);
  }
  .stk-tile:hover .stk-ico { transform: scale(1.14); filter: drop-shadow(0 0 7px color-mix(in srgb, var(--c) 75%, transparent)); }
}

/* Staggered reveal (armed by stack.js only when the panel starts off screen) */
.stk-group.is-armed :is(.stk-tile, .stk-group__head, .stk-sub__title) { opacity: 0; translate: 0 14px; }
.stk-group.is-armed.is-in :is(.stk-group__head, .stk-sub__title) { opacity: 1; translate: none; transition: opacity .6s var(--ease-out), translate .7s var(--ease-out); }
.stk-group.is-armed.is-in .stk-tile {
  opacity: 1; translate: none;
  transition: opacity .5s var(--ease-out), translate .6s var(--ease-out), border-color .3s, background-color .3s, box-shadow .35s var(--ease-out);
  transition-delay: calc(var(--i) * 26ms + .1s), calc(var(--i) * 26ms + .1s), 0s, 0s, 0s;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stk-top { grid-template-columns: 1fr; }
  .stk-orbit { width: min(100%, 600px); }
}
@media (max-width: 899px) {
  .stk-group--mobile, .stk-group--ai { grid-column: span 12; }
}
@media (max-width: 640px) {
  .stk-total { gap: 14px; }
  .stk-total span { font-size: 16px; }
  .stk-legend a { font-size: 14px; padding: 7px 12px 7px 10px; }
  .stk-groups { gap: 14px; }
  .stk-group--mobile, .stk-group--ai { grid-column: span 12; }
  .stk-group { --pad: 16px; }
  .stk-group__head { grid-template-columns: auto 1fr; }
  .stk-group__count { grid-column: 1 / -1; grid-row: 3; justify-self: start; }
  .stk-group__blurb { font-size: 15px; }
  .stk-tiles, .stk-group--ai .stk-tiles, .stk-group--cloud .stk-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stk-group--hardware .stk-tiles { grid-template-columns: 1fr; }
  .stk-group--hardware .stk-tile { min-height: 60px; gap: 12px; padding: 10px 12px; font-size: 15px; }
  .stk-group--hardware .stk-tile .stk-ico { width: 26px; height: 26px; }
  .stk-tile { min-height: 52px; gap: 10px; padding: 8px 10px; font-size: 14px; border-radius: 10px; }
  .stk-ico { width: 22px; height: 22px; }
  .stk-tile--line .stk-ico { width: 24px; height: 24px; }
  .stk-node { --s: 10.5cqi; }
  .stk-ring--1 .stk-node { --s: 11.5cqi; }
}

/* ---------- Reduced motion: no spin, no stagger ---------- */
@media (prefers-reduced-motion: reduce) {
  .stk-ring, .stk-node > span { animation: none !important; }
  .stk-ring::before { display: none; }
}
