/* P1METER.EU — public site styles */

:root {
  --green: #2a9d5c;
  --green-dark: #1f7a46;
  --green-soft: #e8f5ed;
  --green-ring: rgba(42, 157, 92, 0.35);

  --ink: #1a1d21;
  --ink-soft: #3d434a;
  --muted: #6b7480;
  --line: #e6e8eb;
  --line-soft: #f1f3f5;
  --bg: #ffffff;
  --bg-alt: #fafbfc;
  --bg-code: #f5f7f9;
  --bg-code-block: #f8fafc;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.12);

  --header-h: 60px;
  --sidebar-w: 280px;
  --toc-w: 240px;

  --font-sans: 'Figtree', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', 'Monaco', monospace;

  --t-fast: 120ms ease;
  --t: 180ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

/* Make sure the HTML `hidden` attribute is always respected
   (elements with explicit display rules would otherwise ignore it) */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ────────────────────────────────────────────────
   Header
   ──────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
}
.site-header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 28px; height: 28px;
  border-radius: 6px;
  object-fit: cover;
}
.brand-name {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.primary-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  overflow: hidden;
}
.primary-nav-item {
  color: var(--ink-soft);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.primary-nav-item:hover {
  text-decoration: none;
  background: var(--line-soft);
  color: var(--ink);
}
.primary-nav-item.active {
  color: var(--green-dark);
  background: var(--green-soft);
}

.header-right { display: flex; align-items: center; gap: 12px; }

/* Search */
.search-wrap { position: relative; }
#site-search {
  width: 260px;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--line);
  background: var(--bg-alt) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%236b7480" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><line x1="20" y1="20" x2="16.65" y2="16.65"/></svg>') 10px center / 16px no-repeat;
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  transition: border var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
}
#site-search::placeholder { color: var(--muted); }
#site-search:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-ring);
  background-color: #fff;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 420px;
  max-height: 480px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
}
.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  transition: background var(--t-fast);
}
.search-result:hover { background: var(--line-soft); text-decoration: none; }
.search-result-title { font-weight: 600; font-size: 14px; display: block; }
.search-result-product {
  font-size: 11.5px;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 2px;
}
.search-result-snippet {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result mark { background: #fff3c4; color: inherit; padding: 0 2px; border-radius: 2px; }
.search-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.mobile-nav-toggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--ink);
  border-radius: 1px;
  transition: transform var(--t), opacity var(--t);
}

/* ────────────────────────────────────────────────
   Three-column layout (sidebar / main / toc)
   ──────────────────────────────────────────────── */
.layout-three-col {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  align-items: start;
}

/* Left sidebar */
.sidebar-left {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 12px 40px 24px;
  border-right: 1px solid var(--line);
}
.sidebar-left-inner { padding-right: 8px; }
.sidebar-product-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

/* Tree (left sidebar) */
.tree {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tree-depth-0 { padding-left: 0; }
.tree-depth-1, .tree-depth-2, .tree-depth-3 {
  padding-left: 14px;
  margin-left: 8px;
  border-left: 1px solid var(--line);
  margin-top: 2px;
}

.tree-item { margin: 1px 0; }

.tree-item > a,
.tree-dir-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
  line-height: 1.35;
}
.tree-item > a:hover,
.tree-dir-toggle:hover {
  background: var(--line-soft);
  color: var(--ink);
  text-decoration: none;
}
.tree-item.active > a {
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 600;
}

.tree-chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%236b7480" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>') center / 12px no-repeat;
  transition: transform var(--t);
}
.tree-item.dir.open > .tree-dir-toggle .tree-chevron {
  transform: rotate(90deg);
}
.tree-dir-label { flex: 1; }

/* Collapse non-open dir children */
.tree-item.dir:not(.open) > .tree { display: none; }

/* Main content */
.main-content {
  min-width: 0;
  padding: 28px 48px 80px;
}

/* Breadcrumbs */
.breadcrumbs ol {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumbs li { display: flex; align-items: center; gap: 6px; }
.breadcrumbs li:not(:last-child)::after {
  content: '';
  width: 10px; height: 10px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23a0a8b0" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>') center / 10px no-repeat;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--ink); text-decoration: none; }
.breadcrumbs .current span { color: var(--green-dark); font-weight: 500; }

/* Article typography */
.doc-article {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-soft);
  max-width: 820px;
}
.doc-article h1,
.doc-article h2,
.doc-article h3,
.doc-article h4 {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 2.2em 0 0.7em;
  line-height: 1.25;
}
.doc-article h1 {
  font-size: 38px;
  letter-spacing: -0.025em;
  margin-top: 0;
  margin-bottom: 0.5em;
}
.doc-article h2 {
  font-size: 26px;
  padding-top: 10px;
  margin-top: 2.4em;
}
.doc-article h3 { font-size: 20px; margin-top: 2em; }
.doc-article h4 { font-size: 17px; }

.doc-article p { margin: 1em 0; }
.doc-article ul,
.doc-article ol { margin: 1em 0; padding-left: 24px; }
.doc-article li { margin: 0.3em 0; }
.doc-article li > p { margin: 0.4em 0; }

.doc-article a {
  color: var(--green-dark);
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-fast);
}
.doc-article a:hover { text-decoration: none; border-bottom-color: var(--green-dark); }

.doc-article strong { color: var(--ink); font-weight: 700; }

/* Inline code */
.doc-article code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--bg-code);
  color: var(--ink);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* Fenced code */
.doc-article pre {
  background: var(--bg-code-block);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 1.4em 0;
  font-size: 13.5px;
  line-height: 1.55;
}
.doc-article pre code {
  background: transparent !important;
  border: 0;
  padding: 0;
  font-family: var(--font-mono);
  color: var(--ink);
}

/* Blockquote */
.doc-article blockquote {
  margin: 1.4em 0;
  padding: 2px 18px;
  border-left: 3px solid var(--green);
  background: var(--green-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-soft);
}
.doc-article blockquote p:first-child { margin-top: 0.8em; }
.doc-article blockquote p:last-child { margin-bottom: 0.8em; }

/* HR */
.doc-article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

/* Images */
.doc-article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin: 1em 0;
}

/* Tables */
.doc-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.doc-article thead { background: var(--bg-alt); }
.doc-article th, .doc-article td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.doc-article th { font-weight: 600; color: var(--ink); }
.doc-article tbody tr:last-child td { border-bottom: 0; }
.doc-article tbody tr:nth-child(even) { background: var(--bg-alt); }

/* Prev / next pager */
.page-pager {
  margin-top: 3em;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.pager-link:hover {
  border-color: var(--green);
  background: var(--bg-alt);
  text-decoration: none;
}
.pager-prev { align-items: flex-start; }
.pager-next { align-items: flex-end; text-align: right; grid-column: 2; }
.pager-dir { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.pager-title { font-weight: 600; color: var(--green-dark); }

/* Right sidebar (TOC) */
.sidebar-right {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 28px 24px 40px 20px;
}
.toc-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
  padding-bottom: 10px;
}
.toc { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.toc li { padding: 0; }
.toc a {
  display: block;
  padding: 5px 14px;
  margin-left: -2px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active {
  color: var(--green-dark);
  border-left-color: var(--green);
  font-weight: 600;
}
.toc-level-3 a { padding-left: 28px; font-size: 12.5px; }

/* Home page */
.home {
  max-width: 1080px;
  margin: 0 auto;
  padding: 80px 24px 120px;
}
.home-hero { text-align: center; margin-bottom: 64px; }
.home-hero h1 {
  font-size: 56px;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--ink) 0%, var(--green-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.home-tagline { font-size: 19px; color: var(--muted); margin: 0; }
.home-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.product-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 36px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--ink);
  transition: border-color var(--t), transform var(--t), box-shadow var(--t);
  min-height: 160px;
}
.product-card:hover {
  border-color: var(--green);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.product-card h2 { margin: 0; font-size: 22px; font-weight: 700; }
.product-card-cta { font-size: 14px; color: var(--green-dark); font-weight: 600; }

/* Empty state */
.empty-state { text-align: center; padding: 80px 20px; }
.empty-state h1 {
  font-size: 96px;
  margin: 0;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.empty-state p { font-size: 17px; color: var(--muted); margin: 10px 0 26px; }
.btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: background var(--t-fast);
}
.btn:hover { background: var(--green-dark); text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 18px 0;
  margin-top: 40px;
  color: var(--muted);
  font-size: 13px;
}
.site-footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-link { color: var(--muted); }
.admin-link:hover { color: var(--green-dark); }

/* ────────────────────────────────────────────────
   Responsive
   ──────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .layout-three-col { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar-right { display: none; }
  .main-content { padding: 28px 40px 80px; }
}

@media (max-width: 860px) {
  .primary-nav { display: none; }
  .mobile-nav-toggle { display: flex; }

  #site-search { width: 180px; }

  .layout-three-col {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar-left {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    background: #fff;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    transform: translateX(-100%);
    transition: transform var(--t);
    z-index: 40;
    padding-top: 20px;
  }
  body.nav-open .sidebar-left { transform: translateX(0); }

  .main-content { padding: 22px 20px 80px; }
  .doc-article h1 { font-size: 30px; }
  .doc-article h2 { font-size: 22px; }

  .page-pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; align-items: flex-start; text-align: left; }

  .search-results { width: calc(100vw - 32px); right: -40px; }

  .home { padding: 48px 20px; }
  .home-hero h1 { font-size: 40px; }
}

@media (max-width: 520px) {
  .brand-name { display: none; }
  #site-search { width: 140px; font-size: 13px; }
  .site-header-inner { gap: 12px; padding: 0 14px; }
}

/* Focus styles */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Heading anchors on hover */
.doc-article h2:hover::before,
.doc-article h3:hover::before,
.doc-article h4:hover::before {
  content: '#';
  position: absolute;
  margin-left: -28px;
  color: var(--green);
  font-weight: 400;
  opacity: 0.6;
}
.doc-article h2, .doc-article h3, .doc-article h4 { position: relative; }

/* Scrollbars (subtle) */
.sidebar-left, .sidebar-right {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.sidebar-left::-webkit-scrollbar,
.sidebar-right::-webkit-scrollbar { width: 8px; }
.sidebar-left::-webkit-scrollbar-thumb,
.sidebar-right::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.sidebar-left::-webkit-scrollbar-thumb:hover,
.sidebar-right::-webkit-scrollbar-thumb:hover { background: #c7ced5; }
