/*
 * ROLLerUP Visualizer — widget layout.
 * Hand-written against static/css/ru-brand.css custom properties.
 * No utility-class CSS framework loaded (see 02-RESEARCH.md Pitfall 2 for
 * why a CDN-hosted browser-runtime build of that kind doesn't exist). No raw hex —
 * every colour comes from a var(--ru-*) token. Radii <= 8px. No box-shadow
 * on interactive controls (buttons/chips) — shadows are for overlays only.
 * Mobile-first: base rules are the phone layout; desktop refinements sit
 * behind a single @media (min-width: 640px) block at the bottom.
 */

[x-cloak] { display: none !important; }

.ru-noscript {
  background: var(--ru-brand-bg-tint);
  color: var(--ru-text);
  border: 1px solid var(--ru-brand-border);
  border-radius: var(--ru-radius-lg);
  padding: var(--ru-space-3);
  margin: var(--ru-space-3);
  font-size: var(--ru-font-medium);
}

.ru-widget {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--ru-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--ru-space-4);
}

.ru-landing {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--ru-space-6) var(--ru-space-3);
}

.ru-h1 {
  font-size: var(--ru-font-xlarge);
  font-weight: 600;
  margin: 0 0 var(--ru-space-2);
  color: var(--ru-text);
}

.ru-h2 {
  font-size: var(--ru-font-large);
  font-weight: 600;
  margin: 0 0 var(--ru-space-1);
  color: var(--ru-text);
}

.ru-body {
  font-size: var(--ru-font-medium);
  color: var(--ru-text-secondary);
  margin: 0 0 var(--ru-space-3);
}

.ru-hint {
  font-size: var(--ru-font-small);
  color: var(--ru-text-tertiary);
  margin: var(--ru-space-1) 0;
}

.ru-step {
  display: flex;
  flex-direction: column;
  gap: var(--ru-space-3);
}

/* ---- Buttons ---- */

.ru-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--ru-space-4);
  border-radius: var(--ru-radius-lg);
  border: 1px solid transparent;
  font-size: var(--ru-font-medium);
  font-weight: 600;
  font-family: var(--ru-font-sans);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-shadow: none;
  transition: background-color 120ms ease;
}

.ru-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ru-btn:focus-visible {
  outline: none;
  box-shadow: var(--ru-focus-ring);
}

.ru-btn-primary {
  background: var(--ru-brand);
  color: var(--ru-text-oninverse);
}

.ru-btn-primary:hover:not(:disabled) {
  background: var(--ru-brand-hover);
}

.ru-btn-primary:active:not(:disabled) {
  background: var(--ru-brand-pressed);
}

.ru-btn-secondary {
  background: var(--ru-bg);
  color: var(--ru-brand);
  border-color: var(--ru-border);
}

.ru-btn-secondary:hover:not(:disabled) {
  background: var(--ru-brand-bg-tint);
}

.ru-upload-label {
  position: relative;
  overflow: hidden;
  width: fit-content;
}

.ru-upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ---- Chips / swatches ---- */

.ru-chip-row,
.ru-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ru-space-2);
}

.ru-chip {
  min-height: 44px;
  padding: 0 var(--ru-space-3);
  border-radius: var(--ru-radius);
  border: 1px solid var(--ru-border);
  background: var(--ru-bg);
  color: var(--ru-text);
  font-size: var(--ru-font-medium);
  cursor: pointer;
  box-shadow: none;
}

.ru-chip:focus-visible {
  outline: none;
  box-shadow: var(--ru-focus-ring);
}

.ru-chip-selected {
  border-color: var(--ru-brand);
  background: var(--ru-brand-bg-tint);
  color: var(--ru-brand);
}

.ru-swatch-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ru-space-1);
  min-height: 44px;
  min-width: 44px;
  padding: var(--ru-space-1);
  border-radius: var(--ru-radius);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  box-shadow: none;
}

.ru-swatch-btn:focus-visible {
  outline: none;
  box-shadow: var(--ru-focus-ring);
}

.ru-swatch-selected {
  border-color: var(--ru-brand);
}

.ru-swatch {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--ru-border);
}

.ru-swatch-label {
  font-size: var(--ru-font-small);
  color: var(--ru-text-secondary);
}

/* ---- Progress ---- */

.ru-progress {
  height: 6px;
  width: 100%;
  background: var(--ru-border);
  border-radius: var(--ru-radius-sm);
  overflow: hidden;
}

.ru-progress-bar {
  height: 100%;
  background: var(--ru-brand);
  width: 0%;
  transition: width 200ms ease;
}

.ru-step-progress .ru-progress-indeterminate .ru-progress-bar {
  width: 40%;
  animation: ru-indeterminate 1.2s ease-in-out infinite;
}

@keyframes ru-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* ---- Canvas placement ---- */

.ru-canvas-wrap {
  width: 100%;
  border-radius: var(--ru-radius-lg);
  overflow: hidden;
  border: 1px solid var(--ru-border);
  background: var(--ru-bg-page);
}

#ru-placement-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

/* ---- Before/after compare slider (RSLT-01) ---- */

.ru-compare {
  position: relative;
  border-radius: var(--ru-radius-lg);
  overflow: hidden;
}

.ru-compare-before {
  display: block;
  width: 100%;
}

.ru-compare-after {
  position: absolute;
  inset: 0;
  width: 100%;
  clip-path: inset(0 50% 0 0);
}

.ru-compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

.ru-compare-range::-webkit-slider-runnable-track {
  background: transparent;
}

.ru-compare-range::-moz-range-track {
  background: transparent;
}

/* 44px thumb — grabbable on a phone (brand skill + touch-target minimum). */
.ru-compare-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ru-brand);
  border: none;
  cursor: ew-resize;
}

.ru-compare-range::-moz-range-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ru-brand);
  border: none;
  cursor: ew-resize;
}

/* ---- Result / errors ---- */

.ru-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ru-space-2);
}

.ru-result-actions-primary {
  display: flex;
  flex-direction: column;
  gap: var(--ru-space-2);
}

/* ---- Privacy notice (PRIV-01) ---- */

.ru-privacy-note {
  font-size: var(--ru-font-small);
  color: var(--ru-text-tertiary);
  margin: 0;
}

.ru-privacy-note a {
  color: var(--ru-brand);
}

/* ---- Lead form (LEAD-01, LEAD-02) ---- */

.ru-form {
  display: flex;
  flex-direction: column;
  gap: var(--ru-space-3);
}

.ru-field {
  display: flex;
  flex-direction: column;
  gap: var(--ru-space-1);
}

.ru-label {
  font-size: var(--ru-font-small);
  font-weight: 600;
  color: var(--ru-text);
}

.ru-input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--ru-space-3);
  border-radius: var(--ru-radius);
  border: 1px solid var(--ru-border);
  background: var(--ru-bg);
  color: var(--ru-text);
  font-size: var(--ru-font-medium);
  font-family: var(--ru-font-sans);
  box-shadow: none;
}

.ru-input:focus-visible {
  outline: none;
  box-shadow: var(--ru-focus-ring);
}

.ru-field-error {
  font-size: var(--ru-font-small);
  color: var(--ru-danger);
  margin: 0;
}

.ru-check-row {
  display: flex;
  align-items: flex-start;
  gap: var(--ru-space-2);
  min-height: 44px;
  font-size: var(--ru-font-medium);
  color: var(--ru-text);
}

.ru-check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---- Confirmation / deletion (LEAD-05, PRIV-02) ---- */

.ru-delete-block {
  border: 1px solid var(--ru-border);
  border-radius: var(--ru-radius);
  padding: var(--ru-space-3);
}

.ru-delete-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ru-text);
}

.ru-delete-link {
  color: var(--ru-brand);
  word-break: break-all;
}

.ru-alert-success {
  border-radius: var(--ru-radius-lg);
  border: 1px solid var(--ru-success-border);
  background: color-mix(in oklab, var(--ru-success) 8%, var(--ru-bg));
  color: var(--ru-success);
  padding: var(--ru-space-2) var(--ru-space-3);
  font-size: var(--ru-font-medium);
}

.ru-credits {
  font-size: var(--ru-font-small);
  color: var(--ru-text-secondary);
  margin: 0;
}

.ru-alert {
  border-radius: var(--ru-radius-lg);
  border: 1px solid var(--ru-danger-border);
  background: color-mix(in oklab, var(--ru-danger) 8%, var(--ru-bg));
  color: var(--ru-danger);
  padding: var(--ru-space-2) var(--ru-space-3);
  font-size: var(--ru-font-medium);
}

/* ---- Embed docs page ---- */

.ru-embed-docs {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--ru-space-6) var(--ru-space-3);
}

.ru-code-block {
  background: var(--ru-bg-inverse);
  color: var(--ru-text-oninverse);
  border-radius: var(--ru-radius-lg);
  padding: var(--ru-space-3);
  overflow-x: auto;
  font-family: var(--ru-font-mono);
  font-size: var(--ru-font-small);
}

.ru-list {
  font-size: var(--ru-font-medium);
  color: var(--ru-text-secondary);
  padding-left: var(--ru-space-4);
}

@media (min-width: 640px) {
  .ru-widget {
    padding: var(--ru-space-5);
  }

  .ru-chip-row,
  .ru-result-actions {
    gap: var(--ru-space-3);
  }

  .ru-result-actions-primary {
    flex-direction: row;
  }
}
