/* ============================================================
   OpinionPress — Frontend Styles v1.1
   Self-hosted polls, quizzes, surveys — no SaaS, no fees
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ── Light theme variables (default) ───────────────────── */
:root {
  --op-font:        'DM Sans', system-ui, sans-serif;
  --op-radius:      14px;
  --op-radius-sm:   8px;
  --op-shadow:      0 4px 24px rgba(0,0,0,.09), 0 1px 4px rgba(0,0,0,.05);
  --op-accent:      #4f46e5;
  --op-accent-2:    #4338ca;

  /* Light palette */
  --op-bg:          #ffffff;
  --op-surface:     #f7f8fc;
  --op-border:      #e4e7f0;
  --op-text:        #18191e;
  --op-muted:       #6b7280;
  --op-green:       #16a34a;
  --op-red:         #dc2626;
  --op-yellow:      #f59e0b;

  /* Badge colours */
  --op-poll-color:   #0ea5e9;
  --op-quiz-color:   #8b5cf6;
  --op-survey-color: #10b981;

  /* Background image support */
  --op-bg-image:   none;
  --op-bg-overlay: 0.4;
}

/* ── Dark theme ─────────────────────────────────────────── */
.op-theme-dark,
[data-op-theme="dark"] {
  --op-bg:      #16161e;
  --op-surface: #1e1e2a;
  --op-border:  #2e2e3e;
  --op-text:    #e8e8f0;
  --op-muted:   #9090a8;
}

/* ── Auto theme — follow OS ─────────────────────────────── */
@media (prefers-color-scheme: dark) {
  [data-op-theme="auto"] {
    --op-bg:      #16161e;
    --op-surface: #1e1e2a;
    --op-border:  #2e2e3e;
    --op-text:    #e8e8f0;
    --op-muted:   #9090a8;
  }
}

/* ── Native / Use theme mode ────────────────────────────── */
/* Strip all custom styling so the WP theme takes over */
.op-theme-native.op-widget {
  font-family: inherit;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  max-width: 100%;
  color: inherit;
}
.op-theme-native .op-option {
  background: transparent;
  border-color: currentColor;
  border-width: 1px;
}
.op-theme-native .op-btn {
  font-family: inherit;
}
.op-theme-native .op-result-bar__fill { background: var(--op-accent); }
.op-theme-native .op-badge { background: var(--op-accent); }

/* ══════════════════════════════════════════════════════════
   WIDGET BASE
   ══════════════════════════════════════════════════════════ */

.op-widget {
  font-family: var(--op-font);
  background: var(--op-bg);
  border: 1.5px solid var(--op-border);
  border-radius: var(--op-radius);
  padding: 28px 30px;
  box-shadow: var(--op-shadow);
  max-width: 640px;
  margin: 2rem auto;
  color: var(--op-text);
  line-height: 1.5;
  position: relative;
  overflow: hidden;
  transition: background .25s, border-color .25s, color .25s;
}

/* Background image overlay */
.op-has-bg-image {
  background-image: var(--op-bg-image) !important;
  background-size: cover;
  background-position: center;
}
.op-has-bg-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,var(--op-bg-overlay));
  z-index: 0;
}
.op-has-bg-image > * { position: relative; z-index: 1; }
.op-has-bg-image {
  --op-bg:      transparent;
  --op-surface: rgba(255,255,255,.12);
  --op-border:  rgba(255,255,255,.2);
  --op-text:    #ffffff;
  --op-muted:   rgba(255,255,255,.75);
}

/* ── Header image ───────────────────────────────────────── */
.op-header-image {
  margin: -28px -30px 20px;
  height: 160px;
  background-size: cover;
  background-position: center;
  border-radius: calc(var(--op-radius) - 1px) calc(var(--op-radius) - 1px) 0 0;
}

/* ── Header ─────────────────────────────────────────────── */
.op-header    { margin-bottom: 20px; }
.op-badge     {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
  color: #fff;
}
.op-badge--poll   { background: var(--op-poll-color); }
.op-badge--quiz   { background: var(--op-quiz-color); }
.op-badge--survey { background: var(--op-survey-color); }

.op-title {
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  margin: 0 0 6px !important;
  color: var(--op-text) !important;
  line-height: 1.3 !important;
}
.op-desc {
  color: var(--op-muted);
  font-size: .93rem;
  margin: 0 !important;
}

/* ── Question text ──────────────────────────────────────── */
.op-question-text { font-size: 1rem; font-weight: 600; margin-bottom: 16px; color: var(--op-text); }
.op-question { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--op-border); }
.op-question:last-child { border-bottom: none; }
.op-question__num  { font-size: .75rem; font-weight: 700; color: var(--op-accent); letter-spacing: .05em; margin-bottom: 6px; text-transform: uppercase; }
.op-question__text { font-weight: 600; font-size: .98rem; margin-bottom: 14px; color: var(--op-text); }
.op-required { color: var(--op-red); margin-left: 3px; }

/* ── Options ────────────────────────────────────────────── */
.op-options { display: flex; flex-direction: column; gap: 8px; }
.op-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--op-surface);
  border: 1.5px solid var(--op-border);
  border-radius: var(--op-radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  user-select: none;
}
.op-option:hover         { border-color: var(--op-accent); background: color-mix(in srgb, var(--op-accent) 8%, var(--op-bg)); transform: translateX(2px); }
.op-option--selected     { border-color: var(--op-accent); background: color-mix(in srgb, var(--op-accent) 10%, var(--op-bg)); }
.op-option--correct      { border-color: var(--op-green) !important; background: color-mix(in srgb, var(--op-green) 10%, var(--op-bg)) !important; }
.op-option--wrong        { border-color: var(--op-red)   !important; background: color-mix(in srgb, var(--op-red)   10%, var(--op-bg)) !important; }
.op-option input[type="radio"],
.op-option input[type="checkbox"] { accent-color: var(--op-accent); width: 16px; height: 16px; flex-shrink: 0; }
.op-option__label { font-size: .94rem; flex: 1; color: var(--op-text); }

/* ── Star rating ────────────────────────────────────────── */
.op-rating { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.op-rating__star { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: var(--op-border); transition: color .1s, transform .1s; padding: 0; line-height: 1; }
.op-rating__star:hover, .op-rating__star.is-active { color: var(--op-yellow); transform: scale(1.15); }

/* ── Scale ──────────────────────────────────────────────── */
.op-scale__track { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.op-scale__point { cursor: pointer; }
.op-scale__point input { display: none; }
.op-scale__point span { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--op-radius-sm); background: var(--op-surface); border: 1.5px solid var(--op-border); font-size: .9rem; font-weight: 600; color: var(--op-text); transition: all .15s; }
.op-scale__point input:checked + span { background: var(--op-accent); border-color: var(--op-accent); color: #fff; }
.op-scale__point:hover span { border-color: var(--op-accent); color: var(--op-accent); }
.op-scale__labels { display: flex; justify-content: space-between; font-size: .8rem; color: var(--op-muted); }

/* ── Text inputs ────────────────────────────────────────── */
.op-textarea, .op-input {
  width: 100%; box-sizing: border-box;
  border: 1.5px solid var(--op-border); border-radius: var(--op-radius-sm);
  padding: 10px 12px; font-family: var(--op-font); font-size: .94rem;
  color: var(--op-text); background: var(--op-surface); transition: border-color .15s; resize: vertical;
}
.op-textarea:focus, .op-input:focus { border-color: var(--op-accent); outline: none; background: var(--op-bg); }

/* ── Buttons ────────────────────────────────────────────── */
.op-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--op-font); font-size: .93rem; font-weight: 600;
  padding: 11px 22px; border-radius: var(--op-radius-sm);
  border: none; cursor: pointer; transition: all .15s; text-decoration: none;
}
.op-btn--vote   { background: var(--op-poll-color); color: #fff; margin-top: 16px; }
.op-btn--vote:hover { background: #0284c7; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(14,165,233,.35); }
.op-btn--submit { background: var(--op-accent); color: #fff; margin-top: 8px; }
.op-btn--submit:hover { background: var(--op-accent-2); transform: translateY(-1px); box-shadow: 0 4px 16px color-mix(in srgb, var(--op-accent) 40%, transparent); }
.op-btn--submit:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }
.op-arrow { transition: transform .15s; }
.op-btn--submit:hover .op-arrow { transform: translateX(3px); }

/* ── Progress ───────────────────────────────────────────── */
.op-progress-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.op-progress { flex: 1; height: 5px; background: var(--op-border); border-radius: 999px; overflow: hidden; }
.op-progress__bar { height: 100%; background: linear-gradient(90deg, var(--op-survey-color), #3b82f6); border-radius: 999px; transition: width .3s ease; }
.op-progress__label { font-size: .8rem; color: var(--op-muted); white-space: nowrap; }

/* ── Result bars ────────────────────────────────────────── */
.op-results { margin-top: 20px; }
.op-result-bar { margin-bottom: 12px; }
.op-result-bar__label { font-size: .88rem; font-weight: 500; margin-bottom: 4px; color: var(--op-text); }
.op-result-bar__track { position: relative; background: var(--op-surface); border-radius: 999px; height: 26px; overflow: hidden; }
.op-result-bar__fill { height: 100%; background: linear-gradient(90deg, var(--op-accent), var(--op-accent-2)); border-radius: 999px; transition: width .5s cubic-bezier(.34,1.56,.64,1); }
.op-result-bar__pct { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: .8rem; font-weight: 700; color: var(--op-text); }
.op-total { font-size: .82rem; color: var(--op-muted); text-align: right; margin-top: 8px; }
.op-expires { font-size: .78rem; color: var(--op-muted); margin-top: 10px; text-align: right; }

/* ── Quiz results ───────────────────────────────────────── */
.op-quiz-score-banner {
  background: linear-gradient(135deg, var(--op-accent), var(--op-accent-2));
  color: #fff; border-radius: var(--op-radius-sm);
  padding: 20px 24px; text-align: center; margin-bottom: 20px;
}
.op-quiz-score-banner__num   { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.op-quiz-score-banner__label { font-size: .88rem; opacity: .85; margin-top: 4px; }
.op-quiz-score-banner__msg   { margin-top: 12px; font-weight: 600; font-size: .95rem; }

.op-quiz-feedback-item { padding: 12px 14px; border-radius: var(--op-radius-sm); margin-bottom: 8px; border-left: 4px solid transparent; }
.op-quiz-feedback-item--correct { background: color-mix(in srgb, var(--op-green) 10%, var(--op-bg)); border-color: var(--op-green); }
.op-quiz-feedback-item--wrong   { background: color-mix(in srgb, var(--op-red)   10%, var(--op-bg)); border-color: var(--op-red); }
.op-quiz-feedback-item__q    { font-weight: 600; font-size: .9rem; margin-bottom: 4px; color: var(--op-text); }
.op-quiz-feedback-item__info { font-size: .85rem; color: var(--op-muted); }
.op-quiz-feedback-item__exp  { font-size: .85rem; color: var(--op-muted); margin-top: 4px; font-style: italic; }

/* ── Thank you / already voted ──────────────────────────── */
.op-thankyou { text-align: center; padding: 24px 0 8px; }
.op-thankyou__icon { font-size: 2rem; width: 56px; height: 56px; background: color-mix(in srgb, var(--op-green) 12%, var(--op-bg)); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; color: var(--op-green); font-weight: 700; }
.op-thankyou__text { font-size: 1rem; font-weight: 500; color: var(--op-text); }
.op-already-voted { color: var(--op-muted); font-size: .9rem; padding: 6px 0; }
.op-closed-msg { color: var(--op-muted); font-style: italic; }

/* ── Misc ───────────────────────────────────────────────── */
.op-error { color: var(--op-red); font-size: .88rem; }
.op-widget.op-loading { opacity: .6; pointer-events: none; }
.op-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: op-spin .6s linear infinite; vertical-align: middle; }
@keyframes op-spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 540px) {
  .op-widget { padding: 20px 16px; }
  .op-header-image { margin: -20px -16px 16px; }
  .op-scale__point span { width: 30px; height: 30px; font-size: .82rem; }
}
