/* 3D 기술 · 과학 백과사전 (js/encyclopedia/) — 모든 규칙은 .enc 아래에만.
   app.css 의 색 토큰을 쓰되, 단독으로 열어도 보이게 대체값을 둔다. 동적 크기(캔버스 · 진행 막대 · 견본 색)는 JS 의 el.style. */

/* 밝은 정보 화면: 옅은 회색 바탕 · 흰 카드 · 얇은 테두리 · 청록 강조. 3D 무대 · 2D 도식만 어두운 보기 창으로 둔다
   (모형 색 · 입자 · 이름표가 어두운 바탕 기준이라 기존 반도체 · 배터리 모형이 그대로 보이게). 앱 바탕색과 무관하게 같은 모양이 되도록
   토큰을 .enc 안에서 직접 정한다. 대비: 본문 #16202c / 흰 바탕 ≈ 16:1, 보조 #4a5869 ≈ 7:1, 흐린 #5f6c7b ≈ 5.3:1, 청록 글자 #0a7a72 ≈ 5.2:1. */
.enc {
  --enc-bg: #f4f6f8;
  --enc-panel: #ffffff;
  --enc-panel-2: #f7f9fb;
  --enc-line: #e3e8ee;
  --enc-line-2: #d3dae3;
  --enc-ink: #16202c;
  --enc-ink-2: #4a5869;
  --enc-ink-3: #5f6c7b;
  --enc-sky: #0a7a72;
  --enc-teal: #0f9d94;
  --enc-teal-bg: #e6f5f3;
  --enc-amber: #f5b94a;
  --enc-navy: #0a7a72;
  --enc-view: #0b0f17;
  --enc-view-ink: #e8eef7;
  --enc-view-line: #2a3850;
  color-scheme: light;
  background: var(--enc-bg);
  border: 1px solid var(--enc-line);
  border-radius: 14px;
  padding: 16px;
  container-type: inline-size;
  display: grid;
  gap: 14px;
  min-width: 0;
  color: var(--enc-ink);
  font-family: var(--sans, "Pretendard", system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.enc *, .enc *::before, .enc *::after { box-sizing: border-box; }
.enc h2, .enc h3, .enc h4, .enc h5, .enc p, .enc dl, .enc dd, .enc ul, .enc ol { margin: 0; }
.enc ul, .enc ol { padding: 0; list-style: none; }
.enc a { color: var(--enc-sky); text-underline-offset: 2px; }
.enc :focus-visible { outline: 2px solid var(--enc-sky); outline-offset: 2px; border-radius: 6px; }
.enc .mono { font-family: var(--mono, ui-monospace, Menlo, Consolas, monospace); }
.enc-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.enc kbd { font-family: var(--mono, monospace); font-size: 11px; padding: 1px 5px; border: 1px solid var(--enc-line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--enc-ink-2); background: var(--enc-bg); }

/* 머리 */
.enc-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; justify-content: space-between; }
.enc-h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.enc-sub { color: var(--enc-ink-2); font-size: 13px; margin-top: 2px; }
.enc-disclaimer {
  font-size: 12px; font-weight: 700; color: #1b1300; background: var(--enc-amber);
  border-radius: 999px; padding: 4px 12px; align-self: center;
}
.enc-entries { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-start; }
.enc-entrygroup { display: grid; gap: 4px; min-width: 0; }
.enc-entrygroup__h { font-size: 11px; font-weight: 700; color: var(--enc-ink-3); letter-spacing: 0.02em; }
.enc-entrygroup__items { display: flex; flex-wrap: wrap; gap: 6px; }
.enc-entry {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0;
  font: inherit; color: var(--enc-ink); background: var(--enc-panel); cursor: pointer;
  border: 1px solid var(--enc-line-2); border-radius: 10px; padding: 8px 14px; min-height: 44px;
}
.enc-entry:hover { border-color: var(--enc-sky); }
.enc-entry[aria-pressed="true"] { border-color: var(--enc-sky); background: var(--enc-teal-bg); box-shadow: inset 0 -2px 0 var(--enc-sky); }
.enc-entry__cat { font-size: 11px; color: var(--enc-ink-3); }
.enc-entry__name { font-weight: 700; }
.enc-title { font-size: 17px; font-weight: 800; }
.enc-intro { color: var(--enc-ink-2); max-width: 72ch; }

/* 본문 격자 */
.enc-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 880px) {
  .enc-grid { grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); align-items: start; }
}
.enc-viewer, .enc-explain { display: grid; gap: 10px; min-width: 0; }

/* 단추 */
.enc-btn, .enc-seg, .enc-chip, .enc-part, .enc-tl, .enc-link {
  font: inherit; color: var(--enc-ink); cursor: pointer;
}
.enc-btn {
  background: var(--enc-panel); border: 1px solid var(--enc-line-2); border-radius: 8px;
  padding: 6px 10px; min-height: 36px; min-width: 36px; white-space: nowrap;
}
.enc-btn:hover:not(:disabled) { border-color: var(--enc-sky); }
.enc-btn:disabled, .enc-chip:disabled { opacity: 0.45; cursor: not-allowed; }
.enc-btn[aria-pressed="true"] { background: var(--enc-teal-bg); border-color: var(--enc-sky); color: var(--enc-sky); font-weight: 700; }
.enc-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.enc-toolbar__group { display: inline-flex; gap: 4px; }

/* 무대 */
.enc-stage {
  position: relative; overflow: hidden; min-height: 300px;
  border: 1px solid var(--enc-line); border-radius: 12px;
  background: radial-gradient(120% 90% at 50% 20%, #142036 0%, #0b0f17 70%);
}
.enc-stage:focus-visible { outline-offset: -2px; }
.enc-canvas { display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.enc-canvas:active { cursor: grabbing; }
.enc-status {
  position: absolute; left: 10px; top: 10px; max-width: calc(100% - 20px);
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: rgba(8, 14, 24, 0.82); border: 1px solid var(--enc-view-line); color: var(--enc-view-ink); pointer-events: none;
}
.enc-stage-note { padding: 10px 12px; color: var(--enc-ink-2); font-size: 12px; }
.enc-svghost {
  border: 1px solid var(--enc-line); border-radius: 12px; background: #111826; color: var(--enc-view-ink);
  padding: 8px; min-width: 0;
}
.enc-svg { display: block; width: 100%; height: auto; font-family: var(--sans, system-ui, sans-serif); }
/* 좁은 화면: 도식 글씨가 너무 작아지지 않게 최소 폭을 두고 칸 안에서만 가로로 민다(페이지 가로 스크롤 없음). */
@container (max-width: 600px) {
  .enc-svghost { overflow-x: auto; }
  .enc-svg { min-width: 480px; }
  .enc-svghost::after { content: "← 도식을 옆으로 밀어 볼 수 있습니다 →"; display: block; font-size: 11px; color: var(--enc-ink-3); text-align: center; position: sticky; left: 0; }
}
.enc-svg .enc-svg-part { cursor: pointer; }
.enc-svg .enc-svg-part:hover { stroke: var(--enc-sky); stroke-width: 2; }
.enc-svg .is-selected { stroke: #ffffff; stroke-width: 3; }

/* 재생 */
.enc-transport { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.enc-counter { color: var(--enc-ink-2); font-size: 12px; min-width: 44px; text-align: center; }
.enc-progress { flex: 1 1 120px; height: 6px; border-radius: 999px; background: var(--enc-line); overflow: hidden; }
.enc-progress__bar { height: 100%; width: 0; background: var(--enc-sky); }
.enc-timeline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.enc-tl-group { width: 100%; font-size: 11px; color: var(--enc-ink-3); margin-top: 2px; }
.enc-tl {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--enc-panel); border: 1px solid var(--enc-line-2); border-radius: 999px;
  padding: 4px 10px 4px 4px; min-height: 32px; font-size: 13px;
}
.enc-tl__n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--enc-line-2); font-size: 11px; }
.enc-tl:hover { border-color: var(--enc-sky); }
.enc-tl[aria-current="step"] { border-color: var(--enc-sky); background: var(--enc-teal-bg); color: var(--enc-sky); font-weight: 700; }
.enc-tl[aria-current="step"] .enc-tl__n { background: var(--enc-sky); color: #ffffff; }
.enc-keys { font-size: 12px; color: var(--enc-ink-3); }

/* 설명 */
.enc-segs { display: inline-flex; border: 1px solid var(--enc-line-2); border-radius: 999px; overflow: hidden; justify-self: start; }
.enc-seg { background: transparent; border: 0; padding: 6px 16px; min-height: 36px; }
.enc-seg[aria-pressed="true"] { background: var(--enc-sky); color: #ffffff; font-weight: 700; }
.enc-stepbox, .enc-partinfo, .enc-card {
  background: var(--enc-panel); border: 1px solid var(--enc-line); border-radius: 12px; padding: 14px;
  display: grid; gap: 8px; min-width: 0;
}
.enc-step-group { font-size: 12px; color: var(--enc-ink-3); }
.enc-step-title { font-size: 16px; font-weight: 800; }
.enc-step-text { color: var(--enc-ink); }
.enc-look__h { font-size: 12px; color: var(--enc-ink-3); font-weight: 700; }
.enc-look { display: grid; gap: 3px; font-size: 13px; color: var(--enc-ink-2); }
.enc-look li::before { content: "· "; color: var(--enc-sky); }
.enc-partinfo { border-color: var(--enc-line-2); }
.enc-partinfo__name { font-size: 15px; font-weight: 800; }
.enc-en { font-weight: 400; color: var(--enc-ink-3); font-size: 12px; }
.enc-terms { font-size: 13px; color: var(--enc-ink-2); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.enc-link { background: none; border: 0; padding: 0; color: var(--enc-sky); text-decoration: underline; text-underline-offset: 2px; }
.enc-h4 { font-size: 14px; font-weight: 800; }
.enc-h5 { font-size: 13px; font-weight: 700; color: var(--enc-ink); margin-top: 6px; }
.enc-fine { font-size: 12px; color: var(--enc-ink-3); }
.enc-parts { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.enc-part {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--enc-panel); border: 1px solid var(--enc-line-2); border-radius: 8px; padding: 6px 8px; min-height: 36px; font-size: 13px;
}
.enc-part:hover { border-color: var(--enc-sky); }
.enc-part[aria-pressed="true"] { border-color: var(--enc-sky); background: var(--enc-teal-bg); box-shadow: inset 0 0 0 1px var(--enc-sky); }
.enc-swatch { flex: none; width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.18); }

/* 아래 칸 */
.enc-below { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 880px) {
  .enc-below { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
}
.enc-glossary { display: grid; gap: 2px 0; font-size: 13px; max-height: 420px; overflow: auto; padding-right: 4px; }
.enc-glossary dt { font-weight: 700; margin-top: 6px; border-radius: 4px; }
.enc-glossary dt.is-flash { background: var(--enc-teal-bg); }
.enc-glossary dd { color: var(--enc-ink-2); }
.enc-sources { display: grid; gap: 8px; font-size: 13px; list-style: decimal; padding-left: 18px; }
.enc-sources li { color: var(--enc-ink-2); }
.enc-src-kind { font-size: 11px; color: var(--enc-ink-3); border: 1px solid var(--enc-line-2); border-radius: 4px; padding: 0 4px; }
.enc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.enc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--enc-panel-2); border: 1px solid var(--enc-line-2); border-radius: 999px;
  padding: 4px 10px; min-height: 32px; font-size: 13px;
}
.enc-chip:hover:not(:disabled) { border-color: var(--enc-sky); }
.enc-chip[aria-pressed="true"] { border-color: var(--enc-sky); background: var(--enc-teal-bg); color: var(--enc-sky); }
.enc-chip__tag { font-size: 10px; color: var(--enc-ink-3); border: 1px solid var(--enc-line-2); border-radius: 4px; padding: 0 4px; }
.enc-articles { display: grid; gap: 6px; margin-top: 6px; border-top: 1px solid var(--enc-line); padding-top: 8px; }
.enc-articles__status { font-size: 12px; color: var(--enc-ink-2); }
.enc-articles__list { display: grid; gap: 10px; }
.enc-article { display: grid; gap: 2px; }
.enc-article__title { font-weight: 700; }
.enc-article__date { font-size: 11px; color: var(--enc-ink-3); }
.enc-article__excerpt { font-size: 12px; color: var(--enc-ink-2); }

@media (prefers-reduced-motion: reduce) {
  .enc * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ── 확장: 모형 범위 · 원리식 · 대표 기업 · 연결된 기술 ── */
.enc-card, .enc-stepbox, .enc-partinfo { box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
.enc-model { background: var(--enc-panel); border: 1px solid var(--enc-line); border-left: 3px solid var(--enc-teal); border-radius: 10px; padding: 10px 14px; }
.enc-model { display: grid; gap: 6px; }
.enc-model__dl { display: grid; gap: 6px 16px; grid-template-columns: minmax(0, 1fr); margin: 0; align-items: start; }
@container (min-width: 880px) { .enc-model__more .enc-model__dl { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.enc-model__row { display: grid; gap: 2px; min-width: 0; align-content: start; }
.enc-model__more { border-top: 1px solid var(--enc-line); padding-top: 6px; }
.enc-model__sum { cursor: pointer; font-size: 12px; font-weight: 800; color: var(--enc-sky); min-height: 32px; display: flex; align-items: center; }
.enc-model__more[open] .enc-model__sum { margin-bottom: 4px; }
.enc-model__row dt { font-size: 11px; font-weight: 800; color: var(--enc-sky); }
.enc-model__row dd { margin: 0; font-size: 13px; color: var(--enc-ink-2); }

.enc-mid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 880px) { .enc-mid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; } }
.enc-principles { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 600px) { .enc-principles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.enc-principle { border: 1px solid var(--enc-line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; background: var(--enc-panel-2); min-width: 0; }
.enc-principle__name { font-weight: 800; font-size: 13px; }
.enc-principle__expr { font-size: 15px; color: var(--enc-ink); background: var(--enc-panel); border: 1px solid var(--enc-line); border-radius: 6px; padding: 4px 8px; overflow-wrap: anywhere; }
.enc-principle__easy { font-size: 13px; color: var(--enc-ink-2); }

.enc-co-head { display: grid; gap: 2px; }
.enc-co-list { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 600px) { .enc-co-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 1000px) { .enc-co-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.enc-co-card { display: grid; gap: 8px; align-content: start; border: 1px solid var(--enc-line); border-radius: 12px; padding: 12px; background: var(--enc-panel); min-width: 0; }
.enc-co-card[data-status="pending"] { background: var(--enc-panel-2); border-style: dashed; }
.enc-co-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.enc-co-logobox { flex: none; display: inline-grid; place-items: center; width: 104px; height: 40px; border: 1px solid var(--enc-line); border-radius: 8px; background: #ffffff; padding: 4px 6px; }
.enc-co-logo { display: block; max-width: 100%; max-height: 28px; width: auto; height: auto; object-fit: contain; }
.enc-co-mark {
  flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  background: var(--enc-panel-2); border: 1px solid var(--enc-line-2); color: var(--enc-ink-2); font-weight: 800; font-size: 13px; letter-spacing: 0.02em;
}
.enc-co-id { display: grid; gap: 4px; min-width: 0; }
.enc-co-name { font-weight: 800; font-size: 14px; overflow-wrap: anywhere; }
.enc-co-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.enc-tag { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; border: 1px solid var(--enc-line-2); color: var(--enc-ink-2); background: var(--enc-panel); }
.enc-tag--ok { color: #07665f; background: #e6f5f3; border-color: #9fd8d1; }
.enc-tag--info { color: #1d4f91; background: #eaf1fb; border-color: #b8cdea; }
.enc-tag--warn { color: #7a4b00; background: #fff4de; border-color: #f0d199; }
.enc-tag--muted { color: var(--enc-ink-3); }
.enc-tag--pending { color: #5f6c7b; background: #f1f3f6; border-style: dashed; }
.enc-tag--private { color: #6b3fa0; background: #f3eefb; border-color: #d6c6ee; }
.enc-tag--plain { color: var(--enc-ink-2); }
.enc-co-dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; margin: 0; font-size: 13px; }
.enc-co-dl dt { color: var(--enc-ink-3); font-size: 12px; }
.enc-co-dl dd { margin: 0; color: var(--enc-ink); min-width: 0; overflow-wrap: anywhere; }
.enc-co-src { font-size: 12px; overflow-wrap: anywhere; }
.enc-co-open { justify-self: start; white-space: normal; text-align: left; }
.enc-co-pending { font-size: 12px; color: var(--enc-ink-3); border-top: 1px dashed var(--enc-line-2); padding-top: 6px; }
.enc-co-note { border-top: 1px solid var(--enc-line); padding-top: 8px; }
.enc-techlink { text-align: left; white-space: normal; }
/* 분야 묶음 머리글이 있으니 단추 안 분야 글자는 줄인다(화면 읽기 프로그램은 묶음 이름을 읽는다) */
.enc-entrygroup .enc-entry__cat { display: none; }
.enc-entrygroup .enc-entry { min-height: 40px; justify-content: center; }
@media (max-width: 520px) {
  .enc { padding: 10px; border-radius: 10px; gap: 12px; }
  .enc-entries { gap: 8px 12px; }
}
