/* ========================================
   Faktori Design System
   Mobile-first, system fonts, dark/light
   ======================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;

  /* Light mode (default) */
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-bg: #eff6ff;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --result-bg: #f0fdf4;
  --result-border: #16a34a;
  --result-text: #166534;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Sizing */
  --max-width: 72rem;
  --content-width: 48rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --bg-card: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #60a5fa;
    --accent-hover: #93bbfd;
    --accent-bg: #1e3a5f;
    --success: #4ade80;
    --success-bg: #0d2818;
    --result-bg: #0d2818;
    --result-border: #4ade80;
    --result-text: #86efac;
  }
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --bg-card: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #60a5fa;
  --accent-hover: #93bbfd;
  --accent-bg: #1e3a5f;
  --success: #4ade80;
  --success-bg: #0d2818;
  --result-bg: #0d2818;
  --result-border: #4ade80;
  --result-text: #86efac;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
table { border-collapse: collapse; width: 100%; }

/* Typography */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.3; margin-top: var(--space-2xl); margin-bottom: var(--space-md); }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; margin-top: var(--space-xl); margin-bottom: var(--space-sm); }
p { margin-bottom: var(--space-md); }

@media (min-width: 640px) {
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.625rem; }
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}
.content {
  max-width: var(--content-width);
  margin: 0 auto;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) 0;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.03em;
}
.logo:hover { color: var(--accent); text-decoration: none; }
.nav-links {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  list-style: none;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}
.nav-links a:hover { color: var(--accent); }
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-2xl) 0;
  margin-top: var(--space-3xl);
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-md);
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: var(--space-md) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs span { color: var(--text-muted); }

/* Hero / Result */
.hero {
  padding: var(--space-xl) 0 var(--space-2xl);
}
.result-box {
  background: var(--result-bg);
  border: 2px solid var(--result-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  text-align: center;
}
.result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--result-text);
  font-family: var(--font-mono);
}
@media (min-width: 640px) {
  .result-value { font-size: 2.5rem; }
}
.result-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* Copy button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: var(--space-sm);
  transition: background 0.15s;
}
.copy-btn:hover { background: var(--accent-hover); }

/* Quick answer */
.quick-answer {
  background: var(--bg-alt);
  border-left: 4px solid var(--accent);
  padding: var(--space-md) var(--space-lg);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: var(--space-lg) 0;
  font-size: 1.0625rem;
  line-height: 1.7;
}

/* Tables */
.data-table {
  overflow-x: auto;
  margin: var(--space-lg) 0;
}
.data-table table {
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  font-weight: 600;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}
.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover td {
  background: var(--bg-alt);
}
.data-table td a {
  font-weight: 500;
}
.data-table .num {
  font-family: var(--font-mono);
  text-align: right;
}

/* Formula */
.formula-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  font-family: var(--font-mono);
  font-size: 1.0625rem;
  text-align: center;
  overflow-x: auto;
}

/* FAQ */
.faq-section details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-sm);
}
.faq-section summary {
  padding: var(--space-md);
  cursor: pointer;
  font-weight: 500;
  list-style: none;
}
.faq-section summary::-webkit-details-marker { display: none; }
.faq-section summary::before {
  content: '+';
  display: inline-block;
  width: 1.25em;
  font-weight: 700;
  color: var(--accent);
}
.faq-section details[open] summary::before { content: '\2212'; }
.faq-section .faq-answer {
  padding: 0 var(--space-md) var(--space-md);
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.card h3 { margin-top: 0; font-size: 1rem; }
.card p { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0; }

/* Embed snippet */
.embed-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin: var(--space-lg) 0;
}
.embed-box code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
}

/* Context section */
.context-section {
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
}
.context-section h3 {
  margin-top: 0;
}
.context-section ul {
  padding-left: var(--space-lg);
  color: var(--text-secondary);
}
.context-section li {
  margin-bottom: var(--space-xs);
}

/* Interactive calculator inputs */
.calc-form {
  display: grid;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}
@media (min-width: 640px) {
  .calc-form { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
}
.calc-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.calc-form input,
.calc-form select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font-sans);
}
.calc-form input:focus,
.calc-form select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.calc-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-lg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.calc-btn:hover { background: var(--accent-hover); }

/* Yearly schedule table */
.schedule-table { margin: var(--space-lg) 0; }
.schedule-table details summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--accent);
  padding: var(--space-sm) 0;
}

/* Utility */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}
.text-center { text-align: center; }
.mt-lg { margin-top: var(--space-lg); }
.mb-lg { margin-bottom: var(--space-lg); }
