/* ==========================================================================
   기차와 철도 배움터 — 공통 컴포넌트 (Toss 디자인 시스템 기반, DESIGN.md 참조)
   ========================================================================== */

/* ==========================================================================
   헤더 & 내비게이션
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--c-ink);
  flex-shrink: 0;
}

.logo .logo-mark { width: 26px; height: 26px; flex-shrink: 0; color: var(--c-primary); }
.logo .logo-en {
  display: block;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: .66rem;
  letter-spacing: .12em;
  color: var(--c-ink-faint);
  text-transform: uppercase;
}

.site-nav ul {
  list-style: none;
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: block;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: .92rem;
  font-weight: 500;
  color: var(--c-ink-soft);
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}

.site-nav a:hover, .site-nav a:focus-visible { color: var(--c-primary); background: var(--c-bg-soft); }

.site-nav a[aria-current="page"] {
  color: var(--c-primary);
  background: rgba(49, 130, 246, .1);
  font-weight: 700;
}

@media (max-width: 780px) {
  .site-header .container { flex-wrap: wrap; padding-bottom: 0; gap: 12px; }
  .site-nav {
    width: 100%;
    overflow-x: auto;
    border-top: 1px solid var(--c-border);
  }
  .site-nav ul { padding: 4px 0; }
  .site-nav a { padding: 8px 12px; font-size: .86rem; }
  h1 { font-size: 1.375rem; }
  h2 { font-size: 1.125rem; }
}

/* ==========================================================================
   히어로 / 섹션 공통
   ========================================================================== */

.hero { padding: 56px 0 32px; }
.hero.center { text-align: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-accent-text);
  background: var(--c-accent);
  padding: 5px 14px;
  border-radius: 9999px;
  margin-bottom: 18px;
}

.hero p.lead {
  max-width: 620px;
  font-size: 1.08rem;
  color: var(--c-ink-soft);
}
.hero.center p.lead { margin-left: auto; margin-right: auto; }

section { padding: 40px 0; }
section.alt { background: var(--c-bg-soft); }
section.bordered-top { border-top: 1px solid var(--c-border); }

.section-head { margin-bottom: 28px; }
.section-head.center { text-align: center; }
.section-head p { color: var(--c-ink-soft); margin: 0; }

.rule { height: 1px; background: var(--c-border); border: none; margin: 0 0 32px; }

/* ==========================================================================
   카드 & 버튼
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  padding: 28px 26px;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.card:hover, .card:focus-within { background: var(--c-bg-soft); border-color: var(--c-border-strong); box-shadow: var(--shadow-sm); }

.topic-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-card .icon-frame {
  width: 42px; height: 42px;
  background: var(--c-bg-soft);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-primary);
  margin-bottom: 6px;
}
.topic-card .icon-frame svg { width: 22px; height: 22px; }

.topic-card h3 { margin-bottom: 4px; }
.topic-card p { color: var(--c-ink-soft); font-size: .94rem; margin-bottom: 10px; }

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--c-primary);
}
.card-link .arrow { transition: transform .12s ease; }
.card:hover .card-link .arrow { transform: translateX(3px); }

.card.disabled { color: var(--c-ink-faint); }
.card.disabled .icon-frame { color: var(--c-ink-faint); background: var(--c-bg-muted); }
.card.disabled h3 { color: var(--c-ink-faint); }
.card.disabled .card-link { color: var(--c-ink-faint); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .94rem;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--c-primary);
  color: var(--c-white);
  transition: background .12s ease, color .12s ease;
}
.btn:hover { background: var(--c-primary-dark); }

.btn.btn-outline {
  background: rgba(49, 130, 246, .12);
  color: var(--c-primary);
}
.btn.btn-outline:hover { background: rgba(49, 130, 246, .2); }

.btn[disabled] {
  background: var(--c-bg-muted);
  color: var(--c-ink-faint);
  cursor: not-allowed;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--c-bg-muted);
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 700;
  color: var(--c-ink-soft);
}

/* ==========================================================================
   콜아웃 박스 (트리비아 / 알림 / 원리 설명 공통)
   ========================================================================== */

.callout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--c-bg-soft);
  border-left: 3px solid var(--c-border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 20px 24px;
}
.callout.accent { background: var(--c-accent); border-left-color: var(--c-accent-text); }
.callout .callout-icon { width: 22px; height: 22px; flex-shrink: 0; color: var(--c-ink-soft); margin-top: 3px; }
.callout.accent .callout-icon { color: var(--c-accent-text); }
.callout h3 { margin-bottom: 4px; font-size: 1.02rem; }
.callout p { margin: 0; color: var(--c-ink-soft); }
.callout > div { flex: 1; min-width: 0; }

.callout-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 24px;
}
.callout-row .callout-actions { margin-left: auto; }

/* ==========================================================================
   타임라인 (기차 역사) — 세로형 타임라인
   ========================================================================== */

.timeline {
  position: relative;
  max-width: 760px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 84px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--c-border-strong);
}

.timeline-item { position: relative; padding-left: 128px; margin-bottom: 4px; }

.timeline-item .year {
  position: absolute;
  left: 0;
  top: 14px;
  width: 68px;
  text-align: right;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: .92rem;
  color: var(--c-primary);
}

.timeline-item::after {
  content: "";
  position: absolute;
  left: 80px;
  top: 20px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--c-white);
  border: 2px solid var(--c-primary);
}

.timeline-item summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.timeline-item summary::-webkit-details-marker { display: none; }
.timeline-item summary h3 { margin: 0; font-size: 1.05rem; }
.timeline-item summary .toggle-icon { flex-shrink: 0; color: var(--c-ink-faint); transition: transform .15s ease; width: 16px; height: 16px; }
.timeline-item[open] summary .toggle-icon { transform: rotate(180deg); }

.timeline-item .detail { padding: 4px 0 20px; color: var(--c-ink-soft); font-size: .96rem; max-width: 58ch; }

@media (max-width: 640px) {
  .timeline::before { left: 54px; }
  .timeline-item { padding-left: 76px; }
  .timeline-item .year { width: 40px; font-size: .8rem; }
  .timeline-item::after { left: 50px; }
}

/* ==========================================================================
   노선도 비교 슬라이더
   ========================================================================== */

.compare-wrap {
  position: relative;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--c-white);
  aspect-ratio: 16 / 10;
}

.compare-wrap .layer { position: absolute; inset: 0; }
.compare-wrap .layer.top { clip-path: inset(0 50% 0 0); }

.compare-divider {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 1px;
  margin-left: -.5px;
  background: var(--c-white);
  box-shadow: 0 0 0 1px rgba(20,24,33,.2);
  pointer-events: none;
}

.compare-range {
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 40px;
  appearance: none;
  background: transparent;
  margin: 0;
  cursor: ew-resize;
}
.compare-range::-webkit-slider-thumb {
  appearance: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--c-white);
  border: 2px solid var(--c-primary);
  box-shadow: var(--shadow-md);
  margin-top: 0;
}
.compare-range::-webkit-slider-runnable-track { background: transparent; height: 40px; }
.compare-range::-moz-range-thumb {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--c-white); border: 2px solid var(--c-primary);
}
.compare-range::-moz-range-track { background: transparent; height: 40px; }

.compare-label {
  position: absolute;
  top: 14px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 700;
  background: var(--c-white);
  border: 1px solid var(--c-border-strong);
  color: var(--c-ink);
}
.compare-label.left { left: 14px; }
.compare-label.right { right: 14px; }

/* ==========================================================================
   부품 다이어그램 핫스팟
   ========================================================================== */

.diagram-wrap { position: relative; border: 1px solid var(--c-border); border-radius: var(--radius-md); padding: 32px 24px 20px; background: var(--c-bg-soft); }

.hotspot {
  position: absolute;
  width: 26px; height: 26px;
  padding: 0;
  border-radius: 50%;
  background: var(--c-primary);
  border: 2px solid var(--c-white);
  box-shadow: 0 0 0 1px var(--c-primary);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-white);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: .78rem;
  transition: background .12s ease;
}
.hotspot:hover, .hotspot:focus-visible { background: var(--c-primary-dark); box-shadow: 0 0 0 1px var(--c-primary-dark); }

.hotspot-tip {
  position: absolute;
  z-index: 5;
  max-width: 230px;
  background: var(--c-ink);
  color: var(--c-white);
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  box-shadow: var(--shadow-md);
}
.hotspot-tip strong { display: block; margin-bottom: 3px; font-family: var(--font-sans); }

/* ==========================================================================
   속도 막대그래프 (bar chart)
   ========================================================================== */

.bar-chart { margin: 8px 0 4px; border-top: 1px solid var(--c-border); }

.bar-row { padding: 14px 0; border-bottom: 1px solid var(--c-border); }

.bar-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.bar-label { font-size: .92rem; color: var(--c-ink); font-weight: 500; }

.bar-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: .9rem;
  color: var(--c-primary);
  white-space: nowrap;
}

.bar-track { position: relative; height: 20px; background: var(--c-bg-soft); border-radius: var(--radius-sm); overflow: hidden; }

.bar-fill {
  height: 100%;
  background: var(--c-primary);
  min-width: 3px;
}

.bar-axis {
  position: relative;
  height: 18px;
  margin-top: 4px;
  font-size: .74rem;
  color: var(--c-ink-faint);
}
.bar-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.bar-axis span:first-child { transform: translateX(0); }
.bar-axis span:last-child { transform: translateX(-100%); }

@media (max-width: 620px) {
  .bar-label { font-size: .84rem; }
  .bar-value { font-size: .84rem; }
}

.record-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.record-table th, .record-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border);
}
.record-table th {
  font-weight: 700;
  color: var(--c-ink-soft);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--c-border-strong);
}
.record-table td.num { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--c-primary); white-space: nowrap; }
.record-table tbody tr:hover { background: var(--c-bg-soft); }

@media (max-width: 620px) {
  .record-table { font-size: .84rem; }
  .record-table th, .record-table td { padding: 10px 8px; }
}

/* ==========================================================================
   지하철 구별법 도감
   ========================================================================== */

.train-face-card {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.train-face-card .face-stage {
  padding: 22px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg-soft);
  border-bottom: 1px solid var(--c-border);
}

.train-face-card .face-info { padding: 16px 20px 22px; }

.train-face-card .line-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  color: var(--c-white);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: .82rem;
  margin-right: 8px;
}

.feature-list {
  list-style: none;
  padding: 0; margin: 10px 0 0;
  font-size: .88rem;
  color: var(--c-ink-soft);
}
.feature-list li { padding: 3px 0 3px 16px; position: relative; }
.feature-list li::before { content: "–"; position: absolute; left: 0; color: var(--c-ink-faint); }

/* ==========================================================================
   지하철 구별법 — 실루엣 퀴즈
   ========================================================================== */

.quiz-wrap { max-width: 460px; margin: 0 auto; text-align: center; }

.quiz-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}
.quiz-stage svg rect, .quiz-stage svg text { transition: fill .4s ease; }

.quiz-feedback { min-height: 1.4em; font-size: .92rem; font-weight: 700; color: var(--c-primary); margin-bottom: 10px; }

.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.quiz-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: var(--c-white);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .94rem;
  color: var(--c-ink);
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.quiz-choice:hover:not([disabled]) { background: var(--c-bg-soft); border-color: var(--c-primary); }
.quiz-choice .quiz-choice-icon { flex-shrink: 0; }

.quiz-choice.correct { border-color: var(--c-primary); background: rgba(49, 130, 246, .1); color: var(--c-primary); }

.quiz-choice.incorrect {
  flex-direction: column;
  gap: 2px;
  background: var(--c-bg-muted);
  color: var(--c-ink-faint);
  border-color: var(--c-border);
  opacity: .7;
}
.quiz-choice.incorrect .quiz-choice-hint { font-size: .72rem; font-weight: 500; }

.quiz-choice[disabled] { cursor: not-allowed; }

@media (max-width: 480px) {
  .quiz-choices { grid-template-columns: 1fr; }
}

/* ==========================================================================
   푸터
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--c-border);
  padding: 28px 0;
  color: var(--c-ink-faint);
  font-size: .84rem;
}

/* ==========================================================================
   유틸
   ========================================================================== */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > div { background: var(--c-white); border: 1px solid var(--c-border); border-radius: var(--radius-card); padding: 28px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 4px; }
.filter-bar button {
  border: none;
  background: var(--c-bg-muted);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-weight: 500;
  font-size: .84rem;
  color: var(--c-ink-soft);
}
.filter-bar button.active { background: var(--c-primary); color: var(--c-white); }

.center { text-align: center; }
.note { font-size: .84rem; color: var(--c-ink-faint); margin-top: 14px; }

/* ==========================================================================
   사진 (실사진 + 출처 캡션)
   ========================================================================== */

.photo-figure {
  margin: 0 0 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.photo-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--c-bg-muted);
}
.photo-figure figcaption {
  padding: 10px 14px;
  margin: 0;
}
.photo-figure figcaption.note { margin-top: 0; }
.photo-figure figcaption a { color: inherit; text-decoration: underline; }

.photo-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
.photo-compare .photo-figure { margin: 0; }
.photo-compare .photo-label {
  display: block;
  font-weight: 600;
  font-size: .84rem;
  color: var(--c-ink);
  margin-bottom: 6px;
}
@media (max-width: 560px) {
  .photo-compare { grid-template-columns: 1fr; }
}

/* ==========================================================================
   전동차 세대별 변천사 타임라인 (지하철 구별법)
   ========================================================================== */

.gen-timeline {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 4px 4px 12px;
  margin: 24px 0;
  scroll-snap-type: x proximity;
}
.gen-card {
  flex: 0 0 150px;
  scroll-snap-align: start;
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  padding: 16px 12px;
  text-align: center;
}
.gen-card .gen-stage { margin-bottom: 10px; }
.gen-card .gen-stage svg { width: 100%; height: auto; display: block; }
.gen-card .gen-name { display: block; font-weight: 700; font-size: .88rem; color: var(--c-ink); }
.gen-card .gen-nick { display: block; font-size: .82rem; color: var(--c-ink-soft); margin-top: 2px; }
.gen-card .gen-year { display: block; font-size: .78rem; color: var(--c-ink-faint); margin-top: 2px; }
