/* ResearchStudio GitHub Pages — minimal, modern, single-file stylesheet
   Unified palette / typography / hero with ./reel/ subpage. */

:root {
  /* Brand — mirrors ResearchStudio-Reel */
  --brand-1: #0b1020;        /* near-black ink */
  --brand-2: #6c5ce7;        /* indigo */
  --brand-3: #00d4a8;        /* mint accent */
  --brand-grad: linear-gradient(135deg, #6c5ce7 0%, #00d4a8 100%);

  /* Surfaces */
  --bg:            #ffffff;
  --bg-soft:       #f7f8fb;
  --bg-elev:       #ffffff;
  --border:        #e6e8ef;
  --border-strong: #d3d7e0;

  /* Text */
  --fg:        #0b1020;
  --fg-muted:  #555a6a;
  --fg-faint:  #8a90a0;

  /* Typography */
  --font-sans: 'Inter var', 'Inter', ui-sans-serif, system-ui, -apple-system,
               'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC',
               'Microsoft YaHei', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(11,16,32,.06), 0 1px 1px rgba(11,16,32,.04);
  --shadow-md: 0 10px 30px -12px rgba(11,16,32,.18), 0 4px 10px -4px rgba(11,16,32,.08);
  --shadow-lg: 0 30px 60px -20px rgba(11,16,32,.30), 0 18px 36px -18px rgba(11,16,32,.18);

  /* Aliases kept so existing rules continue to work */
  --bg-alt:   var(--bg-soft);
  --ink:      var(--fg);
  --ink-soft: var(--fg-muted);
  --muted:    var(--fg-faint);
  --line:     var(--border);
  --brand:    var(--brand-1);
  --accent:   var(--brand-3);
  --accent-2: var(--brand-2);
  --code-bg:  #0f1430;
  --code-ink: #e2e8f0;
  --radius:   14px;
  --max:      1180px;

  /* Tell the browser we support both themes — themes form controls,
     scrollbars, and the address bar to match the current color-scheme. */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0b0e1a;
    --bg-soft:       #11142a;
    --bg-elev:       #141832;
    --border:        #232846;
    --border-strong: #2f3656;

    --fg:        #eef0f7;
    --fg-muted:  #aab0c4;
    --fg-faint:  #7b8198;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 10px 30px -12px rgba(0,0,0,.55), 0 4px 10px -4px rgba(0,0,0,.35);
    --shadow-lg: 0 30px 60px -20px rgba(0,0,0,.65), 0 18px 36px -18px rgba(0,0,0,.5);

    --code-bg:  #07091a;
  }

  /* Tag pills — bump alpha so they stay visible on the dark card surface,
     and lift the reel accent off the muddy #0d8a72 (fails WCAG on dark). */
  .tag-idea { background: rgba(108, 92, 231, 0.22); color: var(--brand-2); }
  .tag-reel { background: rgba(0, 212, 168, 0.20); color: var(--brand-3); }
  .cover-card--reel::before { background: linear-gradient(90deg, var(--brand-3), #0d8a72); }
  .cover-card--reel .cover-card__cta { color: var(--brand-3); }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-feature-settings: 'cv11','ss01','ss03';
  color: var(--fg);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: color-mix(in srgb, var(--brand-2) 35%, transparent); color: inherit; }

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

/* ---------- Hero (grid + glow, mirrors ./reel/) ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.hero > .container { position: relative; z-index: 1; }

/* ---------- Top nav (sticky, frosted — mirrors ./reel/) ---------- */
.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--fg);
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand img { display: inline-flex; }
.hero__bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.hero__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--border) 50%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--border) 50%, transparent) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 35%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 35%, transparent 75%);
}
.hero__glow {
  position: absolute;
  filter: blur(80px);
  opacity: .55;
  border-radius: 50%;
}
.hero__glow--a {
  width: 520px; height: 520px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--brand-2) 55%, transparent), transparent);
  top: -120px; left: -120px;
}
.hero__glow--b {
  width: 460px; height: 460px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--brand-3) 55%, transparent), transparent);
  top: -60px; right: -100px;
}
@media (prefers-color-scheme: dark) {
  .hero__glow { opacity: .35; }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--fg);
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.nav-links {
  display: flex;
  list-style: none;
  gap: 22px;
  margin: 0 0 0 16px;
  padding: 0;
  align-items: center;
  flex: 1;
}
.nav-links li { display: inline-flex; }
.nav-links a {
  color: var(--fg-muted);
  font-size: 14.5px;
  font-weight: 500;
  padding: 0;
  border-radius: 0;
  transition: color 0.15s ease;
}
.nav-links a:hover {
  color: var(--fg);
  background: transparent;
  text-decoration: none;
}
@media (max-width: 820px) {
  .nav-links { display: none; }
}
@media (max-width: 640px) {
  .nav-links { display: none; }
}
.nav-links a.ghost {
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--bg-elev);
}

/* Star-on-GitHub button in the top nav (Reel-style pill) */
.nav__cta { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav__cta .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14.5px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.nav__cta .btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}
.nav__cta .btn svg { flex-shrink: 0; }

/* .btn--ghost — mirrors ResearchStudio-Reel: bg-elev + border-strong */
.nav__cta .btn--ghost {
  background: var(--bg-elev);
  color: var(--ink);
  border-color: var(--border-strong);
}
.nav__cta .btn--ghost:hover {
  background: var(--bg-soft);
}

/* .btn--primary — mirrors ResearchStudio-Reel: indigo→teal gradient pill */
.nav__cta .btn--pill {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--brand-2) 70%, transparent);
}
.nav__cta .btn--pill:hover {
  color: #fff;
  box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--brand-2) 75%, transparent);
}

@media (max-width: 760px) {
  .nav__cta .btn--pill { display: none; }
}

.hero-body {
  padding: 24px 0 20px;
  text-align: center;
}
.hero-body h1 {
  font-size: clamp(2rem, 4.8vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 auto 18px;
  line-height: 1.12;
}
.hero-body h1 .grad {
  display: inline-block;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .hero-body h1 .grad { white-space: normal; }
}
.grad {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede {
  max-width: 720px;
  margin: 0 auto 16px;
  font-size: 1rem;
  color: var(--ink-soft);
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 0;
}
.btn {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn.primary {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--brand-2) 70%, transparent);
  padding: 10px 22px;
  font-size: 0.92rem;
}
.btn.primary:hover {
  color: #fff;
  box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--brand-2) 75%, transparent);
}
.btn.ghost {
  background: var(--bg-elev);
  color: var(--ink);
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--bg-alt); }

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 8px;
  margin-top: 16px;
  max-width: 100%;
}
.badges img { height: 20px; display: block; }
.badges a { display: inline-flex; line-height: 0; transition: transform 0.15s ease; }
.badges a:hover { transform: translateY(-1px); text-decoration: none; }

/* ---------- Sections ---------- */
.section { padding: 48px 0 24px; }
.section.alt { background: var(--bg-soft); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { text-align: center; margin-bottom: 40px; }
.section-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: 8px 0 10px;
  letter-spacing: -0.015em;
}
.section-head .sub {
  color: var(--muted);
  max-width: 680px;
  margin: 0 auto;
  font-size: 1.02rem;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tag-idea { background: rgba(79, 70, 229, 0.1); color: var(--accent-2); }
.tag-reel { background: rgba(0, 212, 168, 0.12); color: #0d8a72; }

/* Emoji inside tags — render larger, baseline-aligned, with a soft glow that
   matches the tag's accent color. The emoji color comes from the font, so we
   use filter() to tint the surrounding glow per-card. */
.tag__emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05em;
  line-height: 1;
  margin-right: 2px;
  transform: translateY(-0.5px);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
               "Segoe UI Symbol", "Twemoji Mozilla", sans-serif;
  font-variant-emoji: emoji;
  -webkit-font-smoothing: subpixel-antialiased;
}
.tag-idea .tag__emoji {
  filter: drop-shadow(0 0 6px rgba(124, 108, 255, 0.45))
          drop-shadow(0 1px 1px rgba(79, 70, 229, 0.25));
}
.tag-reel .tag__emoji {
  filter: drop-shadow(0 0 6px rgba(0, 212, 168, 0.45))
          drop-shadow(0 1px 1px rgba(13, 138, 114, 0.25));
}

/* Subtle hover animation — the bulb glints, the film reel spins a quarter turn */
.cover-card:hover .tag-idea .tag__emoji {
  animation: tagGlow 1.6s ease-in-out infinite;
}
.cover-card:hover .tag-reel .tag__emoji {
  animation: tagSpin 1.8s ease-in-out infinite;
}
@keyframes tagGlow {
  0%, 100% {
    filter: drop-shadow(0 0 6px rgba(124, 108, 255, 0.45))
            drop-shadow(0 1px 1px rgba(79, 70, 229, 0.25));
    transform: translateY(-0.5px) scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(124, 108, 255, 0.85))
            drop-shadow(0 0 3px rgba(255, 220, 130, 0.55));
    transform: translateY(-0.5px) scale(1.08);
  }
}
@keyframes tagSpin {
  0%, 100% {
    filter: drop-shadow(0 0 6px rgba(0, 212, 168, 0.45))
            drop-shadow(0 1px 1px rgba(13, 138, 114, 0.25));
    transform: translateY(-0.5px) rotate(0deg) scale(1);
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(0, 212, 168, 0.8))
            drop-shadow(0 1px 1px rgba(13, 138, 114, 0.35));
    transform: translateY(-0.5px) rotate(15deg) scale(1.08);
  }
}
@media (prefers-reduced-motion: reduce) {
  .cover-card:hover .tag__emoji { animation: none; }
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  gap: 24px;
  margin-bottom: 0;
}
.card-grid.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) {
  .card-grid.two-col { grid-template-columns: 1fr; }
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
}
.card h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.card p { margin: 0 0 12px; color: var(--ink-soft); }
.card p:last-child { margin-bottom: 0; }

/* ---------- Cover cards (Idea / Reel GIF covers) ---------- */
.cover-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.cover-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  opacity: 0.85;
}
.cover-card--idea::before { background: linear-gradient(90deg, var(--accent-2), var(--brand-2)); }
.cover-card--reel::before { background: linear-gradient(90deg, #0d8a72, var(--accent)); }

.cover-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.cover-card__head {
  padding: 14px 22px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cover-card__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.cover-card__media-wrap {
  position: relative;
  margin: 0 22px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-alt);
}
.cover-card__media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.cover-card:hover .cover-card__media { transform: scale(1.015); }

.cover-card__foot {
  padding: 10px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cover-card__foot p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.5;
}
.cover-card__foot p strong { color: var(--ink); font-weight: 700; }
.cover-card__cta {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-2);
  letter-spacing: 0.01em;
}
.cover-card--reel .cover-card__cta { color: #0d8a72; }

.skill-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}
.skill-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  color: var(--ink-soft);
  font-size: 0.96rem;
}
.skill-list li:last-child { border-bottom: 0; }
.skill-list strong { color: var(--ink); }

.link {
  display: inline-block;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- Code blocks ---------- */
.snippet, .bibtex {
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: 10px;
  padding: 16px 18px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  overflow-x: auto;
  margin: 0;
}
.snippet code, .bibtex code { background: none; padding: 0; }
.muted { color: var(--muted); font-size: 0.9rem; margin-top: 10px; }
code {
  background: color-mix(in srgb, var(--brand-2) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-2) 16%, transparent);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.86em;
  color: inherit;
}

/* ---------- Footer ---------- */
.footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 14px 0 16px;
  color: var(--fg-muted);
  font-size: 0.85rem;
}
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.footer-links { display: flex; gap: 18px; }
.footer-links a { color: var(--ink-soft); }
.footer-links a:hover { color: var(--ink); }

/* ---------- A11y + motion ---------- */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 6px;
}
.cover-card:focus-visible {
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 600px) {
  .hero-body { padding: 24px 0 20px; }
  .cover-card__head { padding: 14px 16px 8px; }
  .cover-card__media-wrap { margin: 0 16px; }
  .cover-card__foot { padding: 10px 16px 16px; }
  .nav__cta .btn { padding: 8px 14px; font-size: 0.88rem; }
}

/* Tablet portrait: 16:10 GIFs read better than 16:9 when the card is wide
   enough to make the media area feel dominant. */
@media (max-width: 900px) {
  .cover-card__media { aspect-ratio: 16 / 10; }
}

/* Very narrow phones: shrink the hero glow blobs so they don't wash out the
   headline, and collapse the GitHub button to its icon so the topbar fits. */
@media (max-width: 480px) {
  .hero__glow--a,
  .hero__glow--b {
    width: 320px;
    height: 320px;
    opacity: .4;
  }
  .hero__glow--a { top: -80px; left: -80px; }
  .hero__glow--b { top: -40px; right: -60px; }

  .topbar { gap: 12px; padding: 12px 16px; }
  .nav__cta .btn--ghost {
    gap: 0;
    padding: 8px 10px;
  }
  /* Hide the label text; keep only the GitHub SVG icon. */
  .nav__cta .btn--ghost > :not(svg) {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}
