/* ---- 3D / AR viewer pages (/3d and /made). Shared, so it lives here rather
     than in either page. Built from site tokens only. ---- */
  .ar-wrap { max-width: 640px; margin-inline: auto; }

  /* The 3D preview. Kept short on phones so the camera button above it and
     the top of the preview both fit on the first screen. Neutral background
     on purpose: the machine is the only colour on the stage. */
  .ar-stage {
    position: relative;
    height: clamp(300px, 44svh, 520px);
    background: radial-gradient(120% 90% at 50% 30%, var(--surface) 0%, color-mix(in srgb, var(--line) 45%, var(--surface)) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  .ar-stage model-viewer {
    width: 100%;
    height: 100%;
    background: transparent;
    --poster-color: transparent;
    --progress-bar-color: transparent;
    /* Let a vertical swipe scroll the page; horizontal drags spin the model. */
    touch-action: pan-y;
  }

  /* Loading bar (our own, so it matches the brand). */
  .ar-progress {
    position: absolute; left: var(--s-5); right: var(--s-5); bottom: var(--s-5);
    height: 4px; border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--ink) 10%, transparent);
    overflow: hidden;
  }
  .ar-progress span {
    display: block; height: 100%; width: 0;
    background: var(--grad);
    transition: width .2s linear;
  }
  .ar-progress.is-done { opacity: 0; transition: opacity .4s ease .2s; }

  /* Small "drag to spin" chip, top-left. */
  .ar-hint {
    position: absolute; top: var(--s-4); left: var(--s-4);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    border: var(--hair);
    color: var(--ink-soft);
    font-size: var(--fs-xs);
    font-weight: 600;
    pointer-events: none;
  }
  .ar-size {
    position: absolute; top: var(--s-4); right: var(--s-4);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    border: var(--hair);
    color: var(--ink);
    font-size: var(--fs-xs);
    font-weight: 700;
    pointer-events: none;
  }

  /* Colour picker: two pills under the model. The dot colours are the
     machines' real wrap colours, so they're product values, not brand tokens. */
  .ar-colours {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-top: 0;
  }
  .ar-colours-label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--ink-soft);
    margin-right: var(--s-1);
  }
  .ar-swatch {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 44px;
    padding: 0 var(--s-4) 0 var(--s-2);
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
  }
  .ar-swatch:hover { border-color: var(--line-2); }
  .ar-swatch[aria-checked="true"] {
    border-color: var(--ink);
    box-shadow: var(--shadow-sm);
  }
  .ar-swatch:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
  .ar-dot {
    width: 28px; height: 28px;
    border-radius: var(--radius-pill);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--surface) 70%, transparent);
  }
  .ar-dot--purple { background: #9162a9; }
  .ar-dot--blue { background: #179fce; }

  /* ---- The "start" block: the main action, above the 3D preview ----
     Which version shows is decided by [data-ar] on .ar-wrap:
       (none yet) -> guess from the pointer: touch = button, mouse = QR code
       yes        -> this device can open the camera view: button
       no         -> it can't: QR code on computers, a short note on phones */
  .ar-start { margin: var(--s-5) 0 var(--s-4); }
  .ar-launch {
    display: none;
    width: 100%;
    white-space: normal;
    text-align: center;
    padding-inline: var(--s-4);
    min-height: 64px;
    gap: var(--s-3);
    font-size: 1.08rem;
    line-height: 1.2;
    box-shadow: var(--shadow-md);
  }
  .ar-launch svg { width: 26px; height: 26px; flex: none; }
  .ar-launch-note {
    display: none;
    margin-top: var(--s-2);
    text-align: center;
    color: var(--ink-soft);
    font-size: var(--fs-sm);
  }
  .ar-qr {
    display: none;
    align-items: center;
    gap: var(--s-5);
    padding: var(--s-4) var(--s-5);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }
  .ar-qr img { width: 112px; height: 112px; flex: none; border-radius: var(--radius-sm); }
  .ar-qr strong { display: block; font-size: 1.05rem; color: var(--ink); margin-bottom: var(--s-1); }
  .ar-qr span { color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.45; }
  .ar-nocam {
    display: none;
    padding: var(--s-4);
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: var(--fs-sm);
    text-align: center;
  }

  @media (pointer: coarse) {
    .ar-wrap:not([data-ar]) .ar-launch { display: inline-flex; }
    .ar-wrap:not([data-ar]) .ar-launch-note { display: block; }
    .ar-wrap[data-ar="no"] .ar-nocam { display: block; }
  }
  @media (pointer: fine) {
    .ar-wrap:not([data-ar]) .ar-qr { display: flex; }
    .ar-wrap[data-ar="no"] .ar-qr { display: flex; }
  }
  .ar-wrap[data-ar="yes"] .ar-launch { display: inline-flex; }
  .ar-wrap[data-ar="yes"] .ar-launch-note { display: block; }

  /* Label above the 3D preview. */
  .ar-or {
    margin: var(--s-5) 0 var(--s-3);
    text-align: center;
    color: var(--ink-soft);
    font-size: var(--fs-sm);
    font-weight: 600;
  }

  .ar-fail {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    padding: var(--s-6);
    text-align: center;
    color: var(--ink-soft);
    font-size: var(--fs-sm);
  }

  .ar-steps {
    list-style: none;
    padding: 0;
    margin: var(--s-6) 0 0;
    display: grid;
    gap: var(--s-3);
    counter-reset: arstep;
  }
  .ar-steps li {
    counter-increment: arstep;
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: var(--s-3);
    align-items: start;
    align-content: start;
    background: var(--surface);
    border: var(--hair);
    border-radius: var(--radius);
    padding: var(--s-4);
  }
  .ar-steps li::before {
    content: counter(arstep);
    display: grid;
    place-items: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-pill);
    background: var(--grad);
    color: #fff;
    font-weight: 800;
  }
  .ar-steps strong { display: block; color: var(--ink); }
  .ar-steps span { color: var(--ink-soft); font-size: var(--fs-sm); line-height: 1.45; }

  .ar-actions {
    display: grid;
    gap: var(--s-3);
    margin-top: var(--s-6);
  }
  @media (min-width: 640px) {
    .ar-steps { grid-template-columns: repeat(3, 1fr); }
    .ar-steps li { grid-template-columns: 1fr; }
    .ar-actions { grid-template-columns: 1fr 1fr; }
  }
  @media (prefers-reduced-motion: reduce) {
    .ar-progress span, .ar-progress.is-done { transition: none; }
  }

  .ar-how {
    font-size: clamp(1.25rem, 3.5vw, 1.6rem);
    text-align: center;
    margin-bottom: var(--s-2);
  }

  /* Second camera button, after "How it works". */
  .ar-start--again { margin: var(--s-6) 0 var(--s-5); }
