/**
 * Discover & Onboarding wizard styles — (v5-mini-app-7-1)
 * Full-screen overlay with 3-step horizontal slide layout.
 * Uses CSS variables provided by app.css / Telegram theme.
 */

/* ── Overlay container ────────────────────────────────────────────────────── */

.wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--cl-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header bar ───────────────────────────────────────────────────────────── */

.wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 0;
  flex-shrink: 0;
}

.wizard-progress {
  display: flex;
  gap: 6px;
  align-items: center;
}

.wizard-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cl-border);
  transition: background 0.25s ease, transform 0.25s ease;
}

.wizard-dot--active {
  background: var(--cl-link);
  transform: scale(1.25);
}

.wizard-skip {
  background: none;
  border: none;
  color: var(--cl-link);
  font-size: 15px;
  cursor: pointer;
  padding: 8px 0 8px 16px; /* extend tap area left */
  min-height: 44px;         /* T1d */
  -webkit-tap-highlight-color: transparent;
}

/* ── Slide track ──────────────────────────────────────────────────────────── */

/**
 * .wizard-track holds all three steps side-by-side in a row.
 * translateX(-N * 100%) scrolls to step N+1.
 * The transition is driven by the inline style set in the template via
 * `:style="{ transform: 'translateX(-' + (step - 1) * 100 + '%)' }"`.
 */
.wizard-track {
  display: flex;
  flex: 1;
  min-height: 0;
  transition: transform 0.3s ease-out;
  will-change: transform;
}

.wizard-step {
  min-width: 100%;
  max-width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 80px; /* bottom padding for MainButton clearance */
  box-sizing: border-box;
}

/* ── Step headers ─────────────────────────────────────────────────────────── */

.wizard-step-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--cl-text);
  margin: 0 0 4px;
}

.wizard-step-subtitle {
  font-size: 14px;
  color: var(--cl-text-secondary);
  margin: 0 0 20px;
}

/* ── Skeleton (T7a, AC10) ─────────────────────────────────────────────────── */

.wizard-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skel-bar {
  height: 14px;
  border-radius: 7px;
  background: var(--cl-border);
  animation: skel-pulse 1.4s ease-in-out infinite;
}

.skel-bar--wide  { width: 80%; }
.skel-bar--mid   { width: 60%; }
.skel-bar--short { width: 40%; }

@keyframes skel-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Pattern bars (T3b) ───────────────────────────────────────────────────── */

.pattern-section {
  margin-bottom: 20px;
}

.pattern-section__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cl-text-secondary);
  margin: 0 0 10px;
}

.pattern-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pattern-row__name {
  width: 90px;
  font-size: 13px;
  color: var(--cl-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  text-transform: capitalize;
}

.pattern-row__bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--cl-border);
  border-radius: 4px;
  overflow: hidden;
}

.pattern-row__bar-fill {
  height: 100%;
  background: var(--cl-link);
  border-radius: 4px;
  transition: width 0.5s ease-out;
}

.pattern-row__pct {
  width: 34px;
  text-align: right;
  font-size: 12px;
  color: var(--cl-text-secondary);
  flex-shrink: 0;
}

/* ── Unit tags ────────────────────────────────────────────────────────────── */

.unit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.unit-tag {
  padding: 4px 10px;
  background: var(--cl-card);
  border: 1px solid var(--cl-border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--cl-text);
}

/* ── Time patterns ────────────────────────────────────────────────────────── */

.time-pattern-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.time-pattern-item {
  font-size: 13px;
  color: var(--cl-text-secondary);
  padding: 4px 0;
}

.time-pattern-item::before {
  content: '→ ';
  color: var(--cl-link);
}

/* ── Error banner ─────────────────────────────────────────────────────────── */

.wizard-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--cl-error, #ef4444);
  border-radius: var(--cl-radius, 8px);
  color: var(--cl-error, #ef4444);
  font-size: 14px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.btn-retry {
  margin-top: 8px;
  padding: 6px 14px;
  background: var(--cl-btn);
  color: var(--cl-btn-text);
  border: none;
  border-radius: var(--cl-radius, 8px);
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── Step 2: template card ────────────────────────────────────────────────── */

.template-card {
  background: var(--cl-card);
  border-radius: var(--cl-radius, 12px);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.template-card__icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}

.template-card__info {
  flex: 1;
  min-width: 0;
}

.template-card__name {
  font-size: 17px;
  font-weight: 600;
  color: var(--cl-text);
  margin: 0 0 4px;
}

.template-card__desc {
  font-size: 13px;
  color: var(--cl-text-secondary);
  margin: 0;
}

/* ── Before / After comparison (T4c) ─────────────────────────────────────── */

.before-after {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.before-after__col {
  flex: 1;
  background: var(--cl-card);
  border-radius: var(--cl-radius, 8px);
  padding: 12px;
  min-width: 0;
}

.before-after__heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
}

.before-after__heading--before { color: var(--cl-text-secondary); }
.before-after__heading--after  { color: var(--cl-success, #10b981); }

.before-after__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.before-after__item {
  font-size: 12px;
  color: var(--cl-text-secondary);
}

.before-after__item--after {
  color: var(--cl-text);
}

.before-after__item--after::before {
  content: '✓ ';
  color: var(--cl-success, #10b981);
}

/* ── "Browse Others" link ─────────────────────────────────────────────────── */

.btn-browse {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--cl-link);
  border: 1px solid var(--cl-link);
  border-radius: var(--cl-radius, 8px);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px; /* T1d */
}

/* ── Next button (step 1 → 2) ─────────────────────────────────────────────── */

.btn-wizard-next {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--cl-btn);
  color: var(--cl-btn-text);
  border: none;
  border-radius: var(--cl-radius, 8px);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  margin-top: 24px;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px; /* T1d */
}

/* ── Use template button (step 2 → 3) ────────────────────────────────────── */

.btn-use-template {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--cl-btn);
  color: var(--cl-btn-text);
  border: none;
  border-radius: var(--cl-radius, 8px);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  margin-bottom: 10px;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px; /* T1d */
}

/* ── Step 3: Confirm ──────────────────────────────────────────────────────── */

.confirm-summary {
  background: var(--cl-card);
  border-radius: var(--cl-radius, 12px);
  padding: 16px;
  margin-bottom: 20px;
}

.confirm-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--cl-border);
  font-size: 14px;
}

.confirm-summary__row:last-child {
  border-bottom: none;
}

.confirm-summary__label {
  color: var(--cl-text-secondary);
}

.confirm-summary__value {
  color: var(--cl-text);
  font-weight: 500;
  text-align: right;
  flex: 1;
  margin-left: 16px;
}

.confirm-note {
  font-size: 13px;
  color: var(--cl-text-secondary);
  margin: 0 0 24px;
  line-height: 1.5;
}

/* ── Catalog overlay ──────────────────────────────────────────────────────── */

/* M4 fix: position:fixed prevents overflow clipping in WebKit scroll contexts */
.catalog-overlay {
  position: fixed;
  inset: 0;
  background: var(--cl-bg);
  z-index: 210;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.catalog-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--cl-border);
  flex-shrink: 0;
}

.catalog-back {
  background: none;
  border: none;
  color: var(--cl-link);
  font-size: 15px;
  cursor: pointer;
  padding: 8px;
  min-height: 44px; /* T1d */
  -webkit-tap-highlight-color: transparent;
}

.catalog-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--cl-text);
  margin: 0;
}

.catalog-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalog-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--cl-card);
  border-radius: var(--cl-radius, 8px);
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px; /* T1d */
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s;
}

.catalog-item--selected {
  border-color: var(--cl-link);
}

.catalog-item__icon {
  font-size: 24px;
  flex-shrink: 0;
}

.catalog-item__info {
  flex: 1;
  min-width: 0;
}

.catalog-item__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--cl-text);
}

.catalog-item__category {
  font-size: 12px;
  color: var(--cl-text-secondary);
  text-transform: capitalize;
}
