/* ==========================================================================
   CERVINO Management Group — pages.css
   Inner pages: rail hero + sticky line map, scroll-drawn figures, process
   rails, industry explorer, network flow stages, and the Arrival terminus.
   Builds on main.css tokens and figure primitives.
   ========================================================================== */

html.has-linemap { scroll-padding-top: calc(64px + 72px + 12px); }

/* Room at the bottom of the hero for the line map to sit on */
.rail-hero { padding-bottom: calc(clamp(3.5rem, 8vw, 6rem) + 64px); }

/* ---------- Line map: the hero's rail, then a sticky section map ---------- */

.linemap {
  position: sticky;
  top: 64px;
  z-index: 80;
  height: 72px;
  margin-top: -72px;
  color: var(--on-dark-muted);
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
              box-shadow var(--speed) var(--ease);
}

.linemap.is-static { position: relative; top: auto; }

.linemap.stuck {
  background: rgba(250, 249, 246, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 1px 0 var(--hairline);
  color: var(--ink-muted);
}

.linemap-inner {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.linemap-current {
  display: none;
  flex: none;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--copper);
  white-space: nowrap;
}

.linemap-track {
  position: relative;
  flex: 1;
  height: 100%;
}

/* Ties + twin rails, drawn in from the left on load */
.linemap-rail,
.linemap-fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 22px;
  height: 12px;
  transform-origin: left center;
}

.linemap-rail {
  background:
    linear-gradient(var(--copper), var(--copper)) 0 2px / 100% 1.5px no-repeat,
    linear-gradient(var(--copper), var(--copper)) 0 8.5px / 100% 1.5px no-repeat,
    repeating-linear-gradient(90deg, rgba(176, 141, 87, 0.45) 0 2.4px, transparent 2.4px 10px);
  opacity: 0.55;
  transform: scaleX(0);
  animation: railLay 1.6s var(--ease) 0.25s forwards;
}

.linemap-fill {
  right: auto;
  width: 100%;
  top: 25px;
  height: 6px;
  border-radius: 3px;
  background: var(--copper);
  transform: scaleX(var(--fill, 0));
  box-shadow: 0 0 12px rgba(176, 141, 87, 0.45);
  transition: transform 0.25s linear;
}

@keyframes railLay { to { transform: scaleX(1); } }

.linemap-stops {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
}

.linemap-stops li { position: relative; width: 0; }

.linemap-stops a {
  position: absolute;
  top: 16px;
  left: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  opacity: 0;
  animation: stopIn 0.5s var(--ease) forwards;
  animation-delay: calc(0.5s + var(--i) * 0.09s);
}

.linemap-stops li:first-child a { transform: none; align-items: flex-start; }
.linemap-stops li:last-child a { transform: translateX(-100%); align-items: flex-end; }

@keyframes stopIn { to { opacity: 1; } }

.linemap-stops i {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.linemap-stops i::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--copper);
  background: var(--navy);
  transition: background 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.linemap.stuck .linemap-stops i::before { background: var(--bg); }

.linemap-stops a.passed i::before { background: var(--copper); }
.linemap-stops a.current i::before {
  background: var(--copper-soft);
  transform: scale(1.25);
  box-shadow: 0 0 0 5px rgba(176, 141, 87, 0.2), 0 0 14px rgba(176, 141, 87, 0.55);
}

.linemap-stops span {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color var(--speed) var(--ease);
}
.linemap-stops a:hover span,
.linemap-stops a.current span { color: var(--copper-soft); }
.linemap.stuck .linemap-stops a:hover span,
.linemap.stuck .linemap-stops a.current span { color: var(--copper); }

/* ---------- Station eyebrow numbering ---------- */

.stop-num {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--copper);
}

/* ---------- Services: illustration under each description ---------- */

.detail-side .st-figure { margin-top: 1.8rem; }
.detail-block { scroll-margin-top: 150px; }

/* Transload: a load moves from railcar to truck */
.xfer-load {
  --lift: calc(-50 * sin(var(--p, 1) * 180deg) + 4 * var(--p, 1));
  transform: translate(calc(var(--p, 1) * 290px), calc(var(--lift) * 1px));
}
.fig-hub-card svg { max-width: 260px; margin-inline: auto; }
.fig-arc { stroke: var(--copper); stroke-opacity: 0.45; stroke-dasharray: 4 5; }

/* Coordination: messages travel between parties */
.coord-node { fill: var(--bg-white); stroke: var(--navy); stroke-width: 1.5; }
.coord-hub { fill: var(--navy); }
.coord-mark { stroke: var(--copper-soft); stroke-width: 1.5; stroke-linejoin: round; fill: none; }
.coord-node-on { opacity: clamp(0.25, calc(var(--p, 1) * 2.2 - 0.6), 1); transition: opacity 0.2s linear; }

/* Cost reduction: spend bars step down */
.cut-bar {
  fill: var(--steel);
  fill-opacity: 0.3;
  transform-box: fill-box;
  transform-origin: bottom;
}
.cut-bar-new {
  fill: var(--copper);
  transform-box: fill-box;
  transform-origin: bottom;
  transform: scaleY(calc(1 - var(--p, 1) * var(--cut)));
}

/* ---------- Process rail (services engagement, contact + partner next steps) ---------- */

.process {
  --n: 4;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: clamp(1.2rem, 3vw, 2.5rem);
  padding-top: 2.2rem;
}

.process::before,
.process::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: 2px;
  background: var(--hairline);
}
.process::after {
  background: var(--copper);
  transform-origin: left;
  transform: scaleX(var(--p, 1));
}

.process-step {
  position: relative;
  opacity: clamp(0.35, calc(var(--p, 1) * (var(--n) + 0.6) - var(--i)), 1);
}

.process-step::before {
  content: "";
  position: absolute;
  top: -2.2rem;
  left: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--copper);
  box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 11px var(--copper);
}
.section-white .process-step::before { background: var(--bg-white); box-shadow: inset 0 0 0 4px var(--bg-white), inset 0 0 0 11px var(--copper); }

.process-step h3 {
  font-size: 1.2rem;
  color: var(--navy);
  margin: 0.35rem 0 0.5rem;
}
.process-step p { color: var(--ink-soft); font-size: 0.9375rem; }

/* Vertical variant (narrow columns) */
.process-vertical {
  grid-template-columns: 1fr;
  padding-top: 0;
  padding-left: 2.4rem;
  gap: 1.6rem;
}
.process-vertical::before,
.process-vertical::after {
  top: 10px;
  bottom: 10px;
  left: 10px;
  right: auto;
  width: 2px;
  height: auto;
}
.process-vertical::after { transform-origin: top; transform: scaleY(var(--p, 1)); }
.process-vertical .process-step::before { top: 0.1rem; left: -2.4rem; }
.process-vertical .process-step h3 { margin-top: 0; }

/* ---------- Network: sticky flow diagram driven by scroll steps ---------- */

.flow-story {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
  gap: clamp(2rem, 5vw, 4.5rem);
}

.flow-sticky {
  position: sticky;
  top: calc(64px + 72px + 24px);
  align-self: start;
}

.flow-sticky .flow-wrap { overflow: visible; }
.flow-sticky .flow-wrap svg { min-width: 0; }

.flow-steps { display: grid; gap: 0; }

.flow-step {
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0.35;
  transition: opacity 0.4s var(--ease);
}
.flow-step:first-child { min-height: 40vh; justify-content: flex-start; padding-top: 3rem; }
.flow-step:last-child { min-height: 52vh; }
.flow-step.active { opacity: 1; }
.flow-step h3 { color: var(--navy); margin: 0.4rem 0 0.7rem; }
.flow-step p { color: var(--ink-soft); }

/* Stages dim until reached; the active stage's routes animate */
.flow-stage .stg { transition: opacity 0.6s var(--ease); opacity: 0.12; }
.flow-stage[data-stage="1"] .stg-1,
.flow-stage[data-stage="2"] .stg-1, .flow-stage[data-stage="2"] .stg-2,
.flow-stage[data-stage="3"] .stg-1, .flow-stage[data-stage="3"] .stg-2, .flow-stage[data-stage="3"] .stg-3,
.flow-stage[data-stage="4"] .stg { opacity: 1; }

.flow-stage .flow-route { animation-play-state: paused; }
.flow-stage[data-stage="2"] .stg-2 .flow-route,
.flow-stage[data-stage="3"] .stg-3 .flow-route,
.flow-stage[data-stage="4"] .stg-4 .flow-route { animation-play-state: running; }

/* Solution cards with icons */
.card .sol-icon { width: 30px; height: 30px; color: var(--copper); margin-bottom: 1.1rem; }

/* ---------- Industries explorer ---------- */

.explorer {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.6fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}

.explorer-list {
  position: sticky;
  top: calc(64px + 72px + 24px);
  display: grid;
  gap: 0.35rem;
  border-left: 2px solid var(--hairline);
  padding-left: 0;
}

.explorer-tab {
  position: relative;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1.1rem 0.85rem 1.4rem;
  margin-left: -2px;
  border-left: 2px solid transparent;
  font-weight: 500;
  font-size: 0.9688rem;
  color: var(--ink-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: color var(--speed) var(--ease), background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.explorer-tab .stop-num { font-size: 0.8rem; opacity: 0.7; }
.explorer-tab:hover { color: var(--navy); background: rgba(176, 141, 87, 0.06); }
.explorer-tab[aria-selected="true"] {
  color: var(--navy);
  font-weight: 600;
  background: var(--copper-dim);
  border-left-color: var(--copper);
}
.explorer-tab:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

.explorer-panel {
  position: relative;
  background: var(--bg-white);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: clamp(1.8rem, 4vw, 3rem);
  box-shadow: 0 30px 60px -45px rgba(14, 27, 44, 0.3);
  overflow: hidden;
}
.explorer-panel + .explorer-panel { margin-top: 1.2rem; }

.explorer-panel .panel-icon { width: 56px; height: 56px; color: var(--copper); margin-bottom: 1.4rem; }
.explorer-panel .panel-watermark {
  position: absolute;
  right: -30px;
  bottom: -40px;
  width: 240px;
  height: 240px;
  color: var(--copper);
  opacity: 0.06;
  pointer-events: none;
}
.explorer-panel h2 { color: var(--navy); font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0.4rem 0 1rem; }
.explorer-panel > p { color: var(--ink-soft); font-size: var(--text-body-lg); line-height: 1.7; max-width: 38em; }

.tag-label {
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  font-size: var(--text-eyebrow);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.tags { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.tags li {
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--slate);
}

/* Enhanced (JS) desktop: one panel at a time */
@media (min-width: 901px) {
  .explorer.is-enhanced .explorer-panel { display: none; }
  .explorer.is-enhanced .explorer-panel.active { display: block; animation: panelIn 0.45s var(--ease); }
  .explorer.is-enhanced .explorer-panel + .explorer-panel { margin-top: 0; }
}
@keyframes panelIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- About: editorial statement that fills in as you scroll ---------- */

.scrub-text {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3.6vw, 2.9rem);
  line-height: 1.28;
  letter-spacing: -0.015em;
  color: var(--navy);
  max-width: 24em;
}
.scrub-text .w { opacity: 0.16; transition: opacity 0.25s linear; }
.scrub-text .w.on { opacity: 1; }
.scrub-text em { color: var(--copper); font-style: italic; }

/* Mission + positioning */
.pillars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--hairline);
}
.pillar { padding: clamp(2rem, 4vw, 3.2rem) clamp(0rem, 3vw, 3rem) 0 0; }
.pillar + .pillar { border-left: 1px solid var(--hairline); padding-left: clamp(1.5rem, 3vw, 3rem); }
.pillar h2 { color: var(--navy); font-size: clamp(1.7rem, 2.8vw, 2.3rem); margin-bottom: 1.1rem; }
.pillar p { color: var(--ink-soft); font-size: var(--text-body-lg); line-height: 1.7; }

/* Values as stations on a rail */
.values-rail {
  --gap: clamp(1rem, 3vw, 2.5rem);
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2.6rem var(--gap);
}
/* Rail segment from each station to the next one in its row */
.value-stop::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 22px;
  right: calc(-1 * var(--gap));
  height: 2px;
  background: linear-gradient(90deg, var(--copper) calc(var(--on) * 100%), var(--hairline) 0);
}
.value-stop:nth-child(4n)::after { display: none; }
.value-stop {
  position: relative;
  padding-top: 2.4rem;
  --on: clamp(0, calc(var(--p, 1) * 9.5 - var(--i)), 1);
}
.value-stop::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--copper);
  background: var(--bg);
  box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 11px rgba(176, 141, 87, var(--on));
}
.value-stop .stop-num { display: block; margin-bottom: 0.4rem; opacity: calc(0.4 + var(--on) * 0.6); }
.value-stop h3 {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--navy);
  opacity: calc(0.35 + var(--on) * 0.65);
  min-height: 2.6em;
}

/* ---------- Contact + partner ---------- */

.schedule-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.8fr);
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}
.next-steps h2 { font-size: clamp(1.5rem, 2.4vw, 1.9rem); color: var(--navy); margin-bottom: 1.8rem; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.3rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--bg-white);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--slate);
}
.chip svg { width: 18px; height: 18px; color: var(--copper); }

.form-head { max-width: 880px; margin: 0 auto 2.2rem; }
.form-head h2 { color: var(--navy); margin-bottom: 0.8rem; }

/* ---------- Arrival terminus (inner pages) ---------- */

.arrival-inner { padding-top: calc(var(--section-pad) * 0.8); }
.arrival-inner .container { position: relative; z-index: 2; }

.terminus-line {
  position: relative;
  height: 64px;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}
.terminus-line .t-rail {
  position: absolute;
  left: 0;
  right: 70px;
  top: 16px;
  height: 12px;
  background:
    linear-gradient(var(--copper), var(--copper)) 0 2px / 100% 1.5px no-repeat,
    linear-gradient(var(--copper), var(--copper)) 0 8.5px / 100% 1.5px no-repeat,
    repeating-linear-gradient(90deg, rgba(176, 141, 87, 0.5) 0 2.4px, transparent 2.4px 10px);
  transform-origin: left;
  transform: scaleX(var(--p, 1));
}
.terminus-line .t-platform {
  position: absolute;
  right: 40px;
  top: 36px;
  width: min(360px, 60%);
  height: 8px;
  border-radius: 2px;
  background: rgba(176, 141, 87, 0.16);
  border: 1px solid rgba(176, 141, 87, 0.45);
  opacity: clamp(0, calc(var(--p, 1) * 3 - 2), 1);
}
.terminus-line .t-buffer {
  position: absolute;
  right: 58px;
  top: 10px;
  width: 3px;
  height: 24px;
  border-radius: 2px;
  background: var(--copper-soft);
  box-shadow: 4px -5px 0 -1px var(--copper-soft), 4px 5px 0 -1px var(--copper-soft);
  opacity: clamp(0, calc(var(--p, 1) * 4 - 3), 1);
}
.terminus-line .t-label {
  position: absolute;
  right: 40px;
  top: 50px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--copper-soft);
  opacity: clamp(0, calc(var(--p, 1) * 3 - 2), 1);
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .values-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .value-stop:nth-child(2n)::after { display: none; }
}

@media (max-width: 900px) {
  .flow-story,
  .explorer,
  .schedule-grid,
  .pillars { grid-template-columns: 1fr; }
  .pillar + .pillar { border-left: none; border-top: 1px solid var(--hairline); padding-left: 0; }
  .flow-sticky { position: relative; top: auto; }
  .flow-sticky .flow-wrap svg { min-width: 640px; }
  .flow-sticky .flow-wrap { overflow-x: auto; }
  .flow-step, .flow-step:first-child, .flow-step:last-child { min-height: 0; padding: 1.4rem 0; opacity: 1; }
  .explorer-list { display: none; }
  .process:not(.process-vertical) { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 3.2rem; }
  .process:not(.process-vertical)::before,
  .process:not(.process-vertical)::after { display: none; }
}

@media (max-width: 820px) {
  .linemap-stops span { display: none; }
  .linemap-current { display: block; }
  .linemap-stops li:first-child a,
  .linemap-stops li:last-child a { transform: translateX(-50%); align-items: center; }
  .linemap-stops li:first-child a { transform: none; }
  .linemap-stops li:last-child a { transform: translateX(-100%); }
}

@media (max-width: 600px) {
  .process:not(.process-vertical) { grid-template-columns: 1fr; }
  .values-rail { grid-template-columns: 1fr; gap: 1.4rem; }
  .value-stop { padding-top: 0; padding-left: 2.2rem; }
  .value-stop::after { display: none; }
  .value-stop h3 { min-height: 0; }
  .terminus-line .t-platform { width: 55%; }
}

/* ---------- Reduced motion: everything drawn, nothing moves ---------- */

@media (prefers-reduced-motion: reduce) {
  .linemap-rail { animation: none; transform: none; }
  .linemap-stops a { animation: none; opacity: 1; }
  .scrub-text .w { opacity: 1; }
  .flow-step { opacity: 1; }
  .flow-stage .stg { opacity: 1; }
}
