/* Handwriting Simulator Styles */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=Dancing+Script:wght@400;600;700&family=Pacifico&family=Kalam:wght@300;400;700&family=Indie+Flower&family=Patrick+Hand&family=Shadows+Into+Light&family=Satisfy&family=Permanent+Marker&family=Architects+Daughter&family=Rock+Salt&family=Handlee&family=Just+Another+Hand&family=Yellowtail&family=Sacramento&display=swap');

.hw-wrap { padding: 0 0 24px; max-width: 800px; margin: 0 auto; }
.hw-title { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }

.hw-textarea-wrap { position: relative; margin-bottom: 16px; }
.hw-textarea-wrap textarea {
  width: 100%; min-height: 80px; padding: 14px 16px;
  font-size: 15px; line-height: 1.6; resize: vertical;
  border: .5px solid var(--gray-200);
  border-radius: 12px;
  background: var(--white);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s;
}
.hw-textarea-wrap textarea:focus { outline: none; border-color: var(--accent); }

.hw-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.hw-control-group { display: flex; flex-direction: column; gap: 6px; }
.hw-control-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.hw-select { width: 100%; padding: 8px 10px; font-size: 13px; border: .5px solid var(--gray-200); border-radius: 8px; background: var(--white); color: var(--text); }
.hw-range-wrap { display: flex; align-items: center; gap: 8px; }
.hw-range-wrap input[type="range"] { flex: 1; }
.hw-range-val { font-size: 12px; color: var(--text-muted); min-width: 28px; text-align: right; }

.hw-style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-bottom: 20px; }
.hw-style-card {
  padding: 12px 10px 8px;
  border: .5px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer; text-align: center;
  background: var(--white);
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.hw-style-card:hover { border-color: var(--gray-400); background: var(--gray-50); }
.hw-style-card.active { border-color: var(--accent); background: var(--gray-50); border-width: 1.5px; }
.hw-style-preview { font-size: 16px; margin-bottom: 4px; line-height: 1.3; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-style-name { font-size: 11px; color: var(--text-muted); }

.hw-preview-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.hw-preview-box {
  min-height: 140px; padding: 24px 28px;
  border: .5px solid var(--gray-200);
  border-radius: 12px;
  background: var(--white);
  position: relative; overflow: hidden;
  transition: all 0.3s ease;
  margin-bottom: 16px;
}
.hw-paper-lines {
  position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-linear-gradient(transparent, transparent 31px, var(--gray-200) 31px, var(--gray-200) 32px);
  background-position: 0 8px;
}
.hw-paper-ruled .hw-paper-lines { opacity: 1; }
.hw-paper-blank .hw-paper-lines { opacity: 0; }
.hw-paper-grid .hw-paper-lines {
  background-image:
    repeating-linear-gradient(transparent, transparent 31px, var(--gray-200) 31px, var(--gray-200) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, var(--gray-200) 31px, var(--gray-200) 32px);
}
.hw-preview-text {
  position: relative; z-index: 1;
  word-break: break-word; line-height: 2;
  transition: all 0.3s ease;
  text-align: center;
}

.hw-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hw-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: 13px; font-weight: 500;
  border: .5px solid var(--gray-200);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  cursor: pointer; transition: all 0.15s;
}
.hw-btn:hover { background: var(--gray-100); }
.hw-btn:active { transform: scale(0.98); }
.hw-btn-primary { background: var(--navy); color: var(--white); border-color: var(--navy); }
.hw-btn-primary:hover { background: var(--accent); }

.hw-ink-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.hw-ink-btn {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.hw-ink-btn:hover { transform: scale(1.1); }
.hw-ink-btn.active { border-color: var(--accent); transform: scale(1.15); }

.hw-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--white);
  padding: 8px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 999;
}
.hw-toast.show { opacity: 1; }

.tool-page .gen-heading { position: absolute; left: -9999px; }

@media (max-width: 640px) {
  .hw-wrap { padding: 0 16px 24px; }
  .hw-controls {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .hw-style-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
  }
  .hw-preview-box {
    padding: 16px 18px;
    min-height: 110px;
  }
  .hw-actions {
    gap: 6px;
  }
  .hw-btn {
    padding: 8px 14px;
    font-size: 12px;
  }
  .hw-ink-row {
    gap: 6px;
  }
}

@media (max-width: 480px) {
  .hw-style-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 6px;
  }
  .hw-style-card {
    padding: 10px 8px 6px;
  }
  .hw-style-preview {
    font-size: 14px;
  }
}

/* Fix content-right table responsive overflow
   Overrides the global style.scss display:block rule with higher specificity.
   Tables inside .content-right render as proper HTML tables (Popular Fonts),
   so they should use normal table layout with word-break on small screens. */
.tool-content .content-right table {
  display: table;
  overflow-x: auto;
  white-space: normal;
  width: 100%;
  max-width: 100%;
}

.tool-content .content-right table th,
.tool-content .content-right table td {
  white-space: normal;
  word-break: break-word;
}