:root {
  --paper: #f3ecdf;
  --seal: #c23a2b;
  --ink: #2a2420;
  --latin: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #14110f;
  color: var(--paper);
  font-family: var(--latin);
}

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#sprites { pointer-events: none; }
/* the tooth of the canvas, over the paint and whatever moves on it (made in painting.js) */
#grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: var(--grain, none);
  background-size: 192px 192px;
}
#scene { cursor: pointer; }

/* ---- where we are (top left) and the time in Berlin (top right) ---- */
#place, #clock {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  font-size: 15px;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  user-select: none;
}
#place { left: max(20px, env(safe-area-inset-left)); }
#clock { right: max(20px, env(safe-area-inset-right)); }
#place .label, #clock .label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.75;
}
#place .label {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-size: 13px;
  letter-spacing: 0.12em;
}
#place .name {
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 13px;
}

/* ---- the arrows at the sides: back to the place before, on to the next ---- */
.walk {
  position: fixed;
  top: 50%;
  translate: 0 -50%;
  width: 56px;
  height: 96px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--paper);
  opacity: 0.85;
  cursor: pointer;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 6px rgba(0, 0, 0, 0.55)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  transition: opacity 0.2s, transform 0.25s;
  animation: beckon 1.6s 2.5s ease-in-out 2;   /* a nudge or two at first, so they are noticed */
  -webkit-tap-highlight-color: transparent;
}
.walk::before {                          /* a soft spot of dark ink behind the chevron, so it reads on any picture */
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle closest-side, rgba(16, 13, 11, 0.5), rgba(16, 13, 11, 0.3) 55%, rgba(16, 13, 11, 0));
  transition: background-color 0.2s, scale 0.25s;
}
.walk:hover::before { scale: 1.12; }
#prev { left: max(8px, env(safe-area-inset-left)); --way: -1; }
#next { right: max(8px, env(safe-area-inset-right)); --way: 1; }
.walk span {                             /* a chevron: two sides of a square, turned to point the way */
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  border: solid currentColor;
  border-width: 0 2.4px 2.4px 0;
  border-radius: 0 0 2px 0;
}
#prev span { transform: translate(-30%, -50%) rotate(135deg); }
#next span { transform: translate(-70%, -50%) rotate(-45deg); }
.walk:hover { opacity: 1; transform: translateX(calc(var(--way) * 4px)); }
.walk:focus-visible { outline: 1px solid var(--paper); outline-offset: -8px; }
@keyframes beckon { 50% { transform: translateX(calc(var(--way) * 6px)); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .walk { transition: none; animation: none; } }

/* ---- the season and the hour, bottom right: written like the corners above ---- */
#almanac {
  position: fixed;
  right: max(13px, env(safe-area-inset-right));
  bottom: max(30px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0 14px;
  width: max-content;
  max-width: calc(100vw - 32px);
  color: var(--paper);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.7), 0 0 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.6);
  user-select: none;
}
#almanac .choices { display: flex; align-items: center; }
#almanac .choices + .choices::before {   /* a thin stroke between the seasons and the hours */
  content: "";
  width: 1px;
  height: 13px;
  margin-right: 14px;
  background: currentColor;
  opacity: 0.4;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
#almanac button {
  position: relative;
  padding: 8px 7px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: inherit;
  opacity: 0.72;
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#almanac button:hover { opacity: 0.92; }
#almanac button[aria-pressed="true"] { opacity: 1; }
#almanac button[aria-pressed="true"]::after {   /* what is painted now: underlined */
  content: "";
  position: absolute;
  left: 7px;
  right: calc(7px + 0.1em);
  bottom: 3px;
  height: 1px;
  background: currentColor;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#almanac button.now::before {             /* the season or hour it really is: a dot in the red of the seal */
  content: "";
  position: absolute;
  top: 4px;
  right: 1px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #e0503c;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}
#almanac .reset {                         /* back to now: small, like the labels at the top */
  font-size: 11px;
  letter-spacing: 0.16em;
  opacity: 0.75;
}
#almanac .reset:disabled { visibility: hidden; }
#almanac button:focus-visible { outline: 1px solid var(--paper); outline-offset: -2px; }
/* where the bar no longer fits beside the note, it goes above it, in two rows if need be */
@media (max-width: 760px) {
  #almanac { bottom: calc(max(24px, env(safe-area-inset-bottom)) + 62px); }
  #almanac .choices + .choices::before { display: none; }
}

/* ---- the music note, bottom left ---- */
#music {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--paper);
  opacity: 0.72;
  cursor: pointer;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.55)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#music .note {                           /* the note is a shape from assets/, filled with the button's colour */
  display: block;
  width: 100%;
  height: 100%;
  background: currentColor;
  -webkit-mask: url(../assets/music-note-off.svg) center / contain no-repeat;
  mask: url(../assets/music-note-off.svg) center / contain no-repeat;
  transition: background-color 0.3s;
}
#music[aria-pressed="false"] { color: #e0503c; opacity: 0.9; }   /* off: struck through, in the red of the seal */
#music[aria-pressed="true"] .note {
  -webkit-mask-image: url(../assets/music-note.svg);
  mask-image: url(../assets/music-note.svg);
}
#music:hover, #music[aria-pressed="true"] { opacity: 1; }
#music[aria-pressed="true"] .note { animation: sway 4s ease-in-out infinite; transform-origin: 50% 80%; }
#music:focus-visible { outline: 1px solid var(--paper); outline-offset: 2px; }
@keyframes sway { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { #music[aria-pressed="true"] .note { animation: none; } }

/* ---- the logo in the middle, and the card it opens ---- */
.defs { position: absolute; width: 0; height: 0; }
#logo {                                  /* written in paper over the painting, like the corners */
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(380px, 62vw);
  aspect-ratio: 2002.7 / 622.8;
  padding: 0;
  border: 0;
  background: none;
  color: var(--paper);
  opacity: 0.9;
  translate: -50% -50%;
  filter:                                /* a dark rim hugging the letters, then a softer glow so it lifts off a bright picture */
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.85))
    drop-shadow(0 0 2.5px rgba(0, 0, 0, 0.6))
    drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 16px rgba(0, 0, 0, 0.4))
    blur(0);
  cursor: pointer;
  /* coming back: it waits for the card to roll up, then settles in */
  transition: opacity 0.4s 0.25s, transform 0.55s 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2), filter 0.45s 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#logo .mark {                            /* the logo is a shape from assets/, filled with paper, a little ragged like a stamp */
  display: block;
  width: 100%;
  height: 100%;
  background: currentColor;
  -webkit-mask: url(../assets/starsbit-black-cropped.svg) center / contain no-repeat;
  mask: url(../assets/starsbit-black-cropped.svg) center / contain no-repeat;
  filter: url(#stamp);
}
#logo:hover { opacity: 1; transform: scale(1.03); transition-delay: 0s; transition-duration: 0.25s; }
#logo:focus-visible { outline: 1px solid var(--paper); outline-offset: 12px; }
#logo[aria-expanded="true"] {            /* going: it swells and dissolves into the card */
  opacity: 0;
  transform: scale(1.18);
  filter:
    drop-shadow(0 0 1px rgba(0, 0, 0, 0))
    drop-shadow(0 0 2.5px rgba(0, 0, 0, 0))
    drop-shadow(0 1px 3px rgba(0, 0, 0, 0))
    drop-shadow(0 0 16px rgba(0, 0, 0, 0))
    blur(8px);
  pointer-events: none;
  transition: opacity 0.35s, transform 0.45s cubic-bezier(0.3, 0, 0.2, 1), filter 0.4s;
}

/* The card unrolls out of the band the logo was written on: a thin, tilted strip of paper that opens
   up and down, overshooting a little, and then what is written on it comes up line by line.  Put away,
   the writing goes first and the paper rolls back up into the strip. */
#about {
  position: fixed;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 22px 24px 18px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 3px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  font-size: 14.5px;
  line-height: 1.55;
  outline: none;
  transform-origin: 50% 50%;
  opacity: 0;
  transform: rotate(-2.5deg) scale(0.86, 0.12);
  pointer-events: none;
  transition: transform 0.38s 0.12s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.14s 0.38s;
}
#about.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: transform 0.6s 0.08s cubic-bezier(0.2, 0.9, 0.25, 1.12), opacity 0.18s 0.08s;
}
#about[hidden] { display: none; }
#about > * { opacity: 0; transform: translateY(8px); filter: blur(2px); transition: opacity 0.12s, transform 0.12s, filter 0.12s; }
#about.open > * {
  opacity: 1;
  transform: none;
  filter: blur(0);
  transition: opacity 0.4s, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.4s;
  transition-delay: calc(0.3s + var(--i, 0) * 0.05s);
}
#about > :nth-child(2) { --i: 1; }
#about > :nth-child(3) { --i: 2; }
#about > :nth-child(4) { --i: 3; }
#about > :nth-child(5) { --i: 4; }
#about > :nth-child(6) { --i: 5; }
#about > :nth-child(7) { --i: 6; }
#about > :nth-child(8) { --i: 7; }
#about .logo { display: block; width: 170px; height: auto; margin: 2px 0 14px; }
#about p { margin: 0 0 10px; }
#about .who { font-size: 16px; letter-spacing: 0.04em; }
#about h2 {
  margin: 16px 0 6px;
  font-size: 11px;
  font-weight: normal;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(42, 36, 32, 0.6);
}
#about a { color: #9c2c20; text-decoration: none; border-bottom: 1px solid rgba(156, 44, 32, 0.3); }
#about a:hover, #about a:focus-visible { border-bottom-color: currentColor; outline: none; }
#about .links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; list-style: none; }
#about .colophon {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(42, 36, 32, 0.15);
  font-size: 12px;
  color: rgba(42, 36, 32, 0.65);
}
@media (prefers-reduced-motion: reduce) {
  #logo, #logo:hover, #logo[aria-expanded="true"], #about, #about.open, #about > *, #about.open > * { transition: none; }
}

.note {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  text-align: center;
}
