/* Green Theory 3D product viewer (embeds/gt-3d-viewer.html) */
:root {
  --bg: #FFFFFF; --ink: #1E1F1F; --muted: #6f6d68; --faint: #8a877f; --line: #ebe9e4; --line-2: #d9d9d9;
  --surface: #f5f4f1; --focus: #2F6B55; color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow-x: clip; } /* never a sideways scrollbar inside the iframe */
body { display: flex; flex-direction: column; font-family: "Skandia", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; color: var(--ink); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
#view { position: relative; flex: 1; min-height: 280px; width: 100%; overflow: hidden; background: #eeeeee; } /* Studio grey, as in the Studio */
#view, #config { max-width: 900px; } /* full width until 900px, then it stays 900px */
/* &autoheight=1: the page sizes the iframe to fit the content, so the view takes its height from its width */
.auto-height, .auto-height body { height: auto; }
.auto-height #view { flex: none; aspect-ratio: 1; }
@media (min-width: 600px) { .auto-height #view { aspect-ratio: 4 / 3; } }
#view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; outline: none; }
#view canvas:active { cursor: grabbing; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; font-size: 13px; color: var(--faint); transition: opacity .4s; pointer-events: none; }
#loading.done { opacity: 0; }
/* Product picker: a quiet card that names the collection above the product */
#picker { position: absolute; top: 14px; left: 14px; z-index: 3; max-width: calc(100% - 28px); }
#picker[hidden] { display: none; }
#pick-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; min-width: 240px; max-width: 360px; text-align: left;
  background: rgba(255,255,255,.92); cursor: pointer;
  border: 1px solid #e4e2dd; border-radius: 14px; padding: 10px 14px 10px 16px;
  box-shadow: 0 1px 2px rgba(30,31,31,.04), 0 4px 14px rgba(30,31,31,.05);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: border-color .15s, box-shadow .15s;
}
#pick-btn:hover { border-color: #cfccc5; }
#pick-btn .txt { flex: 1; min-width: 0; }
#pick-btn .col { display: block; font-size: 12px; line-height: 1.3; color: var(--faint); letter-spacing: .01em; }
#pick-btn .name { display: block; font-size: 15px; line-height: 1.3; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #f3f2ef; display: grid; place-items: center; transition: transform .2s; }
#pick-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
#pick-list {
  position: absolute; top: calc(100% + 8px); left: 0; width: max(100%, 300px); max-width: calc(100vw - 28px);
  max-height: min(62vh, 460px); overflow-y: auto; overscroll-behavior: contain;
  margin: 0; padding: 8px; list-style: none; background: #fff;
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 2px 6px rgba(30,31,31,.05), 0 18px 40px rgba(30,31,31,.12);
  opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity .15s, transform .15s;
}
#pick-list.open { opacity: 1; transform: none; pointer-events: auto; }
#pick-list .grp { padding: 12px 12px 6px; font-size: 12px; color: var(--faint); letter-spacing: .01em; }
#pick-list .grp:not(:first-child) { margin-top: 4px; border-top: 1px solid #f0eee9; }
#pick-list [role="option"] {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  font-size: 14.5px; color: var(--ink); cursor: pointer;
}
#pick-list [role="option"] .meta { margin-left: auto; font-size: 12px; color: #9a978f; white-space: nowrap; }
.tick { width: 16px; height: 16px; flex: none; color: var(--ink); visibility: hidden; }
#pick-list [role="option"][aria-selected="true"] .tick { visibility: visible; }
#pick-list [role="option"][aria-selected="true"] { font-weight: 500; }
#pick-list [role="option"]:hover, #pick-list [role="option"].active { background: var(--surface); }
@media (max-width: 520px) { #pick-btn { min-width: 0; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Options and colours under the 3D view */
/* Laid out like the Details rows on greentheory.com product pages: left aligned, a thin rule over
   each row, the label in a fixed column with its value beside it, and generous space between rows. */
#config { width: 100%; margin: 0; padding: 24px 0 calc(32px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 30px; font-size: 14px; }
#config section { border-top: 1px solid rgba(0,0,0,.3); padding-top: 6px; }
#config section[hidden] { display: none; }
.row-head { display: flex; align-items: baseline; gap: 0; margin-bottom: 18px; }
.row-head h2 { flex: none; width: 148px; font-size: 14px; font-weight: 500; margin: 0; white-space: nowrap; }
.row-head .val { flex: 1; font-size: 14px; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .row-head h2 { width: 110px; } }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.var {
  font-size: 13px; line-height: 1.2; min-height: 36px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: #fff; color: #555; border: 1px solid var(--line-2); transition: background-color .15s, color .15s, border-color .15s;
}
.var:hover { border-color: #9a9a9a; color: var(--ink); }
.var[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.opt-select {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 10px 8px 14px; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--line-2); border-radius: 12px; transition: border-color .15s;
}
.opt-select:hover { border-color: #9a9a9a; }
.opt-select .o-main, .opt-row .o-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.opt-select .o-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-sub { font-size: 12px; color: var(--faint); }

/* Two-colour products: pick the part, then its colour */
.parts { display: flex; gap: 4px; padding: 3px; margin-bottom: 18px; max-width: 422px; background: var(--surface); border-radius: 999px; }
.parts[hidden] { display: none; }
.part {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 6px 12px; border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  font-size: 13px; color: var(--muted); transition: background-color .15s, color .15s, box-shadow .15s;
}
.part span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part[aria-selected="true"] { background: #fff; color: var(--ink); font-weight: 500; box-shadow: 0 1px 3px rgba(30,31,31,.12); }
.dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 1px solid var(--b); }
.swatches { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 0 -6px; padding-left:5px; } /* only pull left, to line the first circle up with the label: a right pull overflows the frame */
.sw { position: relative; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; display: grid; place-items: center; }
.sw::before {
  content: ""; width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 1px solid var(--b);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px transparent; transition: box-shadow .25s ease-out, border-color .25s ease-out;
}
.sw:hover::before { border-color: #000; }
.sw[aria-checked="true"]::before { box-shadow: 0 0 0 2px #fff, 0 0 0 3px #000; }
.sw.static { cursor: default; }
.sw.static::before { box-shadow: none; }
.sw-custom:not([aria-checked="true"])::before { background: conic-gradient(#e0533b, #e8c33a, #5cb85c, #3a9fe0, #8a5ce0, #e0533b); border-color: transparent; }
.sw-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.sw-custom:focus-within::before { outline: 2px solid var(--focus); outline-offset: 5px; }
.single { display: flex; align-items: center; gap: 4px; font-size: 14px; margin: 0 0 0 -6px; }
.note { font-size: 12px; line-height: 1.33; color: var(--muted); max-width: 422px; margin: 18px 0 0; }
/* Resources: the CADdetails link, as on greentheory.com (icon on the left, underline drawn in on hover) */
#res-sec .row-head { margin-bottom: 0; align-items: flex-start; line-height: 1.4; } /* the label lines up with the link's first line */
.ext-link .nowrap { white-space: nowrap; background: none; }
#res-sec .val { overflow: visible; white-space: normal; } /* long product names wrap rather than cut off */
.ext-link { position: relative; display: inline-block; padding-left: 28px; font-size: 14px; color: var(--ink); text-decoration: none; }
.ext-link svg { position: absolute; left: 0; top: 3px; }
.ext-link span { background-image: linear-gradient(currentColor, currentColor); background-position: 0 100%; background-repeat: no-repeat; background-size: 0 1px; transition: background-size .3s ease; }
.ext-link:hover span, .ext-link:focus-visible span { background-size: 100% 1px; }
.note .dot { display: inline-block; width: 11px; height: 11px; vertical-align: -1px; margin-right: 6px; }

/* Option chooser: a card that floats up from the option button, over the 3D view. Floating keeps the
   page (and so an auto-height iframe) the same height; opening upward keeps it inside the frame.
   No dimmed overlay, which inside an iframe would shade only the frame's box. */
#opt-sec { position: relative; }
#sheet { position: absolute; left: 0; right: 0; z-index: 10; } /* bottom and max-height set by placeSheet() */
#sheet[hidden] { display: none; }
.sheet-card {
  display: flex; flex-direction: column; max-height: inherit; background: #fff; border: 1px solid var(--line-2); border-radius: 12px;
  padding: 4px 8px 8px; box-shadow: 0 2px 6px rgba(30,31,31,.05), 0 18px 40px rgba(30,31,31,.14); animation: rise .18s ease-out;
}
.opt-select[aria-expanded="true"] { border-color: var(--ink); }
.opt-select[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 4px 8px; }
.sheet-head h2 { margin: 0; font-size: 15px; font-weight: 500; }
.sheet-x { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface); cursor: pointer; display: grid; place-items: center; }
.search { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; color: var(--faint); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; padding: 11px 0; font: inherit; font-size: 16px; color: var(--ink); background: none; }
.attrs { display: flex; flex-direction: column; gap: 8px; margin: 0 4px 10px; }
.attr { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.attr::-webkit-scrollbar { display: none; }
.attr > span { flex: none; font-size: 12px; color: var(--faint); min-width: 84px; }
.chip { flex: none; border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
#sheet-list { list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.opt-row { display: flex; width: 100%; align-items: center; gap: 12px; min-height: 52px; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.opt-row:hover { background: var(--surface); }
.opt-row[aria-checked="true"] { background: var(--surface); }
.opt-row[aria-checked="true"] .tick { visibility: visible; }
.opt-row .o-name { font-size: 14.5px; }
#sheet-list .empty { padding: 18px 12px; font-size: 13px; color: var(--faint); }
#sheet-count { font-size: 12px; color: var(--faint); padding: 8px 12px 0; }
#sheet-count:empty { display: none; }
@keyframes rise { from { transform: translateY(4px); opacity: 0; } }

#render-test { position: absolute; right: 14px; top: 14px; z-index: 3; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: calc(100% - 28px); }
#render-test[hidden] { display: none; }
#render-test button { border: 1px dashed var(--line-2); background: rgba(255,255,255,.94); border-radius: 999px; padding: 6px 11px; font-size: 13px; cursor: pointer; }
#render-test button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
#ar-btn {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2;
  display: none; align-items: center; gap: 8px; min-height: 40px; padding: 9px 16px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line-2); font-size: 13px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
#ar-btn.show { display: inline-flex; }
#ar-btn svg { width: 16px; height: 16px; }
#ar-btn[aria-busy="true"] { opacity: .6; }
#ar-ui { display: none; position: fixed; inset: 0; pointer-events: none; font-family: inherit; }
#ar-ui.on { display: block; }
#ar-hint {
  position: absolute; left: 50%; bottom: calc(32px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: rgba(20,20,20,.72); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; white-space: nowrap;
}
#ar-exit {
  position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; pointer-events: auto;
  background: rgba(20,20,20,.72); color: #fff; border: 0; border-radius: 999px; padding: 10px 16px; font-size: 14px;
}
@media (prefers-reduced-motion: reduce) { *, ::before { transition: none !important; animation: none !important; } }
