/* ═══════════════════════════════════════════════════════════════════════
 * /portal/portal-design.css — the QR Portal designer (public/portal/portal-design.js), portal-designer round,
 * Nov 13 2026. ONE component used on /setup, the portal page (Settings, subscribe) and /hq, so it has its own
 * sheet instead of a copy in setup.css and another in hq-assets/style.css that could drift apart.
 *
 * White ink on whatever is behind it (setup's black, HQ's violet): translucent white fills and hairlines, the
 * selected thing gets a white ring and a white check. DM Sans; labels 13–15px, body 15–16px.
 * Layout: preview, then five tabs (Colour · Pattern · Image · Logo · Text) and the open tab's choices. A wide box (HQ,
 * desktop Settings) puts the preview beside the choices. .pd--fit (the /setup step, ONE screen per step) lets the
 * preview take what's left and turns the tile rows into sideways strips.
 * JS sets classes and the --pd-c custom property only.
 * ═══════════════════════════════════════════════════════════════════════ */

.pd {
  --pd-ink: #ffffff;
  --pd-ink-2: rgba(255, 255, 255, 0.8);
  --pd-ink-3: rgba(255, 255, 255, 0.6);
  --pd-ink-4: rgba(255, 255, 255, 0.42);
  --pd-line: rgba(255, 255, 255, 0.22);
  --pd-fill: rgba(255, 255, 255, 0.12);
  --pd-fill-2: rgba(255, 255, 255, 0.06);
  --pd-fill-3: rgba(255, 255, 255, 0.18);
  --pd-on: #0b0b0f;
  --pd-body: 'DM Sans', 'Inter', system-ui, -apple-system, sans-serif;
  --pd-ease: cubic-bezier(0.22, 1, 0.36, 1);
  container-type: inline-size;
  color: var(--pd-ink);
  font-family: var(--pd-body);
}
.pd *, .pd *::before, .pd *::after { box-sizing: border-box; }
.pd button { font: inherit; color: inherit; }
.pd [hidden] { display: none !important; }
.pd :focus-visible { outline: 3px solid var(--pd-ink); outline-offset: 3px; }
.pd svg { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.pd-in { display: flex; flex-direction: column; gap: 16px; }

/* ── the preview ── */
.pd-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.pd-disc { position: relative; width: min(100%, 340px); }
.pd-art { display: block; width: 100%; height: auto; filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.45)); transition: opacity 0.2s ease; }
.pd-disc.is-loading { aspect-ratio: 1; border-radius: 50%; background: var(--pd-fill-2); animation: pd-shimmer 1.4s ease-in-out infinite; }
.pd-disc.is-loading .pd-art { visibility: hidden; }
.pd-spin { position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease; animation: pd-spin 0.7s linear infinite; }
.pd-disc.is-busy .pd-spin { opacity: 1; }
.pd-disc.is-busy .pd-art { opacity: 0.72; }
.pd-note { margin: 0; font-size: 15px; line-height: 1.35; color: var(--pd-ink-2); text-align: center; text-wrap: pretty; }
@keyframes pd-spin { to { transform: rotate(360deg); } }
@keyframes pd-shimmer { 50% { background: var(--pd-fill); } }

/* ── tabs ── */
.pd-ctl { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pd-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 18px; background: var(--pd-fill-2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.pd-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 52px; padding: 7px 4px;
  border: 0; border-radius: 14px; background: transparent; cursor: pointer; transition: background 160ms, color 160ms; }
.pd-tab:hover { background: var(--pd-fill-2); }
.pd-tab__label { font-size: 14px; font-weight: 700; line-height: 1.1; }
.pd-tab__value { display: flex; align-items: center; gap: 5px; max-width: 100%; font-size: 12px; line-height: 1.2; color: var(--pd-ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-tab__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--pd-c); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); }
.pd-tab.is-on { background: var(--pd-ink); color: var(--pd-on); }
.pd-tab.is-on .pd-tab__value { color: rgba(0, 0, 0, 0.6); }
.pd-tab.is-on .pd-tab__dot { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.pd-tab.is-covered:not(.is-on) .pd-tab__value { text-decoration: line-through; text-decoration-color: var(--pd-ink-4); }

.pd-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pd-hint { margin: 0; font-size: 15px; line-height: 1.4; color: var(--pd-ink-3); text-wrap: pretty; }
.pd-covered { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 14px; border-radius: 14px; background: var(--pd-fill-2); font-size: 15px; line-height: 1.35; color: var(--pd-ink-2); }
.pd-link { padding: 0; border: 0; background: none; cursor: pointer; font-weight: 700; color: var(--pd-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--pd-ink-4); }
.pd-fail { margin: 0; padding: 18px; border-radius: 16px; background: var(--pd-fill-2); font-size: 16px; color: var(--pd-ink-2); }

/* ── colour ── */
.pd-swatches { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px; }
.pd-swatch { position: relative; flex: none; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%;
  background: var(--pd-c, #6a40f0); color: #fff; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  transition: transform 140ms var(--pd-ease); }
.pd-swatch:active { transform: scale(0.92); }
.pd-swatch svg { width: 22px; height: 22px; stroke-width: 3; }
.pd-swatch.is-light { color: #1a1a1a; }
.pd-swatch.is-on { outline: 2.5px solid var(--pd-ink); outline-offset: 3px; }
.pd-swatch--any { background: conic-gradient(from 90deg, #ff3d3d, #ffc93c, #4cd964, #0fb5ae, #2f6bff, #a34bff, #ff3d8b, #ff3d3d); }
.pd-swatch--any svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
.pd-swatch--any.is-custom { border: 3px solid transparent; background: linear-gradient(var(--pd-c), var(--pd-c)) padding-box, conic-gradient(from 90deg, #ff3d3d, #ffc93c, #4cd964, #0fb5ae, #2f6bff, #a34bff, #ff3d8b, #ff3d3d) border-box; }
.pd-swatch--any.is-custom svg { filter: none; }
.pd-swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.pd-hex { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; font-size: 15px; color: var(--pd-ink-3); }
.pd-hex__input { width: 118px; height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--pd-fill); color: var(--pd-ink);
  font: 600 16px/1 var(--pd-body); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.pd-hex__input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--pd-ink); }

/* ── text: the words above the code, ALL CAPS, the fonts (each tile in its own face, 'pd-f-<id>' from portal-design.js) ── */
.pd-textrow { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pd-text__input { flex: 1 1 auto; min-width: 0; height: 48px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--pd-fill); color: var(--pd-ink);
  font: 600 17px/1 var(--pd-body); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.pd-text__input::placeholder { color: var(--pd-ink-4); text-transform: none; letter-spacing: 0; }
.pd-text__input.is-caps { text-transform: uppercase; letter-spacing: 0.03em; }
.pd-text__input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--pd-ink); }
.pd .pd-caps { flex: none; height: 48px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; box-shadow: inset 0 0 0 1.5px var(--pd-line);
  font-size: 13px; font-weight: 800; letter-spacing: 0.06em; color: var(--pd-ink-2); cursor: pointer; white-space: nowrap; }
.pd .pd-caps.is-on { background: var(--pd-ink); color: var(--pd-on); box-shadow: none; }
.pd-font__sample { font-size: 22px; line-height: 1; color: var(--pd-ink); white-space: nowrap; pointer-events: none; }
.pd-tiles--font .pd-tile__face { background: var(--pd-fill-2); overflow: hidden; }

/* ── tiles (patterns, images, logos, fonts) ── */
.pd-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 14px 10px; padding: 4px; }
.pd-tilewrap { position: relative; min-width: 0; }
.pd-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; min-width: 0; padding: 0; border: 0; background: none; cursor: pointer; }
.pd-tile__face { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 16px; background: var(--pd-fill); color: var(--pd-ink-2);
  transition: transform 140ms var(--pd-ease); }
.pd-tile:active .pd-tile__face { transform: scale(0.95); }
.pd-tile__face img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.pd-tile__face img.is-loading { visibility: hidden; }
.pd-tile__face svg { width: 28px; height: 28px; }
.pd-tile__name { max-width: 100%; font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--pd-ink-2); text-align: center; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.pd-tile.is-on .pd-tile__face { outline: 2.5px solid var(--pd-ink); outline-offset: 3px; }
.pd-tile.is-on .pd-tile__name { color: var(--pd-ink); }
.pd-tile__check { position: absolute; right: -4px; bottom: -4px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--pd-ink); color: var(--pd-on); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.pd-tile__check svg { width: 15px; height: 15px; stroke-width: 3.2; }
.pd-tile__x { position: absolute; top: -6px; right: -6px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(20, 20, 24, 0.9); color: #fff; cursor: pointer; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); }
.pd-tile__x svg { width: 14px; height: 14px; stroke-width: 3; }
/* patterns: the whole sticker, round, with its own transparent corners */
.pd-tiles--round .pd-tile__face { border-radius: 50%; background: var(--pd-fill-2); }
.pd-tiles--round .pd-tile__face img { object-fit: contain; }
/* logos: whole, on a mid fill so white and dark marks both read */
.pd-tiles--logo .pd-tile__face { background: rgba(255, 255, 255, 0.16) repeating-conic-gradient(rgba(255, 255, 255, 0.07) 0 25%, transparent 0 50%) 50% / 14px 14px; }
.pd-tiles--logo .pd-tile__face img { object-fit: contain; padding: 10px; }
.pd-tile--none .pd-tile__face { background: var(--pd-fill-2); color: var(--pd-ink-3); }
.pd-tile--up .pd-tile__face { background: transparent; box-shadow: inset 0 0 0 1.5px var(--pd-line); border: 0; color: var(--pd-ink); }
.pd-tile--up:hover .pd-tile__face { box-shadow: inset 0 0 0 1.5px var(--pd-ink-2); }
.pd-tile--up.is-busy .pd-tile__face svg { animation: pd-bob 0.9s ease-in-out infinite; }
@keyframes pd-bob { 50% { transform: translateY(-4px); } }

/* ── wide: the preview beside the choices (HQ, desktop) ── */
@container (min-width: 640px) {
  .pd-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 28px; align-items: start; }
  .pd-stage { position: sticky; top: 16px; }
  .pd-disc { width: min(100%, 440px); }
}

/* ── fit: the /setup step (one screen) ── */
.pd--fit { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.pd--fit .pd-in { flex: 1 1 auto; min-height: 0; gap: 12px; }
.pd--fit .pd-stage { flex: 1 1 auto; min-height: 120px; justify-content: center; gap: 6px; }
.pd--fit .pd-disc { flex: 1 1 auto; min-height: 0; width: auto; max-width: 100%; display: flex; justify-content: center; }
.pd--fit .pd-art { width: auto; height: 100%; max-width: 100%; object-fit: contain; }
.pd--fit .pd-disc.is-loading { flex: 1 1 auto; height: auto; }
.pd--fit .pd-ctl { flex: none; gap: 12px; }
/* a fixed height: the preview above doesn't jump when the tab changes */
.pd--fit .pd-panel { height: 184px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.pd--fit .pd-panel::-webkit-scrollbar { display: none; }
.pd--fit .pd-tiles { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 76px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scrollbar-width: none; margin: 0; padding: 6px 8px 2px; scroll-padding: 0 8px;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.pd--fit .pd-tiles::-webkit-scrollbar { display: none; }
.pd--fit .pd-tilewrap, .pd--fit .pd-tile { scroll-snap-align: start; }
.pd--fit .pd-note { font-size: 14px; }
@media (max-height: 700px) {
  .pd--fit .pd-tab { min-height: 46px; padding: 5px 4px; }
  .pd--fit .pd-tiles { grid-auto-columns: 66px; }
  .pd--fit .pd-panel { height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .pd-spin, .pd-disc.is-loading, .pd-tile--up.is-busy .pd-tile__face svg { animation: none; }
}
