/* X-Ray tool — phase 2: everything fits inside the toy X-ray machine frame.
   The frame image + the camera screen window + the two button tap targets all
   live in one fixed-aspect .machine container, positioned as % of it, so they
   stay locked together however the frame is sized/cropped to the viewport. */

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #1f7ec0;       /* frame blue — blends any sub-pixel edge gap */
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Fixed-aspect container (752×1344) sized to COVER the viewport (crops the
   slightly-overflowing dimension; the screen + buttons are centered so they're
   never clipped). */
.machine {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max(100vw, calc(100svh * 752 / 1344));
  height: max(100svh, calc(100vw * 1344 / 752));
}

.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;          /* container shares the frame aspect → no distortion */
  display: block;
  pointer-events: none;       /* taps pass through to the button targets */
  user-select: none;
  -webkit-user-drag: none;
}

/* ---- Camera screen window (over the dark rectangle of the frame) ---- */
.screen-window {
  position: absolute;
  left: 11%;
  top: 18%;
  width: 79.3%;
  height: 57.5%;
  overflow: hidden;
  border-radius: 4.5%;        /* match the painted screen's rounded corners */
  background: #05080f;
  z-index: 1;
}
#video,
#result {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;          /* video + result share the same crop → aligned */
  background: #05080f;
}
#result {
  opacity: 0;
  visibility: hidden;
  transition: opacity 250ms ease;
}
#result.show {
  opacity: 1;
  visibility: visible;
}

/* Loading / developing text, shown on the machine's screen. */
.loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10%;
  text-align: center;
  background: #05080f;
  color: #bfe9ff;
  font: 600 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.02em;
}
.loading.hide {
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease;
}

/* ---- Button tap targets (transparent, over the painted buttons) ---- */
.btn {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 20%;                 /* % of container width; aspect-ratio keeps it round */
  aspect-ratio: 1;
  z-index: 3;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translate(-50%, -50%) scale(0.94); }

.btn-xray   { left: 23.6%; top: 89.4%; }
.btn-switch { left: 50.7%; top: 89.4%; }
.btn-finish { left: 76.2%; top: 89.4%; }

/* Blue finish button dimmed until the first X-ray is taken. */
.btn-finish:disabled { cursor: default; }
.btn-finish:disabled::before {
  content: "";
  position: absolute;
  inset: 2%;
  border-radius: 50%;
  background: rgba(6, 14, 30, 0.55);
}

/* ---- Final card (same cream card shell as the other tools' verdict cards) ---- */
.final-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 400ms ease, visibility 0s linear 400ms;
}
.final-overlay.show {
  opacity: 1;
  visibility: visible;
  transition: opacity 400ms ease;
}
.final-scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 10, 20, 0.6);
}
.final-card {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(86vw, 400px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 28px;
  background: var(--color-cream);
  border-radius: 28px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  font-family: var(--font-rounded);
  transform: translate(-50%, calc(-50% + 8vh));
  opacity: 0;
  transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1), opacity 450ms ease;
}
.final-overlay.show .final-card {
  transform: translate(-50%, -50%);
  opacity: 1;
}
.final-thump {
  width: 124px;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.2));
}
.final-title {
  margin: 2px 0 0;
  text-align: center;
  font-weight: 800;
  font-size: 25px;
  line-height: 1.2;
  color: var(--color-button-text);
}
.final-lead {
  margin: 0;
  text-align: center;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.3;
  color: var(--color-button-text);
  opacity: 0.85;
}
.final-findings {
  margin: 2px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  font-weight: 800;
  font-size: 22px;
  line-height: 1.2;
  color: var(--color-button-text);
}
.final-body {
  margin: 0;
  text-align: center;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.4;
  color: var(--color-button-text);
}
.verdict-divider {
  width: 56px;
  height: 2px;
  border-radius: 1px;
  background: var(--color-button-text);
  opacity: 0.22;
  margin: 4px 0;
}
.final-return {
  margin: 0;
  text-align: center;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.4;
  color: var(--color-button-text);
  opacity: 0.75;
}

/* ---- Intro overlay (same treatment as the other tools) ---- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #7fc3e6;          /* blue-family hold color while the video loads */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-rounded);
  transition: opacity 600ms ease;
}
.intro::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.35) 40%, rgba(0, 0, 0, 0) 100%);
  pointer-events: none;
  z-index: 1;
}
.intro.hide { opacity: 0; pointer-events: none; }
.intro-video { width: 100%; height: 100%; object-fit: cover; }
.intro-cta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 7%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.intro-caption {
  margin: 0;
  text-align: center;
  font-weight: 800;
  font-size: 38px;
  letter-spacing: 0.005em;
  color: var(--color-cream);
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.55);
}
.intro-hint {
  margin: 0;
  padding: 13px 28px;
  background: var(--color-cream);
  color: var(--color-button-text);
  font: 700 18px/1 var(--font-rounded);
  letter-spacing: 0.04em;
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--color-cream-edge), 0 10px 18px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  animation: hint-bob 1.6s ease-in-out infinite;
  transition: opacity 250ms ease;
}
.intro-hint.hide { opacity: 0; animation: none; }
@keyframes hint-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.intro-skip {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 14px);
  right: calc(env(safe-area-inset-right) + 14px);
  z-index: 2;
  width: 46px;
  height: 46px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-button-text);
  color: var(--color-cream);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
  opacity: 0.92;
}
.intro-skip:hover,
.intro-skip:focus-visible { opacity: 1; }
.intro-skip:active { transform: scale(0.92); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.intro-skip-icon {
  display: block;
  width: 60%;
  height: 60%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
}

/* ---- Instruction card (same cream card shell as the other tools) ---- */
.instruction-card {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 180;
  width: min(86vw, 400px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 28px;
  background: var(--color-cream);
  border-radius: 28px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  font-family: var(--font-rounded);
  transform: translate(-50%, calc(-50% + 10vh));
  opacity: 0;
  visibility: hidden;
  transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1),
              opacity 450ms ease,
              visibility 0s linear 600ms;
}
.instruction-card.show {
  transform: translate(-50%, -50%);
  opacity: 1;
  visibility: visible;
  transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1), opacity 400ms ease;
}
.instruction-thump {
  width: 150px;
  height: auto;
  margin-bottom: -4px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.2));
}
.instruction-title {
  margin: 2px 0 0;
  text-align: center;
  font-weight: 800;
  font-size: 25px;
  line-height: 1.2;
  color: var(--color-button-text);
}
.instruction-body {
  margin: 0;
  text-align: center;
  font-weight: 600;
  font-size: 17px;
  line-height: 1.4;
  color: var(--color-button-text);
}
.instruction-grownup {
  margin: -2px 0;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.35;
  color: var(--color-button-text);
  opacity: 0.6;
}