@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@700;800&family=Inter:wght@400;500;600;700&display=swap');

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Variables — Tomorrow Night palette, matches the clicker game lessons */
:root {
  --tn-bg:      #1d1f21;
  --tn-surface: #282a2e;
  --tn-raised:  #373b41;
  --tn-fg:      #c5c8c6;
  --tn-muted:   #969896;
  --tn-blue:    #81a2be;
  --tn-aqua:    #8abeb7;
  --tn-green:   #b5bd68;
  --tn-purple:  #b294bb;
  --tn-red:     #cc6666;

  --border-light: #e5e5e5;
  --radius: 6px;
  --electric-blue: #2f8eff;
  --electric-green: #00e676;
  --page-bg: #dce6f5;
  --font: 'Inter', system-ui, sans-serif;
  --font-display: 'Baloo 2', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--tn-bg);
  background: var(--page-bg);
  min-width: 320px;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.25; }
h1 { font-size: 2.5rem; font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; }
h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

strong { font-weight: 700; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Nav */
.site-nav {
  background: var(--page-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  text-decoration: none;
  color: var(--tn-bg);
  white-space: nowrap;
}

.nav-links {
  display: none;
  list-style: none;
  gap: 1.5rem;
}

.nav-links a {
  text-decoration: none;
  font-size: 1rem;
  color: var(--tn-bg);
  padding-bottom: 2px;
}

.nav-links a.active {
  border-bottom: 2px solid var(--tn-bg);
}

.nav-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--tn-bg);
  transform-origin: center;
}

.nav-hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.is-open span:nth-child(2) { opacity: 0; }
.nav-hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-mobile {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 1rem 1.25rem 30px;
  background: var(--page-bg);
  z-index: 99;
}

.nav-mobile.open { display: block; }

.nav-mobile ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nav-mobile a {
  text-decoration: none;
  font-size: 1rem;
  color: var(--tn-bg);
}

.nav-mobile a:hover { text-decoration: underline; }

.nav-mobile a.active {
  font-weight: 700;
  text-decoration: underline;
}

@media (min-width: 640px) {
  .nav-hamburger { display: none; }
  .nav-mobile { display: none !important; }
  .nav-links { display: flex; }
}

/* Header */
header {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.25rem 2rem;
  border-bottom: 1px solid var(--border-light);
}

header p {
  color: #555;
  font-size: 1.0625rem;
  margin-bottom: 0;
}

/* Main / sections */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

section {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border-light);
}

section:last-of-type {
  border-bottom: none;
}

/* "Remember" anatomy callout */
.remember {
  background: var(--tn-surface);
  color: var(--tn-fg);
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  margin: 0 0 1.5rem;
}

.remember strong { color: var(--tn-green); }

.more-link {
  font-size: 0.875rem;
  color: #555;
}

.remember + .more-link {
  margin-top: -0.75rem;
}

table + .more-link {
  margin-top: 0.75rem;
}

.anatomy-diagram {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.anatomy-diagram code {
  background: var(--tn-bg);
  border-color: var(--tn-raised);
  color: var(--tn-green);
}

.anatomy-part {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.anatomy-arrow {
  color: var(--tn-green);
  font-size: 1.125rem;
  line-height: 1;
}

.anatomy-label {
  font-size: 0.75rem;
  color: var(--tn-muted);
  text-align: center;
  max-width: 170px;
}

/* Code blocks */
pre, code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.875rem;
}

pre {
  background: var(--tn-bg);
  color: var(--tn-fg);
  border: 1px solid var(--tn-raised);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  line-height: 1.5;
}

code {
  background: var(--tn-bg);
  color: var(--tn-fg);
  border: 1px solid var(--tn-raised);
  border-radius: var(--radius);
  padding: 0.1em 0.35em;
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

.code-comment { color: var(--tn-muted); }
.code-new { color: var(--electric-green); }

/* More CSS Tricks (css.html) */
.trick-row {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1.5rem 0;
}

.trick-row:first-of-type { padding-top: 1rem; }

.trick-text { flex: 1; min-width: 0; }
.trick-text h3 { color: var(--tn-red); }

.trick-example {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  min-height: 140px;
  background: var(--tn-surface);
  border: 1px solid var(--tn-raised);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: var(--tn-fg);
  text-align: center;
}

.demo-shape {
  width: 72px;
  height: 72px;
  background: var(--tn-red);
}

.demo-shape.demo-circle { border-radius: 50%; }

.demo-arrow { font-size: 1.5rem; color: var(--tn-fg); }

.demo {
  width: 100px;
  height: 100px;
  background: var(--tn-blue);
}

.demo-background {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7ec2ff, #2f8eff 60%, #1a56b0 100%);
}

.demo-dashed {
  background: transparent;
  border: 4px dashed var(--tn-blue);
}

.demo-glow {
  border-radius: 50%;
  background: var(--electric-blue);
  box-shadow: 0 0 24px 8px rgba(47, 142, 255, 0.8);
}

.demo-bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: url("https://media.post.rvohealth.io/wp-content/uploads/2020/08/blueberries_fresh_fullframe_732x549_thumb.jpg");
  background-repeat: repeat;
  background-size: 140px;
}

.trick-row:has(.demo-bg-image) .trick-example {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.demo-text {
  font-family: var(--font);
  font-weight: 700;
}

.demo-color {
  color: #7ec2ff;
  font-size: 1.5rem;
}

.demo-fontsize-small { font-size: 1rem; color: var(--tn-fg); }
.demo-fontsize-big { font-size: 3rem; color: var(--tn-fg); }

.demo-size-small { width: 48px; height: 48px; }
.demo-size-big { width: 100px; height: 100px; }

/* Give each trick its own accent color */
.trick-row:has(.demo-dashed) .trick-text h3 { color: color-mix(in srgb, var(--tn-blue) 20%, var(--tn-surface)); }
.trick-row:has(.demo-dashed) .trick-example {
  background: color-mix(in srgb, var(--tn-blue) 20%, var(--tn-surface));
  border-color: color-mix(in srgb, var(--tn-blue) 50%, var(--tn-surface));
}

.trick-row:has(.demo-background) .trick-text h3 { color: color-mix(in srgb, var(--tn-aqua) 20%, var(--tn-surface)); }
.trick-row:has(.demo-background) .trick-example {
  background: color-mix(in srgb, var(--tn-aqua) 20%, var(--tn-surface));
  border-color: color-mix(in srgb, var(--tn-aqua) 50%, var(--tn-surface));
}

.trick-row:has(.demo-bg-image) .trick-text h3 { color: color-mix(in srgb, var(--tn-red) 20%, var(--tn-surface)); }
.trick-row:has(.demo-bg-image) .trick-example {
  background: color-mix(in srgb, var(--tn-red) 20%, var(--tn-surface));
  border-color: color-mix(in srgb, var(--tn-red) 50%, var(--tn-surface));
}

.trick-row:has(.demo-circle) .trick-text h3 { color: color-mix(in srgb, var(--tn-red) 20%, var(--tn-surface)); }
.trick-row:has(.demo-circle) .trick-example {
  background: color-mix(in srgb, var(--tn-red) 20%, var(--tn-surface));
  border-color: color-mix(in srgb, var(--tn-red) 50%, var(--tn-surface));
}

.trick-row:has(.demo-glow) .trick-text h3 { color: color-mix(in srgb, var(--electric-blue) 20%, var(--tn-surface)); }
.trick-row:has(.demo-glow) .trick-example {
  background: color-mix(in srgb, var(--electric-blue) 20%, var(--tn-surface));
  border-color: color-mix(in srgb, var(--electric-blue) 50%, var(--tn-surface));
}

.trick-row:has(.demo-color) .trick-text h3 { color: color-mix(in srgb, #ec4899 20%, var(--tn-surface)); }
.trick-row:has(.demo-color) .trick-example {
  background: var(--tn-surface);
  border-color: color-mix(in srgb, #ec4899 50%, var(--tn-surface));
}

.trick-row:has(.demo-fontsize-big) .trick-text h3 { color: color-mix(in srgb, var(--tn-purple) 20%, var(--tn-surface)); }
.trick-row:has(.demo-fontsize-big) .demo-fontsize-big { color: var(--tn-purple); }
.trick-row:has(.demo-fontsize-big) .trick-example {
  background: color-mix(in srgb, var(--tn-purple) 20%, var(--tn-surface));
  border-color: color-mix(in srgb, var(--tn-purple) 50%, var(--tn-surface));
}

.trick-row:has(.demo-size-big) .trick-text h3 { color: color-mix(in srgb, var(--tn-green) 20%, var(--tn-surface)); }
.trick-row:has(.demo-size-big) .demo-size-small,
.trick-row:has(.demo-size-big) .demo-size-big { background: var(--tn-green); }
.trick-row:has(.demo-size-big) .trick-example {
  background: color-mix(in srgb, var(--tn-green) 20%, var(--tn-surface));
  border-color: color-mix(in srgb, var(--tn-green) 50%, var(--tn-surface));
}

@media (max-width: 560px) {
  .trick-row { flex-direction: column; }
}

/* Tables */
table {
  width: 100%;
  table-layout: fixed;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 1rem 0 0;
  font-size: 0.9375rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  padding: 0.75rem 1rem;
  background: var(--tn-bg);
  color: var(--tn-fg);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  vertical-align: top;
  background: var(--tn-surface);
  color: var(--tn-fg);
  border-top: 1px solid var(--tn-raised);
}

/* Code editor tabs */
.editor {
  background: var(--tn-surface);
  border: 1px solid var(--tn-raised);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1rem;
}

.editor-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--tn-bg);
  padding: 0.5rem 0.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.editor-tab {
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--electric-blue);
  background: transparent;
  border: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.625rem 1rem;
  cursor: pointer;
  white-space: nowrap;
}

.editor-tab.active {
  background: var(--tn-surface);
}

.editor-panel {
  display: none;
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--tn-surface);
}

.editor-panel.active { display: block; }

.editor-panel-preview { padding: 1.25rem; }

.editor-panel-preview iframe {
  width: 100%;
  height: 360px;
  border: none;
  border-radius: var(--radius);
  display: block;
  background: #fff;
}

/* Game embed (home page) */
.game-frame-wrap {
  background: var(--tn-surface);
  border: 1px solid var(--tn-raised);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.game-frame-wrap iframe {
  width: 100%;
  height: 420px;
  border: none;
  border-radius: var(--radius);
  display: block;
}

/* Numbered goal list (home page) */
.goals-list {
  list-style: none;
  counter-reset: step;
  margin: 1rem 0 0;
}

.goals-list > li {
  counter-increment: step;
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9375rem;
}

.goals-list > li:last-child { border-bottom: none; }

.goals-list > li::before {
  content: counter(step);
  min-width: 24px;
  height: 24px;
  background: var(--tn-bg);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.goals-sublist {
  list-style: none;
  counter-reset: substep;
  margin: 0.625rem 0 0;
}

.goals-sublist li {
  counter-increment: substep;
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem 0;
  color: #555;
}

.goals-sublist li::before {
  content: counter(substep, lower-alpha) ".";
  font-weight: 600;
  color: #888;
  flex-shrink: 0;
}

/* Generic buttons */
button {
  font-family: var(--font);
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  background: var(--electric-blue);
  color: #fff;
}

button:hover { filter: brightness(1.08); }

.site-footer {
  border-top: 1px solid var(--border-light);
  padding: 1.5rem 1.25rem;
  margin-top: 3rem;
  font-size: 0.8125rem;
  color: #888;
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-left: 0;
  padding-right: 0;
}

.site-footer a,
.site-footer a:visited,
.site-footer a:active {
  color: #888;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Per-language code lock (html.html, css.html, js.html editor panels) */
.editor-panel pre {
  display: none;
  margin: 0;
}

.editor-panel.unlocked pre {
  display: block;
}

.code-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
  font-family: var(--font);
}

.editor-panel.unlocked .code-lock {
  display: none;
}

.code-lock-emoji { font-size: 1.75rem; }

.code-lock p {
  color: var(--tn-muted);
  font-size: 0.8125rem;
  margin-bottom: 0;
}

.code-lock-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.code-lock-form input {
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--tn-raised);
  background: var(--tn-bg);
  color: var(--tn-fg);
  width: 160px;
}

.code-lock-form button {
  padding: 8px 14px;
  font-size: 0.875rem;
}

.code-lock-error {
  color: var(--tn-red);
  font-size: 0.8125rem;
  min-height: 1rem;
  margin-bottom: 0;
}
