/* ============================================
   Fabex — Terminal-Native Marketing System
   Visual spec: DESIGN.md (Berkeley Mono style)
   ============================================ */

/* ── Font Import ── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── CSS Variables (Design Tokens) ── */
:root {
  /* Colors */
  --primary: #201d1d;
  --on-primary: #fdfcfc;
  --ink: #201d1d;
  --ink-deep: #0f0000;
  --charcoal: #302c2c;
  --body: #424245;
  --mute: #646262;
  --stone: #6e6e73;
  --ash: #9a9898;
  --canvas: #fdfcfc;
  --surface-soft: #f8f7f7;
  --surface-card: #f1eeee;
  --surface-dark: #201d1d;
  --surface-dark-elevated: #302c2c;
  --hairline: #e0dddd;
  --hairline-strong: #646262;
  --on-dark: #fdfcfc;
  --on-dark-mute: #9a9898;
  --accent: #007aff;
  --accent-hover: #0056b3;
  --accent-active: #004085;
  --warning: #ff9f0a;
  --danger: #ff3b30;
  --success: #30d158;

  /* Spacing */
  --xxs: 1px;
  --xs: 4px;
  --sm: 8px;
  --md: 12px;
  --lg: 16px;
  --xl: 24px;
  --xxl: 32px;
  --section: 96px;

  /* Typography */
  --font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

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

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

body {
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

img {
  max-width: 100%;
  display: block;
}

/* ── Layout ── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--lg);
}

.container-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--lg);
}

.section {
  padding-top: var(--section);
  padding-bottom: var(--section);
  border-bottom: 1px solid var(--hairline);
}

.section:last-of-type {
  border-bottom: none;
}

.section-narrow {
  padding-top: 64px;
  padding-bottom: 64px;
}

/* ── Typography Tokens ── */
.display-xl {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0;
}

.heading-md {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0;
}

.body-md {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
}

.body-strong {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0;
}

.body-tight {
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
}

.caption-md {
  font-size: 14px;
  font-weight: 400;
  line-height: 2;
  letter-spacing: 0;
}

.mute {
  color: var(--mute);
}

.body-text {
  color: var(--body);
}

.ash-text {
  color: var(--ash);
}

.stone-text {
  color: var(--stone);
}

/* ── Components: Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 500;
  line-height: 2;
  padding: 4px 20px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: none;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--on-primary);
  transition: background-color 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--charcoal);
}

.btn-primary:active {
  background-color: var(--ink-deep);
}

.btn-secondary {
  background-color: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-secondary:hover {
  background-color: var(--surface-soft);
  border-color: var(--ink);
}

.btn-disabled {
  background-color: var(--surface-card);
  color: var(--ash);
  cursor: not-allowed;
}

.btn-tab {
  background: transparent;
  color: var(--mute);
  border: none;
  padding: 8px 16px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
}

.btn-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ash);
}

/* ── Components: Badges ── */
.badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 400;
  line-height: 2;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: var(--surface-dark);
  color: var(--on-dark);
}

.badge-section-label {
  display: block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  background: transparent;
  padding: 0;
  margin-bottom: var(--sm);
}

/* ── Components: Inputs ── */
.text-input,
.textarea,
select {
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  background-color: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 8px 12px;
  width: 100%;
  outline: none;
}

.text-input:focus,
.textarea:focus,
select:focus {
  background-color: var(--canvas);
  border-color: var(--ink);
}

.text-input {
  height: 40px;
}

.textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
}

select {
  height: 40px;
  cursor: pointer;
}

/* ── Components: Snippets ── */
.snippet {
  background-color: var(--surface-card);
  color: var(--ink);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  padding: 12px 16px;
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Components: Cards ── */
.card {
  border: 1px solid var(--hairline);
  padding: var(--xl);
  background-color: var(--canvas);
}

.card-dark {
  background-color: var(--surface-dark);
  color: var(--on-dark);
  border: none;
  padding: var(--xl);
}

.card-soft {
  background-color: var(--surface-soft);
  padding: 16px 20px;
  border-radius: 4px;
  border: none;
}

/* ── Components: Console Icon ── */
.console-icon-80 {
  width: 80px;
  height: 80px;
  display: block;
  margin-bottom: var(--md);
  border: 1px solid var(--hairline);
  background-color: var(--canvas);
  color: var(--ink);
  flex-shrink: 0;
}

.dark-section .console-icon-80,
.hero-tui .console-icon-80 {
  border-color: var(--on-dark-mute);
  background-color: var(--surface-dark);
  color: var(--on-dark);
}

/* ── Components: Lists ── */
.list-row {
  padding: 8px 0;
  color: var(--body);
}

.list-row .marker {
  color: var(--ink);
  font-weight: 500;
  margin-right: 8px;
}

/* ── Components: FAQ ── */
.faq-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
}

.faq-row:last-child {
  border-bottom: none;
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
  color: var(--ink);
}

.faq-answer {
  padding-top: var(--sm);
  color: var(--body);
  line-height: 1.5;
}

.faq-toggle {
  color: var(--mute);
  font-size: 16px;
  margin-left: var(--md);
}

/* ── Navigation ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  height: 56px;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav-logo {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--xs);
}

.nav-logo::before {
  content: '[F]';
  color: var(--mute);
}

.nav-links {
  display: flex;
  gap: var(--xl);
  list-style: none;
}

.nav-links a {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--lg);
}

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--ink);
}

/* ── Hero TUI Mockup ── */
.hero-tui {
  background-color: var(--surface-dark);
  color: var(--on-dark);
  padding: 64px 32px;
  margin: 0 calc(-1 * var(--lg));
}

.hero-tui-inner {
  max-width: 960px;
  margin: 0 auto;
}

.tui-wordmark {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  color: var(--on-dark);
  margin-bottom: var(--xl);
}

.tui-prompt-row {
  background-color: var(--surface-dark-elevated);
  color: var(--on-dark);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: var(--sm);
}

.tui-hint {
  color: var(--on-dark-mute);
  font-size: 14px;
  line-height: 2;
}

/* ── Footer ── */
.footer {
  border-top: 1px solid var(--hairline);
  padding: 32px 0;
  color: var(--body);
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--lg);
  margin-bottom: var(--xl);
}

.footer-links a {
  color: var(--mute);
  text-decoration: none;
  font-size: 14px;
  line-height: 2;
  text-align: center;
  display: block;
  padding: 8px 0;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  line-height: 2;
  color: var(--mute);
  border-top: 1px solid var(--hairline);
  padding-top: var(--lg);
}

.footer-center {
  text-align: center;
}

/* ── Tables ── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  line-height: 1.5;
}

.table th,
.table td {
  padding: 12px;
  text-align: left;
  border: 1px solid var(--hairline);
}

.table th {
  font-weight: 700;
  background-color: var(--surface-soft);
  color: var(--ink);
}

.table td {
  color: var(--body);
}

/* ── Grid Layouts ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--xl);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--xl);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--xl);
}

.grid-6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--lg);
}

/* ── Flex helpers ── */
.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-sm { gap: var(--sm); }
.gap-md { gap: var(--md); }
.gap-lg { gap: var(--lg); }
.gap-xl { gap: var(--xl); }

.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Spacing helpers ── */
.mt-sm { margin-top: var(--sm); }
.mt-md { margin-top: var(--md); }
.mt-lg { margin-top: var(--lg); }
.mt-xl { margin-top: var(--xl); }
.mt-xxl { margin-top: var(--xxl); }

.mb-sm { margin-bottom: var(--sm); }
.mb-md { margin-bottom: var(--md); }
.mb-lg { margin-bottom: var(--lg); }
.mb-xl { margin-bottom: var(--xl); }
.mb-xxl { margin-bottom: var(--xxl); }

.pt-sm { padding-top: var(--sm); }
.pt-md { padding-top: var(--md); }
.pt-lg { padding-top: var(--lg); }
.pt-xl { padding-top: var(--xl); }

.pb-sm { padding-bottom: var(--sm); }
.pb-md { padding-bottom: var(--md); }
.pb-lg { padding-bottom: var(--lg); }
.pb-xl { padding-bottom: var(--xl); }

/* ── Utility ── */
.text-center { text-align: center; }
.text-left { text-align: left; }
.full-width { width: 100%; }

.hairline-top {
  border-top: 1px solid var(--hairline);
}

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

.hairline-strong-top {
  border-top: 1px solid var(--hairline-strong);
}

/* ── Dark section overrides ── */
.dark-section {
  background-color: var(--surface-dark);
  color: var(--on-dark);
}

.dark-section .badge-section-label,
.dark-section .display-xl,
.dark-section .heading-md,
.dark-section .body-md,
.dark-section .body-strong {
  color: var(--on-dark);
}

.dark-section .body-text,
.dark-section .mute,
.dark-section .caption-md {
  color: var(--on-dark-mute);
}

/* ── Step flow ── */
.step-flow {
  display: flex;
  flex-direction: column;
  gap: var(--xl);
}

.step-item {
  display: flex;
  gap: var(--lg);
  padding: var(--lg);
  border: 1px solid var(--hairline);
}

.step-number {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  min-width: 80px;
}

.step-caption {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: var(--sm);
}

.step-caption.human {
  background-color: var(--warning);
  color: var(--ink);
}

.step-caption.auto {
  background-color: var(--success);
  color: var(--ink);
}

/* ── Comparison Bar ── */
.comparison-bar {
  display: flex;
  flex-direction: column;
  gap: var(--sm);
  margin-top: var(--xl);
}

.comparison-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--hairline);
}

.comparison-label {
  min-width: 180px;
  font-weight: 500;
  color: var(--ink);
}

.comparison-value {
  flex: 1;
  color: var(--body);
}

/* ── Highlight Bar ── */
.highlight-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lg);
  padding: var(--lg);
  background-color: var(--surface-soft);
  border: 1px solid var(--hairline);
  margin-top: var(--xl);
}

.highlight-bar span {
  font-weight: 500;
  color: var(--ink);
}

/* ── Trust micro-copy ── */
.trust-micro {
  font-size: 14px;
  line-height: 2;
  color: var(--mute);
  margin-top: var(--lg);
}

/* ── Chart tiles ── */
.chart-tile {
  padding: 16px;
}

.chart-ascii {
  font-family: var(--font-family);
  font-size: 12px;
  line-height: 1.2;
  color: var(--body);
  white-space: pre;
  overflow-x: auto;
}

/* ── Form components ── */
.form-group {
  margin-bottom: var(--lg);
}

.form-label {
  display: block;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: var(--xs);
  color: var(--ink);
}

.form-hint {
  font-size: 14px;
  line-height: 2;
  color: var(--mute);
  margin-top: var(--xs);
}

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: var(--sm);
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  cursor: pointer;
}

.checkbox-group label {
  font-size: 16px;
  line-height: 1.5;
  color: var(--body);
  cursor: pointer;
}

/* ── Tab Panels ── */
.tab-strip {
  display: flex;
  gap: var(--xs);
  border-bottom: 1px solid var(--hairline);
  margin-bottom: var(--xl);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  :root {
    --section: 64px;
  }

  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 850px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-links {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-bottom {
    flex-direction: column;
    gap: var(--sm);
    text-align: center;
  }
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
  }

  .nav-hamburger {
    display: block;
  }

  .display-xl {
    font-size: 28px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .hero-tui {
    padding: 48px 24px;
  }

  .tui-wordmark {
    font-size: 22px;
  }

  .step-item {
    flex-direction: column;
    gap: var(--sm);
  }

  .comparison-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--xs);
  }

  .comparison-label {
    min-width: auto;
  }

  .footer-links {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --section: 48px;
  }

  .container,
  .container-wide {
    padding: 0 var(--sm);
  }

  .grid-4,
  .grid-6 {
    grid-template-columns: 1fr;
  }

  .highlight-bar {
    flex-direction: column;
    gap: var(--sm);
  }
}

/* ── Print ── */
@media print {
  .nav,
  .btn,
  .footer {
    display: none;
  }

  .section {
    border-bottom: 1px solid #ccc;
    padding: 24px 0;
  }
}
