/* ==========================================================================
   CENTNORD v2 — SERVICE PAGES
   --------------------------------------------------------------------------
   Loaded on the three single-service pages, after tokens.css and main.css.

   The idea: each service's small line icon (the one that redraws on the
   homepage cards) grows into a working diagram, a "figure" on the same
   blueprint chart as the homepage instrument. A pulse travels the route,
   lights each station and the read-out reports the step. The page shows
   the service working instead of describing it.

     S1  Service hero layout       S3  Figure drawing (SVG)
     S2  Figure frame + read-outs  S4  Draw-in on load + fallbacks
   ========================================================================== */


/* S1 ──────────────────────────── SERVICE HERO ────────────────────────────── */

.svc-hero {
  position: relative;
  padding-block: clamp(3rem, 7vh, 6rem);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: center top;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.svc-hero-grid {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  gap: clamp(2rem, 5vw, 5rem);
}

/* Breadcrumb in drawing-sheet style: SERVICES / 01 */
.crumb {
  display: flex; gap: 0.625rem; align-items: center;
  margin: 0 0 var(--s-6);
  font-family: var(--mono); font-size: var(--text-mono); font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
}
.crumb a { color: var(--blue-ink); text-decoration: none; }
.crumb a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* The service name sits inside the h1 as a mono kicker, so search engines
   read "AI Automation" as part of the main heading. */
.svc-hero h1 {
  font-size: clamp(2.25rem, 1.5rem + 3.4vw, 4rem);
  line-height: 1.05; letter-spacing: -0.03em;
  max-width: 14ch; margin-bottom: var(--s-5);
}
.svc-hero h1 .kicker {
  display: block; margin-bottom: var(--s-4);
  font-family: var(--mono); font-size: 0.875rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--blue-ink);
}
.svc-hero .lede { font-size: var(--text-lg); color: var(--ink-2); max-width: 44ch; margin-bottom: var(--s-6); }
.svc-cta { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.svc-note { font-family: var(--mono); font-size: var(--text-mono); letter-spacing: 0.04em; color: var(--ink-3); }

@media (max-width: 52em) {
  .svc-hero-grid { grid-template-columns: 1fr; }
  .svc-hero .fig-wrap { order: -1; }
  .svc-hero h1 { max-width: 18ch; }
}


/* S2 ──────────────────────────── FIGURE FRAME ─────────────────────────────
   Same frame as the homepage instrument: thin blueprint border, four
   registration marks, a title line on top and a live read-out below.  */

.fig-wrap { justify-self: center; width: min(100%, 30rem); }
.fig {
  position: relative; margin: 0;
  aspect-ratio: 1;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  border: 1px solid color-mix(in srgb, var(--blue) 35%, transparent);
}
.fig::before, .fig::after, .fig .reg::before, .fig .reg::after {
  content: ""; position: absolute; width: 14px; height: 14px;
  border: 0 solid var(--blue);
}
.fig::before      { top: -7px; left: -7px;  border-top-width: 1.5px; border-left-width: 1.5px; }
.fig::after       { top: -7px; right: -7px; border-top-width: 1.5px; border-right-width: 1.5px; }
.fig .reg::before { bottom: -7px; left: -7px;  border-bottom-width: 1.5px; border-left-width: 1.5px; }
.fig .reg::after  { bottom: -7px; right: -7px; border-bottom-width: 1.5px; border-right-width: 1.5px; }

.fig-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.fig-top, .fig-readout {
  position: absolute; left: var(--s-4); right: var(--s-4);
  display: flex; justify-content: space-between; gap: var(--s-4);
  font-family: var(--mono); letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-3); pointer-events: none;
}
.fig-top { top: var(--s-3); font-size: 0.6875rem; }
.fig-readout { bottom: var(--s-3); font-size: var(--text-mono); align-items: flex-end; }
.fig-readout b { font-weight: 500; color: var(--navy); }
.fig-readout [data-out-step] { font-size: 1.125rem; }
.fig.is-human .fig-readout [data-out-status],
.fig.is-final .fig-readout [data-out-status] { color: var(--green-ink); }

/* The step explained in plain words, under the figure */
.fig-detail {
  display: flex; gap: 0.5rem; align-items: baseline;
  min-height: 3.2em; margin: var(--s-4) 0 0; max-width: none;
  font-size: var(--text-sm); color: var(--ink-2);
}
.fig-detail .arrow { color: var(--green); }


/* S3 ─────────────────────────── FIGURE DRAWING ─────────────────────────────
   One visual language for all three figures:
     route-base  the construction line (faint)
     route-lit   the same line, drawn in blue as the pulse travels
     .st         a station; .lit once reached; .human = a person checks;
                 .final = the result (green)
     pulse       the green dot carrying the work                         */

.fig-svg .fig-tick { stroke: var(--blue); stroke-opacity: 0.4; stroke-width: 1; }

.fig-svg .route-base { fill: none; stroke: var(--blue); stroke-opacity: 0.25; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.fig-svg .route-lit  { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round;
                       stroke-dasharray: 1; stroke-dashoffset: var(--lit, 1); }

.fig-svg .branch     { fill: none; stroke: var(--blue); stroke-opacity: 0.5; stroke-width: 1.5; stroke-dasharray: 4 5; }
.fig-svg .branch-end { fill: var(--surface); stroke: var(--green); stroke-width: 1.5; }
.fig-svg .fig-note   { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; fill: var(--ink-3); }

.fig-svg .bracket { fill: none; stroke: var(--star-navy); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.fig-svg .layer rect { fill: transparent; stroke: var(--line); stroke-width: 1.5; transition: fill 400ms var(--ease), stroke 400ms var(--ease); }
.fig-svg .layer .layer-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; fill: var(--ink-3); transition: fill 400ms var(--ease); }
.fig-svg .layer.lit rect { fill: var(--blue-soft); stroke: var(--blue); }
.fig-svg .layer.lit .layer-label { fill: var(--blue-ink); }

.fig-svg .st-dot   { fill: var(--surface); stroke: var(--blue); stroke-width: 2; transition: fill 300ms var(--ease), stroke 300ms var(--ease), r 300ms var(--ease); }
.fig-svg .st-hit   { fill: transparent; cursor: help; }
.fig-svg .st-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; fill: var(--ink-3); transition: fill 300ms var(--ease); }
.fig-svg .st.lit .st-dot   { fill: var(--blue); }
.fig-svg .st.lit .st-label { fill: var(--navy); }
.fig-svg .st.human .st-dot { stroke: var(--green); stroke-width: 2.5; }
.fig-svg .st.human.lit .st-dot { fill: var(--green); }
.fig-svg .st.final .st-dot { stroke: var(--green); }
.fig-svg .st.final.lit .st-dot { fill: var(--green); }
.fig-svg .st.core .st-dot  { stroke: var(--green); }
.fig-svg .st.lit.active .st-dot { r: 9; }
.fig-svg .st.final.lit.active .st-dot { r: 11; }

/* The Centnord star at the end of the delivery route */
.fig-svg .st-star .star-b { fill: var(--star-navy); opacity: 0.35; transition: opacity 400ms var(--ease); }
.fig-svg .st-star .star-t { fill: var(--green); opacity: 0.3; transition: opacity 400ms var(--ease); }
.fig-svg .st-star .star-c { fill: #fff; }
.fig-svg .st.final.lit .st-star .star-b { opacity: 1; }
.fig-svg .st.final.lit .st-star .star-t { opacity: 1; filter: drop-shadow(0 0 6px rgba(57, 183, 143, 0.8)); }

.fig-svg .pulse { fill: var(--green); filter: drop-shadow(0 0 5px rgba(57, 183, 143, 0.9)); }
.fig.is-paused .pulse { opacity: 0.45; }


/* S4 ──────────────────────── DRAW-IN + FALLBACKS ───────────────────────────
   On arrival the construction line draws itself and the stations appear
   in order (the same motion as the icon redraw on the homepage cards).  */

html.js .fig-svg .route-base { stroke-dasharray: 1; stroke-dashoffset: 1; animation: fig-draw 1.2s var(--ease) 0.2s forwards; }
html.js .fig-svg .st,
html.js .fig-svg .bracket,
html.js .fig-svg .layer,
html.js .fig-svg .branch,
html.js .fig-svg .branch-end,
html.js .fig-svg .fig-note { opacity: 0; animation: fig-in 0.4s var(--ease) forwards; }
html.js .fig-svg .st { animation-delay: calc(0.35s + var(--i, 0) * 0.14s); }
html.js .fig-svg .bracket { animation-delay: 0.1s; }
html.js .fig-svg .layer { animation-delay: 0.6s; }
html.js .fig-svg .branch, html.js .fig-svg .branch-end, html.js .fig-svg .fig-note { animation-delay: 1s; }

@keyframes fig-draw { to { stroke-dashoffset: 0; } }
@keyframes fig-in   { to { opacity: 1; } }

/* Without JS: the finished diagram, every station lit */
html:not(.js) .fig-svg .route-lit { --lit: 0; }
html:not(.js) .fig-svg .st-dot { fill: var(--blue); }
html:not(.js) .fig-svg .layer rect { fill: var(--blue-soft); stroke: var(--blue); }
html:not(.js) .fig-svg .pulse { display: none; }


/* S5 ─────────────────── "THREE STEPS" — ANIMATED STORYBOARD ───────────────────
   Three scenes on one track. js/service.js makes one step .is-active at a
   time (every ~4.6s, or on hover/focus/tap). The active scene plays its
   animation; the others rest, complete but dimmed. Steps already passed
   are .is-done. --p (0 → 1) fills the track up to the active step.     */

.flow { --p: 0; position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); padding-top: 2.75rem; }
.flow::before, .flow::after { content: ""; position: absolute; top: 0.75rem; left: 0.75rem; right: 0.75rem; height: 2px; }
.flow::before { background: var(--line); }
.flow::after  { background: linear-gradient(90deg, var(--blue), var(--blue) 75%, var(--green));
                transform-origin: left center; transform: scaleX(var(--p)); transition: transform 700ms var(--ease); }

.flow-step { position: relative; cursor: pointer; outline: none; }
.flow-node {
  position: absolute; top: -2.75rem; left: 0;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
  transition: background 300ms var(--ease), border-color 300ms var(--ease), box-shadow 300ms var(--ease);
}
.flow-step.is-done .flow-node   { background: var(--blue); border-color: var(--blue); }
.flow-step.is-active .flow-node { background: var(--green); border-color: var(--green); box-shadow: 0 0 0 6px var(--green-soft); }

.vg-panel {
  position: relative; aspect-ratio: 240 / 150; margin-bottom: var(--s-4);
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 1px solid var(--line);
  transition: border-color 300ms var(--ease), box-shadow 300ms var(--ease);
}
.flow-step.is-active .vg-panel { border-color: var(--blue); box-shadow: var(--shadow-card); }
.flow-step:focus-visible .vg-panel { outline: 2px solid var(--green); outline-offset: 3px; }
.vg-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; transition: opacity 300ms var(--ease); }
html.js .flow-step:not(.is-active) .vg-svg { opacity: 0.5; }

.flow-label {
  margin: 0 0 var(--s-2);
  font-family: var(--mono); font-size: var(--text-mono); font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  transition: color 300ms var(--ease);
}
.flow-step.is-active .flow-label { color: var(--blue-ink); }
.flow-step h3 { font-size: var(--text-lg); margin-bottom: var(--s-2); }
.flow-step p:not(.flow-label) { font-size: var(--text-sm); color: var(--ink-2); margin: 0; }

@media (max-width: 52em) {
  .flow { grid-template-columns: 1fr; padding-top: 0; padding-left: 2.75rem; gap: var(--s-7); }
  .flow::before, .flow::after { top: 0.75rem; bottom: 0.75rem; left: 0.6875rem; right: auto; width: 2px; height: auto; }
  .flow::after { background: linear-gradient(180deg, var(--blue), var(--blue) 75%, var(--green)); transform-origin: center top; transform: scaleY(var(--p)); }
  .flow-node { top: 0; left: -2.75rem; }
}

/* ---- Scene drawing: the same stroke language as the service icons ---- */
.vg-svg * { vector-effect: non-scaling-stroke; }
.vg-svg .vl { fill: none; stroke: var(--star-navy); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.vg-svg .vs { fill: none; stroke: var(--blue); stroke-opacity: 0.45; stroke-width: 1.5; stroke-linecap: round; }
.vg-svg .vb { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; }
.vg-svg .vg { fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vg-svg .vm { fill: none; stroke: var(--ink-3); stroke-width: 1.75; stroke-linecap: round; }
.vg-svg .vt { font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; fill: var(--ink-3); stroke: none; }
.vg-svg .vt-g { fill: var(--green-ink); }
.vg-svg .vt-b { fill: var(--blue-ink); }
.vg-svg .vt-n { fill: var(--navy); }
.vg-svg .v-dot { fill: var(--green); filter: drop-shadow(0 0 3px rgba(57, 183, 143, 0.8)); }
.vg-svg .v-head { fill: var(--blue); }
.vg-svg .v-block { fill: var(--blue-soft); stroke: var(--blue); stroke-width: 1.25; }
.vg-svg .v-bar { fill: var(--blue-soft); stroke: var(--blue); stroke-width: 1.25; }
.vg-svg .v-card { fill: var(--surface); stroke: var(--green); stroke-width: 1.25; }
.vg-svg .v-card-i { fill: var(--blue-soft); stroke: var(--blue); stroke-width: 1.25; }
.vg-svg .a-conv { color: var(--star-navy); }
.vg-svg .a-conv rect, .vg-svg .a-conv path { fill: var(--surface); stroke: currentColor; stroke-width: 1.5; }
.vg-svg .a-conv path { fill: none; stroke-opacity: 0.6; }
.vg-svg .v-star .star-b { fill: var(--star-navy); }
.vg-svg .v-star .star-t { fill: var(--green); }
.vg-svg .v-star .star-c { fill: #fff; }

/* ---- Animations: only the ACTIVE step plays (restarts each time) ---- */
.is-active .a-draw  { stroke-dasharray: 1; animation: v-draw 0.7s var(--ease) var(--d, 0s) both; }
.is-active .a-pop   { transform-box: fill-box; transform-origin: center; animation: v-pop 0.4s var(--ease) var(--d, 0s) both; }
.is-active .a-grow  { transform-box: fill-box; transform-origin: left center; animation: v-grow 0.7s var(--ease) var(--d, 0s) both; }
.is-active .a-scan  { animation: v-scan 2.2s ease-in-out 0.2s both; }
.is-active .a-conv  { animation: v-conv 3.3s linear var(--d, 0s) infinite both; }
.is-active .a-orbit { transform-origin: 78px 76px; animation: v-spin 4s linear infinite; }
.is-active .a-ping  { transform-box: fill-box; transform-origin: center; animation: v-ping 4s ease-out infinite; }
.is-active .a-spin  { transform-origin: 56px 76px; animation: v-spin 3s linear infinite; }
.is-active .a-hand  { animation: v-hand 1.1s var(--ease) var(--d, 0s) both; }
.is-active .a-progress { animation: v-progress 3.2s linear 0.15s both; }
.is-active .v-star .star-t { animation: v-tip 0.8s ease 2.1s both; }

/* Resting (not active): each scene shows its finished state. The scan
   line hides, the progress dot sits at the last week, and the hand-over
   items wait on the left until the step plays. */
html.js .flow-step:not(.is-active) .a-scan { opacity: 0; }
html.js .flow-step:not(.is-active) .a-progress { transform: translateX(150px); }   /* rests at the last week */
html.js .flow-step:not(.is-active) .a-conv:not(:first-of-type) { opacity: 0; }
html.js .flow-step:not(.is-active) .a-conv { transform: translateX(150px); color: var(--green); }

@keyframes v-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes v-pop  { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes v-grow { from { transform: scaleX(0); } to { transform: none; } }
@keyframes v-scan { 0% { opacity: 0; transform: translateX(0); } 8% { opacity: 1; } 92% { opacity: 1; } 100% { opacity: 0; transform: translateX(220px); } }
@keyframes v-conv {
  0%   { transform: translateX(-10px); opacity: 0; color: var(--star-navy); }
  8%   { opacity: 1; }
  47%  { color: var(--star-navy); }
  53%  { color: var(--green); }
  90%  { opacity: 1; }
  100% { transform: translateX(215px); opacity: 0; color: var(--green); }
}
@keyframes v-spin { to { transform: rotate(360deg); } }
@keyframes v-ping { 0%, 18% { transform: scale(1); opacity: 0.35; } 25% { transform: scale(1.3); opacity: 1; } 40%, 100% { transform: scale(1); opacity: 0.35; } }
@keyframes v-hand { 0% { transform: none; opacity: 1; } 75% { opacity: 1; } 100% { transform: translate(var(--tx), var(--ty)) scale(0.5); opacity: 0; } }
@keyframes v-progress { from { transform: translateX(0); } to { transform: translateX(150px); } }
@keyframes v-tip { 0% { filter: none; } 50% { filter: drop-shadow(0 0 8px rgba(57,183,143,0.9)); } 100% { filter: drop-shadow(0 0 4px rgba(57,183,143,0.6)); } }
