/**
 * styles.css
 * -----------------------------------------------------------------------
 * Design tokens are declared once at the top as CSS variables. Change a
 * color or spacing value there and it updates everywhere it's used.
 * -----------------------------------------------------------------------
 */

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-soft: #dbeafe;
  --color-bg: #ffffff;
  --color-bg-soft: #e9f1fc;
  --color-bg-soft-deep: #dde9fa;
  --color-text: #1f2933;
  --color-text-soft: #5b6472;
  --color-border: #e3e8ef;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-logo: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-card: 0 2px 6px rgba(15, 23, 42, 0.07);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --header-h: 56px;
  --max-width: 1080px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
}

button {
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  padding: 11px 22px;
  transition: background-color 0.15s ease, transform 0.05s ease;
}
button:hover:not(:disabled) { background: var(--color-primary-dark); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { background: #b6c8e8; cursor: not-allowed; }
button.secondary {
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
button.secondary:hover:not(:disabled) { background: #f3f6fa; }
button.secondary:disabled {
  background: #f3f5f8;
  color: #aab2bd;
  border-color: var(--color-border);
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

input, select {
  font-family: inherit;
  font-size: 15px;
  padding: 11px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 100%;
  background: #fff;
  color: var(--color-text);
}
input:invalid:not(:placeholder-shown) { border-color: var(--color-danger); }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ---------------------------------------------------------------- */
/* Top status bar — shown only during active question screens      */
/* ---------------------------------------------------------------- */
#topbar {
  display: none;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 20;
}
#topbar.visible { display: flex; }
.topbar-logo {
  height: 28px;
  width: auto;
  border-radius: 6px;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- */
/* Persistent copyright footer — visible on every screen            */
/* ---------------------------------------------------------------- */
#copyrightFooter {
  position: fixed;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--color-text-soft);
  opacity: 0.65;
  z-index: 5;
  pointer-events: none;
}
/* Hidden during the two-pane Reading/Listening screens, where it would
   sit on top of the "Далее" button at the bottom of the questions pane.
   The topbar logo already provides branding on those screens. */
.screen#screen-reading-task.active ~ #copyrightFooter,
.screen#screen-listening-task.active ~ #copyrightFooter {
  display: none;
}
#topbar .topbar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
#topbar .progress-track {
  flex: 1;
  height: 6px;
  background: var(--color-bg-soft-deep);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
#topbar .progress-seg {
  flex: 1;
  height: 100%;
  position: relative;
}
#topbar .progress-seg + .progress-seg { margin-left: 2px; }
#topbar .progress-seg-fill {
  height: 100%;
  width: 0%;
  background: #93c5fd;
  transition: width 0.25s ease, background-color 0.2s ease;
}
#topbar .progress-seg-fill.done {
  width: 100% !important;
  background: var(--color-primary);
}
#topbar .topbar-timer {
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.time-pie {
  width: 16px;
  height: 16px;
  min-width: 16px;
  border-radius: 50%;
  background: conic-gradient(var(--color-primary) 0%, var(--color-bg-soft-deep) 0%);
}
.time-pie.warning { background: conic-gradient(var(--color-danger) 0%, var(--color-bg-soft-deep) 0%); }
.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}
.icon-btn {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0; font-size: 15px;
  background: var(--color-primary);
  color: #fff;
}
.icon-btn.square { border-radius: 8px; background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
.icon-btn.muted { background: #9aa5b1; }
.volume-control { position: relative; }
.volume-popover {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 20px rgba(15,23,42,0.16);
  padding: 12px 14px;
  z-index: 30;
}
.volume-popover.visible { display: block; }
.volume-popover input[type="range"] {
  width: 110px;
  accent-color: var(--color-primary);
}

/* ---------------------------------------------------------------- */
/* Generic centered "card" screens (welcome, audio check, intros…)  */
/* ---------------------------------------------------------------- */
.card-screen {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--color-bg-soft);
}
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
}
.card-header { padding: 28px 32px 4px; text-align: center; }
.card-header h1 { font-size: 22px; margin: 0 0 6px; }
.card-header p { margin: 0; color: var(--color-text-soft); font-size: 14.5px; }
.card-icons {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 22px 0;
  background: var(--color-bg-soft);
  margin: 18px 0 0;
}
.card-icon { text-align: center; font-size: 13.5px; color: var(--color-text-soft); }
.card-icon svg { display: block; margin: 0 auto 6px; }
.card-icon .icon-circle {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px; box-shadow: var(--shadow-card);
}
.card-icon.done .icon-circle { background: var(--color-success); color: #fff; }
.card-body { padding: 24px 32px 30px; }
.card-body ul { padding-left: 20px; margin: 0 0 22px; color: var(--color-text); font-size: 14.5px; }
.card-body li { margin-bottom: 10px; }
.card-actions { text-align: center; }
.card-actions button { width: 100%; }

/* ---------------------------------------------------------------- */
/* Registration screen — two-column hero layout                    */
/* ---------------------------------------------------------------- */
#screen-register .register-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100vh;
}
.register-intro {
  background: linear-gradient(135deg, #14b8a6, #0d9488 60%, #0ea5a4);
  color: #fff;
  padding: 48px 48px 32px;
}
.register-intro .logo-img {
  width: 64px; height: auto; border-radius: 10px;
  display: block; margin-bottom: 18px; box-shadow: var(--shadow-card);
}
.register-intro .eyebrow { font-size: 13px; opacity: 0.85; margin-bottom: 10px; }
.register-intro h1 { font-size: 30px; line-height: 1.2; margin: 0 0 10px; }
.register-intro .sub { font-size: 14.5px; opacity: 0.92; margin-bottom: 30px; }

.duration-pill {
  background: rgba(255,255,255,0.18);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.duration-big { font-size: 36px; font-weight: 800; margin-bottom: 18px; }
.duration-big span { font-size: 16px; font-weight: 500; }

.icon-row {
  background: #fff;
  border-radius: var(--radius-md);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 18px 12px;
  margin-bottom: 26px;
  flex-wrap: wrap;
  gap: 8px;
}
.icon-row .seg { text-align: center; font-size: 12.5px; color: var(--color-text-soft); }
.icon-row .seg strong { display: block; font-size: 14px; color: var(--color-text); margin-top: 4px; }
.icon-row .plus, .icon-row .eq { font-weight: 700; color: var(--color-text-soft); font-size: 18px; }

.checklist-title { font-weight: 700; margin: 0 0 10px; font-size: 15px; }
.checklist { padding-left: 20px; margin: 0 0 28px; font-size: 13.8px; }
.checklist li { margin-bottom: 6px; }

.about-block h3 { font-size: 15px; margin: 0 0 8px; }
.about-block p { font-size: 13.5px; opacity: 0.92; margin: 0; }

.register-form-pane {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
}
.register-form {
  width: 100%;
  max-width: 380px;
}
.register-form h2 { font-size: 21px; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--color-text-soft); margin-bottom: 4px; }
.consent-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 18px 0 22px;
  font-size: 13px;
  color: var(--color-text-soft);
}
.consent-row input { width: auto; margin-top: 3px; }

/* ---------------------------------------------------------------- */
/* Two-pane question layout (Reading / Listening)                  */
/* ---------------------------------------------------------------- */
.task-layout {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  height: calc(100vh - var(--header-h));
}
.pane {
  overflow-y: auto;
  padding: 28px 36px;
  height: 100%;
}
.pane-passage { background: #fff; }
.pane-questions { background: var(--color-bg-soft); }

.task-instructions { font-weight: 600; font-size: 15px; margin: 0 0 16px; }
.task-instructions + ul { margin: -6px 0 22px; padding-left: 20px; font-size: 14.5px; }

.passage-label {
  display: inline-block;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 5px;
  margin-bottom: 10px;
}
.passage-title { font-weight: 700; margin: 0 0 8px; font-size: 15px; }
.passage-text {
  font-size: 14.5px;
  white-space: pre-line;
  margin: 0 0 26px;
}

.q-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.q-card.unanswered-flag { box-shadow: 0 0 0 2px var(--color-danger); }
.q-text { font-size: 14.5px; font-weight: 500; margin: 0 0 14px; }

.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  background: #fff;
  color: var(--color-text);
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}
.opt:hover { border-color: var(--color-primary); }
.opt input { width: auto; margin: 0; accent-color: var(--color-primary); }
.opt.selected { border-color: var(--color-primary); background: var(--color-primary-soft); }

.opt-row3 { display: flex; gap: 8px; }
.opt-row3 .opt { flex: 1; justify-content: center; text-align: center; margin-bottom: 0; }

.task-next-row { display: flex; justify-content: flex-end; padding: 4px 0 30px; }

/* dot rail */
.dot-rail {
  width: 26px;
  padding-top: 30px;
  background: var(--color-bg-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}
.dot-rail .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #b9cce8;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.dot-rail .dot.active { background: var(--color-primary); transform: scale(1.3); }

/* ---------------------------------------------------------------- */
/* Audio player (Listening section)                                 */
/* ---------------------------------------------------------------- */
.badge-two {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 4px;
}
.audio-player {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 22px 0 10px;
}
.play-btn {
  width: 54px;
  height: 54px;
  min-width: 54px;
  border-radius: 50%;
  font-size: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.audio-meta { font-size: 13.5px; color: var(--color-text-soft); }
.audio-meta .audio-time { margin-top: 4px; font-variant-numeric: tabular-nums; }
.audio-error {
  display: none;
  font-size: 12.5px;
  color: var(--color-danger);
  background: #fef2f2;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  max-width: 360px;
}
.audio-error code { background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 4px; }

/* ---------------------------------------------------------------- */
/* Modal (unanswered questions)                                      */
/* ---------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: none; align-items: center; justify-content: center; z-index: 50;
  padding: 20px;
}
.modal-overlay.visible { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--radius-lg); max-width: 400px; width: 100%;
  padding: 26px 26px 22px; text-align: center; box-shadow: 0 12px 32px rgba(0,0,0,0.18);
}
.modal-box h3 { margin: 0 0 10px; font-size: 17px; }
.modal-box p { margin: 0 0 22px; font-size: 14px; color: var(--color-text-soft); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; }

.break-countdown {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  margin: 8px 0 26px;
}

/* ---------------------------------------------------------------- */
/* Listening empty-state                                            */
/* ---------------------------------------------------------------- */
.empty-state {
  text-align: center;
  max-width: 420px;
}
.empty-state .empty-icon {
  width: 56px; height: 56px; border-radius: 50%; background: var(--color-bg-soft-deep);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 18px;
}
.empty-state h2 { margin: 0 0 8px; font-size: 19px; }
.empty-state p { color: var(--color-text-soft); font-size: 14.5px; margin: 0 0 26px; }

/* ---------------------------------------------------------------- */
/* Test expired                                                      */
/* ---------------------------------------------------------------- */
.expired-card { max-width: 460px; }
.expired-warning {
  background: #fde8e8;
  color: #9b1c1c;
  padding: 26px 32px 22px;
  text-align: center;
}
.expired-warning h1 { font-size: 20px; margin: 0 0 10px; }
.expired-warning p { margin: 0; font-size: 14px; line-height: 1.5; }

/* ---------------------------------------------------------------- */
/* Welcome screen intro video (video0-0) — tap to play              */
/* ---------------------------------------------------------------- */
.welcome-video-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #111827;
}
.welcome-video {
  width: 100%;
  height: 200px;
  display: block;
  object-fit: cover;
  object-position: center;
}
.welcome-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-primary);
  font-size: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
}
.welcome-video-play:hover:not(:disabled) {
  background: #fff;
  color: var(--color-primary-dark);
}

/* ---------------------------------------------------------------- */
/* Speaking section                                                  */
/* ---------------------------------------------------------------- */
/* Stacks the logo above the speaking card, both centered — used on the
   Part-intro screens and the question screens. */
.speaking-card-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 620px;
  width: 100%;
}

.speaking-card {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  max-width: 620px; width: 100%; padding: 32px 36px 30px;
}

/* Video wrapper holds the video + the replay button, so the button can
   be positioned relative to the video frame regardless of aspect ratio. */
.speaking-video-wrap {
  position: relative;
  margin-bottom: 16px;
}
.speaking-video {
  width: 100%;
  height: 280px;
  max-height: 280px;
  background: #111827;
  border-radius: var(--radius-md);
  display: none;
  /* Fill the frame and crop overflow instead of letterboxing — removes
     the black bars on the sides when the source video's aspect ratio
     doesn't exactly match the player's. */
  object-fit: cover;
  object-position: center;
}

/* Replay button: bottom-right corner of the video, inset slightly from
   the edges (standard placement for video controls — out of the way of
   the subject's face, which tends to be centered/upper-frame, and
   reachable with a thumb on mobile without covering content). */
.replay-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.65);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.replay-btn:hover:not(:disabled) { background: rgba(17, 24, 39, 0.85); }

.speaking-eyebrow { font-size: 12.5px; color: var(--color-text-soft); font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 10px; }
.speaking-prompt {
  background: var(--color-bg-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  white-space: pre-line;
  font-size: 14.5px;
  margin-bottom: 22px;
}

/* Part 2 cue card — styled like the physical IELTS cue card students
   are handed in the real exam: cream card stock, a rule under the
   topic line, and the "You should say:" bullets in a clean list. */
.speaking-prompt.cue-card {
  background: #fdf8ee;
  border: 1px solid #e8dcb8;
  border-radius: var(--radius-md);
  padding: 22px 26px;
  font-size: 14.5px;
  line-height: 1.7;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.speaking-logo {
  display: block;
  height: 84px;
  width: auto;
  margin: 0 auto 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-card);
}

.speaking-timer {
  font-size: 26px; font-weight: 800; text-align: center; margin: 6px 0 20px;
  color: var(--color-primary); font-variant-numeric: tabular-nums;
}
.speaking-status { text-align: center; font-size: 13.5px; color: var(--color-text-soft); margin-bottom: 16px; min-height: 18px; }
.speaking-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.speaking-actions button { flex: 1; min-width: 140px; }
.rec-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--color-danger); margin-right: 6px; animation: pulse 1.1s infinite;
}
.rec-label { font-weight: 700; color: var(--color-danger); letter-spacing: 0.04em; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Inline text-style button, used for the "click to unmute" prompt that
   appears inside .speaking-status if autoplay-with-sound gets blocked. */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-primary);
  font-weight: 600;
  font-size: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--color-primary-dark); background: none; }

/* ---------------------------------------------------------------- */
/* Responsive                                                        */
/* ---------------------------------------------------------------- */
@media (max-width: 900px) {
  #screen-register .register-grid { grid-template-columns: 1fr; }
  .register-intro, .register-form-pane { padding: 32px 24px; }
  .task-layout { grid-template-columns: 1fr; height: auto; }
  .pane { height: auto; max-height: 50vh; }
  .dot-rail { display: none; }
}
@media (max-width: 520px) {
  .icon-row { padding: 14px 8px; }
  .card-icons { gap: 18px; }
  .speaking-actions button { min-width: 100%; }
}

.finish-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* Referral is the hero: full-width, prominent, on top */
.share-friend-btn {
  width: 100%;
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md, 10px);
  background: var(--color-primary, #2e4370);
  color: #fff;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.share-friend-btn:hover { filter: brightness(1.08); }
.share-friend-btn:active { transform: scale(0.98); }
/* About link: quieter, secondary, below */
.about-re-btn {
  display: block;
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius-md, 10px);
  background: transparent;
  color: var(--color-primary, #2e4370);
  border: 1.5px solid var(--color-line, #d8cfc0);
  transition: background 0.15s ease;
}
.about-re-btn:hover { background: var(--color-bg-soft, #f5f0e6); }
