/* Hereworks page: device-to-cloud infographic, normalise/validate diagram.
   Colours come from the theme tokens only, so dark mode follows css/styles.css. */

.hw-section { scroll-margin-top: 90px; }
.hw-section .section-title { margin-bottom: 28px; }

/* Icon strokes and fills shared by every inline SVG on the page */
.hw-icon svg, .hw-role-icon svg, .hw-band-icon svg, .hw-checks svg, .hw-norm-arrow svg { display: block; width: 100%; height: 100%; overflow: visible; }
.i-fill { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.i-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.i-dot { fill: var(--accent); }
.i-tick { fill: none; stroke: var(--accent-dark); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* Roles */
.hw-roles { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; padding: 0; list-style: none; }
.hw-roles li { display: inline-flex; align-items: center; gap: 10px; padding: 8px 16px 8px 9px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 650; }
.hw-role-icon { width: 30px; height: 30px; flex: none; }

/* Device to cloud flow */
.hw-flow-wrap { position: relative; }
.hw-flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 26px; margin: 0; padding: 0; list-style: none; counter-reset: none; }
.hw-stage { position: relative; min-width: 0; padding: 18px 16px 18px; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius-small); background: var(--surface); box-shadow: var(--shadow-small); }
.hw-stage + .hw-stage::before { content: ""; position: absolute; top: 46px; left: -24px; width: 22px; height: 2px; background: var(--accent); }
.hw-stage + .hw-stage::after { content: ""; position: absolute; top: 42px; left: -9px; border: 5px solid transparent; border-left: 7px solid var(--accent); }
.hw-stage-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hw-icon { width: 46px; height: 46px; }
.hw-step { color: var(--muted); font-family: var(--mono); font-size: .78rem; font-weight: 700; letter-spacing: .08em; }
.hw-stage-label { margin: 0 0 2px; color: var(--accent-dark); font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.hw-stage h3 { margin: 0 0 12px; font-size: 1.08rem; letter-spacing: -.01em; }
.hw-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.hw-chips li { padding: 3px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--ink-soft); font-size: .8rem; line-height: 1.5; }

.hw-band { display: flex; align-items: center; gap: 12px; margin: 18px 0 0; padding: 12px 18px; border: 1px dashed var(--accent); border-radius: var(--radius-small); background: var(--accent-soft); color: var(--ink); font-weight: 650; }
.hw-band-icon { width: 28px; height: 28px; flex: none; }

/* Normalise and validate */
.hw-norm { display: grid; grid-template-columns: minmax(0, 1fr) 110px minmax(0, 1.1fr) minmax(0, 1.3fr); gap: 22px; align-items: center; }
.hw-col-label { margin: 0 0 10px; color: var(--muted); font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.hw-norm-in { display: grid; gap: 10px; }
.hw-norm-in code { display: block; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-small); background: var(--surface); color: var(--ink-soft); font-family: var(--mono); font-size: .9rem; }
.hw-norm-arrow { height: 150px; margin-top: 22px; }
.hw-norm-arrow .i-line { stroke-width: 2; vector-effect: non-scaling-stroke; }
.hw-point { padding: 18px; border: 2px solid var(--accent); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-small); }
.hw-point code { display: block; margin-bottom: 10px; color: var(--accent-dark); font-family: var(--mono); font-size: .98rem; font-weight: 700; overflow-wrap: anywhere; }
.hw-point span { display: inline-block; margin: 0 6px 0 0; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-family: var(--mono); font-size: .8rem; font-weight: 700; }
.hw-checks ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.hw-checks li { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.hw-checks svg { width: 24px; height: 24px; flex: none; }
.hw-note { margin: 26px 0 0; color: var(--muted); font-family: var(--mono); font-size: .74rem; line-height: 1.6; }

/* At home */
.hw-home { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 40px; align-items: end; }
.hw-home .section-title { margin-bottom: 0; }
.hw-home > p { max-width: 58ch; margin: 0; color: var(--ink-soft); font-size: 1.05rem; line-height: 1.7; }
.hw-home a { color: var(--accent-dark); font-weight: 650; }

/* UDMI: site model tree */
.hw-udmi { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 40px; align-items: start; margin-bottom: 34px; }
.hw-tree, .hw-tree ul { margin: 0; padding: 0; list-style: none; }
.hw-tree ul { position: relative; margin-left: 15px; padding-left: 20px; border-left: 2px solid var(--line-strong); }
.hw-tree li { position: relative; padding-top: 10px; }
.hw-tree ul > li::before { content: ""; position: absolute; top: 27px; left: -20px; width: 16px; height: 2px; background: var(--line-strong); }
.hw-tree ul > li:last-child::after { content: ""; position: absolute; top: 28px; bottom: 0; left: -22px; width: 2px; background: var(--paper); }
.hw-t-node { display: inline-flex; align-items: center; gap: 10px; padding: 7px 14px 7px 8px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 650; }
.hw-t-node b { padding: 2px 8px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
.hw-t-node.is-main { border: 2px solid var(--accent); }
.hw-t-node.is-main b { background: var(--accent-soft); color: var(--accent-dark); }
.hw-t-type { display: block; margin: 6px 0 0 4px; color: var(--muted); font-family: var(--mono); font-size: .74rem; overflow-wrap: anywhere; }
.hw-t-point { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.hw-t-point code { color: var(--accent-dark); font-family: var(--mono); font-size: .86rem; font-weight: 700; overflow-wrap: anywhere; }
.hw-t-chips { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.hw-t-chips span { padding: 2px 8px; border-radius: 999px; background: var(--surface-soft); color: var(--ink-soft); font-family: var(--mono); font-size: .72rem; }
.hw-t-chips span:first-child { background: var(--panel); color: var(--on-panel); }

/* UDMI: messages between device and cloud */
.hw-lanes { display: grid; grid-template-columns: 96px minmax(0, 1fr) 96px; align-items: center; gap: 0; }
.hw-end { display: grid; justify-items: center; gap: 2px; padding: 14px 6px; border: 1px solid var(--line-strong); border-radius: var(--radius-small); background: var(--surface); text-align: center; }
.hw-end-icon { width: 40px; height: 40px; }
.hw-end-icon svg { display: block; width: 100%; height: 100%; }
.hw-end strong { font-size: .95rem; }
.hw-end span:last-child { color: var(--muted); font-family: var(--mono); font-size: .7rem; }
.hw-lane-set { display: grid; gap: 18px; padding: 0 6px; }
.hw-lane { position: relative; height: 2px; margin: 12px 0 0; background: var(--accent); }
.hw-lane::after { content: ""; position: absolute; top: -5px; border: 6px solid transparent; }
.hw-lane.is-up::after { right: -2px; border-left: 9px solid var(--accent); }
.hw-lane.is-down { background: var(--g-hardware); }
.hw-lane.is-down::after { left: -2px; border-right: 9px solid var(--g-hardware); }
.hw-lane span { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); padding: 1px 8px; border-radius: 999px; background: var(--paper); color: var(--ink); font-family: var(--mono); font-size: .74rem; font-weight: 700; white-space: nowrap; }
.hw-lane-key { display: grid; gap: 6px; margin: 18px 0 0; padding: 0; list-style: none; color: var(--ink-soft); font-size: .92rem; }
.hw-lane-key b { margin-right: 6px; color: var(--ink); font-family: var(--mono); font-size: .8rem; }

/* UDMI: JSON panels. Panels stay dark in both themes, so the syntax colours are fixed. */
.hw-codes { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.hw-code-col { display: grid; gap: 18px; min-width: 0; }
.hw-code { display: flex; flex-direction: column; min-width: 0; margin: 0; border: 1px solid var(--panel-line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-small); overflow: hidden; }
.hw-code figcaption { display: flex; justify-content: space-between; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--panel-line); }
.hw-code-name { color: var(--on-panel); font-family: var(--mono); font-size: .8rem; font-weight: 700; }
.hw-code-name::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 9px; border-radius: 50%; background: #8fb8ff; vertical-align: 1px; }
.hw-code.is-down .hw-code-name::before { background: #f0a372; }
.hw-code.is-model .hw-code-name::before { background: #a8d88a; }
.hw-code.is-dbo .hw-code-name::before { background: #e99ac4; }
.hw-code-topic { color: var(--on-panel-soft); font-family: var(--mono); font-size: .72rem; }
.hw-code pre { flex: 1; max-height: 560px; margin: 0; padding: 14px 16px; overflow: auto; color: #d8cfc2; font-family: var(--mono); font-size: .76rem; line-height: 1.6; tab-size: 2; }
.hw-code p { margin: 0; padding: 10px 16px 13px; border-top: 1px solid var(--panel-line); color: var(--on-panel-soft); font-size: .84rem; line-height: 1.5; }
.j-key { color: #d8cfc2; }
.j-dbo { color: #8fb8ff; font-weight: 700; }
.j-str { color: #f0b37e; }
.j-num { color: #a8d88a; }
.j-lit { color: #e99ac4; }
.j-p { color: #8a8276; }

/* Tablet and phone: the flow runs downwards, one stage per row */
@media (max-width: 1040px) {
  .hw-flow { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .hw-stage { display: grid; grid-template-columns: 52px minmax(0, 0.9fr) minmax(0, 1.3fr); grid-template-areas: "top label chips" "top title chips"; column-gap: 16px; align-items: center; padding: 14px 18px; border-top-width: 1px; border-left: 3px solid var(--accent); }
  .hw-stage-top { grid-area: top; flex-direction: column; gap: 4px; margin: 0; }
  .hw-stage-label { grid-area: label; align-self: end; }
  .hw-stage h3 { grid-area: title; align-self: start; margin: 0; }
  .hw-chips { grid-area: chips; }
  .hw-stage + .hw-stage::before { top: -21px; left: 42px; width: 2px; height: 18px; }
  .hw-stage + .hw-stage::after { top: -10px; left: 38px; border: 5px solid transparent; border-top: 7px solid var(--accent); }
  .hw-norm { grid-template-columns: minmax(0, 1fr) 80px minmax(0, 1fr); }
  .hw-checks { grid-column: 1 / -1; }
  .hw-checks ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hw-udmi { grid-template-columns: minmax(0, 1fr); gap: 30px; }
  .hw-codes { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 700px) {
  .hw-stage { grid-template-columns: 52px minmax(0, 1fr); grid-template-areas: "top label" "top title" "top chips"; row-gap: 2px; }
  .hw-chips { margin-top: 8px; }
  .hw-norm { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .hw-norm-arrow { width: 54px; height: 54px; margin: 0; justify-self: center; transform: rotate(90deg); }
  .hw-checks ul { grid-template-columns: minmax(0, 1fr); }
  .hw-home { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .hw-lanes { grid-template-columns: 74px minmax(0, 1fr) 74px; }
  .hw-tree ul { margin-left: 10px; padding-left: 14px; }
  .hw-tree ul > li::before { left: -14px; width: 11px; }
  .hw-tree ul > li:last-child::after { left: -16px; }
  .hw-t-point code { font-size: .72rem; }
  .hw-code pre { font-size: .7rem; }
}
