/* ============================================================
   THEME / POLISH LAYER  (loaded AFTER each page's own stylesheet)
   Refines the existing dark-minimal identity: depth, smoother
   motion, refined cards, scroll reveal, page transitions.
   Safe to remove by deleting the <link> + <script> tags.
   ============================================================ */

/* one consistent web font across every page / device */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* applies site-wide (loaded after each page's own font-family) */
html, body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

/* Cross-page View Transitions are intentionally OFF (the root size-morph made
   the short home page look shrunk). Instead we fade page content in/out via JS,
   over a constant dark background, so there is no blank frame and no scaling. */
body { opacity: 1 !important; }

/* arriving content page: a quick, snappy fade-up so navigation feels continuous
   (navigation itself is instant; home has its own signature entrance) */
main.page {
  animation: pageEnter 0.32s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}

:root {
  --bg:          #07080a;
  --surface-top: #161719;
  --surface-bot: #0f1011;
  --line:        rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.22);
  --muted:       rgba(255,255,255,0.62);
  --radius:      18px;
  --accent:      120,150,230;          /* cool premium accent (rgb) */
  --ease:        cubic-bezier(.22,.61,.36,1);
  --ease-out:    cubic-bezier(.16,1,.3,1);
}

/* ===== smoother base ===== */
html {
  background: var(--bg);
  scroll-behavior: smooth;
}
body {
  background: transparent;
}

/* refined scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.26); background-clip: padding-box; }

/* nicer text selection */
::selection { background: rgba(255,255,255,0.16); color: #fff; }

/* accessible focus */
a:focus-visible, button:focus-visible {
  outline: 2px solid rgba(255,255,255,0.55);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ===== ambient aurora (behind everything) ===== */
.aurora {
  position: fixed;
  inset: 0;                 /* stay within the viewport (no horizontal overflow) */
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  filter: blur(90px);
}
.aurora span {
  position: absolute;
  display: block;
  border-radius: 50%;
  opacity: 0.72;
  will-change: transform;
}
.aurora span:nth-child(1) {
  width: 46vw; height: 46vw;
  top: -6%; left: 8%;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06), transparent 65%);
  animation: auroraA 30s var(--ease) infinite alternate;
}
.aurora span:nth-child(2) {
  width: 40vw; height: 40vw;
  top: 30%; right: 4%;
  background: radial-gradient(circle at 50% 50%, rgba(190,194,202,0.05), transparent 65%);
  animation: auroraB 38s var(--ease) infinite alternate;
}
.aurora span:nth-child(3) {
  width: 38vw; height: 38vw;
  bottom: -10%; left: 30%;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.045), transparent 65%);
  animation: auroraC 44s var(--ease) infinite alternate;
}
@keyframes auroraA { from { transform: translate3d(-4%, -3%, 0) scale(1); } to { transform: translate3d(6%, 5%, 0) scale(1.15); } }
@keyframes auroraB { from { transform: translate3d(3%, 2%, 0) scale(1.05); } to { transform: translate3d(-5%, -4%, 0) scale(0.95); } }
@keyframes auroraC { from { transform: translate3d(0, 4%, 0) scale(1); } to { transform: translate3d(4%, -4%, 0) scale(1.12); } }

/* ===== cursor glow (desktop, subtle) ===== */
.cursor-glow {
  position: fixed;
  top: 0; left: 0;
  width: 480px; height: 480px;
  margin: -240px 0 0 -240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.06), transparent 60%);
  pointer-events: none;
  z-index: 60;
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity .5s ease;
  will-change: transform;
}
.cursor-glow.on { opacity: 1; }

/* ===== topbar: SOLID ===== */
.topbar {
  background: #0c0d0f;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid transparent;
  transition: border-color .35s var(--ease), box-shadow .35s var(--ease);
}
.topbar.scrolled {
  background: #0c0d0f;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 14px 40px -28px rgba(0,0,0,0.95);
}
.brand { transition: letter-spacing .35s var(--ease), color .25s var(--ease); }
.brand:hover { letter-spacing: 0.26em; color: #fff; }

/* tighten the desktop nav so 7 items sit comfortably next to the logo */
.topbar .nav { gap: 1.7rem; }

/* collapse to the hamburger BEFORE the nav items crowd the logo
   (raised from 768px because there are now 7 menu items) */
@media (max-width: 1024px) {
  .topbar .menu-toggle { display: block; }
  .topbar .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 26px 0 32px;
    background: #0c0d0f;
    border-bottom: 1px solid var(--line);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity .28s var(--ease), transform .28s var(--ease);
  }
  .topbar .nav.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* ===== one consistent nav underline everywhere (home, lists, entries) ===== */
.nav a { transition: color .25s var(--ease); }
.nav a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.85), transparent);
  transition: width .3s var(--ease), left .3s var(--ease);
}
.nav a:hover::after,
.nav a.active::after {
  width: 100%;
  left: 0;
}

/* ===== page header: subtle gradient title ===== */
.page-header h1 {
  background-image: linear-gradient(120deg, #cfd2d6 0%, #ffffff 50%, #cfd2d6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ===== full-width frosted-glass header band (iOS-style) ===== */
.page { padding-top: 78px; }            /* sit flush under the solid topbar */

.page-header {
  position: relative;
  margin-bottom: 0;                     /* band sits directly above content */
  padding: 56px 6vw 60px;
  background: rgba(14,15,17,0.62);        /* dark, near-black frosted glass */
  -webkit-backdrop-filter: blur(20px) saturate(110%);
  backdrop-filter: blur(20px) saturate(110%);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* ===== content surface: its own dark panel below the band ===== */
.content-surface {
  background: linear-gradient(180deg, var(--surface-top) 0%, var(--surface-bot) 100%);
  position: relative;
}

@media (max-width: 768px) {
  .page { padding-top: 64px; }
  .page-header { padding: 34px 6vw 38px; }
}

/* ===== unified card polish (research / publications / initiatives / posts) ===== */
.research-card,
.publication-card,
.initiative-card,
.post-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.012));
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);   /* subtle top edge */
  transition: transform .45s var(--ease-out),
              border-color .35s var(--ease),
              background .35s var(--ease),
              box-shadow .45s var(--ease-out);
  will-change: transform;
}
/* left accent that grows on hover */
.research-card::before,
.publication-card::before,
.initiative-card::before,
.post-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, rgba(255,255,255,0.85), rgba(255,255,255,0.15));
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .45s var(--ease-out);
}
.research-card:hover,
.publication-card:hover,
.initiative-card:hover,
.post-card:hover {
  transform: translateY(-5px);
  border-color: var(--line-strong);
  background: linear-gradient(180deg, rgba(255,255,255,0.065), rgba(255,255,255,0.02));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 32px 60px -32px rgba(0,0,0,0.9);
}
.research-card:hover::before,
.publication-card:hover::before,
.initiative-card:hover::before,
.post-card:hover::before {
  transform: scaleY(1);
}
.research-card h2,
.publication-card h2,
.initiative-card h2,
.post-card h2 {
  transition: color .25s var(--ease);
}

/* ===== "Elsewhere" + entry links: smoother ===== */
.elsewhere-links a,
.entry-links a {
  transition: color .2s var(--ease), border-color .2s var(--ease);
}

/* ===== page fade overlay (works on every page) ===== */
.page-fade {
  position: fixed;
  inset: 0;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .42s var(--ease);
  z-index: 9999;
}
.page-fade.active { opacity: 1; }

/* (No scroll-reveal animation: content is simply present as you scroll.) */

/* ===== footer (consistent across all pages, with legal links) ===== */
.footer {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  height: auto;
  padding: 30px 6vw calc(30px + env(safe-area-inset-bottom));
}
.footer .copyright {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
}
.footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  pointer-events: auto;
}
.footer-meta a {
  pointer-events: auto;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.28);
  text-decoration: none;
  transition: color .25s var(--ease);
}
.footer-meta a:hover { color: rgba(255,255,255,0.6); }

/* ===== mobile safety: prevent horizontal overflow, wrap long content ===== */
html, body { overflow-x: hidden; }

.page-header h1,
.research-card h2,
.publication-card h2,
.initiative-card h2,
.post-card h2,
.content p,
.intro,
.exp-org {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* entry meta row: wrap instead of forcing the page wide */
.meta {
  flex-wrap: wrap;
}
@media (max-width: 768px) {
  .meta { gap: 6px 16px; }
}

/* Note: animations intentionally play regardless of the OS "Reduce Motion"
   setting, by request. (No prefers-reduced-motion overrides.) */
