/* Journey across Poland: overview map, scenes, word bubble, passport. Uses the tokens from app.css. */

:root {
  --map-bg: #efe6d4; --map-sea: #a9d2ee; --map-land: #fbf6ea; --map-border: #8a7f6c;
  --map-river: #6aa8db; --map-route: #b9b0a2; --map-label: #3b352e; --map-stars: transparent;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --map-bg: #1d1b18; --map-sea: #1f3c56; --map-land: #2a2622; --map-border: #6c655c;
    --map-river: #3f7fb3; --map-route: #5a544d; --map-label: #e8e1d6;
  }
}
:root[data-theme="dark"] {
  --map-bg: #1d1b18; --map-sea: #1f3c56; --map-land: #2a2622; --map-border: #6c655c;
  --map-river: #3f7fb3; --map-route: #5a544d; --map-label: #e8e1d6;
}

/* ---------- overview map ---------- */
.journey { margin: 28px 0 8px; }
.journey h2 { margin-bottom: 4px; }
.journey-status { color: var(--primary); font-weight: 700; min-height: 1.5em; margin-bottom: 10px; }
.journey-tip { font-size: .9rem; margin-top: 8px; }
.journey-tip a { color: var(--primary); font-weight: 700; text-decoration: none; }
.poland-wrap {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  background: var(--map-bg);
}
.poland { display: block; width: 100%; height: auto; }
.poland-bg { fill: var(--map-bg); }
.poland-sea { fill: var(--map-sea); }
.poland-land { fill: var(--map-land); stroke: var(--map-border); stroke-width: 2; stroke-linejoin: round; }
.poland-river { fill: none; stroke: var(--map-river); stroke-width: 2.5; stroke-linecap: round; opacity: .8; }
.poland-lake { fill: var(--map-river); opacity: .7; }
.poland-stars circle { fill: var(--map-stars); }

/* Time of day tints the map. */
.poland.tod-dawn { --map-bg: #f6dccf; --map-sea: #b9cfe6; }
.poland.tod-dusk { --map-bg: #f2c9a8; --map-sea: #8fb0d6; --map-land: #fbefe0; }
.poland.tod-night { --map-bg: #1b2340; --map-sea: #22345c; --map-land: #313a57; --map-border: #6f7ba0;
  --map-label: #e6ebff; --map-route: #5d6888; --map-stars: #fff8d6; }

.route { fill: none; stroke: var(--map-route); stroke-width: 3; stroke-dasharray: 2 8; stroke-linecap: round; }
.route-done { fill: none; stroke: var(--primary); stroke-width: 4; stroke-linecap: round; opacity: 0;
  stroke-dasharray: 1000; stroke-dashoffset: 1000; transition: stroke-dashoffset 1.6s ease, opacity .3s; }
.route-done.is-done { opacity: 1; stroke-dashoffset: 0; }

.city { cursor: pointer; }
.city-halo { fill: transparent; }
.city-dot { fill: var(--surface); stroke: var(--map-route); stroke-width: 3; }
.city-num { font: 700 8px var(--font); fill: var(--map-route); text-anchor: middle; pointer-events: none; }
.city-name { font: 700 14px var(--font); fill: var(--map-label); paint-order: stroke; stroke: var(--map-land); stroke-width: 3px; }
.city.is-done .city-dot { fill: var(--ok); stroke: var(--ok); }
.city.is-done .city-num { fill: #fff; }
.city.is-current .city-dot { fill: var(--primary); stroke: var(--primary); }
.city.is-current .city-num { fill: #fff; }
.city.is-current .city-halo { fill: var(--primary); opacity: .25; transform-box: fill-box; transform-origin: center;
  animation: halo 2s ease-out infinite; }
.city:hover .city-dot, .city:focus .city-dot { stroke-width: 5; }
@keyframes halo { 0% { transform: scale(.6); opacity: .45; } 100% { transform: scale(1.8); opacity: 0; } }

.traveller { pointer-events: none; transition: transform .4s ease; }
.traveller.is-moving { transition: none; }
.traveller-bg { fill: var(--surface); stroke: var(--primary); stroke-width: 2.5; }
.traveller-body { fill: var(--primary); }
.traveller-window { fill: #dff1fb; }
.traveller-wheel { fill: #2b2b2b; }
.traveller.is-moving .traveller-body { animation: chug .25s ease-in-out infinite alternate; }
@keyframes chug { to { transform: translateY(-1.5px); } }

/* ---------- scenes ---------- */
.scene-wrap { margin: 14px 0 6px; }
.scene-city { margin: 0 0 6px; font-weight: 700; }
.scene-wrap svg.scene {
  display: block; width: 100%; height: auto; border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow); background: #f4efe4;
}
.scene-caption { font-size: .9rem; color: var(--muted); margin-top: 8px; }
.scene-hint { display: block; color: var(--text); margin-top: 2px; }

/* Sketch to colour: the scenery gains colour with progress; pieces wait as pale sketches.
   The grey tint itself is an SVG <filter> set by journey.js: WebKit ignores CSS
   filter functions on elements inside an <svg>. */
.scene .piece { transition: opacity .6s ease; }
.scene .piece:not(.is-on) { opacity: .22; }
.scene .piece-finale:not(.is-on) { opacity: 0; }
.scene .piece.is-new { animation: pop .9s cubic-bezier(.2, 1.4, .4, 1) both; transform-box: fill-box; transform-origin: center bottom; }
@keyframes pop { 0% { transform: scale(.2); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

.scene .sayable { cursor: pointer; }
.scene .sayable:focus { outline: none; }
.scene .sayable:focus-visible { filter: drop-shadow(0 0 3px var(--primary)) drop-shadow(0 0 1px var(--primary)); }
.scene .sayable.is-said { animation: said .45s ease; transform-box: fill-box; transform-origin: center bottom; }
@keyframes said { 40% { transform: translateY(-4px) scale(1.06); } }
.scene .surprise { cursor: pointer; }

/* Motion, only once a piece is alive. */
.scene .is-on .waves { animation: waves 4s linear infinite; }
.scene .is-on .waves-slow { animation-duration: 7s; }
@keyframes waves { to { transform: translateX(-40px); } }
.scene .is-on .spin { animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.scene .is-on .bob { animation: bob 2.4s ease-in-out infinite; transform-box: fill-box; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.scene .is-on .flutter { animation: flutter 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: left center; }
@keyframes flutter { 50% { transform: skewY(4deg) scaleX(.94); } }
.scene .is-on .steam { animation: steam 2.5s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom; }
@keyframes steam { 0% { opacity: .2; transform: translateY(2px); } 50% { opacity: .9; } 100% { opacity: 0; transform: translateY(-6px); } }
.scene .is-on .twinkle circle { animation: twinkle 1.6s ease-in-out infinite alternate; }
.scene .is-on .twinkle circle:nth-child(2n) { animation-delay: .8s; }
@keyframes twinkle { to { opacity: .35; } }
.scene .is-on .wave-arm { animation: wave-arm .8s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: left bottom; }
@keyframes wave-arm { to { transform: rotate(-18deg); } }
.scene .is-on .sail-in { animation: sail-in 3s ease-out both; }
@keyframes sail-in { from { transform: translateX(120px); } }
.scene .is-on .drift { animation: drift 9s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translateX(26px); } }
.scene .is-on .rain, .scene .wx-rain .rain { animation: rain .6s linear infinite; }
@keyframes rain { from { transform: translateY(-4px); opacity: .4; } to { transform: translateY(6px); opacity: 1; } }
.scene .is-on .flash { animation: flash 3s steps(1) infinite; }
@keyframes flash { 0%, 80% { opacity: 0; } 82%, 90% { opacity: 1; } }
.scene .is-on .burst { animation: burst 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes burst { 0% { transform: scale(.2); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(1.15); opacity: 0; } }
.scene .is-on .glow { animation: glow 2.4s ease-in-out infinite alternate; }
@keyframes glow { to { opacity: .55; } }
.scene .is-on .hover { animation: bob 1.6s ease-in-out infinite; transform-box: fill-box; }
.scene .is-on .flame { animation: flame .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: right center; }
@keyframes flame { to { transform: scaleX(1.3); opacity: .7; } }
.scene .is-on .fall path { animation: fall 3s ease-in infinite; }
.scene .is-on .fall path:nth-child(2) { animation-delay: 1.4s; }
@keyframes fall { from { transform: translate(0, -6px); opacity: 1; } to { transform: translate(-6px, 14px) rotate(90deg); opacity: 0; } }
.scene .is-on .jump { animation: jump 3s ease-in-out infinite; transform-box: fill-box; }
@keyframes jump { 0%, 60%, 100% { transform: translateY(8px); opacity: 0; } 70% { opacity: 1; } 80% { transform: translateY(-8px) rotate(-20deg); opacity: 1; } }
.scene .is-on .flap { animation: bob 1s ease-in-out infinite; }
.scene .is-on .train, .scene .is-on .tram { animation: arrive 2.5s ease-out both; }
@keyframes arrive { from { transform: translateX(140px); opacity: 0; } }
.scene .sun-arc, .scene .cable-cabin, .scene .boat { transition: transform 1.2s ease; }

/* Kraków: the trumpeter plays. */
.scene.is-playing [data-surprise="hejnal"] { animation: toot .3s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes toot { to { transform: scale(1.12); } }
/* Poznań: the goats butt heads. */
.scene .goat { transform-box: fill-box; }
.scene.is-butting .goat-left { animation: butt-left .7s ease-in-out var(--butts, 1); }
.scene.is-butting .goat-right { animation: butt-right .7s ease-in-out var(--butts, 1); }
@keyframes butt-left { 45% { transform: translateX(2.5px) rotate(8deg); } }
@keyframes butt-right { 45% { transform: translateX(-2.5px) rotate(-8deg); } }
/* Poznań's goats are cut out of the photo: rear from the hind hooves, gently, so the photo underneath stays hidden. */
.scene-poznan .goat { transform-origin: 50% 100%; }
.scene-poznan.is-butting .goat-left { animation-name: butt-left-photo; }
.scene-poznan.is-butting .goat-right { animation-name: butt-right-photo; }
@keyframes butt-left-photo { 45% { transform: translateX(2px) rotate(1deg); } }
@keyframes butt-right-photo { 45% { transform: translateX(-2px) rotate(-1deg); } }

/* ---------- word bubble ---------- */
.word-bubble {
  position: fixed; z-index: 20; display: flex; flex-direction: column; align-items: center;
  padding: 8px 14px; border-radius: 12px; background: var(--text); color: var(--bg);
  box-shadow: var(--shadow); pointer-events: none; max-width: min(320px, calc(100vw - 16px)); text-align: center;
}
.word-bubble-pl { font-weight: 700; font-size: 1.1rem; }
.word-bubble-tr { font-size: .85rem; opacity: .8; }

/* ---------- passport ---------- */
.passport-header { margin: 8px 0 20px; }
.stamps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.stamp-card {
  display: flex; align-items: center; gap: 16px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.stamp-card h2 { font-size: 1.15rem; margin: 0 0 2px; }
.stamp-unit { margin: 0; font-size: .8rem; color: var(--muted); }
.stamp-status { margin: 0 0 6px; font-size: .9rem; }
.stamp { width: 96px; flex: none; }
.stamp svg { display: block; width: 100%; height: auto; }
.stamp-ring { fill: none; stroke: var(--locked); stroke-width: 3; stroke-dasharray: 4 5; }
.stamp-ring-inner { stroke-width: 1.5; }
.stamp-city { font: 700 15px var(--font); text-anchor: middle; fill: var(--locked); }
.stamp-date { font: 500 10px var(--font); text-anchor: middle; fill: var(--primary); }
.stamp-stars { font: 700 12px var(--font); text-anchor: middle; fill: var(--star); letter-spacing: 1px; }
.stamp-card.is-visited .stamp svg { transform: rotate(-10deg); }
.stamp-card.is-visited .stamp-ring { stroke: var(--primary); stroke-dasharray: none; }
.stamp-card.is-visited .stamp-city { fill: var(--primary); }
.stamp-card.is-missing { opacity: .75; }
.btn-small { min-height: 38px; padding: 6px 14px; font-size: .9rem; }
.btn-postcard { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.postcard-dialog { width: min(720px, calc(100vw - 32px)); }
.postcard-image { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); aspect-ratio: 1200 / 860; }
.postcard-text { margin-top: 12px; }
.postcard-text p { margin: 0 0 4px; }
.postcard-scenes { display: none; }

@media (prefers-reduced-motion: reduce) {
  .scene *, .scene, .poland *, .traveller { animation: none !important; transition: none !important; }
}
