/* Treasure Map: the map view on village.html (js/treasure-map.js), the decoration shelf
   (js/village-deco.js), and the home page hero (index.html, js/home-treasure.js).
   The map itself is a parchment world with its own colours, like the village scene. Panels
   sit on the site's solid cards so they read on every page scene and theme. */

/* ── Village <-> Map switch ─────────────────────────────────────────── */
.vl-view { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.vl-view[hidden] { display: none; }
.vl-hud-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; justify-content: flex-end; }
.vl-tab-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid color-mix(in srgb, var(--purple) 55%, var(--btn-border));
  background: var(--purple); color: #fff; font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.vl-tab-btn:hover { background: var(--purple-dark, #3C3489); color: #fff; }   /* beats main.css button:hover, which went white */
.vl-tab-ico { margin-right: 6px; position: relative; display: inline-grid; place-items: center; }
.vl-tab-badge { position: absolute; right: -7px; bottom: -6px; display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: #fff; color: var(--purple); font-size: 9px !important; line-height: 1; box-shadow: 0 0 0 1.5px var(--purple); }
.vl-tab-btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.vl-tab-btn i { font-size: 17px; line-height: 1; }

/* ── Map view ───────────────────────────────────────────────────────── */
.tz-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.tz-pill { display: inline-flex; gap: 6px; align-items: center; padding: 6px 13px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--toolbar-border, var(--btn-border));
  font-size: 13.5px; font-weight: 700; color: var(--btn-text); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.tz-pill b { color: var(--purple); font-weight: 900; font-variant-numeric: tabular-nums; }

.tz-stage { position: relative; border-radius: 14px; overflow: hidden; background: #9FD0D6; min-height: 220px; }
.tz-stage svg { display: block; width: 100%; height: auto; }
.tz-stage > .vl-loading { position: static; min-height: 220px; }
.tz-stage.is-preview svg { filter: saturate(.5) brightness(1.08); opacity: .55; }
.tz-title { fill: #5A3B1A; font-family: inherit; font-weight: 900; letter-spacing: .02em; }
.tz-lbl { fill: #5A3B1A; font-family: inherit; font-weight: 800; }
.tz-trail { fill: none; stroke: var(--tz-trail, #8A6A3C); stroke-width: 3; stroke-dasharray: 2 9; stroke-linecap: round; }
.tz-trail.is-sea:not(.is-done) { stroke: #fff; opacity: .85; }   /* the crossing between islands is over open sea */
.tz-trail.is-done { stroke: #A5361F; stroke-width: 4; stroke-dasharray: none; opacity: .85; }
.tz-step { cursor: pointer; }
.tz-step:focus { outline: none; }
.tz-hit { fill: transparent; }
.tz-dot { fill: #fff; stroke: #5A3B1A; stroke-width: 2.5; }
.tz-step.is-done .tz-dot { fill: #A5361F; }
.tz-step.is-next .tz-dot { fill: #FFE27A; stroke: #A5361F; }
.tz-step:hover .tz-dot, .tz-step:focus-visible .tz-dot { stroke: #A5361F; stroke-width: 4; }
.tz-stage.is-preview .tz-step { cursor: default; }
html:not([data-reduce-motion]) .tz-step.is-next .tz-dot { animation: tz-beat 1.3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes tz-beat { 50% { transform: scale(1.35); } }
.tz-chest { cursor: pointer; }
.tz-chest.is-locked { opacity: .6; }
.tz-chest:focus { outline: none; }
.tz-ring { fill: none; stroke: #A5361F; stroke-width: 3; stroke-dasharray: 4 4; opacity: 0; }
.tz-chest.is-next .tz-ring, .tz-chest:hover .tz-ring, .tz-chest:focus-visible .tz-ring { opacity: 1; }
.tz-stage.is-preview .tz-chest { cursor: default; }
.tz-stage.is-preview .tz-chest:hover .tz-ring { opacity: 0; }
html:not([data-reduce-motion]) .tz-pawn { transition: transform .6s ease; }
html:not([data-reduce-motion]) .tz-chest.is-next .tz-ring { transform-box: fill-box; transform-origin: center; animation: tz-spin 9s linear infinite; }
@keyframes tz-spin { to { transform: rotate(360deg); } }

.tz-below { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 14px; align-items: start; }
@media (max-width: 760px) { .tz-below { grid-template-columns: minmax(0, 1fr); } }
/* Start / finished card over the faded map */
.tz-map-card { position: relative; }
.tz-cover { position: absolute; inset: 10px; z-index: 1; display: grid; place-items: center; padding: 16px; border-radius: 14px; background: rgba(241, 223, 180, .35); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); overflow-y: auto; }
.tz-cover[hidden] { display: none; }
.tz-cover-card { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 440px; padding: 22px 22px 20px; border-radius: 20px; background: var(--surface); color: var(--btn-text); border: 1.5px solid var(--toolbar-border, var(--btn-border)); box-shadow: 0 12px 36px rgba(0,0,0,.28); }
.tz-cover-card h2 { margin: 0; font-size: 22px; line-height: 1.15; }
.tz-hud { z-index: 2; }
.tz-eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--text-muted) 55%, var(--btn-text)); }
.tz-eyebrow-sm { margin-bottom: 6px; }
.tz-note { margin: 0; font-size: 13.5px; line-height: 1.5; color: color-mix(in srgb, var(--text-muted) 45%, var(--btn-text)); }
.tz-prog { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 14px; font-weight: 800; color: var(--btn-text); }
.tz-bar { height: 12px; border-radius: 99px; background: color-mix(in srgb, var(--purple) 16%, var(--surface-2, var(--surface))); overflow: hidden; }
.tz-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--purple); transition: width .4s; }
.tz-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tz-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1.5px solid var(--toolbar-border, var(--btn-border));
  background: var(--surface); color: var(--btn-text); font: inherit; font-size: 14px; font-weight: 800; text-decoration: none; cursor: pointer; line-height: 1.2; text-align: center; }
.tz-btn.is-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.tz-btn:hover { background: color-mix(in srgb, var(--purple) 10%, var(--surface)); }
.tz-btn.is-primary:hover { background: var(--purple-dark, #3C3489); }
.tz-btn:disabled { opacity: .6; cursor: default; }
.tz-btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }

.tz-start-lbl { fill: #fff; font-family: inherit; font-weight: 900; letter-spacing: .12em; }
.tz-chest.is-ready .tz-ring { opacity: 1; stroke: #D79A1C; stroke-width: 5; stroke-dasharray: none; }
html:not([data-reduce-motion]) .tz-chest.is-ready .tz-ring { animation: tz-ready 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes tz-ready { 50% { transform: scale(1.18); opacity: .55; } }

/* Step popup */
.tz-modal { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 16px; background: rgba(20,16,50,.55); }
.tz-modal[hidden] { display: none; }
.tz-modal-card { position: relative; box-sizing: border-box; width: 100%; max-width: 460px; max-height: calc(100dvh - 32px); overflow-y: auto; padding: 22px 20px 20px; border-radius: 20px;
  background: var(--surface); color: var(--btn-text); border: 1.5px solid var(--toolbar-border, var(--btn-border)); box-shadow: 0 16px 48px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 14px; }
.tz-modal-card h2 { margin: 0; padding-right: 34px; font-size: 21px; }
.tz-modal-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--text-muted) 16%, var(--surface)); color: var(--btn-text); font-size: 22px; line-height: 1; cursor: pointer; }
.tz-modal-close:hover { background: color-mix(in srgb, var(--text-muted) 28%, var(--surface)); }
.tz-modal-close:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.tz-pick { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; border: 1.5px solid var(--toolbar-border, var(--btn-border)); background: color-mix(in srgb, var(--purple) 5%, var(--surface)); }
.tz-pick.is-now { border-color: var(--purple); }
.tz-pick.is-done { opacity: .75; }
.tz-pick-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.tz-pick-head span { font-weight: 700; color: color-mix(in srgb, var(--text-muted) 45%, var(--btn-text)); }
.tz-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; }

/* Chest reveal */
.tz-reveal { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.tz-loot { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tz-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--toolbar-border, var(--btn-border)); font-size: 15px; font-weight: 800; color: var(--btn-text); }
.tz-chip i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.tz-reveal-deco { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid #D79A1C; background: color-mix(in srgb, #F0B83E 14%, var(--surface)); text-align: left; }
.tz-reveal-deco b { display: block; font-size: 15px; }
.tz-reveal-deco span { font-size: 13px; color: color-mix(in srgb, var(--text-muted) 45%, var(--btn-text)); }
html:not([data-reduce-motion]) .tz-reveal-chest { animation: tz-pop .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes tz-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.tz-open { width: 100%; }
.tz-modal .tz-actions { justify-content: center; }
.tz-modal .tz-actions .tz-btn { min-width: 160px; }

/* A game to pick: icon tile, name, Play. Used in the step popup and on the home hero. */
.tz-games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .tz-games { grid-template-columns: minmax(0, 1fr); } .tz-games .tz-game { flex-direction: row; text-align: left; padding: 10px 14px; } .tz-games .tz-game-go { margin-left: auto; } }
.tz-game { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 10px 12px; min-width: 0; text-align: center; text-decoration: none; color: var(--btn-text);
  background: var(--surface); border: 1.5px solid var(--toolbar-border, var(--btn-border)); border-radius: 16px; box-shadow: 0 2px 0 color-mix(in srgb, var(--purple) 18%, transparent); transition: transform .12s, border-color .12s, box-shadow .12s; }
a.tz-game:hover { border-color: var(--g, var(--purple)); transform: translateY(-2px); box-shadow: 0 5px 14px color-mix(in srgb, var(--g, var(--purple)) 28%, transparent); }
a.tz-game:focus-visible { outline: 3px solid var(--g, var(--purple)); outline-offset: 2px; }
.tz-game-icon { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--gbg, color-mix(in srgb, var(--purple) 12%, var(--surface))); color: var(--g, var(--purple)); }
.tz-game-icon svg { width: 30px; height: 30px; }
.tz-game-name { font-size: 14.5px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.tz-game-go { margin-top: auto; padding: 4px 16px; border-radius: 999px; background: var(--g, var(--purple)); color: #fff; font-size: 13px; font-weight: 800; }
.tz-game.is-off { opacity: .55; box-shadow: none; }
.tz-game.is-off .tz-game-icon svg { filter: grayscale(1); }
html[data-reduce-motion] a.tz-game { transition: none; }
html[data-reduce-motion] a.tz-game:hover { transform: none; }

/* Home hero "now" card: heading and progress on top, the three games below */
.tz-home-now { display: flex; flex-direction: column; gap: 14px; }
.tz-now-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.tz-now-top > div { flex: 1 1 280px; min-width: 0; }
.tz-maplink { font-size: 14px; font-weight: 800; color: color-mix(in srgb, var(--purple) 75%, var(--btn-text)); text-decoration: none; white-space: nowrap; }
.tz-maplink:hover { text-decoration: underline; }

/* ── Decorations: shelf + placement spots ───────────────────────────── */
.vl-decos { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.vl-deco-item { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 118px; padding: 10px 8px; text-align: center; font: inherit; color: var(--btn-text);
  background: color-mix(in srgb, var(--purple) 5%, var(--surface)); border: 1.5px solid var(--toolbar-border, var(--btn-border)); border-radius: 14px; cursor: pointer; }
.vl-deco-item b { font-size: 13.5px; }
.vl-deco-item span { font-size: 12px; color: color-mix(in srgb, var(--text-muted) 45%, var(--btn-text)); }
.vl-deco-item:hover { background: color-mix(in srgb, var(--purple) 12%, var(--surface)); }
.vl-deco-item.is-sel { border-color: var(--purple); box-shadow: 0 0 0 2px var(--purple) inset; }
.vl-deco-item:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.vl-deco-away { align-self: center; }
.vd-icon { display: block; overflow: visible; }
.vl-spot-btn { position: absolute; z-index: 3; padding: 0; background: transparent; border: 0; border-radius: 12px; cursor: pointer; }
.vl-spot-btn.is-free { border: 3px dashed #fff; background: rgba(255,255,255,.28); box-shadow: 0 0 0 2px rgba(46,42,85,.55); }
.vl-spot-btn.is-placed:hover { background: rgba(255,255,255,.18); }
.vl-spot-btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
html:not([data-reduce-motion]) .vl-spot-btn.is-free { animation: tz-pulse 1.4s ease-in-out infinite; }
@keyframes tz-pulse { 50% { background: rgba(255,255,255,.5); } }

/* ── Home hero (index.html #treasure-wrap) — reuses the .ms-card banner from lander.css ── */
.tz-home .ms-card { border-color: color-mix(in srgb, #D79A1C 55%, var(--btn-border)); }
.tz-home .ms-kicker { background: color-mix(in srgb, #F0B83E 22%, var(--surface)); color: color-mix(in srgb, #8A5A00 80%, var(--btn-text)); }
.tz-route { display: flex; align-items: center; gap: 0; margin: 0 0 16px; padding: 4px 2px; overflow-x: auto; }
.tz-node { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; width: 52px; font-size: 12px; font-weight: 800; color: color-mix(in srgb, var(--text-muted) 55%, var(--btn-text)); }
.tz-node svg { width: 40px; height: 36px; display: block; }
.tz-node.is-lock svg { opacity: .45; }
.tz-node.is-next { color: var(--purple); }
.tz-node.is-open { color: #15803D; }
.tz-node.is-ready { color: #B45309; }
.tz-node.is-ready svg { filter: drop-shadow(0 0 6px #F0B83E); }
.tz-link { flex: 1 0 14px; height: 4px; border-radius: 4px; margin-bottom: 18px; background: repeating-linear-gradient(90deg, var(--toolbar-border, var(--btn-border)) 0 6px, transparent 6px 12px); }
.tz-link.is-done { background: #A5361F; opacity: .8; }
.tz-home-now { padding: 16px; border-radius: 16px; background: color-mix(in srgb, var(--purple) 5%, var(--surface)); border: 1.5px solid var(--toolbar-border, var(--btn-border)); }
.tz-home-now h3 { margin: 0 0 6px; font-size: 18px; font-weight: 800; color: var(--btn-text); overflow-wrap: anywhere; }

#tz-modal-body { display: flex; flex-direction: column; gap: 14px; }

/* On phones the HUD sits above the map in the flow; keep it clickable above the start card */
@media (max-width: 640px) { .tz-hud { position: relative; } }

/* Treasure hero art: a pirate Blip standing in a heap of treasure, so it needs more room than the milestone banner */
.tz-home .ms-art { flex-basis: 340px; height: 200px; }
@media (max-width: 640px) { .tz-home .ms-art { flex-basis: auto; height: 170px; max-width: 320px; } }
