/**
 * 공유 반응형 CSS — 로망아바타
 * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries
 * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flexible_box_layout
 * ref: https://www.w3.org/WAI/WCAG21/quickref/
 */

/* ── 리셋 & 기본 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg:        #0f0f0f;
  --color-bg-2:      #181818;
  --color-gold:      #ff0000;
  --color-gold-dark: #cc0000;
  --color-text:      #c8d8e8;
  --color-muted:     #8898aa;
  --color-dim:       #6b7c93;
  --color-border:    rgba(255,0,0,0.15);
  --radius-sm:       8px;
  --radius-md:       12px;
  --radius-lg:       16px;
  --transition:      0.25s ease;
  --font-main:       'SchoolSafetyTteokbokki', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── 접근성: 본문 바로가기 */
.skip-to-main {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--color-gold);
  color: var(--color-bg);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 700;
  z-index: 9999;
  text-decoration: none;
  transition: top var(--transition);
}
.skip-to-main:focus { top: 1rem; }

/* ── 컨테이너 */
.g-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* ── 섹션 공통 */
.g-section {
  padding: 4rem 0;
}

.g-section-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  color: var(--color-gold);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.g-section-sub {
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  color: var(--color-muted);
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

/* ── 버튼 공통 */
.g-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  border-radius: 50px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  min-height: 48px;
  min-width: 48px;
}

.g-btn-primary {
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
  color: var(--color-bg);
  box-shadow: 0 4px 16px rgba(255,0,0,0.35);
}
.g-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255,0,0,0.5);
}

.g-btn-outline {
  background: transparent;
  color: var(--color-gold);
  border: 2px solid rgba(255,0,0,0.4);
}
.g-btn-outline:hover {
  background: rgba(255,0,0,0.08);
  border-color: var(--color-gold);
  transform: translateY(-2px);
}

.g-btn:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 3px;
}

/* ── 카드 공통 */
.g-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all var(--transition);
}
.g-card:hover {
  border-color: rgba(255,0,0,0.3);
  background: rgba(255,0,0,0.03);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}

/* ── 배지 */
.g-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,0,0,0.1);
  border: 1px solid rgba(255,0,0,0.25);
  border-radius: 50px;
  padding: 0.3rem 0.875rem;
  font-size: 0.82rem;
  color: var(--color-gold);
}

/* ── 라이브 뱃지 */
.g-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(229,62,62,0.9);
  color: #fff;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
}
.g-live-dot {
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  animation: liveDotBlink 1.5s ease-in-out infinite;
}
@keyframes liveDotBlink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ── 구분선 */
.g-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin: 2rem 0;
}

/* ── 텍스트 유틸 */
.g-text-gold   { color: var(--color-gold); }
.g-text-muted  { color: var(--color-muted); }
.g-text-center { text-align: center; }

/* ── 그리드 유틸 */
.g-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
.g-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

/* ── 페이지 헤더 (각 메뉴 페이지 상단) */
.page-hero {
  background: linear-gradient(180deg, #181818 0%, var(--color-bg) 100%);
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--color-border);
}
.page-hero-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  color: #fff;
  margin-bottom: 0.5rem;
}
.page-hero-title span { color: var(--color-gold); }
.page-hero-desc {
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  color: var(--color-muted);
  line-height: 1.7;
}

/* ── 빵 부스러기 */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-dim);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--color-dim);
  text-decoration: none;
  transition: color var(--transition);
}
.breadcrumb a:hover { color: var(--color-gold); }
.breadcrumb-sep { color: rgba(255,255,255,0.2); }
.breadcrumb-current { color: var(--color-gold); }

/* ── 폼 공통 */
.g-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.g-form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}
.g-form-input,
.g-form-textarea,
.g-form-select {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  transition: border-color var(--transition);
  width: 100%;
}
.g-form-input:focus,
.g-form-textarea:focus,
.g-form-select:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px rgba(255,0,0,0.15);
}
.g-form-textarea { resize: vertical; min-height: 120px; }

/* ── 알림 박스 */
.g-alert {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}
.g-alert-info {
  background: rgba(99,91,255,0.1);
  border: 1px solid rgba(99,91,255,0.25);
  color: #a5b4fc;
}
.g-alert-success {
  background: rgba(72,187,120,0.1);
  border: 1px solid rgba(72,187,120,0.25);
  color: #68d391;
}
.g-alert-warning {
  background: rgba(255,0,0,0.1);
  border: 1px solid rgba(255,0,0,0.25);
  color: var(--color-gold);
}
.g-alert-error {
  background: rgba(229,62,62,0.1);
  border: 1px solid rgba(229,62,62,0.25);
  color: #fc8181;
}

/* ── 로딩 스피너 */
.g-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,0,0,0.2);
  border-top-color: var(--color-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 반응형 미디어 쿼리 */
@media (max-width: 1024px) {
  .g-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .g-section { padding: 2.5rem 0; }
  .g-grid-2,
  .g-grid-3 { grid-template-columns: 1fr; }
  .g-container { padding: 0 1rem; }
}

@media (max-width: 480px) {
  .g-btn { padding: 0.7rem 1.25rem; font-size: 0.9rem; }
}

/* ── 접근성: 포커스 링 */
:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 3px;
}

/* ── 이미지 기본 */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── 링크 기본 */
a { color: inherit; }

/* ── 선택 색상 */
::selection {
  background: rgba(255,0,0,0.3);
  color: #fff;
}

/* ════════════════════════════════════════════════════════════════
   타입 스케일 (유튜브/Material Design 기준, 2026-06-06)
   ref: https://m2.material.io/design/typography/the-type-system.html
        (Roboto 타입스케일: H5 24 / H6 20 / Subtitle 16 / Body2 14 / Caption 12 / Button 14)
   ref: https://developer.mozilla.org/en-US/docs/Web/CSS/clamp  (PC↔모바일 단일 유동 스케일)
   유튜브 실측 매핑: 큰제목 24, 비디오제목 18, 본문 14, 메타 12, 버튼 14 → 아래 토큰으로 통일.
   ════════════════════════════════════════════════════════════════ */
:root {
  --fs-display:   clamp(1.5rem, 1.1rem + 2vw, 2.25rem);  /* 24→36 히어로 대제목 */
  --fs-title-lg:  clamp(1.25rem, 1.05rem + 1vw, 1.5rem);  /* 20→24 섹션 제목 (Material H5/H6) */
  --fs-title:     1.125rem;  /* 18 카드/비디오 제목 */
  --fs-subtitle:  1rem;      /* 16 Subtitle1 */
  --fs-body:      0.875rem;  /* 14 Body2 (유튜브 본문) */
  --fs-meta:      0.75rem;   /* 12 Caption (메타/시간/조회수) */
  --fs-button:    0.875rem;  /* 14 Button */
  --fs-label:     0.75rem;   /* 12 Label */
  --lh-tight:     1.25;
  --lh-normal:    1.6;
}

/* 기본 요소를 스케일에 정렬 (인라인 스타일이 없는 텍스트 안정화) */
body { font-size: var(--fs-body); line-height: var(--lh-normal); }
h1 { font-size: var(--fs-display);  line-height: var(--lh-tight); }
h2 { font-size: var(--fs-title-lg); line-height: var(--lh-tight); }
h3 { font-size: var(--fs-title);    line-height: var(--lh-tight); }
h4 { font-size: var(--fs-subtitle); line-height: var(--lh-tight); }
h5, h6 { font-size: var(--fs-subtitle); line-height: var(--lh-tight); }
small, .g-meta, figcaption { font-size: var(--fs-meta); }
button, .g-btn, input, select, textarea { font-size: var(--fs-button); }

/* 유튜브식 텍스트 유틸 (페이지에서 재사용) */
.yt-display  { font-size: var(--fs-display);  line-height: var(--lh-tight); font-weight: 800; }
.yt-title-lg { font-size: var(--fs-title-lg); line-height: var(--lh-tight); font-weight: 700; }
.yt-title    { font-size: var(--fs-title);    line-height: var(--lh-tight); font-weight: 700; }
.yt-subtitle { font-size: var(--fs-subtitle); line-height: var(--lh-normal); }
.yt-body     { font-size: var(--fs-body);     line-height: var(--lh-normal); }
.yt-meta     { font-size: var(--fs-meta);     line-height: var(--lh-normal); color: var(--color-dim); }

/* 기존 공통 클래스도 토큰으로 정렬해 PC/모바일 편차 제거 */
.g-section-title { font-size: var(--fs-display); }
.g-section-sub   { font-size: var(--fs-subtitle); }
.page-hero-title { font-size: var(--fs-display); }
.page-hero-desc  { font-size: var(--fs-subtitle); }
.g-btn           { font-size: var(--fs-button); }
.breadcrumb      { font-size: var(--fs-meta); }
.g-badge, .g-live-badge { font-size: var(--fs-label); }
.g-form-label    { font-size: var(--fs-body); }
.g-form-input, .g-form-textarea, .g-form-select { font-size: var(--fs-subtitle); }
.g-alert         { font-size: var(--fs-body); }

/* 모바일에서 버튼만 살짝 축소하던 기존 규칙 제거 대체 — 스케일이 이미 유동적이라 고정 */
@media (max-width: 480px) {
  .g-btn { padding: 0.7rem 1.25rem; }  /* font-size는 토큰 유지 */
}
