/*
 * 법문 화면 조작 부품의 꾸밈(core/reader/controls.tsx · text-size.tsx, 2026-11-30 — 겉모습은 번역 사이트 것).
 * 번역 사이트는 app/(site)/layout.tsx 가 site.css 보다 먼저 import 하고,
 * waharakadhamma 는 sync:core 가 public/static/reader.css 로 복사한 것을 styles.css 다음에 싣는다.
 * 색 · 그림자 · 막대 높이는 core/tokens.css 변수. 좁은 화면 문턱은 60rem(두 사이트 같음).
 */

/* ── 넓은 화면 듣기 줄: 재생 혼자 왼쪽 | 따라가기 · 사이트 단추 · 글자 크기, 이름은 단추 아래 ── */
.rail-actions-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem;
}
/* 단추 아래 글까지 넣으면 오른쪽 칸이 가장 좁을 때(13rem) 빠듯하다. 사이를 줄여 글자 크기까지 한 줄에 둔다. */
.rail-player-row {
  flex-wrap: wrap;
  column-gap: 0.15rem;
}
.rail-actions-gap {
  flex: 1 1 auto;
}
.size-control,
.rail-labeled {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-items: center;
  color: var(--text-muted);
}

/* 재생: 강조색 동그라미. 받는 중이면 그림이 깜빡인다. */
.play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-text);
  background: var(--accent);
  cursor: pointer;
}
.play-button:hover {
  color: var(--accent-text);
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}
.play-button[aria-busy="true"] .icon,
.tool.is-primary[aria-busy="true"] .icon {
  animation: player-buffering 1s ease-in-out infinite;
}
@keyframes player-buffering {
  50% {
    opacity: 0.25;
  }
}
@media (prefers-reduced-motion: reduce) {
  .play-button[aria-busy="true"] .icon,
  .tool.is-primary[aria-busy="true"] .icon {
    animation: none;
    opacity: 0.5;
  }
}

/* 따라가기 단추: 켜져 있으면 강조색, 꺼지면 빗금 그림(follow-off). */
.follow-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  color: var(--text-faint);
  background: none;
  cursor: pointer;
}
.follow-switch:hover {
  color: var(--text-strong);
  background: var(--surface-sunken);
}
.follow-switch[aria-pressed="true"],
.rail-labeled[data-on] {
  color: var(--accent);
}

/* ── 단추 하나 = 그림 + 아래 짧은 글(좁은 화면 도구줄, 넓은 화면 듣기 줄의 사이트 단추) ── */
.tool {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 0.1rem;
  align-items: center;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--text-muted);
  background: none;
  font: inherit;
  cursor: pointer;
}
.tool-icon {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
}
.tool-icon .icon {
  width: 1.35rem;
  height: 1.35rem;
}
.tool-glyph {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
}
.tool-label {
  font-size: 0.68rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
  white-space: nowrap;
}
.tool[data-on] {
  color: var(--accent);
}
.tool.is-primary {
  color: var(--text);
}
.tool.is-primary .tool-icon {
  color: var(--accent-text);
  background: var(--accent);
}
.tool:disabled {
  color: var(--border-strong);
  cursor: default;
}
/* 넓은 화면 듣기 줄에 놓는 도구 단추(조금 작게). */
.rail-tool {
  flex: 0 0 auto;
  min-width: 2.2rem;
}
.rail-tool .tool-icon {
  width: 2.2rem;
  height: 2.2rem;
}
.rail-tool:hover .tool-icon {
  background: var(--surface-sunken);
}

/* ── 글자 크기 "− 숫자 +" ── */
.size-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}
.size-stepper button {
  width: 1.75rem;
  height: 2.1rem;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  color: var(--text-muted);
  background: none;
  font: inherit;
  font-size: 1.05rem;
  cursor: pointer;
}
.size-stepper button:hover:not(:disabled) {
  color: var(--text-strong);
  background: var(--surface-sunken);
}
.size-stepper button:disabled {
  color: var(--border-strong);
  cursor: default;
}
.size-now {
  min-width: 1.4rem;
  color: var(--text-strong);
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ── 도구줄 위 작은 창: 설정 단추 위 왼쪽. 줄마다 왼쪽 이름 · 오른쪽 조작 ── */
.set-pop {
  position: absolute;
  left: max(0.75rem, calc(50% - 12.6rem));
  bottom: calc(100% + 0.5rem);
  width: 15rem;
  padding: 0.2rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  box-shadow: var(--shadow-mid);
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.2rem;
  padding: 0.35rem 0;
}
.set-row + .set-row {
  border-top: 1px solid var(--border);
}
.set-name {
  color: var(--text);
  font-size: 0.92rem;
}
.set-pop .size-stepper button {
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.25rem;
}
.set-pop .size-now {
  min-width: 2rem;
  font-size: 0.95rem;
}

/* 켜기 · 끄기 스위치. 켜지면 강조색. */
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 1.6rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
}
.switch[aria-checked="true"] {
  background: var(--accent);
}
.switch[aria-checked="true"]::after {
  transform: translateX(1.15rem);
}
@media (prefers-reduced-motion: reduce) {
  .switch::after {
    transition: none;
  }
}

/* ── 좁은 화면 아래 도구줄(60rem 이하에서만) ── */
.mobile-toolbar {
  display: none;
}
@media (max-width: 60rem) {
  .mobile-toolbar {
    display: block;
    position: fixed;
    z-index: 25;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 0.5rem max(0.4rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom))
      max(0.4rem, env(safe-area-inset-left));
    border-top: 1px solid var(--border);
    background: var(--surface);
    box-shadow:
      var(--shadow-mid),
      0 5rem 0 5rem var(--surface);
  }
  .mobile-toolbar-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    max-width: 26rem;
    margin: 0 auto;
  }
}
