/* Handwriting Assignment Generator — page + tool styles.
   Scoped to .handwriting-page / .hw-* so site-wide styles are never affected. */

/* Page --------------------------------------------------------------------- */
.handwriting-page .page-hero {
  background:
    radial-gradient(circle at 88% 12%, rgba(98, 54, 255, 0.12), transparent 34%),
    radial-gradient(circle at 8% 88%, rgba(193, 255, 82, 0.14), transparent 30%),
    transparent;
}
.handwriting-page .page-hero p { max-width: 52ch; }

.handwriting-page .section-kicker {
  display: inline-block;
  margin-bottom: 0.45rem;
  color: var(--purple);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hw-hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 1.2rem 2rem;
  align-items: center;
}

.hw-hero-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 22px !important;
  font-size: 0.88rem;
  color: var(--purple-navy) !important;
}
.hw-hero-note i { color: var(--purple); font-size: 1.05rem; }

.hw-hero-visual { display: flex; justify-content: center; }
.hw-hero-visual img { display: block; width: 100%; max-width: 460px; height: auto; border-radius: 20px; }

.handwriting-page .about-values .section-head,
.handwriting-page .faq .section-head { text-align: center; }

/* Content article ---------------------------------------------------------- */
.hw-content { padding: 24px 0 40px; }
.hw-article { max-width: 1040px; margin: 0 auto; color: var(--muted); }
.hw-block { padding: 28px 0; border-bottom: 1px solid rgba(98, 54, 255, 0.08); }
.hw-block:last-child { border-bottom: 0; }
.hw-block h2 { margin: 0 0 12px; color: var(--purple-navy); font-size: clamp(1.35rem, 2.6vw, 1.75rem); line-height: 1.25; }
.hw-block h3 { margin: 0 0 8px; color: var(--purple-navy); font-size: 1.05rem; line-height: 1.35; }
.hw-block p { margin: 0 0 10px; line-height: 1.7; }
.hw-block ul { margin: 0 0 12px; padding-left: 1.2rem; line-height: 1.7; }
.hw-block li { margin-bottom: 4px; }
.hw-block strong { color: var(--purple-navy); }
.hw-block a { color: var(--purple); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.hw-block a:hover { color: var(--purple-navy); }
.hw-block code { padding: 1px 6px; border-radius: 6px; background: var(--purple-soft); color: var(--purple); font-size: 0.9em; }

.hw-cards { display: grid; gap: 14px; margin: 14px 0 16px; }
.hw-cards--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hw-cards--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.hw-card {
  position: relative;
  padding: 18px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(98, 54, 255, 0.1);
  box-shadow: 0 10px 26px rgba(42, 22, 90, 0.05);
}
.hw-card p:last-child, .hw-card ul:last-child { margin-bottom: 0; }
.hw-card h3 i { color: var(--purple); margin-right: 4px; }
.hw-card__num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--lime);
  color: var(--purple-navy);
  font-weight: 700;
}
.hw-card--font h3 { font-size: 1.7rem; font-weight: 400; color: #1c3fa8; line-height: 1.2; }
.hw-card--font p { font-size: 0.9rem; }
.hw-card--paper { padding-top: 70px; }
.hw-card--paper::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 18px;
  right: 18px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(98, 54, 255, 0.12);
  background-color: #fff;
}
.hw-paper--ruled::before { background-image: repeating-linear-gradient(180deg, transparent 0 10px, #b9c6e4 10px 11px); }
.hw-paper--grid::before { background-image: linear-gradient(#b9c6e4 1px, transparent 1px), linear-gradient(90deg, #b9c6e4 1px, transparent 1px); background-size: 11px 11px; }
.hw-paper--dotted::before { background-image: radial-gradient(#9aaad0 1.2px, transparent 1.4px); background-size: 11px 11px; }

.hw-list-cols { columns: 2; column-gap: 24px; }
.hw-checklist { list-style: none; padding-left: 0 !important; }
.hw-checklist li { position: relative; padding-left: 28px; }
.hw-checklist li::before {
  content: "\F26E";
  position: absolute;
  left: 0;
  top: 1px;
  font-family: "bootstrap-icons";
  color: var(--purple);
}
.hw-callout {
  padding: 12px 16px;
  border-radius: 12px;
  border-left: 4px solid var(--purple);
  background: var(--purple-soft);
  color: var(--purple-navy) !important;
}

/* Tool shell --------------------------------------------------------------- */
.hw-section { padding: 8px 0 56px; }

.hw-tool {
  display: grid;
  grid-template-columns: minmax(300px, 370px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  scroll-margin-top: 90px;
  color: var(--purple-navy);
}

.hw-panel,
.hw-preview {
  background: #fff;
  border: 1px solid rgba(98, 54, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 14px 36px rgba(42, 22, 90, 0.07);
}

.hw-panel {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 6px 16px 14px;
  scrollbar-width: thin;
}

.hw-step { border-bottom: 1px solid rgba(98, 54, 255, 0.1); padding: 10px 0; }
.hw-step summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 0.95rem;
}
.hw-step summary::-webkit-details-marker { display: none; }
.hw-step summary::after {
  content: "\F282";
  font-family: "bootstrap-icons";
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
  transition: transform 0.2s;
}
.hw-step[open] summary::after { transform: rotate(180deg); }
.hw-step__num {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 0.78rem;
}
.hw-step[open] .hw-step__num { background: var(--purple); color: #fff; }

.hw-tool textarea,
.hw-tool select,
.hw-tool input[type="text"],
.hw-tool input[type="number"] {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  color: var(--purple-navy);
  background: #faf9ff;
  border: 1px solid rgba(98, 54, 255, 0.18);
  border-radius: 10px;
  padding: 7px 10px;
}
.hw-tool textarea { resize: vertical; min-height: 180px; line-height: 1.5; margin-top: 4px; }
.hw-tool textarea:focus,
.hw-tool select:focus,
.hw-tool input:focus { outline: 2px solid var(--purple); outline-offset: 1px; }

.hw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 12px; margin-top: 12px; }
.hw-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 0.8rem; color: var(--muted); }
.hw-field__label { display: flex; justify-content: space-between; gap: 6px; font-weight: 600; }
.hw-field__label output { color: var(--purple); font-variant-numeric: tabular-nums; }
.hw-field input[type="range"] { width: 100%; accent-color: var(--purple); }
.hw-field input[type="color"] { width: 100%; height: 34px; padding: 2px; border: 1px solid rgba(98, 54, 255, 0.18); border-radius: 10px; background: #fff; cursor: pointer; }
.hw-field--check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.hw-field--check input { width: 18px; height: 18px; accent-color: var(--purple); }

.hw-note { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); }
.hw-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 8px; }
.hw-sample { display: block; max-width: 100%; max-height: 140px; margin-top: 10px; border-radius: 10px; }

.hw-panel__foot { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; }

/* Buttons */
.hw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid rgba(98, 54, 255, 0.2);
  border-radius: 999px;
  background: #fff;
  color: var(--purple-navy);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.hw-btn:hover { background: var(--purple-soft); border-color: rgba(98, 54, 255, 0.35); }
.hw-btn:active { transform: scale(0.97); }
.hw-btn:disabled { opacity: 0.45; cursor: default; }
.hw-btn:disabled:hover { background: #fff; }
.hw-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.hw-btn--primary { background: var(--lime); border-color: var(--lime); color: var(--purple-navy); }
.hw-btn--primary:hover { background: #d3ff85; border-color: #d3ff85; }
.hw-btn--ghost { border-color: transparent; color: var(--muted); }
.hw-btn--sm { min-height: 32px; padding: 5px 11px; font-size: 0.8rem; }
.hw-btn--icon { width: 36px; min-height: 36px; padding: 0; }
.hw-btn--block { width: 100%; margin-top: 10px; }

/* Preview */
.hw-preview { min-width: 0; padding: 14px; }
.hw-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 8px; }
.hw-pager { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; }
.hw-zoom { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; color: var(--muted); }
.hw-zoom select { width: auto; }
#hwRegen { margin-left: auto; }

.hw-msg { min-height: 20px; font-size: 0.85rem; color: var(--muted); }
.hw-msg[data-kind="error"] { color: #b42318; }

.hw-stage {
  overflow: auto;
  max-height: calc(100vh - 230px);
  min-height: 360px;
  padding: 16px;
  border-radius: 14px;
  background: #ebe8f5;
  text-align: center;
}
#hwPage { display: inline-block; background: #fff; box-shadow: 0 8px 26px rgba(42, 22, 90, 0.2); }

.hw-export {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(98, 54, 255, 0.1);
}
.hw-export__quality .hw-field { flex-direction: row; align-items: center; gap: 8px; }
.hw-export__quality select { width: auto; }
.hw-export .hw-row { margin: 0; }

.hw-print-area { display: none; }

/* Responsive --------------------------------------------------------------- */
@media (max-width: 960px) {
  .hw-hero-inner { grid-template-columns: 1fr; text-align: center; }
  .handwriting-page .page-hero p { margin-left: auto; margin-right: auto; }
  .hw-hero-note { justify-content: center; }
  .hw-cards--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hw-hero-visual img { max-width: 320px; }

  .hw-tool { grid-template-columns: 1fr; }
  .hw-panel { position: static; max-height: none; }
  .hw-stage { max-height: 75vh; min-height: 260px; }
}

@media (max-width: 560px) {
  .hw-section > .container { padding-left: 10px; padding-right: 10px; }
  .hw-panel { padding: 4px 12px 12px; }
  .hw-preview { padding: 10px; }
  .hw-grid { grid-template-columns: 1fr; }
  .hw-cards--2, .hw-cards--4 { grid-template-columns: 1fr; }
  .hw-list-cols { columns: 1; }
  .hw-stage { padding: 8px; }
  #hwRegen { margin-left: 0; }
  .hw-export .hw-row .hw-btn { flex: 1 1 calc(50% - 8px); }
}

/* Print: only the rendered pages ------------------------------------------- */
@media print {
  body > *:not(#hwPrintArea) { display: none !important; }
  #hwPrintArea { display: block; }
  #hwPrintArea img { display: block; width: 100%; page-break-after: always; break-after: page; }
}

@media (prefers-reduced-motion: reduce) {
  .hw-btn, .hw-step summary::after { transition: none; }
}
