/* Cosmic Academic Theme — two-column layout with header,
   left contents, right body. Clean, readable, "intellectual". */

/* =========================
   Root + Themes
   ========================= */

:root {
  --font-main: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-alt: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --bg: #020817;
  --bg-soft: rgba(6, 11, 25, 0.98);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #38bdf8; /* sky for dark */
  --border: rgba(148, 163, 253, 0.22);

  --link-color: #38bdf8;
  --link-hover: #7dd3fc;

  --radius-lg: 24px;
  --radius-md: 12px;
  --shadow-soft: 0 26px 90px rgba(15, 23, 42, 0.9);
  --transition-fast: 0.18s ease-in-out;

  --base-font-size: 17px; /* slightly larger */
}

[data-theme="light"] {
  --bg: #f9fafb;
  --bg-soft: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --accent: #1d4ed8; /* deep blue */
  --border: #e5e7eb;

  --link-color: #1d4ed8;
  --link-hover: #1d4ed8;

  --shadow-soft: 0 16px 46px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --bg: #020817;
  --bg-soft: rgba(6, 11, 25, 0.98);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #38bdf8;
  --border: rgba(148, 163, 253, 0.22);

  --link-color: #38bdf8;
  --link-hover: #7dd3fc;

  --shadow-soft: 0 26px 90px rgba(15, 23, 42, 0.9);
}

/* =========================
   Reset + Base
   ========================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-main);
  font-size: var(--base-font-size);
  line-height: 1.7;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

/* =========================
   Starfield Background (dark only)
   ========================= */

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -2;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(circle at 100% 8%, rgba(79, 70, 229, 0.20), transparent 55%),
    radial-gradient(circle at 0% 100%, rgba(15, 23, 42, 0.98), transparent 72%),
    var(--bg);
}

body::after {
  background-image:
    radial-gradient(1px 1px at 8% 18%, rgba(248, 250, 252, 0.9), transparent),
    radial-gradient(1px 1px at 24% 76%, rgba(148, 163, 253, 0.6), transparent),
    radial-gradient(1px 1px at 60% 32%, rgba(191, 219, 254, 0.55), transparent),
    radial-gradient(1px 1px at 90% 58%, rgba(248, 250, 252, 0.9), transparent),
    radial-gradient(1px 1px at 40% 10%, rgba(129, 140, 248, 0.4), transparent);
  background-size: 260px 260px;
  mix-blend-mode: screen;
  opacity: 0.55;
  animation: twinkle 22s linear infinite alternate;
}

[data-theme="light"] body::before,
[data-theme="light"] body::after { display: none; }

@keyframes twinkle {
  0%   { opacity: 0.3; transform: translate3d(0,0,0); }
  100% { opacity: 0.9; transform: translate3d(-14px,-10px,0); }
}

/* =========================
   Typography & Links
   ========================= */

p { margin: 0 0 0.7em; max-width: 70rem; }

a {
  color: var(--link-color);
  text-decoration: none; /* no underline */
  transition: color var(--transition-fast), opacity var(--transition-fast);
}
a:hover,
a:focus-visible { color: var(--link-hover); opacity: 0.9; }

/* =========================
   Shell + Header
   ========================= */

.site-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 22px 40px;
}

.site-header { margin-bottom: 30px; }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 24px 22px;
  background: var(--bg-soft);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

.header-text { display: flex; flex-direction: column; gap: 6px; }

.site-name {
  font-size: 2.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.site-tagline { font-family: var(--font-alt); font-size: 1rem; color: var(--muted); }

.site-affiliation { font-size: 0.92rem; color: var(--muted); }

.header-links {
  display: flex; flex-wrap: wrap; gap: 9px; margin-top: 6px;
}
.header-links a {
  font-size: 0.8rem;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: transparent;
  transition: all var(--transition-fast);
}
.header-links a:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

/* Portrait */
.photo-frame {
  width: 150px; height: 150px;
  border-radius: 999px; overflow: hidden;
  background:
    radial-gradient(circle at 30% 0, rgba(56,189,248,0.26), transparent),
    radial-gradient(circle at 80% 90%, rgba(79,70,229,0.24), transparent),
    #020817;
  display: flex; align-items: center; justify-content: center;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }

.theme-toggle {
  margin-top: 8px;
  align-self: flex-start;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

/* =========================
   Two-column Layout
   ========================= */

.page-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 30px;
  margin-top: 24px;
}

/* Left: contents index */
.side-menu {
  position: sticky;
  top: 130px;
  align-self: flex-start;
  font-size: 0.86rem;
  color: var(--muted);
}
.side-menu-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 8px;
}
.side-menu nav { display: flex; flex-direction: column; gap: 4px; }
.side-menu a { color: var(--muted); padding: 3px 0; border-radius: 6px; }
.side-menu a:hover { color: var(--accent); }

/* Right: content */
.main-content { display: flex; flex-direction: column; gap: 18px; }

.section {
  background: var(--bg-soft);
  padding: 18px 18px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 253, 0.16);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}
.section h2 {
  margin: 0 0 8px;
  font-size: 1.04rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--font-alt);
}
.section p,
.section li { font-size: 0.98rem; color: var(--text); }
.section-intro { font-size: 0.86rem; color: var(--muted); }

/* Basic math block helper */
.math-block { text-align: center; margin: 6px 0 10px; }
.section ul, .section ol { margin-left: 1.1rem; padding-left: 1.1rem; }
.section li { margin: 4px 0; }

/* Lists / items */
.item-list { list-style: none; padding: 0; margin: 0; }
.item-list li { margin-bottom: 10px; }
.item-title, .pub-title { font-weight: 600; }
.item-label, .pub-venue, .pub-authors { font-size: 0.8rem; color: var(--muted); }

/* Project / figure cards */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 8px; }
.project-card {
  padding: 10px 10px 9px;
  border-radius: var(--radius-md);
  background-color: rgba(2, 6, 23, 0.98);
  border: 1px solid var(--border);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.9);
  display: flex; flex-direction: column; gap: 3px;
  transition: all var(--transition-fast);
}
[data-theme="light"] .project-card { background-color: var(--bg-soft); box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06); }
.project-card:hover { transform: translateY(-3px); box-shadow: 0 18px 50px rgba(15, 23, 42, 0.95); border-color: var(--accent); }
.project-name { font-size: 0.9rem; font-weight: 600; }
.project-desc { font-size: 0.8rem; color: var(--muted); }
.project-meta { font-size: 0.72rem; color: var(--muted); display: flex; justify-content: space-between; gap: 4px; }
.project-link { font-size: 0.78rem; }

/* Figure list on VEB page (stacked) */
.figure-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

/* Side-by-side videos */
.video-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
  align-items: flex-start;
  justify-content: space-between;
}
.video-col { flex: 1 1 260px; min-width: 260px; }
.veb-video {
  width: 100%;
  display: block;
  margin-top: 6px;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.9);
  background-color: #000;
}

/* Software section media grid (video + image) */
.software-media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.software-media-card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

/* Make video / image fill the card nicely */
.software-media-card video,
.software-media-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Inline code / math */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 2px 5px;
  border-radius: 5px;
  background-color: rgba(15, 23, 42, 0.98);
  color: #bfdbfe;
}
[data-theme="light"] code,
[data-theme="light"] kbd,
[data-theme="light"] samp { background-color: #111827; color: #bfdbfe; }

/* Footer */
.footer {
  max-width: 1180px;
  margin: 20px auto 0;
  padding: 4px 22px 16px;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 900px) {
  .site-shell { padding: 22px 14px 26px; }

  .header-inner { flex-direction: row; align-items: flex-start; gap: 18px; }

  .photo-frame { width: 96px; height: 96px; }

  .page-layout { grid-template-columns: 1fr; gap: 16px; margin-top: 18px; }

  .side-menu {
    position: static;
    display: flex; flex-wrap: wrap; gap: 10px;
    padding: 10px 10px 6px;
    background: var(--bg-soft);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
  }
  .side-menu-title { width: 100%; margin-bottom: 2px; }
  .side-menu nav { flex-direction: row; flex-wrap: wrap; gap: 8px 12px; }
  .video-row { flex-direction: column; }
}

/* Stack software media cards on very small screens */
@media (max-width: 640px) {
  .software-media-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Theorem Section — robust layout (GLOBAL)
   ========================= */

/* Turn selected <p> into bullets without changing your text */
#theorem .p-bullet{
  display: list-item;
  list-style: disc;
  list-style-position: outside;
  margin: 0 0 .55em 1.3em;
  padding-left: .2em;
}
#theorem .p-sub{
  display: list-item;
  list-style: circle;
  list-style-position: outside;
  margin: 0 0 .45em 2.2em;
  padding-left: .2em;
}
#theorem .p-note{ margin: .4em 0 .8em; }

/* Math blocks + MathJax SVG */
#theorem .math-block { display: block; text-align: center; margin: 6px 0 10px; }
#theorem .math-block mjx-container[jax="SVG"] { display: inline-block !important; vertical-align: middle; }

#theorem h4 { margin-top: 1rem; }
