/* ===================================================================
   RobustMAD — Academic Project Page
   =================================================================== */

:root {
  --bg: #ffffff;
  --bg-alt: #f6f8fc;
  --bg-band: #0f172a;
  --ink: #1a2233;
  --ink-soft: #475069;
  --ink-faint: #565f74;
  --line: #e6eaf2;
  --accent: #4f46e5;
  --accent-dark: #3730a3;
  --accent-soft: #eef0fe;
  --accent-2: #0ea5e9;
  --danger: #dc2626;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 12px 32px rgba(16, 24, 40, .10), 0 4px 12px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .16);
  --maxw: 1140px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* Visible keyboard focus (WCAG 2.4.7) — only for keyboard navigation, never removed. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.stats-band :focus-visible,
.footer :focus-visible,
.copy-btn:focus-visible,
.lightbox-close:focus-visible { outline-color: #a5b4fc; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 820px; }

sup { font-size: .62em; font-weight: 600; }

/* ===================== NAV ===================== */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.nav.scrolled { border-bottom-color: var(--line); box-shadow: var(--shadow-sm); }
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  height: 62px; display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
  font-weight: 800; font-size: 1.18rem; letter-spacing: -.02em; color: var(--ink);
}
.nav-brand:hover { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a {
  color: var(--ink-soft); font-size: .92rem; font-weight: 500; position: relative;
}
.nav-links a:not(.nav-cta)::after {
  content: ''; position: absolute; left: 0; bottom: -6px; height: 2px; width: 0;
  background: var(--accent); transition: width .22s ease;
}
.nav-links a:not(.nav-cta):hover { color: var(--ink); }
.nav-links a:not(.nav-cta):hover::after { width: 100%; }
.nav-cta {
  background: var(--accent); color: #fff !important; padding: 8px 16px;
  border-radius: 999px; font-weight: 600; box-shadow: var(--shadow-sm);
}
.nav-cta:hover { background: var(--accent-dark); transform: translateY(-1px); }
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav-toggle span {
  display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px;
  margin: 4px 0; transition: .25s;
}

/* ===================== HERO ===================== */
.hero {
  position: relative; overflow: hidden;
  padding: 72px 0 56px;
  text-align: center;
  background: linear-gradient(180deg, #fbfcff 0%, #f3f5fc 100%);
  border-bottom: 1px solid var(--line);
}
.hero-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 18% 0%, rgba(79, 70, 229, .10), transparent 70%),
    radial-gradient(50% 45% at 88% 8%, rgba(14, 165, 233, .10), transparent 70%);
}
.hero .container { position: relative; z-index: 1; }

.venue-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px; font-size: .82rem; font-weight: 600; color: var(--ink-soft);
  box-shadow: var(--shadow-sm); margin-bottom: 26px; letter-spacing: .01em;
}
.venue-badge .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.title {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 3.6vw, 2.85rem);
  line-height: 1.18; font-weight: 600; letter-spacing: -.015em;
  margin: 0 auto 30px; max-width: 980px; color: var(--ink);
}

.authors {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px;
  margin-bottom: 16px; font-size: 1.06rem;
}
.author a { color: var(--ink); font-weight: 600; }
.author a:hover { color: var(--accent); }
.author sup { color: var(--ink-faint); }

.affiliations {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px;
  color: var(--ink-soft); font-size: .92rem; margin-bottom: 6px;
}
.affiliations sup { color: var(--accent); }
.corresponding { color: var(--ink-faint); font-size: .82rem; margin-bottom: 32px; }
.corresponding span { color: var(--accent); font-weight: 700; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 22px; border-radius: 999px;
  font-weight: 600; font-size: .95rem;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.btn svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: var(--accent-dark); border-color: #d7dcef; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }

/* ===================== STATS BAND ===================== */
.stats-band { background: var(--bg-band); color: #fff; padding: 38px 0; }
.stats-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 18px; text-align: center;
}
.stat-num {
  font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 800; letter-spacing: -.02em;
  color: #fff; line-height: 1.1;
  background: linear-gradient(90deg, #a5b4fc, #7dd3fc);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-label { font-size: .82rem; color: #aab4cc; margin-top: 6px; }

/* ===================== SECTIONS ===================== */
.section { padding: 76px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-teaser { padding: 56px 0 20px; }

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.55rem, 2.8vw, 2.15rem); font-weight: 600; letter-spacing: -.01em;
  margin: 0 0 26px; color: var(--ink); text-align: center;
}
.section-intro {
  max-width: 780px; margin: 0 auto 40px; text-align: center;
  color: var(--ink-soft); font-size: 1.05rem;
}

.lead { font-size: 1.16rem; color: var(--ink); margin-top: 0; }
#abstract p { font-size: 1.04rem; color: var(--ink-soft); }
#abstract p strong, #abstract p em { color: var(--ink); }

/* ===================== FIGURES ===================== */
.figure { margin: 36px auto 0; max-width: 960px; text-align: center; }
.figure-wide { max-width: 1080px; }
.figure img {
  width: 100%; height: auto; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff;
  box-shadow: var(--shadow); cursor: zoom-in;
  transition: transform .25s ease, box-shadow .25s ease;
}
.figure img:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.figure figcaption {
  margin-top: 16px; font-size: .92rem; color: var(--ink-faint);
  line-height: 1.6; max-width: 820px; margin-left: auto; margin-right: auto; text-align: left;
}
.figure figcaption strong { color: var(--ink-soft); }

/* ===================== CARDS ===================== */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 22px; box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #d7dcef; }
.card-icon {
  font-size: 1.7rem; width: 52px; height: 52px; display: grid; place-items: center;
  background: var(--accent-soft); border-radius: 14px; margin-bottom: 16px;
}
.card h3 { font-size: 1.06rem; margin: 0 0 8px; letter-spacing: -.01em; }
.card p { font-size: .92rem; color: var(--ink-soft); margin: 0; }

/* ===================== CATEGORIES ===================== */
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 8px; }
.category {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.category::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.category:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.category-tag {
  display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--accent); background: var(--accent-soft);
  padding: 3px 10px; border-radius: 999px; margin-bottom: 12px;
}
.category h3 { font-size: 1.02rem; margin: 0 0 8px; letter-spacing: -.01em; }
.category p { font-size: .9rem; color: var(--ink-soft); margin: 0; }

/* ===================== DATASET FACTS ===================== */
.dataset-facts {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-top: 44px;
}
.fact {
  text-align: center; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 18px 10px; box-shadow: var(--shadow-sm);
}
.fact-num { display: block; font-size: 1.7rem; font-weight: 800; color: var(--accent); letter-spacing: -.02em; }
.fact-label { font-size: .78rem; color: var(--ink-faint); }

/* ===================== FINDINGS ===================== */
.finding-block {
  max-width: 860px; margin: 0 auto 30px; padding: 24px 28px;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.finding-block h3 {
  display: flex; align-items: center; gap: 14px; margin: 0 0 8px;
  font-size: 1.14rem; letter-spacing: -.01em;
}
.finding-no {
  font-family: var(--font-serif); font-size: 1.25rem; font-weight: 700;
  color: var(--accent); opacity: .55; min-width: 32px;
}
.finding-block p { margin: 0; color: var(--ink-soft); }
.finding-block strong { color: var(--ink); }

/* ===================== FAILURES ===================== */
.failure-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.failure {
  position: relative; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 30px 24px 24px; box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}
.failure:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.failure-badge {
  position: absolute; top: -16px; left: 24px;
  width: 38px; height: 38px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--danger), #f87171); color: #fff;
  font-family: var(--font-serif); font-weight: 700; font-style: italic; font-size: 1rem;
  border-radius: 10px; box-shadow: 0 6px 16px rgba(220, 38, 38, .3);
}
.failure h3 { margin: 6px 0 10px; font-size: 1.05rem; letter-spacing: -.01em; }
.failure p { margin: 0; font-size: .92rem; color: var(--ink-soft); }

/* ===================== GUIDANCE ===================== */
.guidance-list { display: grid; gap: 16px; margin-bottom: 36px; }
.guidance-item {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 22px 24px; box-shadow: var(--shadow-sm);
  position: relative; padding-left: 56px;
}
.guidance-item::before {
  content: '\2713'; position: absolute; left: 20px; top: 22px;
  width: 24px; height: 24px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); border-radius: 50%;
  font-size: .8rem; font-weight: 700;
}
.guidance-item h3 { margin: 0 0 6px; font-size: 1.04rem; letter-spacing: -.01em; }
.guidance-item p { margin: 0; color: var(--ink-soft); font-size: .94rem; }
.pullquote {
  margin: 0; padding: 28px 32px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  font-family: var(--font-serif); font-size: 1.18rem; line-height: 1.5; font-weight: 500;
  box-shadow: var(--shadow); position: relative;
}
.pullquote::before {
  content: '\201C'; font-size: 3.5rem; line-height: 0; position: absolute;
  left: 18px; top: 28px; opacity: .25; font-family: var(--font-serif);
}

/* ===================== BIBTEX ===================== */
.bibtex-wrap { position: relative; }
.bibtex-wrap pre {
  background: #0f172a; color: #e2e8f0; border-radius: var(--radius);
  padding: 26px 24px; overflow-x: auto; box-shadow: var(--shadow);
  font-size: .86rem; line-height: 1.6; margin: 0;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
}
.bibtex-wrap code { color: #cbd5e1; }
.copy-btn {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255, 255, 255, .1); color: #e2e8f0; border: 1px solid rgba(255,255,255,.18);
  padding: 6px 14px; border-radius: 8px; font-size: .8rem; font-weight: 600;
  cursor: pointer; transition: background .18s ease;
}
.copy-btn:hover { background: rgba(255, 255, 255, .2); }
.copy-btn.copied { background: #16a34a; border-color: #16a34a; color: #fff; }

/* ===================== ACK & FOOTER ===================== */
.ack { color: var(--ink-soft); font-size: .96rem; text-align: center; }
.footer { background: var(--bg-band); color: #cbd5e1; padding: 44px 0; text-align: center; }
.footer-links { display: flex; justify-content: center; gap: 28px; margin-bottom: 18px; flex-wrap: wrap; }
.footer-links a { color: #cbd5e1; font-weight: 600; font-size: .94rem; }
.footer-links a:hover { color: #fff; }
.footer-note { font-size: .88rem; color: #94a3b8; margin: 0 0 6px; }
.footer-fine { font-size: .78rem; color: #94a3b8; margin: 0; }

/* ===================== LIGHTBOX ===================== */
.lightbox {
  position: fixed; inset: 0; z-index: 1000; display: none;
  background: rgba(8, 12, 24, .9); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 40px; cursor: zoom-out;
}
.lightbox.open { display: flex; animation: fade .2s ease; }
.lightbox img { max-width: 95%; max-height: 92%; border-radius: 10px; box-shadow: var(--shadow-lg); }
.lightbox-close {
  position: absolute; top: 20px; right: 28px; background: none; border: 0;
  color: #fff; font-size: 2.4rem; line-height: 1; cursor: pointer; opacity: .8;
}
.lightbox-close:hover { opacity: 1; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ===================== REVEAL ANIMATION ===================== */
/* Hidden state applies only when JS is active, so content is visible if JS fails. */
.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s ease; }
.js .reveal.visible { opacity: 1; transform: none; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 980px) {
  .cards, .category-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 24px 14px; }
  .dataset-facts { grid-template-columns: repeat(3, 1fr); }
  .failure-grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: 62px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: rgba(255,255,255,.98); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
    max-height: 0; overflow: hidden; visibility: hidden;
    transition: max-height .3s ease, visibility .3s ease;
  }
  .nav-links.open { max-height: 80vh; overflow-y: auto; visibility: visible; }
  .nav-links a { padding: 14px 24px; border-top: 1px solid var(--line); }
  .nav-links a:not(.nav-cta)::after { display: none; }
  .nav-cta { margin: 12px 24px; text-align: center; }

  .section { padding: 56px 0; }
  .hero { padding: 48px 0 40px; }
  .cards, .category-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dataset-facts { grid-template-columns: repeat(2, 1fr); }
  .actions .btn { flex: 1 1 calc(50% - 12px); min-width: 0; justify-content: center; }
  .authors { font-size: .98rem; gap: 4px 14px; }
}

@media (max-width: 430px) {
  .actions .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
}
