/**
 * 플로팅 FAB — CHILD 전용
 * 경로: /child/inc/floating-fab.css
 *
 * 메인 버튼: 우측 하단 고정. 드래그로 이동 가능 (JS).
 * 메뉴: FAB 위쪽으로 펼침. 4 위젯 행.
 */

.fab-launcher {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: var(--t-z-widget);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  /* 초기엔 숨김 → JS init 완료 후 .is-ready 부여 시 표시 (FOUC 방지) */
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.fab-launcher.is-ready {
  visibility: visible;
  opacity: 1;
}

/* ── 메인 FAB 버튼 ── */
.fab-main {
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--t-clay-500), var(--t-clay-600));
  color: var(--t-paper);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.fab-main:hover {
  transform: scale(1.04);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.18);
}
.fab-main:active { transform: scale(0.98); }
.fab-main .material-symbols-outlined {
  font-size: 1.625rem;
  font-variation-settings: 'FILL' 0, 'wght' 500;
}

/* 메뉴 열림 시 메인 FAB 회전 */
.fab-launcher[data-state="open"] .fab-main {
  transform: rotate(45deg);
}
.fab-launcher[data-state="open"] .fab-icon--open { display: none; }
.fab-launcher[data-state="open"] .fab-icon--close { display: inline-flex; }

/* ── 메뉴 컨테이너 ── */
.fab-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}
.fab-menu[hidden] { display: none; }

.fab-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fab-row-in 180ms ease both;
}
@keyframes fab-row-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 라벨 칩 ── */
.fab-label {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--t-line);
  border-radius: 0.5rem;
  background: var(--t-paper);
  color: var(--t-ink);
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.fab-label:hover {
  background: var(--t-bg);
  transform: translateY(-1px);
}

/* ── 위젯 아이콘 버튼 (색상별 modifier) ── */
.fab-icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 9999px;
  color: var(--t-paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fab-icon-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}
.fab-icon-btn .material-symbols-outlined {
  font-size: 1.25rem;
  font-variation-settings: 'FILL' 0, 'wght' 500;
}

/* 색상 modifier — 사이트 표준 팔레트 (clay / sage / mustard / ink) */
.fab-icon-btn--clay    { background: var(--t-clay-500);    }   /* 타이머 */
.fab-icon-btn--mustard { background: var(--t-mustard-500); color: var(--t-ink); }   /* AI */
.fab-icon-btn--sage    { background: var(--t-sage-500);    }   /* 사전 / 필기 */
.fab-icon-btn--ink     { background: var(--t-ink);         }   /* 기타 */

/* ──────────────────────────────────────────────────────
   타이머 모드 — pill (원형 FAB 대체)
   ────────────────────────────────────────────────────── */
.fab-pill {
  position: relative;
  user-select: none;
}

.fab-pill__sch-tag {
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.0625rem 0.625rem;
  background: var(--t-mustard-600);
  color: var(--t-paper);
  font-size: 11px;
  font-weight: 600;
  border-radius: 9999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  z-index: 1;
}
.fab-pill__sch-emoji { font-size: 10px; }

.fab-pill__body {
  display: flex;
  align-items: center;
  padding: 5px 5px 5px 14px;
  background: var(--t-ink);
  color: var(--t-paper);
  border-radius: 9999px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.fab-pill__play {
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: var(--t-paper);
  cursor: pointer;
  transition: background 0.15s;
}
.fab-pill__play:hover { background: rgba(255, 255, 255, 0.25); }
.fab-pill__play .material-symbols-outlined { font-size: 18px; }

.fab-pill__time {
  font-size: var(--t-fs-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0.375rem;
  flex-shrink: 0;
  cursor: pointer;
}

.fab-pill__hide {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.fab-pill__hide:hover { color: var(--t-paper); background: rgba(255, 255, 255, 0.1); }
.fab-pill__hide .material-symbols-outlined { font-size: 14px; }

.fab-pill__fab {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--t-clay-500), var(--t-clay-600));
  color: var(--t-paper);
  cursor: pointer;
  margin-left: 0.375rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.fab-pill__fab:hover { transform: scale(1.05); }
.fab-pill__fab .material-symbols-outlined { font-size: 1.125rem; }

/* pill 모드일 때 메인 FAB 숨김 */
.fab-launcher[data-mode="timer"] .fab-main { display: none; }
.fab-launcher[data-mode="timer"] .fab-pill { display: block; }

/* 타이머 패널 열림 상태 (pill 의 FAB 아이콘도 ×로 변경) */
.fab-launcher[data-state="open"] .fab-pill__fab .fab-icon--open,
.fab-launcher[data-state="open"] .fab-main .fab-icon--open { display: none; }
.fab-launcher[data-state="open"] .fab-pill__fab .fab-icon--close,
.fab-launcher[data-state="open"] .fab-main .fab-icon--close { display: inline-flex; }

/* ──────────────────────────────────────────────────────
   타이머 확장 패널 (pill 의 시간 클릭 시 FAB 위로 펼침)
   ────────────────────────────────────────────────────── */
.fab-timer-panel {
  position: fixed;
  bottom: 6.5rem;
  right: 1.5rem;
  width: 15rem;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--t-ink) 95%, #000);
  color: var(--t-paper);
  border-radius: 1rem;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  z-index: var(--t-z-widget);
}
.fab-timer-panel[hidden] { display: none; }

.fab-timer-panel__close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.125rem;
  line-height: 1;
  padding: 0.125rem 0.375rem;
  cursor: pointer;
  transition: color 0.15s;
}
.fab-timer-panel__close:hover { color: var(--t-paper); }

.fab-timer-panel__circle {
  position: relative;
  width: 9rem;
  height: 9rem;
  margin: 0.25rem auto;
}
.fab-timer-panel__circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.fab-timer-panel__track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
}
.fab-timer-panel__progress {
  fill: none;
  stroke: var(--t-clay-500);
  transition: stroke-dashoffset 0.5s ease;
}
.fab-timer-panel__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.fab-timer-panel__time {
  font-size: 1.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.fab-timer-panel__phase {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.125rem;
}
.fab-timer-panel__sch-title {
  font-size: 10px;
  color: var(--t-mustard-300);
  margin-top: 0.125rem;
  max-width: 8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fab-timer-panel__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.fab-timer-panel__ctrl,
.fab-timer-panel__play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  font-size: 1.125rem;
}
.fab-timer-panel__ctrl {
  width: 2.25rem;
  height: 2.25rem;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.75);
}
.fab-timer-panel__ctrl:hover { color: var(--t-paper); background: rgba(255, 255, 255, 0.2); }
.fab-timer-panel__play {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--t-clay-500);
  color: var(--t-paper);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.fab-timer-panel__play:hover { transform: scale(1.05); }

.fab-timer-panel__next {
  margin-top: 0.625rem;
  text-align: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
}

.fab-timer-panel__settings {
  display: block;
  margin-top: 0.75rem;
  text-align: center;
  font-size: var(--t-fs-xs);
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  transition: color 0.15s;
}
.fab-timer-panel__settings:hover { color: var(--t-paper); }

/* ── 드래그 중 — hover/transition 모두 차단 (부드러운 이동) ── */
.fab-launcher.is-dragging,
.fab-launcher.is-dragging * {
  transition: none !important;
  animation: none !important;
}
.fab-launcher.is-dragging { cursor: grabbing; }
.fab-launcher.is-dragging .fab-main,
.fab-launcher.is-dragging .fab-pill { cursor: grabbing; }
.fab-launcher.is-dragging .fab-main:hover,
.fab-launcher.is-dragging .fab-pill__fab:hover {
  transform: none;
}

/* ── 모바일 ── */
@media (max-width: 640px) {
  .fab-launcher { right: 1rem; bottom: 1rem; }
  .fab-main { width: 3rem; height: 3rem; }
  .fab-main .material-symbols-outlined { font-size: 1.5rem; }
  .fab-label { font-size: 0.8125rem; padding: 0.25rem 0.625rem; }
  .fab-timer-panel { right: 1rem; bottom: 5rem; width: 14rem; }
}
