
:root {
  --navy: #0F3460;
  --accent: #00B4D8;
  --text: #222;
  --text-muted: #556;
  --text-faint: #889;
  --border: #E5E7EB;
  --bg: #FFFFFF;
  --surf: #F8FAFC;
  --info-bg: #D1ECF1;
  --info-txt: #0C5460;
  --warn-bg: #FFF8E1;
  --warn-txt: #78350F;
  --warn-border: #F59E0B;
}

* { box-sizing: border-box; }

html[dir="rtl"] body { text-align: right; }
html[dir="rtl"] .lang-switcher { direction: ltr; text-align: left; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  color: var(--text);
  line-height: 1.65;
  background: var(--bg);
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.top-nav .home-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.top-nav .home-link:hover {
  color: var(--accent);
}

.lang-switcher {
  position: relative;
  display: inline-block;
}

.lang-switcher-button {
  background: var(--surf);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--navy);
  font-weight: 500;
}

.lang-switcher-button::after {
  content: " ▾";
  font-size: 10px;
  color: var(--text-faint);
}

.lang-switcher-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  padding: 8px 0;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.lang-switcher.open .lang-switcher-menu { display: block; }

.lang-switcher-menu a {
  display: block;
  padding: 8px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.lang-switcher-menu a:hover { background: var(--surf); }
.lang-switcher-menu a.active { background: var(--info-bg); color: var(--info-txt); font-weight: 600; }

.download-banner {
  background: var(--navy);
  color: #FFFFFF;
  padding: 14px 20px;
  text-align: center;
  border-radius: 10px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.download-banner span {
  font-weight: 600;
}

.download-banner a {
  background: var(--accent);
  color: #FFFFFF;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.download-banner a:hover { background: #0099BB; }

.download-banner .alt-link {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
}

.disclaimer-note {
  background: var(--surf);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  border-radius: 0 6px 6px 0;
  font-style: italic;
}

h1, h2, h3, h4 {
  color: var(--navy);
  line-height: 1.3;
}

h1 {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 12px;
  margin-top: 24px;
  font-size: 28px;
}

h2 {
  margin-top: 36px;
  font-size: 22px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

h3 { margin-top: 28px; font-size: 17px; }
h4 { margin-top: 20px; font-size: 15px; color: var(--text); }

p { margin: 12px 0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surf);
  font-weight: 600;
  color: var(--navy);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:last-child td { border-bottom: none; }

code {
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  background: var(--surf);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 90%;
  color: var(--navy);
}

pre {
  background: var(--surf);
  padding: 14px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}

pre code { background: none; padding: 0; color: var(--text); }

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

blockquote {
  border-left: 4px solid var(--accent);
  margin: 16px 0;
  padding: 12px 18px;
  background: var(--surf);
  color: var(--text-muted);
  font-size: 14px;
  border-radius: 0 6px 6px 0;
}

blockquote p { margin: 6px 0; }

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

hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }

ul, ol { padding-left: 24px; }
li { margin: 6px 0; }

.docs-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

.docs-footer a { color: var(--text-muted); }

.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 32px;
}

.doc-card {
  background: #FFFFFF;
  padding: 24px;
  border-radius: 10px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s, box-shadow 0.15s;
}

.doc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--accent);
}

.doc-card h2 {
  color: var(--navy);
  margin: 0 0 8px;
  font-size: 18px;
  border-bottom: none;
  padding-bottom: 0;
}

.doc-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 8px 0;
}

.doc-card .badge {
  display: inline-block;
  background: var(--info-bg);
  color: var(--info-txt);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 8px;
}

.print-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
}

.print-button:hover {
  filter: brightness(1.1);
}

@media print {
  /* Layout: full page width, remove screen padding */
  body { max-width: none; padding: 0; color: #000; background: #fff; }

  /* Hide screen-only navigation and controls */
  .download-banner, .lang-switcher, .top-nav, .docs-footer,
  .print-button { display: none !important; }

  /* Disclaimer styled minimally for print (no colored background) */
  .disclaimer-note { background: none; border: none; padding: 0;
                     font-style: italic; color: #555; margin: 0 0 12pt 0; }

  /* Headings: keep with following content. NOTE: we do NOT force a page break
     before every h2 — that creates near-empty pages when a chapter has just
     an intro paragraph followed by a tall image. Instead, h2 may break and
     prefers to. Browser optimizes page fill. */
  h1, h2, h3, h4 { page-break-after: avoid; color: #000; }
  h2 { page-break-before: auto; margin-top: 18pt; }
  p, li { orphans: 3; widows: 3; }

  /* Images: don't split across pages. Constrain height so portrait phone
     screenshots don't dominate a page (allows text to share the page). */
  img { page-break-inside: avoid; max-width: 60%; max-height: 14cm;
        height: auto; display: block; margin: 8pt auto; }

  /* Tables: borders that print, don't split cells across pages */
  table { page-break-inside: avoid; border-collapse: collapse;
          width: 100%; }
  th, td { border: 1px solid #888; padding: 6pt 8pt; }
  th { background: #f0f0f0; color: #000; }

  /* Links: keep blue, show URL after external links so paper readers
     can find them. Same-page anchor links don't get URL appended. */
  a { color: #003366; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")";
                            font-size: 9pt; color: #555;
                            word-break: break-all; }

  /* Code: keep monospace, light box */
  code { background: #f6f6f6; padding: 1pt 3pt; border-radius: 2pt;
         font-size: 10pt; }
  pre { background: #f6f6f6; padding: 8pt; page-break-inside: avoid;
        font-size: 9pt; border: 1px solid #ddd; }

  /* Suppress URL in TOC chapter links (in-page anchors) */
  .toc a::after, ol a::after, ul a::after { content: ""; }

  /* Comfortable text size on paper */
  body { font-size: 11pt; line-height: 1.5; }
  h1 { font-size: 22pt; }
  h2 { font-size: 16pt; }
  h3 { font-size: 13pt; }
}

@media (max-width: 700px) {
  body { padding: 16px; }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  table { font-size: 13px; }
  th, td { padding: 8px 10px; }
  .doc-grid { grid-template-columns: 1fr; }
}

/* ---- TDOA explainer video ------------------------------------------- */
.tdoa-video { margin: 32px 0 8px; }
.tdoa-video h2 { color: var(--navy); margin: 0 0 4px; font-size: 20px; }
.tdoa-video-sub { color: var(--text-faint); font-size: 14px; margin: 0 0 14px; }
.tdoa-video video {
  display: block;
  width: 100%;
  max-width: 500px;          /* 4:5 portrait — full width would tower */
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #081d33;       /* matches the video, so no white flash on load */
}
html[dir="rtl"] .tdoa-video { text-align: right; }
.tdoa-video video::cue {
  background: transparent;          /* no box — shadow carries the legibility */
  color: #F7FAFC;
  font-size: .5em;
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0,0,0,.95), 0 0 10px rgba(0,0,0,.8);
}
@media (max-width: 480px) {
  .tdoa-video video { max-width: 100%; }
  /* the video is near full width on a phone, so .5em would be unreadable */
  .tdoa-video video::cue { font-size: .95em; }
}

/* ---- Support form (/support/) ---------------------------------------- */
.contact { margin: 20px 0 8px; max-width: 560px; }

.contact .field { margin-bottom: 18px; }

.contact label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.contact input[type="text"],
.contact input[type="email"],
.contact select,
.contact textarea {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.contact textarea { resize: vertical; min-height: 140px; }

.contact input:focus,
.contact select:focus,
.contact textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, .15);
}

.contact .hint {
  display: block;
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 5px;
  line-height: 1.5;
}

/* Honeypot. Off-screen rather than display:none, so that a bot reading the
   computed style still sees a normal field — and so that a sighted person
   never does. aria-hidden and tabindex="-1" keep it away from screen readers
   and the tab order. A filled value is never dropped, only flagged: browser
   autofill fills hidden fields too, and silently binning a real message is
   far worse than letting one through marked [Possible spam]. */
.contact .hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.contact .btn {
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.contact .btn:hover:not(:disabled) { background: #0099BB; }
.contact .btn:disabled { opacity: .6; cursor: default; }

.contact .formmsg {
  display: none;
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.55;
}

.contact .formmsg.show { display: block; }

.contact .formmsg.good {
  background: var(--info-bg);
  color: var(--info-txt);
  border-left: 4px solid var(--accent);
}

.contact .formmsg.bad {
  background: var(--warn-bg);
  color: var(--warn-txt);
  border-left: 4px solid var(--warn-border);
}

html[dir="rtl"] .contact .formmsg.good,
html[dir="rtl"] .contact .formmsg.bad {
  border-left: none;
  border-right: 4px solid var(--accent);
}

@media print { .contact { display: none !important; } }
