/*
  phy-tea 작품 틀 공용 스타일: '종이 위 그림' (studio/DESIGN.md, 2026-10-17 운영자 선택)
  - 틀(위 막대·판·단추·창)은 흰 종이와 잉크. 색은 장면과 물리량에만 쓴다.
  - 단추를 색으로 칠하지 않는다(하늘청록·호박 칠 단추는 운영자가 싫다고 함). 주 단추는 잉크 칠, 보조는 회색 테두리.
  - 반경: 단추·입력·세그먼트 3px, 판·그림·그래프·표·꼬리표·창 0, 손잡이·끄는 점만 원.
  - 쓰지 않는 것: 뒤 흐림, 빛 번짐, 그라데이션 칠, 한쪽 색 띠, 제목 위 작은 분류 줄, 알약 라벨, 반투명 판.
  작품은 이 파일을 번들에 넣고(esbuild CSS bundle 또는 build.sh 복사) 토큰을 자기 style.css에서 쓴다.
*/
:root {
  --k-paper: #ffffff;
  --k-ink: #171717;        /* 글자, 주 단추 칠. 사이트 globals.css의 --foreground와 같다 */
  --k-ink-2: #3d3d3d;      /* 굵은 보조 글자 */
  --k-sub: #5f5f5f;        /* 보조 글자: 흰 바탕 대비 6.4:1 */
  --k-ctl: #8a8a8a;        /* 단추·입력 테두리: 3.4:1 (WCAG 1.4.11 비텍스트 3:1) */
  --k-rule: #d4d4d4;       /* 구역을 나누는 선. 꼭 필요한 곳에만 */
  --k-wash: #f3f3f3;       /* 누를 때·마우스를 올릴 때 바탕 */
  --k-dim: rgba(23, 23, 23, 0.42); /* 창 뒤를 가리는 막(흐림 없이 어둡게만) */
  --k-r: 3px;              /* 단추·입력·세그먼트 반경. 이 밖의 값은 쓰지 않는다 */
  --k-hit: 40px;           /* 누르는 것 최소 높이(DESIGN '크기'). 낮은 화면은 아래에서 36px */
  --k-font: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Hiragino Sans", "Yu Gothic", sans-serif;
}
/* 숨긴 요소는 어떤 display 규칙도 되살리지 못한다(2026-10-17 light-clock: #modal.side의 display가 [hidden]을 이겨
   빈 막이 화면 전체를 막았다) */
[hidden] { display: none !important; }
@media (max-height: 560px) { :root { --k-hit: 36px; } }
html:lang(ja) { --k-font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, "Apple SD Gothic Neo", sans-serif; }

/* ── 단추 ── */
.k-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 14px; border: 1.5px solid var(--k-ctl); border-radius: var(--k-r);
  background: var(--k-paper); color: var(--k-ink); font: inherit; font-size: 15px; font-weight: 650; white-space: nowrap; cursor: pointer;
}
.k-btn.k-primary { background: var(--k-ink); border-color: var(--k-ink); color: var(--k-paper); }
@media (hover: hover) {
  .k-btn:not(:disabled):hover { background: var(--k-wash); }
  .k-btn.k-primary:not(:disabled):hover { background: #000; }
}
.k-btn:disabled { opacity: 0.45; cursor: default; }
.k-btn:focus-visible, .k-link:focus-visible, .k-stage:focus-visible { outline: 2px solid var(--k-ink); outline-offset: 2px; }
/* 어두운 그림(3D 장면 등) 위의 단추: 잉크 링 안쪽에 흰 띠를 둘러 어느 바탕에서도 초점이 보이게 한다.
   그림을 감싼 요소에 k-dark를 붙인다 */
.k-dark :focus-visible { outline: 2px solid var(--k-ink); outline-offset: 2px; box-shadow: 0 0 0 2px var(--k-paper); }
/* 캔버스·잘리는 칸 안의 요소는 바깥 링이 잘리므로 안쪽에 흰 링을 그린다 */
.k-dark canvas:focus-visible, .k-dark [tabindex]:not(button):focus-visible { outline: 3px solid var(--k-paper); outline-offset: -3px; box-shadow: none; }
/* 글자 단추(진행 지우기 등 조용한 동작) */
.k-link { min-height: 40px; border: 0; background: none; padding: 4px 0; font: inherit; font-size: 13px; color: var(--k-sub); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.k-link.k-armed { color: var(--k-ink); font-weight: 700; }

/*
  고른 상태(세그먼트·탭·토글·예측 보기): 굵은 글자 + 칸 아래 3px 막대.
  글자 밑줄은 쓰지 않는다. 글자가 두 줄로 접히면 첫 줄 밑줄이 둘째 줄을 가로질러 취소선처럼 보인다
  (2026-10-17 waves-sound 검토). 글자 밑줄은 범례 낱말(.k-w)과 링크에만 쓴다.
  물리량을 고르는 토글은 --k-on에 그 대상 색을 줘도 된다.
*/
.k-on, .k-seg > [aria-pressed="true"], .k-seg > [aria-selected="true"], .k-seg > [aria-checked="true"] {
  font-weight: 750; color: var(--k-ink); box-shadow: inset 0 -3px 0 var(--k-on, var(--k-ink));
}
/* 세그먼트는 칸 사이만 선으로 나누고, 바깥 테두리 하나에 반경 3px */
.k-seg { display: inline-flex; border: 1.5px solid var(--k-ctl); border-radius: var(--k-r); overflow: hidden; }
.k-seg > button { border: 0; border-radius: 0; background: var(--k-paper); color: var(--k-ink-2); font: inherit; font-size: 14px; font-weight: 600; min-height: 40px; padding: 4px 12px; line-height: 1.3; cursor: pointer; }
.k-seg > button + button { border-left: 1px solid var(--k-rule); }
@media (hover: hover) { .k-seg > button:not([aria-pressed="true"]):not([aria-selected="true"]):not([aria-checked="true"]):not(.k-on):hover { background: var(--k-wash); } }
/* overflow: hidden이 바깥 초점 링을 자르므로 안쪽에 그린다 */
.k-seg > button:focus-visible { outline: 2px solid var(--k-ink); outline-offset: -4px; }

/*
  범례 낱말: 글 속에서 장면의 대상을 가리키는 낱말에 그 대상의 색과 선 모양을 준다(이 방향의 특징).
  <span class="k-w" style="--w:#c2410c">우주선 시계</span>, 점선은 k-dash, 점점선은 k-dot.
  한 문장에 한두 개만. 색은 흰 바탕 대비 4.5:1 이상인 글자용 값을 쓴다.
*/
.k-w { color: var(--w, var(--k-ink)); font-weight: 650; text-decoration: underline; text-decoration-color: currentColor; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-skip-ink: none; }
.k-w.k-dash { text-decoration-style: dashed; }
.k-w.k-dot { text-decoration-style: dotted; }

/*
  슬라이더: 회색 트랙, 지나온 쪽만 진하게(--p = 0~100%), 손잡이는 흰 원.
  손잡이 테두리 --q는 그 슬라이더가 바꾸는 물리량의 색(손과 물체를 잇는다), 일반 설정이면 잉크.
*/
.k-range { -webkit-appearance: none; appearance: none; width: 100%; height: 40px; margin: 0; background: transparent; cursor: pointer; --p: 50%; --q: var(--k-ink); }
.k-range::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, var(--k-ink-2) 0 var(--p), var(--k-rule) var(--p) 100%); }
.k-range::-moz-range-track { height: 4px; background: var(--k-rule); }
.k-range::-moz-range-progress { height: 4px; background: var(--k-ink-2); }
.k-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; background: var(--k-paper); border: 3px solid var(--q); }
.k-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--k-paper); border: 3px solid var(--q); }
.k-range:focus-visible { outline: 2px solid var(--k-ink); outline-offset: 2px; }
.k-range:disabled { opacity: 0.45; cursor: default; }

/* ── 스토리·자유 모드 시작 화면 (start.js의 startSheet) ── */
.k-start { display: flex; flex-direction: column; gap: 16px; min-height: 0; padding: 18px 20px 16px; background: var(--k-paper); color: var(--k-ink); font-family: var(--k-font); }
.k-start .k-q { margin: 0; font-size: clamp(19px, 1.25vw + 10px, 27px); font-weight: 750; line-height: 1.32; }
.k-start .k-modes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-height: 0; }
.k-start .k-mode h2 { margin: 0 0 4px; font-size: 16px; font-weight: 800; }
.k-start .k-mode h2 .k-tot { margin-left: 8px; font-size: 13px; font-weight: 600; color: var(--k-sub); font-variant-numeric: tabular-nums; }
.k-start .k-lead { margin: 0 0 8px; font-size: 14px; line-height: 1.5; color: var(--k-sub); }
.k-start .k-stages { list-style: none; margin: 0 0 10px; padding: 0; }
.k-start .k-stage {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 6px;
  width: 100%; min-height: 40px; padding: 4px 2px; border: 0; border-top: 1px solid var(--k-rule); background: none;
  font: inherit; font-size: 15px; text-align: left; color: var(--k-ink); cursor: pointer;
}
.k-start li:last-child .k-stage { border-bottom: 1px solid var(--k-rule); }
@media (hover: hover) { .k-start .k-stage:hover { background: var(--k-wash); } }
.k-start .k-stage .k-n { color: var(--k-sub); font-variant-numeric: tabular-nums; }
.k-start .k-stage .k-s { font-size: 13px; color: var(--k-ink); white-space: nowrap; }
.k-start .k-stage[aria-current="step"] { box-shadow: inset 0 -3px 0 var(--k-ink); }
.k-start .k-stage[aria-current="step"] .k-t { font-weight: 800; }
.k-start .k-free { margin: 0 0 10px; padding-left: 18px; font-size: 14px; line-height: 1.55; }
.k-start .k-free li { margin: 1px 0; }
.k-start .k-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.k-start .k-at { font-size: 13px; color: var(--k-sub); }
.k-start .k-note { margin: 0; font-size: 13px; line-height: 1.5; color: var(--k-sub); }
/* 안전 문구: 접지 않는다. 호박색은 경고에만 쓰는 색이라 여기서는 기호만 호박, 글은 잉크 */
.k-start .k-warn { margin: 0; font-size: 14px; line-height: 1.45; font-weight: 650; color: var(--k-ink); }
.k-start .k-warn > span { color: #915c08; }

/* 넓은 시작 화면(판 폭 560px 이상): 두 모드를 나란히 */
@container kstart (min-width: 560px) {
  .k-start .k-modes { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; }
}
.k-start { container: kstart / inline-size; }

/* 낮은 화면: 설명 줄을 접어 한 화면에 넣는다 */
@media (max-height: 560px) {
  .k-start { gap: 10px; padding: 12px 14px; }
  .k-start .k-lead { display: none; }
  .k-start .k-stage { min-height: 36px; font-size: 14px; }
  .k-link, .k-seg > button, .k-range { min-height: 36px; }
  .k-range { height: 36px; }
  .k-start .k-free { font-size: 13px; line-height: 1.45; }
  .k-btn { height: 36px; font-size: 14px; padding: 0 12px; }
}

/* 넘칠 때 접기(start.js fitStart). 단계마다 앞 단계를 품는다. 순서: 덜 중요한 것부터 */
.k-start { overflow: hidden; }
.k-start > * { flex-shrink: 0; } /* 줄어든 칸이 넘친 글을 겹쳐 그리면 넘침을 잴 수 없다 */
.k-start.k-f1 .k-lead { display: none; }
.k-start.k-f2 { gap: 8px; padding-top: 10px; padding-bottom: 8px; }
.k-start.k-f2 .k-modes { gap: 10px; }
.k-start.k-f2 .k-stage { font-size: 14px; }
.k-start.k-f2 .k-stages, .k-start.k-f2 .k-free { margin-bottom: 6px; }
.k-start.k-f3 .k-q { font-size: 17px; line-height: 1.3; }
.k-start.k-f4 .k-note { display: none; }
.k-start.k-f5 .k-free { display: none; }
.k-start.k-f6 .k-stages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
.k-start.k-f6 .k-stage { grid-template-columns: 18px minmax(0, 1fr); }
.k-start.k-f6 .k-stage .k-s { display: none; }
.k-start.k-f6 li:nth-last-child(2) .k-stage { border-bottom: 1px solid var(--k-rule); }
/* k-f7: 모드마다 제목과 단추를 한 줄에, 단계 목록은 그 아래 한 줄 전체 */
.k-start.k-f7 .k-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.k-start.k-f7 .k-mode h2 { order: 1; margin: 0; }
.k-start.k-f7 .k-mode .k-acts { order: 2; }
.k-start.k-f7 .k-mode .k-stages, .k-start.k-f7 .k-mode .k-free, .k-start.k-f7 .k-mode .k-lead { order: 3; flex-basis: 100%; margin: 0; }
.k-start.k-f7 .k-at { display: none; }
.k-start.k-f8 .k-stages { display: none; }
.k-start.k-f9 { gap: 6px; padding: 8px 10px; }
.k-start.k-f9 .k-q { font-size: 14px; }
.k-start.k-f9 .k-link, .k-start.k-f9 .k-tot, .k-start.k-f9 .k-at { display: none; }

@media (prefers-reduced-motion: reduce) { .k-start * { transition: none !important; } }
