/* ===================================================================
   HiPolicy — Academic Project Page (v2 – refined)
   =================================================================== */

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

:root {
  --bg: #fcfcfd;
  --bg-alt: #f4f5f9;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #3b3b4f;
  --text-muted: #7c7c8a;
  --text-light: #a8a8b3;
  --accent: #4f5bd5;
  --accent-hover: #3d48b0;
  --accent-glow: rgba(79, 91, 213, 0.10);
  --border: #d5d5dc;
  --border-light: #e9e9f0;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.045);
  --shadow-md: 0 6px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.08);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;

  --max-w: 960px;
  --nav-h: 56px;
  --radius: 8px;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
}

img, video { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-glow); }

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
}

/* ======= Nav ======= */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(252,252,253,.88);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, box-shadow .3s;
}
nav.scrolled {
  border-bottom-color: var(--border-light);
  box-shadow: 0 1px 8px rgba(0,0,0,.04);
}
nav .nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
}
nav .nav-brand {
  font-weight: 800;
  font-size: .88rem;
  letter-spacing: -.03em;
  color: var(--text);
}
nav .nav-links {
  display: flex;
  gap: 26px;
  list-style: none;
}
nav .nav-links a {
  font-size: .72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  transition: color .15s;
}
nav .nav-links a:hover { color: var(--text); }

/* ======= Hero ======= */
.hero {
  padding: 88px 0 60px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
  border-bottom: 1px solid var(--border-light);
}

.hero h1 {
  font-family: var(--serif);
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -.04em;
  color: var(--text);
  margin-bottom: 10px;
}

.hero-subtitle {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-style: italic;
}

/* Authors */
.authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 6px;
  margin-bottom: 14px;
  font-size: .84rem;
}
.authors .author { color: var(--text-secondary); }
.authors .name {
  font-weight: 500;
  color: var(--text);
  transition: color .15s;
}
.authors .name:hover { color: var(--accent); }
.authors .sep { color: var(--text-light); font-size: .7rem; }
.authors sup {
  color: var(--text-light);
  font-size: .58rem;
  margin-left: 1px;
}
.authors .corresponding {
  color: var(--accent);
  font-size: .68rem;
  vertical-align: super;
}

.affiliations {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 18px;
  font-size: .7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.affiliations sup {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: .56rem;
  margin-right: 1px;
}

.email {
  font-size: .72rem;
  color: var(--text-light);
  margin-bottom: 30px;
  font-family: var(--mono);
}

/* Buttons */
.btn-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 24px;
  font-size: .8rem;
  font-weight: 600;
  border-radius: 6px;
  transition: all .2s ease;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 91, 213, .25);
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(79, 91, 213, .30);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ======= Sections ======= */
section {
  padding: 64px 0;
}
.section-alt {
  background: var(--bg-alt);
}

.section-title {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 32px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--text);
}

/* ======= Abstract ======= */
.abstract-text {
  font-family: var(--serif);
  font-size: .95rem;
  line-height: 1.95;
  color: var(--text-secondary);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.abstract-text strong {
  color: var(--text);
  font-weight: 600;
}

.keywords {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.keywords span {
  display: inline-block;
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: .7rem;
  font-weight: 500;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ======= Figures (general) ======= */
figure { margin: 0; }

figure img {
  border-radius: 4px;
}

figcaption {
  margin-top: 12px;
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.7;
  font-family: var(--sans);
}
figcaption strong {
  color: var(--text-secondary);
}

.figure-full {
  margin-bottom: 40px;
}
.figure-full img {
  width: 100%;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}

.figure-entropy {
  max-width: 80%;
  margin: 24px auto 32px;
}
.figure-entropy img {
  width: 100%;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}

/* ======= Teaser ======= */
.section-figure {
  background: var(--bg-alt);
  padding: 48px 0;
}

.figure-teaser-stack {
  max-width: 100%;
  margin: 0 auto;
}

/* Use unequal columns matching actual aspect ratios so heights align naturally.
   teaser.png  ≈ 1.36 : 1   →  ~28% of row
   teaser_comparison.png ≈ 3.50 : 1  →  ~72% of row
   At these proportions both images reach the same height with no padding. */
.teaser-stack {
  display: grid;
  grid-template-columns: 28fr 72fr;
  gap: 12px;
  align-items: start;
}

.teaser-stack img {
  width: 100%;
  height: auto;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}

/* ======= Method ======= */
.method-text {
  margin-bottom: 48px;
  font-family: var(--serif);
}
.method-text:last-child {
  margin-bottom: 0;
}
.method-text h3 {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 700;
  margin-bottom: 14px;
  line-height: 1.35;
  color: var(--text);
}
.method-text p {
  font-size: .92rem;
  color: var(--text-secondary);
  line-height: 1.85;
  margin-bottom: 14px;
}

.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}
.feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-family: var(--sans);
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border-light);
}
.feature-badge {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .62rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
  font-family: var(--sans);
}
.feature-badge.hf { background: #e74c3c; }
.feature-badge.lf { background: #3498db; }
.feature-badge.le { background: #27ae60; }
.feature-badge.he { background: #f39c12; }

.feature strong {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  font-family: var(--sans);
}
.feature p {
  font-size: .76rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
  font-family: var(--sans);
}

.figure-side { display: none; }

/* ======= Simulation ======= */
.sim-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.sim-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s, transform .2s;
}
.sim-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sim-card h3 {
  font-family: var(--sans);
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.sim-card ul {
  padding-left: 16px;
  margin: 0;
}

.sim-card li {
  font-family: var(--sans);
  font-size: .76rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.sim-note {
  margin-top: 10px;
  font-size: .68rem;
  line-height: 1.5;
  color: var(--text-muted);
  font-family: var(--sans);
}

/* ======= Task + Demo layout ======= */
.task-demo-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.figure-tasks {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.figure-tasks img {
  width: 100%;
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.task-caption {
  margin-top: 12px;
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.7;
  font-family: var(--sans);
}
.task-caption strong {
  color: var(--text-secondary);
}

/* ---- Demo video slider ---- */
.demo-videos {
  flex-shrink: 0;
  /* width & height set by JS to match image height + 16:9 video ratio */
}

.demo-slider {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0a0a0f;
  box-shadow: var(--shadow-md);
}

.demo-track {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: visible;
  transition: transform .4s ease;
}

.demo-slide {
  min-width: 100%;
  height: 100%;
  flex-shrink: 0;
}

.demo-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.demo-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.demo-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: .68rem;
  color: var(--text-muted);
  transition: all .15s;
}
.demo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.demo-indicators {
  display: flex;
  gap: 4px;
}

.demo-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all .2s;
}
.demo-dot.active {
  background: var(--accent);
  width: 14px;
  border-radius: 3px;
}

.demo-task-name {
  text-align: center;
  padding: 4px 0 6px;
  font-size: .64rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  font-family: var(--sans);
  flex-shrink: 0;
}

/* ======= Citation ======= */
.cite-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  position: relative;
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}
.cite-box pre {
  font-family: var(--mono);
  font-size: .74rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}
.cite-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: .66rem;
  cursor: pointer;
  font-family: var(--sans);
  font-weight: 500;
  transition: all .15s;
}
.cite-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ======= Footer ======= */
footer {
  text-align: center;
  padding: 28px 0;
  font-size: .72rem;
  color: var(--text-light);
  border-top: 1px solid var(--border-light);
  font-family: var(--sans);
}

/* ======= Responsive ======= */
@media (max-width: 768px) {
  .hero { padding: 56px 0 40px; }
  .hero h1 { font-size: 2.2rem; }
  .hero-subtitle { font-size: .95rem; }
  .feature-grid { grid-template-columns: 1fr; }
  .feature { padding: 12px; }
  .sim-grid { grid-template-columns: 1fr; }
  .figure-teaser-stack { max-width: 100%; }
  .teaser-stack {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .task-demo-layout {
    flex-direction: column;
  }
  .demo-videos {
    width: 100% !important;
    height: auto !important;
  }
  .demo-slider {
    height: auto;
  }
  .demo-track {
    flex: none;
  }
  .demo-slide video {
    aspect-ratio: 16 / 9;
    max-height: none;
  }
  .figure-entropy { max-width: 100%; }
  section { padding: 44px 0; }
  nav .nav-links { gap: 16px; }
  nav .nav-links a { font-size: .66rem; }
  .btn-row { flex-direction: column; align-items: center; }
  .btn { width: 100%; max-width: 240px; justify-content: center; }
  .authors { gap: 0 6px; font-size: .78rem; }
  .affiliations { flex-direction: column; align-items: center; gap: 2px; }
  .container { padding: 0 20px; }
}

@media (max-width: 480px) {
  nav .nav-links { display: none; }
  .hero h1 { font-size: 1.8rem; }
  .hero { padding: 40px 0 32px; }
  .container { padding: 0 16px; }
}
