/* Blind comparison page. Tokens follow the editor's «карандаш и тушь»
   (web/src/index.css), system fonts only: the CSP allows nothing external. */
:root {
  --background: #f2f3f0;
  --foreground: #16181d;
  --card: #fbfbf9;
  --muted: #5a5f68;
  --border: #d6d8d2;
  --primary: #16181d;
  --primary-foreground: #f6f6f3;
  --accent: #1f6fa8;
  --error: #c4302a;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #16181d;
    --foreground: #e9eae6;
    --card: #1d2026;
    --muted: #a3a8b0;
    --border: #2f333b;
    --primary: #e9eae6;
    --primary-foreground: #16181d;
    --accent: #7cc0ea;
    --error: #e5645d;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.card {
  max-width: 640px;
  margin: 8vh auto 0;
  padding: 28px 28px 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.prose h1 {
  margin: 0 0 16px;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.prose p {
  margin: 0 0 14px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.error {
  margin: 12px 0 0;
  color: var(--error);
}

/* --- intro form --- */

.start {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

.field input {
  width: 100%;
  max-width: 280px;
  padding: 9px 11px;
  font: inherit;
  letter-spacing: 0.04em;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.field input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 10px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.primary,
.secondary {
  padding: 10px 22px;
  font-weight: 500;
}

.primary {
  color: var(--primary-foreground);
  background: var(--primary);
  border: 1px solid var(--primary);
}

.secondary {
  color: var(--foreground);
  background: transparent;
  border: 1px solid var(--border);
}

.credit-note {
  margin: 18px 0 0;
}

/* --- a pair --- */

.pair-head {
  max-width: 900px;
  margin: 0 auto 18px;
  text-align: center;
}

.question {
  margin: 0 0 14px;
  font-size: 1.15rem;
  font-weight: 500;
}

.progress {
  height: 4px;
  max-width: 420px;
  margin: 0 auto;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.progress-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
}

.images {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.shot {
  margin: 0;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.shot figcaption {
  margin: 0 0 8px;
  font-weight: 600;
  text-align: center;
}

.shot-src figcaption {
  font-weight: 400;
  color: var(--muted);
}

.shot img {
  display: block;
  /* The crops are small (at most 480 px): shown at the column's width, so a
     tiny one is not judged at thumbnail size; a tall one is held to the
     screen's height. All three of a pair have the same size. */
  width: 100%;
  max-width: 480px;
  height: auto;
  max-height: 65vh;
  object-fit: contain;
  margin: 0 auto;
  /* Manga pages are white: keep the crops on white in dark mode too. */
  background: #fff;
}

.switch,
.hint {
  display: none;
}

.credit {
  margin: 10px 0 0;
  text-align: center;
}

.answers {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 22px auto 0;
}

.answer {
  min-width: 150px;
  padding: 12px 18px;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  font-weight: 500;
}

.answer:not(:disabled):hover {
  border-color: var(--foreground);
}

.answer[data-answer='same'] {
  color: var(--muted);
}

.key {
  display: inline-block;
  min-width: 1.4em;
  margin-right: 6px;
  padding: 0 4px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Medium screens: the original on top as the reference, A and B below. */
@media (max-width: 1099px) and (min-width: 640px) {
  .images {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shot-src {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 60%;
  }
}

/* Phones: one image at a time, switched by the tabs or a tap. */
@media (max-width: 639px) {
  .page {
    padding: 14px 16px 28px;
  }
  .card {
    margin-top: 4vh;
    padding: 22px 18px 18px;
  }
  .prose h1 {
    font-size: 1.35rem;
  }
  .question {
    font-size: 1rem;
  }
  .switch {
    display: flex;
    margin: 0 auto 10px;
    padding: 3px;
    max-width: 360px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .switch button {
    flex: 1;
    padding: 8px 0;
    color: var(--muted);
    background: transparent;
    border: 0;
  }
  .switch button[aria-selected='true'] {
    color: var(--primary-foreground);
    background: var(--primary);
  }
  .images {
    display: block;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .shot figcaption {
    display: none;
  }
  .images .shot {
    display: none;
  }
  .images[data-view='src'] .shot[data-view='src'],
  .images[data-view='left'] .shot[data-view='left'],
  .images[data-view='right'] .shot[data-view='right'] {
    display: block;
  }
  .hint {
    display: block;
    margin: 8px 0 0;
    text-align: center;
  }
  .answers {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  .answer {
    min-width: 0;
    padding: 12px 4px;
    font-size: 0.9rem;
  }
  .key {
    display: none;
  }
}
