/* Crossroads Foundry: one page, pixel art, no trackers, no outside fonts.
   The sky, castles, roads and everything that moves behind the page are drawn by scene.js on the canvas in .world;
   the signpost's foot (the bottom of .signpost) is where scene.js puts the crossroads.

   Text sizes: Jersey 15 is drawn on a grid of 1/27 of its size, so it is only crisp at 27 px and whole multiples of
   it (54, 81, 108). Every size below is one of those; anything between blurs the letters. */
@font-face { font-family: 'Jersey 15'; src: url('fonts/Jersey15.ttf') format('truetype'); font-display: swap; }

:root {
  --night: #0e1125;
  --field: #163225;
  --parchment: #f4e8c8;
  --ember: #e0a35c;
  --flame: #ffcf6a;
  --wood: #c98a4b;
  --wood-light: #e6b273;
  --wood-dark: #9a5e2e;
  --post: #9c5f2b;
  --post-light: #b87538;
  --post-dark: #6e3f1b;
  --ink: #2b170c;
  --shadow: #0b0a14;
  --dusk: #b7b1e0;
  --text: 27px;                 /* (the font's own size: one font pixel = one screen pixel) */
  --arm: min(46vw, 252px);      /* (how far a board reaches from the post's middle) */
  --post-w: 24px;
  --icon: 42px;
  --tip: 24px;
  --title: 108px; --fp: 4px;    /* (the title's size, and one of its font pixels: a 27th of it) */
}

* { box-sizing: border-box; }
html {
  /* (what shows when a phone overscrolls: night above, the field below) */
  background: linear-gradient(var(--night) 50%, var(--field) 50%);
  overflow-x: hidden;
}
body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--parchment);
  font-family: 'Jersey 15', system-ui, sans-serif;
  font-size: var(--text);
  background: var(--night);
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}
img { image-rendering: pixelated; }

/* ---- the world behind the page ---- */
.world { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; z-index: 0; }
.world canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
@supports (image-rendering: pixelated) { .world canvas { image-rendering: pixelated; } }

.page { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }

.stage {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 72px 20px 0;
  display: grid;
  justify-items: center;
  gap: 56px;
}

/* ---- the name, the forge and the words ---- */
.crest { text-align: center; max-width: 600px; }
.forge { position: relative; width: 160px; height: 160px; margin: 0 auto 18px; }
.forge::before {   /* (the forge's glow behind the emblem; brighter for a moment at each hammer strike) */
  content: '';
  position: absolute;
  left: 50%; top: 58%;
  width: 340px; height: 340px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 150, 70, 0.30) 0%, rgba(194, 94, 51, 0.20) 30%, rgba(122, 53, 64, 0.10) 50%, transparent 68%);
  animation: smoulder 4.8s ease-in-out infinite;
  pointer-events: none;
}
.forge.strike::before { animation: none; opacity: 1; filter: brightness(1.5); }
.emblem { position: relative; display: block; width: 160px; height: 160px; }
.forge.strike .emblem { transform: translateY(5px); }   /* (one of the emblem's pixels) */
@keyframes smoulder { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }

h1 {
  margin: 0;
  font-weight: normal;
  font-size: var(--title);
  line-height: 0.875;
  text-transform: uppercase;
  color: var(--parchment);
  /* (the letters cut from a thick plank: warm edge, dark wood, then their shadow on the sky; a font pixel per step) */
  text-shadow: 0 var(--fp) 0 #e6b273, 0 calc(var(--fp) * 2) 0 #c06a35, 0 calc(var(--fp) * 3) 0 #7a3540,
    0 calc(var(--fp) * 4) 0 var(--shadow), 0 calc(var(--fp) * 6) 16px rgba(0, 0, 0, 0.4);
}
h1 span { display: block; }
.tagline {
  margin: 30px 0 0;
  font-size: var(--text);
  line-height: 32px;
  color: var(--flame);
  text-shadow: 2px 2px 0 var(--shadow), -1px -1px 0 var(--shadow), 1px -1px 0 var(--shadow), -1px 1px 0 var(--shadow);
}
.about {   /* (on a dark pane, so the stars and the sunset don't run through the letters) */
  margin: 20px auto 0;
  padding: 14px 20px 16px;
  max-width: 560px;
  font-size: var(--text);
  line-height: 32px;
  text-align: left;
  color: #f1ecff;
  background: rgba(11, 10, 26, 0.80);
  box-shadow: 0 0 0 3px #3b3466, 0 0 0 6px var(--shadow), 0 9px 0 6px rgba(11, 10, 20, 0.35);
}

/* ---- the signpost ---- */
.signpost {
  position: relative;
  width: calc(var(--arm) * 2);
  max-width: 100%;
  padding: 18px 0 74px;        /* (74 px: the bare post below the last board, down to the crossroads) */
}
.signpost::before {   /* the post */
  content: '';
  position: absolute;
  left: calc(50% - var(--post-w) / 2);
  top: 0; bottom: 0;
  width: var(--post-w);
  background: linear-gradient(90deg, var(--post-light) 0 30%, var(--post) 30% 72%, var(--post-dark) 72%);
  box-shadow: 0 0 0 3px var(--ink), 6px 0 0 3px rgba(11, 10, 20, 0.35);
}
.signpost::after {   /* the post's cap */
  content: '';
  position: absolute;
  left: calc(50% - var(--post-w) / 2 - 6px);
  top: -12px;
  width: calc(var(--post-w) + 12px);
  height: 12px;
  background: var(--wood-dark);
  box-shadow: inset 0 3px 0 var(--wood-light), 0 0 0 3px var(--ink);
}
.plaque {   /* the little board across the top */
  position: relative;
  z-index: 1;
  width: max-content;
  margin: 0 auto 26px;
  padding: 8px 16px 7px;
  font-size: var(--text);
  line-height: 27px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--parchment);
  background: #5a3a2a;
  box-shadow: inset 0 3px 0 #7c5338, inset 0 -3px 0 #3c2419, 0 0 0 3px var(--ink), 0 6px 0 3px rgba(11, 10, 20, 0.4);
  text-shadow: 2px 2px 0 var(--ink);
}
.signpost ul { position: relative; list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.signpost li {
  width: var(--arm);
  /* (the dark outline round the board's arrow shape, and its shadow) */
  filter: drop-shadow(3px 0 0 var(--ink)) drop-shadow(-3px 0 0 var(--ink)) drop-shadow(0 3px 0 var(--ink)) drop-shadow(0 -3px 0 var(--ink)) drop-shadow(0 6px 0 rgba(11, 10, 20, 0.45));
  will-change: transform;   /* (each board on its own layer: it slides without its outline being redrawn) */
}
.signpost li.to-right { margin-left: calc(50% - var(--post-w) / 2 - 4px); }
.signpost li.to-left { margin-left: calc(50% - var(--arm) + var(--post-w) / 2 + 4px); }

.sign {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 calc(var(--tip) - 4px) 0 calc(var(--post-w) + 12px);
  font-size: var(--text);
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  background:
    repeating-linear-gradient(90deg, rgba(122, 69, 32, 0.45) 0 14px, transparent 14px 26px) 0 8px / 100% 3px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 9px, rgba(122, 69, 32, 0.45) 9px 20px, transparent 20px 31px) 0 calc(100% - 8px) / 100% 3px no-repeat,
    var(--wood);
  box-shadow: inset 0 4px 0 var(--wood-light), inset 0 -4px 0 var(--wood-dark);
  clip-path: polygon(0 0, calc(100% - var(--tip)) 0, 100% 50%, calc(100% - var(--tip)) 100%, 0 100%);
  transition: transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.3), background-color 0.16s ease-out;
}
.sign::before {   /* the two nails where the board crosses the post */
  content: '';
  position: absolute;
  left: 7px; top: 15px;
  width: 6px; height: 6px;
  background: #3a3f4c;
  box-shadow: inset 2px 2px 0 #8a93a4, 0 24px 0 #3a3f4c;
}
.sign img { flex: none; width: var(--icon); height: var(--icon); }
.sign span { white-space: nowrap; }
.to-left .sign {
  flex-direction: row-reverse;
  padding: 0 calc(var(--post-w) + 12px) 0 calc(var(--tip) - 4px);
  clip-path: polygon(var(--tip) 0, 100% 0, 100% 100%, var(--tip) 100%, 0 50%);
}
.to-left .sign::before { left: auto; right: 7px; }

.sign:hover { background-color: #dda05e; transform: translateX(8px); }
.to-left .sign:hover { transform: translateX(-8px); }
.sign:active { transform: translateX(3px); }
.to-left .sign:active { transform: translateX(-3px); }
.sign:focus-visible { outline: none; background-color: #ffd36b; }
.signpost li:focus-within {
  filter: drop-shadow(3px 0 0 #fff4d6) drop-shadow(-3px 0 0 #fff4d6) drop-shadow(0 3px 0 #fff4d6) drop-shadow(0 -3px 0 #fff4d6) drop-shadow(0 6px 0 rgba(11, 10, 20, 0.45));
}

/* ---- the music button (top right, stays put) ---- */
.music {
  position: fixed;
  z-index: 5;
  top: 14px; right: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 8px 12px;
  font: inherit;
  font-size: var(--text);
  line-height: 27px;
  color: var(--parchment);
  background: #5a3a2a;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 3px 0 #7c5338, inset 0 -3px 0 #3c2419, 0 0 0 3px var(--ink), 0 5px 0 3px rgba(11, 10, 20, 0.45);
  text-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}
.music[hidden] { display: none; }
.music:hover { background: #6b4632; }
.music:focus-visible { outline: 3px solid #fff4d6; outline-offset: 3px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 18px; }
.bars i { display: block; width: 4px; height: 6px; background: var(--flame); box-shadow: 1px 1px 0 var(--ink); }
.music[aria-pressed="true"] .bars i { animation: beat 0.9s steps(4) infinite; }
.music[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: -0.3s; animation-duration: 0.7s; }
.music[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: -0.5s; animation-duration: 1.1s; }
.music[aria-pressed="true"] .bars i:nth-child(4) { animation-delay: -0.2s; animation-duration: 0.8s; }
.music[aria-pressed="false"] .bars i { background: #8f8ac0; }
.music.waiting .music-label { animation: blink 1.2s steps(2) infinite; }
@keyframes beat { 0%, 100% { height: 4px; } 25% { height: 16px; } 50% { height: 9px; } 75% { height: 13px; } }
@keyframes blink { 50% { opacity: 0.6; } }

footer { position: relative; text-align: center; padding: 60px 16px 28px; font-size: var(--text); line-height: 32px; color: #b9d3b2; text-shadow: 2px 2px 0 var(--shadow); }
footer p { margin: 0; }

/* ---- arriving: once the font is in (the page script adds .ready), the crest rises and the boards slide out from
   the post one after another. Until then they wait unseen, so nothing jumps when the font arrives ---- */
.js:not(.ready) .forge, .js:not(.ready) h1, .js:not(.ready) .tagline, .js:not(.ready) .about, .js:not(.ready) .plaque,
.js:not(.ready) .signpost li { opacity: 0; }
.ready .forge, .ready h1, .ready .tagline, .ready .about { animation: rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.ready h1 { animation-delay: 0.06s; }
.ready .tagline { animation-delay: 0.12s; }
.ready .about { animation-delay: 0.18s; }
.ready .plaque { animation: pop 0.4s cubic-bezier(0.2, 0.8, 0.3, 1.4) 0.1s both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.8); } }
.ready .signpost li { animation: out-right 0.5s cubic-bezier(0.2, 0.85, 0.3, 1.25) both; animation-delay: calc(0.16s + var(--n, 0) * 0.055s); }
.ready .signpost li.to-left { animation-name: out-left; }
.signpost li:nth-child(2) { --n: 1; } .signpost li:nth-child(3) { --n: 2; } .signpost li:nth-child(4) { --n: 3; }
.signpost li:nth-child(5) { --n: 4; } .signpost li:nth-child(6) { --n: 5; } .signpost li:nth-child(7) { --n: 6; }
.signpost li:nth-child(8) { --n: 7; }
@keyframes out-right { from { opacity: 0; transform: translateX(-36px); } 40% { opacity: 1; } }
@keyframes out-left { from { opacity: 0; transform: translateX(36px); } 40% { opacity: 1; } }

/* ---- phones ---- */
@media (max-width: 599px) {
  :root { --title: 54px; --fp: 2px; --post-w: 18px; --icon: 28px; --tip: 18px; --arm: calc(50vw - 6px); }
  .stage { padding: 64px 6px 0; gap: 44px; }
  .forge, .emblem { width: 128px; height: 128px; }
  .forge::before { width: 280px; height: 280px; }
  .forge.strike .emblem { transform: translateY(4px); }
  .tagline { margin-top: 24px; }
  .crest { padding: 0 8px; }
  .about { margin: 18px 2px 0; padding: 12px 16px 14px; }
  .sign { height: 52px; gap: 6px; padding-left: calc(var(--post-w) + 10px); padding-right: calc(var(--tip) - 4px); }
  .to-left .sign { padding-left: calc(var(--tip) - 4px); padding-right: calc(var(--post-w) + 10px); }
  .sign::before { left: 5px; top: 12px; width: 6px; height: 6px; box-shadow: inset 2px 2px 0 #8a93a4, 0 22px 0 #3a3f4c; }
  .to-left .sign::before { right: 5px; }
}
@media (max-width: 389px) { .sign span { letter-spacing: -1px; } .sign { gap: 4px; } }   /* (Instagram still fits at 360) */

/* ---- tablets and narrow windows ---- */
@media (min-width: 600px) and (max-width: 1179px) { :root { --title: 81px; --fp: 3px; } }

/* ---- wide screens: the name on the left, the signpost on the right, all in one view ---- */
@media (min-width: 940px) {
  .stage {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    align-items: center;
    gap: 40px;
    padding: 70px 40px 0;
  }
  .crest { text-align: left; justify-self: start; padding-bottom: 40px; }
  .forge { margin-left: 0; }
  .about { margin-left: 0; }
}

/* ---- the wrong-turn page (404.html): one board, pointing home ---- */
.lost { --arm: min(46vw, 290px); }
.lost .signpost { padding: 40px 0 220px; }   /* (the one board high on a tall post) */
.lost .short { display: none; }
@media (max-width: 599px) { .lost { --arm: calc(50vw - 6px); } .lost .long { display: none; } .lost .short { display: inline; } }
@media (min-width: 940px) { .lost .stage { align-items: end; } .lost .crest { padding-bottom: 170px; } }

@media (prefers-reduced-motion: reduce) {
  .ready .forge, .ready h1, .ready .tagline, .ready .about, .ready .plaque, .ready .signpost li { animation: none; }
  .forge::before { animation: none; }
  .sign { transition: none; }
  .sign:hover, .to-left .sign:hover, .sign:active, .to-left .sign:active { transform: none; }
  .music[aria-pressed="true"] .bars i { animation-duration: 3s; }
  .music.waiting .music-label { animation: none; }
}
