/* Coolkid AI Lab v0.2 — NES.css overrides + custom layout */

/* === Theme tokens === */
:root, :root[data-theme="dark"] {
  --bg: #212529;
  --bg-elev: #2c3338;
  --bg-card: #ffffff;
  --text: #ffffff;
  --text-on-card: #212529;
  --text-dim: #b0b9c2;
  --text-mute: #6c757d;
  --line: #495057;
  --nes-red: #e76e55;
  --nes-yellow: #f7d51d;
  --nes-green: #92cc41;
  --nes-blue: #209cee;
  --nes-purple: #b455e0;
  --warn: #f7d51d;
  --danger: #e76e55;
  --ok: #92cc41;
}
:root[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --text: #212529;
  --text-on-card: #212529;
  --text-dim: #495057;
  --text-mute: #868e96;
  --line: #ced4da;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Press Start 2P", "Microsoft JhengHei", "PingFang TC", monospace;
  line-height: 1.7;
  font-size: 14px;
  transition: background .25s, color .25s;
  /* subtle CRT scanline */
  background-image: repeating-linear-gradient(
    0deg, transparent 0, transparent 3px,
    rgba(0,0,0,.04) 3px, rgba(0,0,0,.04) 4px
  );
}
[data-theme="light"] body {
  background-image: repeating-linear-gradient(
    0deg, transparent 0, transparent 3px,
    rgba(0,0,0,.02) 3px, rgba(0,0,0,.02) 4px
  );
}
img { max-width: 100%; display: block; }
a { color: var(--nes-blue); text-decoration: none; }
a:hover { color: var(--nes-yellow); }
[data-theme="light"] a { color: #1a6db5; }
.zh { font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif; }

/* === Layout === */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }
.row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* === Top bar === */
.topbar {
  background: var(--bg);
  border-bottom: 4px solid var(--text);
  padding: 16px 0;
  position: sticky; top: 0; z-index: 50;
}
.brand {
  font-size: 14px; color: var(--text); font-weight: 700;
  display: inline-flex; align-items: center; gap: 12px;
}
.brand .charm { display: inline-flex; align-items: center; transform-origin: left center; margin-right: 4px; }
.brand .mascot-img {
  width: 84px; height: 84px;
  display: inline-block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  vertical-align: middle;
}
.brand .mascot-fallback { transform: scale(1.4); transform-origin: left center; }
.brand .ver { color: var(--nes-yellow); margin-left: 8px; font-size: 10px; }
nav.primary { display: flex; gap: 4px; flex-wrap: wrap; }
nav.primary a {
  font-size: 11px; color: var(--text-dim);
  padding: 6px 10px; border-radius: 0;
  text-decoration: none;
}
nav.primary a:hover { color: var(--nes-yellow); background: var(--bg-elev); }
nav.primary a.active { color: var(--nes-red); }
[data-theme="light"] nav.primary a { color: var(--text-dim); }
[data-theme="light"] nav.primary a.active { color: var(--nes-red); }

/* Theme switch button (NES style) */
.theme-toggle {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  background: var(--nes-yellow);
  color: #212529;
  border: 3px solid #212529;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 4px 4px 0 #212529;
  transition: transform .1s;
}
.theme-toggle:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #212529; }
.theme-toggle:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #212529; }

/* === Hero === */
.hero {
  padding: 64px 0 48px;
  border-bottom: 4px solid var(--text);
  text-align: center;
}
.hero .eyebrow {
  display: inline-block;
  font-size: 10px;
  color: var(--nes-yellow);
  border: 2px solid var(--nes-yellow);
  padding: 4px 10px;
  margin-bottom: 24px;
}
.hero h1 {
  font-size: clamp(18px, 3.2vw, 28px);
  line-height: 1.5;
  margin: 0 0 18px;
  color: var(--text);
}
.hero .lede {
  max-width: 720px; margin: 0 auto 28px;
  color: var(--text-dim); font-size: 12px; line-height: 2;
}
.hero .charm-stage { margin: 24px auto; display: flex; justify-content: center; }
.hero .charm-stage .nes-charmander { transform: scale(1.6); }
.btn-row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* === Hero "我是誰" intro: portrait left + text right === */
.hero-intro {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px;
  align-items: center;
  margin: 32px auto 0;
  max-width: 800px;
  text-align: left;
}
.hero-intro-img {
  border: 4px solid var(--nes-yellow);
  background: var(--bg-elev);
  padding: 6px;
  box-shadow: 6px 6px 0 #212529;
  flex-shrink: 0;
}
.hero-intro-img img {
  display: block;
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}
.hero-intro-text { min-width: 0; }
@media (max-width: 720px) {
  .hero-intro { grid-template-columns: 1fr; justify-items: center; gap: 20px; }
  .hero-intro-text { text-align: center; }
  .hero-intro-text .btn-row { justify-content: center !important; }
  .hero-intro-text .lede { text-align: center !important; }
  .hero-intro-img img { width: 180px; height: 180px; }
}

/* === Sections === */
section.block { padding: 56px 0; border-bottom: 4px dashed var(--line); }
.sec-num {
  font-size: 10px; color: var(--nes-yellow); margin-bottom: 6px;
}
section.block h2 {
  font-size: clamp(16px, 2.4vw, 22px);
  color: var(--text); margin: 0 0 8px;
}
.sec-sub { color: var(--text-dim); font-size: 12px; line-height: 1.9; max-width: 720px; margin-bottom: 32px; }

/* === Cards (using .nes-container) === */
.grid { display: grid; gap: 24px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.nes-container.is-rounded { border-radius: 0 !important; }
.nes-container.with-title > .title {
  font-size: 11px; color: var(--text-on-card);
  background: var(--bg-card); padding: 0 10px;
}
.nes-container { background: var(--bg-card); color: var(--text-on-card); padding: 24px !important; }
.nes-container > h3 { font-size: 13px; color: var(--text-on-card); margin: 0 0 10px; }
.nes-container > p { color: #495057; font-size: 11px; line-height: 1.9; margin: 0; }
.gi { width: 36px; height: 36px; color: var(--text-on-card); fill: var(--text-on-card); }
.nes-container .gi { margin-bottom: 12px; }
.nes-container .gi,
.nes-container .gi * {
  color: var(--text-on-card);
  fill: var(--text-on-card) !important;
}
.gi path { fill: currentColor; }
.card-link { text-decoration: none; color: inherit; display: block; transition: transform .12s; }
.card-link:hover { transform: translate(-2px, -2px); }

/* === Buttons === */
.nes-btn { font-family: "Press Start 2P", monospace !important; font-size: 11px !important; }

/* === Performance Dashboard === */
.perf-card { background: var(--bg-card); border: 4px solid var(--text-on-card); padding: 24px; color: var(--text-on-card); }
.perf-status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 2px dashed var(--text-on-card); font-size: 10px; }
.perf-status { font-weight: 700; padding: 4px 10px; background: var(--nes-yellow); color: #212529; }
.perf-status[data-state="LIVE"] { background: var(--nes-green); color: #212529; }
.perf-status[data-state="OFFLINE"] { background: var(--text-mute); color: white; }
.perf-mode { color: var(--text-mute); }
.perf-updated { margin-left: auto; color: var(--text-mute); font-size: 9px; }
.perf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.perf-stat { background: #f7f8fa; border: 3px solid var(--text-on-card); padding: 12px; text-align: center; }
.perf-label { font-size: 9px; color: var(--text-mute); margin-bottom: 4px; }
.perf-value { font-size: 16px; color: var(--text-on-card); font-weight: 700; }
.perf-note { color: #d9534f; font-size: 10px; margin-top: 14px; padding: 10px; background: #fff3cd; border-left: 4px solid #d9534f; }

/* === Social row (pixel-style icons) === */
.social-row {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  padding: 6px;
  border: 3px solid var(--text);
  background: var(--bg-elev);
  text-decoration: none;
  transition: transform .12s, background .15s;
  box-sizing: border-box;
}
.social-link:hover {
  background: var(--nes-yellow);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--text);
}
.social-link .nes-icon { vertical-align: middle; }
.social-link .pixel-icon,
.social-link .brand-icon {
  fill: var(--text);
  display: block;
  width: 32px;
  height: 32px;
}
.social-link:hover .pixel-icon,
.social-link:hover .brand-icon { fill: #212529; }
[data-theme="light"] .social-link { background: #fff; }
[data-theme="light"] .social-link .pixel-icon,
[data-theme="light"] .social-link .brand-icon { fill: #212529; }

/* === Disclaimer Strip === */
.disclaimer-strip {
  background: var(--nes-red); color: white;
  padding: 12px 18px; text-align: center;
  font-size: 10px; line-height: 1.8;
  border-top: 4px solid #212529;
  border-bottom: 4px solid #212529;
}

/* === Footer === */
footer.site {
  padding: 40px 0 24px; background: var(--bg-elev); color: var(--text-dim);
  font-size: 10px; border-top: 4px solid var(--text);
}
footer.site .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; margin-bottom: 24px; }
footer.site h4 { color: var(--nes-yellow); font-size: 10px; margin: 0 0 10px; }
footer.site ul { list-style: none; padding: 0; margin: 0; }
footer.site li { margin-bottom: 6px; }
footer.site a { color: var(--text-dim); }
footer.site a:hover { color: var(--nes-yellow); }
footer.site .legal-note { padding-top: 18px; border-top: 2px dashed var(--line); font-size: 9px; line-height: 1.9; color: var(--text-mute); }

/* === Article (legal pages, blog posts) === */
article.post { max-width: 720px; margin: 0 auto; padding: 48px 18px; }
article.post h1 { font-size: 18px; color: var(--text); margin: 0 0 14px; }
article.post .meta { color: var(--text-mute); font-size: 10px; margin-bottom: 28px; padding-bottom: 16px; border-bottom: 2px dashed var(--line); }
article.post h2 { font-size: 14px; color: var(--nes-yellow); margin: 32px 0 10px; }
article.post h3 { font-size: 12px; color: var(--text); margin: 22px 0 8px; }
article.post p, article.post li { color: var(--text-dim); font-size: 11px; line-height: 2; }
article.post ul, article.post ol { padding-left: 22px; margin: 12px 0; }
article.post strong { color: var(--text); }
article.post code { background: var(--bg-elev); padding: 2px 6px; color: var(--nes-yellow); font-size: 11px; }
article.post table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 11px; }
article.post th, article.post td { border: 2px solid var(--line); padding: 8px 10px; text-align: left; color: var(--text-dim); }
article.post th { background: var(--bg-elev); color: var(--nes-yellow); }

/* === Page head (inner pages hero) === */
.pagehead { padding: 56px 0 32px; border-bottom: 4px dashed var(--line); text-align: center; }
.pagehead h1 { font-size: clamp(16px, 2.6vw, 22px); margin: 0 0 12px; color: var(--text); }
.pagehead p { color: var(--text-dim); font-size: 11px; line-height: 1.9; max-width: 640px; margin: 0 auto; }
.pagehead .eyebrow {
  display: inline-block; font-size: 9px; color: var(--nes-yellow);
  border: 2px solid var(--nes-yellow); padding: 4px 10px; margin-bottom: 16px;
}

/* === Forms === */
.nes-input, .nes-textarea, .nes-select select { font-family: inherit !important; font-size: 11px !important; }

/* === Tag pills === */
.tag {
  display: inline-block; font-size: 9px; padding: 3px 8px;
  background: var(--nes-yellow); color: #212529; margin-bottom: 10px;
}
.tag.is-red { background: var(--nes-red); color: white; }
.tag.is-green { background: var(--nes-green); color: #212529; }
.tag.is-blue { background: var(--nes-blue); color: white; }

/* === Responsive === */
@media (max-width: 720px) {
  .topbar .row { flex-direction: column; align-items: stretch; }
  nav.primary { justify-content: center; }
  nav.primary a { font-size: 10px; padding: 4px 6px; }
  body { font-size: 12px; }
  section.block { padding: 40px 0; }
}

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