:root {
  color-scheme: dark;
  --ink: #f4ecdc;
  --ink-soft: rgba(244, 236, 220, 0.72);
  --glass: rgba(20, 17, 14, 0.5);
  --paper: #f3ead8;
  --paper-ink: #3a2a20;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #14120f;
  color: var(--ink);
  font: 15px/1.5 var(--serif);
}

/* the paintings fade in gently once the first one has arrived */
#view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
  cursor: grab;
  opacity: 0;
  transition: opacity 1.6s ease;
}
body.ready #view { opacity: 1; }
#view:active { cursor: grabbing; }
body.changing #view { opacity: 0; transition-duration: 0.6s; }

/* the title card: a soft veil and a few words, lifting away on the first touch or after a while */
#veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 28%, rgba(12, 10, 8, 0.55) 0%, rgba(12, 10, 8, 0.1) 60%);
  transition: opacity 2.4s ease;
}
/* in the upper third: the middle of the picture is where the journey goes, so it stays clear */
#title {
  position: fixed;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  width: min(34rem, calc(100vw - 32px));
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: opacity 2.4s ease, transform 2.4s ease;
}
#title h1 {
  margin: 0 0 0.4em;
  font-weight: 400;
  font-size: clamp(2.4rem, 8vw, 4.6rem);
  letter-spacing: 0.02em;
  line-height: 1.05;
}
#title p { margin: 0.2em 0; font-size: clamp(1rem, 2.6vw, 1.2rem); color: var(--ink-soft); }
#title .hint { margin-top: 1.4em; font-size: 0.95rem; font-style: italic; opacity: 0.85; }
body.begun #veil, body.begun #title { opacity: 0; }
body.begun #title { transform: translate(-50%, -46%); }

/* the controls: quiet, at the bottom, gone whenever you are just watching */
#controls {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
#controls button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
#controls button:hover, #controls button:focus-visible { background: rgba(255, 255, 255, 0.12); outline: none; }
#controls button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.2); }
#controls svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#controls .when-paused { display: none; }
body.paused #controls .when-playing { display: none; }
body.paused #controls .when-paused { display: block; }
#controls .when-sound { display: none; }
body.sound #controls .when-quiet { display: none; }
body.sound #controls .when-sound { display: block; }
body.idle #controls { opacity: 0; transform: translate(-50%, 10px); pointer-events: none; }
body.idle, body.idle #view { cursor: none; }

/* a short message, for "link copied" and the like */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 0.95rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
#toast.show { opacity: 1; }

/* the about box, on paper */
#about {
  width: min(34rem, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 1.6rem 1.8rem 1.4rem;
  border: 0;
  border-radius: 6px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  font-size: 1rem;
}
#about::backdrop { background: rgba(10, 8, 6, 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
#about h2 { margin: 0 0 0.5em; font-weight: 400; font-size: 1.9rem; }
#about h3 { margin: 1.2em 0 0.3em; font-weight: 400; font-size: 1.15rem; }
#about p, #about li { margin: 0.5em 0; }
#about ul { padding-left: 1.2em; margin: 0.3em 0; }
#about a { color: #8a3a2a; }
#about .credit { margin-top: 1.2em; font-style: italic; opacity: 0.8; }
#about form { margin-top: 1.2em; text-align: right; }
#about form button {
  font: inherit;
  padding: 0.45em 1em;
  border: 1px solid rgba(58, 42, 32, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--paper-ink);
  cursor: pointer;
}
#about form button:hover { background: rgba(58, 42, 32, 0.08); }

/* loading, only if it takes a while */
#status {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-soft);
  pointer-events: none;
}
#status[hidden] { display: none; }
#status a { color: inherit; }

/* the journey panel, for testing only */
#hud {
  position: fixed;
  left: 16px;
  top: 16px;
  width: min(330px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--glass);
  font: 13px/1.45 system-ui, sans-serif;
}
#hud[hidden] { display: none; }
#route { list-style: none; margin: 10px 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
#route li { display: flex; align-items: center; gap: 5px; padding: 2px 8px 2px 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); opacity: 0.7; }
#route li.now { opacity: 1; background: rgba(255, 255, 255, 0.22); }
#route i { width: 14px; height: 14px; border-radius: 50%; }
#orders { opacity: 0.7; font-size: 12px; }

/* recording a preview: nothing but the picture */
body.capture #veil, body.capture #title, body.capture #controls, body.capture #toast, body.capture #status { display: none; }
body.capture #view { opacity: 1; transition: none; }

.plain { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  #view, #veil, #title, #controls, #toast { transition-duration: 0.01s; }
}
