/* ═══════════════════════════════════════════════════════════════
   PF Manager · Bento Grid + 3D Tilt v4.2 "Spatial"
   ───────────────────────────────────────────────────────────────
   Apple 웹사이트 감각의 비대칭 그리드 + 3D 카드 인터랙션
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   1. Bento Grid Container
   ═══════════════════════════════════════════════════════════════ */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  perspective: 1200px;
}

/* 모바일 */
@media (max-width: 768px) {
  .bento-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* 태블릿 */
@media (min-width: 769px) and (max-width: 1200px) {
  .bento-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════════
   2. Bento Tile · 기본
   ═══════════════════════════════════════════════════════════════ */
.bento-tile {
  position: relative;
  border-radius: 20px;
  padding: 20px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  will-change: transform;

  /* 글래스 기본 */
  background: var(--glass-bg, rgba(255,255,255,0.62));
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.5));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.8),
    0 4px 12px rgba(15, 23, 42, 0.06),
    0 1px 2px rgba(15, 23, 42, 0.04);
}

.bento-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(135deg,
    rgba(255,255,255,0.55) 0%,
    rgba(255,255,255,0.12) 50%,
    rgba(255,255,255,0.28) 100%);
  pointer-events: none;
  z-index: 2;
}

/* 마우스 따라 움직이는 하이라이트 스팟 (3D tilt) */
.bento-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    400px circle at var(--tilt-x, 50%) var(--tilt-y, 50%),
    rgba(255, 255, 255, 0.18),
    transparent 40%
  );
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
}

.bento-tile:hover::after {
  opacity: 1;
}

.bento-tile > * {
  position: relative;
  z-index: 2;
}

/* ═══════════════════════════════════════════════════════════════
   3. Bento 타일 크기 (12-column grid 기반)
   ═══════════════════════════════════════════════════════════════ */
/* 기본 (모바일/태블릿) */
.bento-tile { grid-column: span 2; }

@media (min-width: 769px) {
  /* Desktop: 12 column grid */
  .bento-sm   { grid-column: span 3; }  /* 1/4 */
  .bento-md   { grid-column: span 4; }  /* 1/3 */
  .bento-lg   { grid-column: span 6; }  /* 1/2 */
  .bento-xl   { grid-column: span 8; }  /* 2/3 */
  .bento-full { grid-column: span 12; } /* 전체 */

  .bento-tall { grid-row: span 2; min-height: 300px; }
  .bento-hero { grid-column: span 8; grid-row: span 2; min-height: 300px; }
  .bento-side { grid-column: span 4; }
}

@media (min-width: 769px) and (max-width: 1200px) {
  /* 태블릿: 6 column */
  .bento-sm   { grid-column: span 2; }
  .bento-md   { grid-column: span 3; }
  .bento-lg   { grid-column: span 3; }
  .bento-xl   { grid-column: span 6; }
  .bento-full { grid-column: span 6; }
  .bento-hero { grid-column: span 6; grid-row: span 2; }
}

/* ═══════════════════════════════════════════════════════════════
   4. Bento Tile 변형 · 색상 톤
   ═══════════════════════════════════════════════════════════════ */
.bento-tile.tone-brand {
  background:
    linear-gradient(135deg,
      rgba(15, 118, 110, 0.85) 0%,
      rgba(13, 148, 136, 0.8) 50%,
      rgba(11, 18, 32, 0.85) 100%);
  color: #ffffff;
  border-color: rgba(94, 234, 212, 0.25);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 12px 36px rgba(15, 118, 110, 0.3),
    0 4px 10px rgba(0,0,0,0.1);
}

.bento-tile.tone-brand::before {
  background: linear-gradient(135deg,
    rgba(255,255,255,0.3) 0%,
    rgba(94,234,212,0.1) 50%,
    rgba(255,255,255,0.15) 100%);
}

.bento-tile.tone-indigo {
  background:
    linear-gradient(135deg,
      rgba(79, 70, 229, 0.75) 0%,
      rgba(99, 102, 241, 0.7) 50%,
      rgba(30, 27, 75, 0.85) 100%);
  color: #ffffff;
  border-color: rgba(165, 180, 252, 0.25);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 12px 36px rgba(79, 70, 229, 0.25),
    0 4px 10px rgba(0,0,0,0.1);
}

.bento-tile.tone-rose {
  background:
    linear-gradient(135deg,
      rgba(225, 29, 72, 0.78) 0%,
      rgba(236, 72, 153, 0.72) 50%,
      rgba(76, 5, 25, 0.85) 100%);
  color: #ffffff;
  border-color: rgba(251, 207, 232, 0.25);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 12px 36px rgba(225, 29, 72, 0.25),
    0 4px 10px rgba(0,0,0,0.1);
}

.bento-tile.tone-amber {
  background:
    linear-gradient(135deg,
      rgba(217, 119, 6, 0.8) 0%,
      rgba(245, 158, 11, 0.72) 50%,
      rgba(120, 53, 15, 0.85) 100%);
  color: #ffffff;
  border-color: rgba(253, 230, 138, 0.3);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 12px 36px rgba(217, 119, 6, 0.28),
    0 4px 10px rgba(0,0,0,0.1);
}

.bento-tile.tone-sky {
  background:
    linear-gradient(135deg,
      rgba(2, 132, 199, 0.78) 0%,
      rgba(14, 165, 233, 0.72) 50%,
      rgba(12, 74, 110, 0.85) 100%);
  color: #ffffff;
  border-color: rgba(186, 230, 253, 0.25);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 12px 36px rgba(14, 165, 233, 0.25),
    0 4px 10px rgba(0,0,0,0.1);
}

.bento-tile.tone-emerald {
  background:
    linear-gradient(135deg,
      rgba(5, 150, 105, 0.78) 0%,
      rgba(16, 185, 129, 0.72) 50%,
      rgba(6, 78, 59, 0.85) 100%);
  color: #ffffff;
  border-color: rgba(167, 243, 208, 0.25);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 12px 36px rgba(5, 150, 105, 0.25),
    0 4px 10px rgba(0,0,0,0.1);
}

/* ═══════════════════════════════════════════════════════════════
   5. Bento Tile 내부 요소
   ═══════════════════════════════════════════════════════════════ */
.bento-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.75;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bento-tile.tone-brand .bento-label,
.bento-tile.tone-indigo .bento-label,
.bento-tile.tone-rose .bento-label,
.bento-tile.tone-amber .bento-label,
.bento-tile.tone-sky .bento-label,
.bento-tile.tone-emerald .bento-label {
  color: rgba(255,255,255,0.85);
}

.bento-value {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
  color: var(--text-strong, #0b1220);
}

.bento-hero .bento-value { font-size: 64px; }
.bento-sm .bento-value { font-size: 32px; }

.bento-tile.tone-brand .bento-value,
.bento-tile.tone-indigo .bento-value,
.bento-tile.tone-rose .bento-value,
.bento-tile.tone-amber .bento-value,
.bento-tile.tone-sky .bento-value,
.bento-tile.tone-emerald .bento-value {
  background: linear-gradient(135deg, #ffffff 0%, rgba(255,255,255,0.75) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.bento-caption {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted, #64748b);
  opacity: 0.9;
}

.bento-tile.tone-brand .bento-caption,
.bento-tile.tone-indigo .bento-caption,
.bento-tile.tone-rose .bento-caption,
.bento-tile.tone-amber .bento-caption,
.bento-tile.tone-sky .bento-caption,
.bento-tile.tone-emerald .bento-caption {
  color: rgba(255,255,255,0.82);
}

.bento-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}

.bento-tile.tone-brand .bento-icon,
.bento-tile.tone-indigo .bento-icon,
.bento-tile.tone-rose .bento-icon,
.bento-tile.tone-amber .bento-icon,
.bento-tile.tone-sky .bento-icon,
.bento-tile.tone-emerald .bento-icon {
  background: rgba(255,255,255,0.18);
}

/* 기본(흰색 계열) 타일의 아이콘 */
.bento-tile:not([class*="tone-"]) .bento-icon {
  background: var(--brand-50, #f0fdfa);
  color: var(--brand-700, #0f766e);
}

/* 델타 표시 (변화율) */
.bento-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  margin-top: 8px;
  width: fit-content;
}

.bento-delta.up { color: #10b981; background: rgba(16, 185, 129, 0.15); }
.bento-delta.down { color: #ef4444; background: rgba(239, 68, 68, 0.15); }

.bento-tile.tone-brand .bento-delta,
.bento-tile.tone-indigo .bento-delta,
.bento-tile.tone-rose .bento-delta,
.bento-tile.tone-amber .bento-delta,
.bento-tile.tone-sky .bento-delta,
.bento-tile.tone-emerald .bento-delta {
  background: rgba(255,255,255,0.22);
  color: #ffffff;
}

/* 플로팅 오브 (Bento-hero 내부 장식) */
.bento-tile .bento-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.6;
  pointer-events: none;
  animation: bentoOrb 8s ease-in-out infinite alternate;
  z-index: 0;
}

@keyframes bentoOrb {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(15px, -10px) scale(1.1); }
}

/* ═══════════════════════════════════════════════════════════════
   6. 3D Tilt 인터랙션 (JS가 --tilt-rx, --tilt-ry, --tilt-x, --tilt-y 설정)
   ═══════════════════════════════════════════════════════════════ */
.bento-tile.tilt-enabled {
  transform:
    perspective(1000px)
    rotateX(var(--tilt-rx, 0deg))
    rotateY(var(--tilt-ry, 0deg))
    translateZ(0);
}

.bento-tile.tilt-enabled:hover {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.8),
    0 24px 48px rgba(15, 23, 42, 0.18),
    0 8px 16px rgba(15, 23, 42, 0.1);
}

.bento-tile.tilt-enabled.tone-brand:hover,
.bento-tile.tilt-enabled.tone-indigo:hover,
.bento-tile.tilt-enabled.tone-rose:hover,
.bento-tile.tilt-enabled.tone-amber:hover,
.bento-tile.tilt-enabled.tone-sky:hover,
.bento-tile.tilt-enabled.tone-emerald:hover {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.22),
    0 24px 60px rgba(15, 23, 42, 0.35),
    0 8px 16px rgba(0,0,0,0.15);
}

/* 모션 감소 사용자: 3D 효과 억제 */
@media (prefers-reduced-motion: reduce) {
  .bento-tile.tilt-enabled {
    transform: none !important;
    transition: box-shadow 0.2s ease !important;
  }
  .bento-tile .bento-orb { animation: none !important; }
}

/* 터치 디바이스: 3D 틸트 비활성 (호버가 없어서 어색함) */
@media (hover: none) {
  .bento-tile.tilt-enabled {
    transform: none !important;
  }
  .bento-tile:hover::after { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   7. Number Flow 카운트업 애니메이션
   ═══════════════════════════════════════════════════════════════ */
.num-flow {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* 카운트 중인 상태 (글자가 위로 슥 올라오는 느낌) */
.num-flow.animating {
  animation: numPulse 0.3s ease;
}

@keyframes numPulse {
  0% { transform: translateY(4px); opacity: 0.7; }
  100% { transform: translateY(0); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   8. Bento 다크모드
   ═══════════════════════════════════════════════════════════════ */
[data-theme="dark"] .bento-tile:not([class*="tone-"]) {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .bento-tile:not([class*="tone-"]) .bento-value {
  color: var(--text-strong, #f8fafc);
}

[data-theme="dark"] .bento-tile:not([class*="tone-"]) .bento-icon {
  background: rgba(20, 184, 166, 0.15);
  color: var(--brand-400, #2dd4bf);
}

[data-theme="dark"] .bento-tile::before {
  background: linear-gradient(135deg,
    rgba(255,255,255,0.12) 0%,
    rgba(255,255,255,0.02) 50%,
    rgba(255,255,255,0.08) 100%);
}

/* ═══════════════════════════════════════════════════════════════
   9. Bento CTA (타일 하단 액션 버튼)
   ═══════════════════════════════════════════════════════════════ */
.bento-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(10px);
  color: inherit;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  width: fit-content;
}

.bento-cta:hover {
  background: rgba(255,255,255,0.28);
  transform: translateX(3px);
}

.bento-tile:not([class*="tone-"]) .bento-cta {
  background: rgba(20, 184, 166, 0.1);
  color: var(--brand-700, #0f766e);
  border-color: rgba(20, 184, 166, 0.2);
}

.bento-tile:not([class*="tone-"]) .bento-cta:hover {
  background: rgba(20, 184, 166, 0.18);
}

/* ═══════════════════════════════════════════════════════════════
   10. Bento Hero 타일 (가장 큰 타일 - 숨은 매출 등)
   ═══════════════════════════════════════════════════════════════ */
.bento-hero .bento-orb-1 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.5), transparent 70%);
  top: -100px;
  right: -80px;
  animation-duration: 10s;
}

.bento-hero .bento-orb-2 {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.45), transparent 70%);
  bottom: -60px;
  left: -40px;
  animation-duration: 12s;
  animation-delay: 1s;
}

/* ═══════════════════════════════════════════════════════════════
   End · Bento + Tilt + NumberFlow
   ═══════════════════════════════════════════════════════════════ */
