/* Keepsake room. Chunky, tactile, pastel.
   Every raised thing has an ink outline and a hard drop shadow that it
   presses into when clicked. */

:root {
  --ink: #3d2c4f;
  --ink-soft: #7a6a8c;
  --cream: #fff8ef;
  --paper: #fffdf9;
  --peach: #ffd8c4;
  --mint: #c6efd9;
  --lavender: #ddd3ff;
  --butter: #fff0b3;
  --sky: #cfe6ff;
  --pink: #ffd3e4;
  --berry: #ff8fb1;
  --radius: 16px;
  --lift: 4px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--cream); color: var(--ink);
  font: 500 14px/1.35 var(--font);
  --tray-h: 112px; /* the catalog tray, so the selected card can sit just above it */
}

h2 {
  margin: 0 0 10px; font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft);
}

/* ---------- buttons ---------- */
button {
  font: 800 13px var(--font); color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink); border-radius: 12px;
  padding: 6px 12px; cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .15s;
}
button:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
button:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; }
button svg { width: 22px; height: 22px; display: block; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

input {
  font: 700 14px var(--font); color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 12px;
  padding: 6px 10px; min-width: 0;
}
input.attention { background: var(--butter); animation: nudge .5s ease-in-out 2; }
@keyframes nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* ---------- room: the whole window ---------- */
main { position: fixed; inset: 0; }
canvas { width: 100%; height: 100%; display: block; }
main::after {
  content: ""; position: absolute; inset: 12px; pointer-events: none;
  border: 4px dashed var(--berry); border-radius: 24px; opacity: 0; transition: opacity .15s;
}
main.dropping::after { opacity: 1; }
main.grabbable canvas { cursor: grab; }
main.carrying canvas { cursor: grabbing; }
#hint {
  position: absolute; left: 50%; top: 72px; transform: translateX(-50%); pointer-events: none;
  max-width: calc(100% - 32px); text-align: center;
  font-size: 13px; font-weight: 700; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 99px;
  padding: 6px 14px; box-shadow: 0 3px 0 var(--ink);
}
#hint.flash { background: var(--butter); }
#hint[hidden] { display: none; }

/* ---------- HUD: brand and corner buttons ---------- */
.brand {
  position: fixed; left: 16px; top: 16px; z-index: 10; pointer-events: none;
  display: flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 800; letter-spacing: -.01em;
  padding: 5px 14px 5px 8px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 99px; box-shadow: 0 3px 0 var(--ink);
}
.brand::before {
  content: ""; width: 20px; height: 20px; border-radius: 7px;
  background: var(--berry); border: 3px solid var(--ink); transform: rotate(-8deg);
}
.corner { position: fixed; right: 16px; top: 16px; z-index: 10; display: flex; gap: 8px; }
button.round {
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--mint);
}
#settingsBtn { background: var(--sky); }
#settingsBtn[aria-expanded="true"] { background: var(--berry); }
button.round.off { background: var(--paper); color: var(--ink-soft); }
#mute .cross, #mute.off .waves { display: none; }
#mute.off .cross { display: inline; }
#ambient.off svg { opacity: .5; }
#ambient .dot { fill: currentColor; stroke: none; }

.pop {
  position: fixed; right: 16px; top: 72px; z-index: 11; width: 280px;
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--sky); border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 var(--lift) 0 var(--ink);
  transform-origin: 85% 0; animation: pop .18s cubic-bezier(.3, 1.6, .5, 1);
}
.pop[hidden] { display: none; }
.pop h2 { margin: 0; }
.pop label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 800; color: var(--ink-soft); }
#allowance { margin: 0; font-size: 12px; font-weight: 800; color: var(--ink-soft); }
#allowance.empty { color: var(--ink); background: var(--berry); border-radius: 8px; padding: 4px 8px; }
#allowance[hidden] { display: none; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ---------- selected object: a small card over the tray ---------- */
#selected {
  position: fixed; left: 50%; bottom: calc(var(--tray-h) + 22px); z-index: 10;
  translate: -50% 0; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px;
  background: var(--butter); border: 3px solid var(--ink); border-radius: 99px;
  box-shadow: 0 var(--lift) 0 var(--ink);
  animation: rise .22s cubic-bezier(.3, 1.6, .5, 1);
}
#selected[hidden] { display: none; }
@keyframes rise { from { transform: translateY(14px) scale(.9); opacity: 0; } }
/* The name is a text field that looks like a label until you click it. */
#selName {
  field-sizing: content; min-width: 3ch; max-width: 220px; margin-right: 2px; padding: 3px 8px;
  font-size: 15px; font-weight: 800; text-overflow: ellipsis;
  background: transparent; border: 2px dashed transparent; border-radius: 10px; cursor: text;
}
#selName:hover { border-color: var(--ink-soft); }
#selName:focus { background: var(--paper); border: 2px solid var(--ink); outline: none; }
.size {
  display: flex; align-items: center; gap: 4px; padding: 2px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 99px;
}
.size label { display: flex; align-items: baseline; gap: 2px; font-size: 12px; font-weight: 800; color: var(--ink-soft); }
#height {
  width: 46px; padding: 2px 0; border: 0; border-radius: 6px; background: none;
  text-align: right; font-size: 15px; font-weight: 800; -moz-appearance: textfield;
}
#height::-webkit-inner-spin-button, #height::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
button.mini {
  width: 32px; height: 32px; padding: 0; border-radius: 50%; border-width: 2px;
  display: grid; place-items: center; font-size: 18px; line-height: 1; box-shadow: 0 2px 0 var(--ink);
}
.size button.mini { width: 28px; height: 28px; background: var(--mint); box-shadow: none; }
.size button.mini svg { width: 16px; height: 16px; stroke-width: 3; }
/* Inside the pill the -/+ stay put, so they line up with its rim; a press just darkens. */
.size button.mini:hover { transform: none; box-shadow: none; background: #b3e6cb; }
.size button.mini:active { transform: scale(.92); }
button.mini svg { width: 18px; height: 18px; }
button.mini.icon { width: 38px; height: 38px; background: var(--paper); }
button.mini.danger:hover { background: var(--pink); color: #b2345c; }
/* Lock and group. Pressed means locked, or the selection is one whole group. */
#lock .shut, #lock[aria-pressed="true"] .open { display: none; }
#lock[aria-pressed="true"] .shut { display: inline; }
#lock[aria-pressed="true"], #groupBtn[aria-pressed="true"] { background: #c9bdf2; }
#lock[hidden] { display: none; }
#selected:not(.many) #groupBtn, #selected.many .size, #selected.many #duplicate { display: none; }
#selected.locked .size { opacity: .45; pointer-events: none; }
#selName[readonly] { cursor: default; border-color: transparent; background: transparent; }
#removeFromRoom.sure { background: var(--berry); color: var(--ink); animation: nudge .4s ease-in-out; }
button.mini:disabled { opacity: .4; cursor: default; transform: none; box-shadow: 0 2px 0 var(--ink); }

/* ---------- catalog tray ---------- */
#tray {
  position: fixed; left: 50%; bottom: 14px; z-index: 10; translate: -50% 0;
  height: var(--tray-h); max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 0; padding: 0 0 0 12px;
  background: var(--lavender); border: 3px solid var(--ink); border-radius: 26px;
  box-shadow: 0 var(--lift) 0 var(--ink);
}
#lib {
  /* Room above the tiles for the badges when a tile lifts on hover, since scrolling clips. */
  list-style: none; margin: 0; padding: 16px 12px 10px; display: flex; gap: 10px;
  overflow-x: auto; overflow-y: visible; scrollbar-width: thin; scroll-behavior: smooth;
}
#lib:empty { display: none; }
.tile {
  --tint: var(--peach);
  position: relative; flex: none; width: 80px; height: 80px; padding: 0;
  background: var(--tint); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 0 var(--lift) 0 var(--ink);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), box-shadow .15s;
}
button.tile.add { display: grid; place-items: center; background: var(--butter); }
button.tile.add svg { width: 34px; height: 34px; stroke-width: 3.2; }
li.tile { cursor: pointer; }
li.tile.ready { cursor: grab; }
li.tile:hover { transform: translateY(-4px) rotate(-1.5deg); box-shadow: 0 calc(var(--lift) + 3px) 0 var(--ink); }
li.tile.dragging { opacity: .45; transform: scale(.94); }
li.tile.has-selected { outline: 3px solid var(--berry); outline-offset: 3px; }
.tile img, .tile .ph {
  width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 15px; background: var(--paper);
  -webkit-user-drag: none; pointer-events: none;
}
/* Not ready yet: faded photo with a progress bar along the bottom. */
li.tile:not(.ready) img { filter: saturate(.4) opacity(.6); }
.tile .bar {
  position: absolute; left: 8px; right: 8px; bottom: 8px; height: 10px; overflow: hidden;
  border-radius: 99px; background: var(--paper); border: 2px solid var(--ink);
}
.tile .bar i {
  display: block; height: 100%; border-radius: 99px; transition: width .6s ease;
  background: repeating-linear-gradient(-45deg, var(--berry) 0 6px, #ffb3c9 6px 12px);
  background-size: 17px 17px; animation: stripes 1s linear infinite;
}
@keyframes stripes { to { background-position: 17px 0; } }
.tile .flag {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 26px; font-weight: 900; color: var(--ink);
}
li.tile.failed { background: var(--pink); }
li.tile.failed .flag { color: #b2345c; }
/* How many are in the room. Click it to visit each one in turn. */
.tile .count {
  position: absolute; right: -9px; top: -9px; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 99px; border-width: 2px; box-shadow: 0 2px 0 var(--ink);
  font-size: 12px; background: var(--berry);
}
.tile .count[hidden] { display: none; }
/* Delete: shows on hover, asks once before it removes the model for good. */
.tile .del {
  position: absolute; left: -9px; top: -9px; width: 26px; height: 26px; padding: 0;
  border-radius: 99px; border-width: 2px; box-shadow: 0 2px 0 var(--ink);
  display: grid; place-items: center; font-size: 15px; line-height: 1; opacity: 0; transition: opacity .1s;
}
li.tile:hover .del, .tile .del:focus-visible, .tile .del.sure { opacity: 1; }
.tile .del.sure { width: auto; padding: 0 8px; font-size: 11px; background: var(--berry); }
/* Details: the pencil sits bottom left on hover and opens the details card for the object. */
.tile .pen {
  position: absolute; left: -9px; bottom: -9px; width: 26px; height: 26px; padding: 0;
  border-radius: 99px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); background: var(--butter);
  display: grid; place-items: center; opacity: 0; transition: opacity .1s;
}
.tile .pen svg { width: 14px; height: 14px; stroke-width: 2.6; }
li.tile:hover .pen, .tile .pen:focus-visible { opacity: 1; }
#empty { margin: 0 16px 0 12px; max-width: 360px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
#empty[hidden] { display: none; }

#tip {
  position: fixed; z-index: 12; pointer-events: none; max-width: 240px;
  padding: 6px 12px; translate: -50% -100%;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink);
}
#tip[hidden] { display: none; }
#tip b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tip span { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
#tip span.failed { color: #b2345c; }

/* ---------- help ---------- */
button.help { font-size: 20px; background: var(--butter); }
button.help.new { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }
#help {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: rgb(61 44 79 / .25);
}
#help[hidden] { display: none; }
#help .sheet {
  width: min(980px, 100%); max-height: 100%; overflow-y: auto; padding: 18px 20px 20px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 22px;
  box-shadow: 0 6px 0 var(--ink);
}
#help header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
#help h2 { margin: 0; font-size: 20px; color: var(--ink); text-transform: none; letter-spacing: 0; }
#help .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
#help section { padding: 12px 14px; border: 3px solid var(--ink); border-radius: var(--radius); background: var(--sky); box-shadow: 0 var(--lift) 0 var(--ink); }
#help section[data-input="keys"] { background: var(--mint); }
#help section[data-input="pad"] { background: var(--peach); }
#help h3 { margin: 0 0 8px; font-size: 15px; font-weight: 800; }
#help dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
#help dt { font-weight: 800; white-space: nowrap; }
#help dd { margin: 0; color: var(--ink-soft); font-weight: 700; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 5px; margin-right: 2px; text-align: center;
  font: 800 12px var(--font); background: var(--paper);
  border: 2px solid var(--ink); border-radius: 6px; box-shadow: 0 2px 0 var(--ink);
}

/* ---------- gamepad cursor ---------- */
/* A chunky ink-outlined dot that follows the left stick. It grows over
   something grabbable and squeezes while carrying. */
#padCursor {
  position: fixed; left: -14px; top: -14px; width: 28px; height: 28px; z-index: 10;
  pointer-events: none; border-radius: 50%;
  background: var(--paper); border: 4px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  transition: width .12s, height .12s, left .12s, top .12s, background .12s;
}
#padCursor[hidden] { display: none; }
#padCursor.room.grab { width: 40px; height: 40px; left: -20px; top: -20px; background: var(--butter); }
#padCursor.carrying { width: 22px; height: 22px; left: -11px; top: -11px; background: var(--berry); }
