/* ===================================================
   속초피크 — Feed CSS (레벨별 인터랙티브 테마)
   팔로우/팔로잉 버튼 + 메시지 인라인 모달 포함
=================================================== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&display=swap');

/* ── 기본 변수 ── */
:root {
  --accent:    #e8392a;
  --accent-dk: #c42d1e;
  --accent-lt: #fff2f0;
  --accent-bg: #fdf6f5;
  --ring1:     #e2e6ea;
  --ring2:     #c8cdd4;
  --bg:        #f2f2f2;
  --white:     #fff;
  --g1:        #f9f9f9;
  --g2:        #ececec;
  --g4:        #b0b0b0;
  --g6:        #666;
  --g8:        #1a1a1a;
  --r:         12px;
  --t:         .17s ease;
  --max-w:     680px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ══════════════════════════════════════════
   레벨 테마 변수
══════════════════════════════════════════ */
.lv-theme-pink {
  --accent: #db2777; --accent-dk: #be185d; --accent-lt: #fdf2f8; --accent-bg: #fdf2f8;
  --ring1: rgba(219,39,119,.25); --ring2: rgba(219,39,119,.55);
}
.lv-theme-blue {
  --accent: #2563eb; --accent-dk: #1d4ed8; --accent-lt: #eff6ff; --accent-bg: #eff6ff;
  --ring1: rgba(37,99,235,.22); --ring2: rgba(37,99,235,.5);
}
.lv-theme-green {
  --accent: #16a34a; --accent-dk: #15803d; --accent-lt: #f0fdf4; --accent-bg: #f0fdf4;
  --ring1: rgba(22,163,74,.28); --ring2: rgba(22,163,74,.6);
}
.lv-theme-gold {
  --accent: #d97706; --accent-dk: #b45309; --accent-lt: #fffbeb; --accent-bg: #fffbeb;
  --ring1: rgba(245,158,11,.35); --ring2: rgba(245,158,11,.7);
}
.lv-theme-admin {
  --accent: #e8392a; --accent-dk: #c42d1e; --accent-lt: #fff2f0; --accent-bg: #fff8f7;
  --ring1: rgba(232,57,42,.3); --ring2: rgba(232,57,42,.65);
}

/* ── 리셋 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Noto Sans KR', sans-serif; background: var(--bg); color: var(--g8); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }

/* ══════════════════════════════════════════
   네비
══════════════════════════════════════════ */
.fd-nav {
  position: sticky; top: 0; z-index: 200;
  background: var(--white); border-bottom: 1px solid var(--g2);
  height: 52px; display: flex; align-items: center; padding: 0 4px 0 8px;
}
.fd-nav__back {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; color: var(--g6);
  flex-shrink: 0; transition: background var(--t);
}
.fd-nav__back:active { background: var(--g2); }
.fd-nav__title { flex: 1; text-align: center; font-size: .95rem; font-weight: 700; color: var(--g8); letter-spacing: -.01em; }
.fd-nav__badge { width: 40px; text-align: right; font-size: .7rem; color: var(--g4); padding-right: 8px; flex-shrink: 0; }

/* ══════════════════════════════════════════
   프로필 헤더
══════════════════════════════════════════ */
.fd-profile-header {
  position: relative; overflow: hidden;
  background: var(--white);
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--g2);
  padding: 20px 20px 18px;
  display: flex; align-items: flex-start; gap: 16px;
  max-width: var(--max-w); margin: 0 auto;
}

/* lv5~10 헤더 배경 은은한 그라데이션 */
.lv-theme-green .fd-profile-header { background: linear-gradient(135deg, #fff 55%, #f0fdf4 100%); }
.lv-theme-gold  .fd-profile-header { background: linear-gradient(135deg, #fff 50%, #fffbeb 100%); }
.lv-theme-admin .fd-profile-header { background: linear-gradient(135deg, #fff 55%, #fff5f4 100%); }

/* 파티클 캔버스 */
#fd-particles {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

/* 아바타 래퍼 */
.fd-profile-avatar-wrap { position: relative; flex-shrink: 0; z-index: 1; margin-top: 4px; }
.fd-profile-header__info { position: relative; z-index: 1; flex: 1; min-width: 0; }

.fd-profile-header__avatar {
  width: 60px; height: 60px; border-radius: 50%; object-fit: cover; display: block;
  border: 3px solid var(--white);
  box-shadow: 0 0 0 2.5px var(--ring1);
  position: relative; z-index: 1;
}
.fd-profile-header__avatar--default {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, white));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
  border: 3px solid var(--white);
  box-shadow: 0 0 0 2.5px var(--ring1);
  position: relative; z-index: 1;
}

/* 글로우 링 */
.fd-lv-ring {
  position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid transparent; z-index: 0; pointer-events: none;
}
.lv-theme-green .fd-lv-ring {
  border-color: #4ade80;
  animation: ring-green 3s ease-in-out infinite;
}
.lv-theme-gold .fd-lv-ring {
  border-color: #f59e0b; border-style: dashed;
  animation: ring-gold-spin 4s linear infinite, ring-gold-glow 2s ease-in-out infinite;
}
.lv-theme-admin .fd-lv-ring {
  border-color: #e8392a;
  animation: ring-red 2.5s ease-in-out infinite;
}

@keyframes ring-green {
  0%,100% { box-shadow: 0 0 5px 1px rgba(74,222,128,.35); }
  50%      { box-shadow: 0 0 14px 4px rgba(74,222,128,.65); }
}
@keyframes ring-gold-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes ring-gold-glow {
  0%,100% { box-shadow: 0 0 6px 2px rgba(245,158,11,.4); }
  50%      { box-shadow: 0 0 18px 6px rgba(245,158,11,.8); }
}
@keyframes ring-red {
  0%,100% { box-shadow: 0 0 5px 1px rgba(232,57,42,.35); }
  50%      { box-shadow: 0 0 14px 4px rgba(232,57,42,.65); }
}

/* 닉네임 행 */
.fd-profile-header__nick-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fd-profile-header__nick { font-size: 1.05rem; font-weight: 700; color: var(--g8); }

/* 레벨 칩 */
.fd-lv-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .68rem; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  background: var(--accent-lt); color: var(--accent);
  border: 1px solid var(--ring1); white-space: nowrap; letter-spacing: .01em;
}
.lv-theme-gold .fd-lv-chip {
  background: linear-gradient(90deg, #fff8e1, #fef3c7, #ffe88a, #fef3c7, #fff8e1);
  background-size: 300% auto;
  animation: chip-shimmer-gold 2s linear infinite;
  border-color: #f59e0b; color: #92400e;
  box-shadow: 0 0 8px rgba(245,158,11,.35);
}
.lv-theme-green .fd-lv-chip { border-color: rgba(22,163,74,.4); }

@keyframes chip-shimmer-gold {
  0%   { background-position: 0 center; }
  100% { background-position: 300% center; }
}

.fd-profile-header__count { font-size: .78rem; color: var(--g4); margin-top: 5px; }
.fd-profile-header__count strong { color: var(--accent); font-weight: 700; }

/* ══════════════════════════════════════════
   프로필 액션 버튼 (팔로우 / 메시지 / 편집)
══════════════════════════════════════════ */
.fd-profile-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* 팔로우 버튼 */
.fd-btn-follow {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 18px; border-radius: 20px;
  font-size: .8rem; font-weight: 700;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer; transition: all var(--t);
  background: var(--accent); border: 1.5px solid var(--accent); color: #fff;
  line-height: 1;
}
.fd-btn-follow:hover { background: var(--accent-dk); border-color: var(--accent-dk); }

/* 팔로잉 상태 */
.fd-btn-follow.is-following {
  background: transparent;
  border-color: var(--g2);
  color: var(--g6);
}
.fd-btn-follow.is-following:hover {
  border-color: #e55; color: #e55; background: #fff5f5;
}
.fd-btn-follow:disabled { opacity: .55; cursor: wait; }

/* 메시지 버튼 */
.fd-btn-msg {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px; border-radius: 20px;
  font-size: .8rem; font-weight: 600;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer; transition: all var(--t);
  background: transparent; border: 1.5px solid var(--g2); color: var(--g6);
  line-height: 1;
}
.fd-btn-msg:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }

/* 프로필 편집 버튼 */
.fd-btn-edit {
  display: inline-flex; align-items: center;
  padding: 7px 18px; border-radius: 20px;
  font-size: .8rem; font-weight: 600;
  border: 1.5px solid var(--g2); color: var(--g6);
  transition: all var(--t);
  line-height: 1;
}
.fd-btn-edit:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }

/* ══════════════════════════════════════════
   필터 탭
══════════════════════════════════════════ */
.fd-tabs {
  position: sticky; top: 52px; z-index: 190;
  background: var(--white); border-bottom: 1px solid var(--g2);
  display: flex; gap: 8px; padding: 10px 14px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.fd-tabs::-webkit-scrollbar { display: none; }
.fd-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px; border-radius: 20px; border: 1.5px solid var(--g2);
  background: var(--white); color: var(--g6);
  font-size: .82rem; font-weight: 500; font-family: 'Noto Sans KR', sans-serif;
  white-space: nowrap; flex-shrink: 0; transition: all var(--t);
}
.fd-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.fd-tab:not(.is-active):hover { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════════
   그리드
══════════════════════════════════════════ */
.fd-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  padding: 14px 14px calc(32px + var(--safe-bottom));
  max-width: var(--max-w); margin: 0 auto;
}

/* ══════════════════════════════════════════
   카드 — 기본
══════════════════════════════════════════ */
.fd-card {
  background: var(--white); border-radius: var(--r);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  display: flex; flex-direction: column;
  transition: transform .22s cubic-bezier(.4,0,.2,1), box-shadow .22s ease, border-color .22s ease;
  -webkit-tap-highlight-color: transparent;
  border-left: 3px solid var(--ring1);
}
.fd-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.10);
  border-left-color: var(--accent);
}
.fd-card:active { transform: scale(.97); }

/* lv5 green / admin 카드: 스크롤 페이드인 */
.lv-theme-green .fd-card,
.lv-theme-admin .fd-card {
  opacity: 0; transform: translateY(16px);
}
.lv-theme-green .fd-card.is-visible,
.lv-theme-admin .fd-card.is-visible {
  opacity: 1; transform: translateY(0);
  transition: opacity .45s ease, transform .45s cubic-bezier(.4,0,.2,1),
              box-shadow .22s ease, border-color .22s ease;
}
.lv-theme-green .fd-card:hover {
  box-shadow: 0 8px 24px rgba(22,163,74,.22), 0 2px 8px rgba(0,0,0,.07);
  border-left-color: #16a34a;
}

/* lv6 gold 카드: shimmer + 페이드인 */
.lv-theme-gold .fd-card {
  opacity: 0; transform: translateY(20px) scale(.97);
  position: relative; overflow: hidden;
  border-left: 3px solid rgba(245,158,11,.4);
}
.lv-theme-gold .fd-card.is-visible {
  opacity: 1; transform: translateY(0) scale(1);
  transition: opacity .5s ease, transform .5s cubic-bezier(.34,1.56,.64,1),
              box-shadow .22s ease, border-color .22s ease;
}
.lv-theme-gold .fd-card::before {
  content: '';
  position: absolute; top: 0; left: -90%;
  width: 50%; height: 100%;
  background: linear-gradient(110deg, transparent 20%, rgba(255,236,100,.4) 50%, transparent 80%);
  animation: card-shine 4.5s ease-in-out infinite;
  pointer-events: none; z-index: 2;
}
@keyframes card-shine {
  0%       { left: -90%; opacity: 0; }
  10%      { opacity: 1; }
  55%,100% { left: 130%; opacity: 0; }
}
.lv-theme-gold .fd-card:hover {
  transform: translateY(-5px) scale(1.02) !important;
  box-shadow: 0 12px 32px rgba(245,158,11,.3), 0 4px 12px rgba(0,0,0,.1) !important;
  border-left-color: #f59e0b !important;
}
.lv-theme-gold .fd-card:hover::before { animation-duration: 0.6s; }

/* admin 호버 */
.lv-theme-admin .fd-card:hover {
  box-shadow: 0 8px 24px rgba(232,57,42,.2), 0 2px 8px rgba(0,0,0,.07);
}

/* 카드 내부 공통 */
.fd-card__thumb {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  background: var(--g2); display: block; flex-shrink: 0;
}
.fd-card__no-img {
  width: 100%; aspect-ratio: 4/3;
  background: linear-gradient(135deg, #f2f2f2, #e6e6e6);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; flex-shrink: 0;
}
.fd-card__body { padding: 10px 11px 11px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.fd-card__badge { align-self: flex-start; font-size: .6rem; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: 20px; }
.fd-card__badge--food  { background: #fff3e0; color: #e65100; }
.fd-card__badge--where { background: #e3f2fd; color: #1565c0; }
.fd-card__title { font-size: .83rem; font-weight: 600; line-height: 1.45; color: var(--g8); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.fd-card__meta { display: flex; align-items: center; gap: 4px; padding-top: 6px; border-top: 1px solid var(--g2); margin-top: auto; }
.fd-card__time { font-size: .62rem; color: var(--g4); }
.fd-card__stats { display: flex; gap: 6px; margin-left: auto; font-size: .62rem; color: var(--g4); }
.fd-card__stat { display: flex; align-items: center; gap: 2px; }

/* ══════════════════════════════════════════
   빈 상태
══════════════════════════════════════════ */
.fd-empty { grid-column: 1/-1; text-align: center; padding: 56px 20px; }
.fd-empty__icon { font-size: 3.5rem; display: block; margin-bottom: 14px; }
.fd-empty__text { font-size: .88rem; color: var(--g4); line-height: 1.7; }
.fd-empty__cta {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 20px; padding: 11px 28px;
  background: var(--accent); color: #fff; border-radius: 24px;
  font-size: .84rem; font-weight: 700; transition: background var(--t);
}
.fd-empty__cta:hover { background: var(--accent-dk); }

/* ══════════════════════════════════════════
   페이지네이션
══════════════════════════════════════════ */
.fd-paging { display: flex; justify-content: center; align-items: center; gap: 5px; padding: 16px 16px 40px; max-width: var(--max-w); margin: 0 auto; }
.fd-pg {
  min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1.5px solid var(--g2); background: var(--white);
  color: var(--g6); font-size: .82rem; font-weight: 500; font-family: 'Noto Sans KR', sans-serif;
  text-decoration: none; transition: all var(--t); padding: 0 10px;
}
.fd-pg:hover       { border-color: var(--accent); color: var(--accent); }
.fd-pg.is-active   { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; pointer-events: none; }
.fd-pg.is-disabled { opacity: .3; pointer-events: none; }

/* ══════════════════════════════════════════
   메시지 인라인 모달
══════════════════════════════════════════ */
.fd-msg-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: fd-overlay-in .2s ease;
}
@keyframes fd-overlay-in { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 480px) {
  .fd-msg-overlay { align-items: center; }
}

.fd-msg-box {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px;
  height: 72vh; max-height: 560px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 40px rgba(0,0,0,.18);
  animation: fd-box-up .28s cubic-bezier(.34,1.2,.64,1);
}
@keyframes fd-box-up { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (min-width: 480px) {
  .fd-msg-box {
    border-radius: 20px;
    height: 520px;
    animation: fd-box-scale .25s cubic-bezier(.34,1.2,.64,1);
  }
  @keyframes fd-box-scale { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}

/* 모달 헤더 */
.fd-msg-box-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #f0f0f0;
  font-size: .95rem; font-weight: 700; color: var(--g8);
  flex-shrink: 0;
}
.fd-msg-close {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--g4);
  padding: 4px 8px; border-radius: 6px;
  transition: background var(--t), color var(--t);
  line-height: 1;
}
.fd-msg-close:hover { background: var(--g2); color: var(--g6); }

/* 말풍선 영역 */
.fd-msg-bubbles {
  flex: 1; overflow-y: auto;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  background: #f8f8f8;
  scroll-behavior: smooth;
}
.fd-msg-loading-txt {
  text-align: center; padding: 24px;
  font-size: .82rem; color: var(--g4);
}

/* 말풍선 래퍼 */
.fd-msg-bubble-wrap { display: flex; flex-direction: column; max-width: 74%; }
.fd-msg-bubble-wrap.is-me   { align-self: flex-end;   align-items: flex-end; }
.fd-msg-bubble-wrap.is-them { align-self: flex-start; align-items: flex-start; }

/* 말풍선 */
.fd-msg-bubble {
  padding: 9px 14px; border-radius: 18px;
  font-size: .88rem; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
}
.fd-msg-bubble-wrap.is-me .fd-msg-bubble {
  background: linear-gradient(135deg, var(--accent-dk), var(--accent));
  color: #fff; border-bottom-right-radius: 4px;
}
.fd-msg-bubble-wrap.is-them .fd-msg-bubble {
  background: #fff; color: var(--g8);
  border: 1px solid #e8e8e8;
  border-bottom-left-radius: 4px;
}

/* 시간 */
.fd-msg-time {
  font-size: .68rem; color: var(--g4);
  margin-top: 3px; padding: 0 4px;
}

/* 시스템 메시지 */
.fd-msg-system {
  display: flex; justify-content: center; margin: 8px 0;
}
.fd-msg-system span {
  background: #ebebeb; color: #999;
  font-size: .72rem; padding: 4px 14px; border-radius: 20px;
}

/* 입력창 행 */
.fd-msg-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #f0f0f0;
  background: #fff; flex-shrink: 0;
}
.fd-msg-input {
  flex: 1; height: 40px;
  border: 1.5px solid var(--g2); border-radius: 20px;
  padding: 0 16px; font-size: .88rem;
  font-family: 'Noto Sans KR', sans-serif;
  color: var(--g8); background: #f8f8f8; outline: none;
  transition: border-color var(--t), background var(--t);
}
.fd-msg-input:focus { border-color: var(--accent); background: #fff; }
.fd-msg-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dk), var(--accent));
  border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(232,57,42,.28);
  transition: transform var(--t), box-shadow var(--t);
}
.fd-msg-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(232,57,42,.38);
}
.fd-msg-send-btn:active { transform: scale(.93); }

/* ══════════════════════════════════════════
   반응형
══════════════════════════════════════════ */
@media (max-width: 340px) { .fd-grid { grid-template-columns: 1fr; } }
@media (min-width: 681px) {
  :root { --max-w: 960px; }
  .fd-grid { grid-template-columns: repeat(3, 1fr); }
  .fd-tabs { max-width: var(--max-w); margin: 0 auto; }
}