/* ============================================================
   대기대순환 3D 학습자료 — style.css
   테마: "맑은 교실 아틀라스" (Daylight Classroom Atlas)
   - 밝은 하늘색 배경 + 흰색 카드 + 파란색 포인트
   - 프로젝터·태블릿에서 잘 보이도록 글자·버튼 크게
   ============================================================ */

:root {
  /* 기본 색 토큰 */
  --bg:        #e9f1fb;   /* 밝은 하늘색 배경 */
  --bg-2:      #f4f8fd;   /* 한 단계 밝은 면 */
  --panel:     #ffffff;   /* 흰색 카드 */
  --panel-2:   #f1f5fb;   /* 카드 안 강조 면 */
  --line:      #dde6f2;   /* 경계선 */
  --ink:       #182741;   /* 본문 글자 */
  --muted:     #5c6b85;   /* 보조 글자 */
  --accent:    #2b6fe3;   /* 파란색 포인트 */
  --accent-soft:#e4eefd;  /* 파란색 연한 면 */

  /* 위도대 의미색 (교육적 의미 유지) */
  --heat:      #ea5a3d;   /* 적도 — 공기 올라감 */
  --arid:      #dc9a2e;   /* 30° — 공기 내려감·건조 */
  --front:     #23967f;   /* 60° — 공기 다시 올라감 */
  --cold:      #4f83db;   /* 극 — 찬 공기 내려감 */
  --wet:       #3f83e8;   /* 비 많은 곳 */

  --shadow:      0 10px 30px rgba(35, 65, 120, .12);
  --shadow-soft: 0 4px 14px rgba(35, 65, 120, .08);
  --radius: 16px;
  --sidebar-w: 352px;

  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
          "Malgun Gothic", "맑은 고딕", "Noto Sans KR", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "D2Coding", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 키보드 포커스 가시성 */
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ============================================================
   상단바
   ============================================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 62px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(35,65,120,.04);
  z-index: 30;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  margin-right: auto;
  user-select: none;
}
.brand .glyph {
  width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; line-height: 1;
  background: var(--accent-soft);
}
.brand h1 {
  font-size: 17px; font-weight: 800; letter-spacing: -.01em;
}
.brand .sub {
  font-size: 12px; color: var(--muted); font-weight: 500;
  letter-spacing: .01em; margin-top: 1px;
}

/* 세그먼트 토글 (보기 전환) */
.seg {
  display: inline-flex; align-items: center; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 4px;
  gap: 3px;
}
.seg button {
  font-family: inherit; font-size: 14px; font-weight: 700;
  color: var(--muted); background: transparent; border: 0; cursor: pointer;
  padding: 9px 15px; border-radius: 9px; transition: all .16s ease;
  white-space: nowrap; min-height: 40px;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] {
  color: #fff; background: var(--accent);
  box-shadow: 0 3px 10px rgba(43,111,227,.32);
}
.seg-label {
  font-size: 12px; color: var(--muted); margin: 0 4px 0 6px;
  letter-spacing: .03em; font-weight: 600;
}
.seg button .short { display: none; }

/* ============================================================
   레이아웃: 사이드바(좌) + 3D 무대
   ============================================================ */
.layout { position: fixed; inset: 62px 0 0 0; }

/* 사이드바 토글 손잡이 (사이드바가 닫혔을 때 노출) */
.sidebar-handle {
  position: absolute; top: 14px; left: 14px; z-index: 25;
  width: 46px; height: 46px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--ink); cursor: pointer; box-shadow: var(--shadow-soft);
  transition: transform .15s ease;
}
.sidebar-handle:hover { transform: translateY(-1px); background: var(--panel-2); }
.sidebar-handle svg { width: 21px; height: 21px; }

/* 사이드바 */
.sidebar {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); max-width: 88vw;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 26; box-shadow: var(--shadow);
  transition: transform .28s cubic-bezier(.4,.0,.2,1);
}
.sidebar.collapsed { transform: translateX(calc(-100% - 6px)); }

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px 13px; border-bottom: 1px solid var(--line);
}
.sidebar-head h2 { font-size: 15px; font-weight: 800; letter-spacing: .01em; }
.sidebar-head .close {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); cursor: pointer;
}
.sidebar-head .close:hover { color: var(--ink); background: var(--panel-2); }

.sidebar-body { overflow-y: auto; padding: 16px 16px 28px; flex: 1; }
.sidebar-body::-webkit-scrollbar { width: 8px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

/* 섹션 */
.section { margin-bottom: 24px; }
.section > .label {
  font-size: 11.5px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 10px; padding-left: 3px;
}

/* --- 이해 순서: 단계 목록 --- */
.step-list { list-style: none; display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.step-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 11px;
  font-size: 13.5px; font-weight: 600; line-height: 1.4;
  color: var(--ink); cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: background .13s ease;
}
.step-list li:hover { background: var(--panel-2); }
.step-list li .num {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line);
}
.step-list li.on {
  background: var(--accent-soft);
  border-color: rgba(43,111,227,.35);
  color: var(--accent);
}
.step-list li.on .num { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- 이해 순서: 현재 단계 카드 --- */
.step-box {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 15px 15px 14px;
}
.step-box .step-count {
  font-size: 11.5px; color: var(--accent); font-weight: 800;
  letter-spacing: .05em; margin-bottom: 6px;
}
.step-box .step-title { font-size: 16.5px; font-weight: 800; line-height: 1.35; margin-bottom: 8px; }
.step-box .step-q {
  display: flex; gap: 9px; align-items: flex-start;
  margin-bottom: 11px; padding: 11px 12px;
  background: #fff; border: 1px solid var(--line);
  border-left: 3.5px solid var(--accent);
  border-radius: 10px;
  font-size: 13px; line-height: 1.6; color: var(--ink); font-weight: 500;
}
.step-box .step-q .q-mark { flex: none; font-size: 15px; }
.step-box .step-body { font-size: 13.5px; line-height: 1.68; color: #37455f; }
.step-box .step-body b { color: var(--ink); }
.step-box .nav { display: flex; gap: 9px; margin-top: 13px; }
.step-box .nav button {
  flex: 1; font-family: inherit; font-size: 14px; font-weight: 700;
  padding: 11px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  transition: all .14s ease; min-height: 44px;
}
.step-box .nav button:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.step-box .nav button:disabled { opacity: .4; cursor: not-allowed; }

/* --- 레이어 토글 행 --- */
.layer {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 11px; border-radius: 12px;
  cursor: pointer; user-select: none;
  border: 1px solid transparent; transition: background .14s ease;
  min-height: 46px;
}
.layer:hover { background: var(--panel-2); }
.layer .swatch {
  width: 14px; height: 14px; border-radius: 5px; flex: none;
  box-shadow: 0 0 0 1px rgba(24,39,65,.08) inset;
}
.layer .name { font-size: 14px; font-weight: 600; flex: 1; line-height: 1.3; }
.layer .name small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; margin-top: 2px; }
.layer.disabled { opacity: .45; pointer-events: none; }
.layer .only-note {
  font-size: 10.5px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; flex: none;
}

/* 스위치 */
.switch {
  width: 42px; height: 24px; border-radius: 999px; flex: none;
  background: #cfd9e8; position: relative; transition: background .18s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .18s ease;
  box-shadow: 0 1px 3px rgba(24,39,65,.25);
}
.layer[aria-checked="true"] .switch { background: var(--accent); }
.layer[aria-checked="true"] .switch::after { transform: translateX(18px); }

/* --- 계절 슬라이더 --- */
.season {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 15px 15px 13px;
  transition: box-shadow .3s ease, border-color .3s ease;
}
#season-section.spotlight .season {
  border-color: rgba(43,111,227,.55);
  box-shadow: 0 0 0 3px rgba(43,111,227,.15);
}
.season .track-labels {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--muted); margin-bottom: 10px; font-weight: 500;
}
.season .track-labels b { color: var(--ink); font-weight: 700; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 7px; border-radius: 7px;
  background: linear-gradient(90deg, var(--cold), var(--front), var(--heat), var(--front), var(--cold));
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 3.5px solid var(--accent); cursor: pointer;
  box-shadow: 0 2px 7px rgba(24,39,65,.28);
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 3.5px solid var(--accent); cursor: pointer;
}
.season .readout {
  text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 10px; line-height: 1.5;
}
.season .readout b { color: var(--accent); font-weight: 700; }

/* --- 읽는 법 --- */
.hint {
  font-size: 13px; line-height: 1.65; color: #40506b;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 15px;
}
.hint b { color: var(--ink); font-weight: 700; }
.hint ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.hint li { padding-left: 16px; position: relative; }
.hint li::before {
  content: ""; position: absolute; left: 2px; top: .62em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .55;
}

/* ============================================================
   3D 무대
   ============================================================ */
.stage {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 62% 30%, #f7fbff 0%, #e9f1fb 52%, #dbe8f7 100%);
}
#scene { width: 100%; height: 100%; display: block; touch-action: none; }

/* --- 위도대 정보 카드 --- */
.card {
  position: absolute; right: 18px; top: 18px; width: 344px; max-width: calc(100vw - 36px);
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 20;
  transform: translateY(-8px); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.card.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.card .card-top {
  padding: 14px 16px 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; gap: 11px;
}
.card .dot { width: 13px; height: 13px; border-radius: 5px; flex: none; margin-top: 4px; }
.card .card-titles { flex: 1; min-width: 0; }
.card .card-top h3 { font-size: 15.5px; font-weight: 800; line-height: 1.35; }
.card .card-top .term {
  display: inline-block; margin-top: 5px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 2.5px 7px;
}
.card .card-top .lat { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-top: 4px; flex: none; }
.card .card-top .x {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); cursor: pointer; flex: none;
  font-size: 13px;
}
.card .card-top .x:hover { color: var(--ink); background: var(--panel-2); }

.card .card-body { padding: 13px 16px 15px; display: flex; flex-direction: column; gap: 10px; }
.card .row { display: flex; gap: 10px; align-items: flex-start; }
.card .row .k {
  font-size: 11px; font-weight: 800; letter-spacing: .01em;
  padding: 4px 8px; border-radius: 7px; flex: none;
  margin-top: 1px; min-width: 84px; text-align: center;
}
.card .row .v { font-size: 13.5px; line-height: 1.58; color: var(--ink); }
.card .k.move   { background: var(--accent-soft); color: var(--accent); }
.card .k.rain   { background: #e2f0fd; color: #1d6fd1; }
.card .k.region { background: #e2f3ee; color: #14805f; }
.card .sum {
  margin-top: 2px; padding: 10px 12px;
  background: #fff8e6; border: 1px solid #f2e2b8; border-radius: 10px;
  font-size: 13px; font-weight: 700; line-height: 1.55; color: #6b4d10;
}
.card .sum::before { content: "한 줄 정리 · "; font-weight: 800; color: #b07f1d; }

/* 회전/조작 힌트 */
.controls-hint {
  position: absolute; bottom: 16px; right: 18px; z-index: 16;
  font-size: 12px; color: var(--muted); font-weight: 500;
  background: rgba(255,255,255,.85); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 10px; backdrop-filter: blur(5px);
}

/* 로딩 */
.loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 15px; background: var(--bg); z-index: 40;
  transition: opacity .4s ease;
}
.loading.hide { opacity: 0; pointer-events: none; }
.loading .spinner {
  width: 44px; height: 44px; border: 3.5px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .9s linear infinite;
}
.loading p { color: var(--muted); font-size: 14px; font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   반응형 — 태블릿 / 크롬북 / 휴대전화
   ============================================================ */
@media (max-width: 900px) {
  .seg button .full { display: none; }
  .seg button .short { display: inline; }
}
@media (max-width: 760px) {
  :root { --sidebar-w: 312px; }
  .brand .sub { display: none; }
  .seg-label { display: none; }
  .seg button { padding: 8px 11px; font-size: 13px; }
  .card { right: 12px; top: 12px; width: 306px; }
  .controls-hint { display: none; }
}
@media (max-width: 520px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand h1 { font-size: 15px; }
  .brand .glyph { width: 32px; height: 32px; font-size: 17px; border-radius: 10px; }
}

/* 모션 최소화 선호 존중 */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
  .spinner { animation: none; }
}
