/* ============================================================
   KODI — MZ 세대 타깃 재설계
   main.css: Design Tokens · Reset · Layout · Utilities
   Dark-first · 고채도 포인트 · 트렌디 인플루언서 감성
   ============================================================ */

/* ── Fonts ── */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css');
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Mono:wght@400;500&display=swap');

/* ── Design Tokens ── */
:root {
  /* MZ세대 타깃 감각적인 Sand-Beige & Off-White 라이트 테마 */
  --void:      #F4F3EF; /* 아크네 스튜디오 스타일의 감각적인 페이퍼 배경 */
  --surface:   #FFFFFF; /* 미니멀 화이트 */
  --surface-2: #EAE9E4; /* 카드 내부 및 인풋 서브 배경 */
  --border:    #DDDCD6; /* 얇고 세련된 경계선 */
  --text-1:    #1F1F1E; /* 부드러운 차콜 차원의 메인 텍스트 */
  --text-2:    #65655E; /* 서브 텍스트 */
  --text-3:    #929289; /* 캡션 및 디테일 설명 */

  /* 트렌디 팝 컬러 */
  --hot:       #FF1493; /* 팝 핑크 */
  --electric:  #1F51FF; /* 네온 일렉트릭 블루 */
  --neon:      #39FF14; /* 애시드 네온 그린 */
  --warm:      #FF5F1F; /* 활기찬 팝 오렌지 */

  /* Legacy aliases (JS 호환) */
  --bg:          var(--void);
  --bg-2:        var(--surface);
  --ink:         var(--text-1);
  --ink-2:       var(--text-2);
  --ink-3:       var(--text-3);
  --paper:       var(--void);
  --paper-2:     var(--surface);
  --line:        var(--border);
  --accent:      var(--electric);
  --accent-bg:   rgba(31,81,255,0.08);


  /* 폰트 */
  --font-display: 'Bebas Neue', 'Impact', sans-serif;
  --font-sans:    'Pretendard', system-ui, sans-serif;
  --font-mono:    'DM Mono', monospace;

  /* Legacy aliases */
  --font-serif: var(--font-display);
  --font-ui:    var(--font-sans);

  /* 타입 스케일 */
  --text-xs:   0.6875rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-md:   1.0625rem;
  --text-lg:   1.25rem;
  --text-xl:   1.5rem;
  --text-2xl:  2rem;
  --text-3xl:  2.75rem;
  --text-hero: 3.5rem;

  /* 간격 */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* 모서리 */
  --radius-sm:   6px;
  --radius-md:   6px;
  --radius-lg:   6px;
  --radius-xl:   6px;
  --radius-full: 99px;
  --radius-input: 6px;

  /* 그림자 없음 — glow만 */
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --shadow-xl: none;

  /* glow 효과 */
  --glow-hot:      0 0 20px rgba(255,45,85,0.4);
  --glow-electric: 0 0 20px rgba(124,58,237,0.45);
  --glow-neon:     0 0 20px rgba(0,229,160,0.4);

  /* 모션 */
  --ease-out:    cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in:     cubic-bezier(0.4, 0, 1, 1);
  --duration-fast:   150ms;
  --duration-base:   200ms;
  --duration-slow:   300ms;
  --duration-slower: 400ms;

  /* 레이아웃 */
  --app-max-width:     430px;
  --header-height:     52px;
  --bottom-nav-height: 52px;
  --safe-bottom:       env(safe-area-inset-bottom, 0px);
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-1);
  background-color: var(--void);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video {
  display: block;
  max-width: 100%;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── 스크롤바 숨김 ── */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* ── Selection ── */
::selection {
  background: rgba(124,58,237,0.3);
  color: var(--text-1);
}

/* ── Focus ── */
:focus-visible {
  outline: 2px solid var(--electric);
  outline-offset: 2px;
}

/* ── App Shell ── */
#app {
  position: relative;
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100dvh;
  background-color: var(--void);
  overflow: hidden;
}

@media (min-width: 1200px) {
  #app { overflow: visible; }
}

@media (min-width: 431px) and (max-width: 767px) {
  body { background-color: #000; }
  #app { box-shadow: 0 0 60px rgba(124,58,237,0.15); }
}

/* ── Screen Layer ── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
  will-change: opacity, transform;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* ── Scroll Area ── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Animations ── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

@keyframes floatBubble {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(6px); }
}

@keyframes bounceIn {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes koddiPulse {
  0%   { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.8); opacity: 0; }
}

@keyframes hotGlow {
  0%, 100% { box-shadow: var(--glow-hot); }
  50%       { box-shadow: 0 0 32px rgba(255,45,85,0.7); }
}

@keyframes scrollTicker {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes neonFlicker {
  0%, 100% { opacity: 1; }
  92%       { opacity: 1; }
  93%       { opacity: 0.6; }
  94%       { opacity: 1; }
  96%       { opacity: 0.8; }
  97%       { opacity: 1; }
}

/* ── Stagger Animation ── */
.stagger > * {
  opacity: 0;
  animation: fadeSlideUp var(--duration-slow) var(--ease-out) both;
}
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }
.stagger > *:nth-child(7) { animation-delay: 360ms; }
.stagger > *:nth-child(8) { animation-delay: 420ms; }

/* ── Typography Utilities ── */
.font-display { font-family: var(--font-display); }
.font-serif   { font-family: var(--font-display); }
.font-sans    { font-family: var(--font-sans); }
.font-mono    { font-family: var(--font-mono); }

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md   { font-size: var(--text-md); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }
.text-3xl  { font-size: var(--text-3xl); }

.text-1       { color: var(--text-1); }
.text-2       { color: var(--text-2); }
.text-3       { color: var(--text-3); }
.text-hot     { color: var(--hot); }
.text-electric{ color: var(--electric); }
.text-neon    { color: var(--neon); }
.text-accent  { color: var(--electric); }

.font-light    { font-weight: 300; }
.font-regular  { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* ── Spacing Utilities ── */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* ── Flex Utilities ── */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.flex-wrap       { flex-wrap: wrap; }
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* ── Card Grid ── */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Section Header ── */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding: 0 var(--space-5);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--text-1);
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.section-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-3);
  font-weight: 400;
  letter-spacing: 0.04em;
  transition: color var(--duration-fast) var(--ease-out);
}

.section-link:hover { color: var(--hot); }

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-6) 0;
}

/* ── Misc Utilities ── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.spinner {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border);
  border-top-color: var(--electric);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── OR Divider ── */
.or-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}
.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.or-divider span {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Chip wrap ── */
.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ── h-scroll ── */
.h-scroll {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  -webkit-overflow-scrolling: touch;
}

/* ── Tag cloud ── */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  background: var(--hot);
  color: #fff;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  padding: 0 4px;
}

@media (max-width: 360px) {
  :root { --text-base: 0.875rem; }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (768px+)
══════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  :root {
    --app-max-width: 100%;
  }

  body { background-color: var(--void); }

  #app {
    max-width: 100%;
    box-shadow: none;
  }

  .card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
  }

  .editorial-pair {
    grid-column: 1 / -1;
  }

  .editorial-grid .dress-card:nth-child(1) {
    grid-column: 1 / -1;
  }

  .editorial-grid .dress-card.full-card {
    grid-column: 1 / -1;
  }

  .filter-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  .filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: 0;
  }

  .filter-group .filter-label {
    margin-bottom: 0;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — DESKTOP (1200px+)
══════════════════════════════════════════════════════════ */
@media (min-width: 1200px) {
  :root {
    --sidebar-width: 220px;
  }

  #app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .app-header {
    display: none;
  }

  .sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100dvh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: var(--space-8) var(--space-5);
    z-index: 100;
    overflow-y: auto;
  }

  .screen {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    width: calc(100% - var(--sidebar-width));
    padding-top: 0;
    padding-bottom: 0;
    min-height: 100dvh;
    height: 100dvh;
    overflow-y: auto;
    inset-block: 0;
  }

  .screen.active {
    opacity: 1;
    transform: none;
    pointer-events: all;
  }

  .bottom-nav {
    display: none;
  }

  .koddi-bubble {
    right: var(--space-4);
    bottom: var(--space-6);
  }

  .modal-overlay {
    left: var(--sidebar-width);
    max-width: none;
    width: calc(100% - var(--sidebar-width));
    transform: none;
  }

  .onboarding-overlay {
    left: var(--sidebar-width);
    max-width: none;
    width: calc(100% - var(--sidebar-width));
    transform: none;
  }

  .toast-container {
    left: calc(var(--sidebar-width) + 50%);
    transform: translateX(-50%);
    max-width: 480px;
  }

  #screen-home .editorial-grid.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  #screen-home .editorial-grid .dress-card:nth-child(1) {
    grid-column: 1 / -1;
  }

  #screen-home .editorial-pair {
    grid-column: auto;
    display: contents;
  }

  #screen-home .editorial-pair .dress-card {
    grid-column: auto;
  }

  #screen-home .editorial-pair .dress-card .dress-card-img {
    aspect-ratio: 3/4;
  }

  #screen-home .editorial-grid .dress-card.full-card {
    grid-column: 1 / -1;
  }

  #explore-card-grid.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  #explore-card-grid .dress-card {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  #explore-card-grid .dress-card:nth-child(3n) {
    border-right: none;
  }

  #explore-card-grid .dress-card .dress-card-img {
    aspect-ratio: 2/3;
  }

  #screen-profile .scroll-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  #screen-profile .profile-hero {
    grid-column: 1 / -1;
  }

  #screen-profile .danger-zone {
    grid-column: 1 / -1;
  }

  #screen-chat {
    display: flex;
    flex-direction: column;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .filter-section {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: flex-start;
  }

  .filter-group {
    margin-bottom: 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-group .filter-label {
    margin-bottom: var(--space-2);
  }
}
