/* =============================================================
   Brand alignment: blog.waqasrana.space → waqasrana.space
   Teal accent: #0f766e (light) / #2dd4bf (dark)
   Warm backgrounds: #fafaf9 (light) / #111111 (dark)
   Fonts: Charter (headings), DM Sans (body/UI), Fira Code (mono)
   ============================================================= */

/* ---------------------------------------------------------------
   SECTION A: CSS variable overrides
   Mirrors Chirpy's media-query + data-mode cascade (specificity 0,1,1).
   Loaded after theme CSS via metadata-hook.html → wins by source order.
   --------------------------------------------------------------- */

@media (prefers-color-scheme: light) {
  html:not([data-mode]),
  html[data-mode='light'] {
    --main-bg: #fafaf9;
    --card-bg: #fafaf9;
    --topbar-bg: rgb(250 250 249 / 70%);
    --text-color: #111111;
    --post-list-text-color: #111111;
    --link-color: #0f766e;
    --link-underline-color: rgb(15 118 110 / 30%);
    --toc-highlight: #0f766e;
    --checkbox-checked-color: #0f766e;
    --btn-share-hover-color: #0f766e;
    --sidebar-bg: #f2f5f4;
    --sidebar-border-color: #e8ecea;
    --sidebar-hover-bg: rgb(15 118 110 / 8%);
    --sidebar-muted-color: #575757;
    --sidebar-active-color: #0f766e;
    --site-title-color: #555555;
    --site-subtitle-color: #6b6b6b;
    --tag-hover: rgb(15 118 110 / 12%);
  }

  html[data-mode='dark'] {
    --main-bg: #111111;
    --card-bg: #1a1a1a;
    --topbar-bg: rgb(17 17 17 / 64%);
    --text-color: #f8f7f5;
    --post-list-text-color: #f8f7f5;
    --card-header-bg: #242424;
    --button-bg: #1a1a1a;
    --btn-border-color: #2a2a2a;
    --main-border-color: rgb(42 42 42);
    --tb-odd-bg: #1e1e1e;
    --tb-even-bg: #161616;
    --link-color: #2dd4bf;
    --link-underline-color: rgb(45 212 191 / 30%);
    --toc-highlight: #2dd4bf;
    --checkbox-checked-color: #2dd4bf;
    --btn-share-hover-color: #2dd4bf;
    --sidebar-bg: #161616;
    --sidebar-border-color: #242424;
    --sidebar-hover-bg: #1f1f1f;
    --sidebar-btn-bg: #1c1c1c;
    --sidebar-active-color: #2dd4bf;
    --sidebar-muted-color: #868686;
    --site-title-color: #888888;
    --site-subtitle-color: #868686;
    --tag-hover: rgb(45 212 191 / 12%);
    --tag-border: rgb(45 212 191 / 25%);
  }
}

@media (prefers-color-scheme: dark) {
  html:not([data-mode]),
  html[data-mode='dark'] {
    --main-bg: #111111;
    --card-bg: #1a1a1a;
    --topbar-bg: rgb(17 17 17 / 64%);
    --text-color: #f8f7f5;
    --post-list-text-color: #f8f7f5;
    --card-header-bg: #242424;
    --button-bg: #1a1a1a;
    --btn-border-color: #2a2a2a;
    --main-border-color: rgb(42 42 42);
    --tb-odd-bg: #1e1e1e;
    --tb-even-bg: #161616;
    --link-color: #2dd4bf;
    --link-underline-color: rgb(45 212 191 / 30%);
    --toc-highlight: #2dd4bf;
    --checkbox-checked-color: #2dd4bf;
    --btn-share-hover-color: #2dd4bf;
    --sidebar-bg: #161616;
    --sidebar-border-color: #242424;
    --sidebar-hover-bg: #1f1f1f;
    --sidebar-btn-bg: #1c1c1c;
    --sidebar-active-color: #2dd4bf;
    --sidebar-muted-color: #868686;
    --site-title-color: #888888;
    --site-subtitle-color: #868686;
    --tag-hover: rgb(45 212 191 / 12%);
    --tag-border: rgb(45 212 191 / 25%);
  }

  html[data-mode='light'] {
    --main-bg: #fafaf9;
    --card-bg: #fafaf9;
    --topbar-bg: rgb(250 250 249 / 70%);
    --text-color: #111111;
    --post-list-text-color: #111111;
    --link-color: #0f766e;
    --link-underline-color: rgb(15 118 110 / 30%);
    --toc-highlight: #0f766e;
    --checkbox-checked-color: #0f766e;
    --btn-share-hover-color: #0f766e;
    --sidebar-bg: #f2f5f4;
    --sidebar-border-color: #e8ecea;
    --sidebar-hover-bg: rgb(15 118 110 / 8%);
    --sidebar-muted-color: #575757;
    --sidebar-active-color: #0f766e;
    --site-title-color: #555555;
    --site-subtitle-color: #6b6b6b;
    --tag-hover: rgb(15 118 110 / 12%);
  }
}

/* ---------------------------------------------------------------
   SECTION B: Hardcoded hover color override
   Chirpy's %link-hover compiles to color:#d2603a !important globally.
   Override with teal — light mode default, dark mode via data-mode + media.
   --------------------------------------------------------------- */

#page-category a:hover,
#page-tag a:hover,
#access-lastmod a:hover,
.post-tail-wrapper .license-wrapper > a:hover,
#search-results a:hover,
footer a:hover,
#topbar #breadcrumb a:hover,
.post-meta a:not([class]):hover,
.content a:not(.img-link):hover {
  color: #0f766e !important;
  border-bottom-color: #0f766e !important;
}

@media (prefers-color-scheme: dark) {
  html:not([data-mode]) #page-category a:hover,
  html:not([data-mode]) #page-tag a:hover,
  html:not([data-mode]) #access-lastmod a:hover,
  html:not([data-mode]) .post-tail-wrapper .license-wrapper > a:hover,
  html:not([data-mode]) #search-results a:hover,
  html:not([data-mode]) footer a:hover,
  html:not([data-mode]) #topbar #breadcrumb a:hover,
  html:not([data-mode]) .post-meta a:not([class]):hover,
  html:not([data-mode]) .content a:not(.img-link):hover {
    color: #2dd4bf !important;
    border-bottom-color: #2dd4bf !important;
  }
}

html[data-mode='dark'] #page-category a:hover,
html[data-mode='dark'] #page-tag a:hover,
html[data-mode='dark'] #access-lastmod a:hover,
html[data-mode='dark'] .post-tail-wrapper .license-wrapper > a:hover,
html[data-mode='dark'] #search-results a:hover,
html[data-mode='dark'] footer a:hover,
html[data-mode='dark'] #topbar #breadcrumb a:hover,
html[data-mode='dark'] .post-meta a:not([class]):hover,
html[data-mode='dark'] .content a:not(.img-link):hover {
  color: #2dd4bf !important;
  border-bottom-color: #2dd4bf !important;
}

/* ---------------------------------------------------------------
   SECTION C: Font-family overrides
   Chirpy hardcodes font names in SCSS vars (not CSS custom properties).
   Charter is a system font on macOS/iOS — no web font load needed.
   --------------------------------------------------------------- */

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
}

header .post-desc,
#toc-bar .label,
#search-results a,
h1, h2, h3, h4, h5 {
  font-family: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif;
  font-weight: 400;
}

/* Post reading text in Charter (the font from the mdreview view).
   Scoped to article body only; site chrome (sidebar, nav, lists) stays DM Sans.
   Code keeps Fira Code via its own rule below. */
.content p,
.content li,
.content blockquote {
  font-family: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif;
}

/* Mermaid diagrams (rendered by metadata-hook.html) */
.content .mermaid {
  text-align: center;
  margin: 1.25rem 0;
}
.content .mermaid svg {
  max-width: 100%;
  height: auto;
}

code,
pre,
.highlight pre,
.rouge-code pre {
  font-family: 'Fira Code', Menlo, 'Courier New', monospace;
}

kbd,
.tag span,
.archive-list-header,
#panel-wrapper .panel-heading,
.toc-popup .panel-heading {
  font-family: 'DM Sans', system-ui, sans-serif;
}

/* ---------------------------------------------------------------
   SECTION D: Text selection highlight
   --------------------------------------------------------------- */

::selection {
  background-color: rgb(15 118 110 / 25%);
  color: inherit;
}

/* ---------------------------------------------------------------
   SECTION E: Sidebar bottom — keep all 6 icons on one row
   The default 0.8rem gap + dot separator overflows the 260px
   sidebar with 5 contact icons + mode toggle. Fix: hide the dot
   and tighten the gap so everything fits on a single row.
   --------------------------------------------------------------- */

#sidebar .sidebar-bottom .icon-border {
  display: none;
}

#sidebar .sidebar-bottom a:not(:last-child) {
  margin-right: 0.5rem;
}

#sidebar .sidebar-bottom #mode-toggle {
  margin-right: 0.5rem;
}

/* ---------------------------------------------------------------
   SECTION F: Reading mode (clean, distraction-free post pages)
   `reading-mode` class is added to <html> on /posts/ pages by
   _includes/metadata-hook.html. Hides the left sidebar (avatar, nav,
   socials) and the right panel (search, recently updated, TOC), and
   centers the article to a comfortable measure. The topbar breadcrumb
   stays as back navigation. Mobile (<850px) is untouched: the sidebar
   is already off-canvas there and the hamburger nav still works.
   --------------------------------------------------------------- */

html.reading-mode #panel-wrapper,
html.reading-mode #search,
html.reading-mode #search-trigger { display: none !important; }

/* Breadcrumb becomes a simple back arrow to Home (the title below is the H1,
   so the breadcrumb title is redundant). Drop the title span + separator,
   prefix Home with a left arrow. */
html.reading-mode #breadcrumb span:last-child { display: none !important; }
html.reading-mode #breadcrumb span:not(:last-child)::after { content: "" !important; padding: 0 !important; }
html.reading-mode #breadcrumb a[href="/"] { font-size: 0; }                       /* hide the "Home" text */
html.reading-mode #breadcrumb a[href="/"]::before { content: "\2190"; font-size: 1.5rem; }  /* keep just the arrow */

@media (min-width: 850px) {
  html.reading-mode #sidebar { display: none !important; }
  html.reading-mode #main-wrapper { margin-left: 0 !important; }
}

html.reading-mode #main-wrapper > .container { max-width: 60rem !important; }

/* Chirpy caps the content column at 96% and adds wide-screen padding;
   force it to full width so the reading measure actually widens. */
html.reading-mode #main-wrapper > .container .col-lg-11 {
  flex: 0 0 100% !important;
  max-width: 100% !important;
}

/* Larger, Medium-like reading size (matches the mdreview review view: ~20px / 1.7) */
html.reading-mode .content {
  font-size: 1.25rem !important;
  line-height: 1.7 !important;
}

/* Reading mode: drop the post-tail clutter (category/tag chips, license + share
   row, "Further Reading", older/newer navigation). Giscus comments are also in
   #tail-wrapper, so hide the specific sections rather than the whole container. */
html.reading-mode .post-tail-wrapper,
html.reading-mode #related-posts,
html.reading-mode .post-navigation { display: none !important; }
