/* CM Papers: a compact mathematics reference library. */
:root {
  --primary: #00477B;
  --primary-dark: #00365E;
  --secondary: #1E3A8A;
  --amber: #FFB663;
  --yellow: #FFDE00;
  --accent: #F1F5F8;
  --background: #FFFFFF;
  --surface: #FFFFFF;
  --text: #1F2937;
  --muted: #526172;
  --border: #D5DEE7;
  --border-light: #E8EDF2;
  --focus: #00477B;
  --radius-sm: 3px;
  --radius: 5px;
  --radius-lg: 6px;
  --shadow: none;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Sinhala', 'Nirmala UI', 'Iskoola Pota', Arial, sans-serif;
  --font-math: Georgia, 'Times New Roman', serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --interaction: 160ms ease;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--background); color: var(--text); font: 400 var(--text-base)/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
img, svg, iframe { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
::selection { background: var(--amber); color: var(--text); }
.container { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -80px; left: var(--space-6); z-index: 1000; background: #fff; color: var(--primary); padding: var(--space-3) 18px; border: 2px solid var(--primary); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--space-3); }
h1,h2,h3,h4,p { margin-top: 0; }
h1,h2,h3 { line-height: 1.3; letter-spacing: -.035em; }
h1 { font-weight: 750; }
h2 { font-size: clamp(1.7rem, 3vw, 2.15rem); font-weight: 720; }
h3 { font-weight: 680; }
em { font-style: normal; color: var(--primary); }
.icon { display: inline-block; width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--primary); font-size: var(--text-xs); letter-spacing: .12em; text-transform: uppercase; font-weight: 750; line-height: 1.5; }
.eyebrow-line { display: inline-block; width: 23px; height: 2px; background: var(--primary); }
.mini-label { color: #D8E6F1; font-weight: 700; font-size: var(--text-xs); letter-spacing: .12em; line-height: 1.5; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid transparent; border-radius: var(--radius-sm); min-height: 44px; padding: 10px 18px; font-size: var(--text-sm); line-height: 1.35; font-weight: 680; transition: background var(--interaction), color var(--interaction), border-color var(--interaction), transform var(--interaction); white-space: normal; text-align: center; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--yellow); color: var(--text); border-color: var(--yellow); }
.btn-primary:hover { background: var(--amber); border-color: var(--amber); }
.btn-secondary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-secondary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--primary); }
.btn-outline:hover { background: var(--accent); }
.btn-light { background: var(--yellow); color: var(--text); }
.btn-light:hover { background: var(--amber); }
.btn-small { min-height: 44px; padding: 9px var(--space-3); font-size: .82rem; }
.text-link { min-height: 44px; display: inline-flex; align-items: center; gap: 9px; color: var(--primary); font-size: .9rem; font-weight: 700; }
.text-link:hover, .back-link:hover { text-decoration: underline; text-underline-offset: var(--space-1); }
.text-link .icon { width: var(--space-4); height: var(--space-4); }
.main-content { min-height: 60vh; }
.placeholder-copy { color: var(--muted); font-size: .88rem; }
.loading-placeholder { gap: var(--space-3); padding: var(--space-6); background: var(--border-light); border: 1px dashed var(--border-light); border-radius: var(--radius); min-height: 118px; display: grid; place-items: center; color: var(--muted); font-size: .92rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }

/* Feedback remains brief and respects reduced-motion preferences. */
main:focus { outline: none; }
input[type="search"] { scroll-margin-top: 100px; }
.script-notice { margin-block: 20px; padding: var(--space-4); background: var(--accent); border-radius: var(--radius); }
.script-notice a { text-decoration: underline; }
.btn:active { transform: translateY(1px); }
@media (prefers-reduced-motion: no-preference) {
  .hero-copy, .archive-intro .container, .viewer-heading { animation: arrive .24s ease-out both; }
  .paper-list { animation: arrive .24s ease-out both; }
  .loading-placeholder::before { content: ''; width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: loading .8s linear infinite; }
  @keyframes arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes loading { to { transform: rotate(360deg); } }
}
