/* Drawing page — layered on top of style.css, which supplies :root tokens,
   the base reset, the ambient bg-pattern/bg-noise layers, .logo, and
   .pill-nav/.nav-pill. Only page-specific chrome (header, canvas, toolbar,
   color picker, footer positioning) lives here. */

.draw-page {
  position: relative;
  z-index: 1;
  /* svh (not dvh): assumes the browser chrome (e.g. Safari's address bar)
     is always expanded, i.e. the smallest guaranteed-visible viewport. dvh
     resizes live as that chrome collapses/expands, but on iOS the layout
     doesn't always resync in step with the chrome's own animation, which
     leaves a visible gap under the footer nav for a moment — svh has no
     such resize to lag behind, so the canvas never claims space that isn't
     reliably on-screen. */
  height: 100svh;
  overflow: hidden;
}

/* linked after style.css, so this wins the cascade tie at every viewport —
   keeps the canvas app locked/non-scrolling even under style.css's mobile
   `body { overflow-y: auto }` carve-out, which is meant for the homepage. */
html, body { height: 100%; overflow: hidden; }

/* real <button> elements — strip the browser's native chrome (border,
   background, padding) before any of it can show through. Placed ahead of
   the per-button rules below on purpose: same specificity, so source order
   lets .save-btn/.color-swatch's own border/background win afterward. */
.tool-btn,
.icon-btn,
.save-btn,
.color-swatch {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- header ---------- */

.draw-header {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 3.2vh, 46px) var(--side);
  pointer-events: none;
}

.draw-header .logo,
.draw-actions {
  pointer-events: auto;
}

.draw-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.utility-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: rgba(255, 255, 255, 0.4);
  transition: color 0.2s ease;
}

.icon-btn:hover:not(:disabled) { color: #fff; }
.icon-btn:disabled { color: rgba(255, 255, 255, 0.15); cursor: default; }

.save-btn {
  height: 48px;
  padding: 0 24px;
  border-radius: 50px;
  background: #1b1b1b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.2s ease;
}

.save-btn:hover { background: #242424; }
.save-btn:active { transform: scale(0.96); }
.save-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.save-btn.is-saved { background: #1e3a2a; color: #8fe3ab; }

/* ---------- canvas ---------- */

.canvas-shell {
  position: absolute;
  inset: 0;
}

#drawCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#drawCanvas.tool-select { cursor: grab; }
#drawCanvas.tool-select.is-panning { cursor: grabbing; }
#drawCanvas.tool-pencil,
#drawCanvas.tool-brush,
#drawCanvas.tool-eyedropper { cursor: crosshair; }
#drawCanvas.tool-eraser { cursor: cell; }
#drawCanvas.tool-eraser.is-blocked { cursor: not-allowed; }

/* ---------- left toolbar ---------- */

.left-toolbar {
  position: absolute;
  z-index: 10;
  top: 50%;
  left: clamp(16px, 3.75vw, 72px);
  transform: translateY(-50%);
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  background: #191919;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
}

.tools-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  transition: background 0.2s ease, color 0.2s ease;
}

.tool-btn:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
}

.tool-btn.is-active {
  background: #2f58ed;
  color: #fff;
  box-shadow: 0 2px 2px rgba(47, 128, 237, 0.25);
}

.toolbar-divider {
  width: 32px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--swatch-color, #ed422f);
  border: 2px solid #fff;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.color-swatch:hover { transform: scale(1.06); }

.color-input-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- tool hint toast ---------- */

.tool-hint {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: clamp(90px, 14vh, 130px);
  transform: translateX(-50%) translateY(-6px);
  padding: 10px 18px;
  border-radius: 100px;
  background: rgba(21, 21, 21, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-mid);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.tool-hint.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- footer nav ---------- */

.draw-footer-nav {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: clamp(16px, 3.2vh, 40px);
  transform: translateX(-50%);
  opacity: 0.6;
  transition: opacity 0.25s ease;
}

.draw-footer-nav:hover,
.draw-footer-nav:focus-within {
  opacity: 1;
}

.pill-nav a.nav-pill {
  text-decoration: none;
  cursor: pointer;
}

.nav-pill.is-current {
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
}

.nav-pill.is-current img { opacity: 1; }

.nav-pill.icon-only {
  width: 46px;
  justify-content: center;
  padding: clamp(8px, 1.2vh, 12px);
}

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  .left-toolbar {
    left: 12px;
    width: 52px;
    gap: 8px;
    padding: 12px 0;
  }

  .tool-btn { width: 34px; height: 34px; }
  .toolbar-divider { width: 26px; }
  .color-swatch { width: 30px; height: 30px; }

  .draw-header { padding: 16px; }
  .save-btn { height: 42px; padding: 0 18px; font-size: 14px; }

  .tool-hint { font-size: 11px; padding: 8px 14px; }

  /* 5 pills (this page adds a back-arrow one) don't fit labeled on a phone
     width — collapse every pill to icon-only so the row fits without wrap
     or clipping. */
  .draw-footer-nav { gap: 8px; }
  .draw-footer-nav .nav-pill span { display: none; }
  .draw-footer-nav .nav-pill { padding: 10px; gap: 0; }
}
