/* ══════════════════════════════════════════════════════════════
   editor-glass.css — Liquid Glass 편집기 4-tier 컴포넌트 스타일
   tokens.css 디자인 토큰만 사용. TASK-0007 전용.
   ══════════════════════════════════════════════════════════════ */

/* ─── TKT-0076: Glass 변수 중앙 관리 ───
   편집기 전용 Glass 토큰. 이 블록 1곳만 변경하면 전체 편집기 테마 일괄 전환. */
.lg-editor-shell {
  --editor-glass-blur: var(--glass-blur-sm);
  --editor-glass-blur-panel: var(--glass-blur-md);
  --editor-glass-blur-dialog: var(--glass-blur-lg);
  --editor-glass-blur-overlay: var(--glass-blur-xs);
  --editor-glass-bg: var(--glass-dark);
  --editor-glass-bg-toolbar: var(--glass-dark-dense);
  --editor-glass-bg-panel: var(--glass-dark-deep);
  --editor-glass-border: var(--border-subtle);
  --editor-glass-shadow: 0 8px 32px rgba(0,0,0,0.3);
  --editor-glass-shadow-heavy: 0 24px 80px rgba(0,0,0,0.4);
  --editor-glass-radius: var(--radius-l);
}

/* ─── 유틸리티 ─── */
.lg-hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   Atoms
   ═══════════════════════════════════════════════════════════ */

/* ─── 아이콘 ─── */
.lg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
  pointer-events: none;
}
.lg-icon svg { width: 100%; height: 100%; }
.lg-icon--xs  { width: 14px; height: 14px; }
.lg-icon--sm  { width: 16px; height: 16px; }
.lg-icon--md  { width: 20px; height: 20px; }
.lg-icon--lg  { width: 24px; height: 24px; }
.lg-icon--missing {
  width: 16px; height: 16px;
  background: var(--surface-w8);
  border-radius: var(--radius-s);
}

/* ─── Glass 버튼 ─── */
.lg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-2);
  min-width: 32px;
  min-height: 32px;
  background: var(--surface-w5);
  border: none;
  border-radius: var(--radius-s);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: background 150ms, color 150ms;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.lg-btn:hover { background: var(--surface-w10); }
.lg-btn:active { background: var(--surface-w15); }
.lg-btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* 상태: is-active (JS에서 classList.add('is-active') 사용) */
.lg-btn.is-active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* 변형: ghost */
.lg-btn--ghost { background: transparent; }
.lg-btn--ghost:hover { background: var(--surface-w8); }

/* 변형: primary */
.lg-btn--primary {
  background: var(--accent);
  color: var(--bg);
}
.lg-btn--primary:hover { background: var(--accent-deep); }

/* 변형: accent (다이얼로그용) */
.lg-btn--accent {
  background: var(--accent);
  color: var(--bg);
}
.lg-btn--accent:hover { background: var(--accent-deep); }

/* 변형: danger */
.lg-btn--danger { color: var(--status-error); }
.lg-btn--danger:hover { background: rgba(239,68,68,0.12); }

.lg-btn__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── 슬라이더 ─── */
.lg-slider {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.lg-slider__label {
  font-size: var(--fs-sm);
  color: var(--text-sub);
  min-width: 72px;
}
.lg-slider__input {
  flex: 1;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-w10);
  border-radius: var(--radius-pill);
  outline: none;
  cursor: pointer;
}
.lg-slider__input::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.lg-slider__input::-moz-range-thumb {
  width: 14px; height: 14px;
  border: none; border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.lg-slider__value {
  min-width: 28px;
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  color: var(--text-sub);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ─── 색상 스워치 ─── */
.lg-swatch {
  width: 24px; height: 24px;
  border-radius: var(--radius-s);
  background: var(--swatch-color, #888);
  border: none;
  cursor: pointer;
  transition: transform 100ms, box-shadow 100ms;
  flex-shrink: 0;
}
.lg-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.lg-swatch.is-overridden {
  box-shadow: 0 0 0 2px var(--accent);
}

/* ─── 줌 디스플레이 ─── */
.lg-zoom-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: var(--s-1);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-sub);
  background: transparent;
  border: none;
  border-radius: var(--radius-s);
  cursor: pointer;
}
.lg-zoom-display:hover {
  background: var(--surface-w5);
  color: var(--text);
}

/* ─── 페이지 도트 ─── */
.lg-page-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--surface-w15);
  border: none; padding: 0;
  cursor: pointer;
  transition: background 150ms, transform 150ms;
}
.lg-page-dot:hover {
  background: var(--surface-w20);
  transform: scale(1.3);
}
.lg-page-dot.is-active {
  background: var(--accent);
  transform: scale(1.25);
}

/* ─── 상태 인디케이터 ─── */
.lg-status {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lg-status--idle    { background: var(--text-faint); }
.lg-status--editing { background: var(--accent); }
.lg-status--dirty   { background: var(--status-warning); }
.lg-status--saved   { background: var(--status-success); }

/* ─── Glass 토글 ─── */
.lg-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-sub);
  font: inherit;
}
.lg-toggle__track {
  position: relative;
  width: 36px; height: 20px;
  border-radius: var(--radius-pill);
  background: var(--surface-w10);
  transition: background 200ms;
}
.lg-toggle.is-active .lg-toggle__track {
  background: var(--accent);
}
.lg-toggle__thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 200ms;
}
.lg-toggle.is-active .lg-toggle__thumb {
  transform: translateX(16px);
}
.lg-toggle__label {
  font-size: var(--text-sm);
  white-space: nowrap;
}

/* ─── 색상 입력 (atom) ─── */
.lg-color-input-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.lg-color-input-wrap__label {
  font-size: var(--fs-sm);
  color: var(--text-sub);
}
.lg-color-input-wrap__inner {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.lg-color-input {
  width: 32px; height: 32px;
  border: none;
  border-radius: var(--radius-s);
  padding: 0;
  cursor: pointer;
  background: transparent;
}
.lg-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.lg-color-input::-webkit-color-swatch { border: none; border-radius: var(--radius-s); }
.lg-color-input-wrap__hex {
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  color: var(--text-sub);
}

/* ═══════════════════════════════════════════════════════════
   Molecules
   ═══════════════════════════════════════════════════════════ */

/* ─── ToolbarGroup ─── */
.lg-toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: var(--s-0);
  background: var(--surface-w3);
  border-radius: var(--radius-s);
  padding: var(--s-0);
  flex-wrap: wrap;
}

/* ─── ZoomControls ─── */
.lg-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

/* ─── HScrollNav ─── */
.lg-hscroll-nav {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) 0;
}
.lg-hscroll-nav__dots {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

/* ─── RichTextToolbar ─── */
.lg-rich-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1);
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  border-radius: var(--radius-s);
}
.lg-rich-toolbar__sep {
  width: 1px;
  height: 16px;
  background: var(--line-bold);
  margin: 0 var(--s-0);
}

/* ─── ExportMenu ─── */
.lg-export-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.lg-export-menu__list {
  display: none;
  position: absolute;
  top: calc(100% + var(--s-1));
  right: 0;
  z-index: 100;
  min-width: 160px;
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  border-radius: var(--radius-s);
  padding: var(--s-1);
}
.lg-export-menu__list--open {
  display: flex;
  flex-direction: column;
  gap: var(--s-0);
}
.lg-export-menu__item {
  width: 100%;
  justify-content: flex-start;
  border-radius: var(--radius-s);
  padding: var(--s-2) var(--s-3);
}
.lg-export-menu__item:hover {
  background: var(--surface-w8);
}

/* ─── SegmentedControl ─── */
.lg-segmented {
  display: inline-flex;
  position: relative;
  background: var(--surface-w5);
  border-radius: var(--radius-s);
  padding: 2px;
}
.lg-segmented__indicator {
  position: absolute;
  top: 2px; bottom: 2px;
  left: var(--seg-left, 0%);
  width: var(--seg-width, 50%);
  background: var(--glass-dark-dense);
  border-radius: 6px;
  transition: left 200ms ease, width 200ms ease;
  pointer-events: none;
}
.lg-segmented__btn {
  position: relative;
  z-index: 1;
  padding: var(--s-1) var(--s-3);
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-sub);
  font-family: var(--font);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: color 150ms;
  white-space: nowrap;
}
.lg-segmented__btn:hover { color: var(--text); }
.lg-segmented__btn--active { color: var(--text); }

/* ─── ColorPicker (molecule) ─── */
.lg-color-picker {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.lg-color-picker__label {
  font-size: var(--fs-sm);
  color: var(--text-sub);
}
.lg-color-picker__preview {
  position: relative;
  width: 28px; height: 28px;
  border-radius: var(--radius-s);
  background: var(--picker-color, #fff);
  overflow: hidden;
  cursor: pointer;
  transition: transform 150ms;
}
.lg-color-picker__preview:hover { transform: scale(1.1); }
.lg-color-picker__input {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}
.lg-color-picker__hex {
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  color: var(--text-sub);
  min-width: 56px;
}

/* ─── FontSizeDropdown ─── */
.lg-fontsize-dropdown { position: relative; }
.lg-fontsize-dropdown__trigger { min-width: 64px; }
.lg-fontsize-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + var(--s-1));
  left: 0;
  z-index: 100;
  min-width: 80px;
  max-height: 240px;
  overflow-y: auto;
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  border-radius: var(--radius-s);
  padding: var(--s-1);
}
.lg-fontsize-dropdown__menu--open {
  display: flex;
  flex-direction: column;
  gap: var(--s-0);
}
.lg-fontsize-dropdown__item {
  display: flex;
  align-items: center;
  padding: var(--s-1) var(--s-2);
  font-size: var(--fs-base);
  font-family: var(--font-mono);
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: var(--radius-s);
  cursor: pointer;
  text-align: left;
}
.lg-fontsize-dropdown__item:hover { background: var(--surface-w8); }
.lg-fontsize-dropdown__item--active { color: var(--accent); }

/* ─── TextColorPicker ─── */
.lg-text-color-picker { position: relative; }
.lg-text-color-picker__indicator {
  display: block;
  width: 100%; height: 3px;
  border-radius: var(--radius-pill);
  background: var(--indicator-color, #fff);
  margin-top: var(--s-0);
}
.lg-text-color-picker__panel {
  display: none;
  position: absolute;
  top: calc(100% + var(--s-1));
  right: 0;
  z-index: 100;
  padding: var(--s-3);
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  border-radius: var(--radius-s);
}
.lg-text-color-picker__panel--open {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.lg-text-color-picker__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-1);
}

/* ─── StatusBar (molecule) ─── */
.lg-status-bar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-1) var(--s-3);
  font-size: var(--fs-sm);
  color: var(--text-sub);
}
.lg-status-bar__file {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.lg-status-bar__zoom {
  font-variant-numeric: tabular-nums;
}
.lg-status-bar__dirty {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transition: opacity 200ms;
}
.lg-status-bar__dirty--clean { opacity: 0; }

/* ═══════════════════════════════════════════════════════════
   Compounds
   ═══════════════════════════════════════════════════════════ */

/* ─── EditorToolbar: 상단 도구 모음 ─── */
.lg-editor-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  flex-wrap: wrap;
  min-height: 44px;
  flex-shrink: 0;
}
.lg-editor-toolbar__left,
.lg-editor-toolbar__center,
.lg-editor-toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.lg-editor-toolbar__left { flex-shrink: 0; }
.lg-editor-toolbar__center {
  flex: 1;
  justify-content: center;
}
.lg-editor-toolbar__right {
  flex-shrink: 0;
  margin-left: auto;
}

/* ─── EditorCanvas: 편집 영역 ─── */
.lg-editor-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.lg-editor-canvas__content {
  flex: 1;
  position: relative;
  overflow: auto;
}
.lg-editor-canvas__iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}
.lg-editor-canvas--cardnews .lg-editor-canvas__iframe {
  background: transparent;
}
.lg-editor-canvas__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-sub);
  background: var(--glass-dark-deep);
  backdrop-filter: var(--glass-blur-sm);
  -webkit-backdrop-filter: var(--glass-blur-sm);
  z-index: 5;
}
.lg-editor-canvas__loading.lg-hidden { display: none; }

/* ─── EditorStatusBar (compound) ─── */
.lg-editor-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-1) var(--s-3);
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  font-size: 11px;
  color: var(--text-sub);
  flex-shrink: 0;
}
.lg-editor-statusbar__left,
.lg-editor-statusbar__right {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* ─── SidePanel: 색상/부분편집 공통 ─── */
.lg-side-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: clamp(240px, 25%, 320px);
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 250ms ease;
  z-index: 10;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.lg-side-panel--open {
  transform: translateX(0);
}
.lg-side-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3);
  flex-shrink: 0;
}
.lg-side-panel__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.lg-side-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--s-3) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* ─── ColorPanel 내부 ─── */
.lg-color-panel__original,
.lg-color-panel__override {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.lg-color-panel__section-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.lg-color-panel__swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
}

/* ─── PartialEditPanel 내부 ─── */
.lg-partial-edit__guide {
  font-size: 12px;
  color: var(--text-sub);
  padding: var(--s-2);
  background: var(--surface-w3);
  border-radius: var(--radius-s);
  text-align: center;
}
.lg-partial-edit__textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--s-2);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  background: var(--surface-w5);
  border: none;
  border-radius: var(--radius-s);
  resize: vertical;
}
.lg-partial-edit__textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.lg-partial-edit__actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
}
.lg-partial-edit__status {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2);
  font-size: 12px;
  color: var(--accent);
}

/* ─── 미저장 다이얼로그 ─── */
.lg-dialog-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  backdrop-filter: var(--glass-blur-xs);
  -webkit-backdrop-filter: var(--glass-blur-xs);
  z-index: 10001;
}
.lg-dialog {
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  border-radius: var(--radius-l);
  padding: var(--s-5);
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.lg-dialog__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.lg-dialog__message {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.5;
}
.lg-dialog__actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  margin-top: var(--s-2);
}

/* ═══════════════════════════════════════════════════════════
   Organism — EditorShell
   ═══════════════════════════════════════════════════════════ */

.lg-editor-shell {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  backdrop-filter: var(--glass-blur-xs);
  -webkit-backdrop-filter: var(--glass-blur-xs);
}

.lg-editor-shell__container {
  display: flex;
  flex-direction: column;
  width: 95vw;
  height: 92vh;
  max-width: 1400px;
  /* .glass 또는 .glass--light 클래스와 조합 사용 */
  border-radius: var(--radius-l);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4), 0 0 0 1px var(--line-bold);
}

.lg-editor-shell__body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════
   반응형
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .lg-editor-shell__container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .lg-editor-toolbar {
    padding: var(--s-1) var(--s-2);
    gap: var(--s-1);
  }
  .lg-editor-toolbar__center {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .lg-side-panel {
    width: 100%;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    top: auto;
    height: 50vh;
    transform: translateY(100%);
  }
  .lg-side-panel--open { transform: translateY(0); }

  .lg-editor-canvas { padding: var(--s-2); }

  .lg-dialog {
    width: 95%;
    max-width: none;
  }
}

@media (max-width: 375px) {
  .lg-btn__label { display: none; }

  .lg-editor-toolbar__center {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .lg-fontsize-dropdown__menu {
    left: auto;
    right: 0;
  }
}

/* 스와치 내장 color picker (숨김) */
.lg-swatch__picker {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  border: none;
  padding: 0;
  pointer-events: none;
}
.lg-swatch {
  position: relative;
  overflow: visible;
}

/* 리치 텍스트 글꼴 색상 피커 */
.lg-rich-toolbar__color-wrap {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: var(--s-1);
  border-radius: var(--radius-s);
}
.lg-rich-toolbar__color-wrap:hover {
  background: var(--glass-hover);
}
.lg-rich-toolbar__color-input {
  width: 16px;
  height: 16px;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: var(--radius-s);
}
