/* Cosmo Man B3 — INCI analyzer + compare + chat */

.cm-section {
  --cm-bg: #e8ecf1;
  --cm-shadow-dark: #a3b1c6;
  --cm-shadow-light: #ffffff;
  --cm-accent: #0f766e;
  --cm-accent-soft: rgba(15, 118, 110, 0.12);
  --cm-text: #1e293b;
  --cm-muted: #64748b;
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  color: var(--cm-text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.cm-section h2 {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  margin: 0 0 0.5rem;
}

.cm-section-desc {
  color: var(--cm-muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.cm-neu-inset {
  background: var(--cm-bg);
  border-radius: 16px;
  box-shadow: inset 6px 6px 12px var(--cm-shadow-dark), inset -6px -6px 12px var(--cm-shadow-light);
  padding: 1rem;
}

.cm-neu-raised {
  background: var(--cm-bg);
  border-radius: 16px;
  box-shadow: 8px 8px 16px var(--cm-shadow-dark), -8px -8px 16px var(--cm-shadow-light);
  padding: 1.25rem;
}

.cm-compare-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.cm-vs-badge {
  align-self: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--cm-accent);
  background: var(--cm-bg);
  box-shadow: 4px 4px 8px var(--cm-shadow-dark), -4px -4px 8px var(--cm-shadow-light);
}

.cm-col-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.cm-label {
  display: block;
  font-size: 0.85rem;
  color: var(--cm-muted);
  margin-bottom: 0.35rem;
}

.cm-inci-input,
.cm-catalog-select,
.cm-chat-input {
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-radius: 12px;
  padding: 0.75rem;
  font: inherit;
  background: #f1f5f9;
  box-shadow: inset 2px 2px 5px rgba(163, 177, 198, 0.35);
  color: var(--cm-text);
}

.cm-inci-input {
  min-height: 140px;
  resize: vertical;
}

.cm-hint {
  font-size: 0.8rem;
  color: var(--cm-muted);
  margin: 0.5rem 0 0;
}

.cm-analyzer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.cm-btn-primary,
.cm-btn-secondary,
.cm-btn-ghost {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.cm-btn-primary {
  background: var(--cm-accent);
  color: #fff;
  box-shadow: 4px 4px 10px rgba(15, 118, 110, 0.35);
}

.cm-btn-secondary {
  background: var(--cm-bg);
  color: var(--cm-text);
  box-shadow: 4px 4px 8px var(--cm-shadow-dark), -4px -4px 8px var(--cm-shadow-light);
}

.cm-btn-ghost {
  background: transparent;
  color: var(--cm-muted);
}

.cm-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.cm-status {
  min-height: 1.25rem;
  color: #b45309;
  font-size: 0.9rem;
}

.cm-report {
  margin-top: 1rem;
}

.cm-report[hidden],
.cm-analyze-progress[hidden],
.cm-preanalysis-preview[hidden],
.cm-compare-result[hidden] {
  display: none !important;
}

.cm-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.cm-verdict-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--cm-accent-soft);
  color: var(--cm-accent);
}

.cm-verdict-badge.marketing { background: #fef3c7; color: #92400e; }
.cm-verdict-badge.powerful { background: #d1fae5; color: #065f46; }
.cm-verdict-badge.balanced { background: #e0e7ff; color: #3730a3; }

.cm-power-score {
  font-weight: 700;
  font-size: 0.95rem;
}

.cm-effect {
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.cm-summary {
  color: var(--cm-muted);
  line-height: 1.5;
  margin: 0 0 1rem;
}

.cm-scale-row {
  margin-bottom: 0.55rem;
}

.cm-scale-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
}

.cm-scale-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(163, 177, 198, 0.35);
  overflow: hidden;
}

.cm-scale-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, #0f766e);
  transition: width 0.5s ease;
}

.cm-compare-bars .cm-scale-row--dual .cm-scale-track {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: transparent;
}

.cm-scale-half {
  height: 8px;
  border-radius: 999px;
  background: rgba(163, 177, 198, 0.35);
  overflow: hidden;
}

.cm-scale-half.left .cm-scale-fill { background: linear-gradient(90deg, #64748b, #475569); }
.cm-scale-half.right .cm-scale-fill { background: linear-gradient(90deg, #14b8a6, #0f766e); }

.cm-compare-headline {
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.cm-compare-tip {
  font-size: 0.9rem;
  color: var(--cm-muted);
  margin-top: 0.75rem;
}

.cm-winner-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cm-winner-tag.left { color: #475569; }
.cm-winner-tag.right { color: var(--cm-accent); }

/* Chat */
.cm-chat {
  margin-top: 1.25rem;
}

.cm-chat-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.cm-chat-hint {
  font-size: 0.85rem;
  color: var(--cm-muted);
  margin: 0 0 0.75rem;
}

.cm-chat-log {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cm-chat-msg {
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 92%;
}

.cm-chat-msg.user {
  align-self: flex-end;
  background: #ccfbf1;
}

.cm-chat-msg.bot {
  align-self: flex-start;
  background: #f1f5f9;
}

.cm-chat-input-row {
  display: flex;
  gap: 0.5rem;
}

.cm-chat-input-row .cm-chat-input {
  flex: 1;
}

.cm-disclaimer {
  font-size: 0.75rem;
  color: var(--cm-muted);
  margin-top: 1rem;
}

/* Loader — adapted from cosmo-pravda-home */
.cm-analyze-progress {
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.cm-loader-track {
  position: relative;
  width: 100%;
  height: 58px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.08) 0%, rgba(232, 236, 241, 0.5) 100%);
}

.cm-loader-track::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(163, 177, 198, 0.35);
}

.cm-loader-obstacle {
  position: absolute;
  bottom: 3px;
  z-index: 1;
  transform: translateX(-50%);
}

.cm-obstacle-tubes {
  width: 34px;
  height: 22px;
  background: linear-gradient(180deg, #cbd5e1, #94a3b8);
  border-radius: 2px;
  box-shadow: 0 2px 0 #64748b;
}

.cm-obstacle-kettle {
  width: 30px;
  height: 16px;
  border-radius: 0 0 14px 14px;
  background: linear-gradient(180deg, #94a3b8, #475569);
}

.cm-obstacle-pipe {
  width: 44px;
  height: 10px;
  bottom: 26px;
  border-radius: 8px;
  background: linear-gradient(180deg, #94a3b8, #64748b);
}

.cm-obstacle-flask {
  width: 18px;
  height: 20px;
}

.cm-obstacle-flask::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 14px;
  height: 12px;
  margin-left: -7px;
  background: linear-gradient(180deg, rgba(167, 243, 208, 0.7), rgba(16, 185, 129, 0.45));
  border: 1px solid #6ee7b7;
  border-radius: 0 0 8px 8px;
}

.cm-fallen-paper {
  position: absolute;
  bottom: 4px;
  width: 9px;
  height: 11px;
  background: #fff;
  border: 1px solid #cbd5e1;
  transform: translateX(-50%) rotate(-12deg);
  opacity: 0;
}

.cm-fp-1 { animation: cm-paper-drop 5.8s linear infinite; }
.cm-fp-2 { animation: cm-paper-drop 5.8s linear infinite; animation-delay: -1.15s; }
.cm-fp-3 { animation: cm-paper-drop 5.8s linear infinite; animation-delay: -2.35s; }
.cm-fp-4 { animation: cm-paper-drop 5.8s linear infinite; animation-delay: -3.45s; }
.cm-fp-5 { animation: cm-paper-drop 5.8s linear infinite; animation-delay: -4.55s; }

@keyframes cm-paper-drop {
  0%, 12% { opacity: 0; transform: translateX(-50%) translateY(-20px) rotate(-25deg); }
  14%, 88% { opacity: 0.9; transform: translateX(-50%) translateY(0) rotate(-12deg); }
  90%, 100% { opacity: 0; }
}

.cm-loader-tech {
  position: absolute;
  bottom: 5px;
  left: 0;
  width: 22px;
  height: 34px;
  z-index: 3;
  animation: cm-tech-journey 5.8s linear infinite;
}

.cm-tech-head {
  position: absolute;
  top: 0;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fcd9b6;
}

.cm-tech-coat {
  position: absolute;
  top: 12px;
  left: 1px;
  width: 18px;
  height: 14px;
  border-radius: 4px;
  background: #f8fafc;
}

.cm-tech-leg {
  position: absolute;
  bottom: 0;
  width: 5px;
  height: 9px;
  background: #475569;
  border-radius: 2px;
}

.cm-tech-leg-l { left: 4px; animation: cm-leg-l 0.52s ease-in-out infinite; }
.cm-tech-leg-r { right: 4px; animation: cm-leg-r 0.52s ease-in-out infinite; }

@keyframes cm-leg-l {
  0%, 100% { transform: rotate(28deg); }
  50% { transform: rotate(-22deg); }
}

@keyframes cm-leg-r {
  0%, 100% { transform: rotate(-22deg); }
  50% { transform: rotate(28deg); }
}

@keyframes cm-tech-journey {
  0% { left: 1%; }
  10% { left: 11%; transform: translateY(-14px); }
  13% { left: 14%; transform: translateY(0); }
  24% { left: 26%; transform: translateY(-14px); }
  27% { left: 30%; transform: translateY(0); }
  40% { left: 43%; transform: translateY(8px) scaleY(0.7); }
  44% { left: 47%; transform: translateY(0) scaleY(1); }
  56% { left: 59%; transform: translateY(-14px); }
  59% { left: 63%; transform: translateY(0); }
  74% { left: 77%; transform: translateY(-14px); }
  77% { left: 81%; transform: translateY(0); }
  100% { left: 96%; }
}

@media (max-width: 720px) {
  .cm-compare-grid {
    grid-template-columns: 1fr;
  }
  .cm-vs-badge {
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cm-loader-tech,
  .cm-fp-1, .cm-fp-2, .cm-fp-3, .cm-fp-4, .cm-fp-5 {
    animation: none;
  }
  .cm-loader-tech {
    left: 50%;
    transform: translateX(-50%);
  }
}
