/* QweRty host stylesheet — app layout only, consumes the skarn --sh-* bridge. */

/* skarn's grid uses the Bootstrap gutter pattern (negative row margin + column
   padding). That only works with border-box sizing; skarn sets it on individual
   components but not globally, so the host supplies the standard reset. Without
   it, 33.33% + padding and 66.66% + padding exceed 100% and the columns wrap. */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

.qwerty-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--sh-bg);
  color: var(--sh-fg);
  font-family: var(--sh-font, system-ui, sans-serif);
}

.qwerty-titlebar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--sh-hairline);
  background: var(--sh-track);
  position: sticky;
  top: 0;
  z-index: 20;
}

.qwerty-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.qwerty-mark { color: var(--sh-accent); }
.qwerty-tagline { display: none; }
@media (min-width: 900px) { .qwerty-tagline { display: inline; } }

.qwerty-tabs { flex: 1; }

.qwerty-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  box-sizing: border-box;
}

.qwerty-pages { display: block; }
.qwerty-pages .skf-ribbon-page { padding: 0; }

/* skf-responsive gives .skf-ribbon-page.is-active "min-inline-size: max-content"
   so a *ribbon toolbar* can scroll horizontally on phones. We use it as a full
   page container, so undo that — otherwise the page grows to its content's
   max-content width (839px) inside a 373px parent and every element is pushed
   off-screen. Specificity here beats the framework rule. */
.qwerty-pages .skf-ribbon-page.is-active {
  min-inline-size: 0;
  min-width: 0;
  width: 100%;
  flex-wrap: wrap;
}
.qwerty-page-root {
  flex: 1 1 100%;
  width: 100%;
  max-width: 1180px;
  min-width: 0;
  margin: 0 auto;
}
.qwerty-page-root .skf-row,
.qwerty-page-root .skf-row > * { min-width: 0; }
.qwerty-stage canvas,
.qwerty-video-wrap canvas { max-width: 100%; }

.qwerty-card {
  padding: 16px;
  border: 1px solid var(--sh-hairline);
  background: var(--sh-surface);
  border-radius: var(--sh-radius, 8px);
  margin-bottom: 16px;
}

.qwerty-field { margin-bottom: 12px; }
.qwerty-field > .skf-caption-heading { display: block; margin-bottom: 6px; }

.qwerty-seg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.qwerty-value {
  font-variant-numeric: tabular-nums;
  color: var(--sh-muted);
  margin-inline-start: 8px;
}

.qwerty-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.qwerty-stage {
  display: grid;
  place-items: center;
  padding: 12px;
  background: var(--sh-track);
  border-radius: var(--sh-radius, 8px);
  min-height: 320px;
}
.qwerty-stage canvas {
  image-rendering: pixelated;
  max-width: 100%;
  height: auto;
  background: #fff;
  border-radius: 4px;
  box-shadow: var(--sh-shadow-float, 0 8px 30px rgba(0,0,0,.25));
}

.qwerty-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.qwerty-stat {
  padding: 8px 10px;
  border: 1px solid var(--sh-hairline);
  border-radius: 6px;
  background: var(--sh-bg);
}
.qwerty-stat b {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.qwerty-drop { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 28px; border: 1px dashed var(--sh-hairline); border-radius: var(--sh-radius, 8px); color: var(--sh-muted); cursor: pointer; }
.qwerty-drop.is-over { border-color: var(--sh-accent); color: var(--sh-accent); }

.qwerty-video-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 3 / 4;            /* replaced at runtime with the camera's real ratio */
  max-height: 58vh;
  display: grid;
  place-items: center;
  background: #000;
  border-radius: var(--sh-radius, 8px);
  overflow: hidden;
}
.qwerty-video-wrap video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.qwerty-video-wrap canvas { width: 100%; height: 100%; object-fit: contain; display: block; }

.qwerty-result-text {
  width: 100%;
  min-height: 120px;
  box-sizing: border-box;
  font-family: var(--sh-font-mono, monospace);
  font-size: 13px;
}

.qwerty-status-row { display: flex; align-items: center; gap: 10px; }
.qwerty-status-row .skf-progress { flex: 1; }

.qwerty-hidden { display: none !important; }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .qwerty-body { padding: 10px; }
  .qwerty-card { padding: 12px; margin-bottom: 12px; }
  .qwerty-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qwerty-stage { min-height: 0; padding: 8px; }
  .qwerty-stage canvas { max-height: 56vh; width: auto; }
  .qwerty-video-wrap { max-height: 52vh; }
  .qwerty-titlebar { gap: 10px; padding: 8px 10px; }
  .qwerty-actions .skf-btn { flex: 1 1 auto; }
}

@media (max-width: 600px) {
  .qwerty-brand { font-size: 15px; }
  .qwerty-stat b { font-size: 16px; }
  .qwerty-drop { padding: 18px 12px; }
  .qwerty-result-text { min-height: 90px; }
}
