:root {
  --ink: #3b2417;
  --wood: #b5713b;
  --wood-dark: #7b4a25;
  --wood-light: #e3a35c;
  --paper: #fbe6b8;
  --paper-shade: #f0cd8b;
  --grass: #79b955;
  --grass-dark: #5d9c43;
  --soil: #8b5a35;
  --soil-dark: #6a4126;
  --sky-top: #7fc8ec;
  --sky-bottom: #c5ecf5;
  --focus: #ffe066;
  --px: 4px;
  color-scheme: light;
}

:root[data-time="night"] {
  --grass: #3f7a4a;
  --grass-dark: #326440;
  --sky-top: #141b3d;
  --sky-bottom: #3a3f78;
}

* { -webkit-box-sizing: border-box; box-sizing: border-box; }

html { background: var(--grass); overflow-x: clip; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Pixelify Sans", ui-monospace, monospace;
  /* Pixelify's "fi" ligature reads as "A" (fiveago → Aveago). */
  -webkit-font-variant-ligatures: none;
          font-variant-ligatures: none;
  color: var(--ink);
  background-color: var(--grass);
  /* Pixel grass tufts, tiled. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' shape-rendering='crispEdges'%3E%3Cg fill='%23000' fill-opacity='.12'%3E%3Cpath d='M4 6h1v2H4zM6 5h1v3H6zM8 6h1v2H8zM20 20h1v2h-1zM22 19h1v3h-1zM24 20h1v2h-1zM13 26h1v2h-1zM15 25h1v3h-1z'/%3E%3C/g%3E%3Cg fill='%23fff' fill-opacity='.10'%3E%3Cpath d='M26 4h2v1h-2zM2 18h2v1H2zM16 12h1v1h-1z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 64px 64px;
  -ms-interpolation-mode: nearest-neighbor;
      image-rendering: -webkit-optimize-contrast;
      image-rendering: pixelated;
  position: relative;
  overflow-x: hidden;
  -webkit-transition: background-color .6s;
  transition: background-color .6s;
}

a { color: inherit; }

button { font: inherit; cursor: pointer; }

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

svg[shape-rendering] { display: block; -ms-interpolation-mode: nearest-neighbor; image-rendering: -webkit-optimize-contrast; image-rendering: pixelated; }

.mono { letter-spacing: .04em; }

/* ---------- Sky ---------- */

.sky {
  position: absolute;
  inset: 0 0 auto;
  height: 360px;
  background: -webkit-gradient(linear, left top, left bottom, from(var(--sky-top)), to(var(--sky-bottom)));
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
  overflow: hidden;
  z-index: 0;
}

/* Stepped hill edge where the sky meets the grass. */
.sky::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 24px;
  background: var(--grass);
  clip-path: polygon(0 50%, 8% 50%, 8% 25%, 20% 25%, 20% 0, 34% 0, 34% 33%, 52% 33%, 52% 17%, 70% 17%, 70% 0, 84% 0, 84% 33%, 100% 33%, 100% 100%, 0 100%);
  -webkit-transition: background-color .6s;
  transition: background-color .6s;
}

.sun {
  position: absolute;
  top: 40px;
  left: 10%;
  width: 56px;
  height: 56px;
  background: #ffe27a;
  -webkit-box-shadow: 0 0 0 var(--px) #ffd04a, 0 0 0 calc(var(--px) * 3) #ffe27a55;
          box-shadow: 0 0 0 var(--px) #ffd04a, 0 0 0 calc(var(--px) * 3) #ffe27a55;
  clip-path: polygon(25% 0, 75% 0, 75% 12%, 88% 12%, 88% 25%, 100% 25%, 100% 75%, 88% 75%, 88% 88%, 75% 88%, 75% 100%, 25% 100%, 25% 88%, 12% 88%, 12% 75%, 0 75%, 0 25%, 12% 25%, 12% 12%, 25% 12%);
}

:root[data-time="night"] .sun {
  background: #f1efe0;
  -webkit-box-shadow: inset -14px -6px 0 #c9c6b4;
          box-shadow: inset -14px -6px 0 #c9c6b4;
}

.cloud {
  position: absolute;
  width: 96px;
  height: 24px;
  background: #fff;
  opacity: .9;
  -webkit-animation: drift 70s linear infinite;
          animation: drift 70s linear infinite;
}

.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: #fff;
}

.cloud::before { width: 48px; height: 16px; left: 16px; top: -12px; }
.cloud::after { width: 28px; height: 12px; left: 52px; top: -20px; }

.cloud-1 { top: 70px; left: -10%; }
.cloud-2 { top: 140px; left: -10%; -webkit-animation-duration: 95s; animation-duration: 95s; -webkit-animation-delay: -40s; animation-delay: -40s; -webkit-transform: scale(.7); transform: scale(.7); }
.cloud-3 { top: 40px; left: -10%; -webkit-animation-duration: 120s; animation-duration: 120s; -webkit-animation-delay: -85s; animation-delay: -85s; }

:root[data-time="night"] .cloud { opacity: .18; }

@-webkit-keyframes drift { to { left: 110%; } }

@keyframes drift { to { left: 110%; } }

.stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image:
    radial-gradient(#fff 1px, transparent 1.5px),
    radial-gradient(#fff 1px, transparent 1.5px);
  background-size: 90px 70px, 130px 110px;
  background-position: 10px 20px, 60px 45px;
  -webkit-transition: opacity .6s;
  transition: opacity .6s;
}

:root[data-time="night"] .stars { opacity: .7; }

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

.header {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.language-switch {
  align-self: flex-end;
  display: flex;
  gap: 8px;
}

.language-switch button {
  min-width: 44px;
  min-height: 36px;
  padding: 4px 8px;
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  -webkit-box-shadow: inset 0 -3px 0 var(--paper-shade);
          box-shadow: inset 0 -3px 0 var(--paper-shade);
}

.language-switch button[aria-pressed="true"] {
  background: var(--wood);
  color: #fff7e4;
  -webkit-box-shadow: inset 0 -3px 0 var(--wood-dark);
          box-shadow: inset 0 -3px 0 var(--wood-dark);
}

/* Wooden sign hanging from two ropes. */
.title-board {
  position: relative;
  margin-top: 36px;
  max-width: 640px;
  padding: 20px 28px 22px;
  text-align: center;
  background:
    repeating-linear-gradient(180deg, transparent 0 22px, #0000001a 22px 25px),
    var(--wood);
  border: var(--px) solid var(--ink);
  -webkit-box-shadow: inset 0 0 0 var(--px) var(--wood-light), inset 0 0 0 calc(var(--px) * 2) var(--wood-dark), 0 var(--px) 0 #0000002e;
          box-shadow: inset 0 0 0 var(--px) var(--wood-light), inset 0 0 0 calc(var(--px) * 2) var(--wood-dark), 0 var(--px) 0 #0000002e;
  color: #fff7e4;
}

.rope {
  position: absolute;
  top: -40px;
  width: var(--px);
  height: 40px;
  background: var(--ink);
}

.rope-left { left: 18%; }
.rope-right { right: 18%; }

.title-board h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 700;
  line-height: 1;
  text-shadow: 3px 3px 0 var(--wood-dark);
}

.title-board p {
  margin: 12px 0 0;
  font-size: clamp(17px, 2.4vw, 20px);
  line-height: 1.3;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin: 28px 0 0;
  padding: 8px 16px;
  list-style: none;
  background: var(--paper);
  border: 3px solid var(--ink);
  -webkit-box-shadow: 0 var(--px) 0 #0000002e;
          box-shadow: 0 var(--px) 0 #0000002e;
  font-size: 16px;
}

.legend li { display: flex; align-items: center; gap: 8px; }

.legend-sprite { width: 32px; height: 32px; }

/* ---------- Field ---------- */

.field {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 16px 16px;
}

.plots {
  display: -ms-grid;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 32px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plots + .plots { margin-top: 32px; }

.plots > li { display: flex; }

.plot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  -webkit-transition: -webkit-transform .15s steps(3);
  transition: -webkit-transform .15s steps(3);
  transition: transform .15s steps(3);
  transition: transform .15s steps(3), -webkit-transform .15s steps(3);
}

.plot:hover, .plot:focus-visible { -webkit-transform: translateY(calc(var(--px) * -2)); transform: translateY(calc(var(--px) * -2)); }

.plot:focus-visible { outline: none; }

.plot:focus-visible .sign { outline: var(--px) solid var(--focus); outline-offset: var(--px); }

/* Tilled soil with furrows and stepped corners. */
.soil {
  position: relative;
  width: 100%;
  height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 14px;
  background:
    repeating-linear-gradient(180deg, transparent 0 14px, var(--soil-dark) 14px 18px),
    var(--soil);
  clip-path: polygon(0 8px, 8px 8px, 8px 0, calc(100% - 8px) 0, calc(100% - 8px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 8px), 0 calc(100% - 8px));
}

.soil::before {
  content: "";
  position: absolute;
  bottom: 10px;
  width: 80px;
  height: 8px;
  background: #00000033;
}

.crop {
  position: relative;
  width: 112px;
  height: 112px;
  -webkit-transform-origin: 50% 100%;
          transform-origin: 50% 100%;
}

.plot:hover .crop, .plot:focus-visible .crop { -webkit-animation: wiggle .5s steps(4) infinite alternate; animation: wiggle .5s steps(4) infinite alternate; }

@-webkit-keyframes wiggle {
  from { -webkit-transform: rotate(-4deg); transform: rotate(-4deg); }
  to { -webkit-transform: rotate(4deg); transform: rotate(4deg); }
}

@keyframes wiggle {
  from { -webkit-transform: rotate(-4deg); transform: rotate(-4deg); }
  to { -webkit-transform: rotate(4deg); transform: rotate(4deg); }
}

/* Parchment sign planted under the crop. */
.sign {
  position: relative;
  width: 100%;
  flex: 1;
  margin-top: -6px;
  padding: 14px 16px 12px;
  background: var(--paper);
  border: var(--px) solid var(--ink);
  -webkit-box-shadow: inset 0 0 0 3px var(--paper-shade), 0 var(--px) 0 #0000002e;
          box-shadow: inset 0 0 0 3px var(--paper-shade), 0 var(--px) 0 #0000002e;
  display: flex;
  flex-direction: column;
}

.sign h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.sign p {
  margin: 6px 0 12px;
  font-size: 17px;
  line-height: 1.3;
  flex: 1;
}

.sign-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 15px;
}

.stage-sprite { flex: none; width: 32px; height: 32px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.visit {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.plot:hover .visit { color: #a3361f; }

.crow {
  position: absolute;
  right: 12px;
  top: -40px;
  width: 44px;
  height: 44px;
  -webkit-transform: scaleX(-1);
          transform: scaleX(-1);
}

.plot:hover .crow { -webkit-animation: hop .4s steps(2) 2; animation: hop .4s steps(2) 2; }

@-webkit-keyframes hop {
  50% { translate: 0 -10px; }
}

@keyframes hop {
  50% { translate: 0 -10px; }
}

.plant-hint {
  margin: 32px 0 0;
  text-align: center;
  font-size: 16px;
  color: #fff7e4;
  text-shadow: 2px 2px 0 #00000055;
}

/* Flowers planted by clicking the grass, and harvest sparkles. */
.flower {
  position: absolute;
  z-index: 0;
  width: 36px;
  height: 36px;
  margin: -32px 0 0 -16px;
  pointer-events: none;
  -webkit-animation: sprout .35s steps(4);
          animation: sprout .35s steps(4);
  -webkit-transform-origin: 50% 100%;
          transform-origin: 50% 100%;
}

@-webkit-keyframes sprout {
  from { -webkit-transform: scale(0); transform: scale(0); }
}

@keyframes sprout {
  from { -webkit-transform: scale(0); transform: scale(0); }
}

.sparkle {
  position: fixed;
  z-index: 10;
  width: 8px;
  height: 8px;
  background: #fff6b0;
  -webkit-box-shadow: 0 0 0 2px #f5cf55;
          box-shadow: 0 0 0 2px #f5cf55;
  pointer-events: none;
  -webkit-animation: burst .55s steps(5) forwards;
          animation: burst .55s steps(5) forwards;
}

@-webkit-keyframes burst {
  to { -webkit-transform: translate(var(--dx), var(--dy)); transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

@keyframes burst {
  to { -webkit-transform: translate(var(--dx), var(--dy)); transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

/* ---------- Fence footer ---------- */

.fence {
  position: relative;
  z-index: 1;
  margin-top: 40px;
  padding: 56px 16px 32px;
  text-align: center;
  /* Pickets + two rails. */
  background:
    -webkit-gradient(linear, left top, left bottom, from(var(--wood-dark)), to(var(--wood-dark))) 0 18px / 100% 6px no-repeat,
    -webkit-gradient(linear, left top, left bottom, from(var(--wood-dark)), to(var(--wood-dark))) 0 36px / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, var(--wood) 0 20px, transparent 20px 32px) 0 0 / 100% 48px no-repeat,
    var(--grass-dark);
  background:
    linear-gradient(var(--wood-dark), var(--wood-dark)) 0 18px / 100% 6px no-repeat,
    linear-gradient(var(--wood-dark), var(--wood-dark)) 0 36px / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, var(--wood) 0 20px, transparent 20px 32px) 0 0 / 100% 48px no-repeat,
    var(--grass-dark);
  -webkit-transition: background-color .6s;
  transition: background-color .6s;
}

.fence h2 {
  margin: 0 0 16px;
  font-size: 24px;
  color: #fff7e4;
  text-shadow: 2px 2px 0 #00000055;
}

.paths {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.path {
  padding: 10px 18px;
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
  background: var(--paper);
  border: 3px solid var(--ink);
  -webkit-box-shadow: inset 0 -4px 0 var(--paper-shade), 0 var(--px) 0 #0000002e;
          box-shadow: inset 0 -4px 0 var(--paper-shade), 0 var(--px) 0 #0000002e;
  -webkit-transition: -webkit-transform .15s steps(3);
  transition: -webkit-transform .15s steps(3);
  transition: transform .15s steps(3);
  transition: transform .15s steps(3), -webkit-transform .15s steps(3);
}

.path:hover { -webkit-transform: translateY(-4px); transform: translateY(-4px); }

.credits {
  margin: 24px 0 0;
  font-size: 15px;
  color: #fff7e4;
}

.credits a { text-underline-offset: 3px; }

/* ---------- Critters ---------- */

/* Laid over the whole page (body is position: relative), so critters scroll with the field. */
.critters {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.butterfly {
  position: absolute;
  width: 27px;
  height: 15px;
  -webkit-animation: flutter .3s steps(2) infinite alternate, wander-a 26s ease-in-out infinite;
          animation: flutter .3s steps(2) infinite alternate, wander-a 26s ease-in-out infinite;
}

.butterfly-2 { -webkit-animation: flutter .26s steps(2) infinite alternate, wander-b 34s ease-in-out infinite; animation: flutter .26s steps(2) infinite alternate, wander-b 34s ease-in-out infinite; }

@-webkit-keyframes flutter { to { scale: .55 1; } }

@keyframes flutter { to { scale: .55 1; } }

@-webkit-keyframes wander-a {
  0%, 100% { top: 30%; left: 4%; }
  25% { top: 18%; left: 30%; }
  50% { top: 45%; left: 52%; }
  75% { top: 25%; left: 22%; }
}

@keyframes wander-a {
  0%, 100% { top: 30%; left: 4%; }
  25% { top: 18%; left: 30%; }
  50% { top: 45%; left: 52%; }
  75% { top: 25%; left: 22%; }
}

@-webkit-keyframes wander-b {
  0%, 100% { top: 70%; left: 92%; }
  30% { top: 55%; left: 70%; }
  60% { top: 80%; left: 84%; }
  80% { top: 40%; left: 95%; }
}

@keyframes wander-b {
  0%, 100% { top: 70%; left: 92%; }
  30% { top: 55%; left: 70%; }
  60% { top: 80%; left: 84%; }
  80% { top: 40%; left: 95%; }
}

.firefly {
  position: absolute;
  display: none;
  width: 6px;
  height: 6px;
  background: #f6ff9e;
  -webkit-box-shadow: 0 0 8px 3px #e8ff6a88;
          box-shadow: 0 0 8px 3px #e8ff6a88;
  -webkit-animation: glow 2.4s ease-in-out infinite alternate, wander-a 30s ease-in-out infinite;
          animation: glow 2.4s ease-in-out infinite alternate, wander-a 30s ease-in-out infinite;
}

.firefly-2 { -webkit-animation-delay: -1s, -8s; animation-delay: -1s, -8s; -webkit-animation-duration: 2s, 38s; animation-duration: 2s, 38s; -webkit-animation-name: glow, wander-b; animation-name: glow, wander-b; }
.firefly-3 { -webkit-animation-delay: -.5s, -15s; animation-delay: -.5s, -15s; -webkit-animation-duration: 2.8s, 44s; animation-duration: 2.8s, 44s; }
.firefly-4 { -webkit-animation-delay: -1.6s, -22s; animation-delay: -1.6s, -22s; -webkit-animation-duration: 2.2s, 33s; animation-duration: 2.2s, 33s; -webkit-animation-name: glow, wander-b; animation-name: glow, wander-b; }

@-webkit-keyframes glow { from { opacity: .15; } }

@keyframes glow { from { opacity: .15; } }

:root[data-time="night"] .butterfly { display: none; }
:root[data-time="night"] .firefly { display: block; }

/* ---------- Small screens & motion ---------- */

@media (max-width: 560px) {
  .title-board { padding: 16px 18px 18px; }
  .rope { top: -32px; height: 32px; }
  .title-board { margin-top: 28px; }
  .plots { -ms-grid-columns: 1fr; grid-template-columns: 1fr; gap: 24px; }
  .soil { height: 128px; }
  .crop { width: 96px; height: 96px; }
}

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

/* Names with a bold part (name_html in data/projects.yml): the rest is set lighter. */
.sign h2 > span:has(strong) { font-weight: 400; }
.sign h2 strong { font-weight: 700; }
/* fiveago: "five" bold, "ago" regular. */
.sign h2 > span:has(em) { font-weight: 400; }
.sign h2 em { font-style: normal; font-weight: 700; }
