/* Shared styles for the Tiny Crops pages. Frames, buttons and the grass come straight
   from the game's sprites, drawn at 2x so every art pixel stays square. */

:root {
  --sky: #3a8cde;
  --grass: #54b033;
  --window: #3e3529;
  --pane: #2c251d;
  --ink: #120d08;
  --text: #fff4e0;
  --muted: #d9c8a9;
  --gold: #ffd598;
  --orange: #ff9d0e;
  --orange-deep: #ee6a0e;
  --green: #8bd347;
  --focus: #ffe14d;

  --display: 'Jersey 10', 'Courier New', monospace;
  --body: 'Nunito', system-ui, -apple-system, sans-serif;

  --gutter: clamp(16px, 4vw, 40px);
  --max: 1120px;
  --frame: 32px;

  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background-color: var(--grass);
  background-image: url('img/meadow.png');
  background-size: 192px 192px;
  image-rendering: pixelated;
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Only the grass and the sprite frames are pixelated; photos of the game scale smoothly. */
body > *,
.window > *,
.pane > *,
.btn > * {
  image-rendering: auto;
}

img {
  max-width: 100%;
}

.pixel {
  image-rendering: pixelated;
}

a {
  color: var(--gold);
  text-underline-offset: 3px;
}

a:hover {
  color: #fff;
}

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

.skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 10;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--text);
  font-family: var(--display);
  font-size: 22px;
}

.skip:focus {
  top: 16px;
}

/* ---------- Pixel text ---------- */

.display {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink);
}

h2 {
  font-size: clamp(40px, 7vw, 60px);
}

h3 {
  font-size: 30px;
  text-shadow: 2px 2px 0 var(--ink);
}

/* ---------- Frames ---------- */

.window,
.pane {
  /* The frame art is drawn 32px wide but may overlap the padding, so the real border
     only needs to clear the outline. */
  border: 10px solid transparent;
  /* The center is a flat color rather than the sprite's fill slice, so the seams
     between slices can't show at fractional device scales. */
  border-image: url('img/ui-window.png') 16 / var(--frame) / 0 stretch;
  background: var(--window) padding-box;
  padding: 22px;
  image-rendering: pixelated;
}

.pane {
  border-image-source: url('img/ui-pane.png');
  background-color: var(--pane);
}

@media (max-width: 600px) {
  .window,
  .pane {
    padding: 14px;
  }
}

.window-title {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: 30px;
  line-height: 1;
  color: var(--text);
  text-shadow: 2px 2px 0 var(--ink);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 68px;
  padding: 8px 26px 14px;
  border: 6px solid transparent;
  border-image: url('img/btn-orange.png') 16 / var(--frame) / 0 stretch;
  background: #ff9d0e padding-box;
  image-rendering: pixelated;
  color: #fff;
  font-family: var(--display);
  font-size: 32px;
  line-height: 1;
  text-decoration: none;
  text-shadow: 2px 2px 0 rgba(94, 12, 12, 0.85);
  white-space: nowrap;
  cursor: pointer;
  transition: transform 80ms steps(2);
}

.btn:hover {
  color: #fff;
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(2px);
}

.btn-green {
  border-image-source: url('img/btn-green.png');
  background-color: #64c825;
  text-shadow: 2px 2px 0 rgba(10, 70, 10, 0.85);
}

.btn-gray {
  border-image-source: url('img/btn-gray.png');
  background-color: #979797;
  text-shadow: 2px 2px 0 rgba(30, 30, 30, 0.7);
}

.btn[aria-disabled='true'] {
  cursor: default;
}

.btn[aria-disabled='true']:active {
  transform: none;
}

.btn small {
  display: block;
  font-size: 20px;
  opacity: 0.9;
}

/* ---------- Top bar ---------- */

.topbar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px var(--gutter);
}

.topbar a {
  font-family: var(--display);
  font-size: 26px;
  line-height: 1;
  color: #fff;
  text-decoration: none;
  text-shadow: 2px 2px 0 rgba(10, 40, 90, 0.7);
}

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

.topbar a,
.topbar nav {
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  gap: 22px;
}

@media (max-width: 360px) {
  .topbar nav a:not([href$='#support']) {
    display: none;
  }
}

@media (max-width: 420px) {
  .topbar a {
    font-size: 22px;
  }

  .topbar nav {
    gap: 14px;
  }

  /* Long labels wrap instead of pushing the button past the screen edge. */
  .btn {
    max-width: 100%;
    white-space: normal;
    text-align: center;
    font-size: 26px;
  }
}

/* ---------- Title scene ---------- */

.scene {
  position: relative;
  overflow: hidden;
  /* The sky's top color, shown until the canvas has drawn. */
  background: linear-gradient(#3a8cde, #90d2f4 70%, #54b033 70%);
}

.scene canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 400ms ease;
}

.scene canvas.is-ready {
  opacity: 1;
}

.logo {
  display: block;
  width: min(384px, 76vw);
  height: auto;
  margin: 0 auto;
  image-rendering: pixelated;
  animation: bob 3.2s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo {
    animation: none;
  }
}

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

.site-footer {
  background: var(--pane);
  border-top: 4px solid var(--ink);
  color: var(--muted);
  font-size: 15px;
}

.site-footer .inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--gutter) 36px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

.site-footer a {
  color: var(--text);
}

.site-footer a:hover {
  color: var(--gold);
}
