/* DealMade storefront (index-xd.html) — production styling.
   Derived from the Figma "Shop" frame (node 3:9422, 375px wide):
   header 122px, hero 244px, section headers 18px/500 Noto Sans KR, product
   cards (brand / name / blue discount% + price), circular brand rail, and a
   fixed 5-tab bottom bar. Mobile-first at 375; widens into a desktop shell.

   Data is bound live from /api (deals + products); the luxury items in the
   Figma mock are the designer's placeholder content and are never hardcoded. */

:root {
  --store-pad: 20px;
  --store-radius: 12px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--dm-ink);
  background: #eceef1;
  -webkit-font-smoothing: antialiased;
}

/* App shell — a centered phone column on a neutral canvas. */
.store {
  max-width: var(--dm-max-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--dm-bg);
  padding-bottom: 96px; /* room for the fixed tab bar */
  position: relative;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* ---- Header --------------------------------------------------------- */
.store-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
  padding: 0 var(--store-pad);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--dm-border);
}
.store-brand {
  display: inline-flex;
  align-items: center;
  color: var(--dm-ink);
  text-decoration: none;
}
.store-brand img {
  display: block;
  width: 142px;
  height: auto;
}
.store-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  border-radius: 10px;
  color: var(--dm-ink);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}
.icon-btn:hover { background: var(--dm-surface); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .badge-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  min-width: 8px;
  height: 8px;
  border-radius: 8px;
  background: var(--dm-primary);
}

/* ---- Search --------------------------------------------------------- */
.store-search {
  padding: 12px var(--store-pad) 8px;
  background: #fff;
}
.store-search__box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--dm-line);
  border-radius: 12px;
  background: var(--dm-surface);
  transition: border-color 0.15s, background 0.15s;
}
.store-search__box:focus-within {
  border-color: var(--dm-primary);
  background: #fff;
}
.store-search__box svg { width: 18px; height: 18px; color: var(--dm-hint); flex: none; }
.store-search__box input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font: inherit;
  font-size: 15px;
  color: var(--dm-ink);
}
.store-search__box input::placeholder { color: var(--dm-hint); }
.store-search__box input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.store-search__clear {
  border: none; background: none; cursor: pointer; color: var(--dm-hint);
  font-size: 18px; line-height: 1; padding: 4px; display: none;
}
.store-search.has-value .store-search__clear { display: block; }

/* ---- Hero banner ---------------------------------------------------- */
.store-hero {
  position: relative;
  margin: 8px var(--store-pad) 4px;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 375 / 244;
  background: linear-gradient(135deg, #2b3a44, #4a5b66);
  color: #fff;
  text-decoration: none;
  display: block;
}
.store-hero__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.92;
}
.store-hero__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.05) 60%);
}
.store-hero__body {
  position: absolute;
  left: 22px;
  bottom: 26px;
  right: 22px;
}
.store-hero__eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.9;
}
.store-hero__title {
  margin-top: 6px;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
  word-break: keep-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.store-hero__pager {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
}

/* ---- Section scaffold ---------------------------------------------- */
.store-section { padding: 22px 0 4px; }
.store-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--store-pad) 12px;
}
.store-section__title {
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--dm-ink);
}
.store-section__more {
  font-size: 13px;
  color: var(--dm-muted);
  text-decoration: none;
  white-space: nowrap;
}
.store-section__more:hover { color: var(--dm-primary); }
.store-section__sub {
  padding: 0 var(--store-pad) 12px;
  margin-top: -6px;
  font-size: 13px;
  color: var(--dm-muted);
}
.store-section--tint { background: var(--dm-surface); margin: 8px 0; }

/* ---- Horizontal rail ----------------------------------------------- */
.rail {
  display: flex;
  gap: 12px;
  padding: 2px var(--store-pad) 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; flex: 0 0 auto; }

/* ---- Product card --------------------------------------------------- */
.p-card {
  display: block;
  text-decoration: none;
  color: inherit;
  position: relative;
}
.p-card__media {
  position: relative;
  border-radius: var(--store-radius);
  overflow: hidden;
  background: var(--dm-surface);
  aspect-ratio: 1 / 1;
}
.p-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.p-card:hover .p-card__media img { transform: scale(1.03); }
.p-card__info { padding: 8px 2px 4px; }
.p-card__brand {
  font-size: 13px;
  font-weight: 500;
  color: var(--dm-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p-card__name {
  margin-top: 2px;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px;
  font-weight: 300;
  color: var(--dm-sub);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 35px;
}
.p-card__price {
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
}
.p-card__disc { color: var(--dm-primary); font-weight: 700; }
.p-card__won { color: var(--dm-ink); font-weight: 500; }

/* Rail sizing for the recommended rail (square thumbs). */
.rail--reco .p-card { width: 143px; }
/* Rail sizing for the two-up featured rail. */
.rail--feature .p-card { width: 180px; }
.rail--feature .p-card__media { aspect-ratio: 180 / 200; }

/* ---- Responsive grid (신상품 / results) ---------------------------- */
.p-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 15px;
  padding: 2px var(--store-pad) 8px;
}
.p-grid .p-card__media { aspect-ratio: 160 / 200; }

/* ---- Deal card ------------------------------------------------------ */
.d-card {
  display: block;
  width: 150px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--dm-border);
  border-radius: var(--store-radius);
  overflow: hidden;
  background: #fff;
}
.d-card__media { position: relative; aspect-ratio: 1 / 1; background: var(--dm-surface); }
.d-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.d-card__tag {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(17, 17, 17, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.d-card__tag--soon { background: var(--dm-primary); }
.d-card__info { padding: 10px; }
.d-card__brand { font-size: 12px; font-weight: 500; color: var(--dm-ink); }
.d-card__name {
  margin-top: 2px;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px;
  font-weight: 300;
  color: var(--dm-sub);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 35px;
}
.d-card__price { margin-top: 6px; display: flex; align-items: baseline; gap: 6px; }
.d-card__disc { color: var(--dm-primary); font-weight: 700; font-size: 13px; }
.d-card__won { color: var(--dm-ink); font-weight: 600; font-size: 14px; }
.d-card__meta {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--dm-border);
  font-size: 12px;
  color: var(--dm-primary);
  font-weight: 500;
}

/* ---- Brand rail ----------------------------------------------------- */
.brand-rail { display: flex; gap: 18px; padding: 2px var(--store-pad) 8px; overflow-x: auto; scrollbar-width: none; }
.brand-rail::-webkit-scrollbar { display: none; }
.brand-chip { flex: 0 0 auto; width: 64px; text-align: center; text-decoration: none; }
.brand-chip__disc {
  width: 62px;
  height: 62px;
  margin: 0 auto;
  border-radius: 50%;
  border: 1px solid var(--dm-line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--dm-ink);
  overflow: hidden;
}
.brand-chip__disc img { width: 100%; height: 100%; object-fit: cover; }
.brand-chip__name {
  margin-top: 8px;
  font-size: 12px;
  color: var(--dm-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- States (loading / empty / error) ------------------------------ */
.rail-skeleton { display: flex; gap: 12px; padding: 2px var(--store-pad) 8px; }
.sk {
  border-radius: var(--store-radius);
  background: linear-gradient(90deg, #eef0f2 25%, #f6f7f8 37%, #eef0f2 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease-in-out infinite;
}
.rail-skeleton .sk { flex: 0 0 auto; width: 143px; height: 190px; }
.grid-skeleton { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 15px; padding: 2px var(--store-pad); }
.grid-skeleton .sk { height: 240px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.state {
  margin: 4px var(--store-pad) 8px;
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--dm-line);
  border-radius: var(--store-radius);
  color: var(--dm-muted);
  font-size: 14px;
}
.state--error { color: var(--dm-danger); border-color: var(--dm-danger); }
.state__retry {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 18px;
  border: 1px solid var(--dm-primary);
  border-radius: 20px;
  background: #fff;
  color: var(--dm-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.state__retry:hover { background: var(--dm-primary); color: #fff; }

/* ---- Bottom tab bar ------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--dm-max-width);
  display: flex;
  background: #fff;
  border-top: 1px solid var(--dm-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 40;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px 8px;
  text-decoration: none;
  color: var(--dm-hint);
  font-size: 9px;
  font-weight: 500;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.is-active { color: var(--dm-primary); }

/* ---- Desktop shell -------------------------------------------------- */
@media (min-width: 900px) {
  body { background: #f0f2f5; }
  .store {
    max-width: 960px;
    padding-bottom: 40px;
    min-height: 100vh;
  }
  .store-header { height: 72px; }
  .store-hero { aspect-ratio: 960 / 320; }
  .rail--reco .p-card { width: 190px; }
  .rail--feature .p-card { width: 240px; }
  .p-grid { grid-template-columns: repeat(4, 1fr); gap: 24px 20px; }
  /* On desktop the tab bar becomes a slim inline footer nav, not a fixed bar. */
  .tabbar {
    position: static;
    transform: none;
    max-width: none;
    border-top: 1px solid var(--dm-border);
    margin-top: 24px;
  }
  .tabbar a { flex-direction: row; gap: 8px; font-size: 13px; padding: 16px; justify-content: center; }
  .tabbar a svg { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
  .p-card__media img { transition: none; }
}
