/*
 * Website Health Grader Widget Styles
 * Scoped to .whg-* prefix to avoid CSS pollution.
 */

/* ── Container ─────────────────────────────── */

.whg-widget {
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 32px 24px;
  min-height: 380px;
  overflow: hidden;
}

/* ── Input state ───────────────────────────── */

.whg-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.whg-label {
  font-family: var(--ks-font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.whg-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.whg-input-wrap:focus-within {
  border-color: var(--ks-accent, #10b981);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.whg-favicon {
  width: 24px;
  height: 24px;
  margin-left: 12px;
  border-radius: 4px;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.whg-favicon--visible {
  opacity: 1;
  transform: translateX(0);
}

.whg-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 12px;
  font-family: var(--ks-font-body, 'DM Sans', sans-serif);
  font-size: 16px;
  color: #fff;
  outline: none;
}

.whg-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.whg-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.whg-field {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--ks-font-body, 'DM Sans', sans-serif);
  font-size: 14px;
  color: #fff;
  outline: none;
  transition: border-color 0.3s ease;
}

.whg-field:focus {
  border-color: var(--ks-accent, #10b981);
}

.whg-field::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.whg-btn {
  background: var(--ks-accent, #10b981);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 24px;
  font-family: var(--ks-font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.whg-btn:hover {
  background: #0d9668;
}

.whg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.whg-hint {
  font-size: 13px;
  color: var(--ks-accent, #10b981);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.whg-hint--visible {
  opacity: 1;
}

/* ── Pulse glow (prescan active) ───────────── */

@keyframes whg-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
  50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25); }
}

.whg-input-wrap--pulsing {
  animation: whg-pulse 2s ease-in-out infinite;
}

/* ── Loading state (matrix) ────────────────── */

.whg-matrix {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 16px;
}

.whg-loading-overlay {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  text-align: center;
}

.whg-favicon--lg {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

.whg-scanning {
  font-family: var(--ks-font-body, 'DM Sans', sans-serif);
  font-size: 16px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 24px;
}

.whg-scanning strong {
  color: #fff;
}

.whg-checks {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
}

.whg-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-family: var(--ks-font-body, 'DM Sans', sans-serif);
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.whg-check--visible {
  opacity: 1;
  transform: translateY(0);
}

.whg-check--done {
  color: var(--ks-accent, #10b981);
}

.whg-tick {
  width: 16px;
  height: 16px;
  color: var(--ks-accent, #10b981);
}

.whg-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--ks-accent, #10b981);
  border-radius: 50%;
  animation: whg-spin 0.8s linear infinite;
}

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

/* ── Results state ─────────────────────────── */

.whg-results {
  opacity: 0;
  filter: blur(8px);
  transform: translateY(16px);
  transition: opacity 0.6s ease, filter 0.6s ease, transform 0.6s ease;
}

.whg-results--visible {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}

.whg-results-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.whg-results-title {
  font-family: var(--ks-font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}

.whg-results-title strong {
  color: #fff;
}

/* ── Score ring ────────────────────────────── */

.whg-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.whg-gauge {
  width: 120px;
  height: 120px;
}

.whg-gauge-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 8;
}

.whg-gauge-fill {
  fill: none;
  stroke: var(--ks-accent, #10b981);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), stroke 0.5s ease;
}

.whg-score-number {
  font-family: var(--ks-font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 36px;
  font-weight: 800;
  color: #fff;
  margin-top: -80px;
  letter-spacing: -0.03em;
}

.whg-score-label {
  font-family: var(--ks-font-body, 'DM Sans', sans-serif);
  font-size: 14px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: -4px;
}

/* ── Dimension bars ────────────────────────── */

.whg-dimensions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.whg-dim {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.whg-dim--visible {
  opacity: 1;
  transform: translateY(0);
}

.whg-dim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.whg-dim-name {
  font-family: var(--ks-font-body, 'DM Sans', sans-serif);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.whg-dim-score {
  font-family: var(--ks-font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.whg-dim-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.whg-dim-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Fixes ─────────────────────────────────── */

.whg-fixes {
  margin-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 20px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.whg-fixes--visible {
  opacity: 1;
  transform: translateY(0);
}

.whg-fixes-title {
  font-family: var(--ks-font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 12px;
}

.whg-fix-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  margin-bottom: 8px;
}

.whg-fix-priority {
  width: 24px;
  height: 24px;
  background: var(--ks-accent, #10b981);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.whg-fix-heading {
  font-size: 14px;
  color: #fff;
}

.whg-fix-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  margin: 4px 0;
  line-height: 1.5;
}

.whg-fix-link {
  font-size: 13px;
  color: var(--ks-accent, #10b981);
  text-decoration: none;
}

.whg-fix-link:hover {
  text-decoration: underline;
}

/* ── Error state ───────────────────────────── */

.whg-error {
  text-align: center;
  padding: 48px 24px;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--ks-font-body, 'DM Sans', sans-serif);
}

.whg-error-msg {
  margin-bottom: 16px;
}

/* ── Screen reader only ────────────────────── */

.whg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ────────────────────────────── */

@media (max-width: 640px) {
  .whg-widget {
    padding: 24px 16px;
    min-height: 320px;
  }

  .whg-fields {
    grid-template-columns: 1fr;
  }

  .whg-score-number {
    font-size: 28px;
  }

  .whg-gauge {
    width: 100px;
    height: 100px;
  }

  .whg-score-number {
    margin-top: -70px;
  }
}

/* ── Reduced motion ────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .whg-dim-fill,
  .whg-gauge-fill,
  .whg-results,
  .whg-dim,
  .whg-fixes,
  .whg-check,
  .whg-favicon {
    transition: none;
  }

  .whg-input-wrap--pulsing {
    animation: none;
  }

  .whg-spinner {
    animation: none;
  }
}
