/* ─────────────────────────────────────────────
   Calligraphy canvas page styles
   ───────────────────────────────────────────── */

/* Icon circle used in the page header */
.icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Canvas wrapper: holds both grid and drawing canvases stacked */
.canvas-wrapper {
  border: 2px solid #e8e0d8;
  border-radius: 0.75rem;
  overflow: hidden;
  min-height: 300px; /* Added min-height to prevent collapse if JS fails */
  background:
    /* subtle rice-paper texture */
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 1px,
      rgba(200, 180, 160, 0.03) 1px,
      rgba(200, 180, 160, 0.03) 2px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 1px,
      rgba(200, 180, 160, 0.03) 1px,
      rgba(200, 180, 160, 0.03) 2px
    ),
    linear-gradient(135deg, #fdfbf7 0%, #f8f4ec 50%, #faf6ef 100%);
  cursor: crosshair;
}

/* Both canvases are absolutely positioned on top of each other */
.canvas-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Prevent selection artifacts during drawing */
.canvas-wrapper,
.canvas-layer {
  -webkit-user-select: none;
  user-select: none;
}

/* The grid canvas sits behind the drawing canvas */
#gridCanvas {
  z-index: 1;
  pointer-events: none;
}

#drawCanvas {
  z-index: 2;
}

/* ── Result characters ────────────────────── */
.result-chars {
  letter-spacing: 0.15em;
  transition: color 0.2s ease;
}

.result-chars:hover {
  color: var(--bs-primary) !important;
  text-decoration: underline;
  text-underline-offset: 6px;
}

/* ── Candidate buttons ────────────────────── */
#candidatesList .btn {
  font-size: 1.25rem;
  min-width: 48px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#candidatesList .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ── Lookup badges ────────────────────────── */
.lookup-badge {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lookup-badge:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

/* ── Auto-recognise toggle active state ──── */
#btnRecognizeAuto.active {
  background-color: var(--bs-primary);
  color: #fff;
  border-color: var(--bs-primary);
}

/* ── Grid toggle active state ─────────────── */
#btnToggleGrid.active {
  background-color: var(--bs-secondary);
  color: #fff;
}

/* ── Pen-size range thumb ─────────────────── */
#penSizeRange::-webkit-slider-thumb {
  background: var(--bs-primary);
}

/* ── Responsive tweaks ────────────────────── */
@media (max-width: 991.98px) {
  .canvas-wrapper {
    /* Taller canvas on mobile for portrait writing */
    min-height: 260px;
  }
}

/* ── Dark theme support ───────────────────── */
[data-bs-theme="dark"] .canvas-wrapper {
  border-color: #3a3530;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 1px,
      rgba(80, 70, 60, 0.06) 1px,
      rgba(80, 70, 60, 0.06) 2px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 1px,
      rgba(80, 70, 60, 0.06) 1px,
      rgba(80, 70, 60, 0.06) 2px
    ),
    linear-gradient(135deg, #2a2520 0%, #1e1a16 50%, #252018 100%);
}
