/* Floweon Hyperflow Documentation — Microsoft Learn Layout + Floweon Design System */

:root {
  --font-sans: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Floweon Core Palette */
  --fl-ink: #162127;
  --fl-ink-deep: #0f171c;
  --fl-ink-panel: #1b2830;
  --fl-surface: #f3efe6;
  --fl-surface-elevated: #fbf9f4;
  --fl-tide: #3a7d8a;
  --fl-tide-light: #52a4b4;
  --fl-coral: #d97757;
  --fl-coral-hover: #e48869;

  /* Dark theme default (matches Hyperflow & floweon.ch hero ink) */
  --bg: var(--fl-ink-deep);
  --bg-elevated: var(--fl-ink);
  --bg-panel: var(--fl-ink-panel);
  --bg-code: #0b1115;
  --text: #eef1f3;
  --text-muted: #98a8b2;
  --border: rgba(243, 239, 230, 0.11);
  --border-strong: rgba(243, 239, 230, 0.22);
  --accent: var(--fl-tide-light);
  --accent-bg: rgba(58, 125, 138, 0.16);
  --coral-bg: rgba(217, 119, 87, 0.14);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] {
  --bg: var(--fl-surface);
  --bg-elevated: var(--fl-surface-elevated);
  --bg-panel: #ebe6da;
  --bg-code: #162127;
  --text: #162127;
  --text-muted: #4b5c66;
  --border: rgba(22, 33, 39, 0.12);
  --border-strong: rgba(22, 33, 39, 0.24);
  --accent: var(--fl-tide);
  --accent-bg: rgba(58, 125, 138, 0.12);
  --coral-bg: rgba(217, 119, 87, 0.12);
  --shadow: 0 10px 28px rgba(22, 33, 39, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 1rem;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--fl-coral), var(--fl-tide));
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(82, 164, 180, 0.3);
}

.topbar-center {
  flex: 1;
  max-width: 440px;
}

.search-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.search-trigger:hover {
  border-color: var(--accent);
  color: var(--text);
}

.search-trigger-text {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.lang-select {
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--accent);
}

html[data-theme="dark"] .moon-icon { display: none; }
html[data-theme="light"] .sun-icon { display: none; }
.mobile-menu-btn { display: none; }

/* 3-Column Learn Grid */
.layout {
  max-width: 1520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  gap: 0;
  min-height: calc(100vh - 58px);
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 20px 14px 40px;
  position: sticky;
  top: 58px;
  height: calc(100vh - 58px);
  overflow-y: auto;
}

.sidebar-backdrop {
  display: none;
}

.nav-module {
  margin-bottom: 10px;
}

.nav-module-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}

.nav-module-toggle:hover {
  background: var(--bg-panel);
}

.nav-module-toggle .chevron {
  transition: transform 0.16s ease;
  color: var(--text-muted);
}

.nav-module.expanded .nav-module-toggle .chevron {
  transform: rotate(90deg);
}

.nav-module-items {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 6px 10px;
  border-left: 1px solid var(--border);
  margin-left: 12px;
}

.nav-module.expanded .nav-module-items {
  display: flex;
}

.nav-link {
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.4;
  transition: color 0.12s, background 0.12s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-panel);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}

/* Main Documentation Body */
.doc-main {
  min-width: 0;
  padding: 32px clamp(20px, 4vw, 56px) 56px;
  max-width: 920px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }
.bc-current { color: var(--text); font-weight: 500; }

.doc-header h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.doc-lead {
  margin: 0 0 14px;
  font-size: 1.08rem;
  color: var(--text-muted);
}

.doc-meta {
  display: flex;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.doc-content h2 {
  margin-top: 2.2rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.45rem;
  letter-spacing: -0.015em;
}

.doc-content h3 {
  margin-top: 1.6rem;
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
}

.doc-content .headerlink {
  opacity: 0;
  margin-left: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 400;
}

.doc-content h2:hover .headerlink,
.doc-content h3:hover .headerlink {
  opacity: 0.85;
}

.doc-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.doc-content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  margin: 18px 0 8px;
  display: block;
}

.doc-content p > em:only-child {
  display: block;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.doc-content code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}

.code-block-wrap {
  position: relative;
  margin: 16px 0;
}

.doc-content pre {
  margin: 0;
  padding: 16px 18px;
  border-radius: 10px;
  background: var(--bg-code);
  color: #e6edf3;
  border: 1px solid var(--border-strong);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
}

.doc-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(22, 33, 39, 0.85);
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
}

.copy-btn:hover {
  border-color: var(--fl-tide-light);
}

/* Tables */
.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.doc-content th,
.doc-content td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.doc-content th {
  background: var(--bg-panel);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Admonitions (Microsoft Learn Note / Tip / Warning / Important) */
.admonition {
  margin: 18px 0;
  padding: 14px 18px;
  border-radius: 8px;
  border-left: 4px solid var(--accent);
  background: var(--accent-bg);
}

.admonition-title {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.admonition p:last-child { margin-bottom: 0; }

.admonition.warning,
.admonition.caution,
.admonition.danger {
  border-left-color: var(--fl-coral);
  background: var(--coral-bg);
}

.admonition.warning .admonition-title,
.admonition.caution .admonition-title,
.admonition.danger .admonition-title {
  color: var(--fl-coral);
}

.admonition.tip {
  border-left-color: #2f9e66;
  background: rgba(47, 158, 102, 0.12);
}

.admonition.tip .admonition-title {
  color: #36b376;
}

/* Prev / Next Pager */
.pager {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.pager-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

.pager-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.pager-next { text-align: right; }
.pager-label { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }
.pager-title { font-weight: 700; color: var(--accent); }

.doc-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.doc-footer a { color: var(--accent); text-decoration: none; }

/* Right TOC Rail */
.toc-rail {
  padding: 28px 18px;
}

.toc-sticky {
  position: sticky;
  top: 82px;
}

.toc-heading {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.toc-links {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}

.toc-link {
  padding: 4px 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
  line-height: 1.35;
}

.toc-link.toc-sub {
  padding-left: 22px;
  font-size: 0.79rem;
}

.toc-link:hover,
.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Search Modal */
.search-modal[hidden] { display: none; }
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: start center;
  padding-top: 10vh;
}

.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 19, 0.68);
  backdrop-filter: blur(4px);
}

.search-dialog {
  position: relative;
  width: min(640px, 92vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  outline: none;
}

.search-results {
  max-height: 55vh;
  overflow-y: auto;
  padding: 8px;
}

.search-hit {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}

.search-hit:hover { background: var(--accent-bg); }
.search-hit-mod { font-family: var(--font-mono); font-size: 0.74rem; color: var(--accent); }
.search-hit-title { font-weight: 700; margin: 2px 0; }
.search-hit-desc { font-size: 0.84rem; color: var(--text-muted); }

/* Responsive Breakpoints */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .toc-rail { display: none; }
}

@media (max-width: 820px) {
  .mobile-menu-btn { display: grid; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 58px;
    width: 280px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 58px 0 0 0;
    background: rgba(0,0,0,0.5);
    z-index: 55;
  }
  .pager { grid-template-columns: 1fr; }
  .search-trigger kbd { display: none; }
}
