/*
 * Rounded Design System — Color Tokens
 *
 * Architecture: Two-tier Design Tokens (W3C Design Tokens 권고안 패턴)
 *
 *   ┌─ Tier 1: PRIMITIVE (--c-*) ─────────────┐
 *   │  순수 색 scale. 의미 없음. 색 자체.       │
 *   │  --c-mint-400, --c-coral-500, ...        │
 *   │  scale: 50·100·200·300·400·500·700·900   │
 *   │  (Tailwind/Radix 11-step 의 핵심만)      │
 *   └──────────────────────────────────────────┘
 *                    ↓ 참조
 *   ┌─ Tier 2: SEMANTIC (--r-*) ──────────────┐
 *   │  역할 별칭. Tier 1 참조.                  │
 *   │  --r-primary → var(--c-mint-400)         │
 *   │  --r-warm    → var(--c-coral-500)        │
 *   │  --r-cool    → var(--c-indigo-500)       │
 *   └──────────────────────────────────────────┘
 *                    ↓ 사용
 *   ┌─ Components / Templates ────────────────┐
 *   │  style="color: var(--r-warm)" 만 사용.   │
 *   │  hex 직접 사용 금지. primitive 직참조도 X. │
 *   └──────────────────────────────────────────┘
 *
 * Why this structure?
 *   1. 색 자체 변경 → Tier 1 한 곳만 수정 → 전 시스템 일괄 반영
 *   2. 의미 매핑 변경 → Tier 2 만 수정 → 컴포넌트 코드 무수정
 *   3. 다크/하이콘트라스트 테마 추가 시 → Tier 2 만 재정의
 *   4. 새 색 추가 → Tier 1 scale 정의 → Tier 2 에 별칭 부여만
 *
 * Migration policy:
 *   - 기존 `--r-*` 변수명은 호환성 위해 유지.
 *   - 신규 작업은 Tier 2 semantic (`--r-primary`, `--r-warm`, `--r-cool`) 만 사용.
 *   - hex 리터럴 신규 추가 금지 — 모두 primitive scale 에서 가져와야 함.
 */

:root {
  /* ═══════════════════════════════════════════════════════════════
   * Tier 1: PRIMITIVE TOKENS — 순수 색 scale (의미 없음, hex 자체)
   * 컴포넌트에서 직접 참조하지 말 것. Tier 2 를 통해서만 사용.
   * ═══════════════════════════════════════════════════════════════ */

  /* Mint scale — 브랜드 코어 */
  --c-mint-50:  #F2FAF7;  /* 페이지 배경 */
  --c-mint-75:  #E8F5F0;  /* 섹션 강조 배경 */
  --c-mint-100: #DBF6EE;  /* pill bg, focus ring */
  --c-mint-200: #92E1D0;  /* 보더, 살짝 강조 */
  --c-mint-400: #3CDBC0;  /* 브랜드 메인 */
  --c-mint-500: #2EC4AC;  /* hover */
  --c-mint-700: #14A993;  /* 흰 배경 위 텍스트/링크 */
  --c-mint-900: #0B6E5F;

  /* Coral scale — 따뜻한 강조 (CTA, 알림, 핫 카드) */
  --c-coral-50:  #FFF5F5;
  --c-coral-100: #FED7D7;
  --c-coral-200: #FCB6B6;
  --c-coral-300: #FCA5A5;
  --c-coral-500: #F87171;  /* 메인 — 차분한 코랄 (Tailwind red-400 톤) */
  --c-coral-700: #DC2626;
  --c-coral-900: #7F1D1D;

  /* Indigo scale — 차분한 보조 (정보, 프리미엄, 보조 컨트롤) */
  --c-indigo-50:  #EEF2FF;
  --c-indigo-100: #E5DFF6;  /* enterprise grade bg 와 동일 */
  --c-indigo-200: #C9BFE7;  /* (구) accent — 파스텔 라벤더 */
  --c-indigo-300: #A5B4FC;
  --c-indigo-400: #8B7BC8;  /* (구) accent-deep */
  --c-indigo-500: #6E5DBC;  /* 메인 — enterprise grade text 와 동일 */
  --c-indigo-700: #4F3D9C;
  --c-indigo-900: #312E81;

  /* Green scale — 파스텔 그린 (큐레이션 보조, banner slide 2) */
  --c-green-100: #E2EEDF;
  --c-green-300: #B4D3B2;  /* (구) secondary */
  --c-green-400: #A2C4A0;  /* (구) secondary-hover */

  /* Neutral scale — 텍스트, 보더, 배경 */
  --c-neutral-0:   #FFFFFF;
  --c-neutral-100: #ECF1ED;
  --c-neutral-300: #DDE5DF;
  --c-neutral-500: #8B9A98;
  --c-neutral-600: #5F6E6C;  /* 흐린 글자 — 흰 배경 5.3:1 */
  --c-neutral-700: #4A5F5D;
  --c-neutral-900: #102C2A;

  /* Status scale — 의미 색 (성공/경고/에러) */
  --c-warning-500: #f59e0b;
  --c-error-500:   #ef4444;

  /* ═══════════════════════════════════════════════════════════════
   * Tier 2: SEMANTIC TOKENS — 역할 별칭. 컴포넌트는 이것만 사용.
   * ═══════════════════════════════════════════════════════════════ */

  /* ── Rounded Brand Guideline (Lite) ──
   * 브랜드 팔레트 기준. 변경 시 이 블록만 수정하면 전체 반영.
   *  Primary    #3CDBC0  민트 (Pantone 333 C)
   *  Warm       #F87171  코랄 (NEW — 따뜻한 강조)
   *  Cool       #6E5DBC  인디고 (NEW — 차분한 보조)
   *  Background #F2FAF7  옅은 민트 틴트
   *  Text       #102C2A  딥 틸 블랙
   *  Neutral    #DDE5DF  옅은 그린-그레이
   */
  --r-primary: #3CDBC0;          /* 브랜드 민트 — 솔리드 배경/뱃지/하이라이트 */
  --r-primary-hover: #2EC4AC;    /* hover 시 약간 어둡게 */
  --r-primary-light: #DBF6EE;    /* 옅은 민트 — pill bg, focus ring */
  --r-primary-muted: #92E1D0;    /* 중간 민트 — 보더, 살짝 강조 */
  --r-primary-deep: #0B6E5F;     /* 딥 민트(= --c-mint-900) — 흰 배경 위 텍스트/링크. 흰 배경 6.2:1, 옅은 민트 배경 5.4:1 (예전 #14A993 은 2.9:1, 2026-11-12) */

  --r-secondary: #B4D3B2;        /* 파스텔 그린 */
  --r-secondary-hover: #A2C4A0;
  --r-secondary-light: #E2EEDF;

  --r-accent: #C9BFE7;           /* 파스텔 라벤더 — (Deprecated: --r-cool-light 사용 권장) */
  --r-accent-deep: #6E5DBC;      /* 진한 라벤더 — (Deprecated: --r-cool 사용 권장) */

  /* ── Warm accent (NEW, 2026-06-04) ──
   * 따뜻한 강조 — CTA 보조, 알림, 핫 카드, 활동 강조.
   * primary 민트와 보색 관계로 시각 contrast 강함. 남용 X.
   * 사용처: 알림 뱃지, 핫 딜 표시, 인박스 미처리 강조, 활동 카운트.   */
  --r-warm: var(--c-coral-500);          /* 메인 코랄 — 솔리드 강조 */
  --r-warm-hover: var(--c-coral-700);    /* hover */
  --r-warm-light: var(--c-coral-100);    /* pill bg, 옅은 강조 영역 */
  --r-warm-muted: var(--c-coral-200);    /* 보더 */
  --r-warm-deep: var(--c-coral-900);     /* 흰 배경 위 텍스트/링크 */

  /* ── Cool accent (NEW, 2026-06-04) ──
   * 차분한 보조 — 정보성 강조, 프리미엄, 보조 컨트롤(화살표·info icon).
   * primary 민트와 인접 톤이라 같이 써도 부담 적음.
   * 사용처: 화살표/네비 컨트롤, 정보 뱃지, enterprise grade, 라이선싱 차분 강조. */
  --r-cool: var(--c-indigo-500);         /* 메인 인디고 — 솔리드 강조 */
  --r-cool-hover: var(--c-indigo-700);   /* hover */
  --r-cool-light: var(--c-indigo-100);   /* pill bg, 옅은 강조 영역 */
  --r-cool-muted: var(--c-indigo-200);   /* 보더 */
  --r-cool-deep: var(--c-indigo-700);    /* 흰 배경 위 텍스트/링크 */

  /* ── Neutral / Background ── */
  --r-bg: #F2FAF7;               /* 페이지 배경 — 옅은 민트 틴트 (브랜드 민트와 호흡, 칙칙함 해소) */
  --r-bg-soft: #E8F5F0;          /* 더 진한 민트 틴트 — 섹션 구분 / 강조 영역용 */
  --r-surface: #FFFFFF;          /* 카드/모달 배경 — 순백 (민트 배경 위로 시원하게 떠있음) */
  --r-border: #DDE5DF;           /* 테두리 — 브랜드 Neutral */
  --r-border-light: #ECF1ED;     /* 옅은 테두리 */

  --r-text: #102C2A;             /* 본문 텍스트 — 브랜드 Text */
  --r-text-secondary: #4A5F5D;   /* 보조 텍스트 (Text 의 60%) */
  --r-text-muted: #5F6E6C;       /* 흐린 글자 — 흰 배경 5.3:1, 페이지 배경 5.0:1 (예전 #8B9A98 은 2.9:1, 2026-11-12) */
  --r-text-on-primary: #102C2A;  /* 민트 배경 위 텍스트 — 어두운 글자(가독성↑) */

  /* ── Status ── */
  --r-success: #0B6E5F;          /* 민트 톤 — 글자·흰 글자 받침 모두 4.5:1 이상 (2026-11-12) */
  --r-warning: #f59e0b;
  --r-error: #DC2626;            /* = --c-coral-700. 흰 배경 위 글자·흰 글자 받침 4.8:1 (예전 #ef4444 는 3.8:1, 2026-11-12) */
  --r-info: #3CDBC0;

  /* ── Footer ── */
  --r-footer-bg: #102C2A;        /* 브랜드 Text 다크 */
  --r-footer-text: #DBF6EE;      /* 옅은 민트 */
  --r-footer-muted: #92E1D0;     /* 중간 민트 */

  /* ── Sizing ── */
  --r-radius: 0.75rem;
  --r-radius-lg: 1rem;
  --r-radius-xl: 1.25rem;

  /* ── Badge grades ── */
  --r-grade-basic-bg: #ECF1ED;
  --r-grade-basic-text: #4A5F5D;
  --r-grade-premium-bg: #DBF6EE;
  --r-grade-premium-text: #14A993;
  --r-grade-enterprise-bg: #E5DFF6;
  --r-grade-enterprise-text: #6E5DBC;

  /* ── Banner slide colors ── */
  --r-slide-1: #3CDBC0;          /* 민트 */
  --r-slide-2: #B4D3B2;          /* 파스텔 그린 */
  --r-slide-3: #C9BFE7;          /* 라벤더 */
  --r-slide-4: #102C2A;          /* 다크 틸 */
}

/* ── daisyUI theme overrides ── */
[data-theme="light"] {
  /* Primary — 브랜드 민트 #3CDBC0 (HSL 169 67% 55%) */
  --p: 169 67% 55%;
  --pf: 169 64% 47%;
  --pc: 175 50% 12%;     /* 민트 위 텍스트 — 브랜드 다크 #102C2A */
  /* Secondary — 파스텔 그린 #B4D3B2 */
  --s: 117 25% 76%;
  --sf: 117 22% 70%;
  --sc: 175 50% 12%;
  /* Accent — 라벤더 #C9BFE7 */
  --a: 257 47% 83%;
  --af: 257 35% 64%;
  --ac: 175 50% 12%;
  --n: 175 50% 12%;      /* Neutral surface — 브랜드 다크 텍스트 */
  --nf: 175 50% 8%;
  --nc: 117 22% 89%;
  --rounded-box: var(--r-radius-lg);
  --rounded-btn: var(--r-radius);
}

/* ── Base styles ── */
html { scroll-behavior: smooth; }

body {
  font-feature-settings: 'ss01', 'ss02', 'cv01';
  -webkit-font-smoothing: antialiased;
  background-color: var(--r-bg);
  color: var(--r-text);
  /* 한국어는 낱말 단위로 줄바꿈(2026-11-11 UI 점검) — 좁은 칸에서 '연결하/는'·'새 문/의'처럼 글자 중간이 끊기던 문제.
     공백 없는 긴 값(메일 주소·URL·주문번호)은 overflow-wrap 이 칸 안에서 끊어 준다. */
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ── Utility classes ── */

/* Buttons */
.btn-brand {
  background-color: var(--r-primary);
  color: var(--r-text-on-primary);
  border: none;
  font-weight: 600;
}
.btn-brand:hover {
  background-color: var(--r-primary-hover);
}

.btn-brand-outline {
  background-color: transparent;
  /* 글자만 딥 민트 — 주 민트(#3CDBC0) 글자는 흰 배경 대비 1.7:1 이라 거의 안 보였다(테두리는 그대로) */
  color: var(--r-primary-deep);
  border: 1.5px solid var(--r-primary);
  font-weight: 600;
}
.btn-brand-outline:hover {
  background-color: var(--r-primary-light);
}

.btn-dark {
  background-color: var(--r-text);
  color: var(--r-text-on-primary);
  border: none;
  font-weight: 600;
}
.btn-dark:hover {
  background-color: #374151;
}

/* Cards
   규칙: 카드 자체는 절대 이동/변형하지 않음. 호버 피드백은
   (1) 테두리 강조 (2) 부드러운 그림자 (3) 내부 이미지 확대로 표현.
   카드 전체가 클릭 가능한 슬롯이므로 호버 시 pointer 커서 (모든 카드 통일).
*/
.card-hover {
  border: 1px solid var(--r-border);
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
  will-change: border-color, box-shadow;
  transform: none !important;  /* 카드 본체는 움직이지 않음 */
  cursor: pointer;             /* 클릭 가능한 카드 — pointer 커서 일관 */
}
.card-hover:hover {
  border-color: var(--r-primary);
  box-shadow: 0 8px 24px -6px rgba(20, 169, 147, 0.20), 0 2px 6px -2px rgba(20, 169, 147, 0.10);
}

/* 카드 내부 메인 이미지 줌 (overflow-hidden 컨테이너에서만 동작) */
.card-image {
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.card-hover:hover .card-image {
  transform: scale(1.06);
}

.surface {
  background-color: var(--r-surface);
  border: 1px solid var(--r-border);
  box-shadow: 0 1px 3px rgba(16, 44, 42, 0.06), 0 8px 24px rgba(16, 44, 42, 0.10);
}

/* Text colors using theme.
 * .text-brand 은 흰 배경 위 가독성을 위해 deep 민트 사용.
 * (브랜드 mint #3CDBC0 자체는 흰 배경 텍스트로 대비가 약함.)
 */
.text-brand { color: var(--r-primary-deep); }
.text-secondary-c { color: var(--r-text-secondary); }
.text-muted-c { color: var(--r-text-muted); }
.bg-brand { background-color: var(--r-primary); }
.bg-brand-light { background-color: var(--r-primary-light); }
.bg-surface { background-color: var(--r-surface); }
.border-default { border-color: var(--r-border); }

/* Grade badges */
.badge-grade-basic {
  background-color: var(--r-grade-basic-bg);
  color: var(--r-grade-basic-text);
}
.badge-grade-premium {
  background-color: var(--r-grade-premium-bg);
  color: var(--r-grade-premium-text);
}
.badge-grade-enterprise {
  background-color: var(--r-grade-enterprise-bg);
  color: var(--r-grade-enterprise-text);
}

/* Input focus */
.input-brand:focus {
  border-color: var(--r-primary);
  box-shadow: 0 0 0 3px var(--r-primary-light);
  outline: none;
}

/* Footer */
.footer-brand {
  background-color: var(--r-footer-bg);
  color: var(--r-footer-text);
  overflow-wrap: anywhere;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  padding-block: 2rem 1.5rem;
  text-align: left;
}
.footer-grid > * {
  min-width: 0;
}
.footer-intro,
.footer-company {
  grid-column: 1 / -1;
}
.footer-logo-crop {
  position: relative;
  width: 7.5rem;
  aspect-ratio: 3693 / 847;
  overflow: hidden;
}
.footer-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 112.84%;
  max-width: none;
  height: auto;
  transform: translate(-50%, -50%);
}
.footer-tagline {
  max-width: 19rem;
  margin-top: 0.75rem;
  line-height: 1.75;
}
.footer-section-title {
  margin-bottom: 1rem;
  line-height: 1.5;
}
.footer-links > a,
.footer-links > div {
  margin-bottom: 0.4rem;
  line-height: 1.65;
}
.footer-links > :last-child {
  margin-bottom: 0;
}
.footer-company {
  border-top: 1px solid color-mix(in srgb, var(--r-footer-text) 15%, transparent);
  padding-top: 1.5rem;
}
.footer-company-name {
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--r-footer-text);
}
.footer-company-info {
  margin-bottom: 0.875rem;
}
.footer-company-info > div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  column-gap: 0.75rem;
  margin-bottom: 0.375rem;
  line-height: 1.75;
}
.footer-company-info dt,
.footer-company-info dd {
  display: block;
}
.footer-company-info dt::after {
  content: none;
}
.footer-company-info dd {
  overflow-wrap: break-word;
}
.footer-contact {
  width: fit-content;
  margin-top: 0.75rem;
}
@media (min-width: 768px) and (max-width: 1023px) {
  .footer-grid {
    grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 1fr));
    column-gap: 2.5rem;
    row-gap: 2.5rem;
    padding-block: 3rem 2.5rem;
  }
  .footer-intro {
    grid-column: auto;
  }
  .footer-company {
    grid-column: 1 / -1;
  }
  .footer-company-info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 2.5rem;
  }
}
@media (min-width: 1024px) {
  .footer-grid {
    grid-template-columns:
      minmax(12rem, 1.15fr)
      minmax(7.5rem, 0.65fr)
      minmax(11rem, 0.95fr)
      minmax(18rem, 1.6fr);
    column-gap: clamp(2rem, 4vw, 4.5rem);
    align-items: start;
    padding-block: 3.75rem 3.25rem;
  }
  .footer-intro,
  .footer-company {
    grid-column: auto;
  }
  .footer-logo-crop {
    width: 8rem;
  }
  .footer-company {
    border-top: 0;
    border-left: 1px solid color-mix(in srgb, var(--r-footer-text) 15%, transparent);
    padding-top: 0;
    padding-left: clamp(1.75rem, 3vw, 3.25rem);
  }
  .footer-company-info > div {
    grid-template-columns: 6.75rem minmax(0, 1fr);
    column-gap: 1rem;
  }
}
/* 모바일 하단 고정 탭바(partials/mobile_tab_bar.html, ~56px + safe-area)가 푸터 하단
   콘텐츠(저작권·사업자정보)를 가리지 않도록 푸터 자체에 하단 여백 확보. md(768px)+ 에선 탭바 없음. */
@media (max-width: 767px) {
  .footer-brand {
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }
  .footer-brand .footer-grid {
    gap: 1.5rem;
  }
  .footer-intro p {
    max-width: none;
  }
  .footer-links h6,
  .footer-company h6 {
    margin-bottom: 0.75rem;
  }
  .footer-links a {
    display: block;
    padding-block: 0.25rem;
    line-height: 1.6;
  }
  .footer-company {
    margin-top: 0.25rem;
  }
  .footer-company-info {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
  }
  .footer-brand .footer-disclosure {
    text-align: left;
    line-height: 1.8;
  }
  .footer-disclosure p + p {
    margin-top: 0.75rem;
  }
}
.footer-brand .footer-muted {
  color: var(--r-footer-muted);
}

/* Marquee (infinite scroll) */
.hot-marquee {
  display: flex;
  gap: 0.75rem;
  animation: marquee 30s linear infinite;
  width: max-content;
}
.hot-marquee:hover {
  animation-play-state: paused;
}
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Hide scrollbar — 모든 브라우저. instagram-식 carousel 등에 사용. */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* Category pills */
.cat-pill {
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.cat-pill:hover {
  border-color: var(--r-primary-muted) !important;
  background-color: var(--r-primary-light);
}

/* Masonry (Pinterest-style) layout */
.masonry {
  columns: 4;
  column-gap: 1.25rem;
}
.masonry > * {
  break-inside: avoid;
  margin-bottom: 1.25rem;
}
@media (max-width: 1024px) { .masonry { columns: 3; } }
@media (max-width: 768px) { .masonry { columns: 2; } }
@media (max-width: 480px) { .masonry { columns: 1; } }

.masonry-3 { columns: 3; column-gap: 1.25rem; }
.masonry-3 > * { break-inside: avoid; margin-bottom: 1.25rem; }
@media (max-width: 768px) { .masonry-3 { columns: 2; } }
@media (max-width: 480px) { .masonry-3 { columns: 1; } }

/* Messages / Toasts — 같은 톤이되 불투명(fixed 오버레이로 콘텐츠 위에 떠도 뒤 콘텐츠가 비치지 않도록). */
.msg-success {
  background-color: color-mix(in srgb, #10b981 18%, white);
  border-color: rgba(16, 185, 129, 0.45);
  color: #065f46;
}
.msg-info {
  background-color: color-mix(in srgb, #3b82f6 18%, white);
  border-color: rgba(59, 130, 246, 0.45);
  color: #1e40af;
}
.msg-warning {
  background-color: color-mix(in srgb, #f59e0b 22%, white);
  border-color: rgba(245, 158, 11, 0.50);
  color: #92400e;
}
.msg-error {
  background-color: color-mix(in srgb, #ef4444 18%, white);
  border-color: rgba(239, 68, 68, 0.45);
  color: #991b1b;
}
.msg-debug {
  background-color: color-mix(in srgb, #9ca3af 20%, white);
  border-color: rgba(156, 163, 175, 0.50);
  color: var(--r-text-secondary);
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeInUp 0.6s ease-out both; }
.animate-fade-in-delay { animation: fadeInUp 0.6s ease-out 0.15s both; }
.animate-fade-in-delay-2 { animation: fadeInUp 0.6s ease-out 0.3s both; }

/* ---------- Tiptap Review Editor ---------- */
.review-editor .ProseMirror {
  outline: none;
  min-height: 120px;
}
.review-editor .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--r-text-muted);
  pointer-events: none;
  height: 0;
}
.review-editor .ProseMirror p { margin: 0 0 0.5em; }
.review-editor .ProseMirror ul,
.review-editor .ProseMirror ol { padding-left: 1.25em; margin: 0.25em 0; }
.review-editor .ProseMirror ul { list-style: disc; }
.review-editor .ProseMirror ol { list-style: decimal; }
.review-editor .ProseMirror blockquote {
  border-left: 3px solid var(--r-border);
  padding-left: 0.75em;
  color: var(--r-text-muted);
  margin: 0.5em 0;
}
.review-editor .ProseMirror img,
.review-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 0.5em 0;
}
.review-content p { margin: 0 0 0.5em; }
.review-content ul,
.review-content ol { padding-left: 1.25em; margin: 0.25em 0; }
.review-content ul { list-style: disc; }
.review-content ol { list-style: decimal; }

/* Alpine x-cloak : FOUC 방지 (Alpine 초기화 전 x-show 표시 깜빡임 억제) */
[x-cloak] { display: none !important; }

/* ─── Loading overlay & inline spinner (APNG 자체 애니메이션 사용) ─── */
.r-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.r-loading-overlay.is-active { pointer-events: all; }

/* 페이지 초기 로드 — Alpine 부트 전에도 오버레이 강제 표시.
   window.load 후 JS 가 html.app-loading 클래스를 제거하면 자연스럽게 사라짐.
   [x-cloak] !important 보다 specificity·source-order 가 모두 높으므로 이김. */
html.app-loading .r-loading-overlay {
  display: flex !important;
  pointer-events: all !important;
  opacity: 1 !important;
}

/* Masonry grid 페이드인 — 첫 layoutComplete 까지 카드 점프 가림 */
.masonry-grid[data-masonry-init] {
  opacity: 0;
  transition: opacity 0.25s ease;
}
.masonry-grid[data-masonry-init].is-ready {
  opacity: 1;
}
/* 순수 CSS 회전 링 스피너 (브랜드 컬러) — 이미지/이모지 없이 단색 링만 회전 */
.r-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid var(--r-primary-light, #ccfbf1);
  border-top-color: var(--r-primary, #0f766e);
  animation: r-spin 0.8s linear infinite;
}
.r-spinner-sm { width: 28px; height: 28px; border-width: 3px; }
.r-spinner-md { width: 44px; height: 44px; border-width: 4px; }
.r-spinner-lg { width: 60px; height: 60px; border-width: 5px; }
@keyframes r-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .r-spinner { animation-duration: 1.6s; }
}
.r-inline-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--r-text-secondary, #6b7280);
  font-size: 12px;
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator { display: inline-flex; }

/* ─── Bento Grid (메인 홈 + 마이페이지 홈 + 향후 다른 페이지 재사용) ───
   row-unit 1px + dense flow 로 카드별 가변 높이. bento-init.js 가 카드 높이 측정 후
   각 셀의 grid-row-end span 계산. lg 이상에서만 활성, 모바일은 자연 흐름. */
@media (min-width: 1024px) {
  .bento-grid {
    grid-auto-rows: 1px;
    grid-auto-flow: row dense;
  }
}

/* 초기 로딩 게이트 — bento-init.js 가 첫 layout 끝낼 때까지 컨테이너 숨김.
   안전망: 3s 후 무조건 노출 (bento-init 가 죽어도 빈 화면 방지). */
.bento-grid {
  opacity: 0;
  transition: opacity 220ms ease;
  animation: bento-fallback-show 0s 3s forwards;
}
.bento-grid.bento-ready {
  opacity: 1;
  animation: none;
}
@keyframes bento-fallback-show {
  to { opacity: 1; }
}

/* 모바일 풀-블리드 — 카드가 화면 끝까지 + 카드 사이 간격 없이 연결.
   .bento-framed (환영·프로필 등 사방 테두리 프레임 카드) 는 예외 — 라운드/좌우 테두리 유지. */
@media (max-width: 639px) {
  .bento-grid .card-hover:not(.bento-framed),
  .bento-grid > .bento-item > .rounded-2xl:not(.bento-framed) {
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
  }
}

/* ─── Header global search (3-column command panel) ─── */
.kbd-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 14px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  font: 600 9px ui-monospace, SFMono-Regular, monospace;
  color: var(--r-text-secondary);
  line-height: 1;
}
.result-item {
  outline: none;
}
.result-item:hover,
.result-item[data-active="true"] {
  background: var(--r-bg);
}
.result-item[data-active="true"] {
  box-shadow: inset 2px 0 0 var(--r-primary);
}
.result-item mark {
  background: var(--r-primary-light);
  color: inherit;
  font-weight: 700;
  padding: 0 1px;
  border-radius: 2px;
}

/* ─── Header search panel padding ───
   가로 스크롤 컨테이너에 `snap-x snap-start` 조합이 있으면, scroll-snap 의 snapport
   기본값이 padding-box 가장자리로 잡히지 않고 카드를 컨테이너 시작점(left=0)에
   강제 정렬해 padding 이 시각적으로 0 처럼 보임. `scroll-padding-*` 으로 snap 정렬
   기준점을 padding 만큼 안쪽으로 옮겨 padding 을 보존한다. */
.gs-pad-x {
  padding-left: 24px;
  padding-right: 24px;
  scroll-padding-left: 24px;
  scroll-padding-right: 24px;
}
.gs-pad-x-sm {
  padding-left: 16px;
  padding-right: 16px;
  scroll-padding-left: 16px;
  scroll-padding-right: 16px;
}
.gs-pad-x-cols {
  padding-left: 12px;
  padding-right: 12px;
  scroll-padding-left: 12px;
  scroll-padding-right: 12px;
}
@media (min-width: 640px) {
  .gs-pad-x {
    padding-left: 28px; padding-right: 28px;
    scroll-padding-left: 28px; scroll-padding-right: 28px;
  }
  .gs-pad-x-cols {
    padding-left: 18px; padding-right: 18px;
    scroll-padding-left: 18px; scroll-padding-right: 18px;
  }
}
.gs-mark {
  background: var(--r-primary-light);
  color: var(--r-primary-deep);
  font-weight: 700;
  padding: 0 1px;
  border-radius: 2px;
}

/* ─── 어두운 배경 위 좋아요 버튼 ───
   content_like_button.html partial 이 white 배경 가정으로 색상 inline 박혀있음 (#ef4444 / muted).
   tile_content_image 의 호버 카운트 배지가 어두운 반투명 배경으로 바뀌면서 그 안의 글자가 안 보임 →
   wrapper 에 .like-on-dark 붙이면 자식 svg / span 색을 브랜드 민트로 강제 override. */
.like-on-dark button svg,
.like-on-dark a svg,
.like-on-dark button span,
.like-on-dark a span {
  color: var(--r-primary) !important;
}
.like-on-dark button:hover,
.like-on-dark a:hover {
  background: transparent !important;
}

/* ─── 디폴트 배경 (사용자가 배경 이미지 등록 안 했을 때) ───
   부드러운 radial blob 3-4개 + 그라데이션 베이스. 너무 강하지 않게, 스며드는 느낌.
   seed → 0..3 인덱스로 variant 결정 (avatar_idx filter 와 결합). */
.default-bg-0 {
  background:
    radial-gradient(circle at 25% 30%, rgba(60, 219, 192, 0.22) 0%, transparent 38%),
    radial-gradient(circle at 75% 65%, rgba(201, 191, 231, 0.18) 0%, transparent 42%),
    radial-gradient(circle at 50% 92%, rgba(180, 211, 178, 0.16) 0%, transparent 38%),
    linear-gradient(135deg, var(--r-primary-light) 0%, #F0FAF6 100%);
}
.default-bg-1 {
  background:
    radial-gradient(circle at 18% 22%, rgba(201, 191, 231, 0.25) 0%, transparent 40%),
    radial-gradient(circle at 85% 70%, rgba(60, 219, 192, 0.18) 0%, transparent 42%),
    radial-gradient(circle at 40% 95%, rgba(180, 211, 178, 0.14) 0%, transparent 38%),
    linear-gradient(135deg, #F0F5FA 0%, var(--r-primary-light) 100%);
}
.default-bg-2 {
  background:
    radial-gradient(circle at 30% 40%, rgba(180, 211, 178, 0.22) 0%, transparent 40%),
    radial-gradient(circle at 70% 25%, rgba(60, 219, 192, 0.18) 0%, transparent 38%),
    radial-gradient(circle at 60% 90%, rgba(201, 191, 231, 0.14) 0%, transparent 38%),
    linear-gradient(135deg, var(--r-secondary-light) 0%, var(--r-primary-light) 100%);
}
.default-bg-3 {
  background:
    radial-gradient(circle at 22% 75%, rgba(60, 219, 192, 0.28) 0%, transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(60, 219, 192, 0.14) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(201, 191, 231, 0.10) 0%, transparent 50%),
    linear-gradient(135deg, var(--r-primary-light) 0%, #E0F5EE 100%);
}

/* ─── 디폴트 아바타 (사용자가 프로필 이미지 등록 안 했을 때) ───
   브랜드 팔레트 6 variant. seed (user pk 등) 로 deterministic 선택.
   font-weight·size 는 호출자 클래스에서 추가 지정. */
.default-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.01em;
  user-select: none;
}
.default-avatar-0 { background: linear-gradient(135deg, #3CDBC0 0%, #14A993 100%); color: #FFFFFF; }
.default-avatar-1 { background: linear-gradient(135deg, #C9BFE7 0%, #8B7BC8 100%); color: #FFFFFF; }
.default-avatar-2 { background: linear-gradient(135deg, #B4D3B2 0%, #7DA37B 100%); color: #FFFFFF; }
.default-avatar-3 { background: linear-gradient(135deg, #14A993 0%, #102C2A 100%); color: #DBF6EE; }
.default-avatar-4 { background: linear-gradient(135deg, #DBF6EE 0%, #92E1D0 100%); color: #14A993; }
.default-avatar-5 { background: linear-gradient(135deg, #102C2A 0%, #4A5F5D 100%); color: #3CDBC0; }

/* ─── 프로필 타일 배경 (로그인 사용자 home 프로필 카드) ───
   기존 솔리드 민트 + radial blob 3개로 스며드는 깊이감. 너무 강하지 않은 톤. */
.tile-profile-bg {
  background:
    radial-gradient(circle at 20% 15%, rgba(20, 169, 147, 0.30) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(201, 191, 231, 0.22) 0%, transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(180, 211, 178, 0.20) 0%, transparent 50%),
    linear-gradient(135deg, rgba(60, 219, 192, 0.65) 0%, rgba(146, 225, 208, 0.55) 100%);
}

/* ─────────────────────────────────────────────
 * Global Search — 필터 pill / divider / 시트 / 토글 / 카테고리 pill
 * ─────────────────────────────────────────────
 * 입력창 내부 첫 자리에 박히는 필터 pill 은 활성/비활성에 따라
 * gs-filter-pill--active / --idle 클래스로 색만 바뀐다.
 * 모바일은 바텀시트(.gs-filter-sheet), 데스크탑은 패널 상단 popover. */

/* 필터 pill (input 내부) */
.gs-filter-pill {
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 120ms, color 120ms, box-shadow 120ms;
}
.gs-filter-pill--idle {
  background: transparent;
  color: var(--r-text-secondary);
}
.gs-filter-pill--idle:hover {
  background: var(--r-primary-light);
  color: var(--r-primary-deep);
}
.gs-filter-pill--active {
  background: var(--r-primary-deep);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(20, 169, 147, 0.45);
}
.gs-filter-pill--active:hover {
  opacity: 0.92;
}

/* pill ↔ chips/input 사이 세로 divider */
.gs-pill-divider {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: var(--r-border);
  flex-shrink: 0;
  margin: 0 4px 0 2px;
}

/* ─── 필터 시트 (검색 패널과 독립) ───
 * 데스크탑: 검색 input 바로 아래 fixed popover, 살짝 backdrop.
 * 모바일: viewport 하단 fixed 바텀시트 + 어두운 fullscreen backdrop. */
.gs-filter-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: auto;
  /* 데스크탑은 backdrop 없는 듯한 살짝의 dim */
  background: rgba(15, 23, 42, 0.06);
}

/* 시트 본체 — 데스크탑은 검색바 아래 popover, 모바일은 바닥 시트 */
.gs-filter-sheet__body {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: min(36rem, calc(100vw - 24px));
  background: var(--r-surface);
  border-radius: 16px;
  border: 1px solid var(--r-border);
  box-shadow: 0 18px 48px -12px rgba(15, 23, 42, 0.25);
  z-index: 2;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

@media (max-width: 767px) {
  .gs-filter-sheet {
    background: rgba(15, 23, 42, 0.45);
  }
  .gs-filter-sheet__body {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    border-radius: 20px 20px 0 0;
    border: none;
    box-shadow: 0 -8px 24px -8px rgba(15, 23, 42, 0.3);
    max-height: 70vh;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* 시트 transition (Alpine x-transition: 클래스 매핑) */
.gs-fs-enter { transition: transform 160ms ease-out, opacity 160ms ease-out; }
.gs-fs-enter-start { transform: translate(-50%, -8px); opacity: 0; }
.gs-fs-enter-end { transform: translate(-50%, 0); opacity: 1; }
@media (max-width: 767px) {
  .gs-fs-enter-start { transform: translateY(100%); }
  .gs-fs-enter-end { transform: translateY(0); }
}

/* 카테고리 pill — 시트 내부 그리드 */
.gs-cat-pill {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--r-bg);
  color: var(--r-text-secondary);
  border: 1px solid var(--r-border);
  transition: background-color 100ms, color 100ms, border-color 100ms;
  cursor: pointer;
  white-space: nowrap;
}
.gs-cat-pill:hover {
  background: var(--r-primary-light);
  color: var(--r-primary-deep);
  border-color: var(--r-primary-muted);
}
.gs-cat-pill--on {
  background: var(--r-primary-deep);
  color: #ffffff;
  border-color: var(--r-primary-deep);
  box-shadow: 0 1px 3px rgba(20, 169, 147, 0.35);
}
.gs-cat-pill--on:hover {
  background: var(--r-primary-deep);
  color: #ffffff;
  opacity: 0.92;
}

/* 토글 스위치 — 시트 "팔로우 중" 옵션 */
.gs-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--r-border);
  border: none;
  cursor: pointer;
  transition: background-color 140ms;
  flex-shrink: 0;
}
.gs-toggle--on {
  background: var(--r-primary);
}
.gs-toggle__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 140ms;
}
.gs-toggle--on .gs-toggle__knob {
  transform: translateX(18px);
}

/* ─────────────────────────────────────────────
 * Profile tile — 최근 본 / 찜한 strip
 * ─────────────────────────────────────────────
 * 작은 정사각 카드. 호버 시 상품명이 카드 아래에 floating tooltip 처럼 노출.
 * native title 보다 빠르고 디자인 일관. */
.recent-card {
  cursor: pointer;
}
.recent-card__name {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.recent-card__name::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -4px;
  border: 4px solid transparent;
  border-top-color: rgba(15, 23, 42, 0.92);
}
.recent-card:hover .recent-card__name,
.recent-card:focus .recent-card__name {
  opacity: 1;
}

/* 모바일 — 호버 없음. 작은 화면에서는 title attribute fallback (브라우저 기본).
   tooltip 보다 native title 이 모바일 long-press 에서도 일관. */
@media (hover: none) {
  .recent-card__name { display: none; }
}

/* Bento 영역 swap 중 — 살짝 페이드해서 깜빡임 없이 결과 갱신 시각화 */
#bento-area.bento-swapping {
  transition: opacity 120ms ease-out;
  opacity: 0.55;
  pointer-events: none;
}

/* 상품 썸네일 품절 표시 — 살 수 있는 판매 단위가 하나도 없을 때만 (Product.is_sold_out).
   일부 옵션만 품절이면 붙지 않는다. 공용: products/components/product_card.html · pages/_shop_product_card.html */
.sold-out-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: color-mix(in srgb, var(--r-text) 45%, transparent);
}
.sold-out-overlay > span {
  padding: 0.25rem 0.85rem;
  border-radius: 9999px;
  background: var(--r-surface);
  color: var(--r-text);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
