/* AgentFarmen: gemensam stil. Retro pixel, grön farm, neonrobotar. */

:root {
  --green-1: #3fbf4a;
  --green-2: #2e9a3a;
  --green-3: #1f6f2a;
  --green-light: #8fe08a;
  --sky: #7fd3ff;
  --sky-2: #cfefff;
  --sand: #f6e7b0;
  --earth: #8a5a2b;
  --earth-dark: #5b3a18;
  --wood: #c98a3f;
  --ink: #1b2430;
  --ink-soft: #3b4a5c;
  --paper: #fffdf5;
  --paper-2: #fff5cc;
  --neon-cyan: #00fff2;
  --neon-blue: #0066ff;
  --neon-magenta: #ff00ff;
  --neon-green: #4aad8b;
  --neon-orange: #ff6b35;
  --neon-yellow: #ffd23f;
  --sun: #ffd23f;
  --sun-dark: #d17f00;
  --danger: #e74c3c;

  --font-pixel: 'Press Start 2P', 'Courier New', monospace;
  --font-body: 'Nunito', 'Segoe UI', 'Helvetica Rounded', Arial, sans-serif;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-3d: 0 6px 0;
  --gap: 16px;
  --max-w: 1100px;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-2) 35%, var(--green-light) 36%, var(--green-1) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

img, canvas, svg { max-width: 100%; display: block; }

a { color: var(--green-3); }

h1, h2, h3, .pixel {
  font-family: var(--font-pixel);
  line-height: 1.5;
  letter-spacing: 0.5px;
  margin: 0;
}

h1 { font-size: clamp(22px, 6vw, 44px); }
h2 { font-size: clamp(14px, 3.5vw, 22px); }
h3 { font-size: clamp(11px, 3vw, 14px); }

p { margin: 0 0 1em; }

.container {
  width: min(100% - 32px, var(--max-w));
  margin-inline: auto;
}

.section {
  padding: 40px 0;
}

.section-title {
  text-align: center;
  color: #fff;
  text-shadow: 3px 3px 0 var(--green-3), 0 0 12px rgba(0,0,0,.25);
  margin-bottom: 28px;
}

.section-title.dark {
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--sun);
}

.muted { color: var(--ink-soft); }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 32px; }
.row { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }
.row.center { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(31, 111, 42, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 4px solid var(--green-3);
  color: #fff;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 6px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-pixel);
  font-size: 12px;
}

.brand svg { width: 32px; height: 32px; image-rendering: pixelated; }

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
}

.nav a:hover { background: rgba(255,255,255,.25); }

/* ---------- Hero ---------- */

.hero {
  padding: 28px 0 8px;
  text-align: center;
  color: #fff;
}

.hero h1 {
  color: #fff;
  text-shadow: 4px 4px 0 var(--green-3), 0 0 18px rgba(0,0,0,.25);
  animation: bob 2.5s ease-in-out infinite;
}

.hero .tagline {
  font-size: clamp(18px, 3.5vw, 26px);
  font-weight: 800;
  color: var(--ink);
  background: var(--paper);
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--green-3);
  margin: 14px 0 20px;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

#farm-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 60vh;
  margin: 0 auto;
  border: 6px solid var(--earth-dark);
  border-radius: var(--radius);
  background: var(--green-2);
  overflow: hidden;
  box-shadow: 0 10px 0 var(--earth-dark), 0 18px 30px rgba(0,0,0,.3);
}

#farm-container canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.farm-placeholder-text {
  position: absolute;
  inset: auto 0 12px 0;
  text-align: center;
  font-family: var(--font-pixel);
  font-size: clamp(9px, 2vw, 14px);
  color: #fff;
  text-shadow: 2px 2px 0 var(--green-3);
  pointer-events: none;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin: 28px 0 8px;
}

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--sun);
  --btn-bg-2: #ff9f1c;
  --btn-shadow: var(--sun-dark);
  --btn-fg: #5a3d00;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 18px;
  color: var(--btn-fg);
  background: linear-gradient(180deg, var(--btn-bg), var(--btn-bg-2));
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-3d) var(--btn-shadow), 0 10px 20px rgba(0,0,0,.25);
  transition: transform .08s, box-shadow .08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--btn-shadow), 0 14px 24px rgba(0,0,0,.28); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--btn-shadow), 0 4px 8px rgba(0,0,0,.2); }
.btn:focus-visible { outline: 4px solid #fff; outline-offset: 2px; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-big {
  font-family: var(--font-pixel);
  font-size: clamp(12px, 2.6vw, 18px);
  padding: 22px 30px;
  min-width: min(100%, 260px);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--btn-shadow), 0 14px 26px rgba(0,0,0,.3);
}
.btn-big:hover { box-shadow: 0 10px 0 var(--btn-shadow), 0 18px 30px rgba(0,0,0,.32); }
.btn-big:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--btn-shadow), 0 4px 10px rgba(0,0,0,.2); }
.btn-big .emoji { font-size: 1.6em; }

.btn-green { --btn-bg: #6fe36f; --btn-bg-2: var(--green-1); --btn-shadow: var(--green-3); --btn-fg: #0b3d12; }
.btn-blue { --btn-bg: #66ccff; --btn-bg-2: #1e90ff; --btn-shadow: #0b4f9e; --btn-fg: #05264d; }
.btn-pink { --btn-bg: #ff7ad9; --btn-bg-2: #ff2fb0; --btn-shadow: #9c0f6a; --btn-fg: #fff; }
.btn-red { --btn-bg: #ff7b6b; --btn-bg-2: var(--danger); --btn-shadow: #9c2a1e; --btn-fg: #fff; }
.btn-white { --btn-bg: #fff; --btn-bg-2: #eee; --btn-shadow: #b8b8b8; --btn-fg: var(--ink); }
.btn-small { font-size: 15px; padding: 8px 14px; box-shadow: 0 4px 0 var(--btn-shadow); }
.btn-small:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-shadow); }

/* ---------- Cards & grid ---------- */

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-games { grid-template-columns: repeat(auto-fit, minmax(150px, 190px)); justify-content: center; }

.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 12px 24px rgba(0,0,0,.18);
  color: var(--ink);
  border: 3px solid rgba(0,0,0,.08);
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  aspect-ratio: 1;
  min-height: 150px;
  padding: 16px;
  background: linear-gradient(180deg, var(--sun), #ff9f1c);
  border-radius: 24px;
  box-shadow: 0 10px 0 var(--sun-dark), 0 15px 30px rgba(0,0,0,.3);
  text-decoration: none;
  color: #5a3d00;
  font-weight: 900;
  text-align: center;
  transition: transform .08s, box-shadow .08s;
  border: none;
  cursor: pointer;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 13px 0 var(--sun-dark), 0 18px 35px rgba(0,0,0,.35); }
.game-card:active { transform: translateY(7px); box-shadow: 0 3px 0 var(--sun-dark), 0 6px 12px rgba(0,0,0,.2); }
.game-card .game-emoji { font-size: 60px; line-height: 1; animation: float 3s ease-in-out infinite; }
.game-card:nth-child(2n) .game-emoji { animation-delay: .4s; }
.game-card:nth-child(3n) .game-emoji { animation-delay: .8s; }
.game-card .game-name { font-size: 17px; line-height: 1.25; }
.game-card .game-author { font-size: 13px; opacity: .8; font-weight: 700; }
.game-card.kid { background: linear-gradient(180deg, #a6f0ff, #59c9ff); box-shadow: 0 10px 0 #1e7fb8, 0 15px 30px rgba(0,0,0,.3); color: #06334d; }
.game-card.kid:hover { box-shadow: 0 13px 0 #1e7fb8, 0 18px 35px rgba(0,0,0,.35); }
.game-card.kid:active { box-shadow: 0 3px 0 #1e7fb8, 0 6px 12px rgba(0,0,0,.2); }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  background: rgba(255,255,255,.85);
  border-radius: var(--radius);
  padding: 24px;
  font-weight: 800;
  color: var(--ink-soft);
  border: 3px dashed var(--green-3);
}

/* ---------- Steps ---------- */

.step {
  text-align: center;
  position: relative;
}
.step .step-num {
  font-family: var(--font-pixel);
  display: inline-block;
  background: var(--ink);
  color: var(--sun);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  margin-bottom: 12px;
  box-shadow: 0 4px 0 #000;
}
.step .step-icon { font-size: 56px; line-height: 1; margin-bottom: 8px; }
.step h3 { margin-bottom: 8px; }

/* ---------- Robots ---------- */

.robot-card {
  --robot: var(--neon-cyan);
  text-align: center;
  background: var(--ink);
  color: #fff;
  border: 3px solid var(--robot);
  box-shadow: 0 6px 0 #000, 0 0 18px color-mix(in srgb, var(--robot) 55%, transparent);
}
.robot-card .robot-sprite {
  width: 96px;
  height: 96px;
  margin: 0 auto 10px;
  image-rendering: pixelated;
  animation: bob 1.6s ease-in-out infinite;
}
.robot-card:nth-child(2n) .robot-sprite { animation-delay: .3s; }
.robot-card:nth-child(3n) .robot-sprite { animation-delay: .6s; }
.robot-card h3 { color: var(--robot); text-shadow: 0 0 8px var(--robot); margin-bottom: 4px; }
.robot-card .robot-role { font-size: 13px; opacity: .8; font-weight: 700; margin-bottom: 8px; }
.robot-card p { font-size: 15px; margin: 0; }

/* ---------- Footer ---------- */

.site-footer {
  background: var(--earth-dark);
  color: #f6e7b0;
  padding: 28px 0;
  margin-top: 40px;
  border-top: 6px solid var(--earth);
  text-align: center;
  font-size: 15px;
}
.site-footer a { color: var(--sun); font-weight: 800; }
.site-footer .footer-links { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Bygg-sidan: panel, byggstenar, toolbar ---------- */

.panel {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 12px 24px rgba(0,0,0,.18);
  border: 3px solid rgba(0,0,0,.08);
}
.panel > h2, .panel > h3 { margin-bottom: 12px; }
.panel-title {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--green-3);
  margin: 0 0 10px;
}
.panel.dark { background: var(--ink); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }

.block-chip {
  --chip: var(--sun);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 3px solid var(--chip);
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--chip) 60%, #000);
  transition: transform .08s, box-shadow .08s, background .12s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.block-chip .emoji { font-size: 1.4em; line-height: 1; }
.block-chip:hover { transform: translateY(-2px); }
.block-chip:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--chip) 60%, #000); }
.block-chip.active {
  background: var(--chip);
  color: #111;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--chip) 60%, #000), 0 0 14px var(--chip);
  transform: translateY(2px);
}
.block-chip[disabled], .block-chip.disabled { opacity: .5; cursor: not-allowed; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(31,111,42,.9);
  border-radius: var(--radius);
  border: 3px solid var(--green-3);
  box-shadow: 0 6px 0 var(--green-3);
  color: #fff;
}
.toolbar .spacer { flex: 1; }
.toolbar .toolbar-title { font-family: var(--font-pixel); font-size: 12px; }

.input, input[type="text"], select, textarea {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 3px solid var(--green-3);
  background: #fff;
  color: var(--ink);
  max-width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 4px solid var(--sun); outline-offset: 1px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: var(--sun);
  color: #5a3d00;
}

.bubble {
  position: relative;
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 12px 16px;
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-weight: 700;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 24px;
  bottom: -14px;
  border: 8px solid transparent;
  border-top-color: var(--ink);
}

/* ---------- Layout for builder (two columns on wide) ---------- */

.builder-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .builder-layout { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }
}

/* ---------- Responsive tweaks ---------- */

@media (max-width: 600px) {
  body { font-size: 16px; }
  .section { padding: 28px 0; }
  .card { padding: 16px; }
  .btn-big { width: 100%; }
  .grid-games { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-card .game-emoji { font-size: 48px; }
  .nav a { padding: 5px 10px; font-size: 14px; }
}

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