/* ==========================================================================
   BlockCraft — Minecraft-stijl designsysteem
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --font-pixel: 'Pixelify Sans', 'Courier New', monospace;

  /* Nachtlucht */
  --sky-top: #0c1120;
  --sky-bottom: #1d2b4a;

  /* Minecraft-blockken */
  --grass: #5d9c3c;
  --grass-light: #6fb34a;
  --grass-dark: #4a7d30;
  --dirt: #79553a;
  --dirt-dark: #5c4029;
  --dirt-light: #8a6547;
  --stone: #8a8a8a;
  --stone-dark: #565656;
  --bedrock: #26221e;

  /* MC GUI */
  --panel: #c6c6c6;
  --panel-light: #ffffff;
  --panel-dark: #555555;
  --btn: #7a7a7a;
  --btn-hover: #7f8fbf;

  /* Accents */
  --diamond: #4dd6e8;
  --gold: #f8c22a;
  --redstone: #e5484d;
  --slime: #7ec850;
  --xp-green: #7bba2b;

  --text: #ffffff;
  --text-dark: #2b2b2b;
  --text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);

  --radius: 0; /* Minecraft is hoekig */
  --shadow-hard: 0 6px 0 rgba(0, 0, 0, 0.35);
  --transition-ui: 120ms steps(2, end);

  --content: 1160px;
}

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

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -200px, #2a3c6b 0%, transparent 60%),
    linear-gradient(var(--sky-top), var(--sky-bottom));
  background-attachment: fixed;
  overflow-x: hidden;
}

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

h1,
h2,
h3 {
  line-height: 1.15;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
}

/* hidden moet altijd winnen van display: grid/flex */
[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

::selection {
  background: var(--grass);
  color: #fff;
}

/* ---------- Minecraft knoppen ---------- */
.mc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  font-family: var(--font-pixel);
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  text-shadow: var(--text-shadow);
  background: var(--btn);
  border: 2px solid #1a1a1a;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.42),
    inset -2px -4px 0 rgba(0, 0, 0, 0.42),
    0 4px 0 rgba(0, 0, 0, 0.35);
  image-rendering: pixelated;
  user-select: none;
  transition:
    background var(--transition-ui),
    transform var(--transition-ui),
    box-shadow var(--transition-ui);
}

.mc-btn:hover,
.mc-btn:focus-visible {
  background: var(--btn-hover);
  color: #ffffa0;
}

.mc-btn:active {
  transform: translateY(3px);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.42),
    inset -2px -4px 0 rgba(0, 0, 0, 0.42),
    0 1px 0 rgba(0, 0, 0, 0.35);
}

.mc-btn.primary {
  background: var(--grass);
}

.mc-btn.primary:hover,
.mc-btn.primary:focus-visible {
  background: var(--grass-light);
  color: #fff;
}

.mc-btn.big {
  font-size: 20px;
  padding: 14px 30px;
}

.mc-btn.small {
  font-size: 15px;
  padding: 6px 14px;
}

.icon-btn {
  padding: 6px 10px;
  line-height: 1;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  background: rgba(15, 18, 30, 0.88);
  backdrop-filter: blur(6px);
  border-bottom: 3px solid #000;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  text-shadow: var(--text-shadow);
  letter-spacing: 1px;
}

.logo-block {
  width: 22px;
  height: 22px;
  background:
    linear-gradient(var(--grass) 0 55%, transparent 55%),
    var(--dirt);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35);
}

.main-nav {
  display: flex;
  gap: 18px;
  font-size: 17px;
}

.main-nav a {
  text-shadow: var(--text-shadow);
  padding: 4px 2px;
}

.main-nav a:hover {
  color: var(--gold);
}

.xp-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.xp-bar {
  width: clamp(90px, 14vw, 170px);
  height: 16px;
  background: #0a0a0a;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    90deg,
    var(--xp-green) 0 6px,
    #639c22 6px 8px
  );
  transition: width 400ms steps(8, end);
}

.xp-label {
  font-size: 15px;
  color: var(--xp-green);
  text-shadow: var(--text-shadow);
  white-space: nowrap;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: calc(100dvh - 70px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.hero-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 8% 18%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 20% 55%, #cfe0ff 50%, transparent 51%),
    radial-gradient(2px 2px at 32% 26%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 43% 68%, #ffe9a8 50%, transparent 51%),
    radial-gradient(2px 2px at 58% 14%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 66% 44%, #cfe0ff 50%, transparent 51%),
    radial-gradient(2px 2px at 76% 72%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 86% 30%, #ffe9a8 50%, transparent 51%),
    radial-gradient(2px 2px at 93% 60%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 15% 84%, #cfe0ff 50%, transparent 51%),
    radial-gradient(2px 2px at 50% 86%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 63% 78%, #ffe9a8 50%, transparent 51%);
  animation: twinkle 6s steps(6, end) infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Pixelwolken */
.cloud {
  position: absolute;
  width: 180px;
  height: 54px;
  background: #e8edf5;
  box-shadow:
    -22px -18px 0 -12px #e8edf5,
    26px -22px 0 -14px #e8edf5,
    60px -8px 0 -20px #e8edf5,
    -52px 0 0 -18px #e8edf5;
  opacity: 0.4;
}

.cloud.c1 { top: 16%; animation: drift 55s linear infinite; }
.cloud.c2 { top: 38%; animation: drift 80s linear infinite; animation-delay: -30s; }
.cloud.c3 { top: 60%; animation: drift 65s linear infinite; animation-delay: -48s; }

@keyframes drift {
  from { transform: translateX(-260px); }
  to { transform: translateX(calc(100vw + 260px)); }
}

/* Zwevende blokken */
.hero-block {
  position: absolute;
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  opacity: 0.9;
}

.hb1 { top: 18%; left: 8%; animation: floaty 5s ease-in-out infinite; }
.hb2 { top: 58%; left: 14%; animation: floaty 6.5s ease-in-out infinite; animation-delay: -2s; }
.hb3 { top: 26%; right: 10%; animation: floaty 7s ease-in-out infinite; animation-delay: -1s; }
.hb4 { top: 64%; right: 16%; animation: floaty 5.5s ease-in-out infinite; animation-delay: -3s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-22px) rotate(3deg); }
}

.hero-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 60px 24px;
  max-width: 880px;
}

.hero-kicker {
  display: inline-block;
  padding: 6px 16px;
  font-size: 15px;
  color: var(--gold);
  text-shadow: var(--text-shadow);
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(248, 194, 42, 0.5);
  margin-bottom: 22px;
}

.hero-title {
  font-size: clamp(56px, 11vw, 132px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 2px;
  color: #fff;
  text-shadow:
    3px 3px 0 #3f3f3f,
    6px 6px 0 rgba(0, 0, 0, 0.55),
    0 0 40px rgba(77, 214, 232, 0.25);
}

.hero-title .accent {
  color: var(--grass-light);
}

.hero-sub-title {
  display: block;
  font-size: 0.36em;
  color: var(--diamond);
  letter-spacing: 8px;
  text-transform: uppercase;
  margin-top: 8px;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
}

.hero-sub {
  font-size: 20px;
  color: #d5dce8;
  text-shadow: var(--text-shadow);
  max-width: 62ch;
  margin: 26px auto 34px;
}

.hero-cta {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-badges {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 34px;
}

.badge {
  font-size: 14px;
  padding: 5px 12px;
  text-shadow: var(--text-shadow);
  border: 2px solid #000;
}

.badge.b-green { background: var(--grass-dark); }
.badge.b-blue { background: #2c5f8a; }
.badge.b-gold { background: #a87f1d; }

/* ---------- Secties ---------- */
.games-section,
.info-section {
  max-width: var(--content);
  margin: 0 auto;
  padding: clamp(48px, 8vw, 96px) 24px;
}

.section-title {
  font-size: clamp(30px, 4.5vw, 44px);
  text-shadow: var(--text-shadow);
  text-align: center;
}

.games-section .section-title::after {
  content: '';
  display: block;
  width: 120px;
  height: 8px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, var(--grass) 0 50%, var(--dirt) 50% 100%);
  border: 2px solid #000;
}

.section-sub {
  text-align: center;
  color: #b9c2d2;
  text-shadow: var(--text-shadow);
  margin: 16px auto 44px;
  max-width: 60ch;
}

/* ---------- Spelkaarten ---------- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 28px;
}

.game-card {
  position: relative;
  background: var(--dirt);
  border: 3px solid #000;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.22),
    inset -2px -2px 0 rgba(0, 0, 0, 0.35),
    var(--shadow-hard);
  transition:
    transform var(--transition-ui),
    box-shadow var(--transition-ui);
}

.game-card:hover,
.game-card:focus-within {
  transform: translateY(-6px);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.22),
    inset -2px -2px 0 rgba(0, 0, 0, 0.35),
    0 10px 0 rgba(0, 0, 0, 0.35),
    0 0 0 3px var(--gold);
}

/* Grasrand met zigzag onderrand */
.game-card::before {
  content: '';
  display: block;
  height: 26px;
  background: var(--grass);
  border-bottom: 3px solid #000;
  clip-path: polygon(
    0 0, 100% 0, 100% 62%,
    93.75% 100%, 87.5% 62%,
    81.25% 100%, 75% 62%,
    68.75% 100%, 62.5% 62%,
    56.25% 100%, 50% 62%,
    43.75% 100%, 37.5% 62%,
    31.25% 100%, 25% 62%,
    18.75% 100%, 12.5% 62%,
    6.25% 100%, 0 62%
  );
  margin: -3px -3px 14px; /* compenseert border */
  border-top: 3px solid #000;
}

.card-body {
  padding: 4px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-thumb {
  width: 76px;
  height: 76px;
  image-rendering: pixelated;
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.25);
  background: #2b2b2b;
  flex-shrink: 0;
}

.card-titles {
  min-width: 0;
}

.card-title {
  font-size: 22px;
  font-weight: 700;
  text-shadow: var(--text-shadow);
}

.card-tag {
  font-size: 13px;
  color: var(--gold);
  text-shadow: var(--text-shadow);
}

.card-desc {
  font-size: 15px;
  color: #ecd9c8;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
  min-height: 3.2em;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.card-best {
  font-size: 14px;
  color: var(--diamond);
  text-shadow: var(--text-shadow);
}

.card-best small {
  color: #c7b5a4;
  margin-right: 4px;
}

/* ---------- Info-sectie ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin-top: 40px;
}

.info-card {
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.14);
  padding: 26px 22px;
  text-align: center;
}

.info-icon {
  font-size: 34px;
  display: block;
  margin-bottom: 12px;
}

.info-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
  text-shadow: var(--text-shadow);
}

.info-card p {
  font-size: 15px;
  color: #c4ccda;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 40px 24px 52px;
  font-size: 15px;
  color: #8f99ac;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
  border-top: 3px solid rgba(255, 255, 255, 0.08);
}

/* ---------- Game-overlay ---------- */
.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(5, 7, 14, 0.82);
  backdrop-filter: blur(4px);
}

.game-shell {
  width: min(94vw, 560px);
  background: var(--panel);
  border: 3px solid #000;
  box-shadow:
    inset 3px 3px 0 var(--panel-light),
    inset -3px -3px 0 var(--panel-dark),
    var(--shadow-hard);
  padding: 10px;
}

.game-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 6px 10px;
}

.game-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  margin-right: auto;
}

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

.hud-item {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
  background: #9c9c9c;
  border: 2px solid #000;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.45),
    inset -2px -2px 0 rgba(0, 0, 0, 0.35);
  padding: 3px 10px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums;
}

.game-stage {
  position: relative;
  background: var(--bedrock);
  border: 3px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.18);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  image-rendering: pixelated;
  touch-action: none;
}

/* Start- en gameoverschermen */
.start-screen,
.gameover-screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px;
  background: rgba(8, 10, 18, 0.86);
}

.start-screen canvas {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  margin-bottom: 6px;
}

.start-screen h3,
.gameover-screen h3 {
  font-size: 30px;
  font-weight: 700;
  text-shadow: var(--text-shadow);
}

.start-desc {
  font-size: 16px;
  color: #ccd5e3;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
  max-width: 40ch;
}

.start-controls {
  font-size: 14px;
  color: var(--gold);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}

.over-score {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: var(--text-shadow);
}

.over-best {
  font-size: 15px;
  color: var(--diamond);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}

.over-xp {
  font-size: 16px;
  color: var(--xp-green);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}

.over-buttons {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

/* D-pad voor touch */
.dpad {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 46px);
  gap: 4px;
  opacity: 0.85;
}

.dp {
  font-size: 20px;
  color: #fff;
  text-shadow: var(--text-shadow);
  background: var(--btn);
  border: 2px solid #000;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.42),
    inset -2px -3px 0 rgba(0, 0, 0, 0.42);
}

.dp:active {
  background: var(--btn-hover);
}

.dp.up { grid-area: 1 / 2; }
.dp.left { grid-area: 2 / 1; }
.dp.right { grid-area: 2 / 3; }
.dp.down { grid-area: 3 / 2; }

/* Links/rechts knoppen in de hoeken */
.lrpad {
  position: absolute;
  inset: auto 10px 12px 10px;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.lrpad .dp {
  width: 64px;
  height: 64px;
  font-size: 26px;
  pointer-events: auto;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 20px);
  z-index: 200;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-shadow: var(--text-shadow);
  background: var(--grass-dark);
  border: 2px solid #000;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.3),
    var(--shadow-hard);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Responsief ---------- */
@media (max-width: 720px) {
  .main-nav {
    display: none;
  }

  .site-header {
    gap: 12px;
    padding: 8px 14px;
  }

  .xp-label {
    display: none;
  }

  .hero-block {
    width: 40px;
    height: 40px;
  }

  .hero-sub {
    font-size: 17px;
  }

  .game-shell {
    width: 100vw;
    height: 100dvh;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }

  .game-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #gameCanvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
  }

  .dpad {
    bottom: 10px;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
  }
}

@media (max-width: 420px) {
  body {
    font-size: 16px;
  }

  .card-thumb {
    width: 60px;
    height: 60px;
  }
}

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