/*
 * 원본 미니앱(src/index.css)의 디자인 토큰과 컴포넌트 스타일을 가져오고,
 * 웹사이트로 오면서 달라지는 부분을 덧붙였어요.
 *
 * 반응형 전략 — 모바일 먼저(mobile first) 쓰고 넓어질 때만 덮어씁니다.
 *   ~767px    한 줄짜리 카드 목록. 원본 미니앱과 사실상 같은 화면
 *   768px~    본문 폭이 넓어지고 카드가 그리드로, 헤더가 한 줄로, 시트가 가운데 모달로
 *   1024px~   여백만 조금 더 넉넉하게
 *
 * 가로 폭은 전부 .container 하나가 책임집니다. 헤더 배경만 화면 전체로 깔고
 * 안쪽 내용은 .container 로 묶어서, 넓은 화면에서도 헤더 바가 끊겨 보이지 않게 했어요.
 */

:root {
  --primary: #3182f6;
  --primary-weak: #ebf3fe;
  --green: #15c47e;
  --green-weak: #e6f8f1;
  --red: #f04452;
  --red-weak: #feecec;
  --orange: #ff9500;

  --grey900: #191f28;
  --grey800: #333d4b;
  --grey700: #4e5968;
  --grey600: #6b7684;
  --grey500: #8b95a1;
  --grey400: #b0b8c1;
  --grey300: #d1d6db;
  --grey200: #e5e8eb;
  --grey100: #f2f4f6;
  --grey50: #f9fafb;
  --white: #fff;

  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* 본문 최대 폭과 좌우 여백. 미디어쿼리에서 이 두 개만 바꾸면 레이아웃이 따라옵니다. */
  --content-width: 520px;
  --gutter: 20px;

  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', Pretendard, 'Malgun Gothic',
    system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--grey100);
  color: var(--grey900);
}

/* 시트가 열려 있는 동안 뒷배경이 스크롤되지 않게 */
body.sheet-open {
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

input {
  font: inherit;
}

/* 원본에선 <button> 이던 카드·칩이 웹에선 <a> 가 됐어요 */
a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

.app {
  min-height: 100vh;
  background: var(--grey100);
  padding-bottom: calc(40px + var(--safe-bottom));
}

/* 가로 폭을 책임지는 유일한 클래스 */
.container {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---------- 테스트 모드 배너 ---------- */

.test-banner {
  background: var(--grey900);
  color: var(--white);
  font-size: 12px;
  padding-top: var(--safe-top);
}

.test-banner__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* 배너가 노치 영역을 이미 먹었으니 헤더는 안전영역을 또 더하지 않아요 */
.app--test .header {
  padding-top: 16px;
}

.test-banner b {
  font-weight: 700;
}

.test-banner__reset {
  flex: none;
  color: var(--white);
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.test-banner__reset:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ---------- 헤더 ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--white);
  padding-top: calc(16px + var(--safe-top));
  border-bottom: 1px solid var(--grey200);
}

/*
 * 좁을 땐 [브랜드][개수] / [검색] 두 줄, 넓어지면 [브랜드][검색][개수] 한 줄.
 * order 만 바꿔서 마크업은 그대로 둡니다.
 */
.header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
  row-gap: 14px;
  padding-bottom: 12px;
}

.header__brand {
  flex: 1 1 auto;
  min-width: 0;
  order: 1;
}

.header__title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.header__subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--grey500);
}

.header__count {
  flex: none;
  order: 2;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-weak);
  border-radius: 999px;
  padding: 6px 10px;
}

/* ---------- 검색 ---------- */

.search {
  position: relative;
  order: 3;
  flex: 1 1 100%;
  margin: 0;
}

.search__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--grey400);
  pointer-events: none;
  display: flex;
}

.search__input {
  width: 100%;
  height: 46px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--grey100);
  padding: 0 42px;
  font-size: 15px;
  color: var(--grey900);
  outline: none;
  transition: background 0.15s ease;
}

.search__input::placeholder {
  color: var(--grey400);
}

.search__input:focus {
  background: var(--white);
  box-shadow: inset 0 0 0 2px var(--primary);
}

.search__clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--grey300);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.search__clear:hover {
  background: var(--grey400);
}

/* 입력창이 비어 있으면(=placeholder 가 보이면) 지우기 버튼은 감춰요 */
.search:has(.search__input:placeholder-shown) .search__clear {
  display: none;
}

/* ---------- 필터 ---------- */

/* 좁은 화면에선 칩을 가로로 밀어서 보고, 넓어지면 줄바꿈으로 다 펼칩니다 */
.scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 12px;
  /* 스크롤이 컨테이너 가장자리까지 닿도록 좌우 여백만큼 빼고 다시 채워요 */
  margin-left: calc(var(--gutter) * -1);
  margin-right: calc(var(--gutter) * -1);
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.scroller::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--grey100);
  color: var(--grey700);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.chip:hover {
  background: var(--grey200);
}

.chip--active,
.chip--active:hover {
  background: var(--grey900);
  color: var(--white);
}

.chip__count {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.6;
}

/* 지역 줄은 테두리형으로 두어, 바로 아래 붙는 기간·카테고리 줄과 한눈에 구분되게 했어요 */
.chip--region {
  background: var(--white);
  border: 1px solid var(--grey200);
  color: var(--grey700);
}

.chip--region:hover {
  background: var(--grey100);
}

.chip--region.chip--active,
.chip--region.chip--active:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.chip--month {
  height: 32px;
  font-size: 13px;
  background: transparent;
  color: var(--grey500);
  padding: 0 10px;
}

.chip--month:hover {
  background: var(--grey100);
}

.chip--month.chip--active,
.chip--month.chip--active:hover {
  background: var(--primary-weak);
  color: var(--primary);
}

/* ---------- 광고 지면 ---------- */

.ad {
  margin-top: 14px;
  /* 광고가 안 채워지면 빈 여백만 남지 않도록, 내용이 없으면 자리도 없앱니다 */
  min-height: 0;
}

.ad:empty,
.ad > ins:not([data-ad-status='filled']):empty:only-child {
  margin-top: 0;
}

.ad__placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 90px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--white);
  border: 1px dashed var(--grey300);
  color: var(--grey500);
  font-size: 12px;
}

.ad__label {
  flex: none;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--grey400);
  background: var(--grey100);
  border-radius: 4px;
  padding: 3px 5px;
}

/* ---------- 섹션 ---------- */

/* 좌우 여백은 .container 가 이미 주고 있어요 */
.section {
  padding: 0;
}

.section__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 22px 0 10px;
}

.section__title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.section__count {
  font-size: 14px;
  font-weight: 700;
  color: var(--grey400);
}

.section__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-weak);
}

.month-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 0 8px;
}

.month-header__label {
  font-size: 15px;
  font-weight: 800;
  color: var(--grey800);
}

.month-header__line {
  flex: 1;
  height: 1px;
  background: var(--grey200);
}

/* ---------- 카드 ---------- */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  display: flex;
  align-items: stretch;
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
  box-shadow: 0 2px 12px rgba(25, 31, 40, 0.08);
}

.card__main {
  display: flex;
  gap: 14px;
  align-items: center;
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 14px 4px 14px 14px;
  transition: transform 0.12s ease;
}

.card__main:active {
  transform: scale(0.985);
}

/* 상세 시트 없이 이벤트 페이지로 바로 가는 버튼 */
.card__link {
  flex: none;
  width: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey400);
  border-left: 1px solid var(--grey100);
  margin: 12px 0;
  transition: color 0.12s ease, background 0.12s ease;
}

.card__link:hover,
.card__link:active {
  color: var(--primary);
  background: var(--grey50);
}

.card__thumb {
  flex: none;
  width: 68px;
  height: 68px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  overflow: hidden;
  background: var(--grey100);
}

/* 사진은 기본 배경(그라데이션+이모지) 위에 덮어 씌웁니다 */
.card__thumb,
.sheet__hero {
  position: relative;
}

.thumb__emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card__thumb img,
.sheet__hero img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card__body {
  min-width: 0;
  flex: 1;
}

.card__badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 5px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 6px;
  line-height: 1;
  white-space: nowrap;
}

.badge--ongoing {
  background: var(--green-weak);
  color: var(--green);
}

.badge--soon {
  background: var(--red-weak);
  color: var(--red);
}

.badge--upcoming {
  background: var(--primary-weak);
  color: var(--primary);
}

.badge--category {
  background: var(--grey100);
  color: var(--grey600);
}

.badge--estimated {
  background: var(--grey100);
  color: var(--grey500);
}

.card__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card__meta {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--grey600);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__meta--sub {
  color: var(--grey500);
  margin-top: 2px;
}

/* ---------- 빈 상태 ---------- */

.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--grey500);
}

.empty__emoji {
  font-size: 38px;
}

.empty__title {
  margin: 14px 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--grey700);
}

.empty__desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.empty__desc a {
  color: var(--primary);
  font-weight: 700;
}

/* ---------- 바텀시트 (넓은 화면에선 가운데 모달) ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  display: block;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
  animation: fade-in 0.18s ease;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 520px;
  margin: 0 auto;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--grey300);
  margin: 10px auto 4px;
  flex: none;
}

/* 마우스로 쓰는 사람을 위해 눈에 보이는 닫기 버튼을 하나 둡니다 */
.sheet__close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--grey100);
  color: var(--grey600);
  font-size: 14px;
  line-height: 1;
  z-index: 1;
}

.sheet__close:hover {
  background: var(--grey200);
}

.sheet__scroll {
  overflow-y: auto;
  padding: 12px 20px calc(20px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.sheet__hero {
  height: 140px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin-bottom: 16px;
  overflow: hidden;
}


.sheet__title {
  margin: 8px 0 0;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.4px;
}

.sheet__desc {
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--grey700);
  white-space: pre-wrap;
}

/* <dl> 안에는 dt/dd 가 바로 오기 때문에 행 정렬은 그리드로 잡아요 */
.info-list {
  display: grid;
  grid-template-columns: 62px 1fr;
  column-gap: 12px;
  margin: 18px 0 0;
  border-top: 1px solid var(--grey100);
  font-size: 14px;
}

.info-row__label,
.info-row__value {
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--grey100);
}

.info-row__label {
  color: var(--grey500);
}

.info-row__value {
  color: var(--grey800);
  word-break: break-word;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--grey600);
  background: var(--grey100);
  border-radius: 999px;
  padding: 6px 10px;
}

.sheet__actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.button {
  flex: 1;
  height: 50px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: opacity 0.12s ease, filter 0.12s ease;
}

.button:hover {
  filter: brightness(0.97);
}

.button:active {
  opacity: 0.7;
}

.button--primary {
  background: var(--primary);
  color: var(--white);
}

.button--secondary {
  background: var(--grey100);
  color: var(--grey800);
}

/* ---------- 공유 ---------- */

.share {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--grey100);
}

.share__label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--grey600);
  margin-bottom: 10px;
}

.share__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--grey100);
  color: var(--grey800);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s ease;
}

.share-btn:hover {
  background: var(--grey200);
}

/* [hidden] 이 display:inline-flex 에 지지 않도록 */
.share-btn[hidden] {
  display: none;
}

.share-btn--kakao {
  background: #fee500;
  color: #191600;
}

.share-btn--kakao:hover {
  background: #f2da00;
}

/* ---------- 토스트 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  z-index: 60;
  max-width: calc(100vw - 40px);
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(25, 31, 40, 0.92);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast--on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.notice {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--grey500);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- 푸터 ---------- */

.footer {
  margin: 20px 0 0;
  color: var(--grey500);
  font-size: 12px;
  line-height: 1.6;
}

.footer p {
  margin: 0 0 4px;
}

.footer code {
  background: var(--grey200);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
}

.footer__source {
  color: var(--grey600);
  text-decoration: underline;
}

.footer__links {
  margin-top: 10px;
}

.footer__links a {
  color: var(--grey600);
  font-weight: 700;
  text-decoration: underline;
}

/* ---------- 정책 문서 페이지 ---------- */

.prose {
  padding-top: 28px;
  padding-bottom: 48px;
  max-width: 760px;
  color: var(--grey800);
  font-size: 15px;
  line-height: 1.7;
}

.prose h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin: 8px 0 20px;
}

.prose h2 {
  font-size: 17px;
  font-weight: 800;
  margin: 28px 0 8px;
  color: var(--grey900);
}

.prose p {
  margin: 0 0 12px;
}

.prose ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.prose li {
  margin-bottom: 6px;
}

.prose__link {
  color: var(--primary);
  text-decoration: underline;
}

.prose__back a {
  color: var(--grey600);
  font-size: 14px;
  font-weight: 700;
}

.prose__warn {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--red-weak);
  color: #a1242e;
  font-size: 14px;
}

.prose__meta {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--grey200);
  color: var(--grey500);
  font-size: 13px;
}

/* ==========================================================================
   태블릿 이상 — 본문이 넓어지고, 카드가 그리드로, 시트가 가운데 모달로
   ========================================================================== */

@media (min-width: 768px) {
  :root {
    --content-width: 1160px;
    --gutter: 32px;
  }

  /* 헤더 한 줄: [브랜드] [검색] [개수] */
  .header__inner {
    flex-wrap: nowrap;
    column-gap: 20px;
    padding-bottom: 14px;
  }

  .search {
    order: 2;
    flex: 0 1 380px;
  }

  .header__count {
    order: 3;
  }

  .header__title {
    font-size: 24px;
  }

  /* 칩은 밀어서 보지 않고 전부 펼쳐요 */
  .scroller {
    flex-wrap: wrap;
    overflow-x: visible;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    row-gap: 8px;
  }

  /* 목록 -> 카드 그리드. 폭에 따라 2~3열로 알아서 접힙니다. */
  .card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    align-items: stretch;
  }

  .card__main {
    padding: 16px 4px 16px 16px;
  }

  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(25, 31, 40, 0.1);
  }

  .section__header {
    padding: 28px 0 12px;
  }

  .notice {
    margin-top: 24px;
  }

  /* 바텀시트 -> 화면 가운데 모달 */
  .sheet {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(560px, calc(100vw - 64px));
    max-width: none;
    margin: 0;
    transform: translate(-50%, -50%);
    max-height: min(84vh, 760px);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(25, 31, 40, 0.24);
    animation: pop-in 0.18s ease-out;
  }

  .sheet__handle {
    display: none;
  }

  .sheet__scroll {
    padding: 20px 24px 24px;
  }

  .sheet__hero {
    height: 180px;
  }
}

@media (min-width: 1024px) {
  :root {
    --gutter: 40px;
  }

  .card-list {
    gap: 14px;
  }
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .sheet-backdrop,
  .card,
  .card__main {
    animation: none;
    transition: none;
  }

  .card:hover {
    transform: none;
  }
}
