/* screen-path.css — owner: js/screens/path.js
   Only .scr-path-* class names live here. Every colour is a token from css/base.css.

   Geometry contract shared with path.js:
     --step  distance between node centres            (JS: STEP)
     --pad   space above the first / below the last    (JS: PAD)
     --i     row index of a node inside its unit       (set inline by JS)
     --dx    horizontal offset, % of the track width   (set inline by JS)
     --nh    half a node's width, so nodes can clamp themselves off the gutters
   Nodes are positioned from their top-left corner (left/top already subtract --nh)
   rather than with translate(-50%,-50%), which keeps `transform` free for the press
   and for .a-shake. */

.scr-path{
  display:flex; flex-direction:column; gap:var(--sp-4);
  padding-block:var(--sp-4) var(--sp-7);
}

/* ============================================================ daily goal === */

.scr-path-goal{
  display:flex; align-items:center; gap:var(--sp-3);
  padding:var(--sp-3) var(--sp-4);
}
.scr-path-goal-ring{
  --ring-size:46px; --ring-w:4.4px;
  position:relative; flex:0 0 auto;
  width:var(--ring-size); height:var(--ring-size);
}
.scr-path-goal-num{
  position:absolute; inset:0;
  display:grid; place-items:center;
  font-size:14px; font-weight:800; line-height:1; color:var(--ink);
}
.scr-path-goal-copy{ min-width:0; }
.scr-path-goal-line{ font-size:16px; font-weight:800; line-height:1.25; }
.scr-path-goal.is-met .scr-path-goal-line{ color:var(--ok); }
.scr-path-goal-sub{ margin-top:2px; }

/* ====================================================== finished / empty === */

.scr-path-done,
.scr-path-empty{
  display:flex; flex-direction:column; align-items:center; gap:var(--sp-3);
  padding:var(--sp-5) var(--sp-4);
}
.scr-path-done{ background:var(--brand-soft); border-color:var(--brand); }
.scr-path-done-title{ line-height:1.2; }
.scr-path-done-copy{ max-width:30ch; }

/* ================================================================= units === */

.scr-path-unit{ display:block; }
.scr-path-unit + .scr-path-unit{ margin-top:var(--sp-5); }

.scr-path-banner{
  position:sticky;
  top:calc(var(--topbar-h) + env(safe-area-inset-top));
  z-index:20;
  display:flex; align-items:center; gap:var(--sp-3);
  padding:var(--sp-3) var(--sp-4);
  background:color-mix(in srgb, var(--accent) 13%, var(--surface));
  border:2px solid color-mix(in srgb, var(--accent) 34%, var(--surface));
  border-left-width:6px; border-left-color:var(--accent);
  border-radius:var(--r-lg);
  /* the cream halo hides nodes sliding under the banner while it is stuck */
  box-shadow:0 0 0 6px var(--bg), var(--shadow-sm);
}
.scr-path-banner-icon{
  flex:0 0 auto;
  width:44px; height:44px;
  display:grid; place-items:center;
  font-size:22px; line-height:1;
  background:var(--accent);
  border-radius:var(--r-md);
  box-shadow:inset 0 -3px 0 color-mix(in srgb, var(--accent) 66%, var(--ink));
}
.scr-path-banner-copy{ min-width:0; }
.scr-path-banner-eyebrow{
  display:flex; align-items:center; flex-wrap:wrap; gap:5px;
  color:color-mix(in srgb, var(--accent) 52%, var(--ink));
}
.scr-path-banner-dot{ opacity:.6; }
.scr-path-banner-lock{ font-size:10px; letter-spacing:0; }
.scr-path-banner-title{ font-size:19px; font-weight:800; line-height:1.25; color:var(--ink); }
.scr-path-banner-desc{
  display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden;
  margin-top:1px;
  font-size:13px; font-weight:600; line-height:1.35; color:var(--ink-soft);
}
.scr-path-unit.is-locked .scr-path-banner-icon{ filter:grayscale(.6); opacity:.85; }

/* ================================================== the serpentine track === */

.scr-path-track{
  --step:104px;
  --pad:26px;
  position:relative;
  height:calc(var(--rows) * var(--step) + var(--pad) * 2);
  margin-top:var(--sp-2);
}

.scr-path-line{
  position:absolute; left:0; top:0; z-index:0;
  pointer-events:none; overflow:visible;
}
.scr-path-line-track,
.scr-path-line-done{
  fill:none;
  stroke-width:7; stroke-linecap:round; stroke-linejoin:round;
  stroke-dasharray:.5 17;
}
.scr-path-line-track{ stroke:var(--line); }
.scr-path-line-done { stroke:color-mix(in srgb, var(--accent) 55%, var(--bg)); }

/* ================================================================= nodes === */

.scr-path-node{
  --nh:36px;
  --node-bg:var(--locked);
  --node-edge:var(--locked-ink);
  --node-fg:var(--surface);

  position:absolute; z-index:1;
  width:calc(var(--nh) * 2); height:calc(var(--nh) * 2);
  left:calc(clamp(var(--nh), calc(50% + var(--dx)), calc(100% - var(--nh))) - var(--nh));
  top:calc(var(--pad) + (var(--i) + .5) * var(--step) - var(--nh));

  display:grid; place-items:center;
  color:var(--node-fg);
  background:var(--node-bg); background-clip:padding-box;
  border:0; border-radius:var(--r-pill);
  box-shadow:0 5px 0 var(--node-edge);
  transform:translateY(0);
  transition:transform .07s ease-out, box-shadow .07s ease-out;
  cursor:pointer; user-select:none; -webkit-user-select:none;
  -webkit-tap-highlight-color:transparent; touch-action:manipulation;
}
.scr-path-node:active:not(.is-locked){
  transform:translateY(5px);
  box-shadow:0 0 0 var(--node-edge);
}
.scr-path-node.is-locked{ cursor:default; --node-fg:var(--locked-ink); }

.scr-path-node.is-done   { --node-bg:var(--accent); --node-edge:color-mix(in srgb, var(--accent) 62%, var(--ink)); }
.scr-path-node.is-current{ --node-bg:var(--brand);  --node-edge:var(--brand-dark); }
.scr-path-node.is-open   { --node-bg:var(--gold);   --node-edge:color-mix(in srgb, var(--gold) 58%, var(--ink)); }

.scr-path-node.is-summit{ --nh:44px; }
.scr-path-node.is-chest { --nh:32px; border-radius:var(--r-lg); }

@media (hover:hover){
  .scr-path-node:not(.is-locked):hover{ filter:brightness(1.06); }
}

.scr-path-node-face{
  font-size:28px; font-weight:800; line-height:1;
  pointer-events:none;
}
.scr-path-node.is-done  .scr-path-node-face{ font-size:34px; }
.scr-path-node.is-summit .scr-path-node-face{ font-size:36px; }
.scr-path-node.is-chest .scr-path-node-face{ font-size:26px; }

/* pulsing ring — the current node. Inert (but still visible) under reduced motion. */
.scr-path-node-ring{
  display:none; position:absolute; inset:-7px;
  border:3px solid var(--brand); border-radius:inherit;
  pointer-events:none;
}
.scr-path-node.is-current .scr-path-node-ring{ display:block; }

/* trophy ring — a finished summit */
.scr-path-node-crown{
  display:none; position:absolute; inset:-6px;
  border:4px solid var(--gold); border-radius:inherit;
  pointer-events:none;
}
.scr-path-node.is-summit.is-done .scr-path-node-crown{ display:block; }

/* stars earned, hung off the bottom rim */
.scr-path-node-stars{
  --star-size:10px;
  position:absolute; top:calc(100% - 1px); left:50%;
  transform:translateX(-50%);
  gap:1px; padding:2px 6px;
  background:var(--surface);
  border:2px solid var(--line); border-radius:var(--r-pill);
  pointer-events:none;
}
.scr-path-node-stars[hidden]{ display:none; }

/* bobbing START bubble above the current node */
.scr-path-start{
  display:none; position:absolute; left:50%; bottom:calc(100% + 12px);
  transform:translateX(-50%);
  pointer-events:none;
}
.scr-path-node.is-current .scr-path-start{ display:block; }
.scr-path-start-bubble{
  position:relative; display:block;
  padding:5px 12px;
  font-size:12px; font-weight:800; letter-spacing:.08em; white-space:nowrap;
  color:var(--brand-dark); background:var(--surface);
  border:2px solid var(--brand); border-radius:var(--r-pill);
  box-shadow:var(--shadow-sm);
}
.scr-path-start-bubble::before,
.scr-path-start-bubble::after{
  content:''; position:absolute; left:50%;
  width:0; height:0; border:7px solid transparent;
}
.scr-path-start-bubble::before{ top:100%; margin-left:-7px; border-top-color:var(--brand); }
.scr-path-start-bubble::after { top:calc(100% - 3px); margin-left:-5px; border-width:5px; border-top-color:var(--surface); }

/* ================================================================ mascot === */

.scr-path-mochi{
  --m:62px;
  position:absolute; z-index:1;
  width:var(--m); height:var(--m);
  pointer-events:none;
  left:calc(
    clamp(
      calc(var(--m) / 2),
      calc(50% + var(--dx) + var(--side) * 74px),
      calc(100% - var(--m) / 2)
    ) - var(--m) / 2
  );
  top:calc(var(--pad) + (var(--i) + .5) * var(--step) - var(--m) / 2 + 12px);
}
.scr-path-mochi[hidden]{ display:none; }

/* =============================================================== popover === */

.scr-path-pop{
  position:absolute; z-index:35;
  width:min(268px, calc(100% - 16px));
  display:flex; flex-direction:column; gap:var(--sp-2);
  padding:var(--sp-4);
  background:var(--surface);
  border:2px solid var(--line); border-radius:var(--r-lg);
  box-shadow:var(--shadow-md);
}
.scr-path-pop::before,
.scr-path-pop::after{
  content:''; position:absolute; left:var(--tail, 50%);
  width:0; height:0; border:10px solid transparent;
}
.scr-path-pop::before{ bottom:100%; margin-left:-10px; border-bottom-color:var(--line); }
.scr-path-pop::after { bottom:calc(100% - 3px); margin-left:-7px; border-width:7px; border-bottom-color:var(--surface); }

.scr-path-pop-title{ font-size:17px; font-weight:800; line-height:1.25; }
.scr-path-pop-meta{ margin-top:-2px; }
.scr-path-pop-stars{ --star-size:16px; }
.scr-path-pop .btn{ margin-top:var(--sp-1); }
.scr-path-pop.is-summit{ border-color:var(--gold); }

/* ============================================================== narrow === */

@media (max-width:340px){
  .scr-path-track{ --step:96px; }
  .scr-path-banner-desc{ -webkit-line-clamp:1; }
}

/* ================================================================ review === */

/* Shown only when srs.js says something has come round; path.js sets [hidden]
   outright the rest of the time, so this block never occupies a blank row. */

.scr-path-review{
  display:flex; align-items:center; gap:var(--sp-3);
  padding:var(--sp-3) var(--sp-4);
  border-color:var(--brand);
  background:var(--brand-soft);
}
.scr-path-review[hidden]{ display:none; }
.scr-path-review-icon{
  flex:0 0 auto;
  font-size:26px; line-height:1;
}
.scr-path-review-copy{ min-width:0; flex:1 1 auto; }
.scr-path-review-line{ font-size:16px; font-weight:800; line-height:1.25; color:var(--ink); }
.scr-path-review-sub{ margin-top:2px; }
.scr-path-review-cta{
  flex:0 0 auto;
  padding-inline:var(--sp-4);
}

@media (max-width:359px){
  /* At 320px the button and two lines of copy cannot share a row without the
     copy hyphenating; stack instead and let the button run full width. */
  .scr-path-review{ flex-wrap:wrap; }
  .scr-path-review-cta{ width:100%; }
}
