
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
  /* Background layers */
  --bg:        #06080d;
  --panel:     #0d121b;
  --panel-2:   #11182a;

  /* Ink */
  --ink:       #e6ebf2;
  --body:      #aab4c2;
  --dim:       #6a7388;
  --faint:     #2a3142;

  /* Rules */
  --rule:      #1a2030;

  /* Signal */
  --accent:    #22d3ee;
  --accent-dim:#0e7490;
  --warm:      #f59e0b;

  /* Semantic — kept for legacy classes */
  --primary-color:   var(--ink);
  --secondary-color: var(--accent);
  --accent-color:    var(--accent);
  --text-color:      var(--body);
  --light-text:      var(--dim);
  --bg-color:        var(--bg);
  --bg-gradient-end: var(--bg);
  --card-bg:         var(--panel);
  --border-color:    var(--rule);
  --shadow:          0 8px 24px rgba(0,0,0,0.5);
  --shadow-sm:       0 2px 8px rgba(0,0,0,0.35);

  /* Code blocks */
  --code-bg:    var(--panel);
  --code-text:  var(--accent);
  --pre-bg:     var(--panel);

  /* Post layout */
  --post-bg:           var(--bg);
  --post-text:         var(--body);
  --post-heading:      var(--ink);
  --post-subheading:   var(--ink);
  --post-meta-text:    var(--dim);
  --post-meta-bg:      var(--panel);
  --post-border:       var(--rule);
  --post-footer-btn-bg: var(--panel);
  --post-footer-btn-text: var(--ink);
  --blockquote-bg:     var(--panel);
  --blockquote-border: var(--accent);
  --blockquote-text:   var(--body);

  /* Problem cards */
  --problem-card-bg:    var(--panel);
  --problem-title-color: var(--ink);
  --problem-sub-text:   var(--dim);

  /* Sidebar */
  --sidebar-bg: var(--panel);

  /* Footer */
  --footer-link:    var(--body);
  --footer-subtext: var(--dim);

  /* Type */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Menlo', monospace;

  /* ─────────────────────────────────────────────────────────────
     DESIGN-SYSTEM SCALE  (added in redesign Phase 2)
     Additive tokens — the single source of truth for spacing, type,
     radii, layout width, motion and semantic colour. Existing rules
     keep their literal values; later phases migrate onto these, so
     adding them here is a no-op for current rendering.
     ───────────────────────────────────────────────────────────── */

  /* Spacing — 4px base unit */
  --space-0: 0;
  --space-1: 0.25rem;   /*  4px */
  --space-2: 0.5rem;    /*  8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-8: 3rem;      /* 48px */
  --space-10: 4rem;     /* 64px */
  --space-12: 6rem;     /* 96px */

  /* Type scale — 1.20 modular */
  --fs-xs:   0.75rem;   /* 12px */
  --fs-sm:   0.875rem;  /* 14px */
  --fs-base: 1rem;      /* 16px */
  --fs-md:   1.125rem;  /* 18px */
  --fs-lg:   1.25rem;   /* 20px */
  --fs-xl:   1.5rem;    /* 24px */
  --fs-2xl:  2rem;      /* 32px */
  --fs-3xl:  2.5rem;    /* 40px */
  --fs-4xl:  3.25rem;   /* 52px */

  /* Line heights */
  --leading-tight:   1.2;
  --leading-snug:    1.4;
  --leading-normal:  1.6;
  --leading-relaxed: 1.8;

  /* Radii */
  --radius-none: 0;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-pill: 9999px;

  /* Layout */
  --container:        1200px;
  --container-narrow: 760px;
  --sidebar-width:    250px;

  /* Elevation (in addition to --shadow / --shadow-sm) */
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);

  /* Motion */
  --dur-fast: 0.15s;
  --dur-med:  0.25s;
  --dur-slow: 0.4s;
  --ease:     cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index layers */
  --z-base:     1;
  --z-sticky:   100;
  --z-dropdown: 500;
  --z-header:   800;
  --z-overlay:  1000;
  --z-modal:    1100;

  /* Semantic — callouts / status (for Phase 5 docs components) */
  --info:    #38bdf8;  --info-bg:   rgba(56, 189, 248, 0.08);
  --tip:     #34d399;  --tip-bg:    rgba(52, 211, 153, 0.08);
  --warn:    #f59e0b;  --warn-bg:   rgba(245, 158, 11, 0.08);
  --danger:  #f87171;  --danger-bg: rgba(248, 113, 113, 0.08);
  --success: #34d399;
}


html,
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--body);
}

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

.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  padding: 0;
  box-shadow: none;
  width: 100%;
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 32px;
  display: flex; align-items: center; gap: 32px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}

.brand-mark { flex-shrink: 0; }

.brand-name {
  color: var(--ink); font-size: 15px; font-weight: 600;
  letter-spacing: -0.2px;
}

.site-nav {
  display: flex; gap: 26px;
  font-family: var(--font-sans);
  font-size: 13px;
}

.site-nav a {
  color: var(--body); text-decoration: none; font-weight: 500;
  transition: color 0.15s;
}

.site-nav a::after { display: none; }

.site-nav a:hover { color: var(--ink); }

.site-nav a.active { color: var(--accent); font-weight: 600; }

.header-meta { margin-left: auto; }

.search-chip {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--body);
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  border-radius: 0;
  width: 200px;
}

.search-chip::placeholder { color: var(--dim); }
.search-chip:focus { outline: none; border-color: var(--accent); }

/* Main Content */
.site-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

/* Global Search */
#global-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#global-results-container {
    position: absolute;
    top: 100%;
    right: 0;
    width: 300px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}

#global-results-container:empty {
    display: none;
}

#global-results-container li a {
    display: block;
    padding: 10px 15px;
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

#global-results-container li:last-child a {
    border-bottom: none;
}

#global-results-container li a:hover {
    background: var(--bg-color);
}

.site-main h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    line-height: 1.2;
}

.site-main h2 {
    font-size: 1.8rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.site-main p {
    font-size: 1.1rem;
    color: var(--light-text);
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

/* Posts and Projects */
.post,
.project {
    margin-bottom: 3rem;
}

.post-header,
.project-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--secondary-color);
}

.post-title,
.project-title {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.post-meta {
    color: var(--light-text);
    font-size: 0.95rem;
    font-weight: 500;
}

.project-description {
    color: var(--secondary-color);
    font-style: italic;
    margin-top: 0.75rem;
    font-size: 1.05rem;
}

.post-content,
.project-content {
    line-height: 1.8;
    font-size: 1.05rem;
}

.post-content h2,
.project-content h2,
.post-content h3,
.project-content h3 {
    color: var(--primary-color);
    margin: 1.5rem 0 0.75rem 0;
    font-weight: 700;
}

.post-content p,
.project-content p {
    margin-bottom: 1.2rem;
    color: var(--text-color);
}

.post-content a,
.project-content a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 2px;
}

.post-content a:hover,
.project-content a:hover {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.post-content code,
.project-content code {
    background-color: var(--code-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 0.9rem;
    color: var(--code-text);
    font-weight: 500;
}

.post-content pre,
.project-content pre {
    background: var(--pre-bg);
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
    border-left: 4px solid var(--secondary-color);
    box-shadow: var(--shadow);
}

.post-content pre code,
.project-content pre code {
    background-color: transparent;
    padding: 0;
    color: #e2e8f0;
}

.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--rule);
  color: var(--body);
  margin-top: 0;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 32px 28px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0;
}

.footer-col--center { text-align: center; }

.footer-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 14px;
}

.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links li { margin: 8px 0; }
.footer-links a { color: var(--body); text-decoration: none; font-size: 13px; }
.footer-links a:hover { color: var(--accent); }

.footer-socials { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.footer-social-link {
  color: var(--body); text-decoration: none;
  font-family: var(--font-mono); font-size: 12px;
  border: 1px solid var(--rule); padding: 6px 14px;
  transition: border-color 0.15s, color 0.15s;
}

.footer-social-link:hover { color: var(--accent); border-color: var(--accent); }

.footer-bottom {
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--dim);
}

.footer-bottom p { margin: 0; }
.footer-built-with { margin: 0; }

/* Project Card Styles */
.projects-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.project-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    border-left: 4px solid var(--secondary-color);
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
    border-left-color: var(--accent-color);
}

.project-card h3 {
    margin-bottom: 0.75rem;
}

.project-card h3 a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.3s ease;
}

.project-card h3 a:hover {
    color: var(--secondary-color);
}

.project-card p {
    color: var(--light-text);
    margin: 0;
}

/* Buttons */
a[role="button"],
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--secondary-color), #00b8d4);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

a[role="button"]:hover,
.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    background: linear-gradient(135deg, var(--accent-color), #ff5a8d);
}

/* Modern cross-page link button */
.btn-crosslink {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1.08rem;
    font-weight: 600;
    background: linear-gradient(90deg, #00d4ff, #ff6b9d);
    color: white !important;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.08);
    text-decoration: none;
    border: none;
    transition: background 0.2s, box-shadow 0.2s;
}

.btn-crosslink:hover {
    background: linear-gradient(90deg, #ff6b9d, #00d4ff);
    box-shadow: 0 8px 24px rgba(255, 107, 157, 0.13);
    color: #fff !important;
}

/* List Styles */
.site-main ul,
.site-main ol {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.site-main li {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

/* Responsive */
@media (max-width: 768px) {
    .site-title {
        font-size: 1.5rem;
    }

    .site-nav {
        gap: 1rem;
        font-size: 0.9rem;
    }

    .post-title,
    .project-title {
        font-size: 1.75rem;
    }

    .site-main {
        padding: 1.5rem;
    }

    .site-main h1 {
        font-size: 2rem;
    }

    .projects-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .site-nav {
        gap: 0.75rem;
    }

    .site-title {
        font-size: 1.3rem;
    }

    .post-title,
    .project-title {
        font-size: 1.5rem;
    }

    .site-main {
        padding: 1rem;
    }

    .site-main h1 {
        font-size: 1.75rem;
    }

    .site-main h2 {
        font-size: 1.4rem;
    }
}

@media (max-width: 1024px) {
    #global-search-wrapper {
        width: 100%;
        order: 4;
        margin-top: 0.5rem;
    }

    #global-results-container {
        width: 100%;
        left: 0;
        right: auto;
    }
}

/* Icon for cards */
.card-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 0.5rem;
    fill: var(--secondary-color);
}


/* Diagram images: constrain width for readability */
.diagram-img {
    display: block;
    width: 100%;
    max-width: 900px;
    height: auto;
    margin: 1.75rem auto;
}


/* ===============================================================
   Search trigger (header) + Command palette (Cmd/Ctrl+K) - Phase 6
   =============================================================== */
.search-trigger {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 200px; padding: 6px 12px;
  background: transparent; border: 1px solid var(--rule);
  color: var(--dim); cursor: pointer;
  font-family: var(--font-mono); font-size: 11.5px;
  transition: border-color 0.15s, color 0.15s;
}
.search-trigger:hover { border-color: var(--accent); color: var(--body); }
.search-trigger-kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  border: 1px solid var(--rule); border-radius: 3px; padding: 1px 5px; color: var(--dim);
}

.cmdk { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: flex-start; justify-content: center; }
.cmdk[hidden] { display: none; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 10, 0.72); }
.cmdk-panel {
  position: relative; z-index: 1;
  width: 92%; max-width: 560px; margin-top: 12vh; max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--rule);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.cmdk-input {
  background: transparent; border: none; outline: none;
  color: var(--ink); font-family: var(--font-sans); font-size: 16px;
  padding: 18px 20px; border-bottom: 1px solid var(--rule);
}
.cmdk-input::placeholder { color: var(--dim); }
.cmdk-results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.cmdk-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; cursor: pointer; border-left: 2px solid transparent;
}
.cmdk-item.active { background: var(--panel-2); border-left-color: var(--accent); }
.cmdk-item-title { color: var(--ink); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item-cat {
  flex-shrink: 0; font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 1px; color: var(--accent);
}
.cmdk-empty { padding: 18px 14px; color: var(--dim); font-size: 14px; text-align: center; }
.cmdk-foot {
  display: flex; gap: 18px; padding: 10px 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--dim);
}
.cmdk-foot kbd { border: 1px solid var(--rule); border-radius: 3px; padding: 0 4px; color: var(--body); }
body.cmdk-open { overflow: hidden; }

@media (max-width: 600px) {
  .search-trigger { width: auto; }
  .search-trigger-label { display: none; }
}