/* TGPU Iqra — Touch Handwriting & Tracing Studio (handwriting-v1.css)
   Mobile-first touch & stylus writing pad with RTL-friendly controls. */

.hw-studio {
  border-radius: 22px;
  border: 1px solid #d7e5dd;
  background: #ffffff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(6, 63, 53, 0.05);
}

.hw-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.hw-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hw-title-group strong {
  font-size: 16px;
  font-weight: 800;
  color: #063f35;
}

.hw-title-group span {
  font-size: 12.5px;
  color: #4a5a54;
  line-height: 1.4;
}

.hw-mode-toggle {
  display: inline-flex;
  background: #eef5f1;
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  flex-shrink: 0;
}

.hw-mode-btn {
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #2f4d43;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms ease, color 160ms ease;
}

.hw-mode-btn.active {
  background: #0b5a4c;
  color: #ffffff;
}

.hw-canvas-frame {
  position: relative;
  width: 100%;
  height: 230px;
  border-radius: 18px;
  border: 1.5px solid #cfe0d6;
  background:
    linear-gradient(180deg, transparent 49.4%, rgba(198, 166, 103, 0.28) 49.4%, rgba(198, 166, 103, 0.28) 50.6%, transparent 50.6%),
    linear-gradient(180deg, transparent 74.5%, rgba(11, 90, 76, 0.16) 74.5%, rgba(11, 90, 76, 0.16) 75.5%, transparent 75.5%),
    #fcfbf7;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

@media (min-width: 700px) {
  .hw-canvas-frame {
    height: 268px;
  }
}

.hw-guide-glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: "Amiri Quran", "Amiri", "Noto Naskh Arabic", "Noto Sans Arabic", serif;
  font-size: clamp(118px, 28vw, 164px);
  line-height: 1;
  color: rgba(11, 90, 76, 0.14);
  user-select: none;
  transition: opacity 160ms ease;
}

.hw-canvas-frame.freehand .hw-guide-glyph {
  opacity: 0;
}

.hw-canvas {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.hw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hw-tool-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 13px;
  border: 1px solid #d2e2d9;
  border-radius: 12px;
  background: #f7faf8;
  color: #17352b;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.hw-tool-btn:hover {
  background: #ebf4ef;
  border-color: #9dc2b1;
}

.hw-tool-btn.active {
  background: #0b5a4c;
  border-color: #0b5a4c;
  color: #ffffff;
}

.hw-tool-btn.primary {
  background: #063f35;
  border-color: #063f35;
  color: #ffffff;
}

.hw-tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hw-status {
  font-size: 12px;
  color: #4a5a54;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.hw-disclaimer {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: #5a6b64;
}

.hw-notebook-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.hw-saved-chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid #d5e4dc;
  background: #f9fbf9;
  color: #063f35;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.hw-saved-chip.active {
  border-color: #0b5a4c;
  background: #e9f5ef;
}

.hw-saved-chip .hw-chip-letter {
  font-family: "Amiri Quran", "Amiri", "Noto Naskh Arabic", serif;
  font-size: 24px;
  line-height: 1.1;
}

.hw-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(6, 38, 30, 0.56);
  display: grid;
  place-items: center;
  padding: 16px;
}

.hw-modal-card {
  width: min(100%, 640px);
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 24px;
  background: #f8f6f0;
  padding: 18px;
  box-shadow: 0 24px 64px rgba(6, 38, 30, 0.28);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hw-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hw-modal-head h2 {
  font-size: 19px;
  font-weight: 800;
  color: #063f35;
  margin: 0;
}

.hw-letter-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
}

.hw-pick-btn {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid #d8e5de;
  background: #ffffff;
  color: #063f35;
  font-family: "Amiri Quran", "Amiri", "Noto Naskh Arabic", serif;
  font-size: 26px;
  line-height: 1.1;
  cursor: pointer;
}

.hw-pick-btn.active {
  background: #0b5a4c;
  border-color: #0b5a4c;
  color: #ffffff;
}

.hw-pick-btn.has-saved {
  box-shadow: inset 0 -3px 0 #c6a667;
}

@media (prefers-reduced-motion: reduce) {
  .hw-mode-btn,
  .hw-tool-btn,
  .hw-guide-glyph {
    transition: none;
  }
}
