/* ==========================================================================
   imben.co — Minimalist Engineering Portfolio & Systems Hub
   Design: Hyper-minimal, modern Swiss engineering aesthetic.
   ========================================================================== */

:root {
  --bg-primary: #0a0a0c;
  --bg-secondary: #111115;
  --bg-tertiary: #18181e;
  --bg-elevated: #22222a;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.16);
  --border-focus: #3b82f6;

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --accent-emerald: #10b981;
  --accent-blue: #3b82f6;
  --accent-amber: #f59e0b;

  --code-bg: #07080a;
  --code-border: rgba(255, 255, 255, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, Monaco, monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);

  --max-w: 880px;
  --transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f6f8;
  --bg-tertiary: #ededf1;
  --bg-elevated: #e3e3e8;
  --border: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.16);

  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #94949e;

  --code-bg: #f3f3f6;
  --code-border: rgba(0, 0, 0, 0.08);
}

/* Base reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

::selection {
  background: var(--text-primary);
  color: var(--bg-primary);
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
header.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(10, 10, 12, 0.85);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

[data-theme="light"] header.site-header {
  background: rgba(255, 255, 255, 0.9);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 16px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-link {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.telemetry-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.telemetry-pill .val {
  color: var(--accent-emerald);
  font-weight: 600;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  background: var(--bg-secondary);
}

/* Hero */
.hero-section {
  padding: 56px 0 36px;
  border-bottom: 1px solid var(--border);
}

.hero-pretitle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-emerald);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.hero-title {
  font-size: 2.3rem;
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 14px;
}

.hero-bio {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 22px;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  transition: var(--transition);
}

.hero-link-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

/* Section Wrappers */
.section-wrap {
  padding: 44px 0;
  border-bottom: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Services Grid */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.service-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.service-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.service-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.service-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.service-icon {
  font-size: 1rem;
}

.service-domain {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.88rem;
}

.service-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 12px;
  flex-grow: 1;
}

.service-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.badge-sso {
  padding: 1px 6px;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  font-size: 0.65rem;
  font-weight: 600;
}

.badge-public {
  padding: 1px 6px;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  font-size: 0.65rem;
  font-weight: 600;
}

/* Tag Filter Bar */
.tag-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
  flex-wrap: wrap;
}

.tag-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tag-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
}

.tag-btn.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
  font-weight: 600;
}

/* Article Cards */
.articles-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.article-card {
  padding: 18px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.article-card:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.article-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.article-title {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin-bottom: 8px;
}

.article-summary {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.article-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.article-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.article-tag:hover {
  color: var(--text-primary);
}

/* Modal Article Reader */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-container {
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-pop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.98) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.modal-title-path {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 30px 32px;
  overflow-y: auto;
  line-height: 1.7;
}

.article-markdown h1 {
  font-size: 1.75rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
  line-height: 1.25;
}

.article-markdown h2 {
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.article-markdown h3 {
  font-size: 1.05rem;
  font-weight: 650;
  margin: 20px 0 8px;
}

.article-markdown p {
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.article-markdown blockquote {
  border-left: 3px solid var(--accent-blue);
  padding: 8px 16px;
  background: var(--bg-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 16px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.article-markdown pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 16px 0;
  position: relative;
}

.article-markdown code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent-emerald);
}

.article-markdown table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin: 18px 0;
}

.article-markdown th,
.article-markdown td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.article-markdown th {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.article-markdown ul,
.article-markdown ol {
  margin-left: 20px;
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.article-markdown li {
  margin-bottom: 6px;
}

/* Post Images & Figures */
.post-figure {
  margin: 22px 0;
  text-align: center;
}

.post-figure img,
.article-markdown img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  display: block;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.post-figure img:hover,
.article-markdown img:hover {
  border-color: var(--border-light);
}

.img-caption {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* Footer */
footer.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 32px 0;
  background: var(--bg-secondary);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-link {
  color: var(--text-secondary);
  transition: var(--transition);
}

.footer-link:hover {
  color: var(--text-primary);
}

@media (max-width: 640px) {
  .hero-title {
    font-size: 1.85rem;
  }
  .header-nav {
    display: none;
  }
  .services-grid {
    grid-template-columns: 1fr;
  }
  .modal-body {
    padding: 20px;
  }
}
