/* a2pdf — shared stylesheet for the homepage and all landing pages.
 *
 * Design language:
 *   - Inter typography (same as the default PDF theme, so the website
 *     "looks like" the output it produces)
 *   - Warm red accent (#dc2626) — distinct from md2doc's blue, signals
 *     "PDF" without being literal
 *   - Generous whitespace, monospace details, no rounded-everything blandness
 */

:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --surface-muted: #f5f5f4;
    --ink: #1c1917;
    --ink-soft: #44403c;
    --ink-faded: #78716c;
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --accent: #dc2626;
    --accent-hover: #b91c1c;
    --accent-soft: #fef2f2;
    --accent-ink: #ffffff;
    --code-bg: #1c1917;
    --code-ink: #fafaf9;
    --shadow-sm: 0 1px 2px rgba(28,25,23,.06);
    --shadow-md: 0 4px 12px rgba(28,25,23,.08);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

code, pre, .mono {
    font-family: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.92em;
}

/* ── Header ────────────────────────────────────────────────────────────── */

.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.85);
}
.site-header .inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand {
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand .dot {
    display: inline-block;
    width: 10px; height: 10px;
    background: var(--accent);
    border-radius: 50%;
}
.site-nav {
    display: flex;
    gap: 22px;
    font-size: 14px;
}
.site-nav a {
    color: var(--ink-soft);
    font-weight: 500;
}
.site-nav a:hover { color: var(--ink); text-decoration: none; }

/* ── Hero ──────────────────────────────────────────────────────────────── */

.hero {
    max-width: 1080px;
    margin: 0 auto;
    padding: 56px 24px 24px;
}
.hero h1 {
    font-size: clamp(36px, 5vw, 56px);
    line-height: 1.05;
    letter-spacing: -0.03em;
    margin: 0 0 14px;
    color: var(--ink);
    font-weight: 800;
}
.hero h1 .accent { color: var(--accent); }
.hero .lede {
    font-size: clamp(17px, 1.8vw, 20px);
    color: var(--ink-soft);
    max-width: 640px;
    margin: 0 0 32px;
    line-height: 1.5;
}
.hero .badges {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 32px;
    font-size: 13px;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--ink-soft);
    font-weight: 500;
}
.badge .dot { width: 6px; height: 6px; background: #16a34a; border-radius: 50%; display: inline-block; }

/* ── Converter panel ──────────────────────────────────────────────────── */

.panel {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px 56px;
}
.converter {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}
.tab {
    flex: 1;
    padding: 14px 20px;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border);
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    color: var(--ink-soft);
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .15s;
}
.tab:last-child { border-right: 0; }
.tab:hover { background: rgba(220,38,38,0.04); color: var(--ink); }
.tab.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: inset 0 -2px 0 var(--accent);
}
.tab-icon { font-size: 16px; }

.mode {
    padding: 24px;
    display: none;
}
.mode.active { display: block; }

/* Upload drop zone */
.dropzone {
    /* <label> is inline by default, which collapses the dashed border
       to wrap only its inline content (the .big/.small/.filename divs
       still display block from inside, so the text appears centered but
       the border stays glued to a narrow column on the left). Force a
       block box so the border fills the panel. */
    display: block;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 56px 24px;
    text-align: center;
    transition: border-color .15s, background .15s;
    cursor: pointer;
}
.dropzone:hover, .dropzone.over {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.dropzone .big { font-size: 18px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.dropzone .small { color: var(--ink-faded); font-size: 14px; }
.dropzone input { display: none; }
.dropzone .filename {
    margin-top: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--accent);
}

/* Paste textarea */
.paste-area {
    width: 100%;
    min-height: 240px;
    padding: 14px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--surface-muted);
    resize: vertical;
}
.paste-area:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

.paste-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 13px;
    color: var(--ink-faded);
    gap: 12px;
    flex-wrap: wrap;
}
.format-select {
    padding: 5px 9px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13px;
    color: var(--ink);
}

/* URL input */
.url-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 16px;
    color: var(--ink);
    background: var(--surface-muted);
}
.url-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Settings disclosure */
.settings {
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
}
.settings summary {
    padding: 14px 24px;
    cursor: pointer;
    font-weight: 500;
    color: var(--ink-soft);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary::before {
    content: "▸";
    font-size: 11px;
    color: var(--ink-faded);
    transition: transform .15s;
}
.settings[open] summary::before { transform: rotate(90deg); }
.settings .settings-body {
    padding: 0 24px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.settings label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-faded);
    margin-bottom: 6px;
}
.settings select, .settings .checkbox-row {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font: inherit;
    font-size: 14px;
    color: var(--ink);
}
.settings .checkbox-row { display: flex; align-items: center; gap: 8px; }
.settings input[type="checkbox"] { accent-color: var(--accent); }

/* Submit button + result */
.actions {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.btn {
    background: var(--accent);
    color: var(--accent-ink);
    border: 0;
    border-radius: var(--radius-md);
    padding: 12px 22px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: var(--border-strong); cursor: wait; }
.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-muted); color: var(--ink); }

.result {
    flex: 1;
    font-size: 14px;
    color: var(--ink-soft);
    min-height: 24px;
}
.result.error { color: var(--accent); }
.result.success { color: #16a34a; }
.result a { font-weight: 600; }

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* PDF preview iframe (after success) */
.preview-frame {
    width: 100%;
    height: 600px;
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
}

/* ── Feature grid ─────────────────────────────────────────────────────── */

.features {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 24px 64px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.feature {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px;
}
.feature h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.feature p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.55;
}
.feature .num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent);
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

/* ── Content section (long-form for landing pages) ────────────────────── */

.content {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 24px 64px;
    color: var(--ink);
}
.content h2 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 40px 0 12px;
    color: var(--ink);
}
.content h3 {
    font-size: 19px;
    font-weight: 700;
    margin: 28px 0 8px;
}
.content p { margin: 0 0 16px; color: var(--ink-soft); }
.content ul, .content ol { margin: 0 0 16px; padding-left: 24px; color: var(--ink-soft); }
.content li { margin: 4px 0; }
.content pre {
    background: var(--code-bg);
    color: var(--code-ink);
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.55;
}
.content code:not(pre code) {
    background: var(--surface-muted);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.92em;
}
.content .faq-q {
    font-weight: 700;
    color: var(--ink);
    margin-top: 24px;
    margin-bottom: 4px;
}

/* ── Footer ───────────────────────────────────────────────────────────── */

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 36px 24px;
    color: var(--ink-faded);
    font-size: 14px;
}
.site-footer .inner {
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 24px;
}
.site-footer h4 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink);
    margin: 0 0 10px;
}
.site-footer a {
    color: var(--ink-soft);
    display: block;
    padding: 3px 0;
}
.site-footer a:hover { color: var(--accent); text-decoration: none; }
.site-footer .legal {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 8px;
    text-align: center;
    font-size: 13px;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .hero { padding: 36px 18px 18px; }
    .panel { padding: 0 18px 36px; }
    .features { padding: 18px 18px 48px; }
    .tabs { font-size: 14px; }
    .tab { padding: 12px 8px; }
    .tab .tab-text { display: none; }
    .tab .tab-icon { font-size: 18px; }
}

/* Accessibility: respect user motion and color preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-timing-function: linear !important;
    scroll-behavior: auto !important;
  }

  .converter .tab,
  .btn,
  .dropzone {
    transition: none !important;
  }
}

@media (prefers-color-scheme: dark) {
  /* Gentle dark mode support for the site UI (non-intrusive) */
  body {
    background: #0f0f0f;
    color: #e5e5e5;
  }

  .site-header,
  .panel,
  .converter {
    background: #1a1a1a;
    border-color: #333;
  }

  input,
  textarea,
  select {
    background: #111;
    color: #eee;
    border-color: #444;
  }

  .result {
    background: #111;
  }
}

/* ============================================================
   Night / Dark Mode (automatic via prefers-color-scheme)
   ============================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --surface: #272522;
    --surface-muted: #2f2c28;
    --ink: #f5f5f4;
    --ink-soft: #c4b8a8;
    --ink-faded: #a8a29e;
    --border: #3f3a35;
    --border-strong: #57524b;
    --accent: #f87171;          /* slightly softer red for dark backgrounds */
    --accent-hover: #fb923c;
    --accent-soft: #3f2a2a;
    --accent-ink: #1c1917;
    --code-bg: #111;
    --code-ink: #f5f5f4;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.5);
  }

  /* Component overrides that variables don't fully cover */
  .tab:hover {
    background: rgba(248, 113, 113, 0.08);
  }

  .dropzone:hover,
  .dropzone.over {
    background: var(--accent-soft);
  }

  .result {
    background: #111;
    border-color: var(--border);
  }

  .format-select,
  .select-theme,
  .select-paper,
  .select-orientation {
    background: #111;
    color: var(--ink);
    border-color: var(--border);
  }

  .settings {
    background: var(--surface-muted);
  }

  .site-footer {
    border-top-color: var(--border);
  }

  .badge {
    background: #2a2724;
  }
}
