/* The iGlowly Wall: a full-screen pannable wall (world) on iGlowly's almost-black; HUD fixed on the edges: title
   top-left, language top-right, colour tray bottom-centre, zoom bottom-left, small map bottom-right. Single dark look
   by choice. Note colours: the same pairs are in src/og.js (preview images) and wall.js (story image). */
:root {
  color-scheme: dark;
  --wall: #1d1127;            /* iGlowly --ink "body-black" */
  --wall-glow-1: rgb(124 69 166 / 0.30); /* glow-violet */
  --wall-glow-2: rgb(246 96 138 / 0.14); /* accent pink */
  --wall-glow-3: rgb(18 182 176 / 0.10); /* glow-teal */
  --hud: rgb(255 255 255 / 0.07);
  --hud-line: rgb(255 255 255 / 0.12);
  --hud-text: #efe9f6;
  --hud-muted: rgb(239 233 246 / 0.62);
  --dot: rgb(255 255 255 / 0.07);
  --thread: rgb(255 255 255 / 0.24);
  --focus: #fde4eb;
  --font-ui: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-hand: "Caveat", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --note-w: 190px;
}
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; overscroll-behavior: none;
  font-family: var(--font-ui); color: var(--hud-text);
  background:
    radial-gradient(60vmax 50vmax at 8% 0%, var(--wall-glow-1), transparent 70%),
    radial-gradient(55vmax 45vmax at 100% 100%, var(--wall-glow-2), transparent 70%),
    radial-gradient(40vmax 35vmax at 70% 20%, var(--wall-glow-3), transparent 70%),
    var(--wall);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- wall ---------- */
#vp {
  position: fixed; inset: 0; touch-action: none; cursor: grab;
  background-image: radial-gradient(circle, var(--dot) 1.2px, transparent 1.6px);
}
#vp.grabbing { cursor: grabbing; }
body.armed #vp { cursor: crosshair; }
#world { position: absolute; left: 0; top: 0; width: 3200px; height: 2200px; transform-origin: 0 0; will-change: transform; }
#threads { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#threads line { stroke: var(--thread); stroke-width: 2; stroke-dasharray: 3 7; stroke-linecap: round; }

/* ---------- notes ---------- */
.note {
  position: absolute; width: var(--note-w); box-sizing: border-box; min-height: 150px;
  padding: 24px 16px 8px; display: flex; flex-direction: column; gap: 8px;
  background: var(--bg); color: var(--ink);
  border-radius: 2px 2px 4px 16px / 2px 2px 4px 10px;
  transform: rotate(var(--r, 0deg));
  box-shadow: 0 14px 22px -10px rgb(0 0 0 / 0.6), 0 2px 4px rgb(0 0 0 / 0.28), inset 0 -12px 18px -14px rgb(0 0 0 / 0.18);
  user-select: none; -webkit-user-select: none;
}
.note:hover, .note.open { z-index: 5; }
.c-butter { --bg: #f6d98b; --ink: #4a3a10; }
.c-peach  { --bg: #f7b79a; --ink: #4d2414; }
.c-rose   { --bg: #f6a8c0; --ink: #4c1428; }
.c-lilac  { --bg: #cdb8f2; --ink: #2b1650; }
.c-mint   { --bg: #a8e3d4; --ink: #10392f; }
.c-sky    { --bg: #a9cbef; --ink: #142a45; }
.tape {
  position: absolute; top: -10px; left: 50%; width: 68px; height: 22px; margin-left: -34px;
  background: rgb(255 255 255 / 0.38); transform: rotate(-3deg);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);
}
.note .body { margin: 0; flex: 1; font: 600 23px/1.08 var(--font-hand); overflow-wrap: anywhere; white-space: pre-wrap; }
.note .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; opacity: 0.62; }
.note .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note .when { white-space: nowrap; }
/* printed on the pad, like a branded post-it */
.imprint { align-self: center; font-size: 7.5px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.36; }
.tools {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; align-items: center;
  opacity: 0; transition: opacity .15s; font-size: 12px; font-weight: 600;
}
.note:hover .tools, .note.open .tools, .note:focus-within .tools { opacity: 1; }
.tool {
  min-width: 28px; height: 28px; padding: 0 8px; border: 0; border-radius: 14px;
  background: rgb(0 0 0 / 0.12); color: var(--ink); font-size: 12px; font-weight: 600;
}
.tool:hover { background: rgb(0 0 0 / 0.2); }
.note.just-stuck { animation: stick .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes stick { from { transform: rotate(var(--r)) scale(1.18); box-shadow: 0 34px 40px -12px rgb(0 0 0 / .55); } }
.note.flash { animation: flash 1.6s ease-out 2; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgb(253 228 235 / .9), 0 14px 22px -10px rgb(0 0 0 / .6); } 100% { box-shadow: 0 0 0 26px rgb(253 228 235 / 0), 0 14px 22px -10px rgb(0 0 0 / .6); } }

/* empty sticky offered next to a shared note: "What would you add?" */
.slot {
  position: absolute; width: var(--note-w); min-height: 150px; box-sizing: border-box; padding: 24px 16px 12px;
  display: flex; flex-direction: column; justify-content: center; gap: 6px; text-align: left;
  border: 2px dashed color-mix(in srgb, var(--bg) 70%, transparent); border-radius: 2px 2px 4px 16px / 2px 2px 4px 10px;
  background: color-mix(in srgb, var(--bg) 14%, transparent); color: var(--hud-text);
  transform: rotate(var(--r, 0deg)); z-index: 4;
}
.slot:hover { background: color-mix(in srgb, var(--bg) 24%, transparent); }
.slot strong { font: 700 28px/1 var(--font-hand); }
.slot span { font-size: 12px; color: var(--hud-muted); }

/* editor (a note being written) */
.note.editor { width: 230px; z-index: 20; min-height: 0; padding-bottom: 12px; user-select: text; -webkit-user-select: text; cursor: auto; }
.editor textarea {
  border: 0; background: transparent; color: var(--ink); resize: none; padding: 0; min-height: 84px;
  font: 600 24px/1.1 var(--font-hand); outline: none;
}
.editor textarea::placeholder, .editor input::placeholder { color: var(--ink); opacity: .45; }
/* "Need an idea? …": optional starter under the text, tap to use it, ↻ for another */
.editor .idea { display: flex; align-items: flex-start; gap: 4px; margin-top: -2px; }
.editor .idea[hidden] { display: none; }
.idea-use { flex: 1; border: 0; background: none; padding: 2px 0; text-align: left; font-size: 12px; line-height: 1.3; color: var(--ink); opacity: .6; }
.idea-use em { font: 700 15px/1.1 var(--font-hand); font-style: normal; }
.idea-use:hover { opacity: .9; }
.idea-next { flex: none; width: 26px; height: 26px; border: 0; border-radius: 13px; background: rgb(0 0 0 / .08); color: var(--ink); font-size: 14px; line-height: 1; }
.idea-next:hover { background: rgb(0 0 0 / .16); }
.editor .count { align-self: flex-end; font-size: 11px; opacity: .55; font-variant-numeric: tabular-nums; }
.editor input {
  border: 0; border-bottom: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); background: transparent;
  color: var(--ink); font: 500 14px var(--font-ui); padding: 4px 0; outline: none;
}
.editor input:focus { border-bottom-color: var(--ink); }
.editor .verify { font-size: 11px; opacity: .6; }
.editor .captcha:empty { display: none; }
.editor .err { font-size: 12px; font-weight: 600; line-height: 1.3; }
.editor .actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 2px; }
.btn-text { border: 0; background: none; padding: 8px 6px; font-size: 13px; font-weight: 600; color: var(--ink); opacity: .7; }
.btn-stick { border: 0; border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 600; background: var(--ink); color: var(--bg); }
.btn-stick:disabled { opacity: .6; cursor: progress; }

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 30; }
.glass { background: var(--hud); border: 1px solid var(--hud-line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.head {
  top: calc(14px + env(safe-area-inset-top, 0px)); left: calc(16px + env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 2px; pointer-events: none;
}
.head a { pointer-events: auto; color: var(--hud-muted); text-decoration: none; font-size: 13px; font-weight: 500; }
.head a:hover { color: var(--hud-text); }
.head h1 { margin: 2px 0 0; font: 700 44px/0.95 var(--font-hand); letter-spacing: 0.5px; text-shadow: 0 0 24px rgb(205 184 242 / .45); }
.head p { margin: 0; font-size: 13px; color: var(--hud-muted); }
.corner {
  top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(16px + env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.langs { display: flex; border-radius: 999px; padding: 3px; }
.langs button { border: 0; background: none; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--hud-muted); }
.langs button[aria-pressed="true"] { background: rgb(255 255 255 / .14); color: var(--hud-text); }

.tray-wrap {
  left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.hint { font-size: 12px; color: var(--hud-muted); text-align: center; white-space: nowrap; }
body.armed .hint { color: var(--hud-text); font-weight: 600; }
.tray { display: flex; gap: 10px; padding: 10px 14px; border-radius: 18px; }
.swatch {
  width: 46px; height: 46px; border: 0; border-radius: 3px 3px 4px 10px / 3px 3px 4px 7px; padding: 0;
  background: var(--bg); touch-action: none; transition: transform .18s cubic-bezier(.2,1.4,.4,1);
  box-shadow: 0 6px 12px -4px rgb(0 0 0 / .5), inset 0 1px 0 rgb(255 255 255 / .35);
}
.swatch:nth-child(odd) { transform: rotate(-4deg); }
.swatch:nth-child(even) { transform: rotate(3deg); }
.swatch:hover { transform: translateY(-6px) scale(1.06); }
.swatch[aria-pressed="true"] { transform: translateY(-10px) scale(1.1); box-shadow: 0 0 0 3px var(--wall), 0 0 0 5px var(--focus), 0 12px 18px -6px rgb(0 0 0 / .6); }
.ghost { position: fixed; z-index: 40; width: 70px; height: 70px; margin: -35px 0 0 -35px; pointer-events: none; background: var(--bg); border-radius: 3px 3px 4px 12px; transform: rotate(-4deg); box-shadow: 0 22px 28px -10px rgb(0 0 0 / .6); opacity: .95; }

.zoom { left: calc(16px + env(safe-area-inset-left, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; border-radius: 14px; overflow: hidden; }
.zoom button { border: 0; background: none; min-width: 42px; height: 42px; padding: 0 12px; font-size: 18px; color: var(--hud-text); }
.zoom button + button { border-left: 1px solid var(--hud-line); }
.zoom .fit { font-size: 12px; font-weight: 600; }
.zoom button:hover { background: rgb(255 255 255 / .08); }
.mini-wrap { right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); border-radius: 12px; padding: 6px; }
#mini { display: block; width: 150px; height: 104px; touch-action: none; cursor: pointer; border-radius: 6px; }

.toast {
  left: 50%; top: calc(16px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  max-width: min(440px, calc(100vw - 32px)); box-sizing: border-box; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.35;
  background: #2c1c3b; border: 1px solid var(--hud-line); box-shadow: 0 10px 30px rgb(0 0 0 / .4);
  overflow-wrap: anywhere; user-select: text;
}
.toast[hidden] { display: none; }
.toast-actions { display: flex; gap: 6px; }
.toast-actions button, .menu button, .menu a {
  border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  background: rgb(255 255 255 / .12); color: var(--hud-text); text-decoration: none;
}
.toast-actions button:hover { background: rgb(255 255 255 / .2); }
.menu {
  z-index: 45; display: flex; flex-direction: column; gap: 2px; min-width: 190px; padding: 6px; border-radius: 14px;
  background: rgb(44 28 59 / .92); box-shadow: 0 14px 34px rgb(0 0 0 / .45);
}
.menu[hidden] { display: none; }
.menu button, .menu a { display: block; text-align: left; background: none; border-radius: 8px; padding: 9px 12px; }
.menu button:hover, .menu a:hover { background: rgb(255 255 255 / .1); }
.noscript { inset: 40% 16px auto; text-align: center; }

@media (max-width: 700px) {
  .head h1 { font-size: 34px; }
  .head p { font-size: 12px; }
  .tray { gap: 8px; padding: 9px 10px; }
  .swatch { width: 40px; height: 40px; }
  .zoom, .mini-wrap { bottom: calc(108px + env(safe-area-inset-bottom, 0px)); }
  .zoom .step { display: none; }
  #mini { width: 96px; height: 66px; }
}
@media (prefers-reduced-motion: reduce) {
  .note.just-stuck, .note.flash { animation: none; }
  .swatch { transition: none; }
}
