/* =============================================================================
   Dynamic Tech World - ToolHub | Word Counter styles
   -----------------------------------------------------------------------------
   Tool-specific styling ONLY. All design tokens (--dtw-red, --dtw-gold,
   --dtw-dark, --dtw-text, --dtw-text-muted, --radius, --font-sans, …) and the
   header / footer / nav / .btn / .chip / .ad-728-slot rules come from the
   shared hub CSS (../css/*.css), which this file never overrides globally.
   Mobile-first. No external assets.
   ============================================================================= */

/* ----------------------------------------------------------- accessibility */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.link-btn {
  background: none; border: 0; color: var(--dtw-gold);
  font: inherit; cursor: pointer; text-decoration: underline; padding: 0;
}
:focus-visible {
  outline: 2px solid var(--dtw-gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------- breadcrumb */
.breadcrumb { padding-top: 18px; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb li { color: var(--dtw-text-muted); font-size: 0.85rem; }
.breadcrumb li + li::before { content: "›"; margin-right: 6px; color: var(--dtw-text-muted); }
.breadcrumb a { color: var(--dtw-text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--dtw-gold); }
.breadcrumb li[aria-current="page"] { color: var(--dtw-text); }

/* ------------------------------------------------------------ tool header */
.tool-head { text-align: center; padding: 22px 0 6px; }
.tool-head h1 {
  font-size: clamp(1.9rem, 5vw, 2.9rem); font-weight: 800; line-height: 1.1;
  margin: 6px 0 10px;
  background: linear-gradient(120deg, #fff 30%, var(--dtw-gold) 130%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ------------------------------------------------------------ tool layout */
.tool-section {
  padding: 18px 0 8px;
  max-width: 980px;
}

/* toolbar */
.tool-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 12px;                 /* flush: buttons align exactly with the textarea edge */
}
.tool-toolbar .btn { padding: 9px 16px; font-size: 0.85rem; }
.tool-toolbar .chip { min-width: 42px; justify-content: center; font-size: 0.85rem; }
.toolbar-sep {
  width: 1px; align-self: stretch; margin: 2px 4px;
  background: var(--dtw-border);
}
.file-btn { position: relative; cursor: pointer; margin: 0; }

/* editor */
.editor-wrap { position: relative; }
.text-input {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  padding: 18px;
  font-family: var(--font-sans);
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--dtw-text);
  background: var(--dtw-surface-2);
  border: 1px solid var(--dtw-border);
  border-radius: var(--radius);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.text-input:focus {
  outline: none;
  border-color: var(--dtw-red);
  box-shadow: var(--shadow-glow);
}
.text-input::placeholder { color: var(--dtw-text-muted); opacity: .55; }

.draft-note {
  margin: 8px 2px 0;
  font-size: 0.82rem;
  color: var(--dtw-text-muted);
  background: rgba(255,184,0,.07);
  border: 1px solid rgba(255,184,0,.22);
  border-radius: 9px;
  padding: 7px 12px;
}
.draft-note #draft-text { color: var(--dtw-gold); font-weight: 600; }

/* --------------------------------------------------------------- stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 16px 10px;
  text-align: center;
  background: var(--dtw-surface);
  border: 1px solid var(--dtw-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.stat:hover { border-color: rgba(225,2,2,.4); transform: translateY(-1px); }
.stat-value {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 800;
  line-height: 1;
  color: var(--dtw-text);
}
.stat-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--dtw-text-muted);
}
/* emphasise the hero stat (Words) */
#s-words { color: var(--dtw-gold); }

@media (min-width: 560px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

/* secondary stats strip */
.substats {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  margin-top: 14px; padding: 12px 14px;
  font-size: 0.88rem; color: var(--dtw-text-muted);
  background: var(--dtw-surface-2);
  border: 1px solid var(--dtw-border-soft);
  border-radius: var(--radius-sm);
}
.substats strong { color: var(--dtw-text); font-weight: 700; }

/* ----------------------------------------------------- character presets */
.presets { margin-top: 22px; }
.block-title {
  font-size: 1.05rem; font-weight: 700; color: var(--dtw-text);
  margin: 0 0 12px;
}
.preset-list { list-style: none; display: grid; gap: 10px; }
.preset {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center; gap: 4px 12px;
  padding: 10px 14px;
  background: var(--dtw-surface);
  border: 1px solid var(--dtw-border);
  border-radius: var(--radius-sm);
}
.preset-name { font-size: 0.9rem; font-weight: 600; }
.preset-count { font-size: 0.8rem; color: var(--dtw-text-muted); }
.preset-count b { color: var(--dtw-text); }
.preset-bar {
  grid-column: 1 / -1;
  height: 8px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,.08);
}
.preset-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--dtw-red), var(--dtw-gold));
  border-radius: 999px;
  transition: width .12s linear;
}
.preset.is-over .preset-fill { background: var(--dtw-red); }
.preset.is-over .preset-count b { color: var(--dtw-red); }

/* ------------------------------------------------------------ collapsibles */
.panel {
  margin-top: 18px;
  background: var(--dtw-surface);
  border: 1px solid var(--dtw-border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.panel > summary {
  cursor: pointer; list-style: none; font-weight: 700; color: var(--dtw-text);
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before { content: "▸ "; color: var(--dtw-red); transition: transform var(--speed); display: inline-block; }
.panel[open] > summary::before { content: "▾ "; }
.panel-body { margin-top: 14px; }

.field-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; }
.field-label { font-size: 0.78rem; color: var(--dtw-text-muted); }
.field input[type="text"] {
  padding: 10px 12px;
  color: var(--dtw-text);
  background: var(--dtw-surface-2);
  border: 1px solid var(--dtw-border);
  border-radius: var(--radius-sm);
}
.field input[type="text"]:focus { outline: none; border-color: var(--dtw-red); }
.field-row.checks { align-items: center; margin-top: 10px; gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; color: var(--dtw-text-muted); cursor: pointer; }
.check input { accent-color: var(--dtw-red); width: 16px; height: 16px; }
.match-count { font-size: 0.82rem; color: var(--dtw-text-muted); }
.btn-sm { padding: 8px 16px; font-size: 0.82rem; margin-left: auto; }

/* keyword list */
.keyword-list { list-style: none; display: grid; gap: 6px; margin-top: 12px; }
.keyword-list li {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 6px 0; font-size: 0.9rem;
}
.kw-bar {
  grid-column: 1 / -1; height: 6px; border-radius: 999px;
  background: rgba(255,255,255,.07); overflow: hidden;
}
.kw-bar > span { display: block; height: 100%; background: var(--dtw-red); }
.kw-word { color: var(--dtw-text); }
.kw-count { color: var(--dtw-text-muted); font-variant-numeric: tabular-nums; }
.kw-empty { color: var(--dtw-text-muted); font-style: italic; justify-content: center; }

/* ----------------------------------------------------------- ad + sponsor */
.ad-wrap { padding: 22px 0 6px; }
.ad-wrap .ad-728-slot { max-width: 760px; margin: 0 auto; }

.sponsored-cta {
  display: block; text-align: center;
  margin: 14px auto 4px; max-width: 760px;
  padding: 12px 18px;
  font-weight: 700; font-size: 0.92rem; text-decoration: none;
  color: #fff;
  background: linear-gradient(90deg, var(--dtw-red-dark), var(--dtw-red));
  border: 1px solid rgba(255,184,0,.4);
  border-radius: 999px;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.sponsored-cta:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(225,2,2,.4); }
.sponsored-cta.is-muted {
  opacity: .5; cursor: default; pointer-events: none; filter: grayscale(.4);
}

/* ------------------------------------------------------------- content blocks */
.content-block { padding: 28px 0; max-width: 820px; }
.steps { list-style: decimal; margin: 4px 0 0 1.2em; display: grid; gap: 8px; color: var(--dtw-text-muted); }
.steps strong, .prose strong { color: var(--dtw-text); }
.prose { color: var(--dtw-text-muted); line-height: 1.75; }
.prose h3 { color: var(--dtw-text); font-size: 1.1rem; margin: 20px 0 6px; }
.prose p, .prose ul { margin: 0 0 12px; }
.prose a { color: var(--dtw-gold); text-decoration: none; border-bottom: 1px solid rgba(255,184,0,.4); }
.prose a:hover { color: var(--dtw-text); }
.prose code, .steps code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em; background: rgba(255,255,255,.07);
  padding: 1px 5px; border-radius: 5px; color: var(--dtw-gold);
}
.limit-table {
  list-style: none; display: grid; gap: 6px; margin: 8px 0 4px;
}
.limit-table li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 12px; background: var(--dtw-surface);
  border: 1px solid var(--dtw-border); border-radius: var(--radius-sm);
  font-size: 0.9rem; color: var(--dtw-text-muted);
}
.limit-table b { color: var(--dtw-text); }

/* FAQ */
.faq { display: grid; gap: 10px; }
.faq details {
  background: var(--dtw-surface); border: 1px solid var(--dtw-border);
  border-radius: var(--radius-sm); padding: 12px 16px;
}
.faq summary { cursor: pointer; font-weight: 600; color: var(--dtw-text); }
.faq details[open] summary { margin-bottom: 8px; }
.faq p { color: var(--dtw-text-muted); font-size: 0.92rem; }

/* related tools */
.related-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 620px) { .related-grid { grid-template-columns: repeat(3, 1fr); } }
.related-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; text-decoration: none;
  background: var(--dtw-surface); border: 1px solid var(--dtw-border);
  border-radius: var(--radius); transition: border-color var(--speed), transform var(--speed);
}
.related-card:hover { border-color: rgba(225,2,2,.4); transform: translateY(-2px); }
.related-ico { font-size: 1.6rem; }
.related-card strong { display: block; color: var(--dtw-text); font-size: 0.95rem; }
.related-card small { color: var(--dtw-text-muted); font-size: 0.8rem; }
.back-to-hub { margin-top: 18px; text-align: center; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 540px) {
  .tool-toolbar .btn { padding: 9px 12px; }
  .field-row.checks { gap: 10px 14px; }
  .btn-sm { margin-left: 0; width: 100%; }
  .toolbar-sep { display: none; }
}
@media (max-width: 380px) {
  .text-input { padding: 14px; font-size: 0.98rem; }
  .tool-toolbar { gap: 6px; }
  .tool-toolbar .btn { padding: 8px 11px; font-size: 0.8rem; }
  .tool-toolbar .chip { min-width: 38px; padding: 7px 10px; }
  .stat { padding: 12px 8px; }
  .stat-value { font-size: 1.3rem; }
  .preset { padding: 9px 10px; }
  .content-block { padding: 22px 0; }
  .related-card { padding: 12px; }
  .related-ico { font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =============================================================================
   MOBILE ROBUSTNESS — stop any element overflowing the screen width
   (fixes "text cut at the corners" across every device/browser)
   ============================================================================= */
.tool-toolbar, .field-row, .substats, .related-grid, .preset-list, .keyword-list,
.header-inner, .nav-list, .footer-grid, .footer-bottom, .breadcrumb ol { min-width: 0; }
.tool-toolbar > *, .field-row > *, .substats > *, .preset > *,
.keyword-list > li, .related-card > *, .field, .limit-table li, .breadcrumb li { min-width: 0; }

.prose, .prose p, .prose li, .kw-word, #s-longest, .preset-name, .preset-count,
.stat-value, .related-card small, .draft-note, .sponsored-cta {
  overflow-wrap: anywhere; word-break: break-word;
}
.editor-wrap, .text-input, .ad-wrap, .sponsored-cta { max-width: 100%; }

/* =============================================================================
   LIGHT THEME — tool-specific patches (global tokens live in ../css/theme.css)
   ============================================================================= */
html[data-theme="light"] .tool-head h1 {
  background: linear-gradient(120deg, var(--dtw-text) 30%, var(--dtw-gold) 130%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
html[data-theme="light"] .text-input { background: #fff; }
html[data-theme="light"] .text-input:focus {
  box-shadow: 0 0 0 1px rgba(225,2,2,.3), 0 8px 24px rgba(225,2,2,.12);
}
html[data-theme="light"] .chip { border-color: rgba(0,0,0,.16); color: var(--dtw-text-muted); }
html[data-theme="light"] .chip:hover { border-color: rgba(0,0,0,.3); color: var(--dtw-text); }
html[data-theme="light"] .preset-bar,
html[data-theme="light"] .kw-bar { background: rgba(0,0,0,.1); }
html[data-theme="light"] .draft-note { background: rgba(255,184,0,.12); }
html[data-theme="light"] .file-btn { color: var(--dtw-text); }
html[data-theme="light"] .prose code,
html[data-theme="light"] .steps code { background: rgba(0,0,0,.07); }

/* =============================================================================
   INTRO LINE-CLAMP  — top description clamped to 2 lines with Show more / less
   ============================================================================= */
.hero-sub.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;                       /* standard property (Firefox / future) */
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.intro-toggle {
  display: inline-block;
  margin-top: 6px;
  background: none; border: 0; padding: 4px 2px;
  font: inherit; font-size: 0.85rem; font-weight: 700;
  color: var(--dtw-gold); cursor: pointer; text-decoration: none;
}
.intro-toggle:hover { color: var(--dtw-red); text-decoration: underline; }
.intro-toggle:focus-visible { outline: 2px solid var(--dtw-gold); outline-offset: 2px; border-radius: 4px; }

/* =============================================================================
   VISIBLE TOAST  — confirms Copy / Download / Upload / Clear / Replace actions
   ============================================================================= */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  background: var(--dtw-surface-2); color: var(--dtw-text);
  border: 1px solid var(--dtw-border); border-left: 3px solid var(--dtw-red);
  padding: 11px 18px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow-card); z-index: 300;
  max-width: calc(100% - 32px); text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 480px) { .toast { bottom: 18px; font-size: 0.85rem; padding: 10px 16px; } }
