/* =====================================================
   common.css — 포키보드하우스 공통 스타일 (v3.0 · Liquid Glass)
   iOS 26 Liquid Glass 에서 영감을 받은 재질(material) 시스템.
   - Translucent surfaces (backdrop-filter: blur + saturate)
   - Specular highlight (inset top edge)
   - Layered materials (blob gradient BG → glass → content)
   - Dynamic pressure response (buttons scale on press)
   ===================================================== */

:root {
  /* ── Brand ── */
  --pbh-primary:        #2F6F4E;
  --pbh-primary-dark:   #215038;
  --pbh-primary-light:  #DFF1E7;
  --pbh-accent:         #D9822B;

  /* ── Semantic ── */
  --pbh-bg:             #F2F6F2;
  --pbh-text:           #0F1513;
  --pbh-text-sub:       #4B5A54;
  --pbh-text-muted:     #7E8B85;
  --pbh-danger:         #D0311C;
  --pbh-success:        #1E9C59;
  --pbh-warn:           #DD8017;

  /* ── Liquid Glass Tokens ── */
  --glass-bg:            rgba(255, 255, 255, 0.58);
  --glass-bg-strong:     rgba(255, 255, 255, 0.72);
  --glass-bg-soft:       rgba(255, 255, 255, 0.38);
  --glass-tint:          rgba(240, 248, 244, 0.55);
  --glass-border:        rgba(255, 255, 255, 0.55);
  --glass-border-strong: rgba(255, 255, 255, 0.75);
  --glass-border-dark:   rgba(30, 50, 42, 0.08);
  --glass-blur:          saturate(180%) blur(22px);
  --glass-blur-lg:       saturate(200%) blur(32px);
  --glass-highlight:     inset 0 1px 0 rgba(255, 255, 255, 0.85),
                         inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  --glass-highlight-sm:  inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --glass-shadow-sm:     0 2px 8px rgba(15, 50, 35, 0.06);
  --glass-shadow:        0 8px 28px rgba(15, 50, 35, 0.10), 0 2px 6px rgba(15, 50, 35, 0.04);
  --glass-shadow-lg:     0 20px 60px rgba(15, 50, 35, 0.16), 0 4px 12px rgba(15, 50, 35, 0.06);

  /* ── Geometry (더 둥글고 연속적인 곡률) ── */
  --pbh-radius-xs: 10px;
  --pbh-radius-sm: 14px;
  --pbh-radius:    20px;
  --pbh-radius-lg: 28px;
  --pbh-radius-xl: 36px;

  /* ── Legacy shadow aliases (하위 호환) ── */
  --pbh-shadow-sm: var(--glass-shadow-sm);
  --pbh-shadow:    var(--glass-shadow);
  --pbh-shadow-lg: var(--glass-shadow-lg);

  /* ── Legacy surface aliases (하위 호환) ── */
  --pbh-surface:     var(--glass-bg);
  --pbh-surface-alt: rgba(255, 255, 255, 0.35);
  --pbh-border:      var(--glass-border-dark);

  /* ── Layout ── */
  --pbh-max-w:       560px;
  --pbh-fab-height:  72px;
  --pbh-safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ── Motion ── */
  --ease-out-quart:  cubic-bezier(.25, 1, .5, 1);
  --ease-spring:     cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  color: var(--pbh-text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Pretendard',
               'Apple SD Gothic Neo', 'Noto Sans KR', 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.008em;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
}

/* ── 배경: 레이어드 블롭 그라디언트 (Liquid Glass 무드 핵심) ── */
body {
  background:
    radial-gradient(50% 40% at 15% 10%,  rgba(130, 210, 168, .55) 0%, transparent 60%),
    radial-gradient(45% 35% at 85% 20%,  rgba(217, 194, 130, .48) 0%, transparent 62%),
    radial-gradient(55% 45% at 80% 95%,  rgba(103, 164, 210, .42) 0%, transparent 60%),
    radial-gradient(40% 30% at 20% 80%,  rgba(226, 162, 110, .38) 0%, transparent 62%),
    linear-gradient(160deg, #EEF7F0 0%, #F4F1EA 50%, #E9F1EE 100%);
  background-attachment: fixed;
  background-size: cover;
}

a { color: var(--pbh-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; }

/* ── 레이아웃 ── */
.pbh-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.pbh-container {
  width: 100%;
  max-width: var(--pbh-max-w);
  margin: 0 auto;
  padding: 0 16px;
}
.pbh-main {
  flex: 1 0 auto;
  padding-bottom: calc(var(--pbh-fab-height) + var(--pbh-safe-bottom) + 28px);
}

/* ─────────────────────────────────────────────────
   헤더 (글래스 바 + 홈 버튼)
   ───────────────────────────────────────────────── */
.pbh-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur);
          backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border-dark);
  box-shadow: var(--glass-highlight-sm);
}
.pbh-header-inner {
  display: flex; align-items: center; gap: 10px;
  height: 60px;
  padding: 0 4px;
}
.pbh-header-title {
  flex: 1;
  font-size: 17px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--pbh-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pbh-header-logo { height: 28px; }

/* 홈 버튼 (헤더 좌측, common.js 가 header-logo.png 이미지를 자동 주입) */
.pbh-home-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 6px;
  height: 40px;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s var(--ease-spring), background-color .15s;
}
.pbh-home-btn img {
  height: 30px; width: auto;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(15,50,35,.12));
}
.pbh-home-btn:hover { text-decoration: none; background: var(--glass-bg); }
.pbh-home-btn:active { transform: scale(.94); }

/* ─────────────────────────────────────────────────
   버튼 (Liquid Glass)
   ───────────────────────────────────────────────── */
.pbh-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 999px;        /* pill 형태 */
  border: 1px solid transparent;
  background: linear-gradient(180deg, #3C8560 0%, #2F6F4E 100%);
  color: #fff;
  font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform .15s var(--ease-spring),
              box-shadow .2s,
              background .15s;
  text-decoration: none;
  min-height: 44px;
  box-shadow: var(--glass-highlight-sm), 0 6px 18px rgba(47,111,78,.32);
  overflow: hidden;
  isolation: isolate;
}
.pbh-btn::before {
  /* specular 하이라이트 (상단 굴절 반사) */
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.28) 0%, rgba(255,255,255,0) 45%);
  pointer-events: none;
}
.pbh-btn:hover:not(:disabled) { background: linear-gradient(180deg, #458D69 0%, #2F6F4E 100%); text-decoration: none; }
.pbh-btn:active:not(:disabled) { transform: scale(.97); }
.pbh-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Secondary: 반투명 글래스 */
.pbh-btn-secondary {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
          backdrop-filter: var(--glass-blur);
  color: var(--pbh-text);
  border-color: var(--glass-border);
  box-shadow: var(--glass-highlight-sm), var(--glass-shadow-sm);
}
.pbh-btn-secondary:hover:not(:disabled) { background: var(--glass-bg-strong); }

/* Ghost: 투명 */
.pbh-btn-ghost {
  background: transparent;
  color: var(--pbh-primary-dark);
  border-color: transparent;
  box-shadow: none;
}
.pbh-btn-ghost::before { display: none; }
.pbh-btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.4); }

.pbh-btn-danger {
  background: linear-gradient(180deg, #E24838 0%, #C0311C 100%);
  box-shadow: var(--glass-highlight-sm), 0 6px 18px rgba(192,49,28,.32);
}
.pbh-btn-danger:hover:not(:disabled) { background: linear-gradient(180deg, #EA5847 0%, #C0311C 100%); }

.pbh-btn-block { width: 100%; }
.pbh-btn-sm { padding: 7px 14px; min-height: 34px; font-size: 13px; }

/* ─────────────────────────────────────────────────
   입력 폼 (inset glass)
   ───────────────────────────────────────────────── */
.pbh-field { margin-bottom: 14px; }
.pbh-label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--pbh-text-sub);
  letter-spacing: -0.01em;
}
.pbh-input, .pbh-select, .pbh-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--glass-border-dark);
  border-radius: var(--pbh-radius-sm);
  background: rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  color: var(--pbh-text);
  font-size: 15px; line-height: 1.45;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  box-shadow: inset 0 1px 2px rgba(15, 50, 35, 0.04);
}
.pbh-textarea { min-height: 96px; resize: vertical; }
.pbh-input:focus, .pbh-select:focus, .pbh-textarea:focus {
  outline: none;
  border-color: var(--pbh-primary);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 4px rgba(47,111,78,.15), inset 0 1px 2px rgba(15, 50, 35, 0.04);
}
.pbh-hint {
  margin-top: 6px;
  font-size: 12px; color: var(--pbh-text-muted);
}
.pbh-error {
  margin-top: 6px;
  font-size: 12px; color: var(--pbh-danger);
  font-weight: 500;
}

/* ─────────────────────────────────────────────────
   카드 (Glass Material)
   ───────────────────────────────────────────────── */
.pbh-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
          backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--pbh-radius);
  padding: 18px;
  box-shadow: var(--glass-highlight-sm), var(--glass-shadow-sm);
  position: relative;
}
.pbh-card + .pbh-card { margin-top: 12px; }
.pbh-card-title {
  font-size: 16px; font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 10px;
}
.pbh-muted { color: var(--pbh-text-muted); }

/* ── 섹션 ── */
.pbh-section { margin: 28px 0; }
.pbh-section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 14px;
}
.pbh-section-h h2 {
  font-size: 18px; margin: 0; font-weight: 800;
  letter-spacing: -0.02em;
}
.pbh-section-h a {
  font-size: 13px;
  color: var(--pbh-primary-dark);
  font-weight: 600;
  opacity: .8;
}

/* ─────────────────────────────────────────────────
   토스트 (Liquid Glass pill)
   ───────────────────────────────────────────────── */
.pbh-toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--pbh-fab-height) + var(--pbh-safe-bottom) + 16px);
  z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px); max-width: 420px;
}
.pbh-toast {
  background: rgba(30, 35, 39, 0.72);
  -webkit-backdrop-filter: var(--glass-blur);
          backdrop-filter: var(--glass-blur);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px; font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: var(--glass-shadow-lg), inset 0 1px 0 rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.12);
  opacity: 0; transform: translateY(12px) scale(.96);
  transition: opacity .25s, transform .35s var(--ease-spring);
  pointer-events: auto;
  text-align: center;
}
.pbh-toast.show { opacity: 1; transform: translateY(0) scale(1); }
.pbh-toast.success { background: rgba(30, 108, 68, 0.82); }
.pbh-toast.error   { background: rgba(175, 38, 24, 0.82); }
.pbh-toast.warn    { background: rgba(170, 98, 16, 0.82); }

/* ─────────────────────────────────────────────────
   로딩 / 스켈레톤
   ───────────────────────────────────────────────── */
.pbh-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 240px;
  color: var(--pbh-text-muted);
  font-size: 14px;
}
.pbh-spinner {
  width: 26px; height: 26px;
  border: 3px solid rgba(47,111,78,.2);
  border-top-color: var(--pbh-primary);
  border-radius: 50%;
  animation: pbh-spin .8s linear infinite;
  margin-right: 10px;
}
@keyframes pbh-spin { to { transform: rotate(360deg); } }

.pbh-skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,.3) 0%,
    rgba(255,255,255,.7) 50%,
    rgba(255,255,255,.3) 100%);
  background-size: 200% 100%;
  animation: pbh-skel 1.2s ease-in-out infinite;
  border-radius: var(--pbh-radius-xs);
}
@keyframes pbh-skel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─────────────────────────────────────────────────
   플로팅 하단 메뉴 (Liquid Glass Dock · Slack-mobile 스타일)
   · 충분한 좌우 여백 + 완전 pill 형태 + 깔끔한 둥글둥글
   · 활성 아이템은 브랜드 그린 알약 필로 하이라이트
   ───────────────────────────────────────────────── */
.pbh-fab-nav {
  position: fixed;
  left: 50%; bottom: calc(var(--pbh-safe-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 40;
  display: none;
  width: calc(100% - 32px); max-width: calc(var(--pbh-max-w) - 32px);
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.86) 0%,
    rgba(255,255,255,0.72) 100%
  );
  -webkit-backdrop-filter: var(--glass-blur-lg);
          backdrop-filter: var(--glass-blur-lg);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 999px;           /* 완전 pill — Slack 모바일 느낌 */
  box-shadow:
    /* 유리 엣지 하이라이트 */
    inset 0 1px 0 rgba(255,255,255,0.95),
    inset 0 -1px 0 rgba(255,255,255,0.25),
    /* 세련된 외곽선 */
    0 1px 2px rgba(15,50,35,0.06),
    /* 중거리 그림자 */
    0 10px 24px -10px rgba(15,50,35,0.22),
    /* 브랜드 틴트 글로우 */
    0 22px 44px -18px rgba(47,111,78,0.28);
  padding: 6px 8px;
  animation: pbh-fab-float-in .55s var(--ease-spring) both;
  transition:
    width .28s var(--ease-spring),
    padding .28s var(--ease-spring);
}

/* 스크롤 중 축소 상태 — 라벨 감추고 아이콘만 보이는 피콜 형태 */
.pbh-fab-nav.compact {
  width: auto;
  max-width: calc(100% - 32px);
  padding: 5px 6px;
}
.pbh-fab-nav.compact .pbh-fab-item {
  flex: 0 0 auto;
  height: 44px;
  width: 44px;
  padding: 0;
  gap: 0;
}
.pbh-fab-nav.compact .pbh-fab-item > span:not(.pbh-fab-icon) {
  display: none;
}
.pbh-fab-nav.compact .pbh-fab-item .pbh-fab-icon {
  font-size: 22px;
}
.pbh-fab-nav.show { display: flex; }

@keyframes pbh-fab-float-in {
  0%   { opacity: 0; transform: translate(-50%, 24px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translate(-50%, 0); }
}

.pbh-fab-nav-inner {
  display: flex; width: 100%;
  gap: 2px;
}
.pbh-fab-item {
  flex: 1 1 0;
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  height: 54px;
  color: var(--pbh-text-muted);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
  background: transparent; border: 0;
  border-radius: 999px;           /* 각 아이템도 pill */
  cursor: pointer;
  transition:
    color .22s ease,
    background .22s ease,
    transform .18s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.pbh-fab-item .pbh-fab-icon {
  font-size: 20px; line-height: 1;
  filter: saturate(1.15);
  transition: transform .25s var(--ease-spring);
}
.pbh-fab-item:hover {
  text-decoration: none;
  color: var(--pbh-primary-dark);
  background: rgba(47,111,78,0.06);
}
.pbh-fab-item:hover .pbh-fab-icon { transform: translateY(-1px); }
.pbh-fab-item:active { transform: scale(.94); }

.pbh-fab-item[aria-current="page"],
.pbh-fab-item.active {
  color: #fff;
  background: linear-gradient(180deg, #3C8560 0%, #2F6F4E 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.28),
    0 2px 6px rgba(47,111,78,0.22),
    0 8px 16px -6px rgba(47,111,78,0.32);
}
.pbh-fab-item[aria-current="page"] .pbh-fab-icon,
.pbh-fab-item.active .pbh-fab-icon {
  transform: translateY(-1px) scale(1.06);
}

/* ─────────────────────────────────────────────────
   배지
   ───────────────────────────────────────────────── */
.pbh-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: -0.01em;
  background: rgba(47, 111, 78, 0.12);
  color: var(--pbh-primary-dark);
  border: 1px solid rgba(47, 111, 78, 0.2);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
}
.pbh-badge.muted { background: rgba(255,255,255,.5); color: var(--pbh-text-sub); border-color: var(--glass-border-dark); }
.pbh-badge.warn  { background: rgba(221, 128, 23, 0.14); color: #8a5100; border-color: rgba(221, 128, 23, 0.35); }
.pbh-badge.err   { background: rgba(208, 49, 28, 0.14); color: #7f1f13; border-color: rgba(208, 49, 28, 0.35); }
.pbh-badge.hot   { background: linear-gradient(180deg, #F26D3D 0%, #D9542A 100%); color:#fff; border-color: rgba(255,255,255,.35); box-shadow: var(--glass-highlight-sm); }
.pbh-badge.new   { background: linear-gradient(180deg, #3DA6F2 0%, #2A85D9 100%); color:#fff; border-color: rgba(255,255,255,.35); box-shadow: var(--glass-highlight-sm); }

/* ─────────────────────────────────────────────────
   유틸
   ───────────────────────────────────────────────── */
.pbh-hidden { display: none !important; }
.pbh-row { display: flex; align-items: center; gap: 8px; }
.pbh-row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pbh-text-center { text-align: center; }
.pbh-mt-sm { margin-top: 8px; }
.pbh-mt { margin-top: 16px; }
.pbh-mt-lg { margin-top: 24px; }
.pbh-mb { margin-bottom: 16px; }
.pbh-w-full { width: 100%; }

/* ── 즐겨찾기 하트 버튼 ── */
.pbh-fav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
          backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-highlight-sm), var(--glass-shadow-sm);
  color: var(--pbh-text-sub);
  font-size: 18px;
  cursor: pointer;
  transition: transform .15s var(--ease-spring), color .2s;
}
.pbh-fav-btn:hover { color: #E24838; }
.pbh-fav-btn:active { transform: scale(.85); }
.pbh-fav-btn.active {
  color: #E24838;
  background: linear-gradient(180deg, #FFEAE4 0%, #FFD2C6 100%);
  border-color: rgba(226, 72, 56, .3);
}

/* ── 카드 위 오버레이용 플로팅 즐겨찾기 ── */
.pbh-fav-float {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px; font-size: 15px;
  z-index: 2;
}

/* ─────────────────────────────────────────────────
   태블릿 이상
   ───────────────────────────────────────────────── */
@media (min-width: 720px) {
  :root { --pbh-max-w: 720px; }
  body { font-size: 15.5px; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
