/* Interaction references: Rare UI. See README.md for component links. */
html { scroll-padding-top: 100px; }

/* Quiet navigation with a stable, accented current-section pill. */
.primary-nav { gap: 3px; align-items: center; }
.primary-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  white-space: nowrap;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}
.primary-nav a:hover { background: var(--accent-soft); }
.primary-nav a[aria-current] {
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.primary-nav a:focus-visible { position: relative; z-index: 1; }

/* Article section index and progress ring. */
.has-reading-nav .site-footer { padding-bottom: 110px; }
.reading-nav {
  position: fixed;
  z-index: 15;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: min(330px, calc(100% - 32px));
  color: var(--ink);
}
.reading-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 11px 16px 11px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: inherit;
  box-shadow: 0 6px 24px #0002;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, border-radius .2s;
}
.reading-toggle:hover { border-color: var(--accent); }
.reading-toggle[aria-expanded="true"] { border-radius: 12px 12px 18px 18px; }
.reading-ring { display: block; width: 32px; height: 32px; flex: 0 0 32px; }
.reading-ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.reading-ring circle { stroke-width: 2.5; }
.reading-ring-track { stroke: var(--line); }
.reading-ring-fill { stroke: var(--accent); stroke-dasharray: 100; stroke-dashoffset: 100; stroke-linecap: round; }
.reading-copy { display: grid; gap: 3px; min-width: 0; flex: 1; }
.reading-caption { color: var(--muted); font: 600 .62rem/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.reading-current { overflow: hidden; font-size: .8rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.reading-chevron { color: var(--muted); transition: transform .2s; }
[aria-expanded="true"] .reading-chevron { transform: rotate(180deg); }
.reading-panel {
  max-height: min(480px, calc(100dvh - 200px));
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 8px;
  padding: 18px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 18px 18px 12px 12px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  animation: reading-open .18s ease-out;
}
.reading-title { margin: 0 10px 12px; color: var(--muted); font: 650 .7rem/1.4 var(--mono); }
.reading-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.reading-link { display: flex; align-items: baseline; gap: 12px; min-height: 44px; padding: 10px; border-radius: 8px; font-size: .82rem; line-height: 1.4; }
.reading-number { flex: 0 0 20px; color: var(--muted); font: .68rem/1.5 var(--mono); }
.reading-link:hover, .reading-link[aria-current] { background: var(--accent-soft); color: var(--accent); }
.reading-link:focus-visible { outline-offset: -3px; }
@keyframes reading-open { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Keep the original pre/code text selectable, scrollable, and unchanged. */
.code-frame { min-width: 0; margin: 30px 0; overflow: hidden; border: 1px solid var(--soft-line); border-radius: 14px; background: var(--surface); }
.code-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 54px; padding: 7px 12px 7px 18px; border-bottom: 1px solid var(--soft-line); background: var(--accent-soft); }
.code-title { display: inline-flex; align-items: center; gap: 10px; color: var(--body-copy); font: 600 .72rem/1.5 var(--mono); }
.code-marker { color: var(--accent); font-weight: 800; }
.code-copy { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 72px; min-height: 36px; margin-left: auto; padding: 6px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: .74rem; font-weight: 650; transition: color .18s, background .18s, border-color .18s; }
.code-copy:hover, .code-copy.is-copied { border-color: var(--soft-line); background: var(--surface); color: var(--accent); }
.code-status { width: 100%; color: var(--body-copy); font-size: .75rem; }
.code-status:empty { display: none; }
.code-copy.is-copied + .code-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.code-frame .article-code { margin: 0; padding: 22px; border: 0; border-radius: 0; background: var(--surface); color: var(--body-copy); font-weight: 500; font-size: .86rem; line-height: 1.85; scrollbar-width: thin; scrollbar-color: var(--soft-line) transparent; }
.code-frame .article-code:focus-visible { outline-offset: -4px; }

/* Collapse before translated labels can crowd the header. */
@media (max-width: 1100px) {
  .nav-shell { gap: 12px; }
  .nav-cv { display: none; }
  .menu-toggle { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-content: center; gap: 6px; margin-left: auto; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
  .menu-toggle span:not(.sr-only) { display: block; width: 18px; height: 2px; background: var(--ink); transition: transform .16s ease; }
  .menu-toggle[aria-expanded="true"] span:nth-of-type(2) { transform: translateY(4px) rotate(45deg); }
  .menu-toggle[aria-expanded="true"] span:nth-of-type(3) { transform: translateY(-4px) rotate(-45deg); }
  .primary-nav { position: absolute; top: 100%; right: 0; left: 0; display: none; margin: 0; max-height: none; padding: 10px 15px; border-bottom: 1px solid var(--line); background: var(--surface); }
  .primary-nav.is-open { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: none; }
  .primary-nav a, .primary-nav a:first-child, .primary-nav a:last-child, .primary-nav a:has(+ [aria-current]), .primary-nav a[aria-current] + a { min-height: 44px; padding: 10px; border: 0; border-radius: 8px; white-space: normal; text-align: center; }
  .primary-nav a[aria-current] { margin: 0; border-radius: 999px; transform: none; }
  html:not(.js) .primary-nav { position: static; display: flex; flex-wrap: wrap; grid-column: 1 / -1; }
  html:not(.js) .nav-shell { flex-wrap: wrap; }
}
@media (max-width: 690px) {
  html { scroll-padding-top: 88px; }
  .reading-nav { right: 16px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .reading-toggle { min-height: 58px; }
  .code-frame .article-code { padding: 18px; font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) {
  .primary-nav a[aria-current] { transform: none; }
  .reading-panel { animation: none; }
}
@media (max-width: 390px) {
  .nav-shell { gap: 8px; }
  html[data-language] .language-trigger { width: 128px; }
  html[data-language] .language-trigger-copy > span { font-size: .72rem; }
}
