/* ═══════════════════════════════════════════════════════════════════════════
   IOMKDocs — IOValence Design System
   Style target: Apple Developer Documentation
   ═══════════════════════════════════════════════════════════════════════════ */


/* ───────────────────────────────────────────────────────────────────────────
   Design Tokens — IOValence brand colors + slate palette
   ─────────────────────────────────────────────────────────────────────────── */

:root,
[data-md-color-scheme="default"] {
  /* Material primary/accent — controls header & interactive elements */
  --md-primary-fg-color:              #ffffff;
  --md-primary-bg-color:              #233D4D;
  --md-header-height:                 2.9rem;   /* slightly shorter than IOValence h-16 */
  --md-accent-fg-color:               #FE6C0B;
  --md-accent-fg-color--transparent:  rgba(254, 108, 11, 0.1);
  --md-typeset-a-color:               #FE6C0B;

  /* Override default text to use slate palette */
  --md-default-bg-color:              #ffffff;
  --md-default-fg-color:              #0f172a;
  --md-default-fg-color--light:       rgba(15, 23, 42, 0.54);
  --md-default-fg-color--lighter:     rgba(15, 23, 42, 0.32);
  --md-default-fg-color--lightest:    rgba(15, 23, 42, 0.12);

  /* IOValence custom tokens */
  --iov-nav-hover-bg:   #f8fafc;
  --iov-nav-active-bg:  rgba(254, 108, 11, 0.08);
  --iov-sidebar-bg:     #ffffff;
  --iov-border:         #e2e8f0;
}

[data-md-color-scheme="slate"] {
  --md-primary-fg-color:              #ffffff;
  --md-primary-bg-color:              #233D4D;
  --md-accent-fg-color:               #FE6C0B;
  --md-accent-fg-color--transparent:  rgba(254, 108, 11, 0.1);
  --md-typeset-a-color:               #FE6C0B;

  --iov-nav-hover-bg:   #1e2a35;
  --iov-nav-active-bg:  rgba(254, 108, 11, 0.12);
  --iov-sidebar-bg:     #161d25;
  --iov-border:         #334155;
}


/* ───────────────────────────────────────────────────────────────────────────
   Header
   ─────────────────────────────────────────────────────────────────────────── */

.md-header {
  background-color: #233D4D !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07);
  z-index: 50 !important;
  min-height: var(--md-header-height) !important;
}

/* Header inner: remove .md-grid centering so logo sits at the true left edge.
   Also set height explicitly — Material's header height is driven by the inner
   nav, not the outer <header>, so the scrollwrap padding-top will match. */
.md-header__inner {
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  height: var(--md-header-height) !important;
}

/* Logo: bigger, flush left */
.md-header__button.md-logo {
  padding: 0.3rem 0.75rem !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
}

.md-header__button.md-logo img,
.md-header__button.md-logo svg {
  height: 1.8rem !important;
  width: auto !important;      /* horizontal logo — let width scale naturally */
}

/* Hide the site title text — logo alone identifies the site */
.md-header__title {
  display: none !important;
}

.md-header__button {
  color: rgba(255, 255, 255, 0.8);
}

.md-header__button:hover {
  color: #ffffff;
  opacity: 1;
}

/* Search bar */
.md-search__form {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  transition: background-color 0.15s ease;
}

.md-search__form:hover,
[data-md-toggle="search"]:checked ~ .md-header .md-search__form {
  background-color: rgba(255, 255, 255, 0.17);
}

.md-search__input {
  color: #ffffff;
}

.md-search__input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.md-search__icon {
  color: rgba(255, 255, 255, 0.6);
}


/* ───────────────────────────────────────────────────────────────────────────
   Sidebar drawer
   ─────────────────────────────────────────────────────────────────────────── */

/* Drawer background */
.md-sidebar--primary {
  background-color: var(--iov-sidebar-bg) !important;
  border-right: 1px solid var(--iov-border);
}

/* Drawer header row (logo + site title — Material's built-in) */
.md-nav--primary > .md-nav__title {
  background-color: #233D4D !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

.md-nav--primary > .md-nav__title .md-nav__button {
  color: rgba(255, 255, 255, 0.75);
}

/* Nav typography */
.md-nav {
  font-size: 0.85rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

/* Top-level section headers (navigation.sections) */
.md-nav--primary .md-nav__item--section > .md-nav__link {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-default-fg-color--lighter);
  padding-top: 1rem;
  padding-bottom: 0.3rem;
  pointer-events: none;
  cursor: default;
}

/* All nav links */
.md-nav__link {
  color: var(--md-default-fg-color--light);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  margin: 1px 0.4rem;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.md-nav__link:hover,
.md-nav__link:focus {
  background-color: var(--iov-nav-hover-bg);
  color: var(--md-default-fg-color);
  text-decoration: none;
}

/* Active / current page */
.md-nav__link--active,
.md-nav__link--active:hover {
  background-color: var(--iov-nav-active-bg) !important;
  color: #FE6C0B !important;
  font-weight: 600;
}

/* Collapse toggle arrow */
.md-nav__item--nested .md-nav__link .md-nav__icon {
  color: var(--md-default-fg-color--lighter);
}


/* ───────────────────────────────────────────────────────────────────────────
   Content + typography
   ─────────────────────────────────────────────────────────────────────────── */

.md-typeset {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
}

.md-typeset h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--md-default-fg-color);
}

.md-typeset h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--md-default-fg-color);
}

.md-typeset h3 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--md-default-fg-color);
}

.md-typeset h4 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--md-default-fg-color);
}

.md-typeset a {
  color: #FE6C0B;
  text-decoration: none;
}

.md-typeset a:hover {
  color: #E55F0A;
  text-decoration: underline;
}

/* Inline code */
.md-typeset code {
  border-radius: 4px;
  font-size: 0.875em;
}

/* Content max-width — prevents text stretching too wide on large screens */
.md-content__inner {
  max-width: 860px;
}

/* Cards grid */
.md-typeset .grid.cards > ol > li,
.md-typeset .grid.cards > ul > li {
  border: 1px solid var(--iov-border);
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.md-typeset .grid.cards > ol > li:hover,
.md-typeset .grid.cards > ul > li:hover {
  border-color: #FE6C0B;
  box-shadow: 0 2px 12px rgba(254, 108, 11, 0.1);
}

/* Force 2-column grid on wider screens (more like Apple's topic layout) */
@media screen and (min-width: 45em) {
  .md-typeset .grid.cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Landing page: subtitle paragraph (the line right after h1) */
.md-typeset h1 + p {
  color: var(--md-default-fg-color--light);
  font-size: 1.05rem;
  margin-top: -0.25rem;
  margin-bottom: 1.5rem;
}

/* Card arrow links */
.md-typeset .grid.cards a {
  font-size: 0.875rem;
  font-weight: 500;
}

/* "Topics" heading above cards — de-emphasize */
.md-typeset h2:has(+ .grid) {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-default-fg-color--lighter);
  border-bottom: none;
  margin-bottom: 0.75rem;
}


/* ───────────────────────────────────────────────────────────────────────────
   Desktop sidebar — IOValence-style icon strip (≥ 60em)
   Mirrors DashboardLayout.tsx: fixed sidebar always 64 px visible,
   content margin-left grows with the sidebar so content is never covered.
   Toggle (hamburger) lives inside the sidebar panel, not the header.
   ─────────────────────────────────────────────────────────────────────────── */

@media screen and (min-width: 60em) {

  /* Hide header hamburger — toggle is inside the sidebar */
  label.md-header__button[for="__drawer"] {
    display: none !important;
  }

  /* No backdrop overlay */
  .md-overlay {
    display: none !important;
  }

  /* ── Sidebar ─────────────────────────────────────────────────────────────
     Fixed, always 64 px. overflow: hidden clips the full-width scrollwrap.
     Mirrors: aside.fixed.top-16.left-0.bottom-0 in DashboardLayout.tsx   */
  .md-sidebar--primary {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    width: 3rem !important;
    overflow: hidden !important;
    transform: none !important;
    transition: width 0.3s ease-in-out,
                box-shadow 0.3s ease-in-out !important;
    z-index: 40 !important;
    box-shadow: none !important;
    background-color: var(--iov-sidebar-bg) !important;
    border-right: 1px solid var(--iov-border) !important;
    padding-top: 0 !important;                    /* removes the gap between header and nav title */
  }

  /* Scrollwrap: offset by header height so nav content starts below the header.
     box-sizing: border-box keeps height: 100% from overflowing.             */
  .md-sidebar--primary .md-sidebar__scrollwrap {
    height: 100% !important;
    box-sizing: border-box !important;
    padding-top: var(--md-header-height, 2.4rem) !important;
    max-height: none !important;
    overflow-y: auto !important;
    width: var(--md-sidebar-width, 12.1rem) !important;
  }

  /* Zero out every layer between scrollwrap and nav title — any padding here
     creates a visible gap between the header bottom and the hamburger.    */
  .md-sidebar--primary .md-sidebar__inner {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  .md-sidebar--primary .md-nav--primary {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }

  /* ── Nav title = toggle button ───────────────────────────────────────────
     Override the base dark-header colour so it matches the sidebar bg. */
  .md-nav--primary > .md-nav__title {
    background-color: var(--iov-sidebar-bg) !important;
    color: #64748b !important;
    box-shadow: none !important;
    border-bottom: 1px solid var(--iov-border) !important;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  .md-nav--primary .md-nav__title[for="__drawer"] {
    display: flex !important;
    align-items: center !important;
    gap: 0.6rem !important;
    /* padding-left centers the 1.1rem icon in the 3rem strip: (3 - 1.1) / 2 ≈ 0.95rem */
    padding: 0 0 0 0.95rem !important;
    margin: 0 !important;                         /* zero out all Material margins */
    white-space: nowrap !important;
    overflow: hidden !important;
    cursor: pointer !important;
    height: 2.5rem !important;                    /* shorter than header — compact toggle row */
    /* hide the site-name text node without affecting child elements */
    font-size: 0 !important;
  }

  /* Restore font-size for child elements (logo button, etc.) */
  .md-nav--primary .md-nav__title[for="__drawer"] > * {
    font-size: 0.85rem !important;
  }

  /* CSS hamburger (3 lines) — slate-500 */
  .md-nav--primary .md-nav__title[for="__drawer"]::before {
    content: "";
    display: inline-block;
    align-self: center;
    width: 1.1rem;
    height: 2px;
    flex-shrink: 0;
    background: #64748b;
    box-shadow: 0 -5px 0 #64748b, 0 5px 0 #64748b;
  }

  .md-nav--primary .md-nav__title[for="__drawer"] .md-nav__button {
    color: #64748b !important;
    display: none !important;                     /* hide logo inside nav title — use header logo */
  }

  /* ── Nav items: fade out when collapsed ──────────────────────────────────
     Items are clipped to 4 rem anyway; fading prevents partial text
     appearing during the width animation. */
  .md-sidebar--primary .md-nav__link,
  .md-sidebar--primary .md-nav__item--section > .md-nav__link {
    opacity: 0 !important;
    transition: background-color 0.12s ease, color 0.12s ease,
                opacity 0.15s ease !important;
  }

  /* ── Content ─────────────────────────────────────────────────────────────
     margin-left always equals current sidebar width — content is never
     covered. Mirrors: main style={{ marginLeft: DRAWER_WIDTH_COLLAPSED }}  */
  .md-main {
    margin-left: 3rem !important;
    transition: margin-left 0.3s ease-in-out !important;
  }

  /* ── Expanded state ──────────────────────────────────────────────────────
     Sidebar and content margin grow together at the same speed.           */
  [data-md-toggle="drawer"]:checked ~ .md-container .md-sidebar--primary {
    width: var(--md-sidebar-width, 12.1rem) !important;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08) !important;
  }

  [data-md-toggle="drawer"]:checked ~ .md-container .md-main {
    margin-left: var(--md-sidebar-width, 12.1rem) !important;
  }

  [data-md-toggle="drawer"]:checked ~ .md-container .md-sidebar--primary .md-nav__link,
  [data-md-toggle="drawer"]:checked ~ .md-container .md-sidebar--primary .md-nav__item--section > .md-nav__link {
    opacity: 1 !important;
  }

}
