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

:root, [data-theme="light"] {
  --color-bg: #f5f3ef;
  --color-surface: #ffffff;
  --color-surface-2: #faf9f7;
  --color-border: #e0ddd7;
  --color-divider: #eae7e2;

  --color-text: #1a1814;
  --color-text-muted: #6b6860;
  --color-text-faint: #a8a49c;

  --color-primary: #1b6b5a;
  --color-primary-hover: #145445;
  --color-primary-light: #e6f2ee;
  --color-primary-lighter: #d0e8df;

  --color-native: #1b6b5a;
  --color-native-bg: #e6f2ee;
  --color-zapier: #a85510;
  --color-zapier-bg: #fde8d3;
  --color-api: #3b6faa;
  --color-api-bg: #e6eef7;
  --color-none: #9e9a94;
  --color-none-bg: #f0eeea;

  --shadow-sm: 0 1px 2px rgba(40, 36, 28, 0.05);
  --shadow-md: 0 4px 16px rgba(40, 36, 28, 0.08);
  --shadow-lg: 0 8px 32px rgba(40, 36, 28, 0.1);

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.25rem;

  --font-body: 'General Sans', -apple-system, sans-serif;
  --font-display: 'Cabinet Grotesk', 'General Sans', sans-serif;
}

[data-theme="dark"] {
  --color-bg: #141311;
  --color-surface: #1c1b18;
  --color-surface-2: #232220;
  --color-border: #333130;
  --color-divider: #2a2927;

  --color-text: #d8d5cf;
  --color-text-muted: #8a877f;
  --color-text-faint: #5c5a56;

  --color-primary: #4aaf8e;
  --color-primary-hover: #3d9a7b;
  --color-primary-light: #1e2e28;
  --color-primary-lighter: #1a2622;

  --color-native: #4aaf8e;
  --color-native-bg: #1e2e28;
  --color-zapier: #e09040;
  --color-zapier-bg: #2c2218;
  --color-api: #6a9cd8;
  --color-api-bg: #1c2430;
  --color-none: #6b6860;
  --color-none-bg: #1e1d1b;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #141311;
    --color-surface: #1c1b18;
    --color-surface-2: #232220;
    --color-border: #333130;
    --color-divider: #2a2927;
    --color-text: #d8d5cf;
    --color-text-muted: #8a877f;
    --color-text-faint: #5c5a56;
    --color-primary: #4aaf8e;
    --color-primary-hover: #3d9a7b;
    --color-primary-light: #1e2e28;
    --color-primary-lighter: #1a2622;
    --color-native: #4aaf8e;
    --color-native-bg: #1e2e28;
    --color-zapier: #e09040;
    --color-zapier-bg: #2c2218;
    --color-api: #6a9cd8;
    --color-api-bg: #1c2430;
    --color-none: #6b6860;
    --color-none-bg: #1e1d1b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
  }
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}

/* ───── Header ───── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-divider);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: baseline;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.375rem;
  line-height: 1;
}

.logo-crm {
  color: #22c55e;
  font-weight: 800;
}

.logo-side {
  color: var(--color-text);
  font-weight: 600;
  font-size: 1.1rem;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.back-to-blog {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  padding: 0.4375rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-primary);
  transition: background 180ms ease, color 180ms ease;
}

.back-to-blog:hover {
  background: var(--color-primary);
  color: #fff;
}

.back-to-blog svg {
  flex-shrink: 0;
}

.nav-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius-sm);
  transition: color 180ms ease, background 180ms ease;
}

.nav-link:hover {
  color: var(--color-text);
  background: var(--color-primary-light);
}

[data-theme-toggle] {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease;
}
[data-theme-toggle]:hover {
  color: var(--color-text);
  background: var(--color-primary-light);
}

/* ───── Main ───── */
main {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ───── Hero ───── */
.hero {
  text-align: center;
  padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(1.5rem, 3vw, 2.5rem);
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.75rem, 1.2rem + 2.5vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--color-text);
  max-width: 720px;
  margin: 0 auto;
}

.hero .highlight {
  color: var(--color-primary);
}

.subtitle {
  margin-top: 1rem;
  color: var(--color-text-muted);
  font-size: clamp(0.875rem, 0.85rem + 0.2vw, 1.0625rem);
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.55;
}

/* ───── Checker ───── */
.checker {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  box-shadow: var(--shadow-md);
}

.selector-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}

.selector-group {
  flex: 1;
}

.selector-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.custom-select select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  appearance: none;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b6860' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.custom-select select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-lighter);
}

.connector-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--color-text-faint);
  margin-bottom: 2px;
}

.check-btn {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.875rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 180ms ease, transform 100ms ease, opacity 180ms ease;
}

.check-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.check-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.check-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ───── Result Area ───── */
.result-area {
  margin-top: 1.5rem;
  min-height: 0;
}

.result-area:empty { margin-top: 0; }

.result-card {
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid;
  animation: fadeSlide 300ms ease forwards;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-card.native {
  background: var(--color-native-bg);
  border-color: var(--color-native);
}
.result-card.zapier {
  background: var(--color-zapier-bg);
  border-color: var(--color-zapier);
}
.result-card.api {
  background: var(--color-api-bg);
  border-color: var(--color-api);
}
.result-card.none {
  background: var(--color-none-bg);
  border-color: var(--color-none);
}

.result-status {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 700;
  font-size: 1.0625rem;
  margin-bottom: 0.375rem;
}

.result-status .icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.result-card.native .result-status { color: var(--color-native); }
.result-card.native .icon { background: var(--color-native); color: #fff; }
.result-card.zapier .result-status { color: #7a3d08; }
.result-card.zapier .icon { background: var(--color-zapier); color: #fff; }
.result-card.api .result-status { color: var(--color-api); }
.result-card.api .icon { background: var(--color-api); color: #fff; }
.result-card.none .result-status { color: var(--color-none); }
.result-card.none .icon { background: var(--color-none); color: #fff; }

.result-detail {
  color: var(--color-text);
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: 64ch;
}

/* ───── Matrix ───── */
.matrix-section {
  margin-top: clamp(2.5rem, 4vw, 3.5rem);
  padding-bottom: clamp(2.5rem, 4vw, 3.5rem);
}

.matrix-section h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  letter-spacing: -0.015em;
}

.matrix-desc {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-top: 0.375rem;
  margin-bottom: 1.25rem;
}

.matrix-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.matrix-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface-2);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--color-border);
  text-align: center;
}

.matrix-table thead th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--color-surface-2);
}

.matrix-table tbody td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--color-divider);
  text-align: center;
  vertical-align: middle;
}

.matrix-table tbody td:first-child {
  font-weight: 600;
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--color-surface);
  z-index: 1;
  color: var(--color-text);
}

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

.matrix-table tbody tr:hover td {
  background: var(--color-primary-light);
}
.matrix-table tbody tr:hover td:first-child {
  background: var(--color-primary-light);
}

/* Matrix cell badges */
.cell-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.cell-badge.native { background: var(--color-native-bg); color: var(--color-native); }
.cell-badge.zapier { background: var(--color-zapier-bg); color: var(--color-zapier); }
.cell-badge.api    { background: var(--color-api-bg);    color: var(--color-api);    }
.cell-badge.none   { background: var(--color-none-bg);   color: var(--color-none);   }

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.native { background: var(--color-native); }
.dot.zapier { background: var(--color-zapier); }
.dot.api    { background: var(--color-api);    }
.dot.none   { background: var(--color-none);   }

/* ───── FAQ ───── */
.faq-section {
  margin-top: clamp(2rem, 4vw, 3rem);
  padding-bottom: clamp(2rem, 4vw, 3rem);
}

.faq-section h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  letter-spacing: -0.015em;
  margin-bottom: 1.25rem;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

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

.faq-item:first-child {
  border-top: 1px solid var(--color-divider);
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 0;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--color-text);
  cursor: pointer;
  list-style: none;
  transition: color 180ms ease;
  line-height: 1.45;
}

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

.faq-item summary::after {
  content: '';
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-left: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%236b6860' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 200ms ease;
}

.faq-item[open] summary::after {
  transform: rotate(180deg);
}

.faq-item summary:hover {
  color: var(--color-primary);
}

.faq-answer {
  padding: 0 0 1.25rem 0;
}

.faq-answer p {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.7;
  margin-bottom: 0.75rem;
  max-width: 72ch;
}

.faq-answer p:last-child {
  margin-bottom: 0;
}

.faq-answer strong {
  color: var(--color-text);
  font-weight: 600;
}

.faq-answer ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0.75rem 0;
}

.faq-answer ul li {
  position: relative;
  padding-left: 1.25rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.7;
  margin-bottom: 0.5rem;
}

.faq-answer ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
}

/* ───── Footer ───── */
footer {
  border-top: 1px solid var(--color-divider);
  padding: 1.5rem;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.625rem;
  font-size: 0.8125rem;
}

.footer-logo {
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
}

.footer-sep {
  color: var(--color-text-faint);
}

footer a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 180ms ease;
}

footer a:hover { color: var(--color-primary); }

/* ───── Responsive ───── */
@media (max-width: 640px) {
  .selector-row {
    flex-direction: column;
    align-items: stretch;
  }

  .connector-icon {
    width: auto;
    height: auto;
    margin: 0.25rem auto;
    transform: rotate(90deg);
  }

  .matrix-table { font-size: 0.75rem; }
  .cell-badge { font-size: 0.625rem; padding: 0.2rem 0.5rem; }

  .nav-link { display: none; }

  .back-to-blog span { display: none; }

  .header-nav { gap: 0.5rem; }

  .footer-inner { font-size: 0.75rem; gap: 0.5rem; }
}
