/*
 * tool-page.css (site root, so the locale generator never prefixes its
 * href): components shared by the /tools/ pages that sit on the
 * workbench template (tools-workbench.css): the Xtream <-> M3U converter
 * (.xc-*), the "next step" card (.nx-*), data-path chips (.dp-*), the
 * related-tools block (.rel-*) and the /tools/ hub router (.hub-*).
 *
 * Tokens come from styles.css (klipa-hq IDENTITY.md): ink surfaces,
 * hairlines, one tally accent reserved for the primary action, JetBrains
 * Mono for anything a user copies. Mobile first; every tap target >= 44 px;
 * inputs are 16 px on phones so iOS does not zoom on focus.
 */

/* ────────────────────────────────────────────── page shell */

.article-main.xc-main { max-width: calc(52rem + 2 * var(--gutter)); }
.xc-main .article-title { margin-bottom: 12px; }
.xc-main .article-lede { margin-bottom: 20px; font-size: clamp(16px, 1.4vw, 18px); }
.xc-main .breadcrumb { margin-bottom: 14px; }
/* Links inside the breadcrumb are told apart by more than colour (WCAG
   1.4.1, Lighthouse link-in-text-block). */
.breadcrumb a { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.breadcrumb a:hover { text-decoration-color: currentColor; }

/* ────────────────────────────────────────────── tool card */

.xc-tool.wb-inputcard { margin: 0 0 16px; padding: 16px; }

.xc-smart { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.xc-smart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.xc-smart-label { color: var(--text); font-size: 15px; font-weight: 600; }
.xc-smart-input {
  display: block;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-control);
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font-mono);
  resize: vertical;
  transition: border-color var(--t-small) var(--ease-lock), box-shadow var(--t-small) var(--ease-lock);
}
.xc-smart-input::placeholder { color: var(--text-3); font-family: var(--font-body); }
.xc-smart-input:focus { outline: none; border-style: solid; border-color: var(--tally); box-shadow: 0 0 0 3px var(--tally-glow); }
.xc-smart-hint { margin: 8px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.45; }

/* Direction switch: a two-way segmented control. */
.xc-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--bg);
}
.xc-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: background-color var(--t-small) var(--ease-lock), color var(--t-small) var(--ease-lock);
}
.xc-tab:hover { color: var(--text); }
.xc-tab:focus-visible { outline: 2px solid var(--tally); outline-offset: 1px; }
.xc-tab[aria-selected="true"] { border-color: var(--line-strong); background: var(--raised); color: var(--text); }
.xc-tab-title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.xc-tab-sub { display: none; color: var(--text-3); font: 12px/1.3 var(--font-mono); }

.xc-form { display: grid; gap: 12px; }
.xc-field { display: grid; gap: 6px; min-width: 0; }
.xc-field .tool-label { margin: 0; }
.xc-row2 { display: grid; gap: 12px; }
.xc-form .tool-input { font-size: 16px; }
/* The password input is always left-to-right (dir="ltr", also on /ar/), so
   the reveal button sits on its physical right in every locale. */
.xc-secret { position: relative; }
.xc-secret .tool-input { padding-right: 72px; padding-left: 14px; }
.xc-reveal {
  position: absolute;
  inset-block: 4px;
  right: 4px;
  min-width: 60px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: 600 13px/1 var(--font-body);
  cursor: pointer;
}
.xc-reveal:hover { color: var(--text); background: var(--raised); }
.xc-reveal:focus-visible { outline: 2px solid var(--tally); outline-offset: -2px; }

.xc-options { border: 1px solid var(--line); border-radius: var(--r-control); background: var(--bg); }
.xc-options > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.xc-options > summary::-webkit-details-marker { display: none; }
.xc-options > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-inline-start: auto;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--t-small) var(--ease-lock);
}
.xc-options[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.xc-options > summary:hover { color: var(--text); }
.xc-options-state { color: var(--text-3); font: 500 12px/1 var(--font-mono); }
.xc-options-grid { display: grid; gap: 14px; padding: 4px 14px 14px; }
.xc-select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--text);
  font: 15px var(--font-body);
}
.xc-select:focus { outline: none; border-color: var(--tally); box-shadow: 0 0 0 3px var(--tally-glow); }
.xc-hint { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.45; }

.xc-submit.tool-submit { justify-self: stretch; margin-top: 4px; }

/* ────────────────────────────────────────────── results */

.xc-result, .xc-where, .xc-privacy {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}
.xc-result-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  color: var(--text);
  font: 700 20px/1.25 var(--font-body);
}
.xc-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-tint); }
.xc-result-helper { margin: 0 0 8px; color: var(--text-2); font-size: 14px; line-height: 1.5; }

.xc-out { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.xc-out:last-of-type { border-bottom: 0; }
.xc-out-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.xc-out-label { color: var(--text); font-size: 15px; font-weight: 600; }
.xc-out-hint { color: var(--text-3); font-size: 13px; }
.xc-out-code {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--raised);
  color: var(--text);
  font: 13px/1.5 var(--font-mono);
  overflow-wrap: anywhere;
  word-break: break-all;
  text-align: left;
  user-select: all;
}
.xc-out-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.xc-out-actions .wb-btn { flex: 1; min-height: 44px; }
.xc-copy.is-ok { border-color: var(--success); color: var(--success); }

.xc-notes { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.xc-notes li {
  position: relative;
  padding-inline-start: 16px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}
.xc-notes li::before {
  content: "";
  position: absolute;
  inset-inline-start: 2px;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
}
.xc-notes li.is-ok { color: var(--text); }
.xc-notes li.is-ok::before { background: var(--success); }
.xc-notes li.is-error { color: var(--text); }
.xc-notes li.is-error::before { background: var(--danger); }
.xc-smart .xc-notes { margin-top: 10px; }

.xc-fine, .xc-tip, .xc-verify { margin: 12px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.xc-tip { color: var(--text-2); font-size: 14px; }
.xc-tip strong { color: var(--text); font-weight: 600; }
.xc-fine a, .xc-tip a, .xc-verify a, .xc-privacy a, .nx a.nx-link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
.xc-fine a:hover, .xc-tip a:hover, .xc-verify a:hover, .xc-privacy a:hover, .nx a.nx-link:hover { text-decoration-color: var(--tally); }

/* Where to paste this */
.xc-where-head { display: grid; gap: 10px; margin-bottom: 10px; }
.xc-where-title { margin: 0; color: var(--text); font: 700 17px/1.3 var(--font-body); }
.xc-where-text { margin: 0; color: var(--text); font-size: 15px; line-height: 1.6; }

/* ────────────────────────────────────────────── next step */

.nx {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
}
.nx-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--text);
  font: 800 20px/1.2 var(--font-display);
  letter-spacing: -0.01em;
}
.nx-title::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tally);
  box-shadow: 0 0 0 4px var(--tally-glow);
}
:lang(ar) .nx-title, :lang(zh) .nx-title { letter-spacing: 0; }
.nx-grid { display: grid; gap: 12px; }
.nx-opt { display: grid; align-content: start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--bg); }
.nx-h { margin: 0; color: var(--text); font: 600 16px/1.3 var(--font-body); }
.nx-sub { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.nx-primary.wb-btn { min-height: 48px; font-size: 16px; }
.nx-qr { display: flex; align-items: center; gap: 14px; }
.nx-qr img { flex: none; width: 112px; height: 112px; border-radius: 8px; background: #fff; }
.nx-tvrow { display: flex; gap: 8px; }
.nx-code.tool-input { flex: 1; min-width: 0; font-size: 18px; letter-spacing: 0.12em; }
.nx-tvrow .wb-btn { min-height: 48px; }
.nx-error { margin: 0; color: var(--danger); font-size: 13px; }
.nx-disclosure { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.nx .tool-label { margin: 2px 0 0; }

/* A page with its own next-step card does not also float the download pill
   (site/tools/shared/cta.js) over a form the visitor is still filling in. */
body:has([data-cta-suppress]) .wb-cta { display: none !important; }

/* ────────────────────────────────────────────── privacy */

.xc-privacy-title { margin: 0 0 10px; color: var(--text); font: 700 17px/1.3 var(--font-body); }
.xc-privacy-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.xc-privacy-list li { color: var(--text-2); font-size: 14px; line-height: 1.55; }
.xc-privacy-list strong { color: var(--text); font-weight: 600; }

/* ────────────────────────────────────────────── content under the tool */

.xc-main .wb-docs { margin-top: 40px; }
.xc-main .wb-docs figure { margin: 16px 0 8px; }
.xc-main .wb-docs figure img { display: block; width: 100%; height: auto; border-radius: var(--r-card); }
.xc-main .wb-docs figcaption { margin-top: 8px; color: var(--text-3); font-size: 13px; }
.xc-pattern {
  margin: 12px 0 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--raised);
  color: var(--text);
  font: 13px/1.6 var(--font-mono);
  white-space: pre;
  direction: ltr;
  text-align: left;
}
.xc-advanced { margin: 24px 0 0; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); }
.xc-advanced > summary { min-height: 48px; padding: 14px 16px; color: var(--text); font-weight: 600; cursor: pointer; }
.xc-advanced > div { padding: 0 16px 16px; }

/* ────────────────────────────────────────────── Xtream login check */

.xk-tool .xc-tabs { margin-bottom: 16px; }
.xk-tool .xc-form { margin-bottom: 4px; }
.xk-panel { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.xk-steps { display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; counter-reset: xk; }
.xk-steps > li { display: grid; gap: 10px; padding-inline-start: 36px; position: relative; counter-increment: xk; }
.xk-steps > li::before {
  content: counter(xk);
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-2);
  font: 600 12px/22px var(--font-mono);
  text-align: center;
}
.xk-step-text { margin: 0; color: var(--text); font-size: 15px; line-height: 1.5; }
.xk-open.wb-btn { justify-self: start; min-height: 48px; }
.xk-open[aria-disabled="true"] { opacity: 0.45; }
.xk-disclosure { margin: 0 0 12px; font-size: 14px; color: var(--text-2); }
.xk-dot.is-failed, .xk-dot.is-expired { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-tint); }
.xk-dot.is-unknown { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-tint); }
.xk-facts { display: grid; gap: 0; margin: 12px 0 4px; }
.xk-fact { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 560px) { .xk-fact { grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); } }
.xk-fact:last-child { border-bottom: 0; }
.xk-fact dt { color: var(--text-3); font: 500 12px/1.6 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.xk-fact dd { margin: 0; color: var(--text); font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums; }

/* ────────────────────────────────────────────── data-path chips */

/* What leaves the browser, in words. Green dot: nothing; amber: something
   goes through klipa.tv (the words say what). Never colour alone. */
.dp {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}
.dp::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  margin-top: 0.42em;
  border-radius: 50%;
  background: var(--warning);
}
.dp-local::before { background: var(--success); }

/* ────────────────────────────────────────────── /tools/ hub */

.article-main.hub-main { max-width: calc(64rem + 2 * var(--gutter)); }
.hub-main .article-title { margin-bottom: 12px; }
.hub-lede-top { max-width: 44rem; }
.hub-h2 { margin: 40px 0 6px; color: var(--text); font: 700 22px/1.25 var(--font-body); }
.hub-lede { margin: 0 0 16px; color: var(--text-2); font-size: 15px; }

.hub-hero {
  display: grid;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--t-small) var(--ease-lock), background-color var(--t-small) var(--ease-lock);
}
.hub-hero:hover { border-color: var(--tally); background: var(--raised); }
.hub-hero:focus-visible { outline: 2px solid var(--tally); outline-offset: 2px; }
.hub-hero-kicker { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font: 500 12px/1.4 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.hub-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tally); box-shadow: 0 0 0 4px var(--tally-glow); }
.hub-hero-title { font: 800 clamp(22px, 3vw, 30px)/1.15 var(--font-display); letter-spacing: -0.01em; }
:lang(ar) .hub-hero-title, :lang(zh) .hub-hero-title { letter-spacing: 0; line-height: 1.35; }
.hub-hero-desc { color: var(--text-2); font-size: 16px; line-height: 1.5; max-width: 44rem; }
.hub-hero-go { justify-self: start; display: inline-flex; align-items: center; min-height: 44px; margin-top: 6px; padding: 0 18px; border-radius: var(--r-control); background: var(--tally); color: var(--tally-ink); font-weight: 600; }
.hub-hero:hover .hub-hero-go { background: var(--tally-hover); }

.hub-symptoms { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.hub-symptoms li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  overflow: hidden;
}
.hub-sym {
  display: grid;
  gap: 4px;
  min-height: 56px;
  padding: 12px 14px;
  color: var(--text);
  text-decoration: none;
  transition: background-color var(--t-small) var(--ease-lock);
}
.hub-sym:hover { background: var(--raised); }
.hub-sym:focus-visible, .hub-sym-guide:focus-visible { outline: 2px solid var(--tally); outline-offset: -2px; }
.hub-sym-text { font-size: 15px; font-weight: 600; line-height: 1.4; }
.hub-sym-tool { color: var(--tally-text); font-size: 14px; }
.hub-sym-guide {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-inline-start: 1px solid var(--line);
  color: var(--text-2);
  font-size: 13px;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
.hub-sym-guide:hover { color: var(--text); background: var(--raised); }

.hub-grid.tool-grid { margin-top: 12px; }
/* Dense rows on phones (icon beside the text), cards from 640 px. */
.hub-grid .tool-card a {
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  column-gap: 14px;
  row-gap: 4px;
  padding: 16px;
}
.hub-grid .tool-card-icon { grid-row: 1 / span 3; margin: 0; }
.hub-grid .tool-card-title, .hub-grid .tool-card-desc, .hub-grid .dp { grid-column: 2; }
.hub-grid .tool-card-desc { font-size: 14px; }
.hub-grid .dp { margin-top: 4px; }
@media (min-width: 640px) {
  .hub-grid .tool-card a { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; padding: 20px; row-gap: 8px; }
  .hub-grid .tool-card-icon { grid-row: auto; margin-bottom: 4px; }
  .hub-grid .tool-card-title, .hub-grid .tool-card-desc, .hub-grid .dp { grid-column: 1; }
  .hub-symptoms { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
  .hub-grid.tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ────────────────────────────────────────────── wider screens */

@media (min-width: 560px) {
  .xc-tab-sub { display: block; }
  .xc-row2 { grid-template-columns: 1fr 1fr; }
  .xc-options-grid { grid-template-columns: 1fr 1fr; }
  .xc-submit.tool-submit { justify-self: start; min-width: 200px; }
  .xc-out-actions .wb-btn { flex: none; min-width: 88px; }
  .xc-where-head { grid-template-columns: 1fr auto; align-items: center; }
  .xc-where-head .xc-select { width: auto; min-width: 260px; }
}

@media (min-width: 760px) {
  .xc-tool.wb-inputcard, .xc-result, .xc-where, .xc-privacy, .nx { padding: 20px 24px; }
  .xc-out { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "meta meta" "code actions"; align-items: center; column-gap: 12px; }
  .xc-out-meta { grid-area: meta; }
  .xc-out-code { grid-area: code; }
  .xc-out-actions { grid-area: actions; }
  .nx-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .xc-form .tool-input { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .xc-options > summary::after, .xc-tab, .xc-smart-input { transition: none; }
}

/* Direction arrows point the way the text reads. */
[dir="rtl"] .hub-hero-go span[aria-hidden],
[dir="rtl"] .hub-sym-tool span[aria-hidden] { display: inline-block; transform: scaleX(-1); }
