/**
 * Sprint S-7: QualityModeSelector — segmented button style.
 *
 * Click target은 옵션 전체 영역 (라벨/아이콘/하위텍스트 어디든 클릭 OK).
 * 작은 라디오 동그라미는 시각적으로 숨기되 접근성은 유지.
 */

/* 컨테이너: 부모 폭 기준 50% 가량 차지하도록 width 100% + max-width 조정 */
.qm-selector {
  display: flex;
  width: 100%;
  gap: 6px;
  padding: 4px;
  background: #f1f3f5;
  border-radius: 10px;
  font-size: 14px;
  user-select: none;
  box-sizing: border-box;
}

.qm-option {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease,
    transform 80ms ease;
  color: #555;
  background: transparent;
  white-space: nowrap;
  position: relative;
  min-height: 44px;
}

.qm-option:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #1f1f1f;
}

.qm-option:active {
  transform: scale(0.98);
}

/* 라디오 input 시각적 숨김 (접근성용으로 DOM은 유지) */
.qm-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

.qm-option .qm-icon {
  font-size: 16px;
  line-height: 1;
}

.qm-option .qm-text {
  font-weight: 500;
  letter-spacing: -0.01em;
}

.qm-option .qm-sub {
  font-size: 12px;
  color: #888;
  font-weight: 400;
}

/* 활성 상태 — 흰 배경 + 그림자 + 진한 텍스트 */
.qm-option.qm-active {
  background: #ffffff;
  color: #111;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(0, 0, 0, 0.05);
}

.qm-option.qm-active .qm-text {
  font-weight: 600;
}

.qm-option.qm-active .qm-sub {
  color: #4f46e5;
  font-weight: 500;
}

/* 키보드 포커스 */
.qm-option input[type="radio"]:focus-visible + .qm-icon {
  outline: 2px solid #4f46e5;
  outline-offset: 4px;
  border-radius: 4px;
}

/* Dark theme */
[data-theme="dark"] .qm-selector {
  background: #2b2b30;
}

[data-theme="dark"] .qm-option {
  color: #aaa;
}

[data-theme="dark"] .qm-option:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f0f0f0;
}

[data-theme="dark"] .qm-option .qm-sub {
  color: #888;
}

[data-theme="dark"] .qm-option.qm-active {
  background: #3a3a40;
  color: #fff;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .qm-option.qm-active .qm-sub {
  color: #a5b4fc;
}

/* 좁은 화면: sub 텍스트 감추고 padding 줄임 */
@media (max-width: 520px) {
  .qm-option {
    padding: 10px 8px;
  }
  .qm-option .qm-sub {
    display: none;
  }
}
