/* Design tokens from roadpolice.am (see dev/template-source/roadpolice-app.css) */
:root {
  --rp-bg: #ffffff;
  --rp-text: #3a3a3a;
  --rp-text-muted: #424242;
  --rp-heading: #2c3843;
  --rp-accent-start: #3ac8c8;
  --rp-accent-end: #39addf;
  --rp-accent: #39addf;
  --rp-border: #d4dbea;
  --rp-row-alt: #f8faff;
  --rp-success: #57bd92;
  --rp-error: #e11d3d;
  --rp-shadow: 0 2px 12px rgba(44, 56, 67, 0.08);
  --rp-radius: 4px;
  --rp-font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --rp-max: 1100px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  overflow-x: hidden;
  font-family: var(--rp-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--rp-text);
  background-color: #ffffff;
}

body.is-exam {
  overflow: hidden;
}

a {
  color: var(--rp-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.center {
  max-width: var(--rp-max);
  margin: 0 auto;
  padding: 0 20px;
}

.wrapper {
  min-height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header — top-box--inner from roadpolice.am */
.top-box {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--rp-border);
}

.top-box--inner {
  background: linear-gradient(
    164.92deg,
    rgba(179, 229, 236, 0.7) 2.21%,
    rgba(178, 235, 211, 0.7) 45.57%,
    rgba(211, 243, 214, 0.7) 85.77%
  );
}

.top-box--inner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../media/images/ui/driving-licence-header-lines.svg") no-repeat center top / cover;
  pointer-events: none;
}

.top-box--inner::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--rp-accent-start), var(--rp-accent-end));
}

.top-box__section {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 14px;
}

.top-box__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--rp-heading);
  padding-left: 28px;
  position: relative;
  text-decoration: none;
}

a.top-box__title:hover {
  color: var(--rp-accent);
  text-decoration: none;
}

.top-box__title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--rp-accent-start), var(--rp-accent-end));
}

.top-box__options {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-box__tel {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--rp-shadow);
  color: var(--rp-accent);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}

.language-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 6px;
}

.language-list__link {
  display: block;
  min-width: 28px;
  height: 20px;
  padding: 0 6px;
  border-radius: 2px;
  border: 1px solid var(--rp-border);
  font-size: 10px;
  line-height: 18px;
  text-align: center;
  color: var(--rp-text-muted);
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 700;
}

.language-list__link:hover {
  text-decoration: none;
  border-color: var(--rp-accent);
}

.language-list__link.is-active,
.language-list__link--en.is-active {
  background: linear-gradient(90deg, var(--rp-accent-start), var(--rp-accent-end));
  color: #fff;
  border-color: transparent;
}

.language-list__link--hy.is-active {
  background: linear-gradient(90deg, #f5a623, #e67e22);
  color: #fff;
  border-color: transparent;
}

.language-list__link--ru.is-active {
  background: linear-gradient(90deg, #5b9bd5, #2e75b6);
  color: #fff;
  border-color: transparent;
}

.language-list__link--ar.is-active {
  background: linear-gradient(90deg, #57bd92, #2d7a57);
  color: #fff;
  border-color: transparent;
}

body.is-ltr .question-card__text,
body.is-ltr .option__label {
  text-align: left;
}

body.is-rtl .question-card__text,
body.is-rtl .option__label {
  text-align: right;
}

body.is-rtl .question-card__header {
  flex-direction: row-reverse;
}

body.is-rtl .option {
  flex-direction: row-reverse;
}

body.is-rtl .exam-nav {
  flex-direction: row-reverse;
}

.inner-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 0 24px;
  overflow-y: auto;
  background: #ffffff url("../media/images/ui/driving-licence-page-bg.svg") no-repeat center top / cover;
}

body.is-exam .inner-content {
  padding: 12px 0 16px;
  overflow: hidden;
}

.inner-content > .center {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen--exam {
  overflow: hidden;
  padding: 12px;
  border-radius: 6px;
  background: transparent;
}

.screen--exam .exam-stage {
  background: #fff;
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  box-shadow: var(--rp-shadow);
  padding: 12px 14px;
}

.inner-content__title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  color: var(--rp-heading);
}

.inner-content__description {
  margin: 0 0 24px;
  color: var(--rp-text-muted);
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: var(--rp-radius);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  opacity: 0.92;
  text-decoration: none;
}

.btn--gradient {
  color: #fff;
  background-image: linear-gradient(90deg, var(--rp-accent-start), var(--rp-accent-end));
}

.btn--outline {
  color: var(--rp-text);
  background: #fff;
  border: 1px solid #cfd5e0;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Exam */
.exam-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.exam-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.integrity-checker-on .center {
  max-width: min(1680px, 100%);
}

body.integrity-checker-on .exam-layout {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(360px, 2fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.exam-main {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-original,
.integrity-checker {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  background: #fff;
  overflow: hidden;
}

.exam-original[hidden],
.integrity-checker[hidden] {
  display: none !important;
}

.exam-original__head,
.integrity-checker__head {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--rp-border);
  background: #f8faff;
  font-size: 12px;
  font-weight: 600;
  color: var(--rp-heading);
}

.exam-original__figure {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: auto;
}

.exam-original__img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.exam-original__caption {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--rp-text-muted);
  text-align: center;
  word-break: break-all;
}

.exam-questions {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.exam-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--rp-row-alt);
  border: 1px solid var(--rp-border);
  font-size: 14px;
}

.stat-pill strong {
  color: var(--rp-heading);
}

.question-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.question-card.is-answered {
  border-color: #c5d8ea;
}

.question-card__header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.question-card__header > div {
  flex: 1;
  min-width: 0;
}

.question-card__number {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, var(--rp-accent-start), var(--rp-accent-end));
  font-size: 13px;
}

.question-card__text {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--rp-heading);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.question-card__figure {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 0 10px;
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-card__figure img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.question-card:not(:has(.question-card__figure)) .question-card__header {
  margin-top: 2px;
}

.options {
  flex-shrink: 0;
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.35;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option:hover:not(.is-locked) {
  border-color: var(--rp-accent);
  background: var(--rp-row-alt);
}

.option input {
  margin-top: 3px;
  accent-color: var(--rp-accent);
}

.option__label {
  flex: 1;
}

.option.is-correct {
  border-color: var(--rp-success);
  background: rgba(87, 189, 146, 0.12);
}

.option.is-wrong {
  border-color: var(--rp-error);
  background: rgba(225, 29, 61, 0.08);
}

.option.is-locked {
  cursor: default;
}

.feedback {
  flex-shrink: 0;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--rp-radius);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.35;
}

.feedback--correct {
  color: #2d7a57;
  background: rgba(87, 189, 146, 0.15);
  border: 1px solid rgba(87, 189, 146, 0.35);
}

.feedback--wrong {
  color: #b01530;
  background: rgba(225, 29, 61, 0.1);
  border: 1px solid rgba(225, 29, 61, 0.25);
}

.exam-nav {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

body.is-exam .bottom-box {
  display: none;
}

.screen[hidden] {
  display: none !important;
}

.rules-card {
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  padding: 22px 24px;
  margin: 0 0 28px;
  background: var(--rp-row-alt);
  box-shadow: var(--rp-shadow);
}

.rules-card__title {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--rp-heading);
}

.rules-card__list {
  margin: 0 0 14px;
  padding-left: 1.25rem;
  color: var(--rp-text);
}

.rules-card__list li {
  margin-bottom: 8px;
}

.rules-card__note {
  margin: 0;
  font-size: 14px;
  color: var(--rp-text-muted);
}

.btn--lg {
  padding: 14px 28px;
  font-size: 16px;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--rp-heading);
}

.timer--warning {
  color: #c47a00;
}

.timer--danger {
  color: var(--rp-error);
}

.results-title {
  margin: 0 0 12px;
  font-size: 32px;
  font-weight: 700;
}

.results-title--pass {
  color: var(--rp-success);
}

.results-title--fail {
  color: var(--rp-error);
}

.results-summary {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--rp-heading);
}

.results-detail {
  margin: 0 0 28px;
  padding: 16px 18px;
  border: 1px solid var(--rp-border);
  border-radius: var(--rp-radius);
  background: #fff;
}

.results-detail p {
  margin: 0 0 8px;
}

.results-detail p:last-child {
  margin-bottom: 0;
}

.results-note {
  margin-top: 12px !important;
  font-size: 14px;
  color: var(--rp-text-muted);
}

.exam-empty,
.exam-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--rp-text-muted);
}

.bottom-box {
  flex-shrink: 0;
  margin-top: auto;
  padding: 14px 0;
  border-top: 1px solid var(--rp-border);
  background: #fafbfd;
  font-size: 13px;
  color: var(--rp-text-muted);
}

.bottom-box p {
  margin: 0;
}

@media (max-width: 640px) {
  .center {
    padding: 0 12px;
  }

  .top-box__section {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 0 12px;
  }

  .top-box__title {
    font-size: 13px;
    line-height: 1.35;
    padding-left: 24px;
  }

  .top-box__options {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .top-box__tel {
    font-size: 14px;
    padding: 8px 12px;
  }

  .inner-content {
    padding: 16px 0 20px;
  }

  .inner-content__title {
    font-size: 22px;
  }

  .inner-content__description {
    margin-bottom: 18px;
    font-size: 15px;
  }

  .rules-card {
    padding: 16px;
    margin-bottom: 20px;
  }

  .rules-card__title {
    font-size: 18px;
  }

  .btn--lg {
    width: 100%;
  }

  .results-title {
    font-size: 26px;
  }

  .results-summary {
    font-size: 16px;
  }

  /* Exam: allow scroll instead of clipping on short viewports */
  body.is-exam {
    overflow: auto;
  }

  body.is-exam .wrapper {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  body.is-exam .inner-content {
    overflow: visible;
    padding: 8px 0 12px;
  }

  .exam-toolbar {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 8px;
  }

  .exam-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .screen--exam {
    padding: 0;
  }

  .screen--exam .exam-stage {
    padding: 10px;
  }

  .stat-pill {
    font-size: 12px;
    padding: 7px 10px;
    text-align: center;
  }

  .stat-pill.timer {
    grid-column: 1 / -1;
    font-size: 15px;
  }

  .exam-main {
    min-height: 0;
  }

  .exam-questions {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .question-card {
    overflow: visible;
  }

  .question-card__text {
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
    font-size: 14px;
  }

  .question-card__figure {
    flex: 0 0 auto;
    max-height: min(38vh, 240px);
    margin-bottom: 8px;
  }

  .question-card__figure img {
    max-height: min(38vh, 240px);
  }

  .options {
    gap: 8px;
  }

  .option {
    padding: 10px 12px;
    min-height: 44px;
    font-size: 14px;
  }

  .option input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
  }

  .feedback {
    font-size: 12px;
  }

  .exam-nav {
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
  }

  .exam-nav .btn {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
  }

  .bottom-box {
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .top-box__tel {
    width: 100%;
    justify-content: center;
  }

  .language-list {
    width: 100%;
    justify-content: center;
  }

  .exam-stats {
    grid-template-columns: 1fr;
  }

  .stat-pill.timer {
    grid-column: auto;
  }
}

@media (max-height: 700px) {
  body.is-exam {
    overflow: auto;
  }

  body.is-exam .wrapper {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  body.is-exam .inner-content {
    overflow: visible;
  }

  .exam-questions {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .question-card__figure,
  .question-card__figure img {
    max-height: min(34vh, 220px);
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body.is-exam .inner-content {
    padding: 6px 0;
  }

  .question-card__figure,
  .question-card__figure img {
    max-height: min(32vh, 160px);
  }

  .exam-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .stat-pill.timer {
    grid-column: auto;
  }
}

/* Hidden integrity checker side panel (Ctrl+Shift+I) */
.integrity-checker__hint {
  flex: 1;
  color: var(--rp-text-muted);
  font-size: 11px;
  font-weight: 400;
}

.integrity-checker__close {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--rp-text-muted);
}

.integrity-checker__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px 12px;
}

.integrity-checker__title {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--rp-heading);
}

.integrity-checker__meta {
  margin: 0 0 8px;
  color: var(--rp-text-muted);
  font-size: 12px;
}

.integrity-checker__stats {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 12px;
}

.integrity-checker__stats li {
  margin-bottom: 4px;
}

.integrity-checker__ok {
  color: var(--rp-success);
}

.integrity-checker__bad {
  color: var(--rp-error);
}

.integrity-checker__details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 12px;
}

.integrity-checker__list {
  margin: 0;
  padding-left: 18px;
  max-height: 200px;
  overflow: auto;
  font-size: 11px;
}

.integrity-checker__list li {
  margin-bottom: 6px;
}

.integrity-checker__list code {
  display: block;
  font-size: 10px;
}

body.integrity-checker-on::after {
  content: "integrity";
  position: fixed;
  bottom: 8px;
  right: 8px;
  z-index: 100;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(44, 56, 67, 0.75);
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

@media (max-width: 1100px) {
  body.integrity-checker-on .exam-layout {
    grid-template-columns: minmax(180px, 1fr) minmax(280px, 2fr) minmax(220px, 1fr);
    gap: 8px;
  }
}

@media (max-width: 900px) {
  body.integrity-checker-on .exam-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .exam-original {
    max-height: 200px;
  }

  .integrity-checker {
    max-height: 240px;
  }
}
