/* Shared styles for the work-in-progress page and the error pages. */

:root {
  --crane: #bcae9f;
  --machine: #5a4f49;
  --bg: #fbf7f2;
  --text: #2b2522;
  --muted: #6f655e;
  --ground: #ebe3d9;
  --seg: #efe8df;
  --seg-active: #fffdfa;
  --button: #2b2522;
  --button-text: #fbf7f2;
  --focus: #3b82f6;
  --coral: #ff8a65;
  --yellow: #ffd166;
  --green: #5cc39f;
  --blue: #7aa7ff;
  --block-text: #2b2522;
  color-scheme: light;
}

:root.dark {
  --crane: #5f5650;
  --machine: #8e837b;
  --bg: #1b1817;
  --text: #f4ede6;
  --muted: #aa9f97;
  --ground: #2f2a27;
  --seg: #2a2522;
  --seg-active: #403935;
  --button: #f4ede6;
  --button-text: #1b1817;
  --focus: #7aa7ff;
  color-scheme: dark;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.55 ui-rounded,
    'SF Pro Rounded',
    'Nunito',
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

/* Header: language and theme switches. */

header {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
}

fieldset {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--seg);
}

fieldset button {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background-color 0.15s,
    color 0.15s;
}

fieldset button:hover {
  color: var(--text);
}

fieldset button[aria-pressed='true'] {
  background: var(--seg-active);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

fieldset svg {
  width: 15px;
  height: 15px;
}

/* Main: block scene, text and buttons. */

main {
  display: grid;
  place-items: center;
  padding: 16px 20px 32px;
  text-align: center;
}

.content {
  width: min(760px, 100%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Headings stay on one line: the longest ones ("Building something awesome", "Budujemy coś
   niesamowitego") are about 16.3× their font size wide, so the size follows the viewport and
   tops out where they still fit the content column. */
h1 {
  margin: 0;
  font-size: clamp(16px, 5.1vw, 44px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.lead {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 18px;
  text-wrap: pretty;
}

/* "Coming soon..." — the dots light up one after another, then fade together. They always take
   their space, so the text doesn't shift. With reduced motion they just stay lit. */

.ellipsis span {
  animation: ellipsis 1.8s infinite;
}

.ellipsis span:nth-child(2) {
  animation-delay: 0.3s;
}

.ellipsis span:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes ellipsis {
  0%,
  15% {
    opacity: 0;
  }
  35%,
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: 2px solid var(--button);
  border-radius: 999px;
  background: var(--button);
  color: var(--button-text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s;
}

.button:hover {
  transform: translateY(-2px);
}

.button.secondary {
  background: none;
  color: var(--text);
}

.button svg {
  width: 18px;
  height: 18px;
}

footer {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* Blocks sit in their final spots. With JS they start hidden (.js, set before first paint) so a
   finished build never flashes on load; main.js fades each one in as it arrives.
   Without JS, with reduced motion, or if main.js fails to load (.still), they are just shown. */

.js .block {
  opacity: 0;
}

.js.still .block {
  opacity: 1;
}

.scene {
  position: relative;
  width: 240px;
  height: 184px;
  margin: 0 auto 28px;
}

.ground {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 8px;
  border-radius: 8px;
  background: var(--ground);
}

.block {
  position: absolute;
  bottom: calc(8px + var(--row) * 38px);
  left: calc(50% + var(--col) * 60px - 29px);
  width: 58px;
  height: calc(var(--h, 1) * 38px);
  border-radius: 9px;
  box-shadow: inset 0 -4px 0 rgb(0 0 0 / 0.12);
  will-change: transform, opacity;
}

.block.coral {
  background: var(--coral);
}
.block.yellow {
  background: var(--yellow);
}
.block.green {
  background: var(--green);
}
.block.blue {
  background: var(--blue);
}

/* Work-in-progress page: the building site from crane.js, in this page's colours (they follow
   dark mode). The space is reserved up front so the text doesn't jump when it mounts. */
.crane-site {
  --crane-block-1: var(--coral);
  --crane-block-2: var(--yellow);
  --crane-block-3: var(--green);
  --crane-block-4: var(--blue);
  --crane-frame: var(--crane);
  --crane-machine: var(--machine);
  --crane-paint: var(--yellow);
  --crane-ground: var(--ground);
  --crane-window: var(--bg);
  width: 320px;
  height: 250px;
  margin: 0 auto 24px;
}

/* Without JS there's no building site, so no empty space for it either. */
:root:not(.js) .crane-site {
  display: none;
}

/* Narrow phones: shrink the whole scene; zoom keeps crane.js's layout maths in step. */
@media (max-width: 359px) {
  .crane-site {
    zoom: 0.85;
  }
}

/* Error pages: the status code as three square blocks. */

.scene.code .block {
  bottom: 8px;
  left: calc(50% + var(--col) * 72px - 32px);
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 13px;
  color: var(--block-text);
  font-size: 34px;
  font-weight: 800;
}
