/* Motion, theme control, and reading progress */
:root { --motion-fast: 180ms ease; }
html { scroll-behavior: smooth; }
body, header, nav, main, aside, footer, .container, .home-layout, .home-primary, .home-sidebar,
.welcome-block, .updates-block, .home-sidebar > section, .article-card, .callout-box,
.sidebar-widget, .news-item, .update-row, .notice-strip, .nav-container {
  transition: background-color 220ms ease, color 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

/* Revealed content only hides after JavaScript has prepared the observer. */
html.reveal-ready [data-reveal] { opacity: 0; transform: translateY(16px); transition: opacity 520ms ease, transform 520ms cubic-bezier(.2,.65,.3,1); }
html.reveal-ready [data-reveal].is-visible { opacity: 1; transform: translateY(0); }
html.reveal-ready [data-reveal]:nth-child(2) { transition-delay: 60ms; }
html.reveal-ready [data-reveal]:nth-child(3) { transition-delay: 110ms; }
html.reveal-ready [data-reveal]:nth-child(4) { transition-delay: 160ms; }

/* Tactile but restrained hover states. */
.nav-btn, .btn, .solid-link, .hero-link, .panel-button, .portal-link, .quiet-link,
.sidebar-links a, .update-row a, .article-card, .news-item, .welcome-block, .mini-cover {
  transition: transform var(--motion-fast), box-shadow var(--motion-fast), background-color var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}
.btn:hover, .solid-link:hover, .hero-link:hover, .panel-button:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(57,38,95,.18); }
.article-card:hover, .news-item:hover, .update-row:hover { transform: translateY(-2px); }
.mini-cover:hover { transform: translateY(-3px) rotate(-.5deg); box-shadow: 10px 12px 0 #d69a43; }
.sidebar-links a:hover, .update-row a:hover, .portal-link:hover { color:#39265f; }
.sidebar-links a:hover span { transform:translateX(3px); }

.reading-progress { position:fixed; inset:0 0 auto; z-index:9999; height:3px; pointer-events:none; background:rgba(116,82,164,.18); }
.reading-progress span { display:block; width:100%; height:100%; transform:scaleX(0); transform-origin:left center; background:linear-gradient(90deg,#7452a4,#d69a43); will-change:transform; }
.theme-toggle { display:inline-flex; align-items:center; gap:7px; margin:5px 8px; padding:8px 11px; border:1px solid #d9d0e6; background:#fff; color:#39265f; font:700 10px 'DM Sans',Arial,sans-serif; cursor:pointer; transition:background-color var(--motion-fast),color var(--motion-fast),border-color var(--motion-fast); }
.theme-toggle:hover { background:#eee9f7; border-color:#7452a4; }
.theme-toggle .theme-icon { font-size:14px; line-height:1; }

html[data-theme="dark"] { color-scheme:dark; --ink:#eee9f7; --plum:#e5d9f4; --violet:#c6a9ed; --lavender:#30263d; --gold:#e6b965; --paper:#201b27; --mist:#17141d; --line:#453a51; --muted:#b3aabe; }
html[data-theme="dark"] body { background:#17141d; color:#eee9f7; }
html[data-theme="dark"] header { background:linear-gradient(120deg,#21172f,#39265f 56%,#604280); }
html[data-theme="dark"] nav { background:#201b27; }
html[data-theme="dark"] .nav-container, html[data-theme="dark"] main, html[data-theme="dark"] aside,
html[data-theme="dark"] .portal-content, html[data-theme="dark"] .portal-rail,
html[data-theme="dark"] .updates-block, html[data-theme="dark"] .home-sidebar,
html[data-theme="dark"] .article-card { background:#201b27; border-color:#453a51; }
html[data-theme="dark"] .nav-btn { color:#e5d9f4; }
html[data-theme="dark"] .nav-btn:hover, html[data-theme="dark"] .nav-btn.active { background:#30263d; color:#f1d28f; }
html[data-theme="dark"] h2, html[data-theme="dark"] h3, html[data-theme="dark"] h4,
html[data-theme="dark"] .welcome-block h2, html[data-theme="dark"] .updates-heading h2,
html[data-theme="dark"] .update-row h3, html[data-theme="dark"] .sidebar-issue h3,
html[data-theme="dark"] .sidebar-links h3 { color:#e5d9f4; }
html[data-theme="dark"] p, html[data-theme="dark"] li, html[data-theme="dark"] main p,
html[data-theme="dark"] .update-row p, html[data-theme="dark"] .sidebar-issue>p:not(.eyebrow),
html[data-theme="dark"] .sidebar-links>a, html[data-theme="dark"] .sidebar-facts p { color:#c9c0d3; }
html[data-theme="dark"] .welcome-block, html[data-theme="dark"] .sidebar-issue,
html[data-theme="dark"] .callout-box, html[data-theme="dark"] .issue-panel { background:#30263d; border-color:#51445d; }
html[data-theme="dark"] .notice-strip, html[data-theme="dark"] footer { background:#130f18; }
html[data-theme="dark"] .mini-cover { background:linear-gradient(145deg,#2a1b3c,#4d3472 68%,#765b93); }
html[data-theme="dark"] .theme-toggle { background:#30263d; border-color:#665779; color:#f1d28f; }
html[data-theme="dark"] .theme-toggle:hover { background:#453653; }
html[data-theme="dark"] .update-date { background:#30263d; color:#f1d28f; }
html[data-theme="dark"] .updates-heading { border-bottom-color:#d69a43; }
html[data-theme="dark"] .home-sidebar>section, html[data-theme="dark"] .update-row,
html[data-theme="dark"] .sidebar-links>a, html[data-theme="dark"] .sidebar-facts dl,
html[data-theme="dark"] .sidebar-facts dl div { border-color:#453a51; }
html[data-theme="dark"] .update-row a, html[data-theme="dark"] .sidebar-issue>a,
html[data-theme="dark"] .portal-link { color:#c6a9ed; }
html[data-theme="dark"] pre { background:#211b2b; border-color:#453a51; color:#eee9f7; }
html[data-theme="dark"] code { background:#30263d; color:#e5d9f4; }

@media (max-width:580px) { .theme-toggle { justify-content:center; margin:8px; width:calc(100% - 16px); } }
@media (prefers-reduced-motion:reduce) {
  html { scroll-behavior:auto; }
  *, *::before, *::after { animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
  html.reveal-ready [data-reveal] { opacity:1; transform:none; }
}
