/* ============================================
   FOREST OF LIGHT — Wiki Portal
   Aesthetic: Sandhill Nursery Brand Match
   Warm off-white, Montserrat, teal/orange accents
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Prata&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables --- */
:root {
  --bg-deep: #FEF6EE;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F7EFE5;
  --bg-card: #FFFFFF;
  --bg-hover: #F3EBE0;
  --bg-sidebar: #212427;

  --teal-50: #e8f5f8;
  --teal-100: #c8e6ed;
  --teal-200: #a4d5e0;
  --teal-300: #8CC0CE;
  --teal-400: #6daebb;
  --teal-500: #5199a8;
  --teal-600: #3d7f8e;
  --teal-700: #2d6270;
  --teal-highlight: rgba(140, 192, 206, 0.12);
  --teal-highlight-strong: rgba(140, 192, 206, 0.22);

  --orange-400: #F76A24;
  --orange-500: #e55a14;
  --orange-600: #d04e0c;
  --orange-highlight: rgba(247, 106, 36, 0.08);

  --sage: #B0C3B7;
  --sage-light: #dce8df;
  --sage-highlight: rgba(176, 195, 183, 0.15);

  --text-primary: #212427;
  --text-secondary: #5a5f66;
  --text-muted: #8e9299;
  --text-on-dark: #e8e4d9;
  --text-on-dark-secondary: #a8a49e;
  --text-on-dark-muted: #6b685e;

  --border-light: #e8dfd4;
  --border-subtle: #ede5da;
  --border-accent: rgba(140, 192, 206, 0.4);
  --border-sidebar: rgba(255, 255, 255, 0.08);

  --green-status: #4caf50;
  --red-status: #e53935;
  --yellow-status: #f9a825;
  --blue-accent: #1e88e5;

  --font-display: 'Prata', Georgia, serif;
  --font-body: 'Montserrat', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --sidebar-width: 280px;
  --header-height: 60px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-deep);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle warm grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.018'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(140, 192, 206, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(140, 192, 206, 0.5); }

/* --- Layout Shell --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar (dark, like Sandhill's dark nav) --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-slow);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-sidebar);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-brand {
  display: block;
  text-decoration: none;
  padding: 4px 0;
}

.sidebar-brand-logo {
  width: 100%;
  max-width: 180px;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Search */
.sidebar-search {
  padding: 12px 16px;
  flex-shrink: 0;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-on-dark-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-on-dark);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input::placeholder { color: var(--text-on-dark-muted); }
.search-input:focus {
  border-color: var(--teal-300);
  box-shadow: 0 0 0 3px rgba(140, 192, 206, 0.15);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-on-dark-muted);
  padding: 16px 8px 6px;
  display: block;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-on-dark-secondary);
  text-decoration: none;
  font-size: 13.5px;
  transition: all var(--transition-fast);
  position: relative;
  line-height: 1.4;
}

.nav-link:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: #FFFFFF;
  background: rgba(140, 192, 206, 0.15);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--teal-300);
  border-radius: 1px;
}

.nav-link-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-link-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-sidebar);
  flex-shrink: 0;
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--text-on-dark-muted);
  text-align: center;
}

/* --- Mobile sidebar toggle --- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  width: 36px;
  height: 36px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--teal-300);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-deep);
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(254, 246, 238, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  padding: 0 40px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb a:hover { color: var(--teal-500); }

.breadcrumb-sep { opacity: 0.4; }

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.page-body {
  padding: 36px 40px 80px;
  max-width: 900px;
}

/* --- Typography --- */
.page-title {
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.page-title .emoji {
  margin-right: 8px;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.7;
}

h2 {
  font-family: var(--font-body);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  line-height: 1.3;
}

h3 {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 28px 0 12px;
}

h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 24px 0 10px;
}

p {
  margin-bottom: 16px;
  color: var(--text-primary);
}

strong { color: var(--text-primary); font-weight: 600; }

a { color: var(--teal-500); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--teal-700); text-decoration: underline; }

/* --- Callouts / Alerts --- */
.callout {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.callout-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.callout-warning {
  background: #FFF8E1;
  border: 1px solid #FFE082;
  color: #6d5200;
}

.callout-danger {
  background: #FFEBEE;
  border: 1px solid #EF9A9A;
  color: #b71c1c;
}

.callout-info {
  background: var(--teal-50);
  border: 1px solid var(--teal-200);
  color: var(--teal-700);
}

.callout-success {
  background: #E8F5E9;
  border: 1px solid #A5D6A7;
  color: #2e7d32;
}

.callout-tip {
  background: var(--sage-light);
  border: 1px solid var(--sage);
  color: #3d5c45;
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  margin: 16px 0 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
}

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

thead {
  background: var(--bg-elevated);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal-600);
  border-bottom: 2px solid var(--teal-200);
  white-space: nowrap;
}

td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--teal-highlight); }

td code, th code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--teal-50);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--teal-700);
}

.status-ok { color: var(--green-status); }
.status-warn { color: var(--yellow-status); }
.status-error { color: var(--red-status); }
.status-idle { color: var(--text-muted); }

/* --- Code Blocks --- */
pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 16px 0 24px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--teal-50);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--teal-700);
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* --- Ordered & Unordered Lists --- */
ol, ul {
  margin: 12px 0 20px;
  padding-left: 24px;
}

li {
  margin-bottom: 6px;
  color: var(--text-primary);
}

li::marker {
  color: var(--teal-400);
}

/* --- Horizontal Rule / Divider --- */
hr {
  border: none;
  height: 1px;
  background: var(--border-light);
  margin: 32px 0;
}

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition-base);
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal-300), var(--sage));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.card:hover {
  border-color: var(--teal-300);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(140, 192, 206, 0.15);
  text-decoration: none;
}

.card:hover::before { opacity: 1; }

.card-icon {
  font-size: 28px;
  margin-bottom: 10px;
  display: block;
}

.card-title {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- TOC (on-page) --- */
.page-toc {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 32px;
}

.page-toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.page-toc a {
  display: block;
  padding: 3px 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.page-toc a:hover {
  color: var(--teal-500);
  text-decoration: none;
}

/* --- Search Results --- */
.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.search-results.active { display: block; }

.search-result-item {
  display: block;
  padding: 10px 14px;
  color: var(--text-on-dark-secondary);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid var(--border-sidebar);
  transition: background var(--transition-fast);
}

.search-result-item:hover {
  background: rgba(140, 192, 206, 0.1);
  color: #FFFFFF;
  text-decoration: none;
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item .result-title {
  font-weight: 500;
  color: var(--text-on-dark);
}

.search-result-item .result-section {
  font-size: 11px;
  color: var(--text-on-dark-muted);
  margin-top: 2px;
}

.search-no-results {
  padding: 16px;
  text-align: center;
  color: var(--text-on-dark-muted);
  font-size: 13px;
}

/* --- Decorative accent line at top --- */
.glow-line {
  height: 3px;
  background: linear-gradient(90deg, var(--teal-300), var(--sage), var(--orange-400), var(--teal-300));
  opacity: 0.85;
}

/* --- Page entrance animation --- */
.page-body { animation: fadeInUp 0.4s ease both; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Architecture diagram --- */
.arch-diagram {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin: 16px 0 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--teal-700);
  white-space: pre;
  overflow-x: auto;
}

/* --- Blockquote (for press quotes) --- */
blockquote {
  border-left: 3px solid var(--teal-300);
  padding: 12px 20px;
  margin: 16px 0;
  background: var(--teal-50);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-toggle {
    display: flex;
  }

  .sidebar-overlay.active {
    display: block;
  }

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

  .page-header {
    padding: 0 20px 0 56px;
  }

  .page-body {
    padding: 24px 20px 60px;
  }

  .page-title {
    font-size: 1.8rem;
  }

  h2 { font-size: 1.3rem; }
}

@media (max-width: 600px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 1.5rem;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 7px 10px;
  }
}
