/* TextToCursive — shared stylesheet (no frameworks, no dependencies) */

:root {
  --ink: #1f2430;
  --muted: #5b6472;
  --brand: #7c3aed;
  --brand-dark: #5b21b6;
  --accent: #f5f3ff;
  --line: #e5e7eb;
  --bg: #ffffff;
  --bg-alt: #f7f7f9;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 16.5px;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 2.1rem; line-height: 1.25; margin: 0.4em 0 0.5em; }
h2 { font-size: 1.55rem; margin: 0 0 0.7em; }
h3 { font-size: 1.15rem; margin: 0 0 0.4em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.4em; }
li { margin-bottom: 0.35em; }
img { max-width: 100%; height: auto; }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}
.logo a {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}
.logo a:hover { text-decoration: none; }
.nav-links { display: flex; gap: 18px; flex-wrap: wrap; margin-left: auto; }
.nav-links a {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 4px 2px;
}
.nav-links a:hover { color: var(--brand-dark); text-decoration: none; }
.nav-links a.active { color: var(--brand-dark); font-weight: 600; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 12px 0 0;
}
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.breadcrumb li::after { content: "›"; margin-left: 6px; color: #c3c8d2; }
.breadcrumb li:last-child::after { content: ""; }
.breadcrumb a { color: var(--muted); }

/* ---------- Sections ---------- */
.section { padding: 48px 0; }
.section.alt { background: var(--bg-alt); }
.section.hero { padding: 36px 0 44px; background: linear-gradient(180deg, #faf8ff 0%, #ffffff 100%); }
.byline { font-size: 0.88rem; color: var(--muted); margin: 0 0 1.2em; }
.lead { font-size: 1.08rem; color: #374050; }

/* ---------- Tool panel ---------- */
.tool-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(60, 40, 120, 0.07);
  padding: 22px;
  margin-top: 18px;
}
.tool-input {
  width: 100%;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
}
.tool-input:focus { outline: 2px solid var(--accent); border-color: var(--brand); }

.tabs { display: flex; gap: 8px; margin: 16px 0 0; border-bottom: 1px solid var(--line); }
.tab-btn {
  border: 1px solid var(--line);
  border-bottom: none;
  background: var(--bg-alt);
  padding: 9px 18px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
}
.tab-btn.active {
  background: #fff;
  color: var(--brand-dark);
  font-weight: 600;
  position: relative;
  top: 1px;
}
.tab-pane { display: none; padding-top: 18px; }
.tab-pane.active { display: block; }

.font-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.font-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
}
.font-card:hover { border-color: var(--brand); }
.font-card.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--accent); }
.font-card .font-name { font-size: 0.8rem; color: var(--muted); }
.font-card .font-sample { font-size: 1.5rem; line-height: 1.4; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.preview-stage {
  border: 1px dashed #d5d0e8;
  border-radius: 10px;
  padding: 28px 20px;
  margin: 16px 0;
  text-align: center;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
}
#preview-text { max-width: 100%; }

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 22px;
  margin: 8px 0 4px;
}
.control label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 4px; }
.control input[type="range"] { width: 100%; }
.control input[type="color"] { width: 46px; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: #fff; }

/* Custom select + checkbox (replace browser defaults) */
.control select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 9px 36px 9px 12px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1.5l5 5 5-5" fill="none" stroke="%23878e9c" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>') no-repeat right 12px center;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.control select:hover { border-color: var(--brand); }
.control select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--brand); }

.control input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  display: inline-grid;
  place-content: center;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.control input[type="checkbox"]:hover { border-color: var(--brand); }
.control input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.control input[type="checkbox"]:checked { background: var(--brand); border-color: var(--brand); }
.control input[type="checkbox"]:checked::after {
  content: "";
  width: 11px;
  height: 6px;
  border: 2.5px solid #fff;
  border-top: none;
  border-right: none;
  transform: rotate(-45deg) translate(1px, -1px);
}

.presets { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 0; }
.preset-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

/* Segmented alignment control (left / center / right) */
.align-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.align-group button {
  border: none;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
}
.align-group button:last-child { border-right: none; }
.align-group button.active {
  background: var(--accent);
  color: var(--brand-dark);
  font-weight: 600;
}

/* Checkerboard shown when exporting with a transparent background */
.preview-stage.transparent {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #d9dce3 25%, transparent 25%, transparent 75%, #d9dce3 75%),
    linear-gradient(45deg, #d9dce3 25%, transparent 25%, transparent 75%, #d9dce3 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-size: 0.98rem;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--brand-dark); border: 1px solid var(--brand); }
.btn.secondary:hover { background: var(--accent); }
.tool-badges { margin-top: 14px; font-size: 0.85rem; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.tool-badges span::before { content: "✓ "; color: #16a34a; }

/* ---------- Unicode copy rows ---------- */
.copy-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.copy-row {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
}
.copy-row .copy-sample { flex: 1; font-size: 1.35rem; word-break: break-all; }
.copy-row .copy-label { font-size: 0.8rem; color: var(--muted); min-width: 110px; }
.copy-btn {
  border: 1px solid var(--line);
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}
.copy-btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.copy-btn.copied { background: #ecfdf5; border-color: #34d399; color: #065f46; }

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.style-cell {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.style-cell:hover { border-color: var(--brand); box-shadow: 0 2px 12px rgba(124, 58, 237, 0.08); }
.style-cell .style-name { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.style-cell .style-text { display: block; font-size: 1.4rem; word-break: break-all; }
.style-cell .copy-hint { display: block; font-size: 0.78rem; color: var(--brand-dark); margin-top: 6px; }

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: #fff;
}
.card h3 { margin-top: 0; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--brand-dark); text-decoration: underline; }

/* ---------- Font showcase (home) ---------- */
.showcase-row {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}
.showcase-row:last-child { border-bottom: none; }
.showcase-sample { font-size: 2rem; line-height: 1.35; color: var(--ink); word-break: break-word; }

/* ---------- Name generator comparison grid ---------- */
.name-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.name-cell {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}
.name-preview {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
  padding: 8px 6px;
  border-radius: 6px;
}
/* Checkerboard inside each cell when exporting with transparency */
.name-grid.transparent .name-preview {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #d9dce3 25%, transparent 25%, transparent 75%, #d9dce3 75%),
    linear-gradient(45deg, #d9dce3 25%, transparent 25%, transparent 75%, #d9dce3 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.name-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.name-meta .font-name { font-size: 0.82rem; color: var(--muted); }

/* ---------- Tables ---------- */
table.ref-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 22px;
  font-size: 0.95rem;
}
table.ref-table th, table.ref-table td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}
table.ref-table th { background: var(--bg-alt); }
table.ref-table td.cursive-cell { font-size: 1.5rem; }

/* ---------- FAQ ---------- */
.faq-item { border-bottom: 1px solid var(--line); padding: 16px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item h3 { margin: 0 0 6px; font-size: 1.05rem; }
.faq-item p { margin: 0; color: #374050; }

/* ---------- Worksheet ---------- */
.worksheet-area {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 32px;
  margin-top: 18px;
}
.ws-unit { margin-bottom: 26px; }
/* Four-line guide system: topline / midline (x-height) / baseline / descender */
.ws-line {
  position: relative;
  height: 96px;
}
.ws-g { position: absolute; left: 0; right: 0; }
.ws-top  { top: 0;  border-top: 1px dashed #c7cedb; }
.ws-mid  { top: 32px; border-top: 1px dashed #9aa4b2; }
.ws-base { top: 64px; border-top: 2px solid #333; }
.ws-desc { top: 92px; border-top: 1px dashed #c7cedb; }
.ws-line .ws-text {
  font-family: 'Dancing Script', cursive;
  position: absolute;
  left: 14px;
  bottom: 30px; /* sit on the solid baseline */
  font-size: 46px;
  line-height: 1;
  color: #b8bfca; /* light gray for tracing */
  white-space: nowrap;
}
/* Outline tracing mode: hollow letters via text stroke */
.mode-outline .ws-line .ws-text {
  color: transparent;
  -webkit-text-stroke: 1.2px #8a93a3;
}
/* Firefox/legacy fallback: no stroke support → keep solid gray tracing */
@supports not (-webkit-text-stroke: 1px #000) {
  .mode-outline .ws-line .ws-text { color: #b8bfca; }
}
/* Red starting dot on the baseline */
.ws-dot {
  position: absolute;
  left: 0;
  top: 59px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
}
.worksheet-area.no-dots .ws-dot { display: none; }
/* Landscape preview: wider sheet */
.worksheet-area { max-width: 720px; }
.worksheet-area.landscape { max-width: 100%; }
.worksheet-title-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 24px;
}

/* ---------- Footer ---------- */
.site-footer {
  background: #171a21;
  color: #aab2c0;
  margin-top: 40px;
  padding: 44px 0 26px;
  font-size: 0.92rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 28px;
}
.site-footer h3 { color: #fff; font-size: 0.95rem; margin: 0 0 12px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 8px; }
.site-footer a { color: #aab2c0; }
.site-footer a:hover { color: #fff; }
.footer-brand p { margin: 10px 0 0; max-width: 340px; }
.social-links { display: flex; gap: 12px; margin-top: 14px; }
.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid #39404d;
  color: #aab2c0;
}
.social-links a:hover { border-color: #fff; color: #fff; }
.footer-bottom {
  border-top: 1px solid #2a2f3a;
  margin-top: 30px;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
}

@media (max-width: 760px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.7rem; }
  .showcase-sample { font-size: 1.6rem; }
}

/* ---------- Print (worksheet) ---------- */
@media print {
  .site-header, .site-footer, .breadcrumb, .no-print, #scroll-to-top { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .section { padding: 0; }
  .worksheet-area { border: none; padding: 0; margin: 0; max-width: 100%; }
  .tool-panel { box-shadow: none; border: none; padding: 0; }
  /* Keep each practice unit (tracing rows + blank rows) on one page */
  .ws-unit { break-inside: avoid; page-break-inside: avoid; }
  /* Guides, starting dots and outline strokes must print */
  .ws-g, .ws-dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
