/* ═══════════════════════════════════════════════════════════════════════════
   EasyStateMachine Docs — styles.css
   Palette based on logo stroke color #ff0044
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Variables ─────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:           #07080f;
  --bg-sidebar:   #0b0c16;
  --bg-surface:   #0f1020;
  --bg-elevated:  #13152a;
  --bg-hover:     #191c32;

  /* Primary accent — logo red */
  --accent:       #ff1744;
  --accent-soft:  #ff5370;
  --accent-dim:   rgba(255, 23, 68, 0.10);
  --accent-glow:  rgba(255, 23, 68, 0.22);
  --accent-border:rgba(255, 23, 68, 0.18);

  /* Secondary — blue for code/tech contrast */
  --blue:         #4fc3f7;
  --blue-dim:     rgba(79, 195, 247, 0.10);

  /* Text */
  --text:         #eef0ff;
  --text-dim:     #8892b0;
  --text-muted:   #4a526e;
  --text-subtle:  #292f4a;

  /* Borders */
  --border:       #13162a;
  --border-mid:   #1d2140;
  --border-light: #252a4a;

  /* Code */
  --code-bg:      #08090e;

  /* Sizes */
  --header-h:     60px;
  --sidebar-w:    262px;
  --radius:       8px;
  --radius-sm:    5px;
  --radius-lg:    12px;
  --transition:   .17s ease;
  --shadow-lg:    0 16px 48px rgba(0,0,0,.6);
}

/* ── 2. Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: rgba(255, 23, 68, .22); color: var(--text); }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
* { scrollbar-width: thin; scrollbar-color: var(--border-mid) transparent; }

/* ── 3. Header ────────────────────────────────────────────────────────────── */
#site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  background: rgba(7, 8, 15, .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-mid);
  box-shadow: 0 1px 0 var(--accent-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-center {
  flex: 1;
  min-width: 0;
}

.header-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.brand-logo {
  height: 30px;
  width: 30px;
  object-fit: contain;
}
.brand-name {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -.3px;
  background: linear-gradient(135deg, #fff 30%, var(--accent-soft));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* GitHub link */
.github-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--text-dim);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.github-link svg { width: 16px; height: 16px; }
.github-link:hover {
  color: var(--text);
  border-color: var(--accent-border);
  background: var(--bg-elevated);
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 34px;
  height: 34px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 7px 8px;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  height: 1.5px;
  background: var(--text-dim);
  border-radius: 2px;
  transition: transform .24s ease, opacity .18s ease, background var(--transition);
}
.hamburger:hover { border-color: var(--accent-border); }
.hamburger:hover span { background: var(--text); }
.hamburger.active span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 49;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sidebar-overlay.active { display: block; }

/* ── 4. DocShell root ─────────────────────────────────────────────────────── */
.ds-root {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ── 5. Sidebar ───────────────────────────────────────────────────────────── */
.ds-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-mid);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  transition: transform .26s cubic-bezier(.4,0,.2,1);
}

/* Sidebar extras (search + lang on mobile) */
#sidebar-extras {
  display: none;
}
#sidebar-extras:not(:empty) {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Keep DocShell's built-in search slot invisible — we mount to header */
.ds-search-slot { display: none !important; }

/* ── 6. Navigation ────────────────────────────────────────────────────────── */
.ds-nav { padding: 10px 0 40px; }

.ds-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.ds-nav-link {
  display: block;
  padding: 7px 18px 7px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  line-height: 1.4;
}
.ds-nav-link:hover {
  color: var(--text-dim);
  background: var(--bg-hover);
}
.ds-nav-link--active,
.ds-nav-item--active > .ds-nav-link {
  color: var(--accent-soft);
  background: linear-gradient(90deg, var(--accent-dim) 0%, transparent 100%);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ── 7. Language switcher ─────────────────────────────────────────────────── */
.ds-lang-switcher {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.ds-lang-btn {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .4px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: 'Inter', sans-serif;
}
.ds-lang-btn:hover { color: var(--text-dim); }
.ds-lang-btn--active {
  background: var(--accent);
  color: #fff;
}

/* ── 8. Main content ──────────────────────────────────────────────────────── */
.ds-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--header-h));
}

.ds-page { display: none; }
.ds-page:not([hidden]) { display: block; animation: pageIn .18s ease; }
@keyframes pageIn { from { opacity: .7; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.ds-page-inner {
  max-width: 860px;
  padding: 52px 52px 90px;
  margin: 0 auto;
}

/* ── 9. Typography ────────────────────────────────────────────────────────── */
.ds-h1 {
  font-size: 2.05rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.6px;
  line-height: 1.2;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-mid);
}

.ds-h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 52px;
  margin-bottom: 14px;
  letter-spacing: -.25px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ds-h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-soft) 100%);
  border-radius: 2px;
  flex-shrink: 0;
}

.ds-h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-soft);
  margin-top: 34px;
  margin-bottom: 8px;
  letter-spacing: -.1px;
}

.ds-h4 {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-top: 24px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ds-h5, .ds-h6 {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 16px;
  margin-bottom: 4px;
}

.ds-p {
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.8;
}

.ds-strong { color: var(--text); font-weight: 650; }
.ds-em { font-style: italic; }
.ds-del { text-decoration: line-through; opacity: .55; }

.ds-a {
  color: var(--accent-soft);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,83,112,.3);
  transition: border-color var(--transition), color var(--transition);
}
.ds-a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.ds-ul, .ds-ol {
  padding-left: 22px;
  margin-bottom: 16px;
  color: var(--text-dim);
}
.ds-li { margin-bottom: 6px; line-height: 1.75; }
.ds-li::marker { color: var(--accent); }

.ds-blockquote {
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, var(--accent-dim) 0%, transparent 100%);
  padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 20px 0;
  color: var(--text-dim);
}
.ds-blockquote .ds-p { margin: 0; }

.ds-img { max-width: 100%; border-radius: var(--radius); margin: 16px 0; }

/* Inline code */
.ds-code-inline {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .8em;
  background: var(--blue-dim);
  color: var(--blue);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(79, 195, 247, .15);
}

/* ── 10. Code blocks ──────────────────────────────────────────────────────── */
.ds-code-block-wrapper {
  position: relative;
  margin: 22px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border-mid);
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}

.ds-code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-mid);
  gap: 10px;
}

/* Window-dot decoration */
.ds-code-block-header::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 16px 0 0 #f59e0b, 32px 0 0 #22c55e;
}

.ds-code-lang {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-left: 38px;
}

.ds-code-copy-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  font-family: 'Inter', sans-serif;
  margin-left: auto;
}
.ds-code-copy-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-light); }
.ds-code-copy-btn--copied { color: #4ade80 !important; border-color: rgba(74,222,128,.4) !important; }

.ds-pre {
  margin: 0;
  overflow-x: auto;
  padding: 20px 22px;
}

.ds-code-block {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.65;
  display: block;
  color: var(--text);
  background: transparent !important;
  padding: 0 !important;
}
.ds-code-block-wrapper .hljs { background: transparent !important; }

/* ── 11. Tables ───────────────────────────────────────────────────────────── */
.ds-table-wrapper {
  overflow-x: auto;
  margin: 22px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border-mid);
}

.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.ds-thead { background: var(--bg-surface); }

.ds-th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-mid);
  white-space: nowrap;
}

.ds-td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: top;
  line-height: 1.6;
}
.ds-td .ds-code-inline { font-size: .77em; }

.ds-tr:last-child .ds-td { border-bottom: none; }
.ds-tr:nth-child(even) .ds-td { background: rgba(255,255,255,.015); }
.ds-tr:hover .ds-td { background: var(--bg-hover); }

/* ── 12. Search ───────────────────────────────────────────────────────────── */
.ds-search-wrapper {
  position: relative;
  width: 100%;
}

.ds-search-input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234a526e' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
}
.ds-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background-color: var(--bg-elevated);
}
.ds-search-input::placeholder { color: var(--text-subtle); }

.ds-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 420px;
  overflow-y: auto;
}

.ds-search-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.ds-search-item:last-child { border-bottom: none; }
.ds-search-item:hover,
.ds-search-item--focused { background: var(--bg-elevated); }

.ds-search-item-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.ds-search-item-page {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-soft);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.ds-search-item-section {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.ds-search-item-section::before { content: '›'; margin-right: 3px; color: var(--text-subtle); }
.ds-search-item-type {
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg-surface);
  color: var(--text-subtle);
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  margin-left: auto;
}
.ds-search-item-snippet {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.ds-search-mark {
  background: rgba(255, 23, 68, .2);
  color: var(--accent-soft);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

/* ── 13. Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hamburger { display: flex; }

  /* Hide search and lang from header on mobile */
  .header-center,
  #header-lang-slot { display: none; }

  /* Show sidebar extras on mobile */
  #sidebar-extras { display: flex !important; }
  #sidebar-extras:not(:empty) { display: flex !important; }

  .ds-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .ds-sidebar.open { transform: translateX(0); }

  .ds-main { margin-left: 0; }

  .ds-page-inner { padding: 36px 28px 64px; }

  /* Full-width search in sidebar on mobile */
  #sidebar-extras .ds-search-wrapper { min-width: 0; }
  #sidebar-extras .ds-search-dropdown {
    position: fixed;
    top: auto;
    left: 14px;
    right: 14px;
    width: auto;
  }
}

@media (max-width: 600px) {
  .ds-page-inner { padding: 24px 18px 48px; }
  .ds-h1 { font-size: 1.65rem; }
  .ds-h2 { font-size: 1.15rem; }
  .github-link { display: none; }
}

/* ── 14. Badges (shields.io images) ──────────────────────────────────────── */
.ds-page-inner img[src*="shields.io"],
.ds-page-inner img[src*="badge"] {
  display: inline;
  vertical-align: middle;
  margin: 0 3px 0 0;
  border-radius: 3px;
}
/* Wrap badges in a flex row */
.ds-h1 + .ds-p > img { margin-top: 2px; }

/* ── 15. Misc ─────────────────────────────────────────────────────────────── */
.ds-page-inner > .ds-h1 { margin-top: 0; }
.ds-page-inner > .ds-h2:first-of-type { margin-top: 32px; }
