/*
 * zanreal.com/pl/adwent-2026 - page layer over the game's own style.css.
 *
 * The game keeps its stage at most 980px wide, as designed. Around it the
 * page shows the scenery itself, blurred and stretched to the viewport by
 * adwent-page.js, so there is no flat colour and no hard frame; the title row
 * is dropped.
 */

/* Title and brand stay in the document for screen readers only. */
h1,
.brand {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
/* The colour sits on the root so the backdrop canvas can paint above it. */
:root {
  background: #2b2230;
}
body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: none;
}
main {
  position: relative;
  width: 100%;
}

/* The stretched scene behind the frame. Oversized so the blur has no edge. */
#backdrop {
  position: fixed;
  inset: -3vmax;
  z-index: -1;
  width: calc(100% + 6vmax);
  height: calc(100% + 6vmax);
  filter: blur(10px) saturate(1.1) brightness(0.8);
  pointer-events: none;
}

.stage {
  border: 0;
  border-radius: 14px;
  box-shadow:
    0 24px 60px #1c121c66,
    0 4px 14px #1c121c33;
}

/* The game's note under the calendar is not shown; a locked door explains
   itself in a toast inside the frame instead (see adwent-page.js). */
#calendar-note {
  display: none !important;
}
#adwent-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 5;
  max-width: calc(100% - 24px);
  padding: 8px 14px;
  border: 1px solid #ca9e82;
  border-radius: 8px;
  background: #fff7ea;
  box-shadow: 0 3px #bb80645c;
  color: #51392e;
  font:
    400 16px/1.35 Georgia,
    "Times New Roman",
    serif;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}
#adwent-toast[hidden] {
  display: none;
}

/* Text that sits on the page, outside the frame, needs to read on the scene. */
#keyboard {
  width: fit-content;
  margin-inline: auto;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff7eae0;
}

/* Calendar doors that have not opened yet (see adwent-page.js). */
.day.is-locked {
  cursor: default;
}

/* Loader: covers the stage while the town or a level's art downloads. */
#adwent-loader {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #241a2273;
  backdrop-filter: blur(2px);
}
#adwent-loader[hidden] {
  display: none;
}
.adwent-loader-card {
  width: min(100%, 300px);
  padding: 18px 20px 20px;
  border: 1px solid #ca9e82;
  border-radius: 8px;
  background: #fff7ea;
  box-shadow: 0 3px #bb80645c;
  text-align: center;
}
.adwent-loader-label {
  margin: 0 0 12px;
  font:
    400 18px/1.4 Georgia,
    "Times New Roman",
    serif;
  color: #51392e;
}
.adwent-loader-bar {
  height: 10px;
  overflow: hidden;
  border: 1px solid #ac7971;
  border-radius: 999px;
  background: #f1dcc7;
}
.adwent-loader-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(-45deg, #795295 0 8px, #8f68aa 8px 16px);
  background-size: 22px 22px;
  transition: width 0.2s ease-out;
  animation: adwent-loader-stripes 0.8s linear infinite;
}
@keyframes adwent-loader-stripes {
  to {
    background-position: 22px 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .adwent-loader-bar span {
    transition: none;
    animation: none;
  }
}

/*
 * "Wróć do miasteczka": a row of its own above the frame, lined up with the
 * frame's left edge. The row keeps its height when the button is hidden (on
 * the map), so the frame does not jump between the map and a level. The
 * button is a wooden sign like the game's "POCZTA" board: a lit plank with a
 * dark frame, a nail at each end and spaced capitals. The game's own label
 * stays the accessible name; the sign shows the short form.
 */
header {
  height: 44px;
  margin: 0 0 12px;
  justify-content: flex-start;
}
/* The map has no back button, so no row for it: it only pushed the page
   past the bottom of a phone screen. */
body.adwent-map header {
  display: none;
}
#map {
  position: relative;
  min-height: 44px;
  padding: 0 24px;
  border: 3px solid #6b4229;
  border-radius: 3px;
  /* Two nails, then the plank. */
  background:
    linear-gradient(#5a3a26, #5a3a26) left 7px center / 4px 4px no-repeat,
    linear-gradient(#5a3a26, #5a3a26) right 7px center / 4px 4px no-repeat,
    linear-gradient(#e6c596, #cf9f69);
  box-shadow:
    inset 0 2px 0 #f6dfb8,
    inset 0 -3px 0 #b07c4c,
    0 3px 0 #3d2516;
  color: transparent;
  font-size: 0;
  white-space: nowrap;
}
/* The short sign text, drawn over the game's label (kept for screen readers
   and as the button's accessible name). */
#map::before {
  content: "Do miasteczka" / "";
  color: #4a2f22;
  font:
    700 13px/1 ui-monospace,
    "Courier New",
    monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  /* Letter spacing trails the last letter too; take it back to centre. */
  margin-right: -0.14em;
}
#map:hover {
  background:
    linear-gradient(#5a3a26, #5a3a26) left 7px center / 4px 4px no-repeat,
    linear-gradient(#5a3a26, #5a3a26) right 7px center / 4px 4px no-repeat,
    linear-gradient(#ecd0a5, #d8ab77);
}
#map:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 0 #f6dfb8,
    inset 0 -3px 0 #b07c4c,
    0 1px 0 #3d2516;
}
#map:focus-visible {
  outline: 3px solid #f7d995;
  outline-offset: 3px;
}

/*
 * Return buttons on the completion card and the final message
 * (`.paper-button` in style.css): the solid green of the letter's
 * "Przyjmij zgłoszenie" (`.stage.brief-view #continue`) instead of paper.
 */
.paper-button {
  border: 1px solid #304c3d;
  background: #496454;
  box-shadow: 0 2px 0 #304638;
  color: #fff3d8;
  letter-spacing: 0.015em;
}
.paper-button:hover {
  background: #3c5748;
}
.paper-button:focus-visible {
  outline: 3px solid #9c7542;
  outline-offset: 4px;
}
@media (hover: none) {
  .paper-button:hover {
    background: #496454;
  }
}

/*
 * Touch controls. The game shows them only while a level is being played,
 * and only once its opening camera move ends; anywhere else in the level
 * (its letter, the repair, the completion card) it hides them, and on a
 * phone the stage then grows into their strip - the game changes size.
 * So for every screen of a level (adwent-page.js sets the classes) the strip
 * keeps its room: visible while playing, invisible but in place otherwise.
 * The game ignores input outside play anyway.
 *
 * The buttons are wooden signs like "Do miasteczka" above the stage.
 */
@media (any-pointer: coarse), (max-width: 640px) {
  body.adwent-in-level #controls[hidden] {
    display: flex !important;
    visibility: hidden;
  }
  body.adwent-playing #controls[hidden] {
    visibility: visible;
  }
  #controls button {
    border: 3px solid #6b4229;
    border-radius: 3px;
    background:
      linear-gradient(#5a3a26, #5a3a26) left 6px top 6px / 4px 4px no-repeat,
      linear-gradient(#5a3a26, #5a3a26) right 6px top 6px / 4px 4px no-repeat,
      linear-gradient(#e6c596, #cf9f69);
    box-shadow:
      inset 0 2px 0 #f6dfb8,
      inset 0 -3px 0 #b07c4c,
      0 3px 0 #3d2516;
    color: #4a2f22;
    font-family: ui-monospace, "Courier New", monospace;
    font-weight: 700;
  }
  #controls button[data-key="jump"] {
    font-size: 15px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  #controls button.active,
  #controls button:active {
    border-color: #6b4229;
    background:
      linear-gradient(#5a3a26, #5a3a26) left 6px top 6px / 4px 4px no-repeat,
      linear-gradient(#5a3a26, #5a3a26) right 6px top 6px / 4px 4px no-repeat,
      linear-gradient(#d8ab77, #c08d5a);
    box-shadow:
      inset 0 2px 0 #e9c99a,
      inset 0 -2px 0 #a06f42,
      0 1px 0 #3d2516;
    color: #4a2f22;
    transform: translateY(2px);
  }
  #controls button:focus-visible {
    outline: 3px solid #f7d995;
    outline-offset: 3px;
  }
}

/*
 * Phones: no frame. The game fills the screen edge to edge - the back sign
 * on a slim row at the top (gone on the map), the stage taking all the
 * height that is left, the touch controls in a strip at the bottom - and
 * nothing scrolls. The game sizes its canvas from CSS and lays out the
 * calendar and the levels from that size, so they follow.
 */
@media (max-width: 640px) {
  body {
    display: block;
    padding: 0;
  }
  main {
    display: flex;
    flex-direction: column;
    height: 100svh;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
      env(safe-area-inset-left);
  }
  /* Fixed height: the game also hides the back sign during a repair, and
     the row must not collapse then. */
  header {
    flex: 0 0 auto;
    height: 60px;
    margin: 0;
    padding: 8px 10px;
  }
  .stage,
  .stage.map-view,
  .stage.brief-view {
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .stage canvas,
  .stage.map-view canvas {
    height: 100% !important;
    min-height: 0 !important;
  }
  #controls {
    flex: 0 0 auto;
    margin: 0;
    padding: 10px;
  }
}

/*
 * The letter on a phone. The game gives it a 520px minimum height, which a
 * phone stage (the screen minus the sign row and the controls strip, and in
 * Safari minus its own bars) can be shorter than, so the parchment's foot was
 * cut off. It now takes only the height its words need. Letters differ in
 * length from day to day, so adwent-page.js measures each sheet against the
 * stage and, when it is taller, scales the whole parchment down to fit (to
 * 72% at most); on short screens the spacing and type also tighten. Only
 * past that does the letter scroll inside itself, each sheet from its top.
 */
@media (max-width: 640px) {
  .stage.brief-view {
    padding: 12px 0;
  }
  .stage.brief-view #panel {
    min-height: 0;
    transform-origin: center;
    /* The parchment as the panel's own background, which stays put if the
       words ever have to scroll; style.css draws it in an absolute ::before
       that would scroll away and leave dark text on the dark scene. */
    background: url("parchment-letter-v2.webp") center / 100% 100% no-repeat;
  }
  /* Last resort, set by adwent-page.js with a max-height in px. */
  .stage.brief-view #panel.adwent-letter-scroll {
    overflow-y: auto;
  }
  .stage.brief-view #panel::before {
    content: none;
  }
}
@media (max-width: 640px) and (max-height: 760px) {
  .stage.brief-view #panel {
    padding: 30px 28px 24px;
  }
  .stage.brief-view #letter-date {
    margin-bottom: 10px;
  }
  .stage.brief-view #title {
    font-size: 24px;
    margin-bottom: 14px;
  }
  .stage.brief-view #story p {
    font-size: 16px;
    line-height: 1.5;
  }
  .stage.brief-view #letter-signoff {
    margin: 12px 0 18px;
  }
  .stage.brief-view #level-instructions {
    margin-bottom: 18px;
  }
  .stage.brief-view #level-instructions p {
    font-size: 16px;
  }
  .stage.brief-view #brief-back {
    min-height: 36px;
    margin-top: 6px;
  }
}

/* Local dev server only (see TEST_MODE in adwent-page.js). */
#adwent-test-badge {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 50;
  max-width: 45vw;
  padding: 4px 10px;
  border: 2px solid #6b4229;
  border-radius: 3px;
  background: #f7d995;
  color: #4a2f22;
  font:
    700 11px/1.2 ui-monospace,
    "Courier New",
    monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}
@media (max-width: 640px) {
  .adwent-test-badge-detail {
    display: none;
  }
}

/* Zanek's lines the game prints under the stage at the end of day 24's
   finale: not shown on this page. */
#scene-caption {
  display: none !important;
}
