/* =============================================================================
   ENGINEERING BLOG — extra.css
   Version: clean-final
   Inspired by: Vercel, GitHub, Linear, Cloudflare
   ============================================================================= */


/* =============================================================================
   1. BRAND TOKENS
   ============================================================================= */

[data-md-color-scheme="default"] {
  --md-primary-fg-color:         #3d5afe;
  --md-primary-fg-color--light:  #6f7ff7;
  --md-primary-fg-color--dark:   #2140e0;
  --md-primary-bg-color:         #ffffff;
  --md-primary-bg-color--light:  #ffffff;
  --md-accent-fg-color:          #3d5afe;
  --md-typeset-a-color:          #3d5afe;
}

[data-md-color-scheme="slate"] {
  --md-primary-fg-color:         #7c8cf8;
  --md-primary-fg-color--light:  #a5b0fb;
  --md-primary-fg-color--dark:   #5c6bc0;
  --md-primary-bg-color:         #0d1117;
  --md-primary-bg-color--light:  #161b22;
  --md-accent-fg-color:          #82b1ff;
  --md-typeset-a-color:          #7c8cf8;
  --md-default-bg-color:         #0d1117;
  --md-default-bg-color--light:  #161b22;
  --md-default-bg-color--lighter:#1c2128;
  --md-default-fg-color:         #e6edf3;
  --md-default-fg-color--light:  #8b949e;
  --md-default-fg-color--lighter:#484f58;
  --md-default-fg-color--lightest:#30363d;
}


/* =============================================================================
   2. GRID & LAYOUT
   ============================================================================= */

.md-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}


/* =============================================================================
   3. HEADER
   ============================================================================= */

.md-header {
  background-color: #0d1117 !important;
  border-bottom: 1px solid #21262d;
  box-shadow: 0 1px 0 #21262d, 0 4px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: box-shadow 0.3s ease;
}

.md-header__title {
  font-weight: 800 !important;
  font-size: 1.05rem !important;
  letter-spacing: -0.01em;
  color: #e6edf3 !important;
  transition: opacity 0.2s ease;
}

.md-header__title:hover {
  opacity: 0.85;
}

.md-header__button.md-logo {
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.md-header__button.md-logo:hover {
  transform: scale(1.08);
  opacity: 0.85;
}

.md-header__button:not(.md-logo) {
  border-radius: 6px;
  color: #8b949e !important;
  transition: color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.md-header__button:not(.md-logo):hover {
  color: #e6edf3 !important;
  background: #21262d !important;
  transform: scale(1.08);
}


/* =============================================================================
   4. SEARCH
   ============================================================================= */

.md-search__form {
  background: #161b22 !important;
  border: 1px solid #30363d !important;
  border-radius: 8px !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.md-search__form:focus-within {
  border-color: #7c8cf8 !important;
  box-shadow: 0 0 0 3px rgba(124, 140, 248, 0.15) !important;
}

.md-search__input {
  color: #e6edf3 !important;
  font-size: 0.875rem !important;
  font-weight: 500;
}

.md-search__input::placeholder {
  color: #484f58 !important;
}


/* =============================================================================
   5. NAV TABS
   ============================================================================= */

.md-tabs {
  background-color: #0d1117 !important;
  border-bottom: 1px solid #21262d !important;
}

.md-tabs__item {
  position: relative;
}

.md-tabs__link {
  font-weight: 700 !important;
  font-size: 0.78rem !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: #8b949e !important;
  opacity: 1 !important;
  position: relative;
  transition: color 0.2s ease !important;
}

.md-tabs__link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: #7c8cf8;
  border-radius: 2px;
  transition: width 0.25s ease;
}

.md-tabs__link:hover::after,
.md-tabs__item--active .md-tabs__link::after {
  width: 100%;
}

.md-tabs__link:hover {
  color: #e6edf3 !important;
}

.md-tabs__item--active .md-tabs__link {
  color: #e6edf3 !important;
  font-weight: 800 !important;
}


/* =============================================================================
   6. SIDEBAR NAVIGATION (left nav — blog listing page)
   ============================================================================= */

.md-nav__title {
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
  padding-bottom: 0.4rem;
}

.md-nav__link {
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  padding: 0.3rem 0.6rem !important;
  transition: background 0.15s ease, color 0.15s ease, padding-left 0.2s ease;
}

.md-nav__link:hover {
  background: rgba(124, 140, 248, 0.08);
  padding-left: 1rem !important;
  color: var(--md-primary-fg-color) !important;
}

.md-nav__link--active {
  font-weight: 700 !important;
  color: var(--md-primary-fg-color) !important;
  background: rgba(124, 140, 248, 0.1);
  border-left: 3px solid var(--md-primary-fg-color);
  padding-left: 0.8rem !important;
}

/* =============================================================================
   7. POST SIDEBAR (left panel on individual post pages)
   ============================================================================= */

@media screen and (min-width: 960px) {
  .md-sidebar--primary {
    width: 16.5rem !important;
  }
}

/* Force small font on everything inside sidebar — must come AFTER section 8 */
/* Move this block to the very bottom of your file */

/* =============================================================================
   8. TYPOGRAPHY
   ============================================================================= */

.md-typeset {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--md-default-fg-color);
}

.md-typeset h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.md-typeset h2 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
  margin-top: 2.5rem;
  border-bottom: 1.5px solid var(--md-primary-fg-color);
  padding-bottom: 0.3rem;
}

.md-typeset h3 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  margin-top: 1.75rem;
}

.md-typeset h4 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.65;
  margin-top: 1.5rem;
}

.md-typeset p {
  max-width: 68ch;
  margin-bottom: 1.4rem;
  line-height: 1.75;
}

.md-typeset h1 + p {
  font-size: 1.05rem;
  line-height: 1.7;
  opacity: 0.8;
  font-weight: 400;
  max-width: 60ch;
}

.md-typeset strong {
  font-weight: 700;
  color: var(--md-default-fg-color);
}


/* =============================================================================
   9. POST EXCERPT CARDS (blog listing)
   ============================================================================= */

.md-post {
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 10px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.md-post:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border-color: var(--md-primary-fg-color);
  transform: translateY(-2px);
}

.md-post h2 a:hover,
.md-post h2 a:focus {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.md-post .md-post__action a {
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.03em;
  transition: letter-spacing 0.2s ease, opacity 0.2s ease;
}

.md-post .md-post__action a:hover {
  letter-spacing: 0.06em;
  opacity: 0.85;
}


/* =============================================================================
   10. TAGS
   ============================================================================= */

.md-tag {
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.md-tag:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}


/* =============================================================================
   11. CODE BLOCKS
   ============================================================================= */

.md-typeset pre {
  border-radius: 10px;
  border-left: 4px solid var(--md-primary-fg-color);
}

.md-typeset code {
  font-size: 0.875em;
  border-radius: 4px;
  padding: 0.1em 0.35em;
}


/* =============================================================================
   12. ADMONITIONS
   ============================================================================= */

.md-typeset .admonition {
  border-radius: 8px;
  border-left-width: 4px;
  font-size: 0.95rem;
}


/* =============================================================================
   13. LAST UPDATED
   ============================================================================= */

.md-source-file__fact::before {
  content: "Last Updated: ";
  font-weight: 600;
}

.md-source-file__fact svg {
  display: none !important;
}

.md-source-file__fact::after {
  content: " PKT";
  font-weight: 600;
  color: var(--md-default-fg-color);
}


/* =============================================================================
   14. FOOTER
   ============================================================================= */

.md-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--md-default-fg-color--lightest);
}

.md-social__link {
  border-radius: 6px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.md-social__link:hover {
  transform: translateY(-3px) scale(1.1);
  opacity: 1 !important;
}


/* =============================================================================
   15. RESPONSIVE
   ============================================================================= */

@media screen and (max-width: 767px) {
  .md-grid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .md-typeset h1 { font-size: 1.6rem; }
  .md-typeset h2 { font-size: 1.2rem; }
  .md-typeset h3 { font-size: 1.05rem; }
  .md-typeset p  { max-width: 100%; }

  .md-post { padding: 1rem; }

  .md-tabs__link {
    font-size: 0.72rem !important;
    letter-spacing: 0.04em !important;
  }
}

@media screen and (max-width: 479px) {
  .md-grid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* FIX 1 — "← Back to index" force single line */
.md-post__nav-link,
.md-post__nav-link *,
.md-post__nav-link span {
  white-space: nowrap !important;
  font-size: 0.65rem !important;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  overflow: hidden;
  display: block;
  text-overflow: ellipsis;
}

/* FIX 2 — Author description — max 2 lines */
.md-post__authors .md-author small,
.md-post__authors .md-author span:last-of-type {
  font-size: 0.68rem !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

/* FIX 3 — Date, Category, Read time — max 2 lines each */
.md-post__meta li,
.md-post__meta .md-post__meta-item {
  font-size: 0.68rem !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
  word-break: break-word;
}

/* =============================================================================
   16. POST SIDEBAR OVERRIDES — must be last to win specificity
   ============================================================================= */

/* Shrink all text in sidebar */
.md-sidebar--primary .md-sidebar__scrollwrap * {
  font-size: 0.72rem !important;
  line-height: 1.5 !important;
}

/* Back to index — force single row, no wrapping */
.md-post__nav-link {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.3rem !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  font-size: 0.65rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.05em !important;
  text-transform: uppercase !important;
}

.md-post__nav-link span,
.md-post__nav-link svg {
  white-space: nowrap !important;
  flex-shrink: 0;
}

/* Author name — single line with ellipsis */
.md-post__authors .md-author a {
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: block !important;
  max-width: 12rem !important;
}

/* Author description — single line with ellipsis */
.md-post__authors .md-author small {
  font-size: 0.68rem !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: block !important;
  max-width: 12rem !important;
  opacity: 0.6;
}

/* Metadata rows — date, category, read time */
.md-post__meta .md-post__meta-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  gap: 0.3rem !important;
  font-size: 0.68rem !important;
  line-height: 1.5 !important;
  margin-bottom: 0.3rem;
}

/* The text inside each metadata row — truncate at 1 line */
.md-post__meta .md-post__meta-item span,
.md-post__meta .md-post__meta-item a,
.md-post__meta .md-post__meta-item time {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: block !important;
  max-width: 11rem !important;
  font-size: 0.68rem !important;
}

/* Metadata icons */
.md-post__meta svg {
  width: 0.75rem !important;
  height: 0.75rem !important;
  flex-shrink: 0 !important;
  margin-top: 0.15rem !important;
}
