/* Monocraft, by Idrees Hassan, under the SIL Open Font License 1.1
   (public/licenses/Monocraft-OFL.txt, served beside the site). Subset to Latin, with its programming ligatures
   left out so that "->" in ordinary text stays two characters. */
@font-face {
  font-family: "Monocraft";
  src: url("./fonts/monocraft.woff2") format("woff2");
  font-display: swap;
}

/* One palette, light text on dark earth, like Minecraft's own menus. */
:root {
  --bg-deep: #1e150f;
  /* The earth of the panels, letting the backdrop through. */
  --panel: color-mix(in srgb, #3a2b20 78%, transparent);
  --panel-edge: #57432f;
  --veil: color-mix(in srgb, var(--bg-deep) 84%, transparent);
  --ink: #f2ead8;
  --muted: #c9bba0;
  --gold: #ffff55;
  --gold-shadow: #3f3f15;
  --accent: #6db3a5;
  --accent-deep: #24332e;
  --badge: #38705f;
  --outline: #1a1a1a;
  --error: #ff8a80;
  --focus: #ffff55;
  /* The stone menu button, dark enough that white text on it passes WCAG AA,
     and the blue-grey Minecraft lights it with under the pointer. */
  --button: #6b6b6b;
  --button-light: #9a9a9a;
  --button-dark: #474747;
  --button-hover: #5a5f96;
  --button-hover-light: #8a8fc4;
  --button-hover-dark: #3d4170;
  --button-ink: #ffffff;
  --button-ink-shadow: #3f3f3f;
  --tile: color-mix(in srgb, #1f1712 62%, transparent);
  --tile-hover: color-mix(in srgb, #2b2018 78%, transparent);
  --frost: blur(4px);
  --tile-light: #4a3a2c;
  --input: #000000;
  --input-edge: #a0a0a0;
  --pixel: "Monocraft", ui-monospace, monospace;
  --body: "Karla Variable", system-ui, sans-serif;
  color-scheme: dark;
}

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

body {
  margin: 0;
  background-color: var(--bg-deep);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.6;
}

/* The gazebo, held still behind every page. A fixed layer rather than a fixed
   background, which iOS Safari ignores, and as tall as the screen with its
   toolbars collapsed, so the picture doesn't rescale as they collapse on
   scroll. Anchored left of centre so the gazebo stays in view as the screen
   narrows. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 100lvh;
  z-index: -1;
  background: var(--sky-webp) 12% 40% / cover no-repeat;
}

/* AVIF, whose 10-bit gradients don't band, wherever the browser decodes it;
   the WebP for the rest, chiefly iPads too old to leave iOS 15. A browser
   without image-set()'s type() would drop the whole picture, so it keeps the
   WebP above. */
@supports (background-image: image-set("" type("image/avif"))) {
  body::before {
    background-image: image-set(
      var(--sky-avif) type("image/avif"),
      var(--sky-webp) type("image/webp")
    );
  }
}

/* The sky by the visitor's own clock, as mark-sky.mjs's script marks it before
   the first paint; the dawn wherever it doesn't. Only the picture of the sky
   that applies is fetched. */
:root {
  --sky-avif: url("./gazebo-dawn.avif");
  --sky-webp: url("./gazebo-dawn.webp");
}

[data-sky="night"] {
  --sky-avif: url("./gazebo-night.avif");
  --sky-webp: url("./gazebo-night.webp");
}

[data-sky="predawn"] {
  --sky-avif: url("./gazebo-predawn.avif");
  --sky-webp: url("./gazebo-predawn.webp");
}

[data-sky="sunrise"] {
  --sky-avif: url("./gazebo-sunrise.avif");
  --sky-webp: url("./gazebo-sunrise.webp");
}

[data-sky="dawn"] {
  --sky-avif: url("./gazebo-dawn.avif");
  --sky-webp: url("./gazebo-dawn.webp");
}

[data-sky="day"] {
  --sky-avif: url("./gazebo-day.avif");
  --sky-webp: url("./gazebo-day.webp");
}

[data-sky="evening"] {
  --sky-avif: url("./gazebo-evening.avif");
  --sky-webp: url("./gazebo-evening.webp");
}

/* Running text sits on a panel, never on the backdrop itself. */
.intro,
.page {
  background: var(--veil);
  -webkit-backdrop-filter: var(--frost);
  backdrop-filter: var(--frost);
  border: 2px solid #000000;
  box-shadow:
    inset 0 2px 0 var(--panel-edge),
    0 4px 0 #000000;
}

h1,
h2,
h3,
legend,
.tagline {
  font-family: var(--pixel);
  font-weight: normal;
  line-height: 1.25;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  margin: 0 0 0.6em;
}

h2 {
  font-size: 1.35rem;
  margin: 0 0 0.6em;
}

a {
  color: var(--accent);
}

code {
  font-family: var(--pixel);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

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

/* Skip link: out of sight until a keyboard reaches it. */
.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 10;
  background: var(--gold);
  color: #000000;
  padding: 8px 12px;
  font-family: var(--pixel);
}

.skip-link:focus {
  top: 8px;
}

/* The navigation bar: dark tiles either side of the logo, and the page you
   are on in gold. */
.site-nav {
  padding: 18px 16px 8px;
}

/* Three columns, the outer two equal, so the logo sits at the exact centre.
   Sized to its content, the bar makes both outer columns as wide as the wider
   side's links, and the narrower side's tiles stretch to fill theirs, so the
   row of tiles is as balanced as the logo. That holds only while the window
   fits the whole bar: below the phone breakpoint's width the columns squeeze
   unevenly, so longer labels need that breakpoint raised to match. */
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.nav-links {
  display: flex;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links > li {
  flex: auto;
}

.nav-item {
  display: block;
  font-family: var(--pixel);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  background: var(--tile);
  -webkit-backdrop-filter: var(--frost);
  backdrop-filter: var(--frost);
  border: 2px solid #000000;
  box-shadow:
    inset 0 2px 0 var(--tile-light),
    0 4px 0 #000000;
  padding: 10px 16px;
  white-space: nowrap;
  text-align: center;
}

.nav-item:hover {
  color: var(--gold);
  background: var(--tile-hover);
}

.nav-item:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 0 var(--tile-light),
    0 2px 0 #000000;
}

.nav-item[aria-current="page"] {
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--gold-shadow);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.nav-logo {
  display: block;
  flex: none;
}

.nav-logo-art {
  display: block;
  height: 64px;
  width: auto;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35));
}

.nav-toggle {
  display: none;
  background: var(--tile);
  -webkit-backdrop-filter: var(--frost);
  backdrop-filter: var(--frost);
  border: 2px solid #000000;
  box-shadow:
    inset 0 2px 0 var(--tile-light),
    0 4px 0 #000000;
  width: 48px;
  height: 44px;
  padding: 0;
  cursor: pointer;
}

/* Three bars, drawn as one bar and its two shadows. */
.nav-toggle-bars {
  display: block;
  width: 22px;
  height: 3px;
  margin: 0 auto;
  background: var(--ink);
  box-shadow:
    0 -7px 0 var(--ink),
    0 7px 0 var(--ink);
}

/* A phone: the menu button and the logo on one row, the logo centred by an
   empty third column as wide as the button, and the links beneath, shown once
   the button opens them. */
@media (max-width: 1190px) {
  .nav {
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    gap: 12px;
    width: auto;
  }

  .js .nav-toggle {
    display: block;
  }

  .nav-logo {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
  }

  .nav-logo-art {
    height: 48px;
  }

  .nav-links {
    grid-column: 1 / -1;
    flex-direction: column;
  }

  .js .nav-links {
    display: none;
  }

  .js .nav-open .nav-links {
    display: flex;
  }
}

.lede {
  font-size: 1.15rem;
  color: var(--muted);
}

/* An inner page: one readable column, on a panel. */
.page {
  width: min(760px, 100% - 32px);
  margin: 24px auto 48px;
  padding: 28px 24px 36px;
}

.page h2 {
  margin-top: 1.6em;
}

/* A note a visitor must not miss: gold, edged like a Minecraft panel. */
.warning {
  background: var(--panel);
  border: 2px solid var(--gold);
  box-shadow: 0 4px 0 #000000;
  padding: 12px 16px;
}

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

/* The Play page's server addresses, each with a copy button. */
.addresses {
  display: grid;
  gap: 12px;
  margin: 24px 0;
}

.address {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 16px;
  background: var(--panel);
  border: 2px solid #000000;
  box-shadow:
    inset 0 2px 0 var(--panel-edge),
    0 4px 0 #000000;
  padding: 14px 16px;
}

.address-label {
  grid-column: 1;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.address-value {
  grid-column: 1;
  margin: 0;
  font-size: clamp(1rem, 4.5vw, 1.3rem);
}

/* An address broken across lines invites typing it with a space. The pixel
   font is hard to read letter by letter, which an address is read. */
.address-value code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  white-space: nowrap;
}

/* Too long to keep on one line on a phone; it is copied, not typed. */
.address-long {
  font-size: 0.9rem;
}

.address-long code {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* The Schedule page: ways to add it, then the sessions coming up. */
.subscribe {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0 16px;
}

/* Shown only when the copy button couldn't reach the clipboard. */
.subscribe .address-value {
  flex-basis: 100%;
}

/* The upcoming sessions: a date tile, then the time and what it is. */
.sessions ol {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.session {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 2px solid #000000;
  box-shadow:
    inset 0 2px 0 var(--panel-edge),
    0 4px 0 #000000;
  padding: 10px 16px 10px 10px;
  margin-bottom: 12px;
}

.session-underway {
  border-color: var(--gold);
}

.session-date {
  display: grid;
  justify-items: center;
  flex: none;
  width: 64px;
  padding: 4px 0 6px;
  background: var(--badge);
  border: 2px solid var(--outline);
  color: var(--button-ink);
  font-family: var(--pixel);
  line-height: 1.15;
  text-shadow: 1px 1px 0 var(--outline);
}

.session-weekday,
.session-month {
  font-size: 0.75rem;
  text-transform: uppercase;
}

.session-day {
  font-size: 1.5rem;
}

.session-what {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 16px;
}

.session-time {
  font-family: var(--pixel);
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--gold-shadow);
}

.session-title {
  color: var(--muted);
}

.session-description {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.session-description > :first-child {
  margin-top: 0;
}

.session-description > :last-child {
  margin-bottom: 0;
}

.session-description-text {
  white-space: pre-line;
}

.session-description a {
  color: var(--accent);
}

.session-badge {
  font-family: var(--pixel);
  font-size: 0.8rem;
  padding: 0 6px;
  background: var(--gold);
  color: var(--bg-deep);
}

.sessions-note {
  color: var(--muted);
}

.sessions-note a {
  color: var(--gold);
}

.copy {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-width: 96px;
}

/* The home page: the logo, centred, with everything stacked beneath it. */

.home {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 16px 40px;
  text-align: center;
  /* So the creeper's explosion never widens the page. */
  overflow-x: clip;
}

.logo {
  position: relative;
  margin: 0 auto 28px;
  max-width: 640px;
}

.logo-art {
  display: block;
  width: 100%;
  height: auto;
}

.logo-art,
.logo-blocks {
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.35));
}

/* Only the letters themselves take a click; anywhere else reaches the <img>. */
.logo-targets {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.logo-targets path {
  fill: transparent;
  pointer-events: fill;
}

/* The logo redrawn as its blocks, and the scenes behind and in front of its
   letters that the creeper its M lets out walks through (creeper.js). */
.logo-built .logo-art {
  visibility: hidden;
}

.creeper-scene,
.logo-blocks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.creeper-scene,
.creeper,
.creeper-part {
  transform-style: preserve-3d;
}

.logo-piece,
.creeper,
.creeper-part,
.creeper-face,
.explosion-particle {
  position: absolute;
  left: 0;
  top: 0;
}

.logo-face {
  background-image: url("/logo.svg");
  background-repeat: no-repeat;
}

.creeper-face {
  transform-origin: 0 0;
  backface-visibility: hidden;
  background-image: url("/minecraft/creeper.png");
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

/* The face's lighting, then the fuse's white over it, in the game's order. */
.creeper-face::before,
.creeper-face::after {
  content: "";
  position: absolute;
  inset: 0;
}

.creeper-face::before {
  background: #000000;
  opacity: var(--shade, 0);
}

.creeper-face::after {
  background: #ffffff;
  opacity: var(--white, 0);
}

.explosion-particle {
  background-size: 100% 100%;
  image-rendering: pixelated;
}

/* The yellow line that sits tilted on the corner of every Minecraft title. */
.splash {
  position: absolute;
  right: -1%;
  top: 62%;
  font-family: var(--pixel);
  font-size: clamp(0.85rem, 2.6vw, 1.3rem);
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--gold-shadow);
  transform: rotate(-18deg);
  white-space: nowrap;
  animation: splash 0.9s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes splash {
  from {
    transform: rotate(-18deg) scale(1);
  }
  to {
    transform: rotate(-18deg) scale(1.08);
  }
}

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

.tagline {
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--gold-shadow);
  text-wrap: balance;
  margin: 0 0 20px;
}

.intro {
  font-size: 1.15rem;
  color: var(--ink);
  max-width: 36em;
  margin: 0 auto 32px;
  padding: 16px 20px;
}

/* A Minecraft menu button: grey stone, a light top edge, a dark bottom one,
   white pixel text with a drop shadow, and a black border. */
.mc-button {
  display: inline-block;
  font-family: var(--pixel);
  font-size: 1.05rem;
  color: var(--button-ink);
  text-shadow: 2px 2px 0 var(--button-ink-shadow);
  text-decoration: none;
  background: var(--button);
  border: 3px solid var(--input);
  box-shadow:
    inset 3px 3px 0 var(--button-light),
    inset -3px -4px 0 var(--button-dark);
  padding: 14px 28px 16px;
  cursor: pointer;
  image-rendering: pixelated;
}

.mc-button:hover {
  background: var(--button-hover);
  box-shadow:
    inset 3px 3px 0 var(--button-hover-light),
    inset -3px -4px 0 var(--button-hover-dark);
}

.mc-button:active {
  box-shadow:
    inset 3px 4px 0 var(--button-dark),
    inset -3px -3px 0 var(--button-light);
}

.mc-button-small {
  font-size: 0.9rem;
  padding: 8px 14px 10px;
}

.mc-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.link-button {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0.4em 0;
  text-decoration: underline;
  cursor: pointer;
}

.rules {
  counter-reset: rule;
  margin: 16px 0 0;
}

.rules h2 {
  margin: 28px 0 12px;
}

.rules h2:first-child {
  margin-top: 0;
}

.rules ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rules li {
  counter-increment: rule;
  position: relative;
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  padding: 12px 16px 12px 58px;
  margin-bottom: 10px;
}

.rules li::before {
  content: counter(rule);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--badge);
  border: 2px solid var(--outline);
  color: var(--button-ink);
  font-family: var(--pixel);
  text-shadow: 1px 1px 0 var(--outline);
}

/* The request form, as panels like Minecraft's settings screens. */

.site-form fieldset {
  border: 2px solid var(--panel-edge);
  background: var(--panel);
  padding: 20px;
  margin: 0 0 20px;
  min-width: 0;
}

.site-form legend {
  font-size: 1.05rem;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--gold-shadow);
  padding: 0 6px;
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0.25em 0 0.75em;
}

.choices {
  display: grid;
  gap: 10px;
}

.choices-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 2px solid var(--panel-edge);
  padding: 12px 14px;
  cursor: pointer;
  background: var(--bg-deep);
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-deep);
}

.choice input {
  margin-top: 0.3em;
  accent-color: var(--accent);
  width: 1.1em;
  height: 1.1em;
  flex: none;
}

.choice span {
  display: flex;
  flex-direction: column;
}

.choice strong {
  font-family: var(--pixel);
  font-weight: normal;
}

.choice small {
  color: var(--muted);
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-family: var(--pixel);
}

/* Text inputs like Minecraft's: black, with a grey border. */
.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--ink);
  background: var(--input);
  border: 2px solid var(--input-edge);
  padding: 0.6em 0.75em;
  width: 100%;
  min-height: 44px;
}

.field textarea {
  resize: vertical;
}

/* The browser's own caret ignores padding and sits against the border, so a
   drawn one replaces it, inset like the text. Its stroke is --ink. */
.field select {
  appearance: none;
  padding-right: 2.5em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f2ead8' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75em center;
  background-size: 0.8em auto;
}

/* Forced colours drop background images, and the drawn caret with them, so the
   browser's own caret comes back there. */
@media (forced-colors: active) {
  .field select {
    appearance: auto;
  }
}

.field .hint {
  margin: 0;
}

.error {
  color: var(--error);
  font-weight: 700;
  margin: 0.5em 0 0;
}

.privacy {
  color: var(--muted);
  font-size: 0.95rem;
}

.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.thanks {
  background: var(--panel);
  border: 2px solid var(--accent);
  padding: 24px;
}

.thanks:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

/* A section on a panel, like a rule on the Rules page: each FAQ answer, each way to join on the Play page. */
.panel-section {
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  padding: 16px 16px 4px;
  margin-bottom: 12px;
}

.panel-section h2 {
  margin: 0 0 0.6em;
}

.panel-section > p,
.panel-section > ol {
  margin: 0 0 12px;
}

.panel-section li + li {
  margin-top: 6px;
}

.panel-section .addresses {
  margin: 0 0 12px;
}
