/* ──────────────────────────────────────────────────────────────
   viewer.css — Project 1, AR Product Viewer (/projects/viewer/).
   Page-layout layer only; brand tokens + components come from
   core.css (do not duplicate them here). Every var() carries a
   literal fallback, same convention as hub.css.
   ────────────────────────────────────────────────────────────── */

:root {
  --v-max: 1160px;
  --v-gut: clamp(1.25rem, 4vw, 3rem);
}

body.viewer-page {
  background: var(--cs-light, #EDE8E0);
  color: var(--cs-secondary, #1A1D21);
}

/* Skip link — hidden until focused (sr-only in core.css never reveals) */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  z-index: 2000;
  background: var(--cs-secondary, #1A1D21);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 0 0 8px 0;
  text-decoration: none;
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ── Nav (matches hub-nav language) ──────────────────────── */
.v-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--v-gut);
  background: var(--cs-secondary, #1A1D21);
}
.v-nav__brand { display: inline-flex; flex: none; } /* never squeeze the logo (aspect-ratio) */
.v-nav__brand img { height: 26px; width: auto; }
.v-nav__links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.v-nav__links a {
  color: var(--cs-light, #EDE8E0);
  text-decoration: none;
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 600;
  font-size: .95rem;
}
.v-nav__links a:hover,
.v-nav__links a[aria-current="page"] { color: var(--cs-primary, #E0673E); }

/* ── Main scaffolding ────────────────────────────────────── */
.v-main {
  max-width: var(--v-max);
  margin-inline: auto;
  padding: clamp(1.5rem, 4vw, 3rem) var(--v-gut) clamp(3rem, 6vw, 5rem);
}
.v-crumb {
  font-size: .85rem;
  color: var(--cs-info, #6B6560);
  margin: 0 0 1.25rem;
}
.v-crumb a { color: var(--cs-primary-ink, #C8502D); }
.v-title { margin: 0 0 .5rem; font-size: clamp(1.8rem, 4.5vw, 2.6rem); line-height: 1.1; }
.v-sub { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 1.5rem; }
.v-blurb {
  max-width: 62ch;
  color: var(--cs-info, #6B6560);
  line-height: 1.65;
  margin: 0 0 2rem;
}

/* Index page intro */
.v-intro { max-width: 64ch; margin: 0 0 2.25rem; }
.v-intro h1 { margin-bottom: .6rem; }
.v-intro p { color: var(--cs-info, #6B6560); line-height: 1.65; margin: 0 0 .5rem; }

/* Index product grid */
.v-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}
.v-grid .card__meta { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 .6rem; }

/* ── Product page layout: stage + specs ──────────────────── */
.v-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (min-width: 960px) {
  .v-layout { grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr); }
}

/* Stage (3D viewer card) */
.v-stage {
  position: relative;
  background: #fff;
  border: 1px solid rgba(26, 29, 33, .10);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(26, 29, 33, .05);
  overflow: hidden;
}
.v-stage model-viewer {
  position: relative; /* contains the poster/overlay even BEFORE the element upgrades */
  width: 100%;
  height: min(62vh, 560px);
  min-height: 340px;
  background:
    radial-gradient(ellipse at 50% 40%, #ffffff 0%, #F5F1EA 70%, #EDE8E0 100%);
  --poster-color: transparent;
  display: block;
  touch-action: pan-y;
}
/* We render our own progress UI */
.v-stage model-viewer::part(default-progress-bar) { display: none; }

/* Slotted poster — first paint comes from plain HTML + this rule, so the
   product render is visible before the module JS (let alone the model)
   has loaded, and is the page's LCP element. model-viewer dismisses the
   poster slot automatically when the model reveals. */
.v-poster {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.v-poster picture,
.v-poster img {
  width: 100%;
  height: 100%;
}
.v-poster img { object-fit: contain; }

/* Reset-view control */
.v-reset {
  position: absolute;
  top: .75rem;
  right: .75rem;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 40px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(26, 29, 33, .18);
  border-radius: 8px;
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 600;
  font-size: .85rem;
  color: var(--cs-secondary, #1A1D21);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.v-reset:hover { background: #fff; border-color: var(--cs-primary, #E0673E); }
.v-reset svg { width: 15px; height: 15px; }

/* AR button — light-DOM child with slot="ar-button".
   model-viewer only shows AR when the device can; belt-and-braces:
   explicitly hide it whenever the element cannot activate AR, so a
   desktop never sees a dead button. */
.v-ar-btn {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(26, 29, 33, .25);
}
model-viewer:not([can-activate-ar]) .v-ar-btn { display: none; }

/* AR hint under the stage — swaps by AR capability (:has) */
.v-ar-note {
  padding: .8rem 1.1rem 1rem;
  margin: 0;
  font-size: .84rem;
  color: var(--cs-info, #6B6560);
  border-top: 1px solid rgba(26, 29, 33, .08);
}
.v-ar-note--yes { display: none; }
.v-stage:has(model-viewer[can-activate-ar]) .v-ar-note--yes { display: block; }
.v-stage:has(model-viewer[can-activate-ar]) .v-ar-note--no { display: none; }

/* Loading / error overlay — a slim strip at the bottom of the stage so the
   poster (the LCP element) stays fully visible while the model streams in. */
.v-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: .55rem;
  padding-bottom: 4.4rem; /* clear of the AR button */
  background: linear-gradient(to top, rgba(255, 255, 255, .92) 0%, rgba(255, 255, 255, .55) 22%, rgba(255, 255, 255, 0) 40%);
  transition: opacity .3s ease;
  pointer-events: none;
}
.v-loading.is-hidden { opacity: 0; visibility: hidden; }
.v-loading__spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(70, 157, 202, .25);
  border-top-color: var(--cs-primary, #E0673E);
  border-radius: 50%;
  animation: cs-spin .8s linear infinite;
}
.v-loading__bar {
  width: min(220px, 60%);
  height: 4px;
  background: var(--cs-gray-300, #DCD5CA);
  border-radius: 999px;
  overflow: hidden;
}
.v-loading__fill {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--cs-primary, #E0673E);
  transition: width .2s ease;
}
.v-loading__label { font-size: .85rem; color: var(--cs-info, #6B6560); }
.v-loading.is-error .v-loading__spinner { display: none; }
.v-loading.is-error {
  pointer-events: auto;
  justify-content: center;
  padding-bottom: 0;
  background: rgba(255, 255, 255, .9);
}
.v-loading.is-error .v-loading__label { color: var(--cs-danger, #B3261E); max-width: 34ch; text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .v-loading__spinner { animation-duration: 1.6s; }
}

/* ── Callouts toggle (top-left; Reset view sits top-right) ── */
.v-callouts { left: .75rem; right: auto; }
.v-callouts[hidden] { display: none; } /* .v-reset's display would otherwise beat the UA [hidden] rule */
.v-callouts[aria-pressed="true"] {
  background: var(--cs-primary-soft, #FBEDE8);
  border-color: var(--cs-primary, #E0673E);
}

/* ── Finish switcher (KHR_materials_variants) ─────────────── */
/* A <fieldset> so the legend labels the whole segmented group. Hidden by
   default; viewer-product.js reveals it only when the loaded model really
   carries the finish variants (never a dead control). */
.v-finish {
  border: none;
  margin: 0 0 1.1rem;
  padding: 0;
  min-inline-size: 0; /* fieldsets otherwise refuse to shrink below content */
}
.v-finish[hidden] { display: none; }
.v-finish legend {
  /* mirror .field label (core.css) — legends don't inherit that rule */
  display: block;
  padding: 0;
  margin-bottom: var(--sp-1, 6px);
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--cs-dark, #1A1D21);
}
.v-finish__group {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.v-finish__btn { flex: 1 1 auto; }
.v-finish__btn[aria-pressed="true"] {
  background: var(--cs-primary-soft, #FBEDE8);
  border-color: var(--cs-primary, #E0673E);
  color: var(--cs-primary-ink, #C8502D);
}
.v-finish__note { margin: .55rem 0 0; }

/* ── Engineering hotspots (slotted into model-viewer) ─────── */
/* model-viewer positions each slotted hotspot at its data-position;
   we style visuals only. Document CSS applies to slotted light DOM. */
.v-hotspot {
  position: relative; /* anchor for the label/detail card */
  display: block;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  --min-hotspot-opacity: 0.35; /* facing-away hotspots fade, stay discoverable */
}
.v-hotspot__dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin: 3.5px auto;
  border-radius: 50%;
  background: var(--cs-primary, #C8502D);
  border: 2px solid #fff;
  box-shadow: 0 0 0 3px rgba(200, 80, 45, .35), 0 1px 4px rgba(26, 29, 33, .35);
}
/* AS9102-style balloon numeral inside the dot (aria-hidden; the number is
   spoken via the button's aria-label instead) */
.v-hotspot__num {
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 700;
  font-size: 9px;
  line-height: 1;
  color: #fff;
  user-select: none;
}
.v-hotspot:hover .v-hotspot__dot,
.v-hotspot:focus-visible .v-hotspot__dot,
.v-hotspot[aria-expanded="true"] .v-hotspot__dot {
  background: var(--cs-primary-ink, #C8502D);
}
/* Label chip — HIDDEN by default (just the dot shows) so close hotspots don't
   pile up and clip; the chip reveals on hover / focus / expand. This keeps the
   head area (3 close hotspots) readable instead of a stack of overlapping chips. */
.v-hotspot__card {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%);
  display: none;
  width: max-content;
  max-width: min(250px, 64vw);
  background: #fff;
  border: 1px solid rgba(26, 29, 33, .14);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(26, 29, 33, .16);
  padding: .4rem .6rem;
  text-align: left;
  pointer-events: none;
  z-index: 5;
}
.v-hotspot:hover .v-hotspot__card,
.v-hotspot:focus-visible .v-hotspot__card,
.v-hotspot[aria-expanded="true"] .v-hotspot__card { display: block; }
/* the active hotspot floats above its neighbours' dots */
.v-hotspot:hover,
.v-hotspot:focus-visible,
.v-hotspot[aria-expanded="true"] { z-index: 6; }
.v-hotspot--below .v-hotspot__card {
  bottom: auto;
  top: calc(100% + 7px);
}
.v-hotspot__label {
  display: block;
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 600;
  font-size: .78rem;
  line-height: 1.35;
  color: var(--cs-secondary, #1A1D21);
  white-space: nowrap;
}
.v-hotspot__detail {
  display: none;
  font-size: .76rem;
  line-height: 1.5;
  color: var(--cs-info, #6B6560);
  margin-top: .25rem;
  white-space: normal;
  width: max(200px, 100%);
  max-width: min(250px, 60vw);
}
.v-hotspot:hover .v-hotspot__detail,
.v-hotspot:focus-visible .v-hotspot__detail,
.v-hotspot[aria-expanded="true"] .v-hotspot__detail { display: block; }
/* Hide all callouts when toggled off */
model-viewer.callouts-off .v-hotspot { display: none; }

/* ── Balloon legend (AS9102 idiom — built by viewer-product.js) ── */
/* Sits under the model, above Downloads. Each row mirrors one hotspot:
   the numbered badge matches the balloon on the 3D dot; clicking a row
   opens the matching hotspot (keyboard/SR fallback for balloons hidden
   behind the current rotation). */
.v-legend {
  padding: 1rem 1.1rem .5rem;
  border-top: 1px solid rgba(26, 29, 33, .08);
}
.v-legend__title { font-size: 1.05rem; margin: 0 0 .45rem; }
.v-legend__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.v-legend__row { border-bottom: 1px solid rgba(26, 29, 33, .06); }
.v-legend__row:last-child { border-bottom: 0; }
.v-legend__item {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  width: 100%;
  padding: .6rem .4rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.v-legend__item:hover,
.v-legend__item[aria-expanded="true"] { background: var(--cs-primary-soft, #FBEDE8); }
.v-legend__num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: .05rem;
  border-radius: 50%;
  background: var(--cs-primary, #C8502D);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(26, 29, 33, .18);
  color: #fff;
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 700;
  font-size: .72rem;
  line-height: 1;
}
.v-legend__item[aria-expanded="true"] .v-legend__num { background: var(--cs-primary-ink, #A93F20); }
.v-legend__text { min-width: 0; }
.v-legend__label {
  display: block;
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 600;
  font-size: .88rem;
  line-height: 1.4;
  color: var(--cs-secondary, #1A1D21);
}
.v-legend__detail {
  display: block;
  margin-top: .15rem;
  font-size: .8rem;
  line-height: 1.5;
  color: var(--cs-info, #6B6560);
}

/* ── Downloads (ungated) ─────────────────────────────────── */
.v-downloads {
  padding: 1rem 1.1rem 1.15rem;
  border-top: 1px solid rgba(26, 29, 33, .08);
}
.v-downloads h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
.v-downloads__list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 0;
  padding: 0;
}
.v-downloads__fmt {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--cs-primary-soft, #FBEDE8);
  color: var(--cs-primary-ink, #C8502D);
}
.v-downloads__note { margin: .8rem 0 0; }
.v-downloads__nogate { margin: .65rem 0 0; } /* "No email required." — injected by viewer-product.js */

/* ── Forced colors (Windows High Contrast) ────────────────── */
/* Pressed state relies on a background wash, which forced-colors strips —
   restate it as an outline so toggled controls stay distinguishable. */
@media (forced-colors: active) {
  .v-finish__btn[aria-pressed="true"],
  .v-callouts[aria-pressed="true"],
  .v-legend__item[aria-expanded="true"] { outline: 3px solid; outline-offset: 1px; }
}

/* ── Reduced motion — no animated UI movement ─────────────── */
@media (prefers-reduced-motion: reduce) {
  .v-loading,
  .v-loading__fill,
  .v-reset,
  .btn,
  a.card { transition: none; }
  a.card:hover { transform: none; }
  .v-dims > summary::after { transition: none; }
}

/* ── Specs panel ─────────────────────────────────────────── */
.v-specs {
  background: #fff;
  border: 1px solid rgba(26, 29, 33, .10);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(26, 29, 33, .05);
  padding: 1.5rem;
}
.v-specs h2 { font-size: 1.3rem; margin: 0 0 1rem; }
.v-specs .field { margin-bottom: 1.1rem; }
.v-positioning {
  margin: .9rem 0 1.4rem;
  padding: .85rem 1rem;
  background: var(--cs-primary-soft, #FBEDE8);
  border-left: 3px solid var(--cs-primary, #E0673E);
  border-radius: 0 8px 8px 0;
  font-size: .92rem;
  line-height: 1.6;
  color: var(--cs-secondary, #1A1D21);
}
.v-specs .spec-table-wrap { margin-bottom: 1.4rem; }
.v-specs .spec-table caption { padding: .8rem 1rem; font-size: 1rem; }

/* Dimensions disclosure */
.v-dims > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .7rem .2rem;
  font-family: var(--cs-font-display, "Archivo", system-ui, sans-serif);
  font-weight: 600;
  font-size: 1rem;
  color: var(--cs-secondary, #1A1D21);
  border-radius: 6px;
}
.v-dims > summary::-webkit-details-marker { display: none; }
.v-dims > summary::after {
  content: "";
  width: 9px; height: 9px;
  border-right: 2px solid var(--cs-primary-ink, #C8502D);
  border-bottom: 2px solid var(--cs-primary-ink, #C8502D);
  transform: rotate(45deg);
  transition: transform .15s ease;
  flex: none;
}
.v-dims[open] > summary::after { transform: rotate(225deg); }
.v-dims .spec-table-wrap { margin-top: .5rem; }
.v-standard {
  margin: 1rem 0 0;
  font-size: .84rem;
  color: var(--cs-info, #6B6560);
}

/* CTA row */
.v-cta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(26, 29, 33, .08);
}
.v-cta .btn { flex: 1 1 12rem; }
/* Instant-estimate link (injected by viewer-product.js) — secondary/ghost,
   full-width on its own row beneath the two request buttons. */
.v-cta__estimate {
  flex-basis: 100%;
  text-align: center;
  text-decoration: none;
}

/* ── More products strip ─────────────────────────────────── */
.v-more { margin-top: clamp(2.5rem, 6vw, 4rem); }
.v-more h2 { font-size: 1.3rem; margin: 0 0 1.1rem; }
.v-more .v-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.v-more .card__media { aspect-ratio: 16 / 9; }

/* ── Dialogs (Request a Quote / Sample) ──────────────────── */
.v-dialog {
  width: min(94vw, 520px);
  max-height: min(92vh, 92dvh);
  padding: 0;
  border: none;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(26, 29, 33, .35);
  overscroll-behavior: contain;
}
.v-dialog::backdrop { background: rgba(26, 29, 33, .55); }
.v-dialog form { padding: 1.5rem; }
.v-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .4rem;
}
.v-dialog__head h2 { font-size: 1.35rem; margin: 0; }
.v-dialog__close {
  flex: none;
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--cs-gray-300, #DCD5CA);
  border-radius: 8px;
  background: #fff;
  color: var(--cs-secondary, #1A1D21);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.v-dialog__close:hover { background: var(--cs-gray-100, #FAF8F5); border-color: var(--cs-gray-400, #C9C0B2); }
.v-form__product {
  margin: 0 0 1.25rem;
  padding: .65rem .9rem;
  background: var(--cs-gray-100, #FAF8F5);
  border: 1px solid var(--cs-gray-200, #F0EBE3);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--cs-info, #6B6560);
}
.v-form__product strong { color: var(--cs-secondary, #1A1D21); }
.v-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 480px) { .v-form__row { grid-template-columns: 1fr; } }

/* ── Footer ──────────────────────────────────────────────── */
.v-foot {
  background: var(--cs-secondary, #1A1D21);
  color: rgba(255, 255, 255, .62);
  padding: 2rem var(--v-gut);
  text-align: center;
  font-size: .84rem;
  line-height: 1.7;
}
.v-foot a { color: var(--cs-light, #EDE8E0); }
.v-foot p { margin: 0; }
