/* Components share one skin. Per-palette values live in theme-palettes.css. */
html {
  background-color: var(--wash);
  scroll-padding-top: calc(var(--header-offset) + 24px);
}
body,
body.article-page,
body.edit-page {
  background-color: var(--wash);
  background-image: var(--grid-image);
  background-size: var(--grid-size) var(--grid-size);
  color: var(--ink);
  caret-color: var(--focus);
  accent-color: var(--focus);
}
::selection {
  color: var(--selection-ink);
  background: var(--selection-bg);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
a {
  color: var(--link);
  text-underline-offset: .2em;
}
.skip {
  background: var(--button-bg);
  color: var(--button-ink);
}

.topbar,
.article-page .topbar {
  background: var(--wash);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
:where(.sidebar, .article-page .sidebar) {
  border-color: var(--line);
}
.article-page .sidebar,
.article-page .footer {
  background: transparent;
}
.sidebar-link:hover,
.sidebar-link.is-active,
.tree-leaf.selected,
.directory-tree summary:hover,
.tree-leaf:hover {
  background: var(--hover);
  color: var(--link);
}
.sidebar-link.is-active,
.tree-leaf.selected,
.reading-outline nav a[aria-current="location"] {
  font-weight: 650;
}
.sidebar-link.is-active .nav-arrow,
.reading-outline nav a[aria-current="location"] {
  color: var(--link);
}

/* The original transparent artwork doubles as the dark logo's alpha mask. */
html[data-theme="dark"] .brand {
  position: relative;
}
html[data-theme="dark"] .brand-logo {
  opacity: 0;
}
html[data-theme="dark"] .brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--ink);
  mask: url("/static/logo.png") center / contain no-repeat;
  pointer-events: none;
}

.searchbar {
  background: var(--control-bg);
  border: var(--line-w) solid var(--line);
  border-radius: var(--radius-tight);
}
.searchbar:focus-within {
  border-color: var(--focus);
  outline: var(--line-w) solid var(--focus);
  outline-offset: 0;
  box-shadow: var(--shadow);
}
.searchbar input:not([type="checkbox"]) {
  background: transparent;
  color: var(--control-ink);
  border: 0;
}
input::placeholder,
textarea::placeholder,
.searchbar input::placeholder {
  color: var(--muted);
  opacity: 1;
}
.searchbar button,
.account > a.login-link,
.stack-form .button,
.hero-button {
  font: 600 13px/1.45 var(--font-ui);
}
.searchbar button,
.theme-toggle {
  background: transparent;
  color: var(--control-ink);
}
.searchbar button {
  border-inline-start: var(--line-w) solid var(--line);
  border-radius: var(--radius-tight);
}
.searchbar button:hover,
.theme-toggle:hover {
  background: var(--hover);
  color: var(--ink);
}
:is(.search-suggestions, #search-suggestions) {
  background-color: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
:is(.search-suggestions, #search-suggestions) :is(a:hover, [aria-selected="true"]) {
  background: var(--hover);
  color: var(--link);
}

.button,
.library-cta {
  border-color: var(--button-bg);
  background: var(--button-bg);
  color: var(--button-ink);
  box-shadow: var(--shadow);
}
.button:hover,
.library-cta:hover {
  border-color: var(--button-hover);
  background: var(--button-hover);
  color: var(--button-ink);
  box-shadow: var(--shadow);
}
:is(.button-light, .pagination a, .link-button, .login-link, .language-switch, .code-copy) {
  border-color: var(--control-border);
  background: transparent;
  color: var(--control-ink);
}
:is(.button-light, .pagination a, .link-button, .login-link, .language-switch, .code-copy):hover {
  background: var(--hover);
  border-color: var(--control-border);
  color: var(--control-ink);
}
.button-icon-wrap,
.hero-button:hover .button-icon-wrap {
  background: color-mix(in srgb, var(--button-ink) 12%, transparent);
}
.account .account-name,
.account-dropdown {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.account-dropdown::before {
  border-color: var(--line-strong);
}
.account-dropdown a:hover,
.account-dropdown button:hover {
  background: var(--hover);
}
.account-dropdown .account-logout {
  color: var(--warn);
}

.home-page .intro,
.home-page .note-list,
.home-page .guide-card {
  background: transparent;
}
.home-page .intro h1 {
  font-family: var(--font-display);
  letter-spacing: -.035em;
}
.home-page .intro .hero-description,
.footer p {
  font-family: var(--font-body);
}
.kicker-line { background: var(--accent); }
:is(.hero-dot, .collection-arrow, .hero-bottom b) {
  color: var(--accent-ink);
}
.hero-bottom b {
  font-size: calc(15px * var(--hero-stats-scale));
}
.collection-card {
  background: var(--paper);
}
.collection-card:hover,
.home-page .note-row:hover,
.home-page .guide-card:hover {
  background: var(--hover);
}
#tide-gradient stop:first-child {
  stop-color: var(--line-strong);
}
#tide-gradient stop:last-child {
  stop-color: var(--accent);
}
.footer {
  border-top: var(--footer-rule);
  color: var(--muted);
}
.footer-brand {
  font-family: var(--font-brand);
}

.article-page .reading-layout {
  align-items: start;
}
.article-page .article {
  padding: clamp(20px, 3.1vw, 48px);
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: var(--radius-tight);
  box-shadow: var(--shadow);
}
.article-page .article h1 {
  font-family: var(--font-display);
}
.article-page .article .prose {
  font-family: var(--font-article);
  max-inline-size: var(--article-measure);
  line-height: 1.8;
  color: var(--reading-ink);
}
.article-page .article .prose :is(h2, h3, h4, h5, h6) {
  font-family: var(--font-serif);
}
.article-page .article .prose :is(h1, h2, h3, h4) {
  scroll-margin-top: 18px;
}
.article-page :is(.article-summary, .reading-meta, .reading-outline a, .outline-label) {
  color: var(--reading-muted);
}
.article-page .prose a {
  color: var(--reading-link);
  text-decoration: underline;
}
.article-page .prose :is(code, pre, th) {
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius-tight);
}
.article-page .prose pre {
  border: var(--line-w) solid var(--line);
}
.article-page .prose pre code {
  background: transparent;
}
.article-page .prose :is(code, pre) {
  font-family: var(--font-code);
}
.article-page .prose blockquote {
  color: var(--muted);
  border-inline-start: var(--line-w) solid var(--line-strong);
}
.reading-progress {
  background: var(--accent);
}
.reading-outline nav a[aria-current="location"] {
  color: var(--accent-ink);
  text-decoration: underline;
}

/* Preserve the note's semantic emphasis when printing or switching light levels. */
.prose [style*="background-color:#f2f7fc" i],
.prose [style*="background-color: #f2f7fc" i] {
  background-color: var(--mint) !important;
  color: var(--ink) !important;
}
.prose [style*="background-color:#fff5f6" i],
.prose [style*="background-color: #fff5f6" i] {
  background-color: var(--warning-bg) !important;
  color: var(--ink) !important;
}
html[data-theme="dark"] .prose :is(
  [style*="color:#4682b4" i], [style*="color: #4682b4" i],
  [style*="color:#1e90ff" i], [style*="color: #1e90ff" i],
  [style*="color:#2e8b57" i], [style*="color: #2e8b57" i]
) {
  color: var(--accent-ink) !important;
}
html[data-theme="dark"] .prose :is([style*="color:#dc143c" i], [style*="color: #dc143c" i]) {
  color: var(--warn) !important;
}
.article-page .prose :is(.hljs-comment, .token.comment) { color: var(--code-comment); }
.article-page .prose :is(.hljs-keyword, .token.keyword) { color: var(--accent-ink); font-weight: 650; }
.article-page .prose :is(.hljs-string, .token.string) { color: var(--accent-ink); }

.appearance-panel {
  position: fixed;
  inset: 64px 12px auto auto;
  margin: 0;
  z-index: 100;
  width: min(232px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 10px;
  border: var(--line-w) solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: 13px/1.5 var(--font-ui);
  box-shadow: var(--shadow);
}
.appearance-panel:popover-open {
  animation: appearance-in var(--panel-duration) var(--ease);
}
@keyframes appearance-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.appearance-panel fieldset {
  margin: 0;
  padding: 0;
  min-width: 0;
  border: 0;
}
.appearance-panel .appearance-palette {
  margin-top: 10px;
  padding-top: 8px;
  border-top: var(--line-w) solid var(--line);
}
.appearance-panel legend {
  padding: 0;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}
.appearance-choices {
  display: grid;
  gap: 4px;
}
.appearance-mode .appearance-choices {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  background: var(--wash);
  border-radius: var(--radius);
}
.appearance-palette .appearance-choices {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.appearance-choice {
  position: relative;
  min-width: 0;
  cursor: pointer;
}
#appearance-panel input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.appearance-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 4px 6px;
  border: var(--line-w) solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  transition: color var(--theme-duration), background-color var(--theme-duration), border-color var(--theme-duration);
}
.appearance-palette .appearance-option {
  justify-content: flex-start;
  padding-inline: 8px;
}
.appearance-choice:hover .appearance-option {
  background: var(--hover);
  color: var(--ink);
}
.appearance-choice input:checked + .appearance-option {
  background: var(--mint);
  border-color: var(--line-strong);
  color: var(--ink);
  font-weight: 650;
}
.appearance-choice input:focus-visible + .appearance-option {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.appearance-swatch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  width: 19px;
  height: 19px;
  flex: none;
  border: var(--line-w) solid var(--line-strong);
}
.appearance-swatch span:nth-child(1) { background: var(--wash); }
.appearance-swatch span:nth-child(2) { background: var(--paper); }
.appearance-swatch span:nth-child(3) { background: var(--ink); }
.appearance-swatch span:nth-child(4) { background: var(--accent); }

@media (pointer: coarse) {
  .appearance-option,
  .sidebar-link {
    min-height: 44px;
  }
}
@media (max-width: 650px) {
  html { scroll-padding-top: var(--header-offset); }
  .hero-bottom b { font-size: calc(12px * var(--hero-stats-scale)); }
  .account .account-name { max-width: min(180px, 32vw); }
}
@media print {
  :root[data-theme] {
    --wash: Canvas;
    --paper: Canvas;
    --ink: CanvasText;
    --muted: CanvasText;
    --line: GrayText;
    --line-strong: GrayText;
    --accent: CanvasText;
    --accent-ink: CanvasText;
    --code-bg: Canvas;
    --mint: Canvas;
    --grid-image: none;
    color-scheme: light !important;
  }
  .site-header,
  .topbar,
  .sidebar,
  .footer,
  .reading-outline,
  .reading-progress,
  .appearance-panel,
  .article-actions {
    display: none;
  }
  .shell,
  .article-page .reading-layout {
    display: block;
  }
  .content,
  .article-page .article {
    padding: 0;
  }
}

/* Keep the published atlas, search suggestions, and article navigation on the shared skin. */
.site-header { background: var(--wash); }
.atlas-hero h1 { font-family: var(--font-display); }
.atlas-hero .hero-description { font-family: var(--font-body); }
.primary-nav > a[aria-current],
.suggestion-option[aria-selected="true"],
.suggestion-all[aria-selected="true"] { font-weight: 650; }
.searchbar.suggestion-open { border-radius: var(--radius-tight); }
.search-suggestions mark { color: var(--accent-ink); }
.suggestion-icon { border-radius: 50%; }
