/* Base reset */
* { box-sizing: border-box; }

html, body {
  overflow-x: hidden; /* Prevent horizontal scroll on the page */
}

body {
  margin: 0;
  background: var(--bg-gradient);
  color: var(--text);
}

main {
  /* 내부 스크롤 제거: 문서(body)만 스크롤 */
}

/* Colors - 기본 변수 (계절 테마로 오버라이드됨) */
:root {
  --text: #1a1a1a;
  --bg: #fafbfc;
  --bg-gradient: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  --primary: #3b82f6; /* 기본 파랑 */
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  --accent: #ef4444; /* 기본 레드 */
  --accent-gradient: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  --muted: #e9ecef;
  --glass-bg: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(255, 255, 255, 0.3);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.16);
  --peek: 12px;
  --border-radius: 20px;
  --border-radius-sm: 16px;
  /* Dynamic layout metrics (set from JS) */
  --header-h: 0px;
  --controls-h: 0px;
}

/* Seasonal Themes - 변수만 바꿔 전체 톤을 전환 */
body.theme-spring {
  --bg-gradient: linear-gradient(180deg, #f4fbf6 0%, #e9f7ee 100%);
  --primary: #2e7d32; /* 신록 그린 */
  --primary-gradient: linear-gradient(135deg, #43a047 0%, #2e7d32 100%);
  --accent: #ff6f61; /* 봄꽃 코랄 */
  --accent-gradient: linear-gradient(135deg, #ff8a75 0%, #ff6f61 100%);
}

body.theme-summer {
  --bg-gradient: linear-gradient(180deg, #eaf7ff 0%, #dff3ff 100%);
  --primary: #0284c7; /* 청량 블루 */
  --primary-gradient: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  --accent: #10b981; /* 민트 그린 */
  --accent-gradient: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

body.theme-autumn {
  --bg-gradient: linear-gradient(180deg, #fff5e7 0%, #ffe9cc 100%);
  --primary: #d97706; /* 호박 오렌지 */
  --primary-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --accent: #b45309; /* 카라멜 브라운 */
  --accent-gradient: linear-gradient(135deg, #f97316 0%, #b45309 100%);
}

body.theme-winter {
  --bg-gradient: linear-gradient(180deg, #f7fbff 0%, #eef4ff 100%);
  --primary: #475569; /* 차분한 슬레이트 */
  --primary-gradient: linear-gradient(135deg, #64748b 0%, #475569 100%);
  --accent: #0ea5e9; /* 차가운 스카이 */
  --accent-gradient: linear-gradient(135deg, #7dd3fc 0%, #0ea5e9 100%);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,1px,1px);
  white-space: nowrap; border: 0;
}

.app-header {
  padding: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.app-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-gradient);
  border-radius: 0 0 10px 10px;
}

.header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 800;
}
.brand__primary {
  font-size: 1.2rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand__secondary {
  font-size: 1.2rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.header-search { flex: 1; }

.today-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.today-button:hover {
  background: var(--primary-gradient);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.today-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.today-button:disabled {
  background: var(--muted);
  color: #999;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.today-icon {
  transition: transform 0.2s ease;
}

.today-button:not(:disabled):hover .today-icon {
  transform: scale(1.1);
}

.period-label {
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.4rem;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
}

/* Vertical layout styles */
.carousel {
  padding: calc(var(--header-offset, 0px) + 12px) 20px 20px;
}

.carousel__container {
  /* Remove horizontal scroll styles */
}

.carousel__track {
  display: block; /* Change from flex to block for vertical layout */
}

/* Period header styles */
.period-header {
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.4rem;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin: 32px 0 16px;
  padding: 16px 0;
  border-bottom: 2px solid var(--muted);
}

.period-header:first-child {
  margin-top: 16px;
}

/* Period grid container */
.period-grid {
  margin-bottom: 24px;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

.empty { text-align: center; padding: 24px; color: #666; display: none; }

/* Card */
.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent; /* Android tap highlight 제거 */
  -webkit-touch-callout: none;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.6s ease;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.95);
  }
  .card:hover::before { left: 100%; }
}
.card:focus,
.card:focus-visible,
.card:focus-within {
  outline: none !important;
  border: 1px solid var(--glass-border) !important;
}

.thumb {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  box-shadow: var(--shadow-md);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.thumb::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(0, 85, 164, 0.1) 0%, rgba(214, 40, 40, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover .thumb {
    transform: scale(1.1) rotate(2deg);
    box-shadow: var(--shadow-lg);
  }
  .card:hover .thumb::after { opacity: 1; }
}

.thumb .photo { width: 100%; height: 100%; object-fit: cover; display: block; }

.title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
}

/* 모달 스타일 */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal[aria-hidden="false"] {
  opacity: 1; visibility: visible;
}
.modal__backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.modal__content {
  position: relative;
  background: #fff;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal[aria-hidden="false"] .modal__content {
  transform: scale(1) translateY(0);
}
.modal__close {
  position: absolute;
  top: 12px; right: 16px;
  background: none; border: none;
  font-size: 24px; color: #666;
  cursor: pointer; z-index: 1;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}
.modal__close:hover {
  background: #f5f5f5;
  color: #333;
}
.modal__body {
  display: flex;
  padding: 24px;
  gap: 16px;
}
.modal__image {
  flex: 0 0 auto;
}
.modal__image img {
  width: 80px; height: 80px;
  border-radius: var(--border-radius-sm);
  object-fit: cover;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}
.modal__info {
  flex: 1;
  min-width: 0;
}
.modal__name {
  margin: 0 0 12px 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.modal__description {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #555;
}

/* 손질법과 보관법 섹션 */
.modal__preparation,
.modal__storage {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e9ecef;
}

.modal__section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.modal__icon {
  font-size: 1rem;
}

.modal__section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
}

.modal__preparation-text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #666;
}

.modal__storage-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal__storage-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.modal__storage-type {
  font-weight: 600;
  color: var(--accent);
  min-width: 40px;
  flex-shrink: 0;
}

.modal__storage-method {
  color: #666;
  flex: 1;
}

/* 모달 푸터 */
.modal__footer {
  padding: 16px 24px 24px;
  border-top: 1px solid #e9ecef;
  display: flex;
  justify-content: center;
}

.modal__purchase-btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: var(--border-radius-md);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-width: 120px;
}

.modal__purchase-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal__purchase-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.modal__purchase-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Controls - Sticky bottom controls */
.controls {
  padding: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  position: sticky;
  bottom: 0;
  z-index: 100;
  /* 모바일 브라우저 최적화 */
  position: -webkit-sticky;
}

.controls::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  border-radius: 10px 10px 0 0;
}

/* Category toggle styles removed */
.search-label { display: block; font-size: 12px; color: #666; margin: 6px 0; font-weight: 500; }
.search-input {
  width: 100%;
  padding: 16px 20px;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-sm);
  font-size: 1rem;
  position: relative;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.95);
}

.search-input::placeholder {
  color: #9ca3af;
  font-weight: 500;
}

/* Reduce motion respect */
@media (prefers-reduced-motion: reduce) {
  .card, .search-input { transition: none; }
  .card:hover, .search-input:focus { transform: none; }
}

/* Dragging performance guard */
.is-dragging .card { backdrop-filter: none !important; background: rgba(255, 255, 255, 0.95); }
.is-dragging .card, .is-dragging .search-input, .is-dragging .thumb { transition: none !important; }
.card, .thumb .photo { backface-visibility: hidden; transform: translateZ(0); }

/* 모바일 최적화 */
@media (max-width: 767px) {
  .app-header { padding: 12px 16px; }
  .controls { padding: 12px 16px; }
  .search-input { padding: 12px 16px; }
  
  .modal { padding: 16px; }
  .modal__content { max-width: none; }
  .modal__body { padding: 20px; gap: 12px; }
  .modal__image img { width: 60px; height: 60px; }
  .modal__name { font-size: 1.1rem; }
  .modal__description { font-size: 0.85rem; }
  .modal__footer { padding: 12px 20px 20px; }
  .modal__purchase-btn { padding: 10px 20px; font-size: 0.9rem; min-width: 100px; }
  .modal__preparation, .modal__storage { margin-top: 12px; padding-top: 12px; }
  .modal__preparation-text, .modal__storage-item { font-size: 0.8rem; }
  .modal__section-title { font-size: 0.9rem; }
}

/* Larger thumbnail on bigger screens */
@media (min-width: 768px) {
  .thumb { width: 56px; height: 56px; flex-basis: 56px; }
}
@media (min-width: 1024px) {
  .thumb { width: 64px; height: 64px; flex-basis: 64px; }
}


/* --- Single-scroll hard guard (forces only body to scroll) --- */
html, body { overflow-x: hidden !important; overflow-y: auto !important; }


