/* ==========================================================================
   PHPFoundry Documentation — stylesheet
   Dependency-free. No external fonts or libraries.
   Aesthetic: technical handbook — warm paper, ink, rust accent,
   monospace headings (terminal feel), serif body (manual feel).
   ========================================================================== */

:root {
  /* Type */
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;
  --font-body: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;

  /* Light theme (default) */
  --bg: #f6f2ea;
  --bg-raised: #fffdf8;
  --bg-sidebar: #efeadf;
  --text: #211f1b;
  --text-muted: #6c665b;
  --text-faint: #9a9488;
  --border: #ddd6c8;
  --border-strong: #c9c0ad;
  --accent: #b4470f;
  --accent-hover: #913809;
  --accent-soft: rgba(180, 71, 15, 0.09);
  --code-bg: #211f1c;
  --code-text: #e9e2d4;
  --code-inline-bg: #ece6d7;
  --code-inline-text: #8a3a0c;
  --shadow: 0 1px 2px rgba(33, 31, 27, 0.06), 0 4px 16px rgba(33, 31, 27, 0.05);
}

html[data-theme="dark"] {
  --bg: #181714;
  --bg-raised: #201e19;
  --bg-sidebar: #151412;
  --text: #e9e3d6;
  --text-muted: #a39d90;
  --text-faint: #6f6a5f;
  --border: #322f28;
  --border-strong: #423e35;
  --accent: #e07a32;
  --accent-hover: #ee8e48;
  --accent-soft: rgba(224, 122, 50, 0.12);
  --code-bg: #100f0d;
  --code-text: #e3dccd;
  --code-inline-bg: #2a2720;
  --code-inline-text: #e89a5e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Layout ------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ---- Top bar ------------------------------------------------------------ */

.topbar {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand .mark { color: var(--accent); }
.brand .ver {
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0;
}

.topbar-spacer { flex: 1; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.theme-toggle,
.menu-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover,
.menu-toggle:hover { border-color: var(--border-strong); color: var(--text); }
.theme-toggle svg, .menu-toggle svg { width: 18px; height: 18px; }
.menu-toggle { display: none; }

/* ---- Sidebar ------------------------------------------------------------ */

.sidebar {
  position: sticky;
  top: 60px;
  align-self: start;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 26px 18px 60px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}

.nav-section { margin-bottom: 22px; }
.nav-section > .nav-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-section ul { list-style: none; margin: 0; padding: 0; }
.nav-section li { margin: 1px 0; }

.nav-section a,
.nav-section .soon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 13.5px;
  text-decoration: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s;
}
.nav-section a:hover { background: var(--accent-soft); color: var(--text); }
.nav-section a.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-section .soon { color: var(--text-faint); cursor: default; }
.nav-section .soon .tag {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-faint);
}

/* ---- Main content ------------------------------------------------------- */

.content {
  padding: 48px 56px 120px;
  max-width: 820px;
}

.content .eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin: 0 0 12px;
}

.content h1 {
  font-family: var(--font-mono);
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  font-weight: 600;
}
.content h2 {
  font-family: var(--font-mono);
  font-size: 24px;
  letter-spacing: -0.01em;
  margin: 52px 0 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-weight: 600;
  scroll-margin-top: 76px;
}
.content h3 {
  font-family: var(--font-mono);
  font-size: 18px;
  margin: 32px 0 12px;
  font-weight: 600;
  scroll-margin-top: 76px;
}

.content p { margin: 16px 0; }
.content a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
.content a:hover { border-bottom-color: var(--accent); }

.lead { font-size: 21px; line-height: 1.6; color: var(--text); }

.content ul, .content ol { margin: 16px 0; padding-left: 26px; }
.content li { margin: 7px 0; }

.content hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }

/* Inline + block code */
code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--code-inline-bg);
  color: var(--code-inline-text);
  padding: 2px 6px;
  border-radius: 5px;
}
pre {
  position: relative;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 10px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: var(--shadow);
}
pre code { background: none; color: inherit; padding: 0; font-size: 14px; }
pre::before {
  content: "";
  position: absolute;
  top: 14px; left: 18px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #e0792f;
  box-shadow: 16px 0 0 #5a544a, 32px 0 0 #5a544a;
  opacity: 0.55;
}
pre { padding-top: 38px; }

/* Definition lists (used for troubleshooting) */
.content dl { margin: 20px 0; }
.content dt {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
  margin-top: 18px;
}
.content dd { margin: 4px 0 0; color: var(--text-muted); padding-left: 16px; border-left: 2px solid var(--border); }

/* Admonitions */
.admonition {
  margin: 22px 0;
  padding: 14px 18px 14px 16px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
.admonition .adm-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 6px;
  color: var(--accent);
}
.admonition p { margin: 4px 0; font-size: 16px; }
.admonition.warning { border-left-color: #c9472b; }
.admonition.warning .adm-title { color: #c9472b; }
html[data-theme="dark"] .admonition.warning { border-left-color: #ef6a48; }
html[data-theme="dark"] .admonition.warning .adm-title { color: #ef6a48; }
.admonition.tip { border-left-color: #1f7a52; }
.admonition.tip .adm-title { color: #1f7a52; }
html[data-theme="dark"] .admonition.tip { border-left-color: #45b07e; }
html[data-theme="dark"] .admonition.tip .adm-title { color: #45b07e; }

/* Home hero cards */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 28px 0; }
.card {
  display: block;
  padding: 22px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.card .card-title { font-family: var(--font-mono); font-weight: 600; font-size: 16px; margin: 0 0 6px; }
.card .card-desc { font-size: 15px; color: var(--text-muted); margin: 0; }

/* ---- Search overlay ----------------------------------------------------- */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  background: rgba(20, 18, 14, 0.45);
  backdrop-filter: blur(3px);
  padding-top: 12vh;
}
.search-overlay.open { display: block; }
.search-box {
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.search-box input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 17px;
  padding: 18px 20px;
  outline: none;
  border-bottom: 1px solid var(--border);
}
.search-results { max-height: 50vh; overflow-y: auto; }
.search-results a {
  display: block;
  padding: 13px 20px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.search-results a:hover, .search-results a.sel { background: var(--accent-soft); }
.search-results .r-title { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.search-results .r-section { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.search-results .empty { padding: 22px 20px; color: var(--text-muted); font-size: 14px; }

/* ---- Footer ------------------------------------------------------------- */
.page-footer {
  margin-top: 64px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

/* ---- Responsive --------------------------------------------------------- */

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: grid; }
  .sidebar {
    position: fixed;
    top: 60px; left: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 25;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 32px 22px 100px; }
  .content h1 { font-size: 32px; }
  .cards { grid-template-columns: 1fr; }
  .search-trigger .label { display: none; }
}
