/* ==========================================================================
   Pithy Challenge — Quiz UI (Paid Ads Department)
   ========================================================================== */

body.quiz-body {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

/* Text the candidate legitimately types stays selectable */
.allow-select {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

/* --------------------------------------------------------------- shell -- */
.shell {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) var(--gutter)
           max(18px, env(safe-area-inset-bottom));
}

.shell__main {
  flex: 1;
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px 0;
}

/* ---------------------------------------------------------------- head -- */
.topbar {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 46px;
}

.topbar__logo { display: flex; align-items: center; gap: 12px; }
.topbar__logo img { height: 26px; width: auto; display: block; }

.topbar__tag {
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding-left: 12px;
  border-left: 1px solid var(--glass-border);
}

.topbar__right { display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
  white-space: nowrap;
}

.chip svg { width: 15px; height: 15px; flex: none; opacity: 0.85; }
.chip--live { color: var(--fg); }
.chip--warn { color: var(--warn); border-color: rgba(255, 179, 71, 0.4); background: var(--warn-soft); }
.chip--danger { color: var(--danger); border-color: rgba(255, 90, 95, 0.45); background: var(--danger-soft); }

.dot-live {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.6);
  animation: pulse 2.4s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(61, 220, 151, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); }
}

/* ------------------------------------------------------------ progress -- */
.progress {
  width: 100%;
  max-width: var(--shell);
  margin: 18px auto 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress__track {
  position: relative;
  flex: 1;
  height: 5px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pithy-cyan-deep), var(--pithy-cyan-bright));
  box-shadow: 0 0 18px rgba(0, 179, 197, 0.65);
  transition: width 560ms var(--ease-out);
}

.progress__label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------- cards -- */
.stage { position: relative; }

.card {
  padding: clamp(24px, 4.4vw, 42px);
  border-radius: var(--r-xl);
}

/* Slide + fade choreography */
.view { animation: view-in var(--dur) var(--ease-out) both; }

.view--out {
  animation: view-out 320ms var(--ease-in) both;
  pointer-events: none;
}

@keyframes view-in {
  from { opacity: 0; transform: translate3d(38px, 0, 0) scale(0.985); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes view-out {
  from { opacity: 1; transform: none; filter: blur(0); }
  to   { opacity: 0; transform: translate3d(-34px, 0, 0) scale(0.985); filter: blur(5px); }
}

.view--back { animation: view-in-back var(--dur) var(--ease-out) both; }
@keyframes view-in-back {
  from { opacity: 0; transform: translate3d(-38px, 0, 0) scale(0.985); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* --------------------------------------------------------------- intro -- */
.intro__title {
  font-size: clamp(2rem, 6.4vw, 3.1rem);
  margin: 14px 0 12px;
}

.intro__title span {
  background: linear-gradient(120deg, var(--pithy-cyan-bright), var(--pithy-cyan) 60%, #7ae7f3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.intro__lede {
  color: var(--fg-muted);
  max-width: 54ch;
  margin: 0 0 26px;
}

.rules {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.rules li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.92rem;
  color: var(--fg-muted);
}

.rules li strong { color: var(--fg); font-weight: 600; }

.rules li .ic {
  flex: none;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--pithy-cyan-bright);
}

.rules li .ic svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- form -- */
.field { display: grid; gap: 7px; margin-bottom: 16px; }

.field > label {
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.input,
.textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  transition: border-color 180ms var(--ease-out), background 180ms var(--ease-out),
              box-shadow 180ms var(--ease-out);
  -webkit-user-select: text;
  user-select: text;
}

.input::placeholder,
.textarea::placeholder { color: var(--fg-faint); }

.input:focus,
.textarea:focus {
  outline: none;
  border-color: rgba(0, 179, 197, 0.65);
  background: rgba(0, 179, 197, 0.07);
  box-shadow: 0 0 0 4px rgba(0, 179, 197, 0.14);
}

.input--code {
  letter-spacing: 0.34em;
  text-transform: uppercase;
  font-family: var(--font-display);
  font-weight: 700;
}

.form-row { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; gap: 0; } }

.form-error {
  display: none;
  margin: 0 0 16px;
  padding: 12px 15px;
  border-radius: var(--r-md);
  background: var(--danger-soft);
  border: 1px solid rgba(255, 90, 95, 0.4);
  color: #ffb0b3;
  font-size: 0.9rem;
}

.form-error.is-on { display: block; animation: view-in 300ms var(--ease-out) both; }

/* ------------------------------------------------------------- signin -- */
.signin {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 26px 20px 8px;
}

.signin__btn {
  min-height: 44px;
  display: flex;
  justify-content: center;
}

.signin__note {
  margin: 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--fg-faint);
  max-width: 42ch;
}

.signin.is-loading .signin__btn::after {
  content: "";
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--pithy-cyan-bright);
  animation: spin 760ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------- identity -- */
.ident {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  border-radius: var(--r-md);
  background: rgba(0, 179, 197, 0.08);
  border: 1px solid rgba(0, 179, 197, 0.32);
  margin-bottom: 18px;
}

.ident__avatar {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--accent-soft) center/cover no-repeat;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--pithy-cyan-bright);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.ident__who { flex: 1; min-width: 0; display: grid; }
.ident__who strong { font-family: var(--font-display); font-size: 0.98rem; }
.ident__who span {
  font-size: 0.84rem;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ident__ok {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ok);
}

.ident__ok svg { width: 14px; height: 14px; }

@media (max-width: 480px) {
  .ident { flex-wrap: wrap; }
  .ident__ok { width: 100%; justify-content: flex-start; padding-left: 56px; }
}

/* ------------------------------------------------------------ question -- */
.q__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.q__index {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.q__type {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--glass-border);
}

.q__title {
  font-size: clamp(1.25rem, 3.4vw, 1.75rem);
  margin-bottom: 10px;
}

.q__hint {
  color: var(--fg-muted);
  font-size: 0.92rem;
  margin: 0 0 22px;
}

.options { display: grid; gap: 11px; }

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 60px;
  padding: 14px 18px;
  text-align: left;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 200ms var(--ease-out), border-color 200ms var(--ease-out),
              background 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}

.option__key {
  flex: none;
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--fg-muted);
  transition: inherit;
}

.option__text { flex: 1; }

@media (hover: hover) {
  .option:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 179, 197, 0.55);
    background: rgba(0, 179, 197, 0.08);
    box-shadow: 0 14px 34px -18px rgba(0, 179, 197, 0.9);
  }
  .option:hover .option__key { color: var(--pithy-cyan-bright); border-color: rgba(0, 179, 197, 0.5); }
}

.option.is-picked {
  border-color: var(--pithy-cyan);
  background: linear-gradient(120deg, rgba(0, 179, 197, 0.26), rgba(0, 179, 197, 0.1));
  box-shadow: 0 0 0 1px rgba(0, 179, 197, 0.6), 0 18px 40px -20px rgba(0, 179, 197, 1);
}

.option.is-picked .option__key {
  background: var(--pithy-cyan);
  border-color: var(--pithy-cyan);
  color: #04181b;
}

.options.is-locked .option { pointer-events: none; }
.options.is-locked .option:not(.is-picked) { opacity: 0.38; }

/* ------------------------------------------------------------- writing -- */
.writer { display: grid; gap: 10px; }

.textarea {
  min-height: 210px;
  resize: vertical;
  line-height: 1.7;
}

.writer__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

.writer__count strong { color: var(--fg-muted); font-weight: 600; }
.writer__count.is-ok strong { color: var(--ok); }

.writer__guard {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.writer__guard svg { width: 14px; height: 14px; }

.nav {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* --------------------------------------------------------------- toast -- */
.toasts {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
}

.toast {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(18, 20, 21, 0.86);
  border: 1px solid var(--glass-border-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  font-size: 0.9rem;
  animation: toast-in 420ms var(--ease-out) both;
}

.toast--warn { border-color: rgba(255, 179, 71, 0.5); }
.toast--danger { border-color: rgba(255, 90, 95, 0.55); }
.toast__ic { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.toast--warn .toast__ic { color: var(--warn); }
.toast--danger .toast__ic { color: var(--danger); }
.toast strong { display: block; font-family: var(--font-display); font-size: 0.86rem; }
.toast span { color: var(--fg-muted); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.toast.is-leaving { animation: toast-out 280ms var(--ease-in) both; }
@keyframes toast-out { to { opacity: 0; transform: translateY(12px) scale(0.97); } }

/* --------------------------------------------------------------- guard -- */
.guard {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: var(--gutter);
  background: rgba(6, 8, 9, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.guard.is-on { display: grid; animation: view-in 320ms var(--ease-out) both; }

.guard__box {
  width: min(480px, 100%);
  padding: 34px;
  text-align: center;
  border-radius: var(--r-xl);
}

.guard__ic {
  width: 56px; height: 56px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--warn-soft);
  color: var(--warn);
}

.guard--fatal .guard__ic { background: var(--danger-soft); color: var(--danger); }
.guard__ic svg { width: 26px; height: 26px; }
.guard__box h2 { font-size: 1.4rem; margin-bottom: 10px; }
.guard__box p { color: var(--fg-muted); margin: 0 0 22px; }

.guard__strikes {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}

.guard__strikes i {
  width: 34px; height: 5px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.14);
}

.guard__strikes i.is-used { background: var(--danger); box-shadow: 0 0 14px rgba(255, 90, 95, 0.7); }

/* -------------------------------------------------------------- result -- */
.result { text-align: center; }
.result__title { font-size: clamp(1.7rem, 5vw, 2.4rem); margin-bottom: 10px; }
.result__lede { color: var(--fg-muted); max-width: 48ch; margin: 0 auto 28px; }

.result__ring {
  width: 150px; height: 150px;
  margin: 6px auto 22px;
  display: grid;
  place-items: center;
  position: relative;
}

.result__ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.result__ring .bg { stroke: rgba(255, 255, 255, 0.09); }
.result__ring .fg {
  stroke: url(#ringGrad);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.1s var(--ease-out);
  filter: drop-shadow(0 0 10px rgba(0, 179, 197, 0.6));
}

.result__ring b {
  font-family: var(--font-display);
  font-size: 2.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result__ring small { display: block; font-size: 0.7rem; letter-spacing: 0.14em; color: var(--fg-faint); text-transform: uppercase; }

.result__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
  text-align: left;
}

.stat {
  padding: 16px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat dt { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-faint); margin-bottom: 6px; }
.stat dd { margin: 0; font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat--ok dd { color: var(--ok); }
.stat--warn dd { color: var(--warn); }
.stat--danger dd { color: var(--danger); }

/* -------------------------------------------------------------- footer -- */
.foot {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  text-align: center;
  font-size: 0.74rem;
  color: var(--fg-faint);
  padding-top: 14px;
}

/* -------------------------------------------------------------- mobile -- */
@media (max-width: 560px) {
  .topbar__tag { display: none; }
  .chip { height: 31px; padding: 0 11px; font-size: 0.74rem; }
  .option { min-height: 56px; padding: 13px 15px; font-size: 0.96rem; }
  .nav { flex-direction: column-reverse; }
  .nav .btn { width: 100%; }
  .textarea { min-height: 180px; }
}

@media (max-width: 380px) {
  .topbar__logo img { height: 22px; }
}

/* Short viewports (landscape phones) */
@media (max-height: 680px) {
  .shell__main { justify-content: flex-start; }
}

/* No backdrop-filter support fallback */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .chip, .toast, .option { background: rgba(22, 26, 28, 0.92); }
}

/* Printing / screenshot deterrent */
@media print {
  body.quiz-body * { visibility: hidden !important; }
  body.quiz-body::after {
    content: "Pithy Challenge — contenido protegido.";
    visibility: visible;
    font-family: sans-serif;
  }
}
