/* theme/tokens.css */
/*
 * 규칙: 컴포넌트 CSS 는 색/반경/그림자를 직접 쓰지 않고 반드시 --oui-* 를 통한다.
 * 각 토큰은 호스트 앱의 기존 변수(--theme-main, --border ...)를 먼저 보고,
 * 없으면 기본값으로 떨어진다.
 * 원하면 :root 에서 --oui-* 를 덮어써서 완전히 갈아끼울 수 있다.
 */

:root {
  /* 표면 */
  --oui-surface: var(--white, #ffffff);
  --oui-surface-muted: var(--theme-light, #f4f1ea);
  --oui-surface-border: rgba(255, 255, 255, 0.6);
  --oui-bg: var(--bg, #f4f1ea);

  /* 텍스트 */
  --oui-text: var(--text, #2c2621);
  --oui-muted: var(--muted, #6b6560);

  /* 강조색 */
  --oui-accent: var(--theme-main, #7c3aed);
  --oui-accent-soft: color-mix(in srgb, var(--oui-accent) 10%, transparent);
  --oui-accent-border: color-mix(in srgb, var(--oui-accent) 18%, transparent);
  /* hover 용 — soft/border 보다 진하다 (qr 프로젝트의 아이콘 버튼과 동일한 30% / 50%) */
  --oui-accent-hover: color-mix(in srgb, var(--oui-accent) 30%, transparent);
  --oui-accent-hover-border: color-mix(in srgb, var(--oui-accent) 50%, transparent);

  /* 선 */
  --oui-border: var(--border, #d7ccc8);

  /* 형태 */
  --oui-radius: 16px;
  --oui-radius-lg: 28px;
  --oui-shadow-modal: 0 28px 80px rgba(0, 0, 0, 0.35);

  /* 오버레이 */
  --oui-backdrop: rgba(0, 0, 0, 0.55);
  --oui-z-modal: 9999;

  /* 모션 */
  --oui-transition: 160ms ease;

  /*
   * 호스트 폰트를 그대로 상속하고 싶으면:  :root { --oui-font: inherit; }
   */
  --oui-font: 'Paperlogy', sans-serif;
}

/* color-mix 미지원 브라우저 대비 */
@supports not (color: color-mix(in srgb, red 10%, transparent)) {
  :root {
    --oui-accent-soft: rgba(124, 58, 237, 0.1);
    --oui-accent-border: rgba(124, 58, 237, 0.18);
    --oui-accent-hover: rgba(124, 58, 237, 0.3);
    --oui-accent-hover-border: rgba(124, 58, 237, 0.5);
  }
}

/*
 * 최소 리셋 — 전역 태그 셀렉터는 절대 쓰지 않는다.
 * 호스트 앱의 `* { margin:0 }` 같은 전역 스타일과 충돌하지 않도록
 * .oui- 로 시작하는 요소에만 적용한다.
 */
[class^="oui-"],
[class*=" oui-"] {
  box-sizing: border-box;
  font-family: var(--oui-font);
}


/* core/modal.css */
/* 모달 셸 — 백드롭과 패널 컨테이너만. 내용 스타일은 각 컴포넌트 style.css 에서. */

.oui-modal {
  position: fixed;
  inset: 0;
  z-index: var(--oui-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  background: var(--oui-backdrop);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity var(--oui-transition);
}

.oui-modal[hidden] {
  display: none;
}

.oui-modal.is-open {
  opacity: 1;
}

.oui-modal__panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(880px, 80vw);
  max-height: min(880px, 80vh);
  outline: none;
  transform: translateY(8px) scale(0.98);
  transition: transform var(--oui-transition);
}

.oui-modal.is-open .oui-modal__panel {
  transform: none;
}

/* 카드 = 패널 안에서 반복되는 흰 박스 단위 */
.oui-card {
  padding: 20px;
  background: var(--oui-surface);
  border: 2px solid var(--oui-surface-border);
  border-radius: var(--oui-radius-lg);
  box-shadow: var(--oui-shadow-modal);
}

/* 아이콘 뱃지 */
.oui-badge {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--oui-accent-soft);
  border: 1px solid var(--oui-accent-border);
  border-radius: var(--oui-radius);
  color: var(--oui-accent);
}

/* 아이콘 버튼 */
.oui-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  background: var(--oui-surface);
  border: 2px solid var(--oui-accent);
  border-radius: var(--oui-radius);
  color: var(--oui-text);
  font: inherit;
  cursor: pointer;
  transition: var(--oui-transition);
}

/* qr 프로젝트의 아이콘 버튼과 동일: 배경/테두리/글자색이 모두 강조색으로 물든다. */
.oui-icon-btn:hover {
  background: var(--oui-accent);
  border-color: var(--oui-accent-hover-border);
  color: white;
}

.oui-title {
  color: var(--oui-text);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
}

.oui-subtitle {
  margin-top: 2px;
  color: var(--oui-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

@media (prefers-reduced-motion: reduce) {
  .oui-modal,
  .oui-modal__panel {
    transition: none;
  }
}


/* components/qr-modal */
/* qr-modal — 모든 셀렉터는 .oui-qr 아래로. 전역 태그 셀렉터 금지. */

.oui-qr__select-card {
  flex-shrink: 0;
}

.oui-qr__card {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.oui-qr__head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.oui-qr__head--between {
  justify-content: space-between;
  margin-bottom: 12px;
}

.oui-qr__select-card .oui-qr__head--between {
  margin-bottom: 0;
}

.oui-qr__selected {
  margin-left: auto;
  color: var(--oui-accent);
  text-align: right;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
}

.oui-qr__select {
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--oui-surface);
  border: 2px solid var(--oui-border);
  border-radius: var(--oui-radius);
  color: var(--oui-text);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  outline: none;
}

/* 선택 카드 아래 관리 링크 */
.oui-qr__manage {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-top: 10px;
  color: var(--oui-accent);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

/* href 가 없어도 링크처럼 보이고 눌리게 한다. */
.oui-qr__manage--plain {
  cursor: pointer;
}

.oui-qr__manage:hover .oui-qr__manage-text {
  text-decoration: underline;
}

.oui-qr__manage-icon {
  display: inline-flex;
  line-height: 0;
}

.oui-qr__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.oui-qr__frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(62vmin, 560px);
  height: min(62vmin, 560px);
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--oui-bg);
  border: 2px solid var(--oui-border);
  border-radius: 20px;
}

.oui-qr__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.oui-qr__canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  line-height: 0;
}

/* qrcodejs 는 canvas 와 img 를 동시에 넣는다. 둘 다 프레임에 맞춘다. */
.oui-qr__canvas img,
.oui-qr__canvas canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
}

.oui-qr__img {
  object-fit: contain;
  image-rendering: pixelated;
}

.oui-qr__url {
  display: block;
  width: 100%;
  color: var(--oui-muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  word-break: break-all;
}

.oui-qr__hint {
  color: var(--oui-muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.oui-qr__hint[hidden],
.oui-qr__selected[hidden],
.oui-qr__manage[hidden],
.oui-qr__select-card[hidden] {
  display: none;
}

.is-disabled {
  pointer-events: none;
}
