/* ==========================================================================
   Pi Alarm — Legal Pages
   Mobile-first responsive stylesheet
   ========================================================================== */

:root {
  --brand: #7341D0;
  --brand-dark: #552AA0;
  --brand-soft: #F4EFFC;
  --text: #1A1A1A;
  --text-secondary: #3A3A40;
  --muted: #6B6B6F;
  --border: #E5E5EA;
  --border-soft: #EFEFF2;
  --bg: #FFFFFF;
  --bg-alt: #F7F7F9;
  --accent: #FFCC00;
  --shadow-sm: 0 1px 3px rgba(20, 0, 60, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 0, 60, 0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --max-w: 760px;
  --header-h: 56px;
}

/* ---------- Reset & base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Pretendard', 'Spoqa Han Sans Neo', 'Noto Sans KR',
               'Apple SD Gothic Neo', 'Malgun Gothic',
               -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  word-break: keep-all;
  overflow-wrap: break-word;
}

img, svg { max-width: 100%; height: auto; display: block; }

/* ---------- Header (sticky) ---------- */

.header {
  background: var(--brand);
  color: #FFFFFF;
  border-bottom: 3px solid var(--brand-dark);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
}

.brand-link {
  color: #FFFFFF;
  text-decoration: none;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.3px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Logo image replaces the old accent dot to the left of "Pi Alarm". */
.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.brand-link:hover { opacity: 0.92; }

.lang-switch {
  display: inline-flex;
  gap: 2px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  padding: 3px;
}

.lang-switch a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  white-space: nowrap;
}

.lang-switch a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

.lang-switch a.active {
  background: var(--accent);
  color: var(--text);
  font-weight: 700;
}

/* ---------- Main ---------- */

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 16px 64px;
}

/* ---------- Typography ---------- */

h1 {
  font-size: 24px;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin: 0 0 6px;
  color: var(--text);
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

h2 {
  font-size: 17px;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin: 32px 0 10px;
  color: var(--brand-dark);
  scroll-margin-top: calc(var(--header-h) + 16px);
}

h2:first-of-type {
  margin-top: 24px;
}

h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 18px 0 6px;
  color: var(--text);
  letter-spacing: -0.1px;
}

p {
  margin: 0 0 12px;
  font-size: 15px;
}

ul, ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

li {
  margin-bottom: 6px;
  font-size: 15px;
  line-height: 1.7;
}

li > ul,
li > ol {
  margin-top: 6px;
  margin-bottom: 4px;
}

strong {
  font-weight: 700;
  color: var(--text);
}

a {
  color: var(--brand);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

a:hover { color: var(--brand-dark); }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* ---------- Boxes ---------- */

.intro {
  background: var(--brand-soft);
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 22px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  border: 1px solid rgba(115, 65, 208, 0.08);
}

.note {
  background: var(--bg-alt);
  border-left: 3px solid var(--brand);
  padding: 14px 16px;
  margin: 20px 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.note ul {
  padding-left: 18px;
  margin: 6px 0 0;
}

.note li { font-size: 13px; margin-bottom: 4px; }

/* ---------- Table of Contents ---------- */

.toc {
  background: var(--bg-alt);
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  font-size: 13px;
}

.toc-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--brand-dark);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc ol {
  margin: 0;
  padding-left: 22px;
}

.toc li {
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.6;
}

.toc a {
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-block;
  padding: 2px 0;
}

.toc a:hover {
  color: var(--brand);
  text-decoration: underline;
}

/* ---------- Tables (responsive — outer wrap scrolls horizontally) ---------- */

.table-wrap {
  margin: 14px 0 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #FFFFFF;
  /* scroll hint shadows on left/right when content overflows */
  background:
    linear-gradient(to right, #FFFFFF 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to right, rgba(255, 255, 255, 0), #FFFFFF 70%) 100% 0,
    radial-gradient(farthest-side at 0% 50%, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0)) 100% 0;
  background-repeat: no-repeat;
  background-color: #FFFFFF;
  background-size: 36px 100%, 36px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}

.table-wrap table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0;
  background: transparent;
}

.table-wrap th,
.table-wrap td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-soft);
  line-height: 1.55;
}

.table-wrap th {
  background: var(--bg-alt);
  font-weight: 700;
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.table-wrap tbody tr:last-child td { border-bottom: none; }

.table-wrap tbody tr {
  transition: background 0.12s ease;
}

.table-wrap tbody tr:hover { background: var(--bg-alt); }

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 24px 16px 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

footer p { margin: 0 0 6px; font-size: 12px; line-height: 1.6; }

footer a {
  color: var(--muted);
  text-decoration: none;
}

footer a:hover { color: var(--brand); text-decoration: underline; }

/* ---------- Focus styles (a11y) ---------- */

:focus-visible {
  outline: 3px solid rgba(255, 204, 0, 0.6);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ==========================================================================
   Tablet ≥ 600px
   ========================================================================== */

@media (min-width: 600px) {
  body { font-size: 16px; }

  .header-inner { padding: 14px 24px; }
  .brand-link { font-size: 21px; }

  main { padding: 40px 24px 80px; }

  h1 { font-size: 28px; }
  h2 { font-size: 18px; margin: 36px 0 12px; }
  h3 { font-size: 16px; }

  p, li { font-size: 15px; }

  .intro {
    padding: 18px 22px;
    font-size: 15px;
  }

  .toc { padding: 18px 22px; }
  .toc ol { columns: 2; column-gap: 28px; }
  .toc li { break-inside: avoid; }

  .table-wrap th,
  .table-wrap td { padding: 12px 16px; }
}

/* ==========================================================================
   Desktop ≥ 960px
   ========================================================================== */

@media (min-width: 960px) {
  main { padding: 56px 28px 100px; }

  h1 { font-size: 32px; letter-spacing: -0.5px; }
  h2 { font-size: 19px; margin: 40px 0 14px; }

  .intro { padding: 22px 26px; font-size: 15px; }

  .table-wrap table { font-size: 14px; }
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
  :root { --brand: #000; --brand-dark: #000; --bg-alt: #f5f5f5; }

  .header {
    position: static;
    background: #FFFFFF !important;
    color: #000 !important;
    border-bottom: 2px solid #000;
    box-shadow: none;
  }
  .brand-link { color: #000 !important; }
  .brand-link::before { background: #000 !important; }
  .lang-switch, .toc { display: none; }

  main { padding: 16px 0; max-width: none; }

  h1, h2, h3 { color: #000 !important; page-break-after: avoid; }

  a { color: #000 !important; text-decoration: underline; }

  .intro, .note { background: #f9f9f9 !important; border-color: #ccc !important; }

  .table-wrap {
    overflow: visible;
    border: 1px solid #999;
    background: #FFFFFF !important;
  }
  .table-wrap table { min-width: auto; font-size: 11px; }
  table, tr, td { page-break-inside: avoid; }

  footer { border-top: 1px solid #999; margin-top: 24px; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
