/* =========================================================================
   UDF Tutorial Pokédex — a fan-made, Game Boy flavoured downloads page.
   Original art and shapes; no official game assets.
   ========================================================================= */
:root {
  --bg:      #f4f1e4;
  --bg-2:    #ebe6d2;
  --panel:   #fffdf5;
  --ink:     #1b1b24;
  --muted:   #555562;
  --line:    #1b1b24;
  --screen:  #cfe3b4;
  --screen-2:#b6d193;
  --red:     #d8342c;
  --red-ink: #ffffff;
  --red-text:#b3261e;
  --link:    #2e3192;
  --shadow:  #1b1b24;
  --caught:  #2f8a58;

  --pixel: "Press Start 2P", ui-monospace, monospace;
  --sans:  "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --pad:   clamp(16px, 4vw, 48px);
}

:root[data-theme="dark"] {
  --bg:      #0e0f14;
  --bg-2:    #15171e;
  --panel:   #1b1d26;
  --ink:     #f1f1f1;
  --muted:   #a9abb6;
  --line:    #3b3e4d;
  --screen:  #2d3b2a;
  --screen-2:#3a4c35;
  --red:     #c9302a;
  --red-text:#ff7a70;
  --link:    #9ea6ff;
  --shadow:  #000000;
  --caught:  #6fd39a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #0e0f14;
    --bg-2:    #15171e;
    --panel:   #1b1d26;
    --ink:     #f1f1f1;
    --muted:   #a9abb6;
    --line:    #3b3e4d;
    --screen:  #2d3b2a;
    --screen-2:#3a4c35;
    --red:     #c9302a;
  --red-text:#ff7a70;
    --link:    #9ea6ff;
    --shadow:  #000000;
    --caught:  #6fd39a;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 0) 0 0 / 14px 14px,
    var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }

.skip-link {
  position: absolute; left: -999px; top: 8px;
  background: var(--red); color: var(--red-ink); padding: 8px 12px; z-index: 10;
}
.skip-link:focus { left: 8px; }

/* ---- Top bar: the red Pokédex lid ------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 12px var(--pad);
  background: var(--red);
  color: var(--red-ink);
  border-bottom: 4px solid var(--shadow);
}
.topbar__back {
  color: var(--red-ink); text-decoration: none;
  font: 500 15px/1 var(--mono);
}
.topbar__back:hover { text-decoration: underline; }
.topbar__title {
  margin: 0 auto;
  font: 10px/1.4 var(--pixel);
  letter-spacing: 0.04em;
  text-align: center;
}
.topbar__theme {
  font: 9px/1 var(--pixel);
  color: var(--red-ink); background: transparent;
  border: 2px solid var(--red-ink); padding: 7px 9px; cursor: pointer;
}
.topbar__theme .when-light { display: none; }
:root[data-theme="light"] .topbar__theme .when-dark { display: none; }
:root[data-theme="light"] .topbar__theme .when-light { display: inline; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .topbar__theme .when-dark { display: none; }
  :root:not([data-theme="dark"]) .topbar__theme .when-light { display: inline; }
}

main { max-width: 1240px; margin: 0 auto; padding: 0 var(--pad); }

/* ---- Hero -------------------------------------------------------------- */
.hero { padding: clamp(36px, 7vw, 72px) 0 28px; }
.hero__kicker {
  margin: 0 0 18px;
  font: 10px/1.6 var(--pixel); color: var(--red-text); letter-spacing: 0.05em;
}
.hero__title {
  margin: 0 0 22px;
  font: clamp(22px, 5vw, 44px)/1.35 var(--pixel);
  text-shadow: 4px 4px 0 color-mix(in srgb, var(--red) 55%, transparent);
}
.hero__paper { max-width: 62ch; margin: 0 0 28px; color: var(--muted); font-size: 18px; }
.hero__paper cite { color: var(--ink); font-style: normal; font-weight: 600; }

/* The classic text box: double border, blinking arrow. */
.dialog {
  position: relative;
  max-width: 720px;
  min-height: 92px;
  padding: 20px 44px 20px 22px;
  background: var(--panel);
  border: 4px solid var(--line);
  box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 5px var(--line), 6px 6px 0 var(--shadow);
  cursor: pointer;
}
.dialog__text { margin: 0; font: 12px/2 var(--pixel); }
.dialog__more {
  position: absolute; right: 18px; bottom: 12px;
  font-size: 12px; color: var(--red-text);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.progress {
  display: flex; align-items: center; gap: 12px; margin-top: 22px;
  font: 10px/1 var(--pixel);
}
.progress__balls { display: inline-flex; gap: 6px; }
.progress__balls i {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg-2);
}
.progress__balls i.is-on {
  background: linear-gradient(to bottom, var(--red) 0 42%, var(--ink) 42% 58%, #fff 58%);
}
.progress__count { color: var(--muted); }

/* ---- Pokédex cards ---------------------------------------------------- */
.dex {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
  gap: 26px;
  padding: 24px 0 56px;
}

.card {
  --type: #a8a878;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 4px solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 16px 16px 18px;
  transition: transform 0.15s ease;
}
.card:hover { transform: translate(-2px, -2px); }

.card__top {
  display: flex; justify-content: space-between; align-items: baseline;
  font: 9px/1.4 var(--pixel); color: var(--muted);
  margin-bottom: 12px;
}
.card__caught { color: var(--caught); visibility: hidden; }
.card.is-caught .card__caught { visibility: visible; }

.screen {
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(to top, var(--screen-2) 0 26%, transparent 26%),
    var(--screen);
  border: 4px solid var(--line);
  border-radius: 4px 4px 4px 22px;
  overflow: hidden;
}
.screen::after {           /* the grass patch under the sprite */
  content: ""; position: absolute; left: 50%; bottom: 14%;
  width: 46%; height: 9%; transform: translateX(-50%);
  background: color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 50%;
}
.sprite {
  position: relative; z-index: 1;
  width: 58%; height: auto;
  image-rendering: pixelated;
  animation: bob 1.6s steps(2, end) infinite;
}
.card:nth-child(2) .sprite { animation-delay: -0.4s; }
.card:nth-child(3) .sprite { animation-delay: -0.8s; }
.card:nth-child(4) .sprite { animation-delay: -1.2s; }
@keyframes bob { 50% { transform: translateY(-5%); } }

.card__name { margin: 16px 0 6px; font: 14px/1.4 var(--pixel); }
.card__species { margin: 0 0 12px; color: var(--muted); font: 500 14px/1.3 var(--mono); }

.types { display: flex; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.types li {
  font: 8px/1 var(--pixel); letter-spacing: 0.04em;
  color: #1b1b24;
  background: var(--type);
  border: 2px solid var(--line);
  padding: 6px 8px;
}
.types li + li { background: #d9d5c3; }

.card__flavor { margin: 0 0 14px; font-size: 15.5px; line-height: 1.5; }

.measures {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin: auto 0 16px; padding: 10px 0 0;
  border-top: 2px dashed var(--line);
}
.measures div { min-width: 0; }
.measures dt { font: 7px/1.6 var(--pixel); color: var(--muted); }
.measures dd { margin: 2px 0 0; font: 500 14px/1.3 var(--mono); }

/* ---- The catch button ------------------------------------------------- */
.catch {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 12px 14px;
  background: var(--red); color: var(--red-ink);
  border: 3px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow);
  text-decoration: none;
  font: 11px/1 var(--pixel);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.catch:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--shadow); }
.catch:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.catch small { font: 500 13px/1 var(--mono); opacity: 0.9; }

/* Secondary button: run the notebook online. */
.run {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 10px; padding: 10px 14px;
  background: var(--panel); color: var(--ink);
  border: 3px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow);
  text-decoration: none;
  font: 10px/1 var(--pixel);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.run:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--shadow); }
.run:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.run small { font: 500 13px/1 var(--mono); color: var(--muted); }

.ball {
  position: relative; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #1b1b24;
  background: linear-gradient(to bottom, #d8342c 0 42%, #1b1b24 42% 58%, #ffffff 58%);
}
.ball::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 8px; height: 8px; transform: translate(-50%, -50%);
  border-radius: 50%; background: #fff; border: 2px solid #1b1b24;
}
.card.is-catching .ball { animation: wobble 0.9s ease-in-out 1; }
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-24deg); }
  40% { transform: rotate(18deg); }
  60% { transform: rotate(-12deg); }
  80% { transform: rotate(6deg); }
}
.card.is-catching .sprite { animation: shrink 0.9s ease-in-out 1; }
@keyframes shrink {
  45% { transform: scale(0.15); opacity: 0; filter: brightness(3); }
  70% { transform: scale(0.15); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---- Tips and footer -------------------------------------------------- */
.tips { padding: 8px 0 56px; }
.tips__title { margin: 0 0 22px; font: 16px/1.4 var(--pixel); }
.tips__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; }
.tip {
  background: var(--panel);
  border: 3px solid var(--line);
  padding: 18px 20px;
  min-width: 0;
}
.tip h3 { margin: 0 0 10px; font: 10px/1.6 var(--pixel); color: var(--red-text); }
.tip p { margin: 0 0 10px; }
.tip code { font: 500 14px/1.4 var(--mono); }
.tip pre {
  margin: 0; padding: 12px 14px; overflow-x: auto;
  background: var(--bg-2); border: 2px solid var(--line);
}
.tip pre code { font-size: 13px; }

.footer {
  border-top: 4px solid var(--line);
  padding: 22px var(--pad) 34px;
  color: var(--muted); font-size: 14px;
  text-align: center;
}
.footer p { max-width: 80ch; margin: 0 auto 8px; }

@media (max-width: 560px) {
  .topbar__title { font-size: 8px; }
  .topbar__back { font-size: 13px; }
  .dialog { padding: 16px 36px 16px 16px; }
  .dialog__text { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sprite, .dialog__more, .card.is-catching .ball, .card.is-catching .sprite { animation: none; }
  .card, .catch, .run { transition: none; }
}
