/*
 * Image CAPTCHA for Elementor & Fluent Forms — compact front-end component.
 *
 * A flat, inline challenge: no outer card, no card-per-option. The only
 * surfaces are small icon tiles; selected/error/loading states are carried by
 * color, a check badge and the live status line.
 */

.icef-captcha {
  --icef-fg: #1e293b;
  --icef-muted: #64748b;
  --icef-border: #7c8aa0;
  --icef-border-strong: #64748b;
  --icef-tile-hover: #f1f5f9;
  --icef-icon-tile: #f8fafc;
  --icef-accent: #2563eb;
  --icef-accent-soft: rgba(37, 99, 235, 0.1);
  --icef-accent-contrast: #ffffff;
  --icef-focus: #1d4ed8;
  --icef-danger: #b91c1c;
  --icef-shimmer: rgba(255, 255, 255, 0.6);

  position: relative;
  box-sizing: border-box;
  display: block;
  inline-size: 100%;
  max-inline-size: 100%;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--icef-fg);
  color-scheme: light;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: start;
  -webkit-text-size-adjust: 100%;
}

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

.icef-captcha[data-icef-theme="dark"] {
  --icef-fg: #e7edf7;
  --icef-muted: #9fb0c7;
  --icef-border: #6b7f9c;
  --icef-border-strong: #93a6c0;
  --icef-tile-hover: #16243a;
  --icef-icon-tile: #eef2f7;
  --icef-accent: #78aaff;
  --icef-accent-soft: rgba(120, 170, 255, 0.14);
  --icef-accent-contrast: #0b1422;
  --icef-focus: #93c5fd;
  --icef-danger: #fca5a5;
  --icef-shimmer: rgba(255, 255, 255, 0.08);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  .icef-captcha[data-icef-theme="auto"] {
    --icef-fg: #e7edf7;
    --icef-muted: #9fb0c7;
    --icef-border: #6b7f9c;
    --icef-border-strong: #93a6c0;
    --icef-tile-hover: #16243a;
    --icef-icon-tile: #eef2f7;
    --icef-accent: #78aaff;
    --icef-accent-soft: rgba(120, 170, 255, 0.14);
    --icef-accent-contrast: #0b1422;
    --icef-focus: #93c5fd;
    --icef-danger: #fca5a5;
    --icef-shimmer: rgba(255, 255, 255, 0.08);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- prompt */

.icef-instructions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.55rem;
  padding: 0;
  color: var(--icef-fg);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.35;
}

.icef-reference {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  inline-size: 2rem;
  block-size: 2rem;
  padding: 0.15rem;
  border: 0;
  border-radius: 7px;
  background: var(--icef-icon-tile);
  vertical-align: middle;
}

.icef-reference img,
.icef-reference svg {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
}

/* ---------------------------------------------------------------- options */

.icef-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.icef-option {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  inline-size: 3rem;
  min-block-size: 3rem;
  margin: 0;
  padding: 0.28rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.icef-option:hover {
  border-color: var(--icef-border);
  background: var(--icef-tile-hover);
}

.icef-option:active {
  background: var(--icef-accent-soft);
}

.icef-option input[type="radio"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icef-option.is-selected,
.icef-option:has(input[type="radio"]:checked) {
  border-color: var(--icef-accent);
  background: var(--icef-accent-soft);
  box-shadow: 0 0 0 2px var(--icef-accent-soft);
}

.icef-option.is-selected .icef-icon,
.icef-option:has(input[type="radio"]:checked) .icef-icon,
.icef-option input[type="radio"]:checked + .icef-icon {
  transform: scale(1.04);
}

/* Small check badge; the number is in the accessible name instead. */
.icef-option::after {
  content: "✓";
  position: absolute;
  inset-block-start: 0.05rem;
  inset-inline-end: 0.05rem;
  display: grid;
  place-items: center;
  inline-size: 0.82rem;
  block-size: 0.82rem;
  border-radius: 50%;
  background: var(--icef-accent);
  color: var(--icef-accent-contrast);
  font-size: 0.54rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.icef-option.is-selected::after,
.icef-option:has(input[type="radio"]:checked)::after {
  opacity: 1;
  transform: scale(1);
}

.icef-icon {
  display: grid;
  place-items: center;
  inline-size: 2.15rem;
  block-size: 2.15rem;
  padding: 0.16rem;
  border-radius: 7px;
  background: var(--icef-icon-tile);
  transition: transform 0.12s ease;
}

.icef-icon svg,
.icef-icon img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
}

.icef-option:has(input[type="radio"]:focus-visible) {
  outline: 2px solid var(--icef-focus);
  outline-offset: 2px;
}

.icef-option input[type="radio"]:focus-visible + .icef-icon,
.icef-option input[type="radio"]:focus + .icef-icon {
  outline: 2px solid var(--icef-focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- actions */

.icef-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-block-start: 0.35rem;
}

.icef-captcha .icef-status {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0 !important;
  padding: 0;
  color: var(--icef-muted);
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 1;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.icef-captcha .icef-status.is-fading {
  opacity: 0;
  transform: translateY(-2px);
}

/* Stay in the accessibility tree while empty; do not use display:none. */
.icef-captcha .icef-status:empty {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px !important;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icef-captcha.is-error .icef-instructions,
.icef-captcha.is-error .icef-status {
  color: var(--icef-danger);
}

.icef-captcha.is-loading .icef-options {
  opacity: 0.55;
}

.icef-captcha.is-loading .icef-option {
  overflow: hidden;
}

.icef-captcha.is-loading .icef-option::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(100deg, transparent 15%, var(--icef-shimmer) 50%, transparent 85%);
  transform: translateX(-100%);
  animation: icef-shimmer 1.15s linear infinite;
}

@keyframes icef-shimmer {
  to { transform: translateX(100%); }
}

/* Text link rather than a pill/card. */
.icef-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0 !important;
  padding: 0.15rem 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--icef-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.icef-refresh[hidden] {
  display: none;
}

.icef-refresh:hover {
  color: var(--icef-accent);
  text-decoration-thickness: 2px;
}

.icef-refresh:focus-visible {
  outline: 2px solid var(--icef-focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.icef-refresh[aria-disabled="true"] {
  cursor: progress;
  opacity: 0.65;
}

.icef-refresh svg {
  inline-size: 0.95em;
  block-size: 0.95em;
  flex: 0 0 auto;
}

.icef-captcha.is-loading .icef-refresh svg {
  animation: icef-spin 0.9s linear infinite;
}

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

/* ---------------------------------------------------------------- honeypot */

.icef-honeypot {
  position: absolute !important;
  inset-inline-start: -10000px !important;
  inline-size: 1px !important;
  block-size: 1px !important;
  overflow: hidden !important;
}

/* ---------------------------------------------------------------- extras */

.icef-captcha.icef-captcha-preview {
  margin-block-end: 0;
}

/* Framework reset: keep the flat inner layout even when Elementor/Fluent
   wraps the field in their own flex/grid rules. */
div.icef-captcha {
  display: block;
}

.icef-captcha .icef-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.icef-captcha .icef-option {
  margin: 0;
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.icef-captcha .icef-option input[type="radio"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icef-captcha .icef-refresh {
  font: inherit;
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: normal;
}

/* Astra/Elementor/Fluent style every button, including :hover/:focus. Reset
   the box on all states so the refresh control stays a quiet text link. */
.icef-captcha .icef-refresh,
.icef-captcha .icef-refresh:hover,
.icef-captcha .icef-refresh:focus,
.icef-captcha .icef-refresh:active,
.icef-captcha .icef-refresh:focus-visible {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border: 0 !important;
  border-radius: 3px !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  text-shadow: none !important;
  transform: none !important;
  min-height: 0;
  width: auto;
  transition: color 0.14s ease;
  -webkit-text-fill-color: currentColor;
  line-height: 1.4;
}

.icef-captcha .icef-refresh {
  color: var(--icef-muted);
}

.icef-captcha .icef-refresh:hover,
.icef-captcha .icef-refresh:focus-visible {
  color: var(--icef-accent);
}

.icef-captcha .icef-refresh::before,
.icef-captcha .icef-refresh::after {
  content: none !important;
  display: none !important;
}

@media (max-width: 480px) {
  .icef-options {
    gap: 0.2rem;
  }

  .icef-option {
    inline-size: 2.75rem;
    min-block-size: 2.75rem;
  }

  .icef-icon {
    inline-size: 1.95rem;
    block-size: 1.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .icef-option,
  .icef-icon,
  .icef-option::after {
    transition: none;
  }

  .icef-captcha.is-loading .icef-option::before,
  .icef-captcha.is-loading .icef-refresh svg {
    animation: none;
  }

  .icef-captcha .icef-status {
    transition: none;
  }
}

@media (prefers-contrast: more) {
  .icef-option {
    border-color: currentColor;
  }

  .icef-option.is-selected,
  .icef-option:has(input[type="radio"]:checked) {
    outline: 2px solid currentColor;
    outline-offset: 1px;
  }
}

/* Windows high-contrast mode: keep the light icon tiles readable. */
@media (forced-colors: active) {
  .icef-captcha,
  .icef-instructions,
  .icef-status {
    color: CanvasText;
  }

  .icef-option {
    border: 1px solid transparent;
    background: transparent;
    color: CanvasText;
  }

  .icef-option.is-selected,
  .icef-option:has(input[type="radio"]:checked) {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }

  .icef-option::after {
    background: Highlight;
    color: HighlightText;
  }

  .icef-reference,
  .icef-icon {
    forced-color-adjust: none;
    border: 0;
    background: #f8fafc;
  }

  .icef-captcha.is-loading .icef-option::before {
    display: none;
  }
}

@media print {
  .icef-refresh,
  .icef-status {
    display: none !important;
  }
}
