/*
 * tools.css — additive styles for /learn/ articles and /tools/ pages.
 *
 * Loads on top of styles.css. Reuses the same design tokens (--bg, --text,
 * --teal, etc.). Only contains rules that the landing page does not need:
 * markdown body typography, article lists, tool forms, tool result cards,
 * cross-device handoff widgets.
 */

/* ──────────────────────────────────────────────────────────
 * Article shell
 * ────────────────────────────────────────────────────────── */

.article-main {
  max-width: 44rem;
  margin: 2rem auto 0;
  padding: 0 0.5rem;
}

.article-title {
  margin: 1rem 0 0.5rem;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.article-lede {
  margin: 0 0 2rem;
  color: var(--text-soft);
  font-size: 1.18rem;
  line-height: 1.55;
}

.article-body {
  color: var(--text-soft);
  font-size: 1.04rem;
  line-height: 1.7;
}

.article-body p {
  margin: 0 0 1.1rem;
}

.article-body h2 {
  margin: 2.5rem 0 0.7rem;
  color: var(--text);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}

.article-body h3 {
  margin: 1.8rem 0 0.5rem;
  color: var(--text);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.22rem;
  font-weight: 600;
}

.article-body h2 + p,
.article-body h3 + p {
  margin-top: 0;
}

.article-body a {
  color: var(--teal);
  border-bottom: 1px solid rgba(45, 212, 191, 0.35);
  transition: color 160ms ease, border-color 160ms ease;
}

.article-body a:hover {
  color: #57e6d6;
  border-bottom-color: var(--teal);
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.1rem;
  padding-left: 1.4rem;
}

.article-body li {
  margin: 0.25rem 0;
}

.article-body code {
  padding: 0.12rem 0.36rem;
  border-radius: 4px;
  background: rgba(244, 245, 239, 0.07);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.92em;
}

.article-body pre {
  margin: 1.2rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
}

.article-body pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.article-body blockquote {
  margin: 1.4rem 0;
  padding: 0.6rem 1.1rem;
  border-left: 3px solid var(--teal);
  background: rgba(45, 212, 191, 0.06);
  color: var(--text-soft);
  font-style: italic;
}

.article-body img {
  display: block;
  margin: 1.6rem auto;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(124, 94, 240, 0.04), rgba(45, 212, 191, 0.03));
}

/* Device-framed phone mocks: cap width so they read as a phone next to
 * the text, not as a billboard. Landscape shots (TV, ecosystem) keep the
 * default full-column width. */
.article-body img.device-phone {
  max-width: 320px;
}

/* Caption: a paragraph holding only an italic block, immediately after a
 * paragraph that holds only an image. Matches the `![alt](url)` then blank
 * line then `*caption*` markdown convention. */
.article-body p:has(> img:only-child) {
  margin: 1.6rem 0 0.4rem;
}
.article-body p:has(> img:only-child) + p:has(> em:first-child:last-child) {
  margin-top: 0;
  margin-bottom: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.article-body hr {
  margin: 2.5rem 0;
  border: none;
  border-top: 1px solid var(--line);
}

/* ──────────────────────────────────────────────────────────
 * Install callout (end-of-article CTA)
 * ────────────────────────────────────────────────────────── */

.install-callout {
  margin: 3rem 0 1rem;
  padding: 1.4rem 1.4rem 1.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.06), rgba(255, 209, 102, 0.04));
}

.install-callout > p {
  margin: 0 0 1rem;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.32rem;
  font-weight: 600;
  color: var(--text);
}

.install-callout .action-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 0;
}

/* ──────────────────────────────────────────────────────────
 * Article list (/learn/index.html)
 * ────────────────────────────────────────────────────────── */

.article-list {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.article-list li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(244, 245, 239, 0.025);
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.article-list li:hover {
  border-color: var(--line-strong);
  background: rgba(244, 245, 239, 0.05);
  transform: translateY(-1px);
}

.article-list a {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  padding: 0.95rem 1.1rem;
  align-items: baseline;
}

.article-list time {
  grid-row: 1 / span 2;
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.84rem;
}

.article-list-title {
  color: var(--text);
  font-weight: 600;
  font-size: 1.05rem;
}

.article-list-desc {
  grid-column: 2;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.45;
}

.article-list-empty {
  margin: 2rem 0;
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

/* ──────────────────────────────────────────────────────────
 * Tool grid (/tools/index.html)
 * ────────────────────────────────────────────────────────── */

.tool-grid {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.tool-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(244, 245, 239, 0.05), rgba(244, 245, 239, 0.02));
  transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
  overflow: hidden;
}

.tool-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(120% 80% at 0% 0%, var(--tool-accent, var(--teal)) 0%, transparent 55%);
  transition: opacity 220ms ease;
  mix-blend-mode: screen;
}

.tool-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  background: linear-gradient(180deg, rgba(244, 245, 239, 0.07), rgba(244, 245, 239, 0.025));
}

.tool-card:hover::before {
  opacity: 0.18;
}

.tool-card a {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 0.65rem;
  height: 100%;
  padding: 1.3rem 1.35rem 1.4rem;
}

.tool-card-icon {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: 0.2rem;
  border-radius: 0.7rem;
  background: color-mix(in srgb, var(--tool-accent, var(--teal)) 18%, transparent);
  color: var(--tool-accent, var(--teal));
}

.tool-card-icon svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-card-title {
  display: block;
  color: var(--text);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.2;
}

.tool-card-desc {
  display: block;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.tool-card-teal   { --tool-accent: var(--teal); }
.tool-card-gold   { --tool-accent: var(--gold); }
.tool-card-coral  { --tool-accent: var(--coral); }
.tool-card-violet { --tool-accent: var(--violet); }
.tool-card-green  { --tool-accent: var(--green); }

/* ──────────────────────────────────────────────────────────
 * Tool pages — form (paste-target URL field)
 * ────────────────────────────────────────────────────────── */

.tool-form {
  display: grid;
  gap: 0.7rem;
  margin: 2rem 0;
}

.tool-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tool-input,
.tool-input-password {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.tool-input:focus,
.tool-input-password:focus {
  outline: none;
  border-color: var(--teal);
  background: var(--panel-2);
}

.tool-submit {
  justify-self: start;
  min-height: 3.2rem;
  padding: 0.85rem 1.6rem;
  border: 1px solid rgba(45, 212, 191, 0.5);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #18b7a5, #2dd4bf 48%, #ffd166);
  color: #06100e;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.tool-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 18px 42px rgba(45, 212, 191, 0.25);
}

.tool-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ──────────────────────────────────────────────────────────
 * Tool result card
 * ────────────────────────────────────────────────────────── */

.tool-result {
  margin: 2rem 0;
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.tool-result-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin: 0 0 1.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.tool-result-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.tool-result-stat-value {
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
}

.tool-result-stat-value.is-bad   { color: var(--coral); }
.tool-result-stat-value.is-warn  { color: var(--gold); }
.tool-result-stat-value.is-good  { color: var(--teal); }

.tool-result-stat-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tool-result-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.88rem;
}

.tool-result-table th,
.tool-result-table td {
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.tool-result-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tool-result-table td.is-ok    { color: var(--teal); }
.tool-result-table td.is-bad   { color: var(--coral); }
.tool-result-table td.is-warn  { color: var(--gold); }

/*
 * The "Open in Klipa" CTA on the tool result card MUST be the visually
 * dominant element when the user has a working playlist. Per §4.2 it
 * should be larger, brighter, and above every other link in the result
 * card. This is the highest-leverage conversion surface on the entire
 * site, so resist any urge to make it more "tasteful" / smaller.
 */
.tool-result-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  margin-top: 1.4rem;
  padding: 1.1rem 1.4rem;
  border: 1px solid rgba(45, 212, 191, 0.55);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #18b7a5, #2dd4bf 48%, #ffd166);
  color: #06100e;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
  box-shadow: 0 22px 58px rgba(45, 212, 191, 0.22);
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.tool-result-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 26px 62px rgba(45, 212, 191, 0.3);
}

.tool-result-cta-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.7rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.tool-result-cta-secondary a {
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
}

.tool-result-cta-secondary a:hover {
  color: var(--text);
  border-bottom-color: var(--line-strong);
}

/* ──────────────────────────────────────────────────────────
 * Tool error / status banners
 * ────────────────────────────────────────────────────────── */

.tool-banner {
  margin: 1rem 0;
  padding: 0.85rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.94rem;
}

.tool-banner.is-error {
  border-color: rgba(255, 107, 74, 0.45);
  background: rgba(255, 107, 74, 0.06);
  color: #ffb6a3;
}

.tool-banner.is-info {
  border-color: rgba(45, 212, 191, 0.4);
  background: rgba(45, 212, 191, 0.06);
}

.tool-banner.is-warn {
  border-color: rgba(255, 209, 102, 0.4);
  background: rgba(255, 209, 102, 0.06);
  color: #ffe1a3;
}

.tool-note {
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* ──────────────────────────────────────────────────────────
 * Breadcrumb + ToC
 * ────────────────────────────────────────────────────────── */

.breadcrumb {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.breadcrumb a {
  color: var(--text-soft);
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb-sep {
  margin: 0 0.4rem;
  color: var(--line-strong);
}

.article-toc {
  margin: 1.4rem 0 2rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(244, 245, 239, 0.025);
  font-size: 0.94rem;
}

.article-toc-title {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.article-toc ol,
.article-toc ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-soft);
}

.article-toc a {
  color: inherit;
  border-bottom: 1px solid transparent;
}

.article-toc a:hover {
  border-bottom-color: var(--line-strong);
  color: var(--text);
}

/* ──────────────────────────────────────────────────────────
 * Footer (article-shell uses a slimmer footer than landing)
 * ────────────────────────────────────────────────────────── */

.article-shell .footer {
  margin: 4rem 0 1rem;
  padding: 1rem 0 0;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.86rem;
}

.article-shell .footer a {
  color: var(--text-soft);
}

.article-shell .footer a:hover {
  color: var(--text);
}

/* ──────────────────────────────────────────────────────────
 * Tool tabs (e.g. xtream-m3u-converter direction switch)
 * ────────────────────────────────────────────────────────── */

.tool-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 1.6rem 0 0.8rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.tool-tab {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.tool-tab:hover {
  color: var(--text-soft);
}

.tool-tab.is-active {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.08);
  color: var(--text);
}

.tool-tab-panel { display: none; }
.tool-tab-panel.is-active { display: block; }

/* ──────────────────────────────────────────────────────────
 * Tool output rows (URL + label + copy button)
 * ────────────────────────────────────────────────────────── */

.tool-result-helper {
  margin: -0.4rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tool-output-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  padding: 0.85rem 0;
  border-bottom: 1px dashed var(--line);
}

.tool-output-row:last-of-type {
  border-bottom: none;
}

.tool-output-meta {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.tool-output-label {
  color: var(--text);
  font-weight: 600;
  font-size: 0.94rem;
}

.tool-output-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.tool-output-value {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tool-output-code {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  background: rgba(244, 245, 239, 0.05);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--text);
}

.tool-copy {
  flex-shrink: 0;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.tool-copy:hover {
  border-color: var(--teal);
  color: var(--text);
}

.tool-copy.is-ok {
  border-color: var(--teal);
  background: rgba(45, 212, 191, 0.12);
  color: var(--teal);
}

/* ──────────────────────────────────────────────────────────
 * Sample-M3U generator
 * ────────────────────────────────────────────────────────── */

.sm-fieldset {
  margin: 0;
  padding: 0;
  border: none;
  display: grid;
  gap: 0.55rem;
}

.sm-fieldset legend {
  margin-bottom: 0.4rem;
}

.sm-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(244, 245, 239, 0.025);
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.sm-check:hover {
  border-color: var(--line-strong);
}

.sm-check:has(input:checked) {
  border-color: rgba(45, 212, 191, 0.5);
  background: rgba(45, 212, 191, 0.06);
}

.sm-check input[type="checkbox"] {
  margin-top: 0.18rem;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: #2dd4bf;
}

.sm-check strong {
  color: var(--text);
}

.sm-check-warn:has(input:checked) {
  border-color: rgba(255, 209, 102, 0.55);
  background: rgba(255, 209, 102, 0.06);
}

.sm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.sm-preview-wrap {
  margin-top: 1.4rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(244, 245, 239, 0.025);
}

.sm-preview-wrap > summary {
  cursor: pointer;
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.4rem 0;
}

.sm-preview-wrap > summary:hover {
  color: var(--text);
}

.sm-preview {
  margin: 0.6rem 0 0.2rem;
  max-height: 22rem;
  overflow: auto;
  padding: 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-soft);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre;
}

/* ──────────────────────────────────────────────────────────
 * EPG timezone shifter — quick-select + custom offset row
 * ────────────────────────────────────────────────────────── */

.es-offset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

@media (max-width: 640px) {
  .es-offset-row {
    grid-template-columns: 1fr;
  }
}

/* ──────────────────────────────────────────────────────────
 * Mobile
 * ────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .article-main {
    margin-top: 1.2rem;
    padding: 0 0.25rem;
  }
  .article-title {
    font-size: 2rem;
  }
  .install-callout .action-grid {
    grid-template-columns: 1fr;
  }
  .tool-result-summary {
    gap: 1rem;
  }
  .article-list a {
    grid-template-columns: 1fr;
  }
  .article-list time {
    grid-row: auto;
  }
  .tool-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .tool-tabs {
    flex-direction: column;
  }
  .tool-output-value {
    flex-direction: column;
    align-items: stretch;
  }
  .tool-copy {
    align-self: flex-end;
  }
  .sm-actions {
    grid-template-columns: 1fr;
  }
}
