:root {
  --bg: #eeecea;
  --surface: #e4e1dd;
  --ink: #333231;
  --muted: #6b6763;
  --accent: #5c6b54;
  --accent-ink: #ffffff;
  --field-1: #cdc3b6;

  --req: #4b5a6b;
  --resp: #5c6b54;
  --alarm: #a13d2b;

  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(2.25rem, 1.3rem + 3.6vw, 4.5rem);

  --m: clamp(16px, 2.4vw, 32px);
  --gap: 8px;
  --r: 4px;
  --sec: clamp(96px, 10vw, 160px);
  --align: 27%;

  --font: "Hanken Grotesk", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: var(--step-body); line-height: 1.5;
  letter-spacing: -0.005em; font-variant-numeric: tabular-nums; overflow-x: hidden;
}
a { color: inherit; }
h1, h2, h3, p, figure { margin: 0; }
h1, h2 { font-weight: 500; letter-spacing: -0.04em; line-height: 0.98; }
p { max-width: 70ch; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--field-1); color: var(--ink); }

/* bar: only the language switch */
.bar { display: flex; justify-content: flex-end; padding: 20px var(--m) 0; }
.lang {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 0; border-radius: var(--r); padding: 8px 14px; cursor: pointer;
  transition: background .2s, transform .2s var(--ease);
}
.lang:hover { background: var(--field-1); }
.lang:active { transform: translateY(1px); }

/* hero */
.hero { padding: clamp(40px, 8vh, 110px) var(--m) clamp(40px, 6vh, 72px); }
.hero-col { margin-left: var(--align); max-width: 900px; }
.hero h1 { font-size: var(--step-head); }
.lead { margin-top: 28px; max-width: 40ch; font-size: var(--step-lead); line-height: 1.4; }

/* route diagram */
.route { padding: 0 var(--m); }
.route-h { margin-left: var(--align); font-size: var(--step-lead); letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 20px; }
.diagram { background: var(--surface); border-radius: var(--r); padding: clamp(12px, 2vw, 28px); }
.diagram svg { display: block; width: 100%; height: auto; }
.route-svg.tall { display: none; }
.diagram text { font-family: var(--font); fill: var(--ink); }
.box { fill: var(--bg); }
.box.mine { fill: var(--accent); }
.inner { fill: #f3f3f2; }
.b-title { font-size: 26px; font-weight: 500; letter-spacing: -0.02em; }
.b-sub { font-size: 16px; fill: var(--muted) !important; }
.on-mine { fill: #ffffff !important; }
.i-title { font-size: 19px; font-weight: 500; }
.b-val { font-size: 44px; font-weight: 500; letter-spacing: -0.02em; }
.b-q { font-size: 17px; font-weight: 500; fill: var(--resp) !important; }
.b-q.alarm { fill: var(--alarm) !important; }
.b-q.bad { fill: var(--muted) !important; }
.wire { stroke: var(--muted); stroke-width: 2.5; fill: none; stroke-dasharray: 7 6; }
.wire-lbl { font-size: 16px; fill: var(--muted) !important; }
.req { fill: var(--req); }
.resp { fill: var(--resp); }
.route-svg.lost .d-live { visibility: hidden; }
.route-svg.lost .b-val { fill: var(--muted); }
/* columns follow the diagram boxes: plant 20-270, gateway 410-870, HMI 980-1180 of 1200 */
.route-cols { display: grid; grid-template-columns: 20fr 250fr 140fr 460fr 110fr 200fr 20fr; margin-top: 24px; padding: 0 clamp(12px, 2vw, 28px); }
.route-cols .rc:nth-child(1) { grid-column: 2; }
.route-cols .rc:nth-child(2) { grid-column: 4; }
.route-cols .rc:nth-child(3) { grid-column: 6; }
.rc h3 { font-size: var(--step-body); font-weight: 500; margin-bottom: 6px; }
.rc p { max-width: 42ch; }

/* replay */
.replay { padding: var(--sec) var(--m) var(--sec); }
.replay-head { margin-left: var(--align); display: flex; flex-direction: column; gap: 14px; }
.replay-head h2 { font-size: var(--step-lead); letter-spacing: -0.02em; line-height: 1.2; }
.replay-head p { max-width: 62ch; }
.scenarios { margin: 24px 0 0 var(--align); display: flex; flex-wrap: wrap; gap: var(--gap); }
.scn {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 0; border-radius: var(--r); padding: 14px 20px; cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 10px;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.scn:hover { background: var(--field-1); transform: translateY(-2px); }
.scn:active { transform: translateY(0); }
.scn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.stage { margin-top: 20px; background: var(--surface); border-radius: var(--r); overflow: hidden; position: relative; aspect-ratio: 16 / 9; }
.stage iframe {
  position: absolute; top: 0; left: 0; width: 1600px; height: 900px; border: 0;
  transform-origin: 0 0; transform: scale(var(--s, .5));
}
.stage-foot { margin-top: 16px; display: flex; justify-content: space-between; align-items: start; gap: 32px; }
.stage-foot .text-link { flex: none; }
.scn-note { margin-left: var(--align); max-width: 62ch; min-height: 3em; }
.text-link { text-decoration: none; font-weight: 500; }
.text-link span[aria-hidden] { display: inline-block; transition: transform .25s var(--ease); }
.text-link:hover span[aria-hidden] { transform: translateX(4px); }

/* entrances: content stays visible unless the script runs */
.js .reveal, .js [data-rise] { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js .reveal.in, .js [data-rise].in { opacity: 1; transform: none; }

@media (max-width: 900px) {
  :root { --align: 0%; }
  .hero { padding-top: 12vh; }
  .route-cols { grid-template-columns: 1fr; gap: 20px; padding: 0; }
  .route-cols .rc:nth-child(n) { grid-column: 1; }
  .route-svg.wide { display: none; }
  .route-svg.tall { display: block; max-width: 420px; margin: 0 auto; }
  .stage-foot { flex-direction: column; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .js .reveal, .js [data-rise] { opacity: 1; transform: none; }
}
