/* how-we-work.css — "How we work" section: static level-3 markup (works without JavaScript) and its interactive
   enhancement (.hww-ready, set by how-we-work.js). Layout and sizes are identical in both states, so nothing moves
   when the script initialises.
   Source of truth: shared/components/how-we-work/; copied into sites/[site]/assets/css/ by `npm run content:sync`.
   Uses the shared tokens (tokens.css) for light and dark mode.
   Hierarchy: diagram and draggable labels first; reading, call to action and reset second; native controls last. */

/* ---------------------------------------------------------------- layout */
.hww-layout {
  display: grid;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
@media (min-width: 900px) {
  .hww-layout {
    grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr);
  }
  .hww-panel {
    padding-top: 2.4rem; /* align the reading with the diagram rather than the instruction */
  }
}
.hww-stage {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}
.hww-stage .hexagon-diagram {
  max-width: 760px;
}
.hww-instruction {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* parts that only make sense with JavaScript keep their space but stay invisible until the script is ready */
.hww-js-only {
  visibility: hidden;
}
.hww-ready .hww-js-only {
  visibility: visible;
}

/* ---------------------------------------------------------------- diagram */
/* plate behind each label: covers the axis guide where the label sits on it; carries the focus ring */
.label-plate {
  fill: var(--bg);
  fill-opacity: 0.9;
  stroke: none;
}
.condition-label {
  font-family: var(--font-ui);
  fill: var(--ink);
}

.hww-axis {
  opacity: 0;
}
.hww-axis.is-active {
  opacity: 1;
}
.hww-guide {
  stroke: var(--muted);
  stroke-width: 1.2;
  stroke-dasharray: 1 5;
  stroke-linecap: round;
  fill: none;
}
.hww-tick {
  fill: var(--bg);
  stroke: var(--muted);
  stroke-width: 1;
}

.hww-ready .condition {
  cursor: grab;
}
svg.is-dragging,
svg.is-dragging .condition {
  cursor: grabbing;
}
.hww-hit {
  fill: transparent;
  stroke: none;
  touch-action: none; /* only the labels capture touch movement; the rest of the diagram scrolls normally */
}

/* active: hover, drag or keyboard focus — weight and shape change, not colour alone */
.condition.is-active .condition-label {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.hexagon-diagram .condition.is-active .accent-marker {
  fill: var(--accent);
  stroke-width: 2.4;
}
.condition.is-focus .label-plate {
  stroke: var(--ink);
  stroke-width: 2;
}

/* ---------------------------------------------------------------- panel */
.hww-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}
.hww-reading {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.hww-reading-heading {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.hww-interpretation {
  margin: 0;
  max-width: 52ch;
}
.hww-notice {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.hww-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}

/* quiet text buttons (reset, controls toggle) */
.hww-reset,
.hww-toggle {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.hww-reset.is-neutral {
  color: var(--muted);
}
.hww-reset:focus-visible,
.hww-toggle:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- native controls (secondary) */
.hww-details {
  border-top: 1px solid var(--line);
  padding-top: 0.25rem;
}
.hww-toggle {
  color: var(--muted);
}
.hww-toggle[aria-expanded="true"] {
  color: var(--ink);
}
.hww-controls {
  border: 0;
  margin: 0;
  padding: 0.25rem 0 0;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
}
/* collapsed = visually hidden only: the controls stay in the accessibility tree and keyboard order;
   their keyboard focus is shown on the corresponding label in the diagram.
   Default: collapsed from 600 px, open on phones; the toggle overrides it with .is-open / .is-closed. */
.hww-controls,
.hww-controls.is-closed {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  padding: 0;
}
@media (max-width: 599px) {
  .hww-controls:not(.is-closed) {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
    padding: 0.25rem 0 0;
  }
}
.hww-controls.is-open {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
  padding: 0.25rem 0 0;
}

/* stacked: name and level on one line, a full-width quiet track below */
.hww-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name level" "range range";
  align-items: end;
  gap: 0 0.75rem;
  padding-top: 0.35rem;
}
.hww-control .hww-name { grid-area: name; }
.hww-control .hww-level { grid-area: level; }
.hww-control input[type="range"] { grid-area: range; }
.hww-name {
  font-size: 0.85rem;
}
.hww-level {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.hww-control.is-active .hww-name {
  font-weight: 600;
}

/* compact track: thin line with a small dot instead of a heavy bar (same look when disabled without JavaScript) */
.hww-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 44px; /* touch target */
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.hww-control input[type="range"]:disabled {
  cursor: default;
}
.hww-control input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--line);
}
.hww-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}
.hww-control input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--line);
}
.hww-control input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}
.hww-control input[type="range"]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- motion */
/* short, calm transitions only as a response to input; none with reduced motion */
@media (prefers-reduced-motion: no-preference) {
  .hww-ready .inner-hex {
    transition: fill-opacity 250ms ease-out, stroke-opacity 250ms ease-out;
  }
  .condition.is-moving {
    transition: transform 250ms ease-out;
  }
  .hww-axis {
    transition: opacity 150ms ease-out;
  }
}
