/* ============================================================
   celray.github.io — documentation hub
   Minimal academic theme · hand-written, no framework
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Brand */
  --navy:            #002366;
  --navy-soft:       #1b3a7a;
  --navy-tint:       #eaeef6;

  /* Light theme (default) */
  --bg:              #fbfaf8;
  --bg-elev:         #ffffff;
  --bg-sunken:       #f3f1ec;
  --text:            #1d1d1f;
  --text-muted:      #5f5f66;
  --text-faint:      #8a8a92;
  --border:          #e6e3dc;
  --border-strong:   #d8d4ca;
  --accent:          var(--navy);
  --accent-contrast: #ffffff;
  --chip-bg:         #f1efe9;
  --chip-text:       #57565c;
  --shadow-sm:       0 1px 2px rgba(20, 20, 30, .05);
  --shadow-md:       0 6px 24px -10px rgba(20, 24, 60, .18);
  --shadow-lg:       0 18px 48px -22px rgba(20, 24, 60, .35);
  --ring:            rgba(0, 35, 102, .35);

  /* Type */
  --font-display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Layout */
  --maxw: 1200px;
  --radius: 14px;
  --radius-sm: 9px;
  --gutter: clamp(20px, 5vw, 48px);

  color-scheme: light;
}

[data-theme="dark"] {
  --navy:            #6f8fd8;
  --navy-soft:       #8aa6e6;
  --navy-tint:       #18203a;

  --bg:              #0e1016;
  --bg-elev:         #161922;
  --bg-sunken:       #0a0c11;
  --text:            #ecedf1;
  --text-muted:      #a4a7b4;
  --text-faint:      #71747f;
  --border:          #262a36;
  --border-strong:   #333847;
  --accent:          #9fb6ee;
  --accent-contrast: #0e1016;
  --chip-bg:         #1d2130;
  --chip-text:       #aeb2c0;
  --shadow-sm:       0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md:       0 8px 28px -12px rgba(0, 0, 0, .7);
  --shadow-lg:       0 22px 56px -24px rgba(0, 0, 0, .85);
  --ring:            rgba(159, 182, 238, .4);

  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .35s ease, color .35s ease;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.022em;
  margin: 0;
}

::selection { background: var(--navy); color: #fff; }
[data-theme="dark"] ::selection { background: var(--navy); color: #0e1016; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease, background-color .3s ease;
}
.site-header.scrolled { border-bottom-color: var(--border); }

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.brand .mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--navy);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0;
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .brand .mark { color: #0e1016; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.nav-links a {
  padding: 8px 13px;
  border-radius: 8px;
  font-size: .92rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color .2s ease, background-color .2s ease;
}
.nav-links a:hover { color: var(--text); background: var(--bg-sunken); }

.nav-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, transform .15s ease, background-color .2s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .sun { display: none; }
[data-theme="dark"] .icon-btn .moon { display: none; }
[data-theme="dark"] .icon-btn .sun  { display: block; }

.nav-toggle { display: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-top: clamp(34px, 6vw, 60px);
  padding-bottom: clamp(22px, 3vw, 36px);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40% 30% auto -10%;
  height: 620px;
  background: radial-gradient(60% 60% at 30% 30%, color-mix(in srgb, var(--navy) 16%, transparent), transparent 70%);
  filter: blur(20px);
  z-index: -1;
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 100px;
  box-shadow: var(--shadow-sm);
}
.eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #2bb673;
  box-shadow: 0 0 0 3px color-mix(in srgb, #2bb673 25%, transparent);
}

.hero h1 {
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  margin-top: 18px;
  max-width: 24ch;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.hero h1 .accent {
  color: var(--navy); /* fallback */
  background: linear-gradient(115deg, var(--navy), color-mix(in srgb, var(--navy) 55%, #5a8cf0));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero .lede {
  margin-top: 22px;
  max-width: 60ch;
  font-size: clamp(1.05rem, 2.2vw, 1.28rem);
  color: var(--text-muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  border-radius: 11px;
  font-weight: 600;
  font-size: .95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease, color .2s ease;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--navy); color: #fff; box-shadow: var(--shadow-md); }
[data-theme="dark"] .btn-primary { color: #0e1016; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-ghost { background: var(--bg-elev); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.btn-sm { padding: 9px 14px; font-size: .9rem; }

.brand-dim { color: var(--text-faint); font-weight: 500; }

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.hero-meta .stat .num {
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--text);
  line-height: 1;
}
.hero-meta .stat .label {
  display: block;
  margin-top: 5px;
  font-size: .82rem;
  color: var(--text-faint);
  letter-spacing: .02em;
}

/* ---------- Section scaffolding ---------- */
.section { padding-block: clamp(48px, 8vw, 88px); }
.section-sunken { background: var(--bg-sunken); border-block: 1px solid var(--border); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 34px;
}
.section-head .titles { max-width: 60ch; }
.section-kicker {
  font-family: var(--font-mono);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--navy);
  font-weight: 600;
}
.section-head h2 {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  margin-top: 10px;
}
.section-head p { margin: 12px 0 0; color: var(--text-muted); }

/* ---------- Filter bar ---------- */
.filter {
  position: relative;
  min-width: 260px;
  flex: 1 1 260px;
  max-width: 360px;
}
.filter input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.filter input::placeholder { color: var(--text-faint); }
.filter input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.filter .search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--text-faint);
  pointer-events: none;
}
.hero .filter { margin-top: 32px; max-width: 440px; }
.section-projects { padding-top: clamp(12px, 2vw, 24px); }

/* ---------- Project groups ---------- */
.group { margin-top: 8px; }
.group + .group { margin-top: 54px; }
.group-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.group-head h3 {
  font-size: 1.4rem;
  white-space: nowrap;
}
.group-head .count {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-faint);
}
.group-head .rule { flex: 1; height: 1px; background: var(--border); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 18px;
}

/* ---------- Project card ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .22s cubic-bezier(.2,.7,.3,1), box-shadow .25s ease, border-color .25s ease;
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--navy), color-mix(in srgb, var(--navy) 40%, transparent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.card:hover::after { transform: scaleX(1); }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-icon {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 11px;
  background: var(--navy-tint);
  color: var(--navy);
  flex-shrink: 0;
}
.card-icon svg { width: 22px; height: 22px; }
.card-icon-img { background: none; padding: 0; overflow: hidden; }
.card-icon-img img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; display: block; }
.card-star {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--text-faint);
}
.card-star svg { width: 14px; height: 14px; }

.card h4 {
  font-size: 1.22rem;
  margin-top: 15px;
  font-weight: 600;
}
.card .desc {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: .93rem;
  line-height: 1.55;
  flex: 1;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.chip {
  font-family: var(--font-mono);
  font-size: .72rem;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--chip-bg);
  color: var(--chip-text);
  letter-spacing: .01em;
}
.chip.lang::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--lang-color, var(--text-faint));
}

.card-links {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 8px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: color .18s ease, border-color .18s ease, background-color .18s ease;
}
.card-link svg { width: 15px; height: 15px; }
.card-link:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-sunken); }
.card-link.primary { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.card-link.primary:hover { background: var(--navy-tint); border-color: var(--accent); }
.card-link.disabled { color: var(--text-faint); border-style: dashed; cursor: default; }
.card-link.disabled:hover { background: none; color: var(--text-faint); border-color: var(--border); }

.chip.soon { background: color-mix(in srgb, var(--navy) 13%, var(--chip-bg)); color: var(--accent); }
.card.is-soon { border-style: dashed; }
.card.is-soon::after { display: none; }

.no-results {
  display: none;
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}
.no-results.show { display: block; }

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
}
.about-grid p { color: var(--text-muted); font-size: 1.05rem; }
.about-grid p + p { margin-top: 16px; }
.about-grid a.inline { color: var(--navy); font-weight: 600; border-bottom: 1px solid color-mix(in srgb, var(--navy) 35%, transparent); }
.about-grid a.inline:hover { border-bottom-color: var(--navy); }

.affil-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.affil-card h4 { font-size: 1.05rem; margin-bottom: 4px; }
.affil-list { list-style: none; margin: 0; padding: 0; }
.affil-list li {
  display: flex;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--border);
}
.affil-list li:first-child { border-top: none; padding-top: 4px; }
.affil-list .role { color: var(--text); font-weight: 600; font-size: .95rem; }
.affil-list .org { color: var(--text-muted); font-size: .88rem; }
.affil-list .ic { color: var(--navy); flex-shrink: 0; margin-top: 2px; }
.affil-list .ic svg { width: 18px; height: 18px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 44px;
  background: var(--bg-sunken);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-inner .brand { font-size: 1.05rem; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); font-size: .9rem; }
.footer-links a:hover { color: var(--text); }
.colophon { width: 100%; margin-top: 22px; color: var(--text-faint); font-size: .82rem; }
.colophon code { font-family: var(--font-mono); color: var(--text-muted); }

/* ---------- Reveal animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .6s cubic-bezier(.2,.7,.3,1), transform .6s cubic-bezier(.2,.7,.3,1);
}
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  html { scroll-padding-top: 72px; }

  .nav { height: 60px; gap: 10px; }
  .brand { font-size: 1.06rem; }
  .brand .mark { width: 31px; height: 31px; }
  .gh-label { display: none; }            /* GitHub button → icon-only */
  .btn-sm { padding: 9px 11px; }

  .hero { padding-top: 30px; }
  .hero .lede { margin-top: 14px; }
  .hero .filter { margin-top: 20px; max-width: none; min-width: 0; }

  .card-grid { gap: 14px; }
}

@media (max-width: 440px) {
  :root { --gutter: 18px; }
  .brand-dim { display: none; }           /* shorten wordmark to "celray" */
  .eyebrow { font-size: .72rem; padding: 6px 11px; }
  .hero h1 { font-size: clamp(1.7rem, 8vw, 2.2rem); margin-top: 14px; }
  .card { padding: 18px; }
  .card-links { flex-wrap: wrap; }
  .footer-inner { gap: 16px; }
  .footer-links { gap: 14px; }
}
