/*
 * Wobble-Captcha widget styles.
 * Self-contained: everything is scoped under .wc-* so the sheet can be dropped
 * into a host page without collisions. Themed through custom properties, with a
 * dark palette that follows the viewer's system setting or an explicit
 * data-theme override on <html>.
 */

.wc-card {
  /* Light palette. Dark values are redefined below; never define a colour only
     inside a media query, or a page with no scheme match renders unstyled. */
  --wc-surface: #ffffff;
  --wc-text: #15171a;
  --wc-muted: #7b8088;
  --wc-hint: #8a8f96;
  --wc-track: #f1f2f3;
  --wc-track-border: #eceef0;
  --wc-stage-bg: #e8eaed;
  --wc-loader-bg: rgba(247, 248, 249, .8);
  --wc-loader-text: #737983;
  --wc-accent: #1687df;
  --wc-accent-soft: rgba(66, 183, 226, .16);
  --wc-accent-shadow: rgba(0, 89, 153, .22);
  --wc-success: #18a058;
  --wc-danger: #d14343;
  --wc-thumb-inset: 3px;
  --wc-thumb-size: 46px;
  --wc-track-height: 52px;

  width: 100%;
  padding: 22px 14px 18px;
  background: var(--wc-surface);
  color: var(--wc-text);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wc-card {
    --wc-surface: #17191c;
    --wc-text: #e8eaed;
    --wc-muted: #9aa0a8;
    --wc-hint: #868c95;
    --wc-track: #23262b;
    --wc-track-border: #2d3137;
    --wc-stage-bg: #202327;
    --wc-loader-bg: rgba(23, 25, 28, .82);
    --wc-loader-text: #9aa0a8;
    --wc-accent: #3d9ae8;
    --wc-accent-soft: rgba(61, 154, 232, .18);
    --wc-accent-shadow: rgba(0, 0, 0, .45);
    --wc-success: #35c47c;
    --wc-danger: #ef6b6b;
  }
}

:root[data-theme="dark"] .wc-card {
  --wc-surface: #17191c;
  --wc-text: #e8eaed;
  --wc-muted: #9aa0a8;
  --wc-hint: #868c95;
  --wc-track: #23262b;
  --wc-track-border: #2d3137;
  --wc-stage-bg: #202327;
  --wc-loader-bg: rgba(23, 25, 28, .82);
  --wc-loader-text: #9aa0a8;
  --wc-accent: #3d9ae8;
  --wc-accent-soft: rgba(61, 154, 232, .18);
  --wc-accent-shadow: rgba(0, 0, 0, .45);
  --wc-success: #35c47c;
  --wc-danger: #ef6b6b;
}

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

.wc-prompt {
  margin: 0 0 17px;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--wc-text);
}

.wc-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 2 / 1;
  border-radius: 8px;
  background: var(--wc-stage-bg);
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  -webkit-touch-callout: none;
}

.wc-background,
.wc-piece {
  position: absolute;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.wc-background { inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Positioned with translate3d from JS: percentage left/top forced a layout pass
   on every pointer event, which dropped frames on 120 Hz touch panels. */
.wc-piece {
  top: 0;
  left: 0;
  z-index: 3;
  opacity: 0;
  will-change: transform;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .22));
}

.wc-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  background: linear-gradient(to bottom, rgba(255, 255, 255, .02), rgba(0, 0, 0, .02));
}

.wc-loader {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  background: var(--wc-loader-bg);
  color: var(--wc-loader-text);
  font-size: 13px;
  backdrop-filter: blur(2px);
}
.wc-loader[hidden] { display: none; }

.wc-slider {
  position: relative;
  height: var(--wc-track-height);
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--wc-track-border);
  border-radius: calc(var(--wc-track-height) / 2);
  background: var(--wc-track);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.wc-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, rgba(73, 190, 221, .10), var(--wc-accent-soft));
  pointer-events: none;
}

.wc-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-left: calc(var(--wc-thumb-size) - 4px);
  color: var(--wc-hint);
  font-size: 13px;
  pointer-events: none;
  transition: opacity .12s linear;
}

/* The thumb is offset horizontally by transform, so `left` stays at the inset
   and the vertical inset is derived from the track height: a hardcoded top
   value drifted out of alignment inside the landscape media query. */
.wc-thumb {
  position: absolute;
  top: calc((var(--wc-track-height) - var(--wc-thumb-size)) / 2 - 1px);
  left: 0;
  z-index: 4;
  width: var(--wc-thumb-size);
  height: var(--wc-thumb-size);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--wc-accent);
  color: #fff;
  font: inherit;
  box-shadow: 0 2px 6px var(--wc-accent-shadow);
  cursor: grab;
  touch-action: none;
  will-change: transform;
  transition: background .15s ease, box-shadow .15s ease;
}
.wc-thumb:disabled { cursor: default; }
.wc-thumb:focus-visible { outline: 3px solid var(--wc-accent-soft); outline-offset: 2px; }
.wc-thumb svg { width: 19px; height: 19px; }
.wc-thumb svg path { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.wc-slider[data-dragging="true"] .wc-thumb { cursor: grabbing; box-shadow: 0 2px 9px var(--wc-accent-shadow); }

.wc-footer {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 2px 0;
}

.wc-refresh {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 0 4px 0 0;
  border: 0;
  background: transparent;
  color: var(--wc-text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.wc-refresh:disabled { opacity: .5; cursor: default; }
.wc-refresh svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.wc-status {
  min-width: 0;
  overflow: hidden;
  color: var(--wc-muted);
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.wc-card[data-state="success"] .wc-thumb { background: var(--wc-success); }
.wc-card[data-state="success"] .wc-fill { background: color-mix(in srgb, var(--wc-success) 14%, transparent); }
.wc-card[data-state="success"] .wc-status { color: var(--wc-success); }
.wc-card[data-state="error"] .wc-status,
.wc-card[data-state="expired"] .wc-status { color: var(--wc-danger); }
.wc-card[data-state="verifying"] .wc-thumb { cursor: wait; }
.wc-card[data-state="expired"] .wc-stage { filter: grayscale(.6) brightness(.9); }

/* The shake lands on the track, not the thumb: the thumb's transform carries its
   slider position, and an animation on the same property would fight it. */
@keyframes wc-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-4px, 0, 0); }
  75% { transform: translate3d(4px, 0, 0); }
}
.wc-slider.wc-shake { animation: wc-shake .2s ease; }

@media (pointer: coarse) {
  .wc-card { --wc-track-height: 56px; --wc-thumb-size: 50px; }
  .wc-refresh { min-height: 36px; }
}

@media (max-width: 430px) {
  .wc-card { padding: 18px 12px 12px; }
  .wc-prompt { margin-bottom: 15px; font-size: 17px; }
  .wc-stage { border-radius: 7px; }
  .wc-slider { margin-top: 9px; }
}

@media (max-width: 360px) {
  .wc-card { padding-inline: 9px; }
  .wc-prompt { font-size: 16px; }
  .wc-hint { font-size: 12px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .wc-card { --wc-track-height: 46px; --wc-thumb-size: 40px; padding: 8px 10px 7px; }
  .wc-prompt { margin-bottom: 7px; font-size: 14px; }
  .wc-stage { width: min(72vw, 500px); margin-inline: auto; }
  .wc-slider { width: min(72vw, 500px); margin: 6px auto 0; }
  .wc-footer { width: min(72vw, 500px); margin-inline: auto; min-height: 27px; padding-top: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .wc-card *,
  .wc-card *::before,
  .wc-card *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
