﻿/* =========================================================
   TRIBGAMES • Obsidian Body + White Labels (v9.4.1 LegalTop)
   - Dark aurora background (banding minimized)
   - Pure white header/footer bars across all pages
   - Legal pages: top-aligned content with a subtle gap
   - Safe-area, focus, scrollbar tuned for production
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  font-family: "Noto Sans KR", "Segoe UI", "Apple SD Gothic Neo", system-ui, sans-serif;

  /* layout */
  --side-gap: clamp(20px, 5vw, 56px);
  --content-max: 1080px;

  /* brand accents (components/icons only; not labels) */
  --brand-1: #0ea5e9;
  --brand-2: #22d3ee;
  --brand-3: #a78bfa;

  /* text/surfaces */
  --text: #e8eefc;
  --text-soft: #cfe0ff;
  --text-dim: #b7c7ea;
  --text-dark: #0b1430;
  --surface: #0b1020;

  /* elevations */
  --sh-header: 0 10px 24px rgba(0,0,0,.28);
  --sh-footer: 0 -10px 24px rgba(0,0,0,.26);
  --sh-card:   0 24px 60px rgba(0,0,0,.46);
  --sh-menu:   0 20px 44px rgba(0,0,0,.45);

  /* radii */
  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 12px;

  /* header/footer target heights */
  --header-h: clamp(68px, 9vw, 92px);
  --footer-h: clamp(64px, 8vw, 84px);
  --header-h-sm: 58px;
  --footer-h-sm: 58px;

  /* footer spacing */
  --footer-pad-block: clamp(16px, 2.6vw, 22px);
  --footer-gap: clamp(8px, 2vw, 16px);

  /* type scale */
  --fz-body: clamp(15px, 2.1vw, 16px);
  --fz-hero: clamp(18px, 3vw, 22px);
  --fz-h1: clamp(28px, 4vw, 40px);
  --fz-h2: clamp(20px, 3vw, 26px);

  /* White label palette (global) */
  --hf-bg: #ffffff;
  --hf-fg: var(--text-dark);
  --hf-link: rgba(13,25,54,.9);
  --hf-underline: rgba(9,18,40,.35);
  --hf-border-top: rgba(0,0,0,.08);
  --hf-border-btm: rgba(0,0,0,.12);

  /* rhythm */
  --baseline: 4px;

  /* UI accent for native controls */
  accent-color: var(--brand-2);
}

/* ---------- Reset / Stability ---------- */
*, *::before, *::after { box-sizing: border-box; }
img, svg { display: block; max-width: 100%; }
html { scrollbar-gutter: stable both-edges; text-size-adjust: 100%; }
@supports not (scrollbar-gutter: stable) { html { overflow-y: scroll; } }

/* ---------- Body ---------- */
body {
  margin: 0;
  min-height: 100svh; /* mobile URL bar aware */
  display: flex;
  flex-direction: column;
  color: var(--text);
  /* multilayer aurora + subtle dithering to reduce banding */
  background:
    radial-gradient(1200px 800px at 20% -10%, rgba(34,211,238,.16) 0%, rgba(34,211,238,0) 60%),
    radial-gradient(1000px 760px at 85% -5%, rgba(124,58,237,.14) 0%, rgba(124,58,237,0) 58%),
    radial-gradient(1200px 900px at 50% 120%, rgba(14,165,233,.14) 0%, rgba(14,165,233,0) 64%),
    linear-gradient(180deg, #060914 0%, #070b17 48%, #091123 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.006) 0 1px, transparent 1px 3px);
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Global Frames ---------- */
.site-header,
.site-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  position: sticky;
  left: 0;
  z-index: 10;
}
.site-header { top: 0; }
.site-footer { bottom: 0; margin-top: auto; }

/* ---------- Labels: Pure White Bars (forced globally) ---------- */
.header-label,
.footer-label {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0;
  padding-inline: calc(var(--side-gap) + env(safe-area-inset-left)) calc(var(--side-gap) + env(safe-area-inset-right));
  border: 0;
  border-radius: 0;
  background: var(--hf-bg) !important;
  color: var(--hf-fg) !important;
  box-sizing: border-box;
  backdrop-filter: blur(6px) saturate(108%);
}

.header-label {
  height: var(--header-h);
  min-height: var(--header-h);
  box-shadow:
    var(--sh-header),
    inset 0 1px 0 var(--hf-border-top),
    inset 0 -1px 0 var(--hf-border-btm);
}
.footer-label {
  height: var(--footer-h);
  min-height: var(--footer-h);
  gap: var(--footer-gap);
  padding-block: var(--footer-pad-block);
  box-shadow:
    var(--sh-footer),
    inset 0 1px 0 var(--hf-border-top),
    inset 0 -1px 0 var(--hf-border-btm);
}

/* ---------- Inner Width Unification ---------- */
.header-inner,
.footer-inner,
.footer-content,
.site-header .header-inner,
.site-footer .footer-inner {
  width: min(var(--content-max), 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
}

/* ---------- Header Content ---------- */
.header-inner {
  position: relative;
  justify-content: center;
  gap: clamp(10px, 2.4vw, 18px);
  padding-inline: clamp(56px, 8vw, 112px);
}
.header-brand { display: flex; align-items: center; justify-content: center; height: 100%; }
.header-actions {
  position: absolute;
  right: clamp(16px, 4vw, 28px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.brand-link { display: inline-flex; align-items: center; transition: opacity .15s ease; }
.brand-link:hover, .brand-link:focus-visible { opacity: .88; outline: none; }
.brand-logo { width: clamp(172px, 18vw, 248px); height: auto; filter: drop-shadow(0 3px 8px rgba(0,0,0,.18)); }

/* ---------- Language Select ---------- */
.language-select { position: relative; width: auto; }
.language-select__toggle {
  width: clamp(40px, 6vw, 48px);
  height: clamp(40px, 6vw, 48px);
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.08);
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(255,255,255,.42) 0%, transparent 60%),
    linear-gradient(135deg, rgba(14,165,233,.90) 0%, rgba(167,139,250,.92) 100%);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, box-shadow .2s ease, transform .06s ease;
  backdrop-filter: blur(6px);
}
.language-select__toggle:hover,
.language-select__toggle:focus-visible {
  border-color: rgba(0,0,0,.16);
  box-shadow: 0 0 0 3px rgba(14,165,233,.18);
  outline: none;
}
.language-select__toggle:active { transform: translateY(1px) scale(.985); }
.language-select__icon { width: clamp(20px, 3vw, 26px); height: clamp(20px, 3vw, 26px); }
.language-select__current {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.language-select__menu {
  position: absolute;
  right: 0; top: calc(100% + 10px);
  transform: translateY(-6px);
  list-style: none; margin: 0; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: clamp(160px, 32vw, 220px);
  border-radius: var(--radius-md);
  border: 1px solid rgba(0,0,0,.08);
  background: #ffffff;
  box-shadow: var(--sh-menu);
  backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 30;
}
.language-select.is-open .language-select__menu { opacity: 1; transform: translateY(0); pointer-events: auto; }
.language-select__option {
  width: 100%;
  border: 0; border-radius: var(--radius-sm);
  background: rgba(9,18,40,.04);
  color: var(--text-dark);
  font-size: 14px; font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
  text-align: center;
}
.language-select__option:hover,
.language-select__option:focus-visible {
  outline: none;
  background: linear-gradient(90deg, rgba(14,165,233,.12) 0%, rgba(167,139,250,.12) 100%);
  box-shadow: 0 10px 22px rgba(0,0,0,.06);
}
.language-select__option[aria-selected="true"] {
  background: linear-gradient(90deg, rgba(14,165,233,.18) 0%, rgba(167,139,250,.18) 100%);
}

/* ---------- Main (default pages) ---------- */
.site-main {
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-inline: calc(var(--side-gap) + env(safe-area-inset-left)) calc(var(--side-gap) + env(safe-area-inset-right));
  padding-block: clamp(80px, 12vw, 200px);
}
.content-wrap { width: min(var(--content-max), 100%); margin: 0 auto; }

/* ---------- Home (Hero) ---------- */
.home .site-main {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-block: clamp(44px, 8vw, 96px) clamp(92px, 12vw, 200px);
}
.home .content-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hero-block { display: flex; flex-direction: column; align-items: center; gap: clamp(24px, 6vw, 40px); text-align: center; margin: 0 auto; }
.hero-logo { width: min(560px, 90vw); height: auto; margin-inline: auto; filter: drop-shadow(0 16px 36px rgba(14,165,233,.16)); }
.hero-copy {
  margin: 0;
  font-size: var(--fz-hero);
  line-height: 1.6;
  letter-spacing: -0.005em;
  text-wrap: balance;
  background: linear-gradient(180deg, #e9f2ff 0%, #c8d8ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
  text-align: center;
  font-family: 'Montserrat', 'Pretendard', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Segoe UI', 'Malgun Gothic', system-ui, sans-serif;
  font-weight: 600;
}

/* ---------- Footer ---------- */
.footer-inner,
.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(12px, 3vw, 28px);
}

/* 양측 길이에 영향받지 않도록 중앙 영역을 고정 */
.footer-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.footer-brand { justify-self: start; }
.footer-info { justify-self: center; }
.footer-links { justify-self: end; }

.footer-brand img {
  width: clamp(108px, 14vw, 150px);
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.18));
}
.footer-info {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: calc(var(--baseline) * .5);
  text-align: center;
  font-size: 12px; line-height: 1.12;
  color: rgba(13,25,54,.86);
  padding-inline: clamp(12px, 3vw, 24px);
  margin: 0;
}
.footer-info > * { margin: 0; }

.footer-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.footer-links a {
  color: var(--hf-link);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .02em;
  position: relative;
}
.footer-links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -4px;
  width: 100%; height: 2px;
  background: var(--hf-underline);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .18s ease;
}
.footer-links a:hover::after,
.footer-links a:focus-visible::after { transform: scaleX(1); }

/* ---------- Legal Pages (TOP-ALIGNED with slight gap) ---------- */
body.legal-page {
  background:
    radial-gradient(900px 700px at 100% -10%, rgba(167,139,250,.08) 0%, rgba(167,139,250,0) 60%),
    #070c18;
  color: var(--text);
}
.legal-page .site-header { position: sticky; top: 0; }

/* ⬇️ 핵심: 상단 정렬 + 헤더 아래 "살짝 띄움" */
.legal-page .site-main {
  display: flex;
  flex-direction: column;
  width: min(var(--content-max), 100%);
  margin: 0 auto;

  /* top-aligned */
  justify-content: flex-start;   /* stick to top */
  align-items: center;           /* center horizontally */

  /* spacing */
  padding-inline: calc(var(--side-gap) + env(safe-area-inset-left)) calc(var(--side-gap) + env(safe-area-inset-right));
  padding-top: clamp(8px, 1.5vw, 16px);
  padding-bottom: clamp(40px, 5vw, 88px);

  gap: clamp(12px, 2.5vw, 36px);  /* 섹션 간격 */
}

.legal-page .site-main > *:first-child { margin-top: 0; }
.legal-page .content-wrap { margin-top: 0; }

.legal-container {
  width: 100%; max-width: 960px; margin: 0 auto;
  background: linear-gradient(180deg, rgba(16,23,49,.75) 0%, rgba(10,15,35,.85) 100%), var(--surface);
  padding-block: clamp(20px, 4vw, 40px);
  padding-inline: clamp(20px, 4vw, 48px);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-card);
  line-height: 1.72;
  border: 1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(6px);
}
.legal-container h1 { margin: 0 0 8px; font-size: var(--fz-h1); letter-spacing: -0.02em; color: #f1f6ff; }
.legal-container h2 { margin-top: 28px; font-size: var(--fz-h2); color: #dfeaff; }
.legal-container p,
.legal-container li { font-size: var(--fz-body); margin: 12px 0; color: var(--text-dim); }
.legal-container a { color: #9ccfff; text-underline-offset: 2px; }
.legal-container table {
  width: 100%;
  border-collapse: collapse;
  margin-block: clamp(16px, 3vw, 28px);
  background: rgba(10,15,35,.72);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.legal-container thead { background: rgba(28,42,88,.68); }
.legal-container th,
.legal-container td {
  padding: clamp(10px, 2.2vw, 16px);
  text-align: left;
  font-size: var(--fz-body);
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255,255,255,.08);
  border-right: 1px solid rgba(255,255,255,.06);
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.legal-container th {
  color: #f1f6ff;
  font-weight: 700;
}
.legal-container tbody tr:last-child th,
.legal-container tbody tr:last-child td { border-bottom: none; }
.legal-container th:last-child,
.legal-container td:last-child { border-right: none; }
.legal-container table a {
  color: #a8d4ff;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* 앵커 점프 시 헤더에 가리지 않도록 */
.legal-container h1,
.legal-container h2 {
  scroll-margin-top: calc(var(--header-h) + 12px);
}

/* ---------- Scrollbar (subtle) ---------- */
:root {
  scrollbar-color: rgba(162,196,255,.45) transparent; /* Firefox */
  scrollbar-width: thin;
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: padding-box;
  background-image: linear-gradient(180deg, rgba(158,197,255,.55), rgba(118,167,255,.45));
}

/* ---------- Accessibility & Motion ---------- */
a:focus-visible, button:focus-visible {
  outline: 2px solid rgba(56, 189, 248, .85);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  /* 태블릿 포함: 헤더 여백 최소화 + 언어 토글 우측 밀착, 로고 숨김 */
  .header-label {
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
  }
  .header-inner {
    width: 100%;
    padding-inline: 0;
  }
  .header-actions {
    right: calc(env(safe-area-inset-right) + 8px);
  }
  .footer-brand,
  .footer-brand img {
    display: none !important;
  }
  .footer-label {
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: auto;
    min-height: var(--footer-h-sm);
    padding-block: 14px;
    gap: 10px;
  }
  .footer-inner,
  .footer-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 100%;
  }
  .footer-links {
    width: 100%;
    max-width: 360px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: center;
    justify-items: center;
    gap: 4px;
    align-items: flex-start;
    align-content: flex-start;
  }
  .footer-links a {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    text-align: center;
    padding-block: 2px;
  }
}
@media (max-width: 720px) {
  .header-label { height: auto; min-height: var(--header-h-sm); }
  .legal-container h1,
  .legal-container h2 {
    scroll-margin-top: calc(var(--header-h-sm) + 12px);
  }
  .legal-page .site-main {
    padding-top: clamp(6px, 1.2vw, 14px);
  }
}

/* ---------- Fallbacks ---------- */
@supports not (backdrop-filter: blur(4px)) {
  .header-label, .footer-label { background: var(--hf-bg); }
}
