/* 古诗文背诵解释：以“诗页”阅读节奏组织原文、拼音、词义和句意。 */
.overlay:has(.cn-recite-modal) {
  background: #e4e0d7 url("../img/chinese/li-bai-recitation.jpg") center / cover no-repeat;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.cn-recite-modal {
  width: min(980px, calc(100vw - 40px));
  max-width: 980px;
  background: rgba(255, 253, 248, 0.86);
  border-radius: 14px;
}

.cn-recite-modal .modal-body {
  flex: 1;
  min-height: 0;
  padding: 8px 10px 10px;
  background: transparent;
  overflow-y: auto;
}

.cn-recite-dialog {
  min-height: 320px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.cr-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 24px;
  background: transparent;
  border-bottom: 1px solid var(--line);
}

.cr-toolbar > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.cr-toolbar-title {
  color: var(--ink-900);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.cr-toolbar-meta {
  color: var(--ink-600);
  font-size: 12px;
  line-height: 1.5;
}

.cr-reader {
  max-width: 900px;
  margin: 0 auto;
  padding: 6px 20px 22px;
}

.cr-line {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  transition: opacity var(--t-fast);
}

.cr-line:last-child {
  border-bottom: 0;
}

.cr-line.is-active {
  background: transparent;
}

.cr-line.is-active .cr-line-play {
  color: var(--brand-700);
  border-color: var(--brand-200);
  background: var(--brand-100);
}

.cr-line-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cr-tokens {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 8px 10px;
  font-family: var(--font-serif);
}

.cr-token {
  flex: 1 1 72px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: min-content;
  max-width: 142px;
}

.cr-token.is-punctuation {
  flex: 0 0 auto;
}

.cr-token-plain {
  flex: 1 1 auto;
  max-width: none;
}

.cr-line.is-prose-line .cr-line-main {
  align-items: flex-start;
}

.cr-line.is-prose-line .cr-tokens,
.cr-line.is-prose-line .cr-token {
  display: block;
  min-width: 0;
}

.cr-line.is-prose-line .cr-token-body {
  display: block;
  padding: 0;
}

.cr-line.is-prose-line .cr-char {
  display: block;
  padding-left: 0.05em;
  font-size: 21px;
  line-height: 1.85;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.cr-attribution {
  flex: 1;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.cr-attribution-dynasty {
  padding: 3px 9px;
  color: var(--brand-800);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  background: var(--brand-100);
  border-radius: 999px;
}

.cr-attribution-name {
  color: var(--ink-800);
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.04em;
}

.cr-token-body {
  position: relative;
  z-index: 0;
  display: inline-grid;
  width: 100%;
  min-width: 0;
  grid-template-rows: 17px auto auto;
  align-items: start;
  justify-items: center;
  padding: 4px 7px 5px;
  border-radius: 7px;
}

.cr-token.is-active .cr-token-body::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -2px -4px;
  background: var(--brand-100);
  border-radius: 8px;
}

.cr-pinyin {
  min-height: 17px;
  color: var(--ink-500);
  font-family: var(--font-sans);
  font-size: 11.5px;
  line-height: 17px;
  white-space: nowrap;
}

.cr-char {
  max-width: 100%;
  color: var(--ink-900);
  font-size: 26px;
  line-height: 1.32;
  letter-spacing: 0.015em;
  text-align: center;
  overflow-wrap: anywhere;
}

.cr-token .cr-char {
  white-space: nowrap;
  overflow-wrap: normal;
}

.cr-line.is-prose-line .cr-char {
  white-space: normal;
  overflow-wrap: anywhere;
}

.cr-gloss {
  width: 100%;
  min-height: 18px;
  margin-top: 4px;
  color: var(--ink-600);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.cr-token.is-active .cr-pinyin,
.cr-token.is-active .cr-gloss {
  color: var(--brand-900);
}

.cr-token.is-active .cr-char {
  color: var(--brand-700);
}

.cr-meaning {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  padding: 8px 58px 8px 0;
  background: transparent;
  transition: background var(--t-fast), color var(--t-fast);
}

.cr-meaning > span {
  flex: none;
  margin-top: 1px;
  color: var(--brand-700);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.55;
}

.cr-meaning p {
  margin: 0;
  max-width: 38em;
  text-align: center;
  color: var(--ink-700);
  font-size: 14px;
  line-height: 1.7;
}

.cr-meaning-play {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--ink-500);
  background: transparent;
  border: 0;
  border-radius: 7px;
  transition: color var(--t-fast), background var(--t-fast);
}

.cr-meaning-play:active {
  transform: translateY(-50%) scale(0.97);
}

.cr-meaning-play:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 2px;
}

.cr-meaning-play:disabled {
  opacity: 0.45;
  cursor: wait;
}

.cr-line.is-attribution .cr-meaning {
  padding-inline: 40px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.cr-line.is-attribution .cr-meaning > span {
  margin-top: 0;
}

.cr-line.is-attribution .cr-meaning-play {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.cr-line.is-attribution .cr-meaning-play:active {
  transform: translateY(-50%) scale(0.97);
}

.cr-meaning.is-active {
  background: transparent;
}

.cr-meaning.is-active p {
  color: var(--brand-900);
  font-weight: 600;
}

.cr-line-play {
  flex: none;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-600);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface-solid);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}

.cr-line-play:active {
  transform: scale(0.98);
}

.cr-line-play:focus-visible,
.cr-toolbar .btn:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 2px;
}

.cr-data-note,
.cr-empty {
  max-width: 852px;
  margin: 16px auto 0;
  padding: 14px 16px;
  color: var(--ink-600);
  font-size: 13px;
  background: var(--surface-solid);
  border-radius: 8px;
}

.cn-recite-modal .modal-foot {
  padding: 0;
  background: rgba(255, 253, 248, 0.7);
}

/* 星露园嵌入的复习和学习面板也透出同一幅背景。 */
.cn-recite-modal .sg-study-panel {
  background: rgba(255, 253, 248, 0.36);
}

.cn-recite-modal .sg-study-panel-head {
  background: rgba(255, 253, 248, 0.55);
}

/* 浏览器全屏进入顶层后，背景须由弹窗自身承载。 */
.cn-recite-modal:fullscreen,
.cn-recite-modal.is-fullpage {
  background: linear-gradient(rgba(255, 253, 248, 0.84), rgba(255, 253, 248, 0.84)),
    url("../img/chinese/li-bai-recitation.jpg") center / cover no-repeat;
}

@media (max-width: 640px) {
  .overlay:has(.cn-recite-modal) {
    background-position: 24% center;
  }

  .cn-recite-modal:fullscreen,
  .cn-recite-modal.is-fullpage {
    background-position: center, 24% center;
  }
}

.cr-action-bar {
  width: 100%;
  min-height: 68px;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.cr-action-bar .btn {
  min-height: 44px;
  flex: none;
}

.cr-action-bar p {
  margin: 0;
  color: var(--ink-600);
  font-size: 12px;
  line-height: 1.55;
}

@media (hover: hover) and (pointer: fine) {
  .cr-line-play:hover {
    color: var(--brand-700);
    border-color: var(--brand-400);
    background: var(--brand-50);
  }

  .cr-meaning-play:hover {
    color: var(--brand-700);
    background: var(--brand-50);
  }
}

@media (max-width: 640px) {
  .cn-recite-modal {
    width: calc(100vw - 20px);
    max-width: none;
    height: auto;
    max-height: calc(100dvh - 20px);
    border-radius: 12px;
  }

  .cn-recite-modal .modal-head {
    padding: 12px 16px;
  }

  .cn-recite-dialog {
    min-height: 0;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .cr-toolbar {
    gap: 12px;
    padding: 12px 10px;
  }

  .cr-toolbar-title {
    font-size: 15px;
  }

  .cr-toolbar-meta {
    font-size: 11.5px;
    line-height: 1.45;
  }

  .cr-toolbar-meta > span {
    display: block;
  }

  .cr-reader {
    padding: 4px 6px 16px;
  }

  .cr-line {
    padding: 12px 4px 10px;
  }

  .cr-line-main {
    align-items: flex-start;
    gap: 6px;
  }

  .cr-tokens {
    justify-content: flex-start;
    gap: 7px 2px;
  }

  .cr-token {
    flex-basis: 58px;
  }

  .cr-token-body {
    padding: 3px 4px 4px;
  }

  .cr-pinyin {
    font-size: 10.5px;
  }

  .cr-char {
    font-size: 20px;
    line-height: 1.35;
  }

  .cr-line.is-prose-line .cr-char {
    font-size: 19px;
    line-height: 1.8;
  }

  .cr-gloss {
    font-size: 11px;
  }

  .cr-meaning {
    margin-top: 9px;
    padding: 7px 50px 7px 0;
  }

  .cr-meaning p {
    font-size: 13.5px;
  }

  .cr-line-play {
    width: 44px;
    height: 44px;
  }

  .cr-data-note,
  .cr-empty {
    margin-inline: 12px;
  }

  .cr-action-bar {
    padding: 10px 14px;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .cr-action-bar .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .cr-toolbar-title {
    display: none;
  }
}

@media (max-width: 360px) {
  .cr-toolbar {
    gap: 8px;
    padding-inline: 12px;
  }

  .cr-toolbar-meta {
    font-size: 11px;
    letter-spacing: -0.01em;
  }

  .cr-toolbar-meta > span {
    white-space: nowrap;
  }

  .cr-reader {
    padding-inline: 7px;
  }

  .cr-line {
    padding-inline: 6px;
  }

  .cr-tokens {
    gap: 6px 2px;
  }

  .cr-token {
    flex-basis: 54px;
  }

  .cr-token-body {
    padding-inline: 2px;
  }

  .cr-pinyin {
    font-size: 10.5px;
  }

  .cr-gloss {
    font-size: 11px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .cn-recite-modal .modal-head {
    padding: 9px 16px;
  }

  .cr-toolbar {
    padding-block: 9px;
  }

  .cr-toolbar-title {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cr-line,
  .cr-token,
  .cr-meaning,
  .cr-line-play,
  .cr-meaning-play {
    transition: none;
  }
}
