/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f8f6f1;
  --bg-warm: #f3efe7;
  --text: #2c2a25;
  --text-muted: #6b6860;
  --border: #e5e0d8;
  --accent: #3b5998;
  --accent-hover: #2d4373;
  --sepia: #f5f0e1;
  --dark: #1a1a1a;
  --dark-text: #f0ede6;
  --font-heading: 'Sora', sans-serif;
  --font-serif: 'PT Serif', serif;
  --font-body: -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --max-w: 1120px;
  --radius: 6px;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* RTL support */
html[dir="rtl"] { direction: rtl; }
html[dir="rtl"] .top-bar-left { flex-direction: row-reverse; }
html[dir="rtl"] .top-nav { flex-direction: row-reverse; }

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

/* ── Top Bar ── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 246, 241, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.top-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo:hover { color: var(--text); }

.logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.gh-link, .sponsor-link {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.gh-link:hover, .sponsor-link:hover { color: var(--text); }

.sponsor-link {
  background: rgba(219, 97, 162, 0.1);
  border-radius: 6px;
  padding: 4px 8px;
}
.sponsor-link svg { color: #db61a2; }

.lang-toggle select {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  color: var(--text);
  cursor: pointer;
}

/* ── Hero ── */
.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 80px 24px 64px;
  text-align: center;
}

.hero h1 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.15;
  color: var(--text);
  max-width: 720px;
  margin: 0 auto 20px;
  letter-spacing: -0.5px;
}

.hero-logo {
  display: inline-block;
  vertical-align: middle;
  width: 48px;
  height: 48px;
  margin-right: 4px;
  position: relative;
  top: -2px;
}

.hero-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.65;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.btn {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 24px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-primary:hover {
  background: #1a1816;
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.hero-embed {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  background: #1e1e2e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 14px 20px;
  max-width: 100%;
  overflow-x: auto;
}

.hero-embed code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  color: #cdd6f4;
  display: block;
  text-align: left;
  white-space: nowrap;
}

.hero-embed .hl-tag { color: #89b4fa; }
.hero-embed .hl-attr { color: #a6e3a1; }
.hero-embed .hl-str { color: #f9e2af; }

.hero-install {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.hero-install code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 4px 10px;
  border-radius: 4px;
}

/* ── Example Sections ── */
.example-section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.example-card {
  border-radius: 8px;
  overflow: hidden;
  padding: 32px;
}

.card-white {
  background: #ffffff;
  border: 1px solid var(--border);
}

.card-sepia {
  background: var(--sepia);
  border: 1px solid #d8d0b8;
}

.card-dark {
  background: var(--dark);
}

.example-label {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.label-light { color: #9a9590; }

.example-viewer-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
}

.example-viewer {
  display: block;
  width: 100%;
  height: 420px;
  border-radius: var(--radius);
}

.example-caption {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
}

.caption-light { color: #8a8580; }

/* ── Midway Layout ── */
.midway-layout {
  display: flex;
  gap: 24px;
  min-height: 420px;
}

.midway-globe {
  flex: 0 0 60%;
  border-radius: var(--radius);
  overflow: hidden;
}

.midway-globe .example-viewer {
  height: 100%;
  min-height: 420px;
}

.midway-narrative {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 0;
}

.midway-step {
  background: linear-gradient(135deg, rgba(255,255,255,0.5), rgba(255,255,255,0.2));
  border: 1px solid #cdc3a5;
  border-left: 3px solid transparent;
  border-radius: 4px;
  padding: 20px 22px;
  cursor: pointer;
  transition: border-left-color 0.3s, box-shadow 0.3s;
}

.midway-step.active {
  border-left-color: #8b7355;
  box-shadow: 1px 2px 8px rgba(60, 50, 30, 0.12);
}

.midway-step .step-time {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8b7355;
  display: block;
  margin-bottom: 8px;
}

.midway-step h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 16px;
  color: #2c2416;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-indicator {
  font-size: 10px;
  color: transparent;
  transition: color 0.3s;
  flex-shrink: 0;
}

.midway-step.active .step-indicator {
  color: #8b7355;
}

.midway-step p {
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.7;
  color: #3d3424;
}

/* ── Inline NATO dot-link markers in narrative text ── */
.dot-link {
  border-bottom: 1px dashed rgba(60, 50, 30, 0.35);
  padding-bottom: 1px;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
/* Neutral — circle */
.dot.mid  { background: #16a34a; }
/* Friendly (US) — rectangle (NATO APP-6) */
.dot.us   { background: #2563eb; border-radius: 1px; width: 10px; height: 7px; }
.dot.us.ent { background: #1d4ed8; }
.dot.us.yk  { background: #60a5fa; }
/* Hostile (JP) — diamond (rotated square, NATO APP-6) */
.dot.jp   { background: #dc2626; border-radius: 1px; transform: rotate(45deg); width: 7px; height: 7px; }
/* Sunk — gray diamond */
.dot.sunk { background: #9ca3af; border-radius: 1px; transform: rotate(45deg); width: 7px; height: 7px; }

/* ── Midway viewer button tint ── */
.card-sepia globi-viewer::part(controls),
.card-sepia globi-viewer {
  --globi-button-bg: rgba(139, 115, 85, 0.12);
  --globi-button-color: #6b5d45;
  --globi-button-hover-bg: rgba(139, 115, 85, 0.22);
}

/* ── ISS Overlay ── */
.iss-wrap { position: relative; }

.iss-overlay {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}

.iss-stat {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}

.iss-key {
  color: rgba(255, 255, 255, 0.4);
  display: inline-block;
  width: 32px;
}

/* ── Source Code Toggle ── */
.example-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.code-toggle-btn {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-warm);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.code-toggle-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.card-dark .code-toggle-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
}

.card-dark .code-toggle-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.85);
}

.card-sepia .code-toggle-btn {
  background: rgba(139, 115, 85, 0.08);
  border-color: #cdc3a5;
  color: #8b7355;
}

.card-sepia .code-toggle-btn:hover {
  border-color: #8b7355;
  color: #5a4a2f;
}

.example-link {
  font-family: var(--font-heading);
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.example-link:hover { color: var(--text); }

.card-dark .example-link { color: rgba(255, 255, 255, 0.5); }
.card-dark .example-link:hover { color: rgba(255, 255, 255, 0.85); }
.card-sepia .example-link { color: #8b7355; }
.card-sepia .example-link:hover { color: #5a4a2f; }

.code-panel {
  display: none;
  margin-top: 12px;
  background: #1a1a1a;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.code-panel.open { display: block; }

.code-panel pre {
  padding: 16px;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #c9d1d9;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
}

/* ── Advantages ── */
.advantages {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.advantages-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.advantage-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 24px;
}

.advantage-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.advantage-card h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
}

.advantage-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ── Features ── */
.features {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 80px;
  text-align: center;
}

.features h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(24px, 3vw, 32px);
  margin-bottom: 32px;
}

.features-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.feature-pill {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 400;
  padding: 6px 16px;
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Comparison ── */
.comparison {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.comparison h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(24px, 3vw, 32px);
  margin-bottom: 32px;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

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

thead {
  background: var(--bg-warm);
}

th {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

tbody tr:nth-child(even) { background: rgba(0, 0, 0, 0.015); }

td strong { color: var(--text); }

/* ── FAQ ── */
.faq {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.faq h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(24px, 3vw, 32px);
  margin-bottom: 32px;
  text-align: center;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-item summary {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  padding: 16px 0;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  font-size: 20px;
  font-weight: 400;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-left: 16px;
}

.faq-item[open] summary::after {
  content: '\2212';
}

.faq-item p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  padding: 0 0 16px;
}

/* ── Newsletter ── */
.newsletter-section {
  background: var(--bg-warm);
  padding: 64px 24px;
  text-align: center;
}

.newsletter-inner {
  max-width: 480px;
  margin: 0 auto;
}

.newsletter-inner h2 {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.newsletter-inner p {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.newsletter-form {
  display: flex;
  gap: 8px;
  max-width: 400px;
  margin: 0 auto;
}

.newsletter-form input[type="email"] {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: white;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.newsletter-form input[type="email"]:focus {
  border-color: var(--accent);
}

.newsletter-form button {
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.newsletter-form button:hover {
  opacity: 0.85;
}

.subscribe-toast {
  margin-top: 12px;
  font-size: 14px;
  min-height: 20px;
  transition: opacity 0.3s;
}

.subscribe-toast.success { color: #16a34a; }
.subscribe-toast.error { color: #dc2626; }

/* ── Footer ── */
.site-footer {
  background: var(--text);
  color: rgba(255, 255, 255, 0.7);
  padding: 48px 24px 24px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  color: white;
  display: block;
  margin-bottom: 8px;
}

.footer-col p {
  font-size: 13px;
  line-height: 1.6;
}

.footer-col h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  padding: 3px 0;
}

.footer-col a:hover { color: white; }

.footer-note {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
}

.footer-bottom {
  max-width: var(--max-w);
  margin: 0 auto;
  padding-top: 20px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
}

.footer-bottom a {
  color: rgba(255, 255, 255, 0.5);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-bottom a:hover {
  color: white;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .advantages-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .hero { padding: 48px 20px 40px; }

  .hero-embed { padding: 12px 14px; }
  .hero-embed code { font-size: 11px; }

  .hero-install { flex-wrap: wrap; justify-content: center; }

  .top-nav span { display: none; }
  .top-nav { gap: 12px; }

  .example-section { padding: 0 16px 48px; }
  .example-card { padding: 20px; }
  .example-viewer { height: 300px; }

  .midway-layout {
    flex-direction: column;
  }

  .midway-globe { flex: none; }
  .midway-globe .example-viewer { min-height: 280px; height: 40vh; }

  .advantages-grid { grid-template-columns: 1fr; }
  .newsletter-form { flex-direction: column; }
  .newsletter-section { padding: 48px 20px; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
}
