/* ============================================================
   The Wishing Well — styles
   Scene colors are CSS variables recomputed from the visitor's
   local date/time by js/sky.js (time of day + season).
============================================================ */
:root {
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --hand: "Segoe Print", "Bradley Hand", "Snell Roundhand", "URW Chancery L", Z003, Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --ink: #3a2812;
  --ink-soft: #6d5536;
  --paper: #f4e8cb;
  --gold-1: #fff1a6; --gold-2: #f2c440; --gold-3: #b07a14;
  --silver-1: #f6f8fb; --silver-2: #c4ccd6; --silver-3: #7b8694;
  --hud-fg: #f6eedb;
  --hud-shadow: 0 1px 2px rgba(0,0,0,.6), 0 0 12px rgba(0,0,0,.35);

  /* scene palette defaults (overwritten by JS) */
  --sky0:#3d8fd6; --sky1:#8cc6ef; --sky2:#d7ecfa; --sun:#fff3c0; --fog:#cfe3ee;
  --mtnFar:#8aa0bb; --mtnNear:#5f7891; --forestFar:#34503f;
  --groundFar:#4f6b33; --groundNear:#2e4320; --grass:#5d7f34; --path:#9b8466;
  --trunk:#5d412b; --trunkL:#8a6a4c; --trunkD:#3a2819; --birch:#e8e2d4; --birchD:#9d968a;
  --fA0:#8a3a12; --fA1:#c8641c; --fA2:#e8a23a; --fB0:#7a5a12; --fB1:#c09a24; --fB2:#e8cf5a;
  --p0:#1d3f30; --p1:#2a5640; --p2:#3d6e50;
  --stone:#9a9890; --stoneD:#5f5d58; --stoneL:#c3bfb4; --mortar:#4a4843;
  --wood:#7a5434; --woodD:#432c19; --roof:#7b3f2a; --roofD:#4d2416; --moss:#5d7a2e; --water:#0e2a3a;
  --cloud:#ffffff; --cloudOp:.85; --starsOp:0; --snow:0; --bloom:0; --rays:.0;
  --noteShade:0; --lantern:0; --veil:.16; --moonOp:0; --sunOp:1;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0b1530;
  font-family: var(--serif); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- scene ---------- */
#scene {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
#scene.dragging { cursor: grabbing; }

.st-sky0 { stop-color: var(--sky0); } .st-sky1 { stop-color: var(--sky1); } .st-sky2 { stop-color: var(--sky2); }
.st-sun { stop-color: var(--sun); } .st-fog { stop-color: var(--fog); }
.st-groundFar { stop-color: var(--groundFar); } .st-groundNear { stop-color: var(--groundNear); }
.st-trunk { stop-color: var(--trunk); } .st-trunkL { stop-color: var(--trunkL); } .st-trunkD { stop-color: var(--trunkD); }
.st-birch { stop-color: var(--birch); } .st-birchD { stop-color: var(--birchD); }
.st-wood { stop-color: var(--wood); } .st-woodD { stop-color: var(--woodD); }
.st-stoneD { stop-color: var(--stoneD); } .st-water { stop-color: var(--water); }

.c-sunDisk { fill: var(--sun); }
#sun { opacity: var(--sunOp); }
#moon { opacity: var(--moonOp); }
#stars { opacity: var(--starsOp); }
.c-mtnFar { fill: var(--mtnFar); } .c-mtnNear { fill: var(--mtnNear); } .c-forestFar { fill: var(--forestFar); }
.c-snowcap { fill: #f4f7fb; opacity: calc(.35 + var(--snow) * .65); }
.c-cloud { fill: var(--cloud); opacity: var(--cloudOp); }
#rays { opacity: var(--rays); mix-blend-mode: screen; }
.c-grass { fill: var(--grass); } .c-path { fill: var(--path); }
.c-trunkD { fill: var(--trunkD); } .c-bark { stroke: var(--trunkD); fill: none; stroke-linecap: round; opacity: .55; }
.c-branch { stroke: var(--trunk); fill: none; stroke-linecap: round; }
.c-birchMark { fill: #2b2620; opacity: .7; }
.fA0 { fill: var(--fA0); } .fA1 { fill: var(--fA1); } .fA2 { fill: var(--fA2); }
.fB0 { fill: var(--fB0); } .fB1 { fill: var(--fB1); } .fB2 { fill: var(--fB2); }
.p0 { fill: var(--p0); } .p1 { fill: var(--p1); } .p2 { fill: var(--p2); }
.c-snow { fill: #f4f8fc; opacity: var(--snow); }
.c-snowline { fill: none; stroke: #f4f8fc; opacity: var(--snow); }
.c-bloom { fill: #ffc4dc; opacity: var(--bloom); }
.c-stone { fill: var(--stone); } .c-stoneD { fill: var(--stoneD); } .c-stoneL { fill: var(--stoneL); }
.c-mortar { fill: var(--mortar); stroke: var(--mortar); }
.c-wood { fill: var(--wood); } .c-woodD { fill: var(--woodD); }
.c-roof { fill: var(--roof); } .c-roofD { fill: var(--roofD); }
.c-moss { fill: var(--moss); opacity: .8; }
.c-rope { stroke: #c7a676; fill: none; }
.veil { opacity: var(--veil); pointer-events: none; }
.lantern-glow { opacity: var(--lantern); }
.lantern-flame { fill: #ffd27a; opacity: calc(.25 + var(--lantern) * .75); }

.twinkle { animation: twinkle 3.2s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .25; } to { opacity: 1; } }

/* ---------- wish notes on trees ---------- */
.note { cursor: pointer; }
#rows use, #rows .veil, #rows rect, #rows circle:not(.note *) { pointer-events: none; }
.note .sway { transform-box: fill-box; transform-origin: 50% 10%; animation: sway 6s ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }
.note-text { font-family: var(--hand); font-style: italic; pointer-events: none; }
.note-shade { fill: #0a1230; opacity: var(--noteShade); pointer-events: none; }
.note-glow { opacity: calc(.25 + var(--noteShade) * 1.2); pointer-events: none; }
.note .sparkle { fill: #fffbe0; transform-box: fill-box; transform-origin: center;
  animation: glint 2.6s ease-in-out infinite; }
@keyframes glint { 0%, 70%, 100% { transform: scale(0); } 80% { transform: scale(1); } }
.note.highlight .paper { stroke: #fff6c4 !important; stroke-width: 5 !important; }
.note.highlight { animation: pulse 1.2s ease-in-out 4; }
@keyframes pulse { 50% { opacity: .55; } }
.note:focus { outline: none; }
.note:focus-visible .paper { stroke: #fff; stroke-width: 4; }
#focusLayer, #wellBack, #wellFront, #actors, #particles, #groundFront, #rays, #clouds, #sun, #moon, #stars { pointer-events: none; }
#focusLayer .note { animation: pop .18s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes pop { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .note .sway, .twinkle, .note .sparkle { animation: none; }
}

/* ---------- HUD ---------- */
.hud { position: fixed; left: 0; right: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; padding: max(14px, env(safe-area-inset-top)) 20px 14px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top { top: 0; align-items: flex-start; }
.hud-bottom { bottom: 0; padding-bottom: max(18px, env(safe-area-inset-bottom)); align-items: flex-end; }
.brand { color: var(--hud-fg); text-shadow: var(--hud-shadow); }
.brand h1 { margin: 0; font-weight: normal; font-size: clamp(20px, 2.4vw, 34px); letter-spacing: .04em; font-style: italic; }
.clock { font-size: 13px; opacity: .85; letter-spacing: .03em; margin-top: 2px; }
.position { color: var(--hud-fg); text-shadow: var(--hud-shadow); font-size: 13px; min-width: 120px; text-align: right; opacity: .9; }
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--hud-fg); text-shadow: var(--hud-shadow);
  font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; opacity: .85; min-width: 120px; text-align: left; }
.link-btn:hover { opacity: 1; }
dialog .link-btn { color: var(--ink-soft); text-shadow: none; min-width: 0; }
.link-btn.danger { color: #9b2c1c; }

.btn { border: 0; cursor: pointer; border-radius: 999px; padding: 11px 22px; font-size: 16px; line-height: 1.2;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; filter: grayscale(.7) brightness(.85); opacity: .7; }
.btn:focus-visible, .link-btn:focus-visible, .pan-btn:focus-visible, .uuid:focus-visible {
  outline: 3px solid #ffe28a; outline-offset: 3px; }
.btn.small { padding: 7px 14px; font-size: 14px; }

.btn-wood { color: #fbefd4; background: linear-gradient(#8a5d36, #5c3a1e); border: 1px solid #3b240f;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 3px 10px rgba(0,0,0,.35); text-shadow: 0 1px 0 rgba(0,0,0,.5); }
.btn-wood.ghost { background: rgba(80,50,25,.12); color: var(--ink); border-color: rgba(60,36,15,.4); text-shadow: none; box-shadow: none; }
.btn-gold { color: #4a3205; font-weight: bold; background: linear-gradient(160deg, var(--gold-1), var(--gold-2) 45%, var(--gold-3));
  border: 1px solid #8a5f0e; box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 4px 14px rgba(176,122,20,.45); }
.btn-silver { color: #232b35; font-weight: bold; background: linear-gradient(160deg, var(--silver-1), var(--silver-2) 50%, var(--silver-3));
  border: 1px solid #5d6672; box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 4px 14px rgba(60,70,85,.35); }
.btn.choice[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }
.btn.choice[aria-pressed="true"]::before { content: "✓ "; }

.btn-coin { display: inline-flex; align-items: center; gap: 10px; font-size: 19px; padding: 13px 28px 13px 16px;
  color: #fbefd4; background: linear-gradient(#7c5230, #4e3119); border: 1px solid #2f1c0b;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 6px 20px rgba(0,0,0,.45); text-shadow: 0 1px 0 rgba(0,0,0,.5); }
.coin-ico { width: 28px; height: 28px; border-radius: 50%; display: inline-block;
  background: radial-gradient(circle at 38% 32%, #fff6c4, #f6cf4f 35%, #c48b1c 75%, #7d5410);
  box-shadow: 0 0 0 2px #7d5410 inset, 0 0 10px rgba(255,214,90,.7); animation: coinspin 3s ease-in-out infinite; }
@keyframes coinspin { 0%, 60%, 100% { transform: scaleX(1); } 70% { transform: scaleX(.1); } 80% { transform: scaleX(1); } }

.pan-btn { position: fixed; top: 50%; z-index: 15; transform: translateY(-50%); width: 56px; height: 84px; border-radius: 28px;
  border: 1px solid rgba(255,255,255,.25); background: rgba(10,16,24,.28); color: #fff; cursor: pointer;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0; transition: background .15s, opacity .3s; }
.pan-btn span { font-size: 40px; line-height: .8; }
.pan-btn small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.pan-btn:hover { background: rgba(10,16,24,.5); }
.pan-btn[disabled] { opacity: .15; cursor: default; }
.pan-left { left: 14px; } .pan-right { right: 14px; }

.toast { position: fixed; left: 50%; top: 80px; transform: translate(-50%, -20px); z-index: 100;
  background: rgba(20,14,8,.88); color: #fbefd4; padding: 10px 18px; border-radius: 10px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: min(90vw, 460px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; color: var(--ink); max-width: min(92vw, 500px); width: 100%; }
dialog::backdrop { background: rgba(5,10,20,.35); backdrop-filter: blur(1.5px); }
dialog[open] { animation: dlgIn .28s cubic-bezier(.2,.9,.3,1.2); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }

.parchment { padding: 30px 32px 26px; border-radius: 6px; position: relative;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255,255,255,.55), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(140,95,40,.22), transparent 60%),
    linear-gradient(170deg, #f8eed5, #ecdab2);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 0 0 1px rgba(120,85,40,.35), 0 0 40px rgba(110,70,20,.25) inset,
    0 24px 60px rgba(0,0,0,.5); }
.parchment::after { content: ""; position: absolute; inset: 8px; border: 1px dashed rgba(110,80,40,.25); border-radius: 4px; pointer-events: none; }
.parchment h2 { margin: 0 0 4px; font-weight: normal; font-style: italic; font-size: 28px; }
.composer { margin-top: 7vh; }
.x { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; z-index: 2;
  background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink-soft); }
.x:hover { background: rgba(80,50,20,.1); }
.hint { margin: 2px 0 14px; color: var(--ink-soft); font-size: 14px; }
.hint.small, .small { font-size: 12.5px; }
.error { min-height: 1.2em; margin: 6px 0; color: #9b2c1c; font-size: 14px; }
.error:empty { min-height: 0; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--ink-soft); }
.question { margin: 14px 0 0; text-align: center; font-style: italic; }
.prose { font-size: 15px; line-height: 1.5; }
.prose ul { padding-left: 20px; }

.wish-input, .mono-input { width: 100%; padding: 12px 14px; border-radius: 4px; color: var(--ink);
  background: rgba(255,252,240,.7); border: 1px solid rgba(110,80,40,.45);
  box-shadow: inset 0 2px 4px rgba(90,60,20,.15); outline: none; }
.wish-input { font-family: var(--hand); font-style: italic; font-size: 24px; }
.mono-input { font-family: var(--mono); font-size: 15px; }
.wish-input:focus, .mono-input:focus { border-color: #8a5d36; box-shadow: inset 0 2px 4px rgba(90,60,20,.15), 0 0 0 3px rgba(242,196,64,.4); }
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.count { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.count.full { color: #9b2c1c; }
.composer .btn-gold { display: block; width: 100%; margin-top: 8px; font-size: 18px; padding: 14px; }

.seg { display: inline-flex; border-radius: 999px; background: rgba(90,60,25,.12); padding: 3px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 14px; border-radius: 999px; font-size: 14px; transition: background .15s, color .15s; }
.seg input:checked + span { background: #6b4526; color: #fbefd4; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.seg input:focus-visible + span { outline: 2px solid #8a5d36; outline-offset: 1px; }
.small-seg { display: flex; width: fit-content; margin: 16px auto 0; }
.small-links { justify-content: space-between; margin-top: 18px; }

.wish-quote { margin: 10px 0 6px; padding: 18px 20px; font-family: var(--hand); font-style: italic; font-size: 26px;
  line-height: 1.35; text-align: center; word-break: break-word; border-radius: 4px;
  background: rgba(255,250,235,.55); box-shadow: inset 0 0 0 1px rgba(110,80,40,.2); }
.wish-quote.gold { background: linear-gradient(150deg, #fff4bf, #f0c64e 50%, #c9952a); color: #4a3205; box-shadow: 0 0 22px rgba(240,198,78,.55); }
.wish-quote.silver { background: linear-gradient(150deg, #fafbfd, #c9d1db 50%, #97a2b0); color: #232b35; }

/* ---------- splash ---------- */
.splash { max-width: none; width: 100vw; height: 100vh; height: 100dvh; max-height: none; margin: 0; background: transparent; overflow: hidden; }
.splash::backdrop { background: rgba(80,140,200,.18); backdrop-filter: blur(5px) saturate(1.3); -webkit-backdrop-filter: blur(5px) saturate(1.3); }
.splash[open] { animation: none; display: grid; place-items: center; }
.splash-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.splash-art .blob { transform-box: fill-box; transform-origin: center; animation: splat .55s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes splat { from { transform: scale(0); opacity: 0; } 40% { opacity: 1; } }
.splash-art .drip { animation: drip 4.5s cubic-bezier(.5,0,.8,.6) both; }
@keyframes drip { from { transform: translateY(-40px); opacity: 0; } 12% { opacity: 1; } to { transform: translateY(var(--fall, 600px)); opacity: 0; } }
.splash-card { position: relative; z-index: 1; color: #fff; text-align: center; padding: 34px 32px 26px; width: min(92vw, 540px);
  border-radius: 28px; background: radial-gradient(ellipse at 50% 40%, rgba(10,45,80,.42), rgba(10,45,80,.18) 70%, transparent);
  text-shadow: 0 1px 3px rgba(0,30,60,.6); animation: cardIn .7s .35s cubic-bezier(.2,1.2,.4,1) both; }
@keyframes cardIn { from { opacity: 0; transform: scale(.85); } }
.splash-card h2 { margin: 0 0 6px; font-weight: normal; font-style: italic; font-size: 30px; }
.splash-card p { margin: 6px auto; max-width: 420px; font-size: 15px; }
.uuid { display: block; margin: 14px auto 4px; padding: 12px 16px; border-radius: 10px; cursor: copy; max-width: 100%;
  font: 600 clamp(13px, 3.6vw, 17px)/1.3 var(--mono); letter-spacing: .03em; color: #06263f; word-break: break-all;
  background: rgba(255,255,255,.82); border: 1px solid rgba(255,255,255,.9); box-shadow: 0 6px 20px rgba(0,40,80,.35);
  user-select: all; -webkit-user-select: all; text-shadow: none; }
.btn-glass { color: #fff; background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.55);
  backdrop-filter: blur(4px); text-shadow: 0 1px 2px rgba(0,30,60,.5); }
.btn-glass:hover { background: rgba(255,255,255,.3); }
.btn-glass.ghost { background: transparent; }

/* ---------- consent ---------- */
.consent { position: fixed; z-index: 30; left: 16px; bottom: 56px; width: min(calc(100vw - 32px), 400px);
  padding: 14px 18px; border-radius: 10px; color: var(--ink); font-size: 14px;
  background: linear-gradient(170deg, #f8eed5, #ecdab2); box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.consent p { margin: 0; }
.consent .row { justify-content: flex-end; margin-top: 8px; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; color: #fff; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .hud { padding-left: 12px; padding-right: 12px; }
  .pan-btn { width: 40px; height: 64px; top: auto; bottom: 92px; transform: none; }
  .pan-btn span { font-size: 30px; }
  .pan-btn small { display: none; }
  .position, .link-btn { min-width: 0; font-size: 11px; }
  .btn-coin { font-size: 17px; padding: 11px 20px 11px 12px; }
  .parchment { padding: 26px 18px 20px; }
  .composer { margin-top: 3vh; }
  .wish-quote { font-size: 22px; }
  .hud-bottom { gap: 8px; }
  .consent { bottom: 150px; }
}
@media (max-height: 520px) {
  .composer { margin-top: 1vh; }
  .parchment { padding-top: 18px; padding-bottom: 14px; }
}
