/* Public pages (designer, wall, battle): the layout and component rules the poster look
   was built with. Every colour, font and shadow is a token; the values live in
   themes/<id>/tokens.css (poster's accent is the blue from PRINT_PALETTE in
   color-picker.js). Everything lives under body.public so admin.html, which shares
   theme.css and designer.css, is untouched. */
body.public { background-color: var(--color-bg); background-image: var(--page-background); accent-color: var(--control-accent); }

/* The triangle background stays as it is, so loose text sits on a paper card
   instead of on the grey. */
body.public .message-box,
body.public .canvas-notes,
body.public .jump-to-send {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

body.public .message-box { padding: var(--panel-padding); }
body.public .canvas-notes { padding: var(--space-sm) var(--space-md); }
body.public .jump-to-send { color: var(--color-link); }

/* Poster headings: bold condensed caps. The designer's h1 was screen-reader
   only; it now heads the page, kept to one line so the message box and canvas
   stay in view on a phone. */
body.public h1,
body.public h2,
body.public #btn-submit {
  font-family: var(--font-display);
  font-weight: var(--heading-weight);
  text-transform: var(--heading-transform);
  letter-spacing: var(--heading-tracking);
}

body.public .site-title {
  grid-area: title;
  justify-self: center;
  max-width: 100%;
  margin: 0;
  padding: var(--space-xs) var(--space-md);
  font-size: clamp(1.15rem, 5.4vw, 2rem);
  line-height: 1.1;
  text-align: center;
  color: var(--color-header-text);
  background: var(--color-header-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

body.public main {
  grid-template-areas:
    "title"
    "message"
    "canvas"
    "note"
    "jump"
    "toolbar"
    "form";
}

@media (min-width: 760px) {
  body.public main {
    grid-template-areas:
      "title   title"
      "message toolbar"
      "canvas  toolbar"
      "canvas  form"
      "note    .";
  }
}

/* Footer: a plain paper strip in the page flow (the dark theme pinned white
   text to the viewport bottom, over the canvas controls). */
body.public .site-footer {
  position: static;
  margin-top: var(--space-md);
  padding: var(--space-md);
  gap: var(--space-sm);
  font-size: 0.95rem;
  color: var(--color-text-primary);
  text-shadow: none;
  background: var(--color-bg);
  border-top: 2px solid var(--color-text-primary);
  pointer-events: auto;
}

/* One rhythm on phones: every footer row is a --target-min tall and rows sit --space-sm apart,
   whether the row is a wall link, the credit line or the feedback/admin pair. The column gap
   (--space-md) only matters on desktop, where the explore links share a row. */
body.public .footer-explore-group { gap: var(--space-sm) var(--space-md); }

body.public .footer-explore,
body.public .footer-feedback {
  opacity: 1;
  font-weight: 500;
  min-height: var(--target-min);
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.public .footer-feedback {
  position: static;
  font-family: inherit;
  font-size: inherit;
  padding: 0 var(--space-sm);
}

body.public .footer-credit { margin: 0; font-weight: 600; }
body.public .footer-credit a,
body.public .footer-admin {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
}
body.public .footer-credit a { color: var(--color-link); }

body.public .footer-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

body.public .footer-admin {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* The "Your message" box above the canvas is where words go here, so the shared
   "Type a message" tile (admin's prompt) is not shown. On a phone it cost a tile row. */
body.public #btn-quick { display: none; }

/* ---------- Phone: keep the button in view while editing ---------- */

/* Under 760px the canvas panel pins to the top of the screen, so the button stays visible while the
   tools below it scroll. The disc is capped near 40% of the screen height and the whole pinned pane
   (disc plus its tile rows) at 58%, so a short phone still leaves room for the tools. scroll-padding
   on the page makes the jump link, focus and scrollIntoView land below the pane, not under it.
   Layout, not look: every theme gets it. */
@media (max-width: 759px) {
  body.public { --_pin-size: min(85vw, 360px, 40vh); }
  @supports (height: 1dvh) {
    body.public { --_pin-size: min(85vw, 360px, 40dvh); }
  }

  body.public > main > .canvas-area {
    position: sticky;
    top: 0;
    z-index: 10;
    max-height: 58vh;
    overflow-y: auto;
    background: var(--color-bg);
    box-shadow: var(--shadow-sm);
  }

  body.public > main > .canvas-area .canvas-frame > .canvas-wrapper { width: var(--_pin-size); }

  /* A panel title a theme shows would take about 35px of the pinned pane and push the second row of
     tiles out of view. The pane is for the button and its tiles, so the title steps aside visually
     here (it stays in the page for screen readers). Hidden by a theme, it is display: none already. */
  body.public > main > .canvas-area > .panel__title {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body.public { scroll-padding-top: calc(min(58vh, var(--_pin-size) + 130px) + var(--space-md)); }

  @supports (height: 1dvh) {
    body.public > main > .canvas-area { max-height: 58dvh; }
    body.public { scroll-padding-top: calc(min(58dvh, var(--_pin-size) + 130px) + var(--space-md)); }
  }
}
