/* Street-sign widget. Scoped under .ssw. Fonts come from the theme (the
   heading is a real <h3>, so it gets the theme's heading face); colours default
   to Skyltcentralen's Empire theme and can be overridden with --ssw-accent
   (block setting) or from theme CSS. */
.ssw {
  --ssw-accent: #007bff;
  --ssw-accent-soft: color-mix(in srgb, var(--ssw-accent) 10%, #fff);
  --ssw-ink: #2f3337;
  --ssw-muted: #6b747c;
  --ssw-line: #d9dee3;
  --ssw-surface: #f4f6f8;
  --ssw-error: #c62828;
  --ssw-error-soft: #fdeeee;
  --ssw-radius: 3px;
  display: grid;
  gap: 16px;
  margin: 24px 0;
  padding-top: 24px;
  border-top: 1px solid var(--ssw-line);
  color: var(--ssw-ink);
  font: inherit;
}
.ssw * { box-sizing: border-box; }
.ssw [hidden] { display: none !important; }

.ssw-heading { margin: 0; font-size: 1.35em; line-height: 1.2; }

/* ---- preview ---- */
.ssw-stage {
  border: 1px solid var(--ssw-line);
  border-radius: var(--ssw-radius);
  background: var(--ssw-surface);
  overflow: hidden;
}
.ssw-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 0 14px;
}
.ssw-stage-title { font-size: 14px; font-weight: 700; }
.ssw-segs {
  display: inline-flex;
  border: 1px solid var(--ssw-line);
  border-radius: var(--ssw-radius);
  background: #fff;
  overflow: hidden;
}
.ssw-seg {
  font: inherit;
  font-size: 13px;
  padding: 5px 14px;
  border: 0;
  background: none;
  color: var(--ssw-muted);
  cursor: pointer;
}
.ssw-seg + .ssw-seg { border-left: 1px solid var(--ssw-line); }
.ssw-seg[aria-pressed="true"] { background: var(--ssw-accent-soft); color: var(--ssw-accent); font-weight: 700; }
.ssw-seg:focus-visible { outline: 2px solid var(--ssw-accent); outline-offset: -2px; }

.ssw-scene { width: 100%; }
.ssw-scene svg { display: block; width: 100%; height: auto; }
.ssw-scene text { font-family: inherit; }
.ssw-scene.is-placeholder svg svg g { opacity: 0.25; }
.ssw-scene.is-overflow svg svg { outline: 2px dashed var(--ssw-error); outline-offset: 2px; }

.ssw-note { margin: -8px 0 0; font-size: 13px; color: var(--ssw-muted); }

/* ---- text ---- */
.ssw-fields { display: grid; gap: 12px; }
.ssw-field { display: grid; gap: 6px; margin: 0; }
.ssw-label { font-size: 15px; font-weight: 700; }
.ssw-input, .ssw-select {
  font: inherit;
  font-size: 16px; /* no zoom on iOS */
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--ssw-line);
  border-radius: var(--ssw-radius);
  background: #fff;
  color: var(--ssw-ink);
}
.ssw-input::placeholder { color: #a2aab1; }
.ssw-input:focus, .ssw-select:focus, .ssw-qty-input:focus {
  outline: none;
  border-color: var(--ssw-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ssw-accent) 22%, transparent);
}

.ssw-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: -6px;
  padding: 10px 12px;
  border-radius: var(--ssw-radius);
  font-size: 14px;
  line-height: 1.4;
}
.ssw-msg:empty { display: none; }
.ssw-msg svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.ssw-msg[data-tone="info"] { background: var(--ssw-accent-soft); color: color-mix(in srgb, var(--ssw-accent) 70%, #000); }
.ssw-msg[data-tone="info"] svg circle { fill: var(--ssw-accent); }
.ssw-msg[data-tone="error"] { background: var(--ssw-error-soft); color: var(--ssw-error); }
.ssw-msg[data-tone="error"] svg circle { fill: var(--ssw-error); }

/* ---- text size: text height per step, and the sign length it needs ---- */
.ssw-textsize { display: grid; gap: 6px; }
.ssw-steps { display: flex; gap: 10px; align-items: stretch; margin-top: 8px; }
.ssw-steps-legend, .ssw-step { display: grid; align-content: center; padding: 7px 0; }
.ssw-steps-legend b, .ssw-step b { font-size: 14px; line-height: 20px; }
.ssw-steps-legend span, .ssw-step span { font-size: 12px; line-height: 16px; min-height: 16px; }
.ssw-steps-legend { color: var(--ssw-muted); }
.ssw-steps-legend b { font-weight: 400; }
.ssw-textsize.is-empty .ssw-steps-legend span,
.ssw-textsize.is-empty .ssw-step span { display: none; }
.ssw-steps-btns {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  border: 1px solid var(--ssw-line);
  border-radius: var(--ssw-radius);
  background: #fff;
}
.ssw-step {
  position: relative;
  font: inherit;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ssw-ink);
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}
.ssw-step + .ssw-step { border-left: 1px solid var(--ssw-line); }
.ssw-step:first-child { border-radius: var(--ssw-radius) 0 0 var(--ssw-radius); }
.ssw-step:last-child { border-radius: 0 var(--ssw-radius) var(--ssw-radius) 0; }
/* "Standard" tab sitting on the top edge of the standard step. */
.ssw-step-tag {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -55%);
  padding: 2px 5px;
  border-radius: var(--ssw-radius);
  background: var(--ssw-ink);
  white-space: nowrap;
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  pointer-events: none;
}
.ssw-step[aria-pressed="true"] .ssw-step-tag { background: var(--ssw-accent); }
.ssw-step span { color: var(--ssw-muted); }
.ssw-step:hover { background: var(--ssw-surface); }
.ssw-step[aria-pressed="true"] { background: var(--ssw-accent-soft); color: var(--ssw-accent); box-shadow: inset 0 -2px 0 var(--ssw-accent); }
.ssw-step[aria-pressed="true"] span { color: inherit; }
.ssw-step:focus-visible { outline: 2px solid var(--ssw-accent); outline-offset: -2px; }

/* ---- size ---- */
.ssw-size { display: grid; gap: 4px; }
.ssw-size-head { display: flex; align-items: center; gap: 8px; }
.ssw-badge {
  font-size: 12px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: var(--ssw-radius);
  background: var(--ssw-accent-soft);
  color: var(--ssw-accent);
  font-weight: 700;
}
.ssw-badge[data-mode="manual"] { background: #eceff2; color: var(--ssw-muted); }
.ssw-size-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ssw-size-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.ssw-select { width: auto; min-width: 0; flex: 0 1 auto; padding-right: 32px; font-size: 15px; }
.ssw-select:disabled { opacity: 0.5; }
.ssw-size-hintrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.ssw-size-hint { margin: 0; font-size: 14px; color: var(--ssw-muted); }
.ssw-link {
  font: inherit;
  font-size: 14px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ssw-accent);
  text-decoration: underline;
  cursor: pointer;
}

/* The size ruler: every size as a dot, the chosen one marked. */
.ssw-ruler { position: relative; height: 46px; margin: 10px 7px 0; }
.ssw-track, .ssw-track-fit { position: absolute; top: 7px; height: 2px; }
.ssw-track { left: 0; right: 0; background: #e3e7eb; }
.ssw-track-fit { right: 0; background: #c3cbd2; }
.ssw-dot {
  position: absolute;
  top: 8px;
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #b3bcc4;
  cursor: pointer;
}
.ssw-dot[data-state="small"] { background: #fff; box-shadow: inset 0 0 0 1.5px #d3d9de; cursor: not-allowed; }
.ssw-dot[data-state="current"] {
  width: 16px;
  height: 16px;
  background: var(--ssw-accent);
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px color-mix(in srgb, var(--ssw-accent) 35%, transparent);
  transition: left 0.2s ease;
}
.ssw-tick {
  position: absolute;
  top: 22px;
  font-size: 12px;
  color: var(--ssw-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ssw-tick-min { left: -7px; }
.ssw-tick-max { right: -7px; }
.ssw-tick-cur { transform: translateX(-50%); color: var(--ssw-ink); font-weight: 700; }

.ssw-tiers { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; font-size: 13px; color: var(--ssw-muted); }
.ssw-tier[data-current="true"] { color: var(--ssw-ink); font-weight: 700; }

/* ---- buy ---- */
.ssw-buy { display: flex; gap: 10px; align-items: stretch; margin-top: 4px; }
.ssw-qty {
  display: flex;
  flex: none;
  border: 1px solid var(--ssw-line);
  border-radius: var(--ssw-radius);
  background: #fff;
}
.ssw-qty-btn {
  font: inherit;
  font-size: 20px;
  width: 40px;
  border: 0;
  background: none;
  color: var(--ssw-ink);
  cursor: pointer;
}
.ssw-qty-btn:disabled { color: #c3cbd2; cursor: default; }
.ssw-qty-btn:focus-visible { outline: 2px solid var(--ssw-accent); outline-offset: -2px; }
.ssw-qty-input {
  font: inherit;
  font-size: 16px;
  width: 44px;
  border: 0;
  border-left: 1px solid var(--ssw-line);
  border-right: 1px solid var(--ssw-line);
  text-align: center;
  color: var(--ssw-ink);
  -moz-appearance: textfield;
}
.ssw-qty-input::-webkit-outer-spin-button, .ssw-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ssw-add {
  flex: 1;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--ssw-accent);
  border-radius: var(--ssw-radius);
  background: var(--ssw-accent);
  color: #fff;
  cursor: pointer;
}
.ssw-add:hover:not(:disabled) { filter: brightness(0.94); }
.ssw-add:focus-visible { outline: 2px solid var(--ssw-accent); outline-offset: 2px; }
.ssw-add:disabled { opacity: 0.4; cursor: not-allowed; }

.ssw-status { margin: -4px 0 0; font-size: 14px; }
.ssw-status:empty { display: none; }
.ssw-status[data-tone="ok"] { color: #1e7a3a; }
.ssw-status[data-tone="error"] { color: var(--ssw-error); }
.ssw-status a { color: inherit; font-weight: 700; }

@media (max-width: 420px) {
  .ssw-size-value { font-size: 21px; }
  .ssw-select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ssw-dot[data-state="current"] { transition: none; }
}
