/* ---- Serenity x DocFX theme bridge ---- */

/* ---------- Base and Variables ---------- */
:root {
    /* Transitions */
  --transition-speed: 250ms;
  --transition: all var(--transition-speed) ease;

  /* Light Mode Palette */
  --background: #f8fafc;
  --background-alt: #f1f5f9;
  --surface: #ffffff;
  --surface-subtle: #f1f3f8;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-color: 0 123 196;

  --accent: rgb(var(--accent-color) / 0.5);
  --accent-hover: rgb(var(--accent-color) / 0.8);
  --accent-soft: rgb(var(--accent-color) / 0.1);

  --radius: 12px;
  --radius-button: 10px;

  --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

  /* Legacy mapping (to avoid breaking components immediately) */
  --color-white: var(--surface);
  --color-black: var(--text-primary);
  --color-primary: var(--accent);
  --color-primary-detail: var(--accent);
  --color-secondary: var(--text-secondary);
  --color-secondary-detail: var(--text-primary);
  --border-radius-small: 6px;
  --border-radius-medium: var(--radius);
  --border-radius-large: 16px;
  --link-color: var(--accent);

  overflow: auto;
}

[data-theme='dark'] {
  --background: #030712;
  --background-alt: #050914;
  --surface: #111827;
  --surface-subtle: #1f2937;
  --border: #000000;
  --border-hover: #374151;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;


  --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);

  --color-white: var(--surface);
  --color-black: var(--text-primary);
}

/* --- Base Styles --- */

body {
  background:
    radial-gradient(circle at 20% 10%,
      var(--accent-soft),
      transparent 40%),
    var(--background);
  color: var(--text-primary);
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  opacity: 0.8;
}

p {
  line-height: 1.6;
  color: var(--text-secondary);
}

h1,
h2,
h3,
h4 {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-top: 0;
}

h1 {
  font-size: clamp(1.75rem, 2.4vw, 2.85rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

h2 {
  font-weight: 700;
  color: var(--text-primary);
  padding-left: 1.25rem;
  letter-spacing: -0.01em;
  font-size: 2.5rem;
}

/* ---------- DocFX Navbar ---------- */

#sidetoc {
  position: absolute;
  left: 0;
}
nav.navbar {
  background: transparent;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text-primary) !important;
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-left: 0;
  border-right: 0;
  box-shadow: var(--shadow-soft);
  padding: 1rem 0;
}

.navbar .navbar-brand,
.navbar .navbar-text,
.navbar .navbar-nav > li > a,
.navbar .navbar-link {
  color: var(--text-primary) !important;
  font-size: 1.05rem;
  font-weight: 700;
}

.navbar .navbar-nav > li > a:hover,
.navbar .navbar-brand:hover {
  color: var(--accent) !important;
  opacity: 1;
  text-decoration: none;
}

.navbar-toggle {
  border-color: var(--border) !important;
}

.navbar-toggle .icon-bar {
  background-color: var(--text-primary) !important;
}

.subnav.navbar {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(226, 232, 240, 0.7);
  box-shadow: var(--shadow-soft);
}

/* ---------- Main Content ---------- */
.article {
  border-radius: var(--radius);
  padding: 32px;
  flex: 1;
  text-align: left;
  box-shadow: var(--shadow-premium);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-top: 2rem;
  color: var(--text-primary);
}

.article p,
.article li {
  color: var(--text-secondary);
}

.article.grid-right {
  margin: 0;
  margin-top: 13rem;
  margin-bottom: 7rem;
}

/* ---------- Sidebars ---------- */
.sidefilter {
  position: fixed;
  top: 10rem;
  width: 260px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 15px;
  border: 1px solid var(--border);
  z-index: 1;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-soft);
}

.sidetoc {
  position: fixed;
  width: 260px;
  top: 15.2rem;
  bottom: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  z-index: 1;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-soft);
  margin-top: 3rem;
}

.sidefilter,
.sidenav {
  background: rgba(255, 255, 255, 0.82);
  border-right: 1px solid var(--border);
  margin-top: 3rem;
}

.toc {
  background: rgba(255, 255, 255, 0.82);
  border-left: 1px solid var(--border);
}

.toc .nav > li > a,
.sidetoc .nav > li > a,
.sidefilter a {
  color: var(--text-secondary);
  transition: var(--transition);
}

.toc .nav > li > a:hover,
.sidetoc .nav > li > a:hover,
.sidefilter a:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
}

.toc .active > a,
.sidetoc .active > a {
  color: var(--accent) !important;
  font-weight: 600;
}

/* ---------- Code / Tables ---------- */
pre,
code,
kbd,
samp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
  background: #0f172a;
  color: #e5e7eb;
  border-radius: var(--radius);
  padding: 14px;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

code {
  color: var(--accent-hover);
  background: var(--surface-subtle);
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

th,
td {
  border: 1px solid var(--border);
  padding: 10px 12px;
}

th {
  background: var(--surface-subtle);
  color: var(--text-primary);
  font-weight: 600;
}

td {
  color: var(--text-secondary);
}

.float-right {
  float: right;
}

/* ---------- Container / Branding ---------- */
.container {
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-right: 15px;
  padding-left: 15px;
  box-sizing: border-box;
}

.logo,
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo:hover,
.navbar-brand:hover {
  color: var(--accent);
}

.logo-img {
  width: 100px;
  height: auto;
}

.logo-text {
  font-weight: 100;
  font-size: 3rem;
  text-transform: uppercase;
  color: var(--text-primary);
}

/* ---------- Navigation ---------- */
.navbar .navbar-nav {
  display: none;
}

.navigation,
.navbar-nav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.navigation a,
.navbar-nav > li > a {
  color: var(--text-primary) !important;
  text-decoration: none;
  transition: var(--transition);
}

.navigation a:hover,
.navbar-nav > li > a:hover {
  color: var(--accent) !important;
  opacity: 1;
}

/* ---------- Buttons / CTA ---------- */
.cta .button,
.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 12px 28px;
  border-radius: var(--radius-button);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
  transition: var(--transition);
  border: none;
  cursor: pointer;
}

.cta .button:hover,
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25);
  filter: brightness(1.05);
  color: #fff;
}

.cta-inverse .button,
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  padding: 12px 28px;
  border-radius: var(--radius-button);
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.cta-inverse .button:hover,
.btn-secondary:hover {
  background: var(--surface-subtle);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ---------- Language Dropdown ---------- */
.lang {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown {
  position: relative;
}

.dropdown-toggle {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-button);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  box-shadow: var(--shadow-soft);
  transition: var(--transition);
}

.dropdown-toggle:hover {
  background: var(--surface-subtle);
  border-color: var(--border-hover);
}

.dropdown-toggle img {
  width: 20px;
  max-height: 20px;
  object-fit: contain;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  padding: 0.5rem 0;
  margin: 0;
  box-shadow: var(--shadow-premium);
  display: none;
  z-index: 1000;
  min-width: 180px;
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-menu li {
  padding: 0;
  display: flex;
  align-items: center;
}

.dropdown-menu li:hover {
  background: var(--surface-subtle);
}

.dropdown-menu li a {
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
}

.dropdown-menu li a:hover {
  color: var(--accent);
}

.dropdown-menu li a img {
  width: 20px;
  max-height: 20px;
  object-fit: contain;
}

/* ---------- Footer ---------- */
footer,
#footer {
  padding: 20px 0;
  text-align: center;
  width: 100%;
  background: var(--surface);
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.04);
  position: fixed;
}

/* ---------- Form / Bootstrap Overrides ---------- */
.form-control {
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.breadcrumb {
  background: transparent;
}

.breadcrumb > li,
.breadcrumb > li a {
  color: var(--text-secondary);
}

.breadcrumb > li::marker,
.navbar .breadcrumb > li::marker {
  content: none;
}

.affix {
  background: var(--surface);
  color: var(--text-primary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 2rem;
  box-shadow: var(--shadow-soft);
}

.hljs {
  color: #e5e7eb;
  background: transparent;
}

.logo-text-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  float: right;
}

.logo-image {
  transition: transform 0.3s ease;
  margin-top: -1.5rem;
  width: 3rem;
}

.logo-container {
  width: fit-content;
}

/* ---------- Responsive & Anchor Scroll Fixes ---------- */

/* Ensure headings clear sticky headers when navigated via anchor */
h1[id], h2[id], h3[id], h4[id] {
  scroll-margin-top: 120px;
}

/* Prevent code blocks and tables from breaking layout */
.article pre {
  overflow-x: auto;
  max-width: 100%;
  word-wrap: normal;
}

.article .table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.article .codewrapper {
  overflow-x: auto;
  max-width: 100%;
}

/* Prevent long links / xrefs from overflowing */
.article a,
.article .xref {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ---------- Tablet (<=1024px) ---------- */
@media (max-width: 1024px) {
  .container {
    max-width: 100%;
    padding-left: 20px;
    padding-right: 20px;
  }

  .article.grid-right {
    margin-left: 260px;
    margin-top: 10rem;
  }

  .sidefilter {
    width: 230px;
  }

  .sidetoc {
    width: 230px;
  }
}

/* ---------- Small tablet / large phone (<=768px) ---------- */
@media (max-width: 768px) {
  .container {
    padding-left: 15px;
    padding-right: 15px;
  }

  .article {
    padding: 20px;
    margin-top: 1rem;
  }

  .article.grid-right {
    margin-left: 0;
    margin-top: 2rem;
    margin-bottom: 4rem;
  }

  .sidefilter,
  .sidetoc {
    position: static;
    width: 100%;
    border-radius: var(--radius);
    margin-top: 1rem;
  }

  .sideaffix {
    position: static;
    margin-top: 1rem;
  }

  .affix {
    position: static;
  }

  h1 {
    font-size: 1.6rem;
  }

  h2 {
    font-size: 1.35rem;
    padding-left: 0;
  }

  .logo-text {
    font-size: 2rem;
  }

  .logo-image {
    width: 2rem;
    margin-top: -0.75rem;
  }

  nav.navbar {
    padding: 0.5rem 0;
  }

  footer,
  #footer {
    position: static;
    padding: 15px 0;
  }
}

/* ---------- Phone (<=480px) ---------- */
@media (max-width: 480px) {
  .container {
    padding-left: 10px;
    padding-right: 10px;
  }

  .article {
    padding: 14px;
    border-radius: 8px;
  }

  .article pre {
    font-size: 0.8rem;
    padding: 10px;
  }

  table {
    font-size: 0.85rem;
  }

  th,
  td {
    padding: 6px 8px;
  }

  h1 {
    font-size: 1.35rem;
  }

  h2 {
    font-size: 1.15rem;
  }

  .logo-text {
    font-size: 1.5rem;
  }

  .logo-text-subtitle {
    font-size: 0.75rem;
  }
}
