/* Subtle dark palette overrides for readability */
html[data-theme="dark"] html,
html[data-theme="dark"] body {
  background: #0f1115;
  color: #e6e8eb;
}

html[data-theme="dark"] body a {
  color: #8ab4f8;
}

html[data-theme="dark"] body a:hover {
  color: #a3c4ff;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] .page__title,
html[data-theme="dark"] .archive__item-title,
html[data-theme="dark"] .site-title {
  color: #f2f4f7;
}

html[data-theme="dark"] .masthead {
  background: #111418;
  border-bottom: 1px solid #2a2f36;
}

html[data-theme="dark"] .masthead__menu-item a {
  color: #e6e8eb;
}

html[data-theme="dark"] .masthead__menu-item a:hover {
  color: #ffffff;
}

html[data-theme="dark"] .page,
html[data-theme="dark"] .page__content {
  background: transparent;
  color: #e6e8eb;
}

html[data-theme="dark"] hr {
  border-color: #2a2f36;
}

html[data-theme="dark"] code,
html[data-theme="dark"] pre {
  background: #161a20;
  color: #e8eaed;
  border: 1px solid #2a2f36;
}

html[data-theme="dark"] blockquote {
  border-left-color: #2a2f36;
  color: #c8cdd3;
}

html[data-theme="dark"] table,
html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-color: #2a2f36;
}

html[data-theme="dark"] .archive__item,
html[data-theme="dark"] .feature__item,
html[data-theme="dark"] .feature__item--center,
html[data-theme="dark"] .page__content .archive__item {
  background: #12161c;
  border: 1px solid #2a2f36;
  border-radius: 8px;
  padding: 1rem;
}

html[data-theme="dark"] .archive__item-title a {
  color: #f2f4f7;
}

html[data-theme="dark"] .theme-toggle {
  margin-left: 0.75rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #2a2f36;
  background: #12161c;
  color: #e6e8eb;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

html[data-theme="dark"] .theme-toggle:focus {
  outline: 2px solid #8ab4f8;
  outline-offset: 2px;
}

html[data-theme="dark"] .theme-toggle:hover {
  background: #1a1f27;
}

/* --- Dark mode: masthead/nav readability fix --- */
html[data-theme="dark"] .masthead,
html[data-theme="dark"] .masthead__inner-wrap {
  background: #0f1216 !important;
  border-bottom: 1px solid rgba(255,255,255,0.10) !important;
}

html[data-theme="dark"] .greedy-nav,
html[data-theme="dark"] .masthead__menu {
  background: transparent !important;
}

html[data-theme="dark"] .site-title,
html[data-theme="dark"] .site-title:visited {
  color: #f2f5f8 !important;
}

html[data-theme="dark"] .greedy-nav a,
html[data-theme="dark"] .masthead__menu-item a {
  color: #e7edf3 !important;
  opacity: 1 !important;
}

html[data-theme="dark"] .greedy-nav a:hover,
html[data-theme="dark"] .greedy-nav a:focus,
html[data-theme="dark"] .masthead__menu-item a:hover,
html[data-theme="dark"] .masthead__menu-item a:focus {
  color: #ffffff !important;
  background: rgba(255,255,255,0.08) !important;
  border-radius: 8px;
  outline: none;
}

html[data-theme="dark"] .greedy-nav .active > a,
html[data-theme="dark"] .masthead__menu-item.active > a {
  color: #ffffff !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

html[data-theme="dark"] .greedy-nav__toggle,
html[data-theme="dark"] .greedy-nav__toggle .navicon,
html[data-theme="dark"] .greedy-nav__toggle .navicon:before,
html[data-theme="dark"] .greedy-nav__toggle .navicon:after {
  background: #e7edf3 !important;
}

html[data-theme="dark"] .masthead * {
  text-shadow: none !important;
}

/* --- Dark mode (attribute-based) --- */
html[data-theme="dark"] body {
  background: #0b0f14 !important;
  color: #e7edf3 !important;
}

html[data-theme="dark"] .masthead,
html[data-theme="dark"] .masthead__inner-wrap {
  background: #0f1216 !important;
  border-bottom: 1px solid rgba(255,255,255,0.12) !important;
}

/* Ensure nav container isn't forcing light bg */
html[data-theme="dark"] .greedy-nav,
html[data-theme="dark"] .masthead__menu {
  background: transparent !important;
}

html[data-theme="dark"] .site-title,
html[data-theme="dark"] .site-title:visited {
  color: #ffffff !important;
}

/* NAV LINKS: FORCE FULL OPACITY + HIGH CONTRAST */
html[data-theme="dark"] .greedy-nav a,
html[data-theme="dark"] .masthead__menu-item a {
  color: #ffffff !important;
  opacity: 1 !important;
  font-weight: 600 !important;
}

/* Hover/focus */
html[data-theme="dark"] .greedy-nav a:hover,
html[data-theme="dark"] .greedy-nav a:focus,
html[data-theme="dark"] .masthead__menu-item a:hover,
html[data-theme="dark"] .masthead__menu-item a:focus {
  color: #ffffff !important;
  background: rgba(255,255,255,0.12) !important;
  border-radius: 10px;
  outline: none !important;
}

/* Active link */
html[data-theme="dark"] .greedy-nav .active > a,
html[data-theme="dark"] .masthead__menu-item.active > a {
  color: #ffffff !important;
  text-decoration: underline;
  text-underline-offset: 6px;
}

/* --- Fix author sidebar overflow / clipping --- */
.author__avatar,
.author__content,
.author__urls {
  max-width: 100%;
}

.author__name,
.author__bio,
.author__content,
.author__urls,
.author__urls-wrapper,
.author__urls li,
.author__urls a {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Avoid any horizontal scroll in the sidebar */
.sidebar,
.sidebar__right,
.author__profile,
.author__inner-wrap {
  overflow-x: hidden !important;
}

/* Slightly tighter typography so long titles fit nicely */
.author__name {
  font-size: 1.35rem;
  line-height: 1.25;
}

.author__bio {
  font-size: 0.95rem;
  line-height: 1.45;
}

/* Ensure link labels don’t get cut */
.author__urls a {
  display: inline-block;
  max-width: 100%;
}

html[data-theme="dark"] .case-study-grid .feature__item {
  background: #0f1216;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 26px rgba(0,0,0,0.55);
}

html[data-theme="dark"] .case-study-grid .feature__item:hover {
  box-shadow: 0 16px 34px rgba(0,0,0,0.70);
  border-color: rgba(255,255,255,0.18);
}

html[data-theme="dark"] .case-study-grid .feature__item .archive__item-title a,
html[data-theme="dark"] .case-study-grid .feature__item .archive__item-title {
  color: #ffffff !important;
}

html[data-theme="dark"] .case-study-grid .feature__item .archive__item-excerpt {
  color: rgba(255,255,255,0.75) !important;
}
