@font-face {
  font-family: "Stash Times Roman";
  src: url("assets/fonts/TimesRoman_19.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* World 0 is also the no-JavaScript fallback. Keep it in sync with worlds.js. */
:root {
  --ground: #ffffff;
  --ink: #2e2922;
  --accent: #0000ff;
}

/* ROLE → ELEMENT MAP: change assignments here. The library is in worlds.js. */
html { background: var(--ground); color: var(--ink); }
::selection { background: var(--accent); color: var(--ground); }
.logo { fill: var(--ink); }
.tagline-first { color: var(--ink); }
/* Both tagline lines stay in the normal text color, including during cycling. */
.tagline-second { color: var(--ink); }
.availability { color: var(--ink); }
.join { color: var(--accent); }
.logo-button:focus-visible { outline-color: var(--ink); }
.join:focus-visible { outline-color: var(--accent); }

/* Type, rhythm and glyph size share the same responsive scale. */
:root {
  --pixel-scale: 1;
  --unit: calc(1px * var(--pixel-scale));
  --font-display: "Stash Times Roman", serif;
  --type-display: calc(19 * var(--unit));
  --line-display: calc(22 * var(--unit));
  --logo-size: calc(48 * var(--unit));
  --space-logo: calc(24 * var(--unit));
  --space-section: calc(16 * var(--unit));
  --space-edge: calc(16 * var(--unit));
  --content-width: calc(340 * var(--unit));
  --content-height: calc(
    var(--logo-size) + var(--space-logo)
    + 4 * var(--line-display) + 2 * var(--space-section)
  );
}

@media (min-width: 672px) and (min-height: 400px) {
  :root { --pixel-scale: 2; }
}

@media (min-width: 1120px) and (min-height: 600px) {
  :root { --pixel-scale: 3; }
}

@media (min-width: 1760px) and (min-height: 800px) {
  :root { --pixel-scale: 4; }
}

* { box-sizing: border-box; }

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--space-edge);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: var(--type-display);
  line-height: var(--line-display);
  font-weight: 400;
  font-synthesis: none;
  font-kerning: none;
  font-variant-ligatures: none;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
}

.placeholder {
  width: var(--content-width);
  text-align: center;
}

.logo-button {
  display: block;
  width: var(--logo-size);
  height: var(--logo-size);
  margin: 0 auto var(--space-logo);
  padding: 0;
  border: 0;
  background: transparent;
}

.logo-button:enabled { cursor: pointer; }

.logo {
  display: block;
  width: var(--logo-size);
  height: var(--logo-size);
  image-rendering: pixelated;
}

.tagline {
  margin: 0;
  font: inherit;
}

.tagline span {
  display: block;
  width: max-content;
  margin-inline: auto;
}

.availability {
  width: max-content;
  margin: var(--space-section) auto 0;
}

.join {
  display: block;
  width: max-content;
  margin: var(--space-section) auto 0;
  text-decoration-line: underline;
  text-decoration-thickness: var(--unit);
  text-underline-offset: calc(2 * var(--unit));
  text-decoration-skip-ink: none;
}

.logo-button:focus-visible,
.join:focus-visible {
  outline-width: var(--unit);
  outline-style: solid;
  outline-offset: calc(3 * var(--unit));
}

/* Center to the nearest whole CSS pixel toward the start edge. The percentages
   in translate refer to the element itself, so this also works as copy changes.
   No scaling transforms: these offsets only remove half-pixel placement. */
@supports (width: round(down, 1px, 1px)) {
  .placeholder {
    position: relative;
    left: calc(
      round(down, (100vw - var(--content-width)) / 2, 1px)
      - (100vw - var(--content-width)) / 2
    );
    top: calc(
      round(down, max(0px, (100svh - 2 * var(--space-edge) - var(--content-height)) / 2), 1px)
      - max(0px, (100svh - 2 * var(--space-edge) - var(--content-height)) / 2)
    );
  }

  .tagline span,
  .availability,
  .join {
    transform: translateX(calc(
      round(down, (var(--content-width) - 100%) / 2, 1px)
      - (var(--content-width) - 100%) / 2
    ));
  }
}

/* Scale the 32-cell home slot and its eight-cell reach margin together.
   At scale 4 the 192px slot gives the resting mark roughly 144px of visible ink. */
.logo-button { position: relative; color: var(--ink); touch-action: manipulation; }
.glyph-canvas {
  position: absolute;
  inset: calc(var(--logo-size) * -.25);
  width: calc(var(--logo-size) * 1.5);
  height: calc(var(--logo-size) * 1.5);
  image-rendering: pixelated;
  pointer-events: none;
}
.has-glyph .logo { visibility: hidden; }
[hidden] { display: none !important; }
.world-designer {
  position: fixed;
  z-index: 10;
  top: 16px;
  right: 16px;
  width: min(310px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--ink);
  background: var(--ground);
  color: var(--ink);
  font: 13px/1.5 ui-monospace, monospace;
  -webkit-font-smoothing: auto;
}
.world-designer header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.world-designer label { display: grid; gap: 4px; margin-bottom: 12px; }
.world-designer button, .world-designer select {
  font: inherit;
  color: inherit;
  border: 1px solid currentColor;
  background: var(--ground);
  padding: 5px 8px;
  cursor: pointer;
  max-width: 100%;
}
.world-designer > button, .world-designer > a { display: block; margin: 12px 0; }
.world-designer a { color: var(--accent); }
.world-designer p { margin: 12px 0; }
.world-designer :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }


/* Only the changing sentence gets a temporary rendering layer. The DOM live
   region and selection remain; the other text keeps its ordinary rendering. */
.tagline { position: relative; }
.text-baseline { display: inline-block; width: 0; height: 0; padding: 0; }
.tagline-second.is-melting { color: transparent; }
.text-melt { position: absolute; left: 0; pointer-events: none; image-rendering: pixelated; }
