/* ========================================
   농수산식품가격정보 - 레이아웃
   ======================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ---- 헤더 (로고 + 네비 한 줄) ---- */
.site-header {
  background-color: var(--accent-primary);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 calc((100% - var(--max-width)) / 2 + 16px);
  position: sticky;
  top: 0;
  z-index: 200;
}

.site-header .logo {
  display: flex;
  align-items: center;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  margin-right: 32px;
  white-space: nowrap;
}
.site-header .logo-icon {
  flex-shrink: 0;
  margin-right: 6px;
  background: #fff;
  border-radius: 6px;
}
.site-header .logo span {
  color: var(--accent-light);
  font-weight: 400;
}

/* 네비게이션 (헤더 내부) */
.site-nav {
  display: flex;
  gap: 2px;
  height: 100%;
}

.site-nav a {
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.site-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.site-nav a.active {
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--accent-light);
}

.header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

#item-search {
  height: 30px;
  width: 160px;
  padding: 0 14px;
  font-size: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.12);
  color: #fff;
  outline: none;
}
#item-search::placeholder {
  color: rgba(255,255,255,.45);
}
#item-search:focus {
  background: rgba(255,255,255,.2);
}

.theme-toggle {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
}
.theme-toggle:hover {
  background: rgba(255,255,255,.2);
}

/* ---- 검색 드롭다운 ---- */
.search-wrap {
  position: relative;
}
.search-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  z-index: 300;
  min-width: 200px;
}
.search-dropdown.open {
  display: block;
}
.search-dropdown li {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-dropdown li:hover,
.search-dropdown li.active {
  background: var(--accent-bg);
  color: var(--accent-primary);
}
.search-dropdown li .sd-cat {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
}

/* ---- 히어로 ---- */
.hero {
  background: linear-gradient(135deg, #005b53 0%, #008577 50%, #00a68c 100%);
  padding: 28px 24px 24px;
  color: #fff;
}
[data-theme="dark"] .site-header {
  background-color: #111816;
}
[data-theme="dark"] .site-nav a {
  color: rgba(255,255,255,.5);
}
[data-theme="dark"] .site-nav a:hover {
  color: rgba(255,255,255,.8);
  background: rgba(255,255,255,.05);
}
[data-theme="dark"] .site-nav a.active {
  color: #4dd9c0;
}
[data-theme="dark"] #item-search {
  background: rgba(255,255,255,.08);
}
[data-theme="dark"] .theme-toggle {
  background: rgba(255,255,255,.08);
}
[data-theme="dark"] .hero {
  background: linear-gradient(135deg, #0a2e2a 0%, #0d3d38 50%, #104a44 100%);
}
[data-theme="dark"] .hero-item {
  background: rgba(255,255,255,.05);
}
[data-theme="dark"] .hero-stat {
  background: rgba(255,255,255,.06);
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.hero-text h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.hero-text p {
  font-size: 13px;
  color: rgba(255,255,255,.7);
  margin-top: 3px;
}

.hero-stats {
  display: flex;
  gap: 20px;
}

.hero-stat {
  text-align: center;
  background: rgba(255,255,255,.1);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
}
.hero-stat .num {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-light);
}
.hero-stat .label {
  font-size: 10px;
  color: rgba(255,255,255,.6);
  margin-top: 2px;
}

/* 히어로 주요 품목 카드 */
.hero-items {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.hero-item {
  background: rgba(255,255,255,.08);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.hero-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.hero-item-name {
  font-size: 13px;
  font-weight: 600;
}
.hero-item-change {
  font-size: 12px;
  font-weight: 700;
}
.hero-item-change.up { color: #ff8a80; }
.hero-item-change.down { color: #82b1ff; }
.hero-item-change.flat, .hero-item-change.steady { color: rgba(255,255,255,.4); }
.hero-item-price {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}
.hero-item-sub {
  font-size: 10px;
  font-weight: 400;
  color: rgba(255,255,255,.5);
}
.hero-item-unit {
  font-size: 10px;
  color: rgba(255,255,255,.5);
}
.spark {
  display: block;
}

/* ---- 메인 콘텐츠 ---- */
.main-content {
  max-width: var(--max-width);
  margin: 24px auto;
  padding: 0 16px;
}

/* ---- 2열 레이아웃 ---- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.row-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ---- 푸터 ---- */
.site-footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 40px;
}
.site-footer a {
  color: var(--text-secondary);
}

/* ---- 스크롤 투 탑 ---- */
#btn-scroll-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 50;
}
#btn-scroll-top.show {
  display: flex;
}

/* ---- 햄버거 메뉴 (모바일) ---- */
.nav-toggle {
  display: none;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nav-toggle:hover {
  background: rgba(255,255,255,.2);
}

.mobile-nav {
  display: none;
  background: var(--accent-primary);
  padding: 8px 16px 12px;
}
[data-theme="dark"] .mobile-nav {
  background: #111816;
}
.mobile-nav.open {
  display: flex;
  flex-direction: column;
}
.mobile-nav a {
  color: rgba(255,255,255,.75);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.mobile-nav a:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.mobile-nav a.active {
  color: var(--accent-light);
  font-weight: 600;
}

/* ---- 반응형 ---- */
@media (max-width: 1024px) {
  .two-col,
  .row-2-1 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .hero-items {
    grid-template-columns: repeat(3, 1fr);
  }
  .hero-top {
    flex-direction: column;
    gap: 12px;
  }
  .cat-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 0 12px;
  }
  .site-header .logo {
    font-size: 14px;
    margin-right: 0;
  }
  #item-search {
    width: 90px;
    font-size: 11px;
    padding: 0 8px;
  }
  .site-nav {
    display: none;
  }
  .nav-toggle {
    display: flex;
  }
  .main-content {
    padding: 0 12px;
    margin: 12px auto;
  }
  .hero {
    padding: 20px 12px;
    overflow-x: hidden;
  }
  .hero-text h1 {
    font-size: 20px;
  }
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
  }
  .hero-stat {
    padding: 8px 6px;
  }
  .hero-stat .num {
    font-size: 20px;
  }
  .hero-items {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  html {
    font-size: 15px;
  }
}
