/* Jig Quiz Web App — layout + top menu + screens
   Chrome tokens + top bar match webviewer 2.0's design language — see
   docs/webviewer-2-design-reference.md for the source values. */

:root {
  --jsv-accent: #304DE4;
  --jsv-accent-hover: #2740c2;
  --jsv-text: #101b31;
  --jsv-text-secondary: #525c76;
  --jsv-text-muted: #747c90;
  --jsv-text-disabled: #cacdd5;
  /* Mirrors quiz.css's --jq-success so the header's "question next" affordance
     is the same green the overlay uses for a correct answer. */
  --jsv-success: #0ca977;
  --jsv-surface: #ffffff;
  --jsv-surface-bar: #fafafb;
  --jsv-shadow: 0 9px 20px rgba(15, 13, 35, 0.1);
  --jsv-radius-btn: 8px;
  --jsv-radius-menu: 16px;
  --jsv-radius-pill: 9999px;
  --jsv-font: 'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--jsv-font);
  background: var(--jsv-surface-bar);
  color: var(--jsv-text);
  overflow: hidden;
}

[hidden] { display: none !important; }

/* ── Setup / landing screens ─────────────────────────────────────── */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--jsv-surface-bar);
}

.screen-card {
  width: 100%;
  max-width: 440px;
  padding: 40px 32px;
  background: var(--jsv-surface);
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: var(--jsv-shadow);
}

.screen-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--jsv-text);
}

.screen-subtitle {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--jsv-text-secondary);
  line-height: 1.5;
}

.stack > * + * { margin-top: 14px; }

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--jsv-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--jsv-text);
  background: var(--jsv-surface);
  border: 1px solid #e2e8f0;
  border-radius: var(--jsv-radius-btn);
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus {
  border-color: var(--jsv-accent);
}

.field-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--jsv-text-muted);
  line-height: 1.5;
}

.error-text {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  color: #e5484d;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  border: none;
  border-radius: var(--jsv-radius-btn);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, background 0.15s;
}

.btn-primary {
  background: var(--jsv-accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--jsv-accent-hover); }
.btn-primary:active { transform: translateY(1px); }

/* ── Viewer ──────────────────────────────────────────────────────── */
.viewer {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #f4f5f7;
}

/* Viewer-header — replicates the native webviewer 2.0 top bar (see
   docs/webviewer-2-design-reference.md §5.1): 64px, --jsv-surface-bar,
   --jsv-shadow, no border, 12px/24px padding, 32px Jig logo then the title
   at 20px/500. No Back chevron — the native bar has none (UAT 2026-08-25).
   Stays position:static above the iframe rather than floating over it —
   this is wrapper chrome, not a duplicate of the viewer's own (absent, in
   the query-param iframe) bar. */
.viewer-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 12px 24px;
  background: var(--jsv-surface-bar);
  box-shadow: var(--jsv-shadow);
  color: var(--jsv-text);
  z-index: 10;
}

/* Embed mode: strip the viewer header entirely so the iframe shows only the
   3D viewer + quiz overlays. Triggered by ?embed=1 on the URL. Core feature,
   not demo styling — kept here rather than in any client theme. */
body.is-embed .viewer-header { display: none !important; }

/* Logo — 32×32 like the native bar. Tenant white-labelling is not part of
   this change (open question, see the plan's Non-goals). */
/* The Jig mark is square and sits in the native bar's 32x32 slot. A TENANT's
   logo is whatever they uploaded — Stryker's happens to be square (512x512),
   but a wordmark is typically wide, and a fixed square box with the default
   object-fit: fill squashes it. So: pin the HEIGHT, let the width follow the
   image, and cap it so a very wide logo cannot crowd the Jig title. */
.vh-logo {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: block;
  object-fit: contain;
}

/* Set by tenant-branding.js only when the swap actually happens, so the
   default mark keeps its exact 32x32 box. */
.vh-logo.is-tenant-logo {
  width: auto;
  max-width: 140px;
}

.vh-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

/* Native h1: 20px/500, 26px line-height, #272b30. */
.vh-jig-name {
  font-size: 20px;
  font-weight: 500;
  line-height: 26px;
  color: #272b30;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vh-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Persistent quiz progress (G5) ────────────────────────────────────
   Counter + thin fill bar, live for the whole session while a quiz runs, so
   a question landing on an unpredictable step reads as expected rather than
   random. Sits in its own header slot between the Jig name and the
   quiz/kebab group; 8px of margin keeps it off the buttons.

   The track/fill pair reuses the Chrome extension's in-modal progress idiom
   (content.css .jq-progress-bar/.jq-progress-fill): a hairline track in the
   border colour, an accent fill, width transitioned at 0.4s ease. */
.vh-quiz-progress {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 96px;
  margin-right: 8px;
  padding: 6px 10px;
  background: var(--jsv-surface);
  box-shadow: var(--jsv-shadow);
  border-radius: var(--jsv-radius-btn);
}

.vh-quiz-progress-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.vh-quiz-progress-label {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--jsv-text-secondary);
  font-variant-numeric: tabular-nums; /* the count must not jitter as it ticks */
}

/* Lookahead: the next step carries an unanswered question. The Jig's own Next
   button is inside a cross-origin iframe and unreachable from this document,
   so the affordance lives on chrome we DO own — this indicator. */
.vh-quiz-progress-flag {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--jsv-success);
}

.vh-quiz-progress.is-next-question .vh-quiz-progress-label { color: var(--jsv-success); }
.vh-quiz-progress.is-next-question .vh-quiz-progress-fill { background: var(--jsv-success); }

.vh-quiz-progress.is-complete .vh-quiz-progress-fill { background: var(--jsv-success); }

.vh-quiz-progress-track {
  height: 4px;
  background: #e2e4e8;
  border-radius: var(--jsv-radius-pill);
  overflow: hidden;
}

.vh-quiz-progress-fill {
  width: 0;
  height: 100%;
  background: var(--jsv-accent);
  border-radius: var(--jsv-radius-pill);
  transition: width 0.4s ease, background 0.2s ease;
}

/* Tertiary button (Quiz) — white surface, 8px radius, soft shadow, slate text. */
.vh-tertiary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 8px 16px;
  font-family: var(--jsv-font);
  font-size: 14px;
  font-weight: 500;
  color: var(--jsv-text-secondary);
  background: var(--jsv-surface);
  border: none;
  box-shadow: var(--jsv-shadow);
  border-radius: var(--jsv-radius-btn);
  cursor: pointer;
  transition: color 0.15s;
}

.vh-tertiary-btn:hover { color: var(--jsv-text); }

.vh-tertiary-btn svg {
  width: 16px;
  height: 16px;
}

/* Primary button (LMS finish) — indigo accent. */
.vh-primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 8px 16px;
  font-family: var(--jsv-font);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--jsv-accent);
  border: none;
  border-radius: var(--jsv-radius-btn);
  cursor: pointer;
  transition: background 0.15s;
}

.vh-primary-btn:hover { background: var(--jsv-accent-hover); }
.vh-primary-btn:disabled { opacity: 0.6; cursor: default; }

/* Kebab trigger — 40px circular tertiary button, same family as the back button. */
.vh-kebab-wrap {
  position: relative;
}

.vh-icon-circle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--jsv-text-secondary);
  background: var(--jsv-surface);
  border: none;
  box-shadow: var(--jsv-shadow);
  border-radius: var(--jsv-radius-pill);
  cursor: pointer;
  transition: color 0.15s;
}

.vh-icon-circle-btn:hover { color: var(--jsv-text); }

.vh-icon-circle-btn svg {
  width: 18px;
  height: 18px;
}

/* Kebab dropdown — 16px-radius white panel, icon+label rows, 1px dividers. */
.vh-kebab-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 240px;
  padding: 8px;
  background: var(--jsv-surface);
  box-shadow: 0 40px 64px -12px rgba(0, 0, 0, 0.08), 0 0 14px -4px rgba(0, 0, 0, 0.05), 0 32px 48px -8px rgba(0, 0, 0, 0.1);
  border-radius: var(--jsv-radius-menu);
}

.vh-kebab-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  font-family: var(--jsv-font);
  font-size: 14px;
  font-weight: 400;
  color: var(--jsv-text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--jsv-radius-btn);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.vh-kebab-item:hover {
  color: var(--jsv-text);
  background: var(--jsv-surface-bar);
}

.vh-kebab-item svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.vh-kebab-divider {
  margin: 8px 4px;
  border: none;
  border-top: 1px solid #e2e4e8;
}

/* No orphaned divider when the item after it (Restart quiz) is hidden. */
.vh-kebab-divider:has(+ [hidden]),
.vh-kebab-divider:last-child {
  display: none;
}

.viewer-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  display: block;
  background: #f4f5f7;
}

@media (max-width: 640px) {
  .viewer-header { gap: 8px; padding: 12px 16px; }
  .vh-jig-name { font-size: 14px; }
  .vh-tertiary-btn { padding: 8px 12px; }
  .vh-primary-btn { padding: 8px 12px; font-size: 13px; }
  .vh-kebab-menu { width: 220px; }
  .vh-quiz-progress { min-width: 84px; margin-right: 4px; padding: 6px 8px; }
  /* Too tight for prose at this width — the green label + fill still carry
     the "question next" signal on their own. */
  .vh-quiz-progress-flag { display: none; }
  .screen-card { padding: 28px 22px; }
}

@media (max-width: 420px) {
  .vh-tertiary-btn { width: 40px; padding: 0; justify-content: center; }
  .vh-btn-label { display: none; }
}
