/* certs.css -- the sign-in control, the level controls and the level up overlay.
 *
 * Loaded by every exam landing page under site/certs/, which are the pages that run
 * site/js/certs-levelup.js. Everything here is built on the shared tokens, so it follows the
 * theme with the rest of the site and defines no colour of its own.
 *
 * Phone first. The overlay is laid out for a 390px viewport and every option button is at
 * least 44px tall, because the whole point of the challenge is that it works on a phone.
 */

/* ---------------------------------------------------------------- the sign-in control */

.cert-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.7rem;
  margin: 0.3rem 0 0.7rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}

/* The line carries one short sentence when all is well and a two-line explanation when sign-in
   fails, so it is allowed to grow and to take the whole row. Without the flex basis the longer
   message squeezed the sign-out link to one character per line at 390px. */
.cert-account-line {
  flex: 1 1 16rem;
  min-width: 0;
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}

.cert-account-line .cert-who {
  color: var(--text);
  font-weight: 600;
}

.cert-account-line .cert-sync {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.cert-account-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  margin-left: auto;
}

/* An explicit display value beats the user agent's rule for the hidden attribute, so the
   sign-out link stayed on screen while signed out until this line was added. */
.cert-account [hidden] {
  display: none !important;
}

.cert-signout {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.cert-signout:hover {
  color: var(--teal);
}

/* ---------------------------------------------------------------- buttons */

.cert-btn,
.cert-levelup-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.cert-btn:hover,
.cert-levelup-btn:hover:not([disabled]) {
  border-color: var(--teal);
  color: var(--teal);
}

.cert-btn:focus-visible,
.cert-levelup-btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.cert-levelup-btn[disabled] {
  opacity: 0.55;
  cursor: default;
  border-style: dashed;
}

.cert-levelup {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.8rem;
  margin: 0.5rem 0 0.2rem;
}

.cert-level {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  color: var(--highlight);
}

.cert-level.is-soon {
  color: var(--faint);
}

/* ---------------------------------------------------------------- the overlay */

.cert-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0.6rem;
  background: rgba(10, 12, 16, 0.62);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cert-panel {
  width: 100%;
  max-width: 40rem;
  margin: 0.4rem auto 2rem;
  padding: 0.8rem 0.85rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.cert-panel:focus {
  outline: none;
}

.cert-ov-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.7rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.cert-ov-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--red);
}

.cert-ov-timer {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-left: auto;
}

.cert-ov-timer.is-low {
  color: var(--danger);
}

.cert-ov-close {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  min-height: 44px;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.cert-ov-close:hover {
  color: var(--text);
  border-color: var(--teal);
}

.cert-ov-sub,
.cert-ov-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--faint);
  margin: 0.4rem 0 0;
  line-height: 1.35;
}

.cert-card {
  margin-top: 0.6rem;
}

.cert-stem {
  font-size: 0.98rem;
  line-height: 1.5;
  margin: 0 0 0.7rem;
}

/* A question may carry a short listing, between the stem and the options. The script puts it in
   with textContent, so nothing in a bank file can become an element here. The box scrolls on both
   axes inside itself: a long line has to move the listing, never the card, or the whole page goes
   sideways at 390px. */
.cert-code {
  margin: 0 0 0.7rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 40vh;
  -webkit-overflow-scrolling: touch;
}

.cert-code:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.cert-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cert-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.4;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text);
  cursor: pointer;
}

.cert-option:hover:not([disabled]) {
  border-color: var(--teal);
  background: var(--surface-2);
}

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

.cert-option[disabled] {
  cursor: default;
}

.cert-option-letter {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  flex: 0 0 auto;
  min-width: 1.2em;
}

.cert-option.is-right {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.cert-option.is-right .cert-option-letter {
  color: var(--accent);
}

.cert-option.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.cert-option.is-wrong .cert-option-letter {
  color: var(--danger);
}

.cert-verdict {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  margin: 0.7rem 0 0.2rem;
}

.cert-verdict.is-right {
  color: var(--accent);
}

.cert-verdict.is-wrong {
  color: var(--danger);
}

.cert-explain {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0.2rem 0 0;
  padding: 0.5rem 0.7rem;
  border-left: 3px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.cert-next {
  margin-top: 0.7rem;
}

/* ---------------------------------------------------------------- the result screen */

.cert-result-head {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0.6rem 0 0.2rem;
}

.cert-result-head.is-earned {
  color: var(--accent);
}

.cert-result-score {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--text);
  margin: 0.2rem 0;
}

.cert-result-note {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
  margin: 0.3rem 0 0.7rem;
}

.cert-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cert-note {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Nothing here animates, so there is nothing to turn off, but a future addition
   inherits the site-wide rule rather than re-learning it. */
@media (prefers-reduced-motion: reduce) {
  .cert-overlay,
  .cert-panel,
  .cert-option {
    transition: none !important;
    animation: none !important;
  }
}
