/* HUD: a compact, grouped panel. Same data and element ids as before; the three
   recognized-shape counts sit in one row of tiles and the practice totals are labelled rows. */
.shape-hud {
  position: absolute;
  bottom: 24px;
  right: 24px;
  --panel-open-width: 188px;
  width: var(--panel-open-width);
  box-sizing: border-box;
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 100;
  pointer-events: none;
  box-shadow: var(--shadow-panel);
  color: var(--text-color);
}

.hud-utility-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
  pointer-events: auto;
}

.hud-utility-button {
  appearance: none;
  display: grid;
  place-items: center;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-color);
  opacity: var(--opacity-muted);
  cursor: pointer;
  transition: opacity 90ms var(--ease-out-quart), background-color 90ms var(--ease-out-quart);
}

.hud-utility-button:hover,
.hud-utility-button:focus-visible,
.hud-utility-button.is-selected {
  opacity: 1;
  background: var(--surface-2);
  border-color: var(--panel-border);
}

.hud-utility-button:focus-visible,
.shape-stat-button:focus-visible {
  outline: 1px solid var(--text-color);
  outline-offset: 1px;
}

.hud-group { display: grid; gap: 4px; }

.hud-shapes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.hud-tile,
.hud-row {
  box-sizing: border-box;
  color: var(--text-color);
  font: inherit;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--surface-1);
  transition: background-color 90ms var(--ease-out-quart), border-color 90ms var(--ease-out-quart);
}

.hud-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0 7px;
}

.hud-group > .hud-row { width: 100%; }

.hud-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-top: 0;
  text-align: left;
}

.hud-row-label { font-size: var(--font-sm); opacity: var(--opacity-muted); }

.hud-icon {
  display: inline-grid;
  place-items: center;
  opacity: var(--opacity-secondary);
}

.hud-count {
  font-size: var(--font-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Rows that open a statistics view are real buttons. */
.shape-stat-button {
  appearance: none;
  margin: 0;
  cursor: pointer;
  pointer-events: auto;
}

.shape-stat-button:hover,
.shape-stat-button:focus-visible,
.shape-stat-button.is-selected {
  background: var(--surface-2);
  border-color: var(--panel-border);
}

.shape-stat-button.is-selected {
  background: var(--surface-3);
  border-color: var(--panel-border);
}

@keyframes hud-count-flash {
  0% { color: #4ade80; text-shadow: 0 0 8px rgba(74, 222, 128, 0.5); transform: scale(1.22); }
  100% { color: var(--text-color); text-shadow: none; transform: scale(1); }
}

.hud-flash .hud-count {
  display: inline-block;
  animation: hud-count-flash 0.6s var(--ease-out-quart);
}

.slider-wrapper { position:relative; width:100%; height:100%; }
.size-fill { position:absolute; left:0; right:0; bottom:0; height:var(--size-fill, 0%); background:var(--text-color); pointer-events:none; }
.size-display { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; color:var(--text-color); font-variant-numeric:tabular-nums; pointer-events:none; opacity:1; transition:opacity 0.4s var(--ease-out-quart); }
.size-display-inverted { color:var(--bg-color); clip-path:inset(calc(100% - var(--size-fill, 0%)) 0 0 0); }
.size-number { font-size:var(--font-lg); font-weight:600; line-height:1; }
.size-unit { font-size:var(--font-sm); font-weight:400; line-height:1; opacity:var(--opacity-secondary); }
.slider-wrapper input[type=range] {
  -webkit-appearance:none; -moz-appearance:none; appearance:none; margin:0; background:transparent; cursor:pointer;
  width:var(--brush-panel-height); height:48px;
  position:absolute; top:50%; left:50%; transform:translate(-50%, -50%) rotate(-90deg);
}
.slider-wrapper input[type=range]::-webkit-slider-runnable-track { height:100%; background:transparent; border:none; }
.slider-wrapper input[type=range]::-webkit-slider-thumb { -webkit-appearance:none; width:0; height:0; border:none; box-shadow:none; background:transparent; opacity:0; }
.slider-wrapper input[type=range]::-moz-range-track { height:100%; background:transparent; border:none; }
.slider-wrapper input[type=range]::-moz-range-progress { background:transparent; }
.slider-wrapper input[type=range]::-moz-range-thumb { width:0; height:0; border:none; background:transparent; opacity:0; box-shadow:none; }
.slider-wrapper input[type=range]:focus { outline:none; }
/* Mouse and pen only: the number fades out while the panel is thin. Touch screens keep it visible. */
@media (hover: hover) {
  .toolbar:not(.is-expanded) .size-display { opacity:0; }
  .toolbar { border-image-slice: 0 0 0 1; border-image-width: 0 0 0 1px; }
  .toolbar:not(.is-expanded) { border-color: transparent; --edge-line: var(--text-color); border-image-source: linear-gradient(to bottom, transparent 0, transparent 6px, var(--edge-line) 6px, var(--edge-line) calc(100% - 6px), transparent calc(100% - 6px)); transition: opacity 0.4s var(--ease-out-quart), transform 0.3s var(--ease-out-quart), width 0.4s var(--ease-out-quart), border-color 0.4s var(--ease-out-quart), --edge-line 0.2s var(--ease-out-quart) 0.2s, border-image-source 0s var(--ease-out-quart) 0.2s allow-discrete !important; }
  body:not(.ui-hidden) .toolbar:not(.is-expanded) { opacity:var(--opacity-rest); }
}
.custom-cursor.is-over-brush-panel { visibility:hidden; }
.custom-cursor.is-over-ui { visibility:hidden; }

/* Zoom readout: bottom-left, same panel treatment as the toolbar and HUD. */
.zoom-indicator {
  position: absolute;
  appearance: none;
  margin: 0;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
  bottom: 24px;
  left: 24px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: var(--font-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-color);
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
  z-index: 100;
}
.zoom-indicator[hidden] { display: none; }
.zoom-indicator:hover { background-image: linear-gradient(var(--surface-2), var(--surface-2)); }
.zoom-indicator:focus-visible { outline: 1px solid var(--text-color); outline-offset: 1px; }
.rule-line { position:absolute; top:24px; left:50%; transform:translateX(-50%); z-index:100; display:flex; align-items:baseline; gap:8px; min-width:0; max-width:min(520px, max(160px, calc(100vw - 800px))); padding:6px 12px; background:var(--panel-bg); border:1px solid var(--panel-border); border-radius:8px; color:var(--text-color); font:inherit; font-size:var(--font-sm); cursor:pointer; opacity:var(--opacity-muted); }
.rule-line.has-rule { opacity:var(--opacity-secondary); }
.rule-line:hover, .rule-line:focus-visible { opacity:1; }
.rule-line-text { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rule-line-count { flex:0 0 auto; font-variant-numeric:tabular-nums; opacity:var(--opacity-muted); }
.rule-line-count[hidden] { display:none; }

/* Rotation reset: shown only while the canvas is turned. Sits directly above the zoom readout. */
.rotation-reset-btn {
  position: absolute;
  bottom: 60px;
  left: 24px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text-color);
  box-shadow: var(--shadow-panel);
  cursor: pointer;
  z-index: 100;
}
.rotation-reset-btn[hidden] { display: none; }
.rotation-reset-btn:hover { background-image: linear-gradient(var(--surface-2), var(--surface-2)); }
.rotation-reset-btn:active { transform: translateY(1px); }

/* Receding (mouse and pen only): the HUD rests as a thin bar on its right edge, dimmed to --opacity-rest, and opens when the mouse is near.
   The zoom readout and the rotation reset are too small to become a bar, so they only dim: the zoom readout rests at --opacity-muted, the same as the rule line, and the rotation reset at --opacity-rest.
   The bar changes its real width like the brush panel (constant radius, overflow: hidden), so the border, shadow and corners travel with the edge.
   The class is-expanded is set by updateRecedingPanels() in js/app/13-render-and-strokes.js. */
@media (hover: hover) {
  .shape-hud {
    padding-left: 0;
    padding-right: 0;
    align-items: flex-end;
    overflow: hidden;
    transition: opacity 0.4s var(--ease-out-quart), transform 0.3s var(--ease-out-quart), width 0.4s var(--ease-out-quart), border-color 0.4s var(--ease-out-quart) !important;
    border-image-slice: 0 1 0 0;
    border-image-width: 0 1px 0 0;
  }
  .shape-hud > * { flex: none; width: calc(var(--panel-open-width) - 18px); margin-right: 8px; transition: opacity 0.4s var(--ease-out-quart), visibility 0.4s var(--ease-out-quart); }
  .shape-hud:not(.is-expanded) {
    width: 12px;
    border-color: transparent;
    --edge-line: var(--text-color);
    border-image-source: linear-gradient(to bottom, transparent 0, transparent 6px, var(--edge-line) 6px, var(--edge-line) calc(100% - 6px), transparent calc(100% - 6px));
    transition: opacity 0.4s var(--ease-out-quart), transform 0.3s var(--ease-out-quart), width 0.4s var(--ease-out-quart), border-color 0.4s var(--ease-out-quart), --edge-line 0.2s var(--ease-out-quart) 0.2s, border-image-source 0s var(--ease-out-quart) 0.2s allow-discrete !important;
  }
  body:not(.ui-hidden) .shape-hud:not(.is-expanded) { opacity: var(--opacity-rest); }
  .shape-hud:not(.is-expanded) > * { opacity: 0; visibility: hidden; }
  body:not(.ui-hidden) .zoom-indicator:not(.is-expanded) { opacity: var(--opacity-muted); }
  body:not(.ui-hidden) .rotation-reset-btn:not(.is-expanded) { opacity: var(--opacity-rest); }
  /* The zoom readout and the rotation reset have no transition of their own, so they take the 0.4s fade here. */
  .zoom-indicator, .rotation-reset-btn { transition: opacity 0.4s var(--ease-out-quart), transform 0.3s var(--ease-out-quart) !important; }
}

/* F12: hide the interface. The tracing ghost (#trace-reference-layer) is not listed, so it stays. */
body.ui-hidden .ui-element,
body.ui-hidden #prompt-station,
body.ui-hidden #stats-cluster {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

