/* MasterAIKit.com — Clean, fast, conversion-focused */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2330;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --radius: 8px;
  --max-width: 840px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

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

/* ===== NAV ===== */
nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 20px;
  gap: 16px;
}
.nav-logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-logo span { color: var(--accent); }

/* Desktop nav links */
.nav-links {
  display: flex;
  gap: 20px;
  list-style: none;
  align-items: center;
  flex: 1;
}
.nav-links a { color: var(--text-dim); font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-cta {
  background: var(--accent);
  color: var(--bg) !important;
  padding: 6px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  white-space: nowrap;
}
.nav-cta:hover { background: var(--accent-hover); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-content {
  display: none;
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 0;
  min-width: 180px;
  top: 56px;
  left: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content { display: block; }
.dropdown-content a {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-dim);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.dropdown-content a:hover { background: var(--bg-hover); color: var(--text); }

/* Search in nav */
.nav-search {
  position: relative;
  flex-shrink: 0;
}
.nav-search input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  width: 180px;
  font-family: inherit;
  transition: border-color 0.15s, width 0.2s;
}
.nav-search input:focus {
  outline: none;
  border-color: var(--accent);
  width: 240px;
}
.nav-search input::placeholder { color: var(--text-dim); }
#search-results {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: min(400px, calc(100vw - 40px));
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 1001;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Mobile hamburger toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 4px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: all 0.2s;
}
.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ===== LAYOUT ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 20px;
  overflow-x: hidden;
}
.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 80px 20px 60px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-card) 100%);
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}
.hero .subheadline {
  font-size: 18px;
  color: var(--text-dim);
  max-width: 580px;
  margin: 0 auto 32px;
}
.hero-ctas {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); text-decoration: none; }
.btn-paid {
  background: var(--green);
  color: var(--bg);
}
.btn-paid:hover { background: #4cc961; text-decoration: none; }

/* ===== CARDS / GRIDS ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin: 32px 0;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.card h3 { font-size: 18px; margin-bottom: 8px; }
.card p { color: var(--text-dim); font-size: 14px; }
.card-icon { font-size: 28px; margin-bottom: 12px; }

/* ===== SECTIONS ===== */
.section {
  padding: 48px 0;
  border-bottom: 1px solid var(--border);
}
.section h2 {
  font-size: 28px;
  margin-bottom: 8px;
}
.section .section-sub {
  color: var(--text-dim);
  margin-bottom: 24px;
}

/* ===== TRUST BADGE ===== */
.trust-bar {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px 0;
}
.trust-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 14px;
}
.trust-item span { color: var(--green); }

/* ===== ARTICLE ===== */
.article-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-dim);
}
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-beginner { background: rgba(63,185,80,0.2); color: var(--green); }
.badge-intermediate { background: rgba(210,153,34,0.2); color: var(--orange); }
.badge-advanced { background: rgba(248,81,73,0.2); color: var(--red); }

.article h1 {
  font-size: 32px;
  line-height: 1.3;
  margin-bottom: 16px;
}
.article h2 {
  font-size: 24px;
  margin-top: 40px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.article h3 {
  font-size: 18px;
  margin-top: 28px;
  margin-bottom: 8px;
}
.article p { margin-bottom: 16px; overflow-wrap: break-word; }
.article { overflow-x: hidden; max-width: 100%; }
.article ul, .article ol { margin-bottom: 16px; padding-left: 24px; }
.article li { margin-bottom: 6px; }
.article code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'SF Mono', Consolas, monospace;
  overflow-wrap: break-word;
  word-break: break-word;
}
.article pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.article pre code { 
  background: none; 
  padding: 0; 
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: break-word;
  display: block;
  max-width: 100%;
}
.article blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin-bottom: 16px;
  background: var(--bg-card);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-dim);
}

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  max-width: 100%;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
  max-width: 100%;
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
th { color: var(--text-dim); font-weight: 600; }

/* ===== TESTED-ON BOX ===== */
.tested-on {
  background: rgba(88,166,255,0.08);
  border: 1px solid rgba(88,166,255,0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}
.tested-on h4 { color: var(--accent); margin-bottom: 8px; font-size: 14px; }
.tested-on code { background: rgba(88,166,255,0.15); }

/* ===== CTA BOX ===== */
.cta-box {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-hover));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  margin: 32px 0;
}
.cta-box h3 { font-size: 20px; margin-bottom: 8px; }
.cta-box p { color: var(--text-dim); margin-bottom: 16px; }

/* ===== WARNING BOX ===== */
.warning-box {
  background: rgba(248,81,73,0.08);
  border: 1px solid rgba(248,81,73,0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}
.warning-box h4 { color: var(--red); margin-bottom: 8px; }

/* ===== QUICK ANSWER ===== */
.quick-answer {
  background: rgba(63,185,80,0.08);
  border: 1px solid rgba(63,185,80,0.3);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
}
.quick-answer h4 { color: var(--green); margin-bottom: 8px; }

/* ===== FAQ ===== */
details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
}
details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
}
details[open] summary { margin-bottom: 12px; }

/* ===== FORM ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  max-width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 16px; /* 16px prevents iOS zoom */
  font-family: inherit;
  -webkit-appearance: none;
  overflow-wrap: break-word;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== FOOTER ===== */
footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 40px 20px;
  margin-top: 60px;
}
.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 32px;
}
.footer-section h4 { font-size: 14px; margin-bottom: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.footer-section ul { list-style: none; }
.footer-section li { margin-bottom: 6px; }
.footer-section a { color: var(--text-dim); font-size: 14px; }
.footer-bottom {
  max-width: 1200px;
  margin: 32px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ===== GUIDE CARDS ===== */
.guide-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color 0.15s;
  text-decoration: none;
}
.guide-card:hover { border-color: var(--accent); text-decoration: none; }
.guide-card h3 { font-size: 17px; margin-bottom: 6px; color: var(--text); }
.guide-card p { color: var(--text-dim); font-size: 14px; }
.guide-card-meta { display: flex; gap: 8px; margin-top: 8px; }


/* ===== FREE BUTTON VARIANT ===== */
.btn-free {
  background: var(--green);
  color: var(--bg);
}
.btn-free:hover { background: #4cc961; text-decoration: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  /* Mobile nav */
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }
  .nav-links.active { display: flex; }
  .nav-links.active a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 8px 0;
    font-size: 16px;
  }
  .nav-links.active .nav-cta {
    text-align: center;
    justify-content: center;
    margin-top: 8px;
  }
  .nav-links .dropdown-content {
    position: static;
    box-shadow: none;
    border: none;
    padding-left: 16px;
  }
  .nav-search input { width: 120px; }
  .nav-search input:focus { width: 160px; }

  /* Hero */
  .hero { padding: 48px 16px 40px; }
  .hero h1 { font-size: 26px; }
  .hero .subheadline { font-size: 16px; }
  .hero-ctas { flex-direction: column; align-items: stretch; gap: 12px; }
  .hero-ctas .btn { width: 100%; }

  /* Buttons on mobile */
  .btn {
    width: 100%;
    max-width: none;
    text-align: center;
    padding: 14px 24px;
    font-size: 16px;
    min-height: 48px;
  }

  /* Cards stack */
  .card-grid { grid-template-columns: 1fr; }

  /* Tables scroll */
  table { font-size: 13px; }
  th, td { padding: 8px 10px; }

  /* Container tighter padding */
  .container, .container-wide { padding: 24px 16px; }

  /* Footer stacks */
  .footer-container { grid-template-columns: 1fr 1fr; gap: 24px; }
  .footer-bottom { padding: 16px; }
}

  /* Force scroll on wide content blocks */
  .article pre, .article code { max-width: 100%; overflow-x: auto; }
  .article code { display: inline-block; max-width: 100%; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap { display: block; }

@media (max-width: 480px) {
  .footer-container { grid-template-columns: 1fr; }
  .hero h1 { font-size: 22px; }
  .nav-search { display: none; }
}

/* Smooth scroll for anchor links */
html { scroll-behavior: smooth; }

/* Ensure body doesn't overflow horizontally */
body { overflow-x: hidden; }

/* ===== SCRENSHOT PLACEHOLDER ===== */
.screenshot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 16px;
  font-size: 14px;
}

.screenshot img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

/* ===== ACCESSIBILITY ===== */
.skip-link {
  position: absolute;
  top: -60px;
  left: 0;
  background: var(--purple);
  color: #fff;
  padding: 12px 24px;
  font-weight: 700;
  z-index: 9999;
  border-radius: 0 0 8px 0;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

nav[role="navigation"] { display: flex; }

:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== FAQ SECTION ===== */
.faq-section {
  margin: 40px 0;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.faq-section h2 {
  margin-top: 0;
  font-size: 24px;
}

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

.faq-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.faq-item h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text);
}

.faq-item p {
  font-size: 15px;
  color: var(--text-dim);
  margin: 0;
}

/* ===== PRINT STYLES ===== */
@media print {
  nav, footer, .cta-box, .related-guides, .hero-ctas, .search-container, .skip-link {
    display: none !important;
  }
  body { background: #fff; color: #000; }
  article { max-width: 100%; }
  a { color: #000; text-decoration: underline; }
  a::after { content: " (" attr(href) ")"; font-size: 11px; }
  h1, h2, h3 { page-break-after: avoid; }
  table, blockquote, pre { page-break-inside: avoid; }
}

/* ===== READING PROGRESS BAR ===== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--purple);
  width: 0%;
  z-index: 9998;
  transition: width 0.1s;
}

/* ===== TABLE OF CONTENTS ===== */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
}
.toc h3 { margin-top: 0; font-size: 16px; }
.toc ul { margin: 0; padding-left: 20px; }
.toc li { margin-bottom: 6px; font-size: 14px; }
