/* ============================================
   aleph-onchain Documentation Site
   Dark theme matching docs.aleph.cloud
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;600;700&family=Source+Code+Pro:wght@400;500&display=swap');

:root {
  --bg: #141421;
  --bg-card: #1E1E30;
  --bg-sidebar: #18182A;
  --bg-code: #12121E;
  --text: #E0E0E0;
  --text-dim: #8888AA;
  --text-bright: #FFFFFF;
  --purple: #5100CD;
  --purple-light: #7B3FE4;
  --lime: #D4FF00;
  --lime-dim: #A8CC00;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(81, 0, 205, 0.4);
  --link: #7B3FE4;
  --link-hover: #D4FF00;

  --sidebar-width: 260px;
  --toc-width: 200px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: 'Titillium Web', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

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

a:hover {
  color: var(--link-hover);
}

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.5rem 0;
  z-index: 100;
}

.sidebar-logo {
  display: block;
  padding: 0 1.5rem 1.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-bright);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-logo span {
  color: var(--lime);
}

.sidebar-section {
  padding: 0.5rem 0;
}

.sidebar-section-title {
  padding: 0.4rem 1.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}

.sidebar-link {
  display: block;
  padding: 0.4rem 1.5rem 0.4rem 2rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(81, 0, 205, 0.05);
}

.sidebar-link.active {
  color: var(--lime);
  border-left-color: var(--lime);
  background: rgba(212, 255, 0, 0.05);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
}

/* ---- MAIN CONTENT ---- */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(20, 20, 33, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.breadcrumbs a {
  color: var(--text-dim);
}

.breadcrumbs span {
  color: var(--text);
}

.search-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 1rem;
  color: var(--text);
  font-family: 'Titillium Web', sans-serif;
  font-size: 0.85rem;
  width: 250px;
  transition: border-color 0.2s;
}

.search-box:focus {
  outline: none;
  border-color: var(--purple);
}

.search-box::placeholder {
  color: var(--text-dim);
}

.content {
  max-width: 860px;
  padding: 2rem 3rem 4rem;
}

/* ---- TYPOGRAPHY ---- */
h1 {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

.lead {
  font-size: 1.15rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

/* ---- CODE ---- */
code {
  font-family: 'Source Code Pro', monospace;
  background: var(--bg-code);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--lime);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text);
}

/* Syntax highlighting */
.kw { color: #C792EA; }
.ty { color: #82AAFF; }
.str { color: #C3E88D; }
.cmt { color: #546E7A; }
.fn { color: #FFD54F; }
.num { color: #F78C6C; }
.op { color: #89DDFF; }
.attr { color: #FFCB6B; }

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: 'Titillium Web', sans-serif;
  transition: color 0.2s, border-color 0.2s;
}

.copy-btn:hover {
  color: var(--lime);
  border-color: var(--lime);
}

/* ---- TABLES ---- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-bright);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover td {
  background: rgba(81, 0, 205, 0.03);
}

/* ---- CALLOUTS ---- */
.callout {
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid;
}

.callout-info {
  background: rgba(81, 0, 205, 0.08);
  border-color: var(--purple);
}

.callout-warning {
  background: rgba(255, 200, 0, 0.08);
  border-color: #FFCB6B;
}

.callout-tip {
  background: rgba(212, 255, 0, 0.06);
  border-color: var(--lime);
}

.callout-title {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
}

.callout-info .callout-title { color: var(--purple-light); }
.callout-warning .callout-title { color: #FFCB6B; }
.callout-tip .callout-title { color: var(--lime); }

/* ---- CARDS ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: border-color 0.2s, transform 0.2s;
}

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

.card h4 {
  margin-top: 0;
  color: var(--lime);
  font-size: 1rem;
}

.card p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 0;
}

/* ---- PAGE NAV ---- */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.page-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 200px;
  transition: border-color 0.2s;
}

.page-nav a:hover {
  border-color: var(--purple);
}

.page-nav-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.page-nav-title {
  font-weight: 600;
  color: var(--text-bright);
}

/* ---- TABLE OF CONTENTS ---- */
.toc {
  position: fixed;
  right: 2rem;
  top: 80px;
  width: var(--toc-width);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.toc-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.toc a {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 0.2rem 0;
  transition: color 0.2s;
}

.toc a:hover {
  color: var(--text);
}

.toc a.active {
  color: var(--lime);
}

.toc .toc-h3 {
  padding-left: 0.75rem;
  font-size: 0.78rem;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1400px) {
  .toc { display: none; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .content {
    padding: 2rem 1.5rem;
  }

  .topbar {
    padding: 0.75rem 1rem 0.75rem 3.5rem;
  }

  .search-box {
    width: 150px;
  }

  .page-nav {
    flex-direction: column;
    gap: 1rem;
  }

  .page-nav a {
    min-width: auto;
  }
}
