/* papers.updn.no — deep-navy dark UI. Dark-only by design: this is a reading
   surface for late evenings, so there is no light palette to fall back to. */
:root {
  --bg:          #060a14;
  --bg-glow-a:   rgba(58, 110, 255, .16);
  --bg-glow-b:   rgba(124, 92, 255, .10);
  --surface:     #0c1322;
  --surface-2:   #111a2e;
  --surface-3:   #16223c;
  --border:      #1b2743;
  --border-soft: #141e34;
  --text:        #e8eefb;
  --text-dim:    #a7b6d0;
  --muted:       #7185a5;
  --accent:      #5a94ff;
  --accent-soft: #2a4a8f;
  --violet:      #8b6cff;
  --teal:        #3ad6bd;
  --amber:       #ffb44d;
  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 10px 34px rgba(2, 6, 18, .55);
  --maxw:        1360px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body::before {   /* the glow, fixed so it does not scroll away */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1100px 520px at 18% -8%, var(--bg-glow-a), transparent 60%),
    radial-gradient(900px 460px at 88% -14%, var(--bg-glow-b), transparent 62%);
}
.wrap { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(6, 10, 20, .82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border-soft);
}
.topbar .wrap { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand { display: flex; align-items: baseline; gap: 10px; flex: 0 0 auto; }
.brand h1 {
  margin: 0; font-size: 19px; font-weight: 640; letter-spacing: -.02em;
  background: linear-gradient(92deg, #fff 10%, var(--accent) 130%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.searchbox { position: relative; flex: 1 1 auto; max-width: 560px; }
.searchbox input {
  width: 100%; height: 40px; padding: 0 78px 0 40px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 11px;
  font-size: 14px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.searchbox input::placeholder { color: var(--muted); }
.searchbox input:focus {
  outline: none; border-color: var(--accent-soft); background: var(--surface-3);
  box-shadow: 0 0 0 3px rgba(90, 148, 255, .13);
}
.searchbox .icon { position: absolute; left: 13px; top: 11px; color: var(--muted); pointer-events: none; }
.searchbox kbd {
  position: absolute; right: 10px; top: 10px;
  font: 500 11px/18px ui-monospace, Menlo, monospace; color: var(--muted);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 6px; padding: 0 7px; pointer-events: none;
}
.searchbox .clear {
  position: absolute; right: 10px; top: 9px; display: none;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; height: 22px; padding: 0 8px; font-size: 12px; cursor: pointer;
}
.searchbox.has-q .clear { display: block; }
.searchbox.has-q kbd { display: none; }

.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button {
  display: grid; place-items: center; width: 34px; height: 30px;
  background: none; border: 0; border-radius: 7px; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--text-dim); }
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--accent); }
select.sort {
  height: 40px; padding: 0 12px; background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 10px; font-size: 13px; cursor: pointer;
}

/* ------------------------------------------------------------------ hero */
.hero { margin: 26px 0 8px; }
.hero-card {
  position: relative; border-radius: 18px; padding: 1px;
  background: linear-gradient(135deg, rgba(90,148,255,.55), rgba(139,108,255,.30) 42%, rgba(27,39,67,.7) 78%);
  box-shadow: var(--shadow);
}
.hero-inner { background: linear-gradient(168deg, #0d1526 0%, #0a1120 100%); border-radius: 17px; padding: 26px 30px 24px; }
.hero-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.hero-toggle {
  flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s, transform .18s;
}
.hero-toggle:hover { color: var(--text); border-color: var(--accent-soft); }
.hero-toggle svg { transition: transform .2s ease; }
.hero.collapsed .hero-toggle svg { transform: rotate(180deg); }
.hero.collapsed .hero-body { display: none; }
.hero.collapsed .hero-head { margin-bottom: 0; }
.hero.collapsed .hero-inner { padding: 16px 30px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 11px/1 ui-monospace, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent);
}
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 0 rgba(58,214,189,.7); animation: pulse 2.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(58,214,189,0); } 100% { box-shadow: 0 0 0 0 rgba(58,214,189,0); } }
.hero-body { font-size: 15.5px; line-height: 1.72; color: var(--text-dim); max-width: 88ch; }
.hero-body p { margin: 0 0 13px; }
.hero-body p:last-child { margin-bottom: 0; }
.hero-body strong { color: var(--text); font-weight: 620; }
.hero-body em { color: var(--text); font-style: italic; }
.hero-empty { color: var(--muted); font-style: italic; }

/* -------------------------------------------------------------- controls */
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 26px 0 16px; }
.filters { display: flex; gap: 7px; flex-wrap: wrap; flex: 1 1 auto; }
.fchip {
  font-size: 12.5px; color: var(--text-dim); background: var(--surface); cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
  transition: border-color .15s, background .15s, color .15s;
}
.fchip:hover { border-color: var(--accent-soft); color: var(--text); }
.fchip[aria-pressed="true"] { background: rgba(90,148,255,.14); border-color: var(--accent-soft); color: #cfe0ff; }
.fchip .n { color: var(--muted); margin-left: 6px; font-size: 11px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); cursor: pointer; user-select: none; }
.toggle input { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); position: relative; cursor: pointer; transition: background .18s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .18s, background .18s; }
.toggle input:checked { background: rgba(90,148,255,.3); border-color: var(--accent-soft); }
.toggle input:checked::after { transform: translateX(14px); background: var(--accent); }
.result-line { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }

/* ----------------------------------------------------------------- cards */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(325px, 1fr)); }
.grid.list { grid-template-columns: 1fr; gap: 9px; }
.card {
  position: relative; text-align: left; width: 100%; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 17px 18px 15px; color: inherit; font: inherit;
  display: flex; flex-direction: column; gap: 9px;
  transition: transform .16s ease, border-color .16s, box-shadow .16s, background .16s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent-soft); background: var(--surface-2); box-shadow: var(--shadow); }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 18px; }
.badge {
  font: 600 10.5px/1 ui-monospace, Menlo, monospace; letter-spacing: .03em;
  padding: 5px 8px; border-radius: 6px; white-space: nowrap;
  background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--border);
}
.badge[data-g="preprint"]    { color: #9fc2ff; border-color: #24365c; background: rgba(90,148,255,.10); }
.badge[data-g="journal"]     { color: #b9a6ff; border-color: #322a5e; background: rgba(139,108,255,.10); }
.badge[data-g="mathphys"]    { color: #7fe3d2; border-color: #1d4a44; background: rgba(58,214,189,.09); }
.badge[data-g="foundations"] { color: #ffd08f; border-color: #4d3a1c; background: rgba(255,180,77,.09); }
.badge.new { color: var(--teal); border-color: #1d4a44; background: rgba(58,214,189,.10); }
.badge.replace { color: var(--muted); }
.card-date { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
/* The venue is context, not headline: pinned bottom-right and deliberately
   quiet, so the eye lands on the title first. */
.card-foot { margin-top: auto; padding-top: 4px; display: flex; justify-content: flex-end;
             align-items: center; gap: 10px; }
.card-foot .rel { opacity: .62; font-size: 10.5px; }
.card:hover .card-foot .rel { opacity: .9; }
.venue {
  font: 500 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .03em; color: var(--muted); opacity: .62;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.card:hover .venue { opacity: .85; }
.rel { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.rel i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; font-style: normal; }
.rel.hi { color: var(--teal); }
.rel.mid { color: var(--accent); }
.card h3 { margin: 0; font-size: 15.5px; line-height: 1.4; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.card .teaser { margin: 0; font-size: 13.2px; line-height: 1.62; color: var(--text-dim); }
.card .authors { margin: 0; font-size: 11.8px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid.list .card { flex-direction: row; align-items: baseline; gap: 14px; padding: 13px 16px; }
.grid.list .card .card-top { flex: 0 0 auto; order: -1; }
.grid.list .card .body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.grid.list .card .teaser { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid.list .card-date { flex: 0 0 auto; }
.grid.list .card .card-foot { margin-top: 0; flex: 0 0 auto; padding-top: 0; }

.skeleton { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); height: 168px; overflow: hidden; position: relative; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.035), transparent); animation: shimmer 1.5s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* An author `display` beats the [hidden] attribute's UA display:none, so the
   button stayed visible while the script believed it was hidden — during a
   search that meant a live button that appended nothing when clicked. */
.more[hidden] { display: none; }
.more { display: block; margin: 24px auto 46px; padding: 11px 26px; background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); border-radius: 11px; font-size: 13.5px; cursor: pointer; transition: border-color .15s, color .15s; }
.more:hover { border-color: var(--accent-soft); color: var(--text); }
.empty { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty h3 { color: var(--text-dim); font-weight: 550; margin: 0 0 6px; }

/* ----------------------------------------------------------------- modal */
.modal-root { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }
.modal-root[hidden] { display: none; }
.backdrop { position: absolute; inset: 0; background: rgba(3, 6, 14, .72); backdrop-filter: blur(6px); animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.modal {
  position: relative; width: min(820px, 100%); max-height: min(86vh, 900px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6); display: flex; flex-direction: column;
  animation: rise .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.modal-head { padding: 24px 26px 16px; border-bottom: 1px solid var(--border-soft); }
.modal-head .card-top { margin-bottom: 12px; }
.modal-head h2 { margin: 0 0 10px; font-size: 21px; line-height: 1.34; font-weight: 640; letter-spacing: -.015em; }
.modal-head .authors { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.modal-body { padding: 20px 26px; overflow-y: auto; font-size: 14.6px; line-height: 1.75; color: var(--text-dim); }
.modal-body h4 { margin: 0 0 9px; font: 600 11px/1 ui-monospace, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.modal-body p { margin: 0 0 14px; }
.modal-foot { padding: 16px 26px 20px; border-top: 1px solid var(--border-soft); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px;
  border-radius: 10px; font-size: 13.6px; font-weight: 550; cursor: pointer; border: 1px solid transparent;
  transition: filter .15s, border-color .15s, background .15s, color .15s;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), #4a7ce8); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); text-decoration: none; }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover { border-color: var(--accent-soft); color: var(--text); text-decoration: none; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; }
.modal-close:hover { color: var(--text); border-color: var(--accent-soft); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 18px; }
.meta-grid div { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 9px 12px; }
.meta-grid dt { font: 600 10px/1 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 5px; }
.meta-grid dd { margin: 0; font-size: 12.6px; color: var(--text-dim); word-break: break-word; }
.dl-note { font-size: 12px; color: var(--muted); margin-left: auto; }

/* ---------------------------------------------------------------- footer */
footer { border-top: 1px solid var(--border-soft); margin-top: 40px; padding: 22px 0 34px; }
footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
footer .wrap span + span::before { content: "·"; margin-right: 16px; color: var(--border); }

/* KaTeX should inherit our colour and never blow out a card's width */
.katex { color: inherit; font-size: 1.02em; }
.card .katex-display, .hero-body .katex-display { margin: .5em 0; }
.katex-display > .katex { max-width: 100%; overflow-x: auto; overflow-y: hidden; }

@media (max-width: 860px) {
  .topbar .wrap { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .searchbox { order: 3; flex-basis: 100%; max-width: none; }
  .wrap { padding: 0 16px; }
  .hero-inner { padding: 20px 18px; }
  .grid { grid-template-columns: 1fr; }
  .modal-root { padding: 0; }
  .modal { max-height: 100vh; height: 100%; border-radius: 0; border: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
