/*
  Shape Maker.

  Sizing rule for every control: nothing a seven-year-old has to hit is
  smaller than 56px, and every button carries a word as well as a picture.
  There is no hover-only affordance anywhere — this is built for a finger.
*/

:root {
  --ink: #1d2433;
  --ink-soft: #5a6478;
  --paper: #f2f5fa;
  --panel: #ffffff;
  --edge: #d7deea;
  --focus: #1c7ed6;
  --undo: #f59f00;
  --save: #2f9e44;
  --danger: #e03131;
  --radius: 16px;
  --shadow: 0 2px 0 rgba(29, 36, 51, .13), 0 6px 16px rgba(29, 36, 51, .09);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 600 16px/1.3 ui-rounded, "Nunito", "Trebuchet MS", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- top bar ---------- */

#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--edge);
}

#brand {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
}

#hint {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#topactions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
}

/* ---------- the scene ---------- */

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;   /* we own every gesture in here */
  cursor: grab;
}

#scene.is-dragging { cursor: grabbing; }

/* ---------- bottom bar ---------- */

#bottombar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 12px 14px;
  background: var(--panel);
  border-top: 1px solid var(--edge);
}

#palette, #edit {
  display: flex;
  gap: 10px;
}

#edit {
  padding-left: 18px;
  border-left: 2px dashed var(--edge);
}

/* ---------- buttons ---------- */

button {
  font: inherit;
  color: var(--ink);
  border: 2px solid var(--edge);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 74px;
  min-height: 68px;
  padding: 6px 10px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .06s ease, background-color .12s ease, opacity .12s ease;
}

button span { font-size: 13px; font-weight: 800; }

button svg { width: 30px; height: 30px; display: block; }

button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(29,36,51,.13); }

button:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }

button:disabled {
  opacity: .34;
  cursor: default;
  box-shadow: none;
}

.shape svg { width: 38px; height: 38px; }
.shape { min-width: 82px; min-height: 78px; }

.tool-undo:not(:disabled) { color: #8a5a00; border-color: #ffd8a8; background: #fff4e6; }
.tool-download:not(:disabled) { color: #ffffff; border-color: var(--save); background: var(--save); }
.tool-delete:not(:disabled) { color: var(--danger); border-color: #ffc9c9; background: #fff5f5; }

/* The chosen shape's palette button is not a mode — nothing stays pressed.
   Only the "which shape is selected in the scene" state is shown, and it is
   shown in the scene itself with an outline, where a child is already looking. */

/* ---------- back-link ---------- */

#backlink {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  padding: 8px 4px;
  white-space: nowrap;
}

#backlink:hover, #backlink:focus-visible { color: var(--focus); text-decoration: underline; }

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #fff5f5;
  border: 2px solid #ffc9c9;
  color: #a32f2f;
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  #brand { display: none; }
  #hint { font-size: 14px; }
  #bottombar { gap: 8px 12px; padding: 10px; justify-content: center; }
  #edit { padding-left: 12px; }
  button { min-width: 62px; min-height: 62px; padding: 5px 7px; }
  .shape { min-width: 68px; min-height: 68px; }
  button span { font-size: 11px; }
  #backlink { margin-left: 0; flex-basis: 100%; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
