/* ============================================================
   MICROSITE PORTFOLIO — Shared Design System
   Vanilla CSS, zero dependencies, <8KB gzipped
   ============================================================ */

:root {
  /* Color palette */
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;

  /* Spacing */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);

  /* Layout */
  --max-width: 960px;
  --header-h: 64px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  height: var(--header-h);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon { font-size: 1.5rem; }
nav ul { list-style: none; display: flex; gap: 24px; }
nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}
nav a:hover { color: var(--primary); }

/* ===== Main content ===== */
main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px;
}

/* ===== Hero / page title ===== */
.hero { text-align: center; margin-bottom: 32px; }
.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.hero p { color: var(--text-muted); font-size: 1.05rem; max-width: 600px; margin: 0 auto; }

/* ===== Tool card ===== */
.tool-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-bottom: 24px;
}

/* ===== Forms ===== */
.input-group { margin-bottom: 20px; }
.input-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
}
.input-group .hint { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }
input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], input[type="tel"], input[type="url"], select, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }

/* Input grid */
.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 2px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #059669; }

/* ===== Results ===== */
.result-box {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 24px;
  margin-top: 20px;
  display: none;
}
.result-box.show { display: block; }
.result-box h3 { margin-bottom: 12px; font-size: 1.1rem; }
.result-value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -0.02em;
}
.result-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.result-detail .item { text-align: center; }
.result-detail .item .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.result-detail .item .val { font-size: 1.2rem; font-weight: 700; color: var(--primary-dark); }

/* ===== Ad zones ===== */
.ad-zone {
  margin: 24px 0;
  text-align: center;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-zone .ad-placeholder {
  width: 100%;
  min-height: 90px;
  background: repeating-linear-gradient(
    45deg, var(--code-bg), var(--code-bg) 10px, var(--bg) 10px, var(--bg) 20px
  );
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.ad-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

/* ===== Content / article ===== */
.article-content { line-height: 1.8; }
.article-content h2 { font-size: 1.5rem; margin: 28px 0 12px; }
.article-content h3 { font-size: 1.2rem; margin: 24px 0 8px; }
.article-content p { margin-bottom: 16px; color: var(--text); }
.article-content ul, .article-content ol { margin: 0 0 16px 20px; }
.article-content li { margin-bottom: 6px; }
.article-content code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Fira Code', Consolas, monospace;
}

/* ===== FAQ accordion ===== */
.faq-item { border-bottom: 1px solid var(--border); }
.faq-question {
  padding: 16px 0;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}
.faq-question::-webkit-details-marker { display: none; }
.faq-question::after { content: '▸'; color: var(--primary); font-size: 1.2rem; transition: transform 0.2s; }
details[open] .faq-question::after { transform: rotate(90deg); }
.faq-answer { padding: 0 0 16px; color: var(--text-muted); }

/* ===== Table ===== */
.data-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--bg); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.04em; }
.data-table tr:hover { background: var(--bg); }

/* ===== Related tools ===== */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.related-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.related-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.related-card .title { font-weight: 600; color: var(--primary); }
.related-card .desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Footer ===== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 20px;
  margin-top: 48px;
}
.footer-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 32px;
}
.footer-col h4 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; color: var(--text-muted); }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { color: var(--text); text-decoration: none; font-size: 0.9rem; transition: color 0.15s; }
.footer-col a:hover { color: var(--primary); }
.footer-bottom {
  max-width: var(--max-width);
  margin: 24px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== Toast notifications ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }

/* ===== Copy button ===== */
.copy-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.copy-btn:hover { background: var(--border); }
.copy-btn.copied { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.5rem; }
  .tool-card { padding: 20px; }
  nav ul { gap: 16px; }
  nav a { font-size: 0.85rem; }
  .result-value { font-size: 1.8rem; }
  .header-actions { gap: 8px; }
  .lang-switcher { font-size: 0.75rem; }
  .theme-toggle { padding: 4px 8px; }
  .theme-toggle .theme-icon { font-size: 0.85rem; }
}

/* ===== Mega Menu (Tool Groups Navigation) ===== */
.mega-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.mega-nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 6px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.mega-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.mega-nav a:hover {
  color: var(--primary);
  background: var(--primary-light);
}
.mega-nav a.active {
  color: var(--primary);
  font-weight: 700;
  background: var(--primary-light);
}
.mega-nav .mega-icon { font-size: 1rem; }

/* ===== Portal Grid (All Tools Landing) ===== */
.portal-hero {
  text-align: center;
  padding: 48px 20px 32px;
}
.portal-hero h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 12px; }
.portal-hero p { color: var(--text-muted); font-size: 1.1rem; max-width: 650px; margin: 0 auto; }
.portal-search {
  max-width: 480px;
  margin: 24px auto 0;
  position: relative;
}
.portal-search input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}
.portal-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.portal-search .search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}
.portal-section { margin: 40px 0 24px; }
.portal-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.portal-section-title .section-icon { font-size: 1.3rem; }
.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.portal-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.portal-card .card-icon { font-size: 1.8rem; margin-bottom: 8px; display: block; }
.portal-card .card-name { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; color: var(--text); }
.portal-card .card-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.portal-card.hidden { display: none; }

@media (max-width: 640px) {
  .portal-hero h1 { font-size: 1.6rem; }
  .portal-hero p { font-size: 0.95rem; }
  .portal-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .portal-card { padding: 14px; }
  .portal-card .card-icon { font-size: 1.4rem; }
  .mega-nav a { padding: 6px 10px; font-size: 0.8rem; }
  .mega-nav-inner { padding: 4px 12px; gap: 2px; }
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s;
  color: var(--text);
}
.theme-toggle:hover { border-color: var(--primary); }
.theme-toggle .theme-icon { font-size: 1rem; transition: transform 0.3s; }
.theme-toggle .theme-icon.spin { transform: rotate(360deg); }
[data-theme="dark"] .theme-toggle .theme-icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-sun { display: none; }
[data-theme="light"] .theme-toggle .theme-icon-moon { display: inline; }
/* Defaults (no data-theme set = light) */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: inline; }
html:not([data-theme]) .theme-icon-sun { display: none; }
html:not([data-theme]) .theme-icon-moon { display: inline; }

/* ===== Dark Mode ===== */
:root[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-dark: #93bbfd;
  --primary-light: #1e3a5f;
  --accent: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --code-bg: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.4);
  color-scheme: dark;
}

/* Dark mode specific overrides for components */
[data-theme="dark"] .ad-zone .ad-placeholder {
  background: repeating-linear-gradient(
    45deg, var(--code-bg), var(--code-bg) 10px, var(--bg) 10px, var(--bg) 20px
  );
}
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}
[data-theme="dark"] .btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .copy-btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .data-table th {
  background: var(--surface);
}
[data-theme="dark"] .data-table tr:hover {
  background: var(--surface);
}
[data-theme="dark"] .result-value {
  color: var(--primary);
}

/* ===== Print ===== */
@media print {
  .site-header, .site-footer, .ad-zone, nav, .theme-toggle { display: none; }
  body { background: #fff; }
  [data-theme="dark"] { --bg: #fff; --text: #000; --surface: #fff; }
}
