/* THE STAND CUSTOMIZER (StandCustomizer.razor, js/stand.js; docs/STOREFRONT.md → Stand customizer). Two questions sit with the page's
   own choices, with one small picture of the top under them; choosing engraving opens the designer, one step over the page. The
   customer site's own colours, type and corners (app.css tokens): the site has one look, so this has too. Every class starts "sc-":
   most of what it styles is drawn by the script, which a page's scoped styles can't reach, and the site's own .choice, .btn and
   .field mean other things. */
.sc, .sc-over {
    --sc-stone: var(--rw-cream);
    --sc-edge: var(--rw-sf-edge);
    --sc-line: var(--rw-border);
    --sc-field: var(--rw-surface, #fff);
    --sc-picked: var(--rw-walnut-soft);
    --sc-forest: var(--rw-sf-forest);
    --sc-stop: #9a2c1c;
    --sc-stop-bg: #fbeeeb;
}
.sc[hidden], .sc [hidden], .sc-over [hidden] { display: none !important; }
.sc button, .sc input, .sc-over button, .sc-over input { font: inherit; color: inherit; }
.sc button, .sc-over button { cursor: pointer; }
.sc h2, .sc h3, .sc p, .sc-over h2, .sc-over p { margin: 0; }
.sc a, .sc-over a, .sc-linkbtn { color: var(--sc-forest); text-decoration: underline; text-underline-offset: 3px; }
.sc-linkbtn { background: none; border: 0; padding: 0; font-weight: 500; min-height: 44px; }
.sc :focus-visible, .sc-over :focus-visible { outline: none; box-shadow: var(--rw-focus); }
.sc a:focus-visible, .sc-over a:focus-visible, .sc-linkbtn:focus-visible { box-shadow: none; outline: 2px solid var(--sc-forest); outline-offset: 2px; }
.sc-noscript { margin: var(--rw-space-4) 0 0; padding: var(--rw-space-3) var(--rw-space-4); background: var(--rw-cream); border-radius: var(--rw-radius-panel); font-size: var(--rw-text-sm); color: var(--rw-ink); }

/* ---- The two questions, each under a rule like the page's own. ---- */
.sc { min-width: 0; }
.sc-block { padding-block: var(--rw-space-4); border-top: 1px solid var(--sc-line); }
.sc-block > .sc-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: var(--rw-space-3); }
.sc-block h2 { font: 600 var(--rw-text-md)/1.3 var(--rw-font); color: var(--rw-ink-strong); }
.sc-label span { color: var(--rw-muted); font-size: var(--rw-text-sm); }
.sc-note { color: var(--rw-muted); font-size: .875rem; }
.sc-choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.sc-choices.sc-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sc-choices.sc-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sc-choice { background: var(--sc-field); border: 1px solid var(--rw-border-strong); border-radius: var(--rw-radius-sm); padding: 6px 12px; min-height: 52px; text-align: left; display: flex; flex-direction: column; justify-content: center; line-height: 1.25; min-width: 0; }
.sc-choice small { color: var(--rw-muted); font-size: var(--rw-text-sm); }
.sc-choice:hover { border-color: var(--rw-walnut); }
.sc-choice[aria-checked="true"] { background: var(--sc-picked); border-color: var(--rw-walnut); box-shadow: inset 0 0 0 1px var(--rw-walnut); color: var(--rw-ink-strong); font-weight: 600; }
.sc-choice[aria-checked="true"] small { color: var(--rw-ink); font-weight: 400; }
.sc-choice[aria-checked="true"]:focus-visible { box-shadow: inset 0 0 0 1px var(--rw-walnut), var(--rw-focus); }

/* Bowl openings. */
.sc-measure { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 14px; align-items: center; background: var(--sc-stone); border-radius: var(--rw-radius-panel); padding: 12px; margin-top: 12px; }
.sc-measure svg { width: 100%; height: auto; display: block; }
.sc-measure p { font-size: .9375rem; }
.sc-measure p + p { margin-top: 6px; }
.sc-bowl-line { fill: #fff; stroke: #6b6762; stroke-width: 2; }
.sc-measure-line { stroke: var(--sc-forest); stroke-width: 2; fill: none; stroke-linecap: round; }
.sc-measure-word { font: 600 17px var(--rw-font); fill: var(--sc-forest); }
.sc-tick { display: flex; gap: 10px; align-items: center; min-height: 44px; margin-top: 8px; }
.sc-tick input { width: 20px; height: 20px; accent-color: var(--rw-walnut); flex: none; }
.sc-mrow { display: grid; grid-template-columns: minmax(0, 7.5rem) 6.5rem minmax(0, 1fr); gap: 10px; align-items: center; margin-top: 8px; }
.sc-mrow label { font-weight: 500; }
.sc-field { position: relative; }
.sc-field input { width: 100%; min-height: 48px; border: 1px solid var(--sc-edge); border-radius: 6px; background: var(--sc-field); padding: 8px 30px 8px 12px; font-variant-numeric: tabular-nums; scroll-margin-top: 24px; }
.sc-unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--rw-muted); font-size: .875rem; pointer-events: none; }
.sc-res { font-size: .9375rem; font-variant-numeric: tabular-nums; }
.sc-res.sc-stop { color: var(--sc-stop); }
.sc-mrow.sc-bad input { border-color: var(--sc-stop); box-shadow: inset 0 0 0 1px var(--sc-stop); }
.sc-mhelp { grid-column: 1 / -1; font-size: .875rem; color: var(--sc-stop); }
#sc-gap { margin-top: 12px; }
#sc-gap + .sc-note { margin-top: 6px; }

/* The one small picture of the top, under the last question: a picture, and (with engraving) a way into the designer. */
.sc-top { margin-top: 12px; display: grid; gap: 8px; }
.sc-prev { max-width: 440px; border: 1px solid var(--sc-edge); border-radius: var(--rw-radius-photo); background: var(--sc-stone); overflow: hidden; }
.sc-prev.sc-can { cursor: pointer; }
.sc-prev svg { display: block; width: 100%; height: auto; }
.sc-toprow { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.sc-toprow .sc-note { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.sc-pagenote { font-size: .875rem; color: var(--rw-ink); }
.sc-pagenote[data-tone="stop"] { color: var(--sc-stop); font-weight: 500; }
.sc-rights { font-size: .9375rem; }
.sc-rights .sc-tick { margin-top: 0; }
.sc-rights-terms { display: inline-block; margin-top: .25rem; font-size: .875rem; }

/* Buttons, here and in the designer: an outline in the edge colour, walnut for the one that moves things on. */
.sc-btn { background: var(--sc-field); border: 1px solid var(--sc-edge); border-radius: 6px; padding: 8px 14px; min-height: 44px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.sc-btn:hover { border-color: var(--rw-walnut); }
.sc-btn.sc-main, .sc .sc-btn.sc-main, .sc-over .sc-btn.sc-main { background: var(--rw-walnut); border-color: var(--rw-walnut); color: #fff; font-weight: 600; }
.sc-btn.sc-main:hover { background: var(--rw-walnut-dark); }
.sc-btn.sc-small { min-height: 40px; padding: 6px 12px; }

/* What it comes to, and what still stops it, just above the page's button. */
.sc-buy { display: flex; flex-direction: column; gap: 12px; }
.sc-buy:not(:has(> :not([hidden]))) { display: none; }
.sc-sum { margin: 0; display: grid; gap: 6px; }
.sc-sum div { display: flex; justify-content: space-between; gap: 16px; }
.sc-sum dt { min-width: 0; }
.sc-sum dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-sum .sc-total { border-top: 1px solid var(--sc-line); padding-top: 8px; margin-top: 2px; font-weight: 600; font-size: 1.125rem; }
#sc-stop { background: var(--sc-stop-bg); color: var(--sc-stop); border-radius: var(--rw-radius-panel); padding: 10px 12px; font-size: .9375rem; font-weight: 500; }

/* ---- THE DESIGNER: one step over the page. The page under it can't scroll while it is open (stand.js puts it back to the pixel). ---- */
html.sc-lock, html.sc-lock body { overflow: hidden; }
dialog.sc-over {
    position: fixed; inset: auto; left: 0; top: var(--sc-vvt, 0px); box-sizing: border-box; width: 100%; height: var(--sc-vvh, 100vh);
    max-width: none; max-height: none; margin: 0; padding: 2vh 2vw; border: 0; background: transparent; color: var(--rw-ink);
    overflow: hidden; overscroll-behavior: contain;
}
dialog.sc-over:not([open]) { display: none; }
dialog.sc-over[open] { display: flex; align-items: center; justify-content: center; }
dialog.sc-over::backdrop { background: rgba(40, 28, 20, .62); }
/* A browser without the dialog element's own behaviour: the same step, drawn over the page by hand. */
dialog.sc-over.sc-nomodal { z-index: 120; background: rgba(40, 28, 20, .62); }
.sc-win {
    position: relative; box-sizing: border-box; width: min(100%, 1600px); max-height: 100%; overflow: auto; overscroll-behavior: contain;
    background: var(--rw-bg); border-radius: var(--rw-radius-panel); padding: 16px 20px; display: flex; flex-direction: column; gap: 10px;
}
.sc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 16px; flex-wrap: wrap; }
.sc-headwords { min-width: 0; flex: 1 1 16rem; display: grid; gap: 2px; }
.sc-head h2 { font-size: var(--rw-text-xl); line-height: 1.2; color: var(--rw-ink-strong); }
.sc-head h2:focus-visible { box-shadow: none; outline: none; }
.sc-headline { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--rw-muted); font-size: .9375rem; }
.sc-headline span:first-child { color: var(--rw-ink); font-weight: 500; }
.sc-how { font-size: .9375rem; }
.sc-preview-note { justify-self: start; margin-top: 4px !important; padding: 4px 10px; border: 1px dashed var(--sc-edge); border-radius: var(--rw-radius-sm); font-size: .875rem; color: var(--rw-ink); }
.sc-headacts { display: flex; gap: 8px; flex-wrap: wrap; }

/* The drawing: as big as the window allows (stand.js sizes the box, so the scale is one number). */
.sc-big { display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 0; }
.sc-stage { position: relative; background: var(--sc-stone); border-radius: var(--rw-radius-photo); max-width: 100%; overflow: hidden; touch-action: none; }
#sc-draw { display: block; width: 100%; height: 100%; -webkit-user-select: none; user-select: none; touch-action: none; cursor: crosshair; }
#sc-ruler { display: block; max-width: 100%; height: 22px; }
#sc-ruler .sc-tickmark { stroke: var(--rw-muted); stroke-width: 1; }
#sc-ruler .sc-num { font: 10px var(--rw-font); fill: var(--rw-muted); font-variant-numeric: tabular-nums; }
.sc-foot { display: grid; gap: 6px; }
.sc-status { min-height: 2.6em; font-size: .9375rem; line-height: 1.3; color: var(--rw-muted); display: flex; align-items: center; flex-wrap: wrap; gap: 0 8px; }
.sc-status[data-tone="stop"] { color: var(--sc-stop); font-weight: 500; }
.sc-status[data-tone="note"] { color: var(--rw-ink); }
.sc-status .sc-linkbtn { min-height: 28px; padding: 0 4px; }
.sc-legend { font-size: .875rem; color: var(--rw-muted); }
/* The legend's own swatch of the hatching (stand.js gives it the wood's own colours; walnut's until then). */
.sc-hatchkey { display: inline-block; width: 22px; height: 12px; margin-right: 4px; vertical-align: -1px; border: 1px solid var(--sc-edge); background: repeating-linear-gradient(45deg, #6b4a36 0 2px, #d9c7b3 2px 4px); }

#sc-draw .sc-item { cursor: grab; touch-action: none; outline: none; }
#sc-draw.sc-dragging, #sc-draw.sc-dragging .sc-item { cursor: grabbing; }
#sc-draw .sc-hit { fill: transparent; }
#sc-draw .sc-item:focus-visible .sc-hit { stroke: #fff; stroke-width: 2.5; vector-effect: non-scaling-stroke; paint-order: stroke; filter: drop-shadow(0 0 1.5px #24160d); }
#sc-draw .sc-ghost { fill: none; stroke: #fff; stroke-opacity: .85; stroke-width: 1.25; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
#sc-draw .sc-ghost-text { fill: #fff; fill-opacity: .85; font-family: var(--rw-font); }
#sc-draw .sc-isbad .sc-words { fill: #c63a25; fill-opacity: 1; }
#sc-draw .sc-guide-under { stroke: #24160d; stroke-opacity: .6; stroke-width: 3; vector-effect: non-scaling-stroke; }
#sc-draw .sc-guide { stroke: #fff; stroke-width: 1.5; stroke-dasharray: 7 5; vector-effect: non-scaling-stroke; }
#sc-draw .sc-sel-under { fill: none; stroke: #24160d; stroke-opacity: .6; stroke-width: 3; vector-effect: non-scaling-stroke; }
#sc-draw .sc-sel-box { fill: none; stroke: #fff; stroke-width: 1.25; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
#sc-draw .sc-sel-box.sc-bad, #sc-draw .sc-bad-box { stroke: #ff8a75; }
#sc-draw .sc-bad-box { fill: #c63a25; fill-opacity: .22; stroke-width: 1.5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
#sc-draw .sc-edge-label, #sc-draw .sc-hole-label, #sc-prev .sc-hole-label { fill: var(--rw-muted); font-family: var(--rw-font); font-variant-numeric: tabular-nums; }

/* The editing panel. A computer: a pop-up over the drawing, beside the thing (stand.js places it inside the window). */
.sc-ed {
    position: fixed; z-index: 3; box-sizing: border-box; width: 384px; max-width: calc(100vw - 16px); max-height: calc(var(--sc-vvh, 100vh) - 16px); overflow: auto; overscroll-behavior: contain;
    background: var(--sc-field); border: 1px solid var(--sc-edge); border-radius: var(--rw-radius-sm); outline: 3px solid rgba(21, 19, 15, .16);
    padding: 12px; display: flex; flex-direction: column; gap: 10px; font-size: .9375rem;
}
.sc-grab { display: none; }
.sc-edtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.sc-edacts { display: inline-flex; gap: 6px; }
.sc-seg { display: inline-flex; border: 1px solid var(--sc-edge); border-radius: 6px; overflow: hidden; }
.sc-seg button { min-height: 40px; padding: 4px 12px; border: 0; background: var(--sc-field); }
.sc-seg button + button { border-left: 1px solid var(--sc-edge); }
.sc-seg button[aria-pressed="true"] { background: var(--rw-walnut); color: #fff; font-weight: 600; }
.sc-seg button:focus-visible { box-shadow: inset 0 0 0 2px var(--sc-field), inset 0 0 0 4px var(--sc-forest); }
.sc-edbody { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.sc-in { width: 100%; box-sizing: border-box; min-height: 46px; border: 1px solid var(--sc-edge); border-radius: 6px; background: var(--sc-field); padding: 8px 12px; font-size: 1rem; }
.sc-fontchips { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-font-chip { background: var(--sc-field); border: 1px solid var(--sc-edge); border-radius: 6px; min-height: 44px; padding: 4px 12px; font-size: 1.125rem; line-height: 1.2; white-space: nowrap; }
.sc-font-chip[aria-checked="true"], .sc-font-row[aria-checked="true"], .sc-cat[aria-pressed="true"], .sc-icon-btn[aria-pressed="true"] { background: var(--sc-picked); border-color: var(--rw-walnut); box-shadow: inset 0 0 0 1px var(--rw-walnut); }
.sc-row, .sc-morerow { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.sc-size { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
#sc-sizelbl, #sc-rotlbl { font-variant-numeric: tabular-nums; color: var(--rw-ink); }
#sc-rotlbl { min-width: 3rem; text-align: center; }
.sc-tool { min-width: 44px; height: 44px; background: var(--sc-field); border: 1px solid var(--sc-edge); border-radius: 6px; display: inline-grid; place-items: center; padding: 0 10px; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sc-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sc-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-cat { background: var(--sc-field); border: 1px solid var(--sc-edge); border-radius: 6px; min-height: 36px; padding: 2px 10px; font-size: .875rem; }
.sc-lib { max-height: 230px; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 4px; padding: 2px; }
.sc-font-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 46px; padding: 4px 12px; text-align: left; background: var(--sc-field); border: 1px solid var(--rw-border); border-radius: 6px; }
.sc-sample { font-size: 1.25rem; line-height: 1.2; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sc-fname { flex: none; font-size: .8125rem; color: var(--rw-muted); }
.sc-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.sc-icons.sc-lib { display: grid; }
.sc-icon-btn { aspect-ratio: 1; min-height: 48px; background: var(--sc-field); border: 1px solid var(--sc-edge); border-radius: 6px; display: grid; place-items: center; padding: 8px; touch-action: manipulation; }
.sc-icon-btn img { width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none; user-select: none; }
.sc-upload { display: inline-flex; align-items: center; position: relative; }
.sc-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.sc-upload input:focus-visible + span { box-shadow: var(--rw-focus); }
.sc-upload span { cursor: pointer; }
.sc-upload.sc-busy span { opacity: .6; cursor: default; }
.sc-more { border-top: 1px solid var(--sc-line); padding-top: 6px; }
.sc-more summary { min-height: 36px; display: flex; align-items: center; cursor: pointer; color: var(--sc-forest); font-weight: 500; }
.sc-more[open] summary { margin-bottom: 4px; }
.sc-morerow { justify-content: flex-start; margin-top: 6px; }
.sc-lbl { min-width: 3rem; font-size: .875rem; font-weight: 600; color: var(--rw-ink-strong); }

/* A phone: the step fills the screen that can be seen (above the keyboard), the drawing at the top, and the editing panel is a sheet
   at the bottom with a handle to swipe down. */
@media (max-width: 860px) {
    dialog.sc-over { padding: 0; }
    .sc-win { width: 100%; height: 100%; border-radius: 0; padding: 10px 12px; gap: 8px; }
    /* The heading in rows that use the screen's width: its name beside Back to the stand; the stand and the price; what to do beside Add words. */
    .sc-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 10px; }
    .sc-headwords, .sc-headacts { display: contents; }
    .sc-head h2 { grid-column: 1; grid-row: 1; font-size: var(--rw-text-lg); }
    #sc-close { grid-column: 2 / -1; grid-row: 1; }
    .sc-headline { grid-column: 1 / -1; grid-row: 2; font-size: .875rem; }
    .sc-how { grid-column: 1 / 3; grid-row: 3; font-size: .875rem; }
    #sc-addwords { grid-column: 3; grid-row: 3; }
    .sc-preview-note { grid-column: 1 / -1; grid-row: 4; }
    .sc-head .sc-btn { min-height: 40px; padding: 6px 12px; }
    .sc-ed {
        position: absolute; left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-width: none; outline: 0;
        border-width: 1px 0 0; border-radius: 10px 10px 0 0; padding: 4px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    }
    .sc-grab { display: flex; justify-content: center; padding: 6px 0 8px; margin-bottom: -4px; touch-action: none; cursor: grab; }
    .sc-grab i { display: block; width: 46px; height: 5px; border-radius: 3px; background: var(--sc-edge); }
    .sc-fontchips { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior: contain; padding: 2px; margin: -2px; }
    .sc-lib { max-height: 34vh; }
    /* With the keyboard up there is little room: the words that only explain step aside, and the drawing and the sheet stay. */
    .sc-tight .sc-how, .sc-tight .sc-headline, .sc-tight .sc-legend, .sc-tight #sc-ruler, .sc-tight .sc-preview-note, .sc-tight #sc-addwords { display: none; }
    .sc-tight .sc-status { min-height: 1.3em; }
}
@media (max-width: 420px) {
    .sc-measure { grid-template-columns: 104px minmax(0, 1fr); }
    .sc-mrow { grid-template-columns: minmax(0, 6rem) 6rem minmax(0, 1fr); }
}
