:root {
  --bg: #0b0d12;
  --bg-elev: #12151c;
  --fg: #e7ecf3;
  --fg-dim: #9aa4b2;
  --accent: #4cc9f0;
  --accent-2: #b5179e;
  --border: #1f2430;
  --radius: 10px;
  --maxw: 1200px;
}

* { box-sizing: border-box; }

/* Skip-to-content link (a11y) */
.skip-link {
  position: absolute; top: -40px; left: 0.5rem; z-index: 1000;
  background: var(--accent); color: #0b0d12; padding: 0.5rem 1rem;
  border-radius: 0 0 6px 6px; font-weight: 600;
  transition: top .15s;
}
.skip-link:focus { top: 0; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55; }
a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--accent); }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }

/* Header + nav */
.site-header { background: var(--bg-elev); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.nav-wrap { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.brand { font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em; }
.brand span { color: var(--accent); }

.nav-toggle { display: none; background: none; border: 0; cursor: pointer; width: 40px; height: 40px; padding: 8px; }
.nav-toggle span { display: block; width: 100%; height: 2px; background: var(--fg); margin: 5px 0; transition: transform .2s, opacity .2s; }

.primary-nav .nav-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.25rem; }
.nav-item { position: relative; }
.nav-link { display: block; padding: 0.75rem 0.9rem; border-radius: 6px; color: var(--fg); font-size: 0.95rem; }
.nav-item:hover .nav-link, .nav-item:focus-within .nav-link { background: rgba(76, 201, 240, 0.08); color: var(--accent); }

.dropdown { position: absolute; top: 100%; left: 0; min-width: 220px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.4rem; margin: 0; list-style: none;
  opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .15s, transform .15s, visibility .15s; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.nav-item:hover .dropdown, .nav-item:focus-within .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown a { display: block; padding: 0.55rem 0.75rem; border-radius: 6px; font-size: 0.92rem; color: var(--fg-dim); }
.dropdown a:hover { background: rgba(76, 201, 240, 0.08); color: var(--accent); }

/* Content */
.hero { padding: 3rem 0 1.5rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.25rem); margin: 0 0 0.5rem; letter-spacing: -0.02em; }
.lede { color: var(--fg-dim); font-size: 1.1rem; max-width: 70ch; }

/* Full-bleed hero with optional background image. Pass the image via
   an inline style setting the --hero-image custom property on the
   element. Gradient fade on the left keeps the headline legible over
   the image; falls back to a solid background colour when unset. */
.hero-bleed {
  position: relative;
  padding: 6rem 0 5rem;
  min-height: 52vh;
  background-color: var(--bg-elev);
  background-image:
    linear-gradient(
      90deg,
      rgba(11,13,18,0.92) 0%,
      rgba(11,13,18,0.65) 45%,
      rgba(11,13,18,0.15) 80%,
      rgba(11,13,18,0) 100%
    ),
    var(--hero-image, none);
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  border-bottom: 1px solid var(--border);
}
.hero-bleed .hero-inner { position: relative; max-width: 780px; }
.hero-bleed h1 { text-shadow: 0 2px 16px rgba(0,0,0,0.6); }
.hero-bleed .lede { color: rgba(231,236,243,0.9); text-shadow: 0 1px 8px rgba(0,0,0,0.5); }
@media (max-width: 700px) {
  .hero-bleed {
    padding: 3.5rem 0 2.5rem;
    min-height: auto;
    background-image:
      linear-gradient(
        180deg,
        rgba(11,13,18,0.55) 0%,
        rgba(11,13,18,0.85) 70%,
        rgba(11,13,18,0.95) 100%
      ),
      var(--hero-image, none);
  }
}
.crumbs { color: var(--fg-dim); font-size: 0.9rem; padding: 1rem 0 0; }
.crumbs a { color: var(--fg-dim); }
.crumbs a:hover { color: var(--accent); }

.section-head { margin: 3rem 0 1.25rem; }
.section-head h2 { margin: 0 0 0.25rem; font-size: 1.75rem; letter-spacing: -0.01em; }
.section-head .section-sub { margin: 0; color: var(--fg-dim); font-size: 1rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin: 0 0 4rem; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.card p { margin: 0; color: var(--fg-dim); font-size: 0.9rem; }

/* Captains — avatar portrait + bio, two-up on desktop, stacked on mobile */
.captains-section { margin-bottom: 4rem; }
.captains {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
.captain {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color .2s;
}
.captain:hover { border-color: var(--accent); }
.captain-portrait {
  flex: 0 0 140px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, rgba(76,201,240,0.15), rgba(11,13,18,0) 70%), var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.captain-portrait img {
  width: 130%;
  height: auto;
  object-fit: contain;
  object-position: bottom;
  margin-bottom: -4%;
}
.captain-body { min-width: 0; }
.captain-name { margin: 0 0 0.15rem; font-size: 1.25rem; letter-spacing: -0.01em; }
.captain-role { margin: 0 0 0.5rem; color: var(--accent); font-size: 0.9rem; font-weight: 500; }
.captain-blurb { margin: 0; color: var(--fg-dim); font-size: 0.95rem; line-height: 1.5; }

@media (max-width: 720px) {
  .captains { grid-template-columns: 1fr; gap: 1rem; }
  .captain { flex-direction: column; text-align: center; padding: 1.25rem; }
  .captain-portrait { flex: 0 0 auto; }
  .captain-role { margin-bottom: 0.75rem; }
}

/* Article list (shared by home Latest, science page, subtopic page) */
.article-list { list-style: none; padding: 0; margin: 0 0 3rem; display: grid; gap: 0.75rem; }
.article-row { margin: 0; }
.article-link {
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  transition: border-color .15s, transform .15s;
  color: var(--fg);
}
.article-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.article-link h2, .article-link h3 { margin: 0 0 0.35rem; font-size: 1.2rem; letter-spacing: -0.005em; }
.article-link p { margin: 0 0 0.35rem; color: var(--fg-dim); font-size: 0.95rem; }
.article-link p:last-child { margin-bottom: 0; }
.article-meta { color: var(--fg-dim); font-size: 0.85rem; }
.article-meta span { white-space: nowrap; }

/* Article detail */
.article-hero {
  height: clamp(240px, 40vh, 440px);
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border);
}
.article-inner { max-width: 780px; }
.article-head { padding: 2.5rem 0 1.5rem; }
.article-head h1 { margin: 0 0 0.5rem; font-size: clamp(1.75rem, 4vw, 2.75rem); letter-spacing: -0.015em; }
.article-head .lede { margin: 0 0 1rem; }
.article-head .article-meta { padding: 0; }

/* Responsive 16:9 iframe embed */
.embed { position: relative; width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; margin: 1.5rem 0; }
.embed-16x9 { aspect-ratio: 16 / 9; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Prose styling for rendered markdown */
.prose { max-width: 72ch; font-size: 1.05rem; line-height: 1.7; }
.prose h2 { margin: 2.25rem 0 0.75rem; font-size: 1.5rem; letter-spacing: -0.01em; }
.prose h3 { margin: 1.75rem 0 0.5rem; font-size: 1.2rem; }
.prose p { margin: 0 0 1.1rem; }
.prose a { color: var(--accent); border-bottom: 1px solid rgba(76,201,240,0.35); }
.prose a:hover { border-bottom-color: var(--accent); }
.prose ul, .prose ol { margin: 0 0 1.1rem 1.25rem; padding: 0; }
.prose li { margin-bottom: 0.35rem; }
.prose blockquote {
  margin: 1.25rem 0; padding: 0.5rem 1.1rem; border-left: 3px solid var(--accent);
  color: var(--fg-dim); background: rgba(76,201,240,0.04);
}
.prose code {
  background: rgba(255,255,255,0.06); padding: 0.1em 0.35em; border-radius: 4px;
  font-size: 0.92em;
}
.prose pre { background: #0a0d13; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; overflow-x: auto; }
.prose pre code { background: transparent; padding: 0; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.article-elsewhere, .article-source {
  margin: 2rem 0; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.article-elsewhere h2, .article-source h2 {
  margin: 0 0 0.4rem; font-size: 0.95rem; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--fg-dim); font-weight: 600;
}
.article-elsewhere ul { list-style: none; padding: 0; margin: 0; display: flex; gap: 1rem; flex-wrap: wrap; }
.article-elsewhere a, .article-source a { color: var(--accent); }
.article-source p { margin: 0; color: var(--fg-dim); font-size: 0.95rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 2rem 0; color: var(--fg-dim); font-size: 0.9rem; margin-top: 4rem; }

/* Mobile */
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .primary-nav { position: absolute; top: 64px; left: 0; right: 0; background: var(--bg-elev); border-bottom: 1px solid var(--border);
    max-height: 0; overflow: hidden; transition: max-height .25s ease; }
  .primary-nav.open { max-height: 80vh; overflow-y: auto; }
  .primary-nav .nav-list { flex-direction: column; padding: 0.5rem 1rem 1rem; }
  .nav-item { width: 100%; }
  .nav-link { padding: 0.9rem 0.5rem; border-bottom: 1px solid var(--border); }
  .dropdown { position: static; opacity: 1; visibility: visible; transform: none; border: 0; box-shadow: none;
    padding: 0 0 0.5rem 0.75rem; background: transparent; display: none; }
  .nav-item.open .dropdown { display: block; }
}
