/* ==========================================================================
   ItemLog (아이템로그) - Optimized Global Stylesheet
   ========================================================================== */

/* 1. Root Variables & Theme System */
:root {
  --bg: #FAF9F7;
  --card: #FFFFFF;
  --ink: #191919;
  --sub: #707070;
  --accent: #E8862B;
  --accent-hover: #D0721B;
  --accent-text: #FFFFFF;
  --accent2: #FFF3E8;
  --line: #EAE7E1;
  --radius: 8px;
  --radius-sm: 6px;
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --card: #1E1E1E;
    --ink: #F3F3F3;
    --sub: #A0A0A0;
    --accent: #FF9436;
    --accent-hover: #FF8014;
    --accent-text: #000000; /* 다크모드 주황 배경 위 명도대비 4.5:1 이상 확보 */
    --accent2: #2C1E14;
    --line: #2A2A2A;
  }
}

:root[data-theme="dark"] {
  --bg: #121212;
  --card: #1E1E1E;
  --ink: #F3F3F3;
  --sub: #A0A0A0;
  --accent: #FF9436;
  --accent-hover: #FF8014;
  --accent-text: #000000;
  --accent2: #2C1E14;
  --line: #2A2A2A;
}

/* 2. Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  overflow-x: hidden;
}

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.4;
  letter-spacing: -0.025em;
  word-break: keep-all;
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* 3. Outer Layout Wrap */
.wrap {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 8px 12px 40px;
}

@media (min-width: 768px) {
  .wrap {
    padding: 20px 16px 60px;
  }
}

/* 4. Compact Hero Header (첫 화면에서 카드가 노출되도록 최적화) */
.hero {
  text-align: center;
  padding: 12px 0 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.hero img {
  width: 80px;
  height: auto;
  margin: 0 auto 8px;
  mix-blend-mode: multiply; /* 흰 바탕 네모 방지 */
}

:root[data-theme="dark"] .hero img,
:root[data-theme="dark"] .top img {
  mix-blend-mode: normal;
  background: #FFFFFF;
  padding: 4px;
  border-radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero img,
  :root:not([data-theme="light"]) .top img {
    mix-blend-mode: normal;
    background: #FFFFFF;
    padding: 4px;
    border-radius: 8px;
  }
}

.hero h1 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.hero h1 b {
  color: var(--accent);
  font-weight: 700;
}

.hero p {
  font-size: 11px;
  color: var(--sub);
  margin-bottom: 12px;
}

.chips {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.chips a {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--sub);
  transition: all 0.15s ease;
}

.chips a.main {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* Links Top Header */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-top: 8px;
}

.top img {
  width: 44px;
  height: auto;
}

.top h1 {
  font-size: 16px;
  font-weight: 700;
}

.top p {
  font-size: 11.5px;
  color: var(--sub);
}

.search {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font-size: 12.5px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  margin-bottom: 16px;
  outline: none;
  -webkit-appearance: none;
}

.search:focus {
  border-color: var(--accent);
}

/* 5. Section Header Visual Enhancement */
section {
  margin-bottom: 28px;
}

.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 2px;
}

.sec-head h2 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sec-head h2 span {
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
}

.sec-head a {
  font-size: 12px;
  color: var(--sub);
  font-weight: 600;
}

/* 6. Strict Grid Layout System (모바일 3칸 / 태블릿 5칸 / PC 6칸) */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 6px;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px 8px;
  }
}

@media (min-width: 800px) {
  .grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 14px 10px;
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 16px 12px;
  }
}

/* 7. Unified & Standardized Card Component */
.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px;
  height: 100%;
}

/* 3:4 Aspect Ratio Thumbnail */
.thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: calc(var(--radius) - 3px);
  overflow: hidden;
  background-color: var(--line);
  display: block;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Zoom YouTube Horizontal Thumbnails to Remove Black Letterboxing */
.thumb img.yt {
  transform: scale(1.34);
  transform-origin: center center;
}

.new {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 8.5px;
  font-weight: 800;
  padding: 1.5px 4px;
  border-radius: 3px;
  line-height: 1;
  z-index: 2;
  letter-spacing: 0.02em;
}

/* Title Typography & Height Normalization */
.card h3 {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  height: 2.7em; /* 고정 2줄 높이 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
  word-break: break-all;
}

/* Product List Page Title Override */
body.list .card h3 {
  height: 1.35em; /* 고정 1줄 높이 */
  -webkit-line-clamp: 1;
}

/* Buttons & Secondary Action Fixed to Bottom */
.card .btn {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 26px;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
}

.card .btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.card .watch {
  display: block;
  text-align: center;
  font-size: 9.5px;
  color: var(--sub);
  margin-top: 4px;
  height: 13px; /* 높이 고정으로 레이아웃 흔들림 방지 */
  line-height: 13px;
  text-decoration: underline;
  flex-shrink: 0;
}

.card .watch.off {
  opacity: 0.35;
  text-decoration: none;
}

/* 8. Footer & Extra Notes */
.note {
  font-size: 10.5px;
  color: var(--sub);
  text-align: center;
  margin-top: 16px;
  opacity: 0.8;
}

footer {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 28px;
  font-size: 11px;
  color: var(--sub);
  text-align: center;
}

footer a {
  text-decoration: underline;
  margin-left: 4px;
}

/* 9. Hover System (Desktop PC Only) */
@media (hover: hover) {
  .chips a:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
  .card:hover {
    border-color: var(--sub);
  }
  .card .btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
  }
  .card .btn.ghost:hover {
    background: var(--accent2);
  }
}

/* 10-09 사용자 "여기 너무 작아졌다, 더 키워도 될 것 같아" → 히어로 키움 */
.hero { padding: 28px 0 24px; }
.hero img { width: 120px; border-radius: 24px; margin-bottom: 14px; }
.hero h1 { font-size: clamp(20px, 4.6vw, 30px); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 8px; }
.hero p { font-size: clamp(13px, 2.6vw, 15.5px); max-width: 560px; margin: 0 auto 18px; line-height: 1.6; }
.chips { gap: 8px; }
.chips a { font-size: clamp(12.5px, 2.4vw, 14.5px); padding: 8px 16px; }

/* 10-09 사용자 "전체 제품, 못 보고 지나칠 수 있다" → 알약 버튼 + 섹션 아래 큰 버튼 */
.sec-head a.pill { background: var(--accent); color: #fff; padding: 7px 14px; border-radius: 999px; font-weight: 800; font-size: 14px; text-decoration: none; box-shadow: 0 2px 10px rgba(232,134,43,.35); }
.more-btn { display: block; text-align: center; margin: 16px auto 4px; max-width: 520px; padding: 14px 18px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 800; font-size: clamp(15px, 3.6vw, 17px); text-decoration: none; box-shadow: 0 4px 16px rgba(232,134,43,.35); animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 85%, 100% { transform: translateY(0); } 92% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .more-btn { animation: none; } }
@media (hover: hover) { .more-btn:hover, .sec-head a.pill:hover { filter: brightness(1.08); } }
