/* ==================================================================
   연프팅 링크 페이지 스타일
   - 모바일 우선 (320px 이상), 375/390px 최적화
   - 데스크톱에서는 모바일 폭 컨테이너 유지
   ================================================================== */

:root {
  /* ── 배경 사진 위치 조정 ──────────────────────────────────────
     첫 번째 값: 가로(0%=왼쪽, 50%=가운데, 100%=오른쪽)
     두 번째 값: 세로(0%=위, 50%=가운데, 100%=아래)
     남산타워가 잘리면 이 값만 조정하세요. (README 3장) */
  --bg-position: 50% 35%;

  /* 가독성용 오버레이: 상단은 사진이 보이도록 옅게, 하단 버튼 영역은 조금 더 어둡게 */
  --bg-overlay: linear-gradient(
    180deg,
    rgba(6, 8, 18, 0.30) 0%,
    rgba(6, 8, 18, 0.18) 38%,
    rgba(6, 8, 18, 0.50) 72%,
    rgba(6, 8, 18, 0.68) 100%
  );
  --bg-fallback: #151a2b;
  --page-dark: #0b0d14;

  --text: #ffffff;
  --text-sub: rgba(255, 255, 255, 0.86);
  --text-muted: rgba(255, 255, 255, 0.72);

  --btn-bg: #ffffff;
  --btn-bg-hover: #f1f1f4;
  --btn-bg-active: #e5e5ea;
  --btn-text: #111117;
  --btn-radius: 20px;
  --btn-height: 78px;

  --container: 480px;
  --gutter: 24px;

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    system-ui, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic",
    "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--page-dark);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--page-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 작은 화면에서도 버튼이 가려지지 않도록 세로 스크롤 허용 */
  overflow-x: hidden;
  overflow-y: auto;
}

/* ── 배경 ─────────────────────────────────────────────────────── */
.page-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  /* iOS 주소창이 줄어들어도 빈 공간이 생기지 않도록 가장 큰 뷰포트 높이 사용 */
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  background-color: var(--bg-fallback);
  background-image: var(--bg-overlay), url("images/namsan-bg.png");
  background-size: cover, cover;
  background-position: center, var(--bg-position);
  background-repeat: no-repeat;
  pointer-events: none;
}

/* 배경 이미지가 없을 때(개발 중): 깨진 느낌 없이 어두운 그라데이션으로 대체 */
.page-bg.is-missing {
  background-image: var(--bg-overlay),
    radial-gradient(120% 70% at 50% 20%, #2a3150 0%, #151a2b 55%, #0b0d14 100%);
  background-position: center, center;
}

/* ── 레이아웃 ─────────────────────────────────────────────────── */
.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--container);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding:
    calc(env(safe-area-inset-top, 0px) + 40px)
    calc(env(safe-area-inset-right, 0px) + var(--gutter))
    calc(env(safe-area-inset-bottom, 0px) + 40px + var(--consent-offset, 0px))
    calc(env(safe-area-inset-left, 0px) + var(--gutter));
}

/* ── 대표 이미지 ─────────────────────────────────────────────── */
.logo {
  margin: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

.logo__img {
  display: block;
  /* 원본 비율 유지(height auto). 이전보다 약 20% 작게, 화면 높이가 낮으면 더 작아짐. 테두리·그림자 없음 */
  width: min(46vw, 24vh, 186px);
  width: min(46vw, 24dvh, 186px);
  height: auto;
  border-radius: 18px;
}

.logo__placeholder {
  display: none;
}

/* 로고 이미지가 없을 때(개발 중) 대체 표시 */
.logo.is-missing .logo__img {
  display: none;
}

.logo.is-missing .logo__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: min(46vw, 24dvh, 186px);
  aspect-ratio: 1 / 1;
  border: 1.5px dashed rgba(255, 255, 255, 0.55);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  padding: 16px;
}

.logo__placeholder-title {
  font-size: 15px;
  font-weight: 600;
}

.logo__placeholder-path {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ── 소개 문구 ───────────────────────────────────────────────── */
.intro {
  margin-top: 22px;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.intro__headline {
  margin: 0;
  font-size: clamp(24px, 6.7vw, 26px);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.035em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.22);
  text-wrap: balance;
}

.intro__sub {
  margin: 8px 0 0;
  font-size: clamp(15px, 4.1vw, 16px);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: var(--text-sub);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
}

.nowrap {
  display: inline-block;
  white-space: nowrap;
}

/* ── 신청 버튼 (두 버튼 동일 디자인) ──────────────────────────── */
.apply {
  width: 100%;
  margin-top: clamp(28px, 4.5vh, 36px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.apply__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--btn-height);
  padding: 0 20px;
  border-radius: var(--btn-radius);
  background-color: var(--btn-bg);
  color: var(--btn-text);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

@media (hover: hover) {
  .apply__btn:hover {
    background-color: var(--btn-bg-hover);
  }
}

.apply__btn:active {
  background-color: var(--btn-bg-active);
  transform: scale(0.985);
}

/* 키보드 포커스: 어두운 배경 위에서 잘 보이는 흰색 외곽선 */
.apply__btn:focus-visible,
.footer__consent-link:focus-visible,
.consent__btn:focus-visible,
.consent__policy:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

/* ── 하단 안내 ───────────────────────────────────────────────── */
.footer {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 12px;
}

.footer__consent-link {
  padding: 6px 8px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* 개인정보 처리방침: 배너를 닫은 뒤에도 항상 보이는 링크 (쿠키 설정 링크와 같은 모양) */
.footer__policy-link {
  display: inline-block;
}

.footer__consent-link[hidden] {
  display: none;
}

.noscript {
  margin: 20px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-sub);
}

/* ── 안내 토스트 ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px + var(--consent-offset, 0px));
  z-index: 20;
  width: max-content;
  max-width: calc(100% - 40px);
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(22, 22, 30, 0.94);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  word-break: keep-all;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ── 동의 배너 ───────────────────────────────────────────────── */
.consent {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 30;
  width: calc(100% - 24px);
  max-width: calc(var(--container) - 24px);
  transform: translateX(-50%);
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  color: #1b1b22;
  text-align: left;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.consent[hidden] {
  display: none;
}

/* 아래에 두면 신청 버튼을 가리는 화면에서는 위쪽에 표시 (app.js가 판단) */
.consent.consent--top {
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  bottom: auto;
}

.consent__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.consent__text {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: #3a3a44;
  word-break: keep-all;
}

.consent__policy {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: #3a3a44;
  text-underline-offset: 3px;
}

.consent__policy[hidden] {
  display: none;
}

.consent__policy:focus-visible,
.consent__btn:focus-visible {
  outline-color: #1b1b22;
}

.consent__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* 거부와 동의를 같은 크기로 제공 (어느 한쪽을 유도하지 않음) */
.consent__btn {
  flex: 1 1 0;
  min-height: 44px;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.consent__btn--deny {
  border: 1px solid #c9c9d1;
  background: #ffffff;
  color: #1b1b22;
}

.consent__btn--accept {
  border: 1px solid #1b1b22;
  background: #1b1b22;
  color: #ffffff;
}

/* ── 개발용 연결 상태 패널 (localhost / ?debug=1 에서만 표시) ── */
.dev-panel {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: 8px;
  z-index: 40;
  max-width: min(360px, calc(100% - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.82);
  color: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  text-align: left;
}

.dev-panel summary {
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
}

.dev-panel ul {
  margin: 0;
  padding: 0 10px 10px 10px;
  list-style: none;
}

.dev-panel li + li {
  margin-top: 3px;
}

.dev-panel .ok { color: #7ee2a8; }
.dev-panel .warn { color: #ffd479; }
.dev-panel .todo { color: #ff9b9b; }

/* ── 보조 ────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── 반응형 ──────────────────────────────────────────────────── */

/* 아주 좁은 화면 (320px대) */
@media (max-width: 359px) {
  :root {
    --gutter: 20px;
    --btn-height: 76px;
  }
}

/* 세로가 짧은 화면 (구형 iPhone SE, 가로 모드 등): 간격과 로고를 줄이고 스크롤 허용 */
@media (max-height: 680px) {
  .page {
    padding-top: calc(env(safe-area-inset-top, 0px) + 28px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 28px + var(--consent-offset, 0px));
  }

  .intro {
    margin-top: 18px;
  }

  .apply {
    margin-top: 24px;
  }
}

/* 태블릿·데스크톱: 모바일 폭 컨테이너 유지, 사진도 중앙 컬럼 안에만 표시해 타워가 잘리지 않게 */
@media (min-width: 600px) {
  .page-bg {
    left: 50%;
    width: var(--container);
    transform: translateX(-50%);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
  }
}

/* 움직임 최소화 설정 존중 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
