/*
 * Sprint19 Tools: Shared Styles
 *
 * Common CSS used across all tool pages.
 * Each tool links this via <link rel="stylesheet" href="/shared/styles.css">
 * and may add tool-specific overrides inline.
 *
 * Brand: Sprint19 (teal #4CA38C on ink #0D2420, Plus Jakarta Sans).
 */

/* ── Brand font (self-hosted, no third-party requests) ── */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/shared/vendor/fonts/plus-jakarta-sans.woff2") format("woff2");
}

/* ── Theme variables ────────────────────────────────── */

:root {
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* Sprint19 brand */
  --color-teal: #4CA38C;
  --color-teal-dark: #2E7A69;
  --color-teal-light: #6BBFA7;
  --color-teal-pale: #EAF5F1;

  --color-bg: #ffffff;
  --color-text: #0D2420;
  --color-text-secondary: #3a4f4a;
  --color-text-muted: #5A7C76;
  --color-text-faint: #6f8d87;
  --color-text-passive: #88a39d;
  --color-text-dim: #a6bbb6;
  --color-text-ghost: #c2d2ce;
  --color-card-bg: #fff;
  --color-surface: #f2faf7;
  --color-surface-code: #f6faf9;
  --color-surface-hover: #e6f3ee;
  --color-border: #d9e6e2;
  --color-border-input: #c2d4cf;
  --color-link: #2E7A69;
  --color-btn-bg: #0D2420;
  --color-btn-text: #fff;
  --color-btn-hover: #2E7A69;
  --color-success: #1a7f37;
  --color-warning: #b35900;
  --color-error: #cf222e;
  --color-shadow: rgba(13, 36, 32, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-teal: #6BBFA7;
    --color-teal-dark: #4CA38C;
    --color-teal-light: #8ed3bf;
    --color-teal-pale: #16302b;
    --color-bg: #0a1816;
    --color-text: #e7f0ed;
    --color-text-secondary: #b4c8c2;
    --color-text-muted: #8fa8a2;
    --color-text-faint: #748b86;
    --color-text-passive: #62786f;
    --color-text-dim: #51635c;
    --color-text-ghost: #41504a;
    --color-card-bg: #112320;
    --color-surface: #16302b;
    --color-surface-code: #0e1f1c;
    --color-surface-hover: #1d3d37;
    --color-border: #22443e;
    --color-border-input: #2f5750;
    --color-link: #6BBFA7;
    --color-btn-bg: #4CA38C;
    --color-btn-text: #062019;
    --color-btn-hover: #6BBFA7;
    --color-success: #2ea043;
    --color-warning: #d97706;
    --color-error: #f85149;
    --color-shadow: rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
    --color-teal: #6BBFA7;
    --color-teal-dark: #4CA38C;
    --color-teal-light: #8ed3bf;
    --color-teal-pale: #16302b;
    --color-bg: #0a1816;
    --color-text: #e7f0ed;
    --color-text-secondary: #b4c8c2;
    --color-text-muted: #8fa8a2;
    --color-text-faint: #748b86;
    --color-text-passive: #62786f;
    --color-text-dim: #51635c;
    --color-text-ghost: #41504a;
    --color-card-bg: #112320;
    --color-surface: #16302b;
    --color-surface-code: #0e1f1c;
    --color-surface-hover: #1d3d37;
    --color-border: #22443e;
    --color-border-input: #2f5750;
    --color-link: #6BBFA7;
    --color-btn-bg: #4CA38C;
    --color-btn-text: #062019;
    --color-btn-hover: #6BBFA7;
    --color-success: #2ea043;
    --color-warning: #d97706;
    --color-error: #f85149;
    --color-shadow: rgba(0, 0, 0, 0.4);
}

/* ── Theme toggle ────────────────────────────────────── */

.theme-toggle-wrap {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-card-bg);
  box-shadow: 0 2px 8px var(--color-shadow);
  color: var(--color-text-muted);
  font-size: 12px;
  user-select: none;
}

.theme-toggle-wrap label {
  cursor: pointer;
}

.theme-toggle-wrap select {
  font-size: 12px;
  border: 1px solid var(--color-border-input);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  padding: 2px 8px;
  cursor: pointer;
}

@media print {
  .theme-toggle-wrap {
    display: none !important;
  }
}

/* ── Base ────────────────────────────────────────────── */

body {
  font-family: var(--font-sans);
  max-width: 800px;
  margin: 40px auto;
  padding: 0 20px;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { color: var(--color-text); letter-spacing: -0.02em; text-wrap: balance; }
h1 { margin-bottom: 4px; font-weight: 700; letter-spacing: -0.03em; }
h2 { margin-top: 32px; font-weight: 600; }

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

::selection { background: var(--color-teal); color: #fff; }
:focus-visible { outline: 2px solid var(--color-teal-dark); outline-offset: 2px; }

/* ── Back link (shared across tool pages) ───────────── */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: 8px;
}
.back-link::before {
  content: "";
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: url("/shared/brand/s19-mark-dark.png") center / contain no-repeat;
}
.back-link:hover { color: var(--color-teal-dark); text-decoration: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .back-link::before {
    background-image: url("/shared/brand/s19-mark-light.png");
  }
}
:root[data-theme="dark"] .back-link::before {
  background-image: url("/shared/brand/s19-mark-light.png");
}
:root[data-theme="light"] .back-link::before {
  background-image: url("/shared/brand/s19-mark-dark.png");
}

/* ── Affiliate CTA (opt-in pages only) ──────────────── */

.affiliate-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--color-card-bg);
}

.affiliate-cta-text {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.affiliate-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--color-border-input);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.affiliate-cta-btn:hover {
  text-decoration: none;
  background: var(--color-surface-hover);
}

@media (max-width: 640px) {
  .affiliate-cta {
    flex-direction: column;
    align-items: stretch;
  }
  .affiliate-cta-btn {
    width: 100%;
  }
}

/* ── Cards ───────────────────────────────────────────── */

.card {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 20px;
  background: var(--color-card-bg);
}

/* ── Status colors ───────────────────────────────────── */

.green  { color: var(--color-success); }
.yellow { color: var(--color-warning); }
.red    { color: var(--color-error); }

/* ── Summary lists ───────────────────────────────────── */

.summary ul  { list-style: disc; padding-left: 20px; }
.summary li  { margin-bottom: 6px; line-height: 1.5; }
.summary p   { margin-top: 16px; line-height: 1.5; }

/* ── Tables ──────────────────────────────────────────── */

table    { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
th, td   { border: 1px solid var(--color-border); padding: 8px; text-align: left; }
th       { background: var(--color-surface); }

/* ── Raw / preformatted blocks ───────────────────────── */

.raw-block {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  max-height: 400px;
  background: var(--color-surface-code);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 12px;
  font-size: 13px;
  font-family: var(--font-mono);
}

/* Legacy alias from DMARC reader */
.raw-xml { white-space: pre-wrap; overflow: auto; max-height: 400px; background: var(--color-surface-code); border: 1px solid var(--color-border); padding: 12px; font-size: 13px; }

/* ── Disclaimer ──────────────────────────────────────── */

.disclaimer {
  margin-top: 24px;
  font-style: italic;
  color: var(--color-text-muted);
}

/* ── Print button ────────────────────────────────────── */

.print-btn {
  margin-top: 24px;
  padding: 10px 24px;
  font-size: 16px;
  cursor: pointer;
  background: var(--color-surface);
  border: 1px solid var(--color-border-input);
  border-radius: 4px;
}
.print-btn:hover { background: var(--color-surface-hover); }

/* ── Textarea input (common across tools) ────────────── */

.tool-input {
  width: 100%;
  min-height: 120px;
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 12px;
  border: 1px solid var(--color-border-input);
  border-radius: 4px;
  box-sizing: border-box;
  resize: vertical;
  background: var(--color-card-bg);
  color: var(--color-text);
}

.tool-btn {
  margin-top: 12px;
  padding: 10px 28px;
  font-size: 16px;
  cursor: pointer;
  background: var(--color-btn-bg);
  color: var(--color-btn-text);
  border: none;
  border-radius: 4px;
}
.tool-btn:hover { background: var(--color-btn-hover); }

/* ── Site footer ─────────────────────────────────────── */

.site-footer {
  text-align: center;
  color: var(--color-text-passive);
  font-size: 13px;
  margin-top: 48px;
  padding-bottom: 24px;
}
.site-footer hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin-bottom: 16px;
}
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--color-text-muted); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer .guardrail {
  font-style: italic;
  font-size: 12px;
  color: var(--color-text-dim);
  margin-top: 12px;
}
.site-footer .copyright {
  margin-top: 12px;
  font-size: 11px;
  color: var(--color-text-ghost);
}
.site-footer .copyright a {
  color: var(--color-text-ghost);
}

/* ── Report metadata ─────────────────────────────────── */

.report-timestamp { color: var(--color-text-muted); font-size: 14px; margin-bottom: 16px; }
.report-source    { color: var(--color-text-passive); font-size: 13px; margin-bottom: 20px; }

/* ── Print ───────────────────────────────────────────── */

@media print {
  input, button, textarea, .tool-btn {
    display: none;
  }
  body {
    margin: 0;
  }
  .card {
    border: none;
    page-break-inside: avoid;
  }
  .raw-xml-section, .raw-block-section {
    display: none;
  }
  pre {
    white-space: pre-wrap;
    word-wrap: break-word;
  }
  .site-footer {
    display: block !important;
  }
}
