/* ==========================================================================
   Kinox Capture (capture.html)
   One centered column for phones: sign in, choose a model, capture, follow the job and share the result.
   Colors, buttons, the brand mark and the language switcher come from style.css; this file lays out the page.
   ========================================================================== */
:root {
  color-scheme: dark;
}

/* style.css fixes the body to the viewport for the studio; this page scrolls */
.capture-page {
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
  background: var(--bg-dark);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.capture-page.is-recorder-open {
  overflow: hidden;
}

/* Top bar */
.capture-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) calc(env(safe-area-inset-right, 0px) + 16px) 6px calc(env(safe-area-inset-left, 0px) + 16px);
  background: rgba(13, 17, 23, 0.94);
  border-bottom: 1px solid var(--border-color);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.capture-brand {
  flex-shrink: 0;
  min-height: 44px;
}

.capture-heading {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capture-lang {
  flex-shrink: 0;
}

.capture-lang .lang-btn {
  height: 38px;
  min-width: 40px;
  font-size: 12px;
}

/* Guided tour button (tours/capture.js, styled by tour.css) after the language buttons, as tall as they are. On narrow
   phones it shows only its icon (its name stays in the accessible label), so the heading keeps its room. */
.capture-topbar .capture-tour-button {
  flex-shrink: 0;
  min-height: 38px;
}

@media (max-width: 419px) {
  .capture-topbar .capture-tour-button {
    min-width: 38px;
    padding: 0;
    justify-content: center;
  }

  .capture-tour-button .kinox-tour-button-label {
    display: none;
  }
}

/* Column */
.capture-main {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px calc(env(safe-area-inset-right, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 32px) calc(env(safe-area-inset-left, 0px) + 16px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.capture-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.capture-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.capture-step {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
}

.capture-hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.capture-hint:empty {
  display: none;
}

/* Buttons: at least 48px tall, and labels may wrap (Japanese and Turkish labels run long) */
.capture-page .btn:not(.btn-xs):not(.btn-sm):not(.btn-lg),
.capture-page .btn-lg {
  height: auto;
  min-height: 48px;
  padding: 10px 18px;
  font-size: 14px;
  line-height: 1.3;
  white-space: normal;
  text-align: center;
}

.capture-page .btn-lg {
  min-height: 52px;
  font-size: 15px;
}

.capture-page .btn-sm {
  height: auto;
  min-height: 40px;
  padding: 6px 14px;
  font-size: 13px;
  white-space: normal;
}

.capture-page .btn {
  touch-action: manipulation;
  text-decoration: none;
}

.capture-page .btn:focus-visible,
.capture-page .lang-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Intro */
.capture-intro {
  padding: 4px 2px 0;
}

.capture-intro-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.capture-intro-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.capture-tips-label {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.capture-tips {
  list-style: none;
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.capture-tips li {
  position: relative;
  padding-left: 22px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-main);
}

.capture-tips li::before {
  content: "✓";
  position: absolute;
  left: 2px;
  top: 0;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Account */
.account-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
  overflow-wrap: anywhere;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.account-google {
  flex: 1 1 100%;
}

.account-card.is-signed-in {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.account-card.is-signed-in .account-text {
  flex: 1 1 180px;
  min-width: 0;
}

.account-card.is-signed-in .capture-message {
  flex-basis: 100%;
}

/* Messages */
.capture-messages {
  display: grid;
  gap: 8px;
}

.capture-messages:empty {
  display: none;
}

.capture-message {
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-wrap: anywhere;
}

.capture-message.is-error {
  color: #ffa198;
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.4);
}

.capture-message.is-warning {
  color: #e3b341;
  background: rgba(210, 153, 34, 0.1);
  border-color: rgba(210, 153, 34, 0.4);
}

.capture-message.is-success {
  color: #56d364;
  background: rgba(46, 160, 67, 0.1);
  border-color: rgba(46, 160, 67, 0.4);
}

.capture-message.is-hint {
  padding: 0;
  color: var(--text-muted);
  background: none;
  border: 0;
}

/* Model choice */
.model-options {
  display: grid;
  gap: 10px;
}

.model-option {
  position: relative;
  display: block;
  cursor: pointer;
}

.model-option input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.model-option-body {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 4px;
  min-height: 64px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.model-option-body::before {
  content: "";
  grid-row: 1 / span 2;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 2px solid var(--text-dim);
  border-radius: 50%;
}

.model-option input:checked + .model-option-body {
  background: rgba(88, 166, 255, 0.08);
  border-color: var(--accent-cyan);
}

.model-option input:checked + .model-option-body::before {
  border-color: var(--accent-cyan);
  background: radial-gradient(circle, var(--accent-cyan) 0 38%, transparent 44%);
}

.model-option input:focus-visible + .model-option-body {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.model-option-name {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.model-badge {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #56d364;
  background: rgba(46, 160, 67, 0.15);
  border-radius: var(--radius-full);
}

.model-option-desc {
  grid-column: 2;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Capture options */
.capture-options {
  display: grid;
  gap: 10px;
}

.capture-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  font-family: var(--font-sans);
  text-align: left;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.capture-option:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.capture-option:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.capture-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.capture-option-primary {
  color: #ffffff;
  background: linear-gradient(135deg, #1f6feb 0%, #0099ff 100%);
  border-color: rgba(255, 255, 255, 0.15);
}

.capture-option-primary:active:not(:disabled) {
  background: linear-gradient(135deg, #1a5fcc 0%, #0088e6 100%);
}

.capture-option-icon {
  display: flex;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  height: 42px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.capture-option-icon svg {
  width: 24px;
  height: 24px;
}

.capture-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.capture-option-label {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.capture-option-hint {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-muted);
}

.capture-option-primary .capture-option-hint {
  color: rgba(255, 255, 255, 0.82);
}

@media (hover: hover) {
  .capture-option:not(:disabled):not(.capture-option-primary):hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
  }

  .capture-option-primary:not(:disabled):hover {
    filter: brightness(1.08);
  }
}

/* Chosen input */
.input-preview {
  display: grid;
  gap: 10px;
}

.input-video {
  display: block;
  width: 100%;
  max-height: 45vh;
  background: #000000;
  border-radius: var(--radius-md);
}

.input-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.input-summary-text {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Fields */
.capture-field {
  display: grid;
  gap: 6px;
}

.capture-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* 16px text keeps iOS Safari from zooming in when the field is focused */
.capture-page .capture-field input[type="text"] {
  height: 48px;
  min-width: 0;
  font-size: 16px;
}

.capture-submit {
  width: 100%;
}

/* Job progress */
.job-model {
  font-size: 13.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.job-model:empty {
  display: none;
}

.job-progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
}

.job-progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: inherit;
  transition: width 0.4s ease;
}

.job-progress.is-indeterminate .job-progress-bar {
  width: 35%;
  transition: none;
  animation: captureIndeterminate 1.4s ease-in-out infinite;
}

@keyframes captureIndeterminate {
  from { transform: translateX(-100%); }
  to { transform: translateX(290%); }
}

.job-status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.job-stage {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.job-percent {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-cyan);
}

.job-elapsed {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.job-elapsed:empty,
.job-stage:empty {
  display: none;
}

.job-actions,
.result-actions {
  display: grid;
  gap: 10px;
}

/* Result */
.result-card {
  text-align: center;
}

.result-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto;
  font-size: 28px;
  font-weight: 800;
  color: #56d364;
  background: rgba(46, 160, 67, 0.15);
  border-radius: 50%;
}

.result-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
}

.result-name {
  font-size: 14px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.result-card .capture-field {
  text-align: left;
}

.capture-page .result-card input[type="text"] {
  font-family: var(--font-mono);
  font-size: 14px;
}

/* The note that the link is public, with the button that turns it off beside it (below it on narrow phones) */
.result-link-public {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
}

/* Recent captures */
.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recent-list {
  list-style: none;
  display: grid;
  gap: 8px;
}

.recent-list:empty {
  display: none;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.recent-body {
  flex: 1;
  min-width: 0;
}

.recent-model {
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.recent-meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.recent-error {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.4;
  color: #ffa198;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.recent-side {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  align-items: flex-end;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
}

.status-pill.is-queued {
  color: #e3b341;
  background: rgba(210, 153, 34, 0.15);
}

.status-pill.is-claimed,
.status-pill.is-running {
  color: var(--accent-cyan);
  background: rgba(88, 166, 255, 0.15);
}

.status-pill.is-completed {
  color: #56d364;
  background: rgba(46, 160, 67, 0.15);
}

.status-pill.is-failed {
  color: #ffa198;
  background: rgba(248, 81, 73, 0.15);
}

/* Recorder: full-screen camera with the controls above the home indicator */
.recorder {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  color: #ffffff;
  background: #000000;
  overscroll-behavior: contain;
}

.recorder-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000000;
}

.recorder-top,
.recorder-track,
.recorder-bottom {
  position: relative;
}

.recorder-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 12px) 10px calc(env(safe-area-inset-left, 0px) + 12px);
  background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
}

.recorder-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-size: 20px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
}

.recorder-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.55);
  border-radius: var(--radius-full);
}

.recorder-limit {
  color: rgba(255, 255, 255, 0.65);
}

.recorder-dot {
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

.recorder.is-recording .recorder-dot {
  background: #f85149;
  box-shadow: 0 0 8px #f85149;
}

.recorder-track {
  height: 4px;
  margin: 0 calc(env(safe-area-inset-right, 0px) + 16px) 0 calc(env(safe-area-inset-left, 0px) + 16px);
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

.recorder-track-bar {
  width: 0;
  height: 100%;
  background: #f85149;
  border-radius: inherit;
}

.recorder-track-bar.is-good {
  background: #3fb950;
}

.recorder-track-mark {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 12px;
  background: #ffffff;
}

.recorder-spacer {
  flex: 1;
}

.recorder-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px calc(env(safe-area-inset-right, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 18px) calc(env(safe-area-inset-left, 0px) + 16px);
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75));
}

.recorder-tips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.recorder-tips li {
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.55);
  border-radius: var(--radius-full);
}

.recorder-status {
  min-height: 20px;
  max-width: 460px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.recorder-status.is-error {
  padding: 8px 12px;
  color: #ffa198;
  text-shadow: none;
  background: rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-md);
}

.recorder-shutter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 78px;
  padding: 0;
  background: rgba(0, 0, 0, 0.2);
  border: 4px solid #ffffff;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
}

.recorder-shutter:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.recorder-shutter:focus-visible,
.recorder-close:focus-visible {
  outline: 3px solid var(--accent-cyan);
  outline-offset: 3px;
}

.recorder-shutter-inner {
  width: 58px;
  height: 58px;
  background: #f85149;
  border-radius: 50%;
  transition: width 0.2s ease, height 0.2s ease, border-radius 0.2s ease;
}

.recorder.is-recording .recorder-shutter-inner {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.recorder-shutter-label {
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Narrow phones: the logo alone leaves the heading more room */
@media (max-width: 419px) {
  .capture-brand .brand-name {
    display: none;
  }
}

@media (min-width: 600px) {
  .capture-main {
    padding-top: 24px;
  }

  .capture-intro-title {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .capture-page *,
  .capture-page *::before,
  .capture-page *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }

  .job-progress.is-indeterminate .job-progress-bar {
    width: 100%;
    opacity: 0.4;
  }
}
