/* ==========================================================================
   Toolflect Text Tools — styles.css
   Shares the Toolflect design system used across image/pdf/seo-tools
   (same tokens, same components). New components are namespaced tt-*.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --brand: #5b5ce2;
  --brand-600: #4a4bd0;
  --brand-050: #eef0ff;
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --good: #16a34a;
  --good-bg: #ecfdf5;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 10px 30px rgba(16, 24, 40, .08);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #f7f8ff 0%, #ffffff 260px);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }

.container { width: min(1080px, 100% - 2rem); margin-inline: auto; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; border: 0; clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__mark { color: var(--brand); font-size: 1.35rem; line-height: 1; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__name { font-size: 1.05rem; font-weight: 700; }
.brand__tag { font-size: .7rem; color: var(--muted); font-weight: 500; letter-spacing: .02em; }

/* ---------- Hero ---------- */
.hero { padding: 3.25rem 0 2rem; text-align: center; }
.breadcrumb { display: flex; gap: .4rem; justify-content: center; align-items: center; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-bottom: 1.25rem; }
.breadcrumb a { color: var(--muted); }
.crumb-sep { color: var(--line-strong); }
.hero__title { font-size: clamp(1.9rem, 4vw, 3rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: .75rem; }
.hero__subtitle { max-width: 680px; margin: 0 auto 1.5rem; color: var(--ink-soft); font-size: 1.06rem; }
.hero__actions { margin-bottom: 1.5rem; }
.hero__trust { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; justify-content: center; padding: 0; margin: 0; color: var(--muted); font-size: .88rem; }

/* ---------- Tool card ---------- */
.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem; margin: .75rem 0 3rem; }
.tool-card__head { margin-bottom: 1rem; }
.tool-card__title { font-size: 1.4rem; }
.tool-card__sub { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease, transform .05s ease;
}
.btn:hover { background: var(--surface-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--brand-600); }
.btn--lg { padding: .85rem 1.6rem; font-size: 1rem; }
.btn--sm { padding: .4rem .7rem; font-size: .82rem; }
.btn--success { background: var(--good); border-color: var(--good); color: #fff; }
.btn--danger { color: var(--bad); border-color: #f3c1c1; }
.btn--danger:hover:not(:disabled) { background: var(--bad-bg); }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field__label { font-size: .8rem; font-weight: 600; color: var(--ink-soft); display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.field__counter { font-weight: 700; font-variant-numeric: tabular-nums; }
.input {
  font: inherit; font-size: .92rem; color: var(--ink);
  padding: .55rem .75rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); width: 100%;
}
.input:focus { outline: 2px solid var(--brand-050); border-color: var(--brand); }

/* ---------- Text Tools: privacy badge (reusable component §15) ---------- */
.tt-privacy-badge {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .5rem 1rem; border-radius: 999px;
  background: var(--good-bg); border: 1px solid #bbe7c9; color: #14532d;
  font-size: .84rem; font-weight: 600; margin: 0 0 1rem;
}
.tt-privacy-badge__icon { font-size: 1rem; line-height: 1; }
.tt-privacy-badge strong { font-weight: 800; }

/* ---------- Text Tools: input area ---------- */
.tt-textarea {
  width: 100%; min-height: 240px; resize: vertical;
  font: inherit; font-size: 1rem; line-height: 1.65;
  padding: .9rem 1rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.tt-textarea:focus { outline: 2px solid var(--brand-050); border-color: var(--brand); }
.tt-textarea::placeholder { color: var(--muted); }
.tt-textarea--out { background: var(--surface-soft); min-height: 170px; }

/* Case-mode selector row */
.tt-case-field { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--ink-soft); min-width: 240px; flex: 1 1 260px; }

/* ---------- Find & Replace controls ---------- */
.tt-fr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.tt-fr-grid .input { width: 100%; }
.tt-fr-toggles { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.tt-fr-check { display: inline-flex; align-items: center; gap: .45rem; font-size: .82rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.tt-fr-check input { accent-color: var(--brand); width: 1rem; height: 1rem; cursor: pointer; }
.tt-fr-error { color: var(--bad); background: var(--bad-bg); border: 1px solid #f3c1c1; border-radius: var(--radius-sm); padding: .45rem .7rem; font-size: .8rem; margin: .35rem 0 0; overflow-wrap: anywhere; }

/* ---------- Text Tools: toolbar ---------- */
.tt-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .8rem; }
.tt-toolbar__spacer { flex: 1 1 auto; }
.tt-counter { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Text Tools: stats grid ---------- */
.tt-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .75rem; margin-top: 1.25rem;
}
.tt-stat-card {
  background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .85rem .9rem; text-align: center;
}
.tt-stat-value { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.tt-stat-label { font-size: .78rem; font-weight: 600; color: var(--ink-soft); margin-top: .15rem; }
.tt-stat-hint { font-size: .7rem; color: var(--muted); margin-top: .1rem; }

/* ---------- Text Tools: per-tool controls ---------- */
.tt-controls {
  display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center;
  margin-top: 1rem; padding: .9rem 1rem;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.tt-wpm-field { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--ink-soft); min-width: 220px; flex: 1 1 240px; }
.tt-wpm-number { max-width: 110px; text-align: center; }
.tt-wpm-value { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand-600); }

/* ---------- SEO sections ---------- */
.seo-section { margin: 3rem 0; }
.seo-section__title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; margin-bottom: 1.25rem; }

.ht-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.ht-step { display: flex; gap: 1rem; align-items: flex-start; }
.ht-step__num { flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: 999px; background: var(--brand-050); color: var(--brand-600); font-weight: 800; display: grid; place-items: center; margin-top: .1rem; }
.ht-step__title { margin: 0 0 .15rem; font-size: 1.02rem; }
.ht-step__text { margin: 0; color: var(--ink-soft); font-size: .92rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.comparison-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 480px; }
.comparison-table th, .comparison-table td { text-align: start; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.comparison-table thead th { background: var(--surface-soft); font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.comparison-table tbody tr:last-child th, .comparison-table tbody tr:last-child td { border-bottom: none; }
.comparison-table tbody th { font-weight: 600; color: var(--ink); }

/* ---------- Privacy prose ---------- */
.privacy-box {
  background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 1.25rem 1.4rem;
}
.privacy-box p { color: var(--ink-soft); font-size: .95rem; margin: 0 0 .75rem; }
.privacy-box p:last-of-type { margin-bottom: 0; }
.privacy-box ul { margin: .75rem 0 0; padding-inline-start: 1.25rem; color: var(--ink-soft); font-size: .92rem; }
.privacy-box li { margin: .25rem 0; }

.faq-list { display: flex; flex-direction: column; gap: .6rem; }
.faq-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.faq-item__q { cursor: pointer; padding: .85rem 1rem; font-weight: 600; font-size: .95rem; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq-item__q::-webkit-details-marker { display: none; }
.faq-item__q::after { content: "+"; font-size: 1.2rem; color: var(--brand); transition: transform .15s ease; }
.faq-item[open] .faq-item__q::after { transform: rotate(45deg); }
.faq-item__a { padding: 0 1rem 1rem; color: var(--ink-soft); font-size: .9rem; }

.related-tools { display: flex; flex-wrap: wrap; gap: .6rem; }
.rt-chip { display: inline-block; padding: .5rem .9rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); font-size: .85rem; font-weight: 500; transition: border-color .15s ease, background .15s ease; }
.rt-chip:hover { border-color: var(--brand); background: var(--brand-050); text-decoration: none; }

/* ---------- Tools directory grid ---------- */
.tools-directory { margin-top: 3rem; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; margin-top: 1rem; }
.tools-grid__card { display: flex; flex-direction: column; gap: .25rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-sm); transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.tools-grid__card:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow); text-decoration: none; }
.tools-grid__card strong { font-size: .92rem; }
.tools-grid__card small { font-size: .76rem; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.75rem 0; color: var(--muted); font-size: .85rem; text-align: center; }
.site-footer__nav { display: flex; flex-wrap: wrap; gap: 1.25rem; justify-content: center; margin-bottom: .75rem; font-weight: 500; }
.site-footer__nav a { color: var(--ink-soft); }
.site-footer__nav a:hover { color: var(--brand); }
.site-footer__nav--legal { font-size: .8rem; gap: 1rem; }
.site-footer__nav--legal a { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .tool-card { padding: 1.1rem; }
  .hero { padding-top: 2.5rem; }
  .site-header__cta { display: none; }
  .brand__tag { display: none; }
  .tt-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .tt-stat-value { font-size: 1.2rem; }
}

/* RTL: the page chrome is English/LTR, but Arabic/RTL *content* inside the
   textarea flows correctly via dir="auto". Layout uses logical properties
   (padding-inline-start etc.) and never hardcodes a global direction. */


/* ===================== Group 14 — Text Comparison ===================== */
.diff-view {
  margin: .75rem 0 .5rem;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .875rem;
  line-height: 1.55;
}
.diff-row { display: flex; gap: .6rem; padding: .1rem .6rem; }
.diff-row--eq { background: transparent; }
.diff-row--del { background: var(--bad-bg); }
.diff-row--add { background: var(--good-bg); }

/* ===================== Group 16 — Markdown & Markup ===================== */
.md-preview-panel { margin-top: 1rem; }
.md-preview {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 1rem 1.25rem;
  overflow-wrap: break-word;
}
.md-preview > :first-child { margin-top: 0; }
.md-preview > :last-child { margin-bottom: 0; }
.md-preview h1, .md-preview h2, .md-preview h3 { margin: .9rem 0 .4rem; line-height: 1.3; }
.md-preview p { margin: .5rem 0; }
.md-preview code { background: var(--surface-soft); padding: .1em .35em; border-radius: 4px; }
.md-preview pre { background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .75rem; overflow: auto; }
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote { border-inline-start: 3px solid var(--brand); margin-inline-start: 0; padding-inline-start: .9rem; color: var(--muted); }
.md-preview table { border-collapse: collapse; margin: .6rem 0; }
.md-preview th, .md-preview td { border: 1px solid var(--line-strong); padding: .3rem .6rem; }
.md-preview img { max-width: 100%; height: auto; }

.diff-ln {
  flex: 0 0 4.4rem;
  color: var(--muted);
  text-align: right;
  user-select: none;
}
.diff-txt { white-space: pre-wrap; word-break: break-word; min-width: 0; }
.diff-note { padding: .4rem .6rem; color: var(--muted); font-style: italic; font-size: .8rem; }

