/* GAME MARKETING RESEARCH INDEX — Commerce/Analytics Theme */

:root,
[data-theme='light'] {
  --hero-bg: url('hero-bg-light.png');

  --hero-filter: none;
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-surface-2: #f0f4f7;
  --color-surface-offset: #e6ecf1;
  --color-border: #d0d9e0;
  --color-divider: #dde4ea;
  --color-text: #14202b;
  --color-text-muted: #51636f;
  --color-text-faint: #8a98a3;
  --color-primary: #0e7490;
  --color-primary-2: #0e7490;
  --color-accent: #6d28d9;
  --color-success: #15803d;
  --color-error: #b91c1c;
  --color-warning: #b45309;
  --shadow-sm: 0 1px 3px rgba(16, 40, 60, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 40, 60, 0.08);
}

[data-theme='dark'] {
  --hero-bg: url('hero-bg-dark.png');
  --hero-filter: none;
  --color-bg: #0c1420;
  --color-surface: #131c28;
  --color-surface-2: #1a2532;
  --color-surface-offset: #222f3e;
  --color-border: #2a3a4a;
  --color-divider: #22303e;
  --color-text: #e4ecf4;
  --color-text-muted: #93a5b4;
  --color-text-faint: #647a8a;
  --color-primary: #22d3ee;
  --color-primary-2: #67e8f9;
  --color-accent: #a78bfa;
  --color-success: #4ade80;
  --color-error: #f87171;
  --color-warning: #fbbf24;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.45);
} 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background-image: var(--hero-bg);
  background-size: cover; background-position: top center; background-repeat: no-repeat;
  background-attachment: scroll;
  filter: var(--hero-filter, none);
  opacity: 0.35;
  transition: filter 0.25s ease, opacity 0.25s ease;
}

h1, h2, h3 { line-height: 1.2; text-wrap: balance; }
a { color: var(--color-primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--color-primary-2); }
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: 3px; }
code { font-family: 'JetBrains Mono', monospace; font-size: 0.85em; background: var(--color-surface-2); padding: 0.1em 0.3em; border-radius: 3px; }

/* --- Topbar --- */
.topbar { background: var(--color-surface); border-bottom: 1px solid var(--color-border); position: static; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 36px; height: 36px; color: var(--color-primary); flex-shrink: 0; }
.brand h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { font-size: 0.78rem; color: var(--color-text-muted); }
.last-updated { font-size: 0.72rem; color: var(--color-text-faint); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }

/* --- Navbar --- */
.navbar { background: var(--color-surface-2); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 60; }
.navbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; min-height: 46px; }
.nav-menu { display: flex; align-items: center; flex: 1; justify-content: space-between; }
.nav-links { display: flex; list-style: none; gap: 4px; flex-shrink: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-actions .refresh-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 6px;
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  font-size: 0.78rem; transition: background 0.15s;
}
.topbar-actions .refresh-btn:hover { background: var(--color-primary); color: #fff; }
.topbar-actions [data-theme-toggle] { background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: 4px; }
.topbar-actions [data-theme-toggle]:hover { color: var(--color-primary); }
.nav-links a {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 6px;
  font-size: 0.8rem; font-weight: 500; color: var(--color-text-muted); text-decoration: none;
  white-space: nowrap; transition: color 0.15s, background 0.15s;
}
.nav-links a:hover, .nav-links a.active { color: var(--color-primary); background: var(--color-surface); }
.nav-links a svg { flex-shrink: 0; display: block; }

/* --- Subnav dropdown (subsection sub-items) --- */
.nav-item { position: relative; }
.subnav {
  position: absolute; top: 100%; left: 0; min-width: 240px; max-height: 70vh; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 8px; box-shadow: var(--shadow-md);
  display: none; flex-direction: column; padding: 6px; z-index: 300;
}
.nav-item:hover > .subnav,
.nav-item:focus-within > .subnav,
.nav-item.subnav-open > .subnav { display: flex; }
.subnav.subnav-has-children { overflow: visible; max-height: none; }
.subnav-nested { max-height: 70vh; overflow-y: auto; }
.subnav a {
  padding: 7px 12px; font-size: 0.76rem; border-radius: 6px;
  color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.subnav a:hover { background: var(--color-surface-offset); color: var(--color-primary); }

/* Nested sub-subnav */
.subnav .nav-item { position: relative; }
.subnav-nested { left: 100%; top: 0; }
.subnav .nav-item:hover > .subnav-nested,
.subnav .nav-item:focus-within > .subnav-nested { display: flex; }
@media (max-width: 900px) {
  .subnav-nested { left: 0; position: static; }
  .subnav .nav-item.subnav-open > .subnav-nested { display: flex; }
}
@media (max-width: 900px) {
  .subnav { position: static; min-width: 0; max-height: none; box-shadow: none; border: none; border-left: 1px solid var(--color-divider); margin: 0 0 4px 14px; padding: 2px 0 2px 8px; display: none; }
  .nav-item.subnav-open > .subnav { display: flex; }
}

.hamburger { display: none; flex-direction: column; justify-content: center; gap: 4px; width: 38px; height: 38px; padding: 8px; }
.hamburger span { display: block; height: 2px; width: 100%; background: var(--color-text); border-radius: 2px; transition: transform 0.2s, opacity 0.2s; }
.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
section[id] { scroll-margin-top: 70px; }
.evidence-card, .playbook-card, .project-card { scroll-margin-top: 70px; }

@media (max-width: 900px) {
  .hamburger { display: flex; }
  .nav-menu { position: absolute; top: 46px; left: 0; right: 0; flex-direction: column; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 8px 12px; transform: translateY(-200%); transition: transform 300ms ease; z-index: 99; }
  .nav-menu.open { transform: translateY(0); }
  .nav-links { flex-direction: column; gap: 2px; }
  .nav-links a { padding: 10px 12px; }
  
}

/* --- Container --- */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; display: flex; flex-direction: column; gap: 28px; }

/* --- Section Head --- */
.section-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.q-num {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: color-mix(in srgb, var(--color-primary) 50%, #0b0f14); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.q-num svg { width: 18px; height: 18px; display: block; }
.section-head h2 { font-size: 1.12rem; font-weight: 700; }
.card-note { font-size: 0.76rem; color: var(--color-text-faint); }

/* --- Lead --- */
.lead-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary); border-radius: 10px; padding: 28px; box-shadow: var(--shadow-sm);
}
.lead-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; background: rgba(34, 211, 238, 0.12); color: var(--color-primary); margin-bottom: 12px; }
.lead-card h2 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
.lead-subhead { color: var(--color-text-muted); font-size: 0.98rem; margin-bottom: 16px; line-height: 1.55; }
.pullquote { border-left: 3px solid var(--color-primary); padding: 10px 16px; font-size: 0.88rem; color: var(--color-text-muted); font-style: italic; line-height: 1.55; }

/* --- Evidence Grid --- */
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.evidence-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 8px; padding: 16px; box-shadow: var(--shadow-sm);
}
.evidence-code { font-family: 'JetBrains Mono', monospace; font-size: 1.3rem; font-weight: 700; color: var(--color-primary); }
.evidence-label { font-size: 0.8rem; font-weight: 700; color: var(--color-text); margin: 2px 0; }
.evidence-note { font-size: 0.74rem; color: var(--color-text-muted); line-height: 1.45; }

/* --- Playbooks --- */
.playbooks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.playbook-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 10px; padding: 20px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 8px;
}
.playbook-scope { display: inline-block; align-self: flex-start; font-size: 0.66rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; background: var(--color-surface-offset); color: var(--color-text-muted); }
.playbook-card h3 { font-size: 0.95rem; font-weight: 700; }
.playbook-desc { font-size: 0.8rem; color: var(--color-text-muted); line-height: 1.5; }
.playbook-insights { display: flex; flex-direction: column; gap: 3px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--color-divider); }
.playbook-insights li { font-size: 0.74rem; color: var(--color-primary-2); margin-left: 16px; line-height: 1.4; }
.playbook-card a { font-size: 0.74rem; }

/* --- Projects --- */
.projects-grid { display: flex; flex-direction: column; gap: 16px; }
.project-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 10px; padding: 22px; box-shadow: var(--shadow-sm);
}
.project-header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.project-header h3 { font-size: 1.05rem; font-weight: 700; }
.project-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.72rem; color: var(--color-text-muted); }
.project-meta span { padding: 2px 8px; border-radius: 999px; background: var(--color-surface-offset); }
.project-status { font-weight: 600; }
.project-desc { font-size: 0.82rem; color: var(--color-text); line-height: 1.5; margin-bottom: 10px; }
.project-findings { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.project-findings li { font-size: 0.78rem; color: var(--color-text-muted); margin-left: 16px; line-height: 1.45; }
.project-docs { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px solid var(--color-divider); }
.project-docs a {
  font-size: 0.72rem; color: var(--color-primary-2); border: 1px solid var(--color-border);
  padding: 3px 10px; border-radius: 999px; transition: background 0.15s, color 0.15s;
}
.project-docs a:hover { background: var(--color-primary); color: #fff; }

/* --- Sources --- */
.methodology-content { margin-bottom: 16px; padding: 16px; background: color-mix(in srgb, var(--color-surface) 80%, transparent); backdrop-filter: blur(4px); border: 1px solid var(--color-border); border-radius: 8px; }
.methodology-content ul { margin: 0 0 12px 18px; font-size: 0.84rem; color: var(--color-text-muted); display: flex; flex-direction: column; gap: 5px; }
.methodology-content li { line-height: 1.5; }
.sources-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.sources-grid a {
  font-size: 0.76rem; color: var(--color-primary-2); text-decoration: none;
  border: 1px solid var(--color-border); padding: 5px 12px; border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
.sources-grid a:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* --- Footer --- */
.footer { text-align: center; padding: 20px; font-size: 0.72rem; color: var(--color-text-faint); border-top: 1px solid var(--color-border); }

/* --- Toast --- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-left: 4px solid var(--color-success); padding: 12px 20px; border-radius: 8px; font-size: 0.84rem; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-left-color: var(--color-error); }
.toast.info { border-left-color: var(--color-primary); }

@media (max-width: 640px) {
  .container { padding: 16px 12px 40px; gap: 20px; }
  .lead-card { padding: 20px; }
  .lead-card h2 { font-size: 1.2rem; }
}

/* --- Hero Background Transparency --- */
body { background-color: color-mix(in srgb, var(--color-bg) 85%, transparent); }
.topbar { background: color-mix(in srgb, var(--color-surface) 80%, transparent); backdrop-filter: blur(8px); }
.navbar { background: color-mix(in srgb, var(--color-surface-2) 80%, transparent); backdrop-filter: blur(24px); }
.lead-card, .evidence-card, .playbook-card, .project-card {
  background: color-mix(in srgb, var(--color-surface) 80%, transparent);
  backdrop-filter: blur(4px);
}
.nav-menu { background: color-mix(in srgb, var(--color-surface) 85%, transparent); backdrop-filter: blur(32px); }
.toast { background: color-mix(in srgb, var(--color-surface) 85%, transparent); backdrop-filter: blur(16px); }
.footer { background: color-mix(in srgb, var(--color-surface) 80%, transparent); backdrop-filter: blur(4px); }

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

/* --- Nav / subnav horizontal overflow guard --- */
.nav-links { flex-wrap: nowrap; flex-shrink: 0; }
.nav-menu { min-width: 0; }
.navbar-inner { height: auto; }
#refresh-btn { display: none; }
.nav-item.subnav-right > .subnav { left: auto !important; right: 0 !important; }
.nav-item.subnav-right > .subnav.subnav-nested { left: auto !important; right: 100% !important; }
html.nav-collapsed .hamburger { display: flex; }
html.nav-collapsed .nav-menu { position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 8px 12px; transform: translateY(-200%); transition: transform 300ms ease; z-index: 99; }
html.nav-collapsed .nav-menu.open { transform: translateY(0); }
html.nav-collapsed .nav-links { flex-direction: column; gap: 2px; }
html.nav-collapsed .nav-links a { padding: 10px 12px; }


/* research corpus (md2wiki researchFiles) */
.research-list { display: flex; flex-wrap: wrap; gap: 8px; }
.research-link { font-size: 0.82rem; color: var(--color-primary); text-decoration: none; background: var(--color-surface-2, rgba(0,0,0,0.04)); border: 1px solid var(--color-border); padding: 5px 10px; border-radius: 999px; }
.research-link:hover { text-decoration: underline; }
