/* ==========================================================================
   GitHubFolder — design system
   Aesthetic: Dark-first OKLCH, "terminal-native" developer tool identity.
   Distinct from sibling photoconvert (copper/Fraunces). Accent: indigo/violet
   (hue ~290) for actions, green (hue ~145, git "add" color) for success/
   checked/progress states, red (hue ~25) for errors. Fonts: Sora (display +
   body) paired with JetBrains Mono (file paths / code / tree / curl only).
   Manual light/dark toggle via [data-theme], defaulting to system preference.
   ========================================================================== */

/* ---- Design tokens ---- */
:root {
  color-scheme: dark;

  --color-bg: oklch(15% 0.014 250);
  --color-surface: oklch(20% 0.016 250);
  --color-surface-2: oklch(25% 0.018 250);
  --color-surface-3: oklch(30% 0.02 250);
  --color-ink: oklch(96% 0.006 250);
  --color-ink-muted: oklch(76% 0.012 250);
  --color-ink-faint: oklch(58% 0.014 250);

  --color-accent: oklch(64% 0.19 290);
  --color-accent-hover: oklch(70% 0.19 290);
  --color-accent-strong: oklch(55% 0.21 286);
  --color-accent-soft: oklch(64% 0.19 290 / 14%);
  --color-on-accent: oklch(99% 0.01 290);

  --color-success: oklch(72% 0.16 145);
  --color-success-soft: oklch(72% 0.16 145 / 14%);
  --color-error: oklch(68% 0.19 25);
  --color-error-soft: oklch(68% 0.19 25 / 14%);

  --color-border: oklch(40% 0.02 250 / 55%);
  --color-border-strong: oklch(52% 0.02 250 / 75%);

  --font-display: "Sora", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 30%), 0 1px 1px oklch(0% 0 0 / 20%);
  --shadow-md: 0 8px 24px oklch(0% 0 0 / 34%), 0 2px 8px oklch(0% 0 0 / 22%);
  --shadow-lg: 0 24px 64px oklch(0% 0 0 / 40%), 0 8px 24px oklch(0% 0 0 / 26%);

  --z-dropdown: 10;
  --z-sticky: 20;
  --z-modal-backdrop: 30;
  --z-modal: 40;
  --z-toast: 50;
  --z-tooltip: 60;
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-bg: oklch(97% 0.006 250);
  --color-surface: oklch(99.5% 0.003 250);
  --color-surface-2: oklch(95% 0.008 250);
  --color-surface-3: oklch(91% 0.012 250);
  --color-ink: oklch(22% 0.02 250);
  --color-ink-muted: oklch(40% 0.02 250);
  --color-ink-faint: oklch(52% 0.016 250);
  --color-accent: oklch(48% 0.19 290);
  --color-accent-hover: oklch(42% 0.2 290);
  --color-accent-strong: oklch(40% 0.21 286);
  --color-accent-soft: oklch(48% 0.19 290 / 10%);
  --color-on-accent: oklch(99% 0.01 290);
  --color-success: oklch(45% 0.15 145);
  --color-success-soft: oklch(45% 0.15 145 / 10%);
  --color-error: oklch(48% 0.2 25);
  --color-error-soft: oklch(48% 0.2 25 / 10%);
  --color-border: oklch(80% 0.012 250 / 80%);
  --color-border-strong: oklch(68% 0.016 250 / 90%);
  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 6%), 0 1px 1px oklch(0% 0 0 / 4%);
  --shadow-md: 0 8px 24px oklch(0% 0 0 / 8%), 0 2px 8px oklch(0% 0 0 / 5%);
  --shadow-lg: 0 24px 64px oklch(0% 0 0 / 12%), 0 8px 24px oklch(0% 0 0 / 6%);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --color-bg: oklch(97% 0.006 250);
    --color-surface: oklch(99.5% 0.003 250);
    --color-surface-2: oklch(95% 0.008 250);
    --color-surface-3: oklch(91% 0.012 250);
    --color-ink: oklch(22% 0.02 250);
    --color-ink-muted: oklch(40% 0.02 250);
    --color-ink-faint: oklch(52% 0.016 250);
    --color-accent: oklch(48% 0.19 290);
    --color-accent-hover: oklch(42% 0.2 290);
    --color-accent-strong: oklch(40% 0.21 286);
    --color-accent-soft: oklch(48% 0.19 290 / 10%);
    --color-on-accent: oklch(99% 0.01 290);
    --color-success: oklch(45% 0.15 145);
    --color-success-soft: oklch(45% 0.15 145 / 10%);
    --color-error: oklch(48% 0.2 25);
    --color-error-soft: oklch(48% 0.2 25 / 10%);
    --color-border: oklch(80% 0.012 250 / 80%);
    --color-border-strong: oklch(68% 0.016 250 / 90%);
  }
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body, var(--font-display));
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}
img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--color-accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--color-accent-hover); }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; text-wrap: balance; margin: 0; }
p { max-width: 72ch; }
p.lede, .prose p { text-wrap: pretty; }
code, kbd, pre, .mono { font-family: var(--font-mono); }
ul, ol { padding-left: 1.25em; }

/* ---- Utilities ---- */
.container { max-width: 1200px; margin-inline: auto; padding-inline: clamp(1rem, 3vw, 1.5rem); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: var(--z-toast);
  background: var(--color-accent); color: var(--color-on-accent);
  padding: 0.75rem 1.25rem; border-radius: var(--radius-sm); font-weight: 600;
  transition: top 0.2s ease-out;
}
.skip-link:focus { top: 1rem; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 4px;
}
@media (forced-colors: active) {
  :focus-visible { outline: 3px solid ButtonText; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Header ---- */
.site-header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: color-mix(in oklch, var(--color-bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}
.nav-container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 0.85rem; }
.logo { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--color-ink); }
.logo:hover { color: var(--color-ink); }
.logo svg { flex-shrink: 0; }
.nav-links { display: flex; gap: 1.75rem; list-style: none; margin: 0; padding: 0; }
.nav-links a { color: var(--color-ink-muted); font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--color-ink); }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent; cursor: pointer;
  color: var(--color-ink-muted);
}
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-ink); border-color: var(--color-border); }
#theme-toggle .icon-sun, #theme-toggle .icon-moon { display: none; }
:root:not([data-theme="light"]) #theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] #theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) #theme-toggle .icon-sun { display: none; }
  :root:not([data-theme]) #theme-toggle .icon-moon { display: block; }
}
.mobile-menu-btn { display: none; }
@media (max-width: 760px) {
  .nav-links { position: fixed; inset: 64px 0 auto 0; flex-direction: column; gap: 0; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 0.5rem 0; transform: translateY(-8px); opacity: 0; pointer-events: none; transition: transform 0.2s ease-out, opacity 0.2s ease-out; }
  .nav-links.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-links li { border-top: 1px solid var(--color-border); }
  .nav-links a { display: block; padding: 0.85rem 1.25rem; }
  .mobile-menu-btn { display: inline-flex; }
}

/* ---- Hero ---- */
.hero { padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(2rem, 5vw, 3rem); }
.hero-inner { max-width: 760px; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw + 0.5rem, 3.25rem); letter-spacing: -0.02em; margin-bottom: 0.9rem; }
.hero .lede { font-size: clamp(1.05rem, 1.2vw + 0.6rem, 1.25rem); color: var(--color-ink-muted); margin-bottom: 2rem; }

.tool-card {
  container-type: inline-size;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: var(--shadow-md);
}
.url-form { display: flex; flex-direction: column; gap: 0.75rem; }
@container (min-width: 480px) {
  .url-form { flex-direction: row; }
  .url-form .field-group { flex: 1; }
}
.field-group { display: flex; flex-direction: column; gap: 0.4rem; }
.field-group label { font-size: 0.85rem; font-weight: 600; color: var(--color-ink-muted); }
.field-group input[type="url"], .field-group input[type="text"], .field-group input[type="email"], .field-group textarea {
  width: 100%; padding: 0.85rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong); background: var(--color-surface-2);
  color: var(--color-ink); font-family: var(--font-mono); font-size: 0.95rem;
  min-height: 44px;
}
.field-group textarea { resize: vertical; font-family: inherit; }
.field-group input:focus-visible, .field-group textarea:focus-visible { border-color: var(--color-accent); }
.field-group input::placeholder, .field-group textarea::placeholder { color: var(--color-ink-faint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.85rem 1.5rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.95rem; border: 1px solid transparent;
  cursor: pointer; min-height: 44px; min-width: 44px;
  transition: transform 0.15s cubic-bezier(0.16,1,0.3,1), background-color 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn-primary:hover { background: var(--color-accent-hover); color: var(--color-on-accent); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--color-surface-2); color: var(--color-ink); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-3); color: var(--color-ink); }
.btn-ghost { background: transparent; color: var(--color-ink-muted); }
.btn-ghost:hover { color: var(--color-ink); background: var(--color-surface-2); }
.btn-sm { padding: 0.5rem 0.9rem; min-height: 36px; font-size: 0.85rem; }

.trust-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-top: 1.25rem; }
.trust-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--color-ink-muted); }
.trust-item svg { color: var(--color-success); flex-shrink: 0; }

/* ---- Tool states ---- */
.tool-state { margin-top: 1.5rem; }
.tool-state[hidden] { display: none; }

.progress-region { display: flex; flex-direction: column; gap: 0.6rem; }
.progress-status { font-size: 0.95rem; font-family: var(--font-mono); color: var(--color-ink); }
.progress-track { height: 10px; border-radius: 999px; background: var(--color-surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-success); width: 0%; transition: width 0.2s ease-out; border-radius: inherit; }

.error-panel {
  display: flex; gap: 0.85rem; padding: 1rem 1.25rem; border-radius: var(--radius-md);
  background: var(--color-error-soft); border: 1px solid color-mix(in oklch, var(--color-error) 40%, transparent);
}
.error-panel svg { flex-shrink: 0; color: var(--color-error); margin-top: 2px; }
.error-panel h3 { font-size: 1rem; margin-bottom: 0.3rem; }
.error-panel p { margin: 0; color: var(--color-ink-muted); font-size: 0.9rem; }
.error-panel .btn { margin-top: 0.75rem; }
.banner-warning {
  display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.85rem 1rem;
  border-radius: var(--radius-sm); background: var(--color-accent-soft);
  border: 1px solid color-mix(in oklch, var(--color-accent) 35%, transparent);
  font-size: 0.88rem; color: var(--color-ink-muted); margin-top: 1rem;
}

/* ---- File tree ---- */
.tree-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.85rem; }
.tree-meta { font-size: 0.85rem; color: var(--color-ink-muted); font-family: var(--font-mono); }
.file-tree {
  list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface-2);
}
.file-tree ul { list-style: none; margin: 0; padding-left: 1.5rem; }
.tree-node { border-bottom: 1px solid var(--color-border); }
.tree-node:last-child { border-bottom: none; }
.tree-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.85rem; font-family: var(--font-mono); font-size: 0.87rem; }
.tree-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--color-success); flex-shrink: 0; }
.tree-row .tree-icon { color: var(--color-ink-faint); flex-shrink: 0; }
.tree-row button.tree-toggle { background: none; border: none; padding: 0; cursor: pointer; color: var(--color-ink-muted); display: flex; }
.tree-row .tree-label { overflow-wrap: anywhere; }
.tree-row .tree-size { margin-left: auto; color: var(--color-ink-faint); font-size: 0.8rem; }

/* ---- Recent downloads / history ---- */
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.65rem 0.9rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); font-size: 0.85rem; }
.history-item .history-path { font-family: var(--font-mono); color: var(--color-ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Sections / content ---- */
main { display: block; }
.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.section-alt { background: var(--color-surface); border-block: 1px solid var(--color-border); }
.section-head { max-width: 640px; margin-bottom: 2.25rem; }
.section-head h2 { font-size: clamp(1.5rem, 2.4vw + 0.5rem, 2.25rem); letter-spacing: -0.015em; margin-bottom: 0.6rem; }
.section-head p { color: var(--color-ink-muted); }

.feature-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.feature { padding: 1.5rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); transition: transform 0.2s cubic-bezier(0.16,1,0.3,1), border-color 0.2s ease; }
.feature:hover { transform: translateY(-3px); border-color: var(--color-border-strong); }
.feature .feature-icon { color: var(--color-accent); margin-bottom: 0.85rem; }
.feature h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.feature p { color: var(--color-ink-muted); font-size: 0.92rem; margin: 0; }

/* ---- Page hero (sub-pages) ---- */
.page-hero { padding-block: clamp(2rem, 5vw, 3.5rem) clamp(1.5rem, 3vw, 2rem); }
.breadcrumbs { font-size: 0.85rem; color: var(--color-ink-faint); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--color-ink-muted); }
.breadcrumbs [aria-current="page"] { color: var(--color-ink); }
.page-hero h1 { font-size: clamp(1.7rem, 3.2vw + 0.5rem, 2.5rem); letter-spacing: -0.02em; margin-bottom: 0.75rem; }
.page-hero .lede { color: var(--color-ink-muted); font-size: 1.05rem; }

.prose { max-width: 72ch; }
.prose h2 { font-size: 1.4rem; margin-block: 2rem 0.75rem; letter-spacing: -0.01em; }
.prose h3 { font-size: 1.15rem; margin-block: 1.5rem 0.5rem; }
.prose p { margin-block: 0 1rem; color: var(--color-ink-muted); }
.prose ul, .prose ol { color: var(--color-ink-muted); margin-block: 0 1rem; }
.prose li { margin-bottom: 0.4rem; }
.prose code { background: var(--color-surface-2); padding: 0.15em 0.4em; border-radius: 5px; font-size: 0.88em; color: var(--color-ink); }
.prose pre { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 1rem 1.25rem; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose a { text-decoration-line: underline; }

.callout { display: flex; gap: 0.85rem; padding: 1rem 1.25rem; border-radius: var(--radius-md); background: var(--color-accent-soft); border: 1px solid color-mix(in oklch, var(--color-accent) 35%, transparent); margin-block: 1.25rem; }
.callout-title { font-weight: 700; color: var(--color-ink); margin-bottom: 0.25rem; }
.callout p { margin: 0; color: var(--color-ink-muted); font-size: 0.92rem; }

/* Comparison table (alternatives page) */
.compare-table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
table.compare-table { width: 100%; border-collapse: collapse; min-width: 640px; font-size: 0.92rem; }
.compare-table th, .compare-table td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.compare-table th { background: var(--color-surface-2); font-family: var(--font-display); font-weight: 700; }
.compare-table tr:last-child td { border-bottom: none; }
.compare-table td[data-yes]::before { content: "✓ "; color: var(--color-success); font-weight: 700; }
.compare-table td[data-no]::before { content: "✕ "; color: var(--color-ink-faint); }

/* HowTo steps (real numbered sequence — earns the numbering) */
.howto-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 1.25rem; }
.howto-step { display: grid; grid-template-columns: auto 1fr; gap: 1rem; counter-increment: step; }
.howto-step::before {
  content: counter(step);
  display: flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--color-accent-soft); color: var(--color-accent);
  font-family: var(--font-mono); font-weight: 700; flex-shrink: 0;
}
.howto-step h3 { font-size: 1.05rem; margin-bottom: 0.35rem; }
.howto-step p { color: var(--color-ink-muted); margin: 0; }

/* FAQ accordion */
.faq-list { display: grid; gap: 0.75rem; }
.faq-item { border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); overflow: hidden; }
.faq-item summary {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.25rem; cursor: pointer; font-weight: 600; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary .chev { transition: transform 0.2s ease-out; flex-shrink: 0; color: var(--color-ink-muted); }
.faq-item[open] summary .chev { transform: rotate(180deg); }
.faq-item .faq-answer { padding: 0 1.25rem 1.1rem; color: var(--color-ink-muted); }

/* Glossary */
.glossary-list { display: grid; gap: 1.5rem; }
.glossary-item dt { font-family: var(--font-mono); font-weight: 700; color: var(--color-ink); font-size: 1.05rem; }
.glossary-item dd { margin: 0.35rem 0 0; color: var(--color-ink-muted); }

/* Related links */
.related-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.related-list a { display: block; padding: 0.85rem 1rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); font-weight: 600; }
.related-list a:hover { border-color: var(--color-accent); }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--color-border); background: var(--color-surface); padding-block: clamp(2.5rem, 5vw, 3.5rem) 1.5rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 2rem; }
.footer-brand p { color: var(--color-ink-muted); font-size: 0.9rem; margin-top: 0.75rem; max-width: 32ch; }
.footer-col h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-ink-faint); margin-bottom: 0.85rem; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.footer-col a { color: var(--color-ink-muted); font-size: 0.9rem; }
.footer-col a:hover { color: var(--color-ink); }
.footer-bottom { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; justify-content: space-between; padding-top: 1.5rem; border-top: 1px solid var(--color-border); font-size: 0.85rem; color: var(--color-ink-faint); }

/* Ad slots — reserve space up front to avoid CLS */
.ad-slot { display: flex; align-items: center; justify-content: center; margin-block: 1.5rem; min-height: 90px; }
.ad-slot[hidden] { display: none; }

@media (max-width: 480px) {
  .hero h1 { letter-spacing: -0.015em; }
  .footer-bottom { flex-direction: column; }
}

/* Scroll-driven entrance reveal — progressive enhancement only.
   Content is fully visible by default in browsers without
   animation-timeline support; nothing is gated behind JS or a class flip. */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .reveal {
      animation: reveal-in linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
  }
}
@keyframes reveal-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
