/* Shop mode: one step at a time, full screen, for a phone at the saw.
   The diagram and the setting for the current cut carry the screen;
   everything else stays quiet. Uses the tokens in app.css only. */

.shop-start[hidden] { display: none; }
.plan-head .plan-tools { margin-left: auto; }
@media (max-width: 559px) {
  /* Full width on its own line, with room before the notice or summary below. */
  .plan-head .shop-start { flex-basis: 100%; justify-content: center; margin-bottom: 0.75rem; }
}

:root:has(.shop[open]) { overflow: hidden; }

.shop {
  position: fixed; inset: 0;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; overflow: hidden;
  background: var(--ground); color: var(--ink);
}
.shop[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.shop::backdrop { background: var(--ground); }
.shop [hidden] { display: none !important; }

.shop .btn { min-height: 2.75rem; justify-content: center; }
.shop .btn:disabled { opacity: 0.4; cursor: default; transform: none; background: var(--panel); }

.shop-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: calc(0.5rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.5rem max(1rem, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--line);
}

.shop-body {
  display: flex; flex-direction: column; gap: 0.875rem; min-height: 0;
  padding-block: 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  padding-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
}

/* Diagram */
/* The frame takes the shape of what it shows (set from the script), and gives
   way first when a long step needs the room. */
.shop-figure { display: flex; flex-direction: column; gap: 0.375rem; flex: 0 3 auto; min-height: 0; margin: 0; }
.shop-where { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.125rem 1rem; font-size: 0.875rem; color: var(--ink-2); }
.shop-where strong { color: var(--ink); font-weight: 700; }
.shop-count { color: var(--ink); font-weight: 650; }
.shop-art {
  position: relative; flex: 0 1 auto; width: 100%; min-height: 7rem; aspect-ratio: 2; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-s);
}
.shop-art .sheet-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.shop .sv-part { cursor: default; }
.shop .sv-mark:not(.is-hl) { display: none; }
.shop .sv-cut.is-hl:not(.is-done) { stroke: var(--crayon); stroke-width: 3; }
.sv-fade { fill: var(--panel); opacity: 0.7; pointer-events: none; }
.sv-focus { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 7 4; pointer-events: none; }

/* The step */
.shop-panel { display: flex; flex-direction: column; justify-content: space-between; gap: 0.875rem; flex: 1 1 auto; min-height: 0; }
.shop-step { min-height: 0; overflow-y: auto; }
.shop-back { margin-bottom: 0.375rem; font-weight: 650; }
.shop-head { display: flex; align-items: baseline; gap: 0.5rem; font-size: 1.25rem; font-weight: 700; font-stretch: 108%; line-height: 1.25; }
.shop-head .step-n { align-self: center; }
.shop .step-n { width: 1.75rem; height: 1.75rem; flex: none; font-size: 0.875rem; }
.shop .step-n.is-done { background: var(--line-strong); }
.shop-setting {
  margin: 0.125rem 0 0.125rem -0.04em;
  font-size: clamp(3.75rem, 19vw, 6.5rem); font-weight: 800; font-stretch: 112%;
  line-height: 1.05; letter-spacing: -0.02em;
}
.shop-unit { margin-left: 0.04em; font-size: 0.55em; font-weight: 700; vertical-align: 0.62em; }
.shop-unit.is-mm { margin-left: 0.2em; font-size: 0.4em; vertical-align: 0; letter-spacing: 0; }
.shop-from { font-size: 1rem; color: var(--ink-2); }
.shop-pieces { display: flex; flex-wrap: wrap; gap: 0.375rem 1.125rem; margin-top: 0.75rem; }
.shop-pieces li { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.shop-pieces li.is-done > span:last-child { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1px; }
.shop-status { margin-top: 0.625rem; color: var(--ink-2); font-size: 0.9375rem; }
.shop-status .linkish { min-height: 2.75rem; color: var(--ink); }
.shop-step.is-done .shop-head, .shop-step.is-done .shop-setting { color: var(--ink-2); }

.shop-controls { display: grid; gap: 0.5rem; }
.shop-nav { display: flex; gap: 0.5rem; }
.shop-nav .btn { flex: 1; }
.shop .shop-done { width: 100%; min-height: 5rem; font-size: 1.5rem; font-weight: 750; font-stretch: 108%; border-radius: var(--r-m); }

/* Finished */
.shop-finish { align-self: start; max-width: 34rem; padding-top: 2rem; }
.shop-finish h2 { font-size: clamp(2rem, 8vw, 3rem); font-weight: 800; font-stretch: 112%; line-height: 1.1; }
.shop-finish p { margin-top: 0.75rem; font-size: 1.125rem; color: var(--ink-2); max-width: 40ch; }
.shop-finish-actions { display: flex; flex-wrap: wrap; gap: 0.625rem; margin-top: 1.5rem; }
.shop .shop-finish-actions .btn-dark { min-height: 3.5rem; padding: 0 1.5rem; font-size: 1.125rem; }

/* All steps */
.shop-list { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 40rem; overflow-y: auto; }
.shop-list-sum { margin-bottom: 1rem; color: var(--ink-2); }
.shop-list section + section { margin-top: 1.5rem; }
.shop-list h3 { margin-bottom: 0.375rem; }
.shop-list-stock { color: var(--ink-2); font-weight: 450; }
.shop-jump {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; min-height: 2.75rem; padding: 0.375rem 0.625rem;
  font: inherit; font-size: 1rem; color: var(--ink); text-align: left; cursor: pointer;
  background: none; border: 0; border-left: 3px solid transparent; border-radius: 0 var(--r-s) var(--r-s) 0;
}
.shop-jump:hover { background: var(--paper); }
.shop-jump[aria-current] { background: var(--panel); border-left-color: var(--ink); font-weight: 650; }
.shop-jump:focus-visible { outline-offset: -2px; }
.shop-jump-n { display: flex; flex-wrap: wrap; gap: 0.25rem; min-width: 1.75rem; }
.shop-jump.is-done .shop-jump-text { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1px; }
.shop-skipped { margin-left: 0.625rem; font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }

/* Wide screens and phones on their side: diagram left, step right. */
@media (min-width: 700px) and (orientation: landscape), (min-width: 960px) {
  .shop-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 27rem); grid-template-rows: minmax(0, 1fr); gap: 1.75rem; }
  .shop-figure { min-height: 0; }
  .shop-panel { justify-content: space-between; padding-top: 1.625rem; }
  .shop-finish, .shop-list { grid-column: 1 / -1; }
}

/* Short screens (a phone on its side): tighter type, same order. */
@media (max-height: 520px) {
  .shop-bar { padding-block: calc(0.25rem + env(safe-area-inset-top)) 0.25rem; }
  .shop-body { gap: 0.5rem; padding-block: 0.5rem max(0.5rem, env(safe-area-inset-bottom)); }
  .shop-panel { gap: 0.5rem; padding-top: 1.5rem; }
  .shop-head { font-size: 1.0625rem; }
  .shop-setting { font-size: clamp(2.75rem, 16vh, 4rem); }
  .shop-pieces { margin-top: 0.375rem; }
  .shop .shop-done { min-height: 3.75rem; font-size: 1.25rem; }
  .shop-finish { padding-top: 0.5rem; }
}

@media print {
  .shop { display: none !important; }
}
