/* ==========================================================================
   IMPORTS
   ========================================================================== */

/* Components & Specific Features */
@import url("components/_images-figures.css");
@import url("components/_search-modal.css");

/* Page-Specific Styles */
@import url("pages/_home.css");
@import url("pages/_contact.css");
@import url("pages/_further_reading.css");
@import url("pages/_guides.css");

/* Utility Classes */
@import url("utilities/_helpers.css");

/* ==========================================================================
   1. GLOBAL VARIABLES & BASE STYLES
   ========================================================================== */

:root {
  /* Colors */
  --primary: #14b8a6;
  --primary-dark: #0d9488;
  --primary-color: #007aff; /* Legacy */
  --primary-color-rgb: 0, 122, 255; /* Legacy */
  --secondary: #3b82f6;
  --secondary-color: #5f6368; /* Legacy */
  --dark-blue: #2c3e50;
  --white: #ffffff;
  --bg-light: #f8fafc;
  --bg-dark: #111827;
  --bg-color: #f8f9fa; /* Legacy */
  --content-bg-color: #ffffff;
  --border-color: #e0e0e0;
  --border-light: #e5e7eb;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-color: #202124; /* Legacy */
  --text-light: #4d5156; /* Legacy */
  --text-very-light: #70757a; /* Legacy */

  /* Components */
  --info-box-blue-bg: #e3f2fd;
  --info-box-blue-border: #90caf9;
  --info-box-blue-icon: #1e88e5;

  /* Accent Colors */
  --accent-color-tip: #20c997;
  --accent-color-tip-rgb: 32, 201, 151;
  --accent-color-tip-bg: rgba(var(--accent-color-tip-rgb), 0.08);
  --accent-color-warning: #ffc107;
  --accent-color-warning-rgb: 255, 193, 7;
  --accent-color-warning-bg: rgba(var(--accent-color-warning-rgb), 0.08);

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-brand: "Manrope", var(--font-sans);
  --new-font-family: "Manrope", sans-serif; /* Legacy */

  /* Sizing & Spacing */
  --header-height-desktop: 64px;
  --header-height-mobile: 114px;
  --sidebar-width: 260px;
  --border-radius: 8px;

  /* Shadows & Transitions */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  line-height: 1.7;
  color: var(--text-color);
  background-color: var(--bg-color);
  font-size: 16px;
  padding-top: var(--header-height-desktop);
}

body.mobile-menu-open {
  overflow: hidden;
}

a {
  color: var(--new-primary-color);
  font-family: var(--new-font-family);
}

@media (max-width: 950px) {
  body {
    padding-top: var(--header-height-mobile);
    font-size: 15px;
  }
}

/* ==========================================================================
   2. BRANDING
   ========================================================================== */

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  text-decoration: none;
}

.logo-image {
  height: 60px;
  width: 60px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  object-fit: contain;
}

.app-brand-name {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 1.5rem;
}
.app-brand-name .fluent-part {
  color: #4a4f74;
}
.app-brand-name .speak-part {
  color: var(--primary);
}

.app-brand-name.on-dark .fluent-part,
.app-brand-name.on-dark .speak-part {
  color: var(--white);
}

.app-name {
  font-size: 1.3em;
  font-weight: 600;
  color: var(--text-color);
  white-space: nowrap;
}

.help-suffix {
  font-weight: 400;
  color: var(--text-light);
  margin-left: 0.5rem;
}

@media (max-width: 480px) {
  .app-name {
    font-size: 1.15em;
  }
}

/* ==========================================================================
   3. CORE TYPOGRAPHY
   ========================================================================== */

.article-content h1 {
  font-size: 2.2em;
  color: #0000008a;
  margin-bottom: 0.75em;
  font-weight: 400;
  line-height: 1.3;
}
.article-content h2 {
  font-size: 1.6em;
  color: var(--text-color);
  margin-top: 2em;
  margin-bottom: 0.8em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  line-height: 1.4;
}
.article-content h3 {
  font-size: 1.25em;
  color: var(--text-color);
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  font-weight: 600;
}
.article-content h4 {
  font-size: 1.1em;
  color: var(--text-color);
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  font-weight: 600;
}
.article-content h5 {
  font-size: 0.95em;
  font-weight: 600;
  color: var(--text-color);
  margin-top: 0;
  margin-bottom: 1em;
}
.article-content p {
  margin-bottom: 1.25em;
  font-size: 1em;
  color: var(--text-light);
}
.article-content a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.article-content a:not(.directory-article-item):hover {
  text-decoration: underline;
}

@media (max-width: 950px) {
  .article-content h1 {
    font-size: 1.9em;
  }
  .article-content h2 {
    font-size: 1.4em;
  }
  .article-content h3 {
    font-size: 1.15em;
  }
}

/* ==========================================================================
   4. MAIN LAYOUT
   ========================================================================== */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1003;
  min-height: var(--header-height-desktop);
  background-color: var(--content-bg-color);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.main-layout {
  display: flex;
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

.main-layout--full-width {
  justify-content: center;
}

.sidebar-left,
.sidebar-right {
  position: sticky;

  /* The Fix: Position sticky elements below the header PLUS the desired gap. */
  top: calc(var(--header-height-desktop) + 24px);

  /* The Fix: Correctly calculate the height to fill the remaining viewport,
     accounting for the top offset and a matching bottom gap. */
  height: calc(
    100vh - var(--header-height-desktop) - 48px
  ); /* 24px top gap + 24px bottom gap */

  overflow-y: auto;
  width: var(--sidebar-width);
  flex-shrink: 0;
}

.sidebar-left {
  background-color: var(--content-bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.sidebar-right {
  padding: 10px 0;
  font-size: 0.9em;
}

.article-content {
  flex-grow: 1;
  max-width: 900px;
  background-color: var(--content-bg-color);
  padding: 32px 40px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.article-content ul,
.article-content ol {
  padding-left: 0;
  margin-left: 1.5rem;
}

@media (max-width: 1024px) {
  .main-layout {
    justify-content: center;
  }
  .main-layout .sidebar-right {
    display: none;
  }
  .main-layout .article-content {
    max-width: 800px;
  }
}

@media (max-width: 950px) {
  .app-header {
    min-height: var(--header-height-mobile);
    padding: 8px 16px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .main-layout {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }

  .sidebar-left,
  .sidebar-right {
    top: var(--header-height-mobile);
    height: calc(100vh - var(--header-height-mobile));
  }

  .main-layout > .sidebar-left,
  .sidebar-right {
    display: none;
  }

  .article-content {
    max-width: 100%;
    padding: 24px;
  }
}

@media (max-width: 480px) {
  .main-layout {
    padding: 0;
  }
  .article-content {
    border-radius: 0px !important;
    border: none !important;
  }
}

/* ==========================================================================
   5. COMPONENTS
   ========================================================================== */

/* --- Header & Navigation --- */

.logo-container {
  display: flex;
  align-items: center;
}

.header-nav {
  margin-left: auto;
}

.header-nav ul {
  list-style: none;
  display: flex;
  padding: 0;
  margin: 0;
}

.header-nav ul li {
  margin-left: 24px;
}

.header-nav ul li a {
  text-decoration: none;
  color: var(--secondary-color);
  font-weight: 500;
  font-size: 0.95em;
  transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
  padding: 8px 0;
  border-bottom: 2px solid transparent;
  display: inline-block;
}

.header-nav ul li a:hover {
  color: var(--primary-color);
}

.header-nav ul li a.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

.search-button {
  background: none;
  border: none;
  color: var(--secondary-color);
  cursor: pointer;
  padding: 8px;
  margin-left: 16px;
  line-height: 0;
}

.search-button svg {
  width: 22px;
  height: 22px;
}

.search-button:hover {
  color: var(--primary-color);
}

.hamburger-menu {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--secondary-color);
  z-index: 1005;
  line-height: 0;
  align-self: center;
}
.hamburger-menu svg {
  display: block;
  width: 24px;
  height: 24px;
}
.hamburger-menu .icon-close {
  display: none;
}
.hamburger-menu.is-active .icon-menu {
  display: none;
}
.hamburger-menu.is-active .icon-close {
  display: block;
}

@media (max-width: 950px) {
  .logo-container {
    margin-right: auto;
    align-self: center;
  }
  .header-nav {
    margin-left: 0;
    width: 100%;
    order: 4;
    padding-top: 8px;
  }
  .header-nav ul li {
    margin: 0 8px 8px;
  }
  .app-header .search-button {
    margin-left: auto;
    order: 2;
    align-self: center;
  }
  .hamburger-menu {
    z-index: 2000;
    display: flex;
    order: 3;
  }
}

@media (max-width: 480px) {
  .logo-container img {
    height: 28px;
    width: 28px;
  }
  .header-nav ul {
    justify-content: space-between;
  }
  .header-nav ul li {
    margin: 0 2px;
  }
  .header-nav ul li a {
    font-size: 0.9em;
    padding: 8px 4px;
  }
}

/* --- Left Sidebar Content --- */

.sidebar-content-wrapper {
  padding-bottom: 20px;
}

.sidebar-left .sidebar-section-main-title {
  display: block;
  font-size: 1.1em;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-color);
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  transition: color 0.2s ease-in-out;
}
.sidebar-left .sidebar-section-main-title:hover {
  color: var(--primary-color);
}

.sidebar-left .sidebar-group-title {
  font-size: 0.85em;
  font-weight: 700;
  color: var(--secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.75px;
  margin-top: 24px;
  margin-bottom: 12px;
  padding-left: 20px;
}

.sidebar-left ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 15px;
}
.sidebar-left .sidebar-group-title + ul {
  padding-left: 12px;
  padding-right: 12px;
}
.sidebar-left ul:last-of-type {
  margin-bottom: 0;
}
.sidebar-left ul li {
  margin-bottom: 2px;
}
.sidebar-left ul li a {
  display: block;
  padding: 9px 12px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.92em;
  border-radius: 6px;
  transition: all 0.2s;
}
.sidebar-left ul li a:hover {
  background-color: rgba(var(--primary-color-rgb), 0.07);
  color: var(--primary-color);
}
.sidebar-left ul li a.current-article-link {
  background-color: rgba(var(--primary-color-rgb), 0.1);
  color: var(--primary-color);
  font-weight: 500;
}

.go-to-app-link {
  font-size: 0.9em;
  font-weight: 500;
  color: var(--secondary-color);
  text-decoration: none;
  display: block;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  transition: color 0.2s;
}

.go-to-app-link:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

/* --- Right Sidebar (Table of Contents) --- */

.sidebar-right h3 {
  font-size: 0.85em;
  color: var(--secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-left: 22px;
}
.toc-list {
  list-style: none;
  border-left: 2px solid var(--border-color);
  padding-left: 18px;
  margin-left: 2px;
  position: relative;
}
.toc-list li {
  margin-bottom: 10px;
}
.toc-list li a {
  display: block;
  color: var(--secondary-color);
  text-decoration: none;
  transition: all 0.2s;
  position: relative;
}
.toc-list li.toc-h2 a {
  padding-left: 12px;
}
.toc-list li.toc-h3 a {
  padding-left: px;
  font-size: 0.95em;
  color: var(--text-light);
}
.toc-list li a:hover {
  color: var(--primary-color);
}
.toc-list li a.active-toc {
  color: var(--primary-color);
  font-weight: 600;
}
.toc-list li a.active-toc::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 15%;
  bottom: 15%;
  width: 3px;
  background-color: var(--primary-color);
  border-radius: 1.5px;
}

/* --- Mobile Navigation Popout --- */

@media (max-width: 950px) {
  aside.sidebar-left#leftSidebarNav {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 90vw);
    height: 100dvh;
    z-index: 1100;
    background-color: var(--content-bg-color);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: var(--shadow-lg);
    border-radius: 0;
    border: none;
    padding: 0;
  }

  aside.sidebar-left#leftSidebarNav.is-open {
    transform: translateX(0);
  }

  .mobile-nav-header {
    flex-shrink: 0;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    min-height: var(--header-height-mobile);
    display: flex;
    align-items: center;
  }
  .mobile-nav-header .logo-container {
    text-decoration: none;
  }
  .mobile-nav-header .logo-image {
    height: 32px;
    width: 32px;
    margin-right: 12px;
  }

  .mobile-nav-header .hamburger-menu {
    display: flex;
    z-index: 1005;
    margin-left: auto;
    margin-right: 10px;
  }

  .mobile-nav-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px 16px;
  }

  .sidebar-content-wrapper {
    flex-grow: 1;
    overflow-y: auto;
  }

  .mobile-nav-footer {
    flex-shrink: 0;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--content-bg-color);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .mobile-nav-footer .btn {
    width: 100%;
    text-align: center;
    padding: 12px;
    font-size: 1rem;
  }

  .mobile-nav-content .sidebar-section-main-title {
    margin: 0 0 24px 0;
    padding: 0 0 16px 0;
  }
  .mobile-nav-content .sidebar-group-title {
    margin-top: 0;
    margin-bottom: 12px;
  }
  .mobile-nav-content ul li a {
    padding: 12px;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  aside.sidebar-left#leftSidebarNav {
    width: 100%;
  }

  aside.sidebar-left#leftSidebarNav.is-open {
    box-shadow: none;
  }
}

/* --- Miscellaneous Components --- */
.general-note {
  font-size: 1em;
  font-style: italic;
  color: var(--secondary-color);
  text-align: center;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 1.5em;
  margin-bottom: 1.5em;
  padding: 0.75em 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

/* --- INFO OX --- */
@media (max-width: 768px) {
  .info-box {
    flex-direction: column;
  }
}

.info-box {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin: 24px 0;
  padding: 16px 24px;
  border-left: 4px solid;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  font-size: 0.95em;
}

.info-box-title {
  flex: 0 0 25%;
  font-weight: bold;
  font-size: 1.1em;
  color: #343a40;
}

.info-box-content {
  flex-grow: 1;
}

.info-box-content p:first-child,
.info-box-content ul:first-child {
  margin-top: 0;
}

.info-box-content p:last-child,
.info-box-content ul:last-child {
  margin-bottom: 0;
}

.info-box.tip {
  background-color: var(--accent-color-tip-bg);
  border-left-color: var(--accent-color-tip);
}

.info-box.warning {
  background-color: var(--accent-color-warning-bg);
  border-left-color: var(--accent-color-warning);
}

.info-box.info {
  background-color: var(--info-box-blue-bg);
  border-left-color: var(--info-box-blue-icon);
}

.info-box p {
  color: var(--text-color);
  margin-bottom: 0.5em;
  line-height: 1.6;
}

.info-box p:last-child {
  margin-bottom: 0;
}

.info-box strong {
  font-weight: 600;
}

/* ==========================================================================
   6. UTILITY CLASSES
   ========================================================================== */

.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

@media (max-width: 950px) {
  .mobile-only {
    display: flex;
  }
  .desktop-only {
    display: none;
  }
}
