/* Pipe counter — page-specific styles.
 * Relies on global tokens (--ink, --ink-soft, --muted, --accent, --bg,
 * --bg-alt, --sans, --mono) and shared classes (.btn-primary, .btn-ghost,
 * .kicker, .section-head). */

/* ---------- How it works ---------- */
.pc-how {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 1.6vw, 18px);
  margin: clamp(16px, 2.2vw, 24px) 0 0;
  padding: 0;
  list-style: none;
}
.pc-how-step {
  position: relative;
  background: var(--bg);
  border: 1px solid rgba(10, 25, 41, 0.12);
  border-radius: 14px;
  padding: 14px 16px 16px;
}
.pc-how-step svg { display: block; width: 100%; max-width: 168px; height: auto; margin: 0 auto 10px; }
.pc-how-n {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  line-height: 26px;
  text-align: center;
}
.pc-how-step h3 { margin: 0 0 4px; font-size: 16px; }
.pc-how-step p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.pc-g-pipe { fill: #0a1929; stroke: #aab6c3; stroke-width: 2.5; }
.pc-g-ring { fill: none; stroke: #2fbf6c; stroke-width: 2; }
.pc-g-num { font: 600 8px/1 var(--mono); fill: #fff; text-anchor: middle; }
.pc-g-box { fill: none; stroke: #e85f00; stroke-width: 3; stroke-linecap: round; }
.pc-g-dot { fill: #5bb0ff; stroke: #fff; stroke-width: 1.5; }
.pc-g-hand { fill: #fff; stroke: #0a1929; stroke-width: 1.6; stroke-linejoin: round; }
.pc-g-phone { fill: #fff; stroke: #0a1929; stroke-width: 2; }
.pc-g-phonedot { fill: #0a1929; }
.pc-g-ray { fill: none; stroke: #e85f00; stroke-width: 2; stroke-linecap: round; }
/* On a phone each step is one compact row, picture on the left. */
@media (max-width: 760px) {
  .pc-how { grid-template-columns: 1fr; gap: 8px; }
  .pc-how-step {
    display: grid;
    grid-template-columns: 96px 1fr;
    column-gap: 14px;
    align-items: center;
    padding: 10px 14px 10px 10px;
  }
  .pc-how-step svg { grid-row: 1 / span 2; margin: 0; }
  .pc-how-step h3 { align-self: end; }
  .pc-how-step p { align-self: start; font-size: 13.5px; }
  .pc-how-n { top: 6px; left: 6px; width: 22px; height: 22px; line-height: 22px; font-size: 12px; }
}

/* ---------- Step 1: the photo ---------- */
.pc-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.pc-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: clamp(150px, 22vh, 220px);
  padding: 28px 20px;
  border: 2px dashed rgba(10, 25, 41, 0.28);
  border-radius: 18px;
  background: var(--bg-alt);
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.pc-pick { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.pc-pick label { cursor: pointer; justify-content: center; min-width: 200px; }
.pc-on-mouse { display: none; }
/* a mouse-and-keyboard computer has no camera button worth showing */
@media (hover: hover) and (pointer: fine) {
  .pc-pick-camera { display: none; }
  .pc-on-touch { display: none; }
  .pc-on-mouse { display: inline; }
  .pc-pick-gallery { background: var(--accent); border-color: var(--accent); color: #fff; }
  .pc-pick-gallery:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; }
}
.pc-drop:hover,
.pc-drop.is-over { border-color: var(--accent); background: var(--bg); }
.pc-start:focus-within .pc-drop { outline: 2px solid var(--accent); outline-offset: 4px; }
.pc-drop-hint { font-size: 14.5px; color: var(--ink-soft); max-width: 36ch; }
.pc-noscript { margin: 14px 0 0; font-size: 14px; color: var(--ink-soft); }

/* ---------- The total ---------- */
.pc-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  min-height: 44px;
  margin-bottom: 12px;
}
.pc-total { display: flex; align-items: baseline; gap: 10px; }
.pc-total[hidden] { display: none; }
.pc-total-n {
  font-family: var(--mono);
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}
.pc-total-word {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.pc-split { margin: 0; font-size: 14.5px; color: var(--ink-soft); }

/* ---------- The stage ---------- */
.pc-stage {
  position: relative;
  border: 1px solid rgba(10, 25, 41, 0.14);
  border-radius: 14px;
  overflow: hidden;
  background: #0a1929;
  line-height: 0;
}
.pc-canvas {
  display: block;
  width: 100%;
  touch-action: none;          /* the stage handles pinch and drag itself */
  -webkit-touch-callout: none; /* press and hold adds a pipe, not the save-image menu */
  -webkit-user-select: none;
  user-select: none;
  cursor: crosshair;
}
/* Zoom sits in the bar above the stage, never over the photo: a button on top of a pipe
   would hide the very thing being checked. */
.pc-zoom {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.pc-zoom-btn {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(10, 25, 41, 0.2);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.pc-zoom-btn:hover { border-color: var(--ink); }
.pc-zoom-fit { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.pc-zoom-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pc-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 25, 41, 0.55);
  color: #fff;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.4;
}
.pc-busy[hidden] { display: none; }

.pc-status {
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* ---------- Actions and legend ---------- */
.pc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.pc-actions[hidden] { display: none; }
.pc-actions button:disabled { opacity: 0.45; cursor: default; }
.pc-actions button[hidden] { display: none; }

.pc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.pc-legend[hidden] { display: none; }
.pc-legend li { display: flex; align-items: center; gap: 8px; }
.pc-key {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0a1929;
}
.pc-key-found { box-shadow: inset 0 0 0 2px #4be08a; }
.pc-key-check { box-shadow: inset 0 0 0 2px #ffb020; }
.pc-key-hand  { background: radial-gradient(circle, #5bb0ff 0 45%, #0a1929 48%); }

/* ---------- Guidance ---------- */
.pc-tips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: clamp(14px, 2vw, 22px);
}
.pc-tip {
  background: var(--bg);
  border: 1px solid rgba(10, 25, 41, 0.12);
  border-radius: 14px;
  padding: clamp(18px, 2vw, 24px);
}
.pc-tip h3 { margin: 0 0 8px; font-size: 17px; }
.pc-tip p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-soft); }
.pc-note {
  margin-top: clamp(18px, 2.5vw, 28px);
  border-left: 3px solid var(--accent);
  background: var(--bg);
  border-radius: 0 12px 12px 0;
  padding: 16px 20px;
  max-width: 78ch;
}
.pc-note p { margin: 0; font-size: 14.5px; line-height: 1.65; color: var(--ink-soft); }

@media (max-width: 700px) {
  .pc-actions > button { flex: 1 1 calc(50% - 5px); justify-content: center; }
  .pc-actions > .btn-primary { flex-basis: 100%; }
}
