/* ============================================================
   Planlab — User guide
   Design tokens mirrored from the Planlab app (themes/planlab)
   ============================================================ */

/* Haffer — the Planlab app's brand typeface */
@font-face {
  font-family: "haffer";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/HafferXH-Regular.woff2") format("woff2"),
       url("fonts/HafferXH-Regular.woff") format("woff");
}
@font-face {
  font-family: "haffer";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("fonts/HafferXH-Medium.woff2") format("woff2"),
       url("fonts/HafferXH-Medium.woff") format("woff");
}

:root {
  /* Brand */
  --pl-orange:        #e57528;  /* planlab-dark-orange */
  --pl-orange-soft:   #f7dac5;  /* brand / background-primary  */
  --pl-orange-faint:  #fbf1e9;  /* background-primary-faded    */
  --pl-navy:          #0e2134;  /* workspace-selector bg        */
  --pl-navy-2:        #293e4f;  /* workspace-selector button    */

  /* Paper / surfaces */
  --pl-paper:         #f6f6f2;  /* viewer-page                  */
  --pl-paper-border:  #ddddd9;  /* viewer-page-border           */
  --pl-page:          #ffffff;
  --pl-page-faded:    #f7f7f5;

  /* Ink */
  --pl-ink:           #1b1e23;  /* foreground-neutral           */
  --pl-ink-faded:     #62666d;  /* foreground-neutral-faded     */
  --pl-ink-heading:   #10141a;

  /* Lines */
  --pl-border:        rgba(0, 0, 0, 0.12);
  --pl-border-faint:  rgba(0, 0, 0, 0.07);

  /* Status (health checks / callouts) */
  --pl-positive:      #16874a;
  --pl-warning:       #b8791a;
  --pl-critical:      #cf2a29;

  /* Type + shape */
  --pl-font: "haffer", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --pl-mono: "Geist Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --pl-radius-s: 4px;
  --pl-radius-m: 8px;
  --pl-radius-l: 12px;
  --pl-shadow-raised: 0 1px 5px -4px rgba(0,0,0,.5), 0 4px 8px 0 rgba(0,0,0,.05);
  --pl-shadow-overlay: 0 5px 10px 0 rgba(0,0,0,.05), 0 15px 25px 0 rgba(0,0,0,.07);

  /* Layout */
  --header-h: 60px;
  --sidebar-w: 288px;
  --content-max: 760px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--pl-font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--pl-ink);
  background: var(--pl-paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Header ---------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: rgba(255,255,255,.9);
  backdrop-filter: saturate(1.6) blur(8px);
  color: var(--pl-ink);
  border-bottom: 1px solid var(--pl-paper-border);
}
.site-header .brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.site-header .brand img { height: 22px; width: auto; display: block; }
.site-header .divider { width: 1px; height: 22px; background: var(--pl-border); }
.site-header .context { font-size: 14px; font-weight: 500; color: var(--pl-ink-faded); letter-spacing: .01em; }
.site-header .spacer { flex: 1; }
.site-header .draft-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #b8560f;
  background: rgba(229,117,40,.12);
  border: 1px solid rgba(229,117,40,.5);
  padding: 4px 10px; border-radius: 999px;
}
.menu-toggle { display: none; }

/* ---------- Shell layout ---------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  max-width: 1220px;
  margin: 0 auto;
}

/* ---------- Sidebar --------------------------------------- */
.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 26px 18px 40px 22px;
  border-right: 1px solid var(--pl-paper-border);
}
.sidebar .nav-label {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--pl-ink-faded);
  margin: 0 0 12px 8px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar .parts > li { margin-bottom: 2px; }
.sidebar a.part-link {
  display: flex; align-items: baseline; gap: 9px;
  text-decoration: none;
  color: var(--pl-ink);
  font-size: 14.5px; font-weight: 500;
  padding: 8px 10px;
  border-radius: var(--pl-radius-m);
  border-left: 2px solid transparent;
}
.sidebar a.part-link .idx { color: var(--pl-ink-faded); font-weight: 700; font-size: 12.5px; min-width: 14px; }
.sidebar a.part-link:hover { background: var(--pl-orange-faint); }
.sidebar li.active > a.part-link {
  background: var(--pl-orange-faint);
  border-left-color: var(--pl-orange);
  color: var(--pl-ink-heading);
  font-weight: 700;
}
.sidebar li.active > a.part-link .idx { color: var(--pl-orange); }
/* in-page section links under the active part */
.sidebar .sections { margin: 2px 0 8px 0; padding-left: 22px; border-left: 1px solid var(--pl-paper-border); }
.sidebar .sections a {
  display: block; text-decoration: none;
  color: var(--pl-ink-faded);
  font-size: 13px; line-height: 1.35;
  padding: 5px 10px; border-radius: 6px;
}
.sidebar .sections a:hover { color: var(--pl-orange); background: var(--pl-orange-faint); }

/* ---------- Content --------------------------------------- */
.content-wrap { padding: 34px clamp(20px, 4vw, 56px) 80px; min-width: 0; }
.content {
  max-width: var(--content-max);
  margin: 0 auto;
  background: var(--pl-page);
  border: 1px solid var(--pl-paper-border);
  border-radius: var(--pl-radius-l);
  box-shadow: var(--pl-shadow-raised);
  padding: clamp(26px, 4vw, 52px);
}
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--pl-orange);
  margin-bottom: 8px;
}

/* Typography */
.content :where(h1,h2,h3,h4) { color: var(--pl-ink-heading); line-height: 1.22; scroll-margin-top: calc(var(--header-h) + 16px); }
.content h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 20px; }
.content h2 {
  font-size: 24px; font-weight: 700; letter-spacing: -0.01em;
  margin: 46px 0 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--pl-paper-border);
}
.content h3 { font-size: 18.5px; font-weight: 700; margin: 32px 0 10px; }
.content h4 { font-size: 15.5px; font-weight: 700; margin: 24px 0 8px; }
.content p { margin: 0 0 15px; }
.content a { color: #b8560f; text-decoration: none; border-bottom: 1px solid rgba(229,117,40,.4); }
.content a:hover { color: var(--pl-orange); border-bottom-color: var(--pl-orange); }
.content strong { font-weight: 700; color: var(--pl-ink-heading); }
.content ul, .content ol { margin: 0 0 15px; padding-left: 24px; }
.content li { margin: 6px 0; }
.content li::marker { color: var(--pl-orange); }
.content hr { border: 0; border-top: 1px solid var(--pl-paper-border); margin: 34px 0; }

/* Anchor link on headings */
.header-anchor { float: left; margin-left: -0.85em; padding-right: 0.25em; opacity: 0; border: 0 !important; color: var(--pl-orange) !important; font-weight: 400; }
.content :where(h2,h3):hover .header-anchor { opacity: 1; }

/* On-this-page contents box (Wikipedia-style) */
.content .page-toc {
  display: inline-block;
  min-width: 320px;
  max-width: 100%;
  margin: 22px 0;
  padding: 16px 20px 18px;
  background: var(--pl-page-faded);
  border: 1px solid var(--pl-paper-border);
  border-radius: var(--pl-radius-m);
}
.content .page-toc-title {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--pl-ink-faded);
}
.content .page-toc ol { margin: 0; padding: 0; list-style: none; }
.content .page-toc li {
  margin: 0; padding: 6px 0;
  border-top: 1px solid var(--pl-border-faint);
}
.content .page-toc li:first-child { border-top: 0; }
.content .page-toc a { border: 0; color: var(--pl-ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.content .page-toc a:hover { color: var(--pl-orange); }

/* Blockquotes → "Coming from P6" callouts */
.content blockquote {
  margin: 20px 0;
  padding: 14px 18px;
  background: var(--pl-orange-faint);
  border: 1px solid #f0dcc9;
  border-left: 3px solid var(--pl-orange);
  border-radius: var(--pl-radius-m);
  color: var(--pl-ink);
}
.content blockquote p { margin: 0; font-size: 14.5px; }
.content blockquote p + p { margin-top: 8px; }
.content blockquote em { font-style: italic; }

/* Tables */
.content .table-scroll { overflow-x: auto; margin: 20px 0; border: 1px solid var(--pl-paper-border); border-radius: var(--pl-radius-m); }
.content table { width: 100%; border-collapse: collapse; font-size: 14px; }
.content thead th {
  text-align: left; font-weight: 700; color: var(--pl-ink-heading);
  background: var(--pl-page-faded);
  padding: 10px 14px; border-bottom: 1px solid var(--pl-border);
  white-space: nowrap;
}
.content tbody td { padding: 10px 14px; border-bottom: 1px solid var(--pl-border-faint); vertical-align: top; }
.content tbody tr:last-child td { border-bottom: 0; }
.content tbody tr:nth-child(even) { background: var(--pl-page-faded); }

/* Code */
.content code {
  font-family: var(--pl-mono); font-size: 0.88em;
  background: var(--pl-orange-faint); color: #9a4a12;
  padding: 2px 6px; border-radius: var(--pl-radius-s);
  border: 1px solid #f0dcc9;
}
.content pre {
  background: var(--pl-navy); color: #eef2f6;
  padding: 16px 18px; border-radius: var(--pl-radius-m);
  overflow-x: auto; font-size: 13.5px; line-height: 1.5;
}
.content pre code { background: none; border: 0; color: inherit; padding: 0; }

/* Figures / images */
.content figure { margin: 24px 0; }
.content img {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--pl-paper-border);
  border-radius: var(--pl-radius-m);
  box-shadow: var(--pl-shadow-raised);
  background: var(--pl-paper);
}
.content figure figcaption,
.content img + em {
  display: block; margin-top: 9px;
  font-size: 12.5px; color: var(--pl-ink-faded); font-style: italic;
  text-align: center;
}

/* Prev / next footer */
.pager { max-width: var(--content-max); margin: 26px auto 0; display: flex; gap: 14px; }
.pager a {
  flex: 1; min-width: 0; text-decoration: none;
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 18px;
  background: var(--pl-page);
  border: 1px solid var(--pl-paper-border);
  border-radius: var(--pl-radius-m);
  box-shadow: var(--pl-shadow-raised);
  transition: border-color .15s;
}
.pager a:hover { border-color: var(--pl-orange); }
.pager a.next { text-align: right; align-items: flex-end; }
.pager .dir { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--pl-orange); }
.pager .label { font-size: 14.5px; font-weight: 600; color: var(--pl-ink-heading); }
.pager .spacer-cell { flex: 1; }

/* Home / index hero + cards */
.home-hero { max-width: var(--content-max); margin: 0 auto 26px; }
.home-hero h1 { font-size: 40px; font-weight: 700; letter-spacing: -0.025em; margin: 6px 0 10px; color: var(--pl-ink-heading); }
.home-hero .lede { font-size: 18px; color: var(--pl-ink-faded); max-width: 62ch; }
.home-hero .org { font-size: 13px; font-weight: 700; color: var(--pl-orange); letter-spacing: .02em; }
.card-grid { max-width: var(--content-max); margin: 0 auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card {
  text-decoration: none; color: inherit;
  background: var(--pl-page);
  border: 1px solid var(--pl-paper-border);
  border-radius: var(--pl-radius-l);
  box-shadow: var(--pl-shadow-raised);
  padding: 22px 22px 24px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--pl-orange); transform: translateY(-2px); }
.card .num {
  width: 34px; height: 34px; display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  color: var(--pl-orange); background: var(--pl-orange-faint);
  border: 1px solid #f0dcc9; border-radius: var(--pl-radius-m);
}
.card h3 { margin: 4px 0 0; font-size: 17px; font-weight: 700; color: var(--pl-ink-heading); }
.card p { margin: 0; font-size: 13.5px; color: var(--pl-ink-faded); line-height: 1.5; }
.card.wide { grid-column: 1 / -1; }

/* ---------- Login gate ------------------------------------ */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 120% at 50% -10%, var(--pl-orange-faint) 0%, var(--pl-paper) 46%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--pl-page);
  border: 1px solid var(--pl-paper-border);
  border-radius: var(--pl-radius-l);
  box-shadow: var(--pl-shadow-overlay);
  padding: 36px 34px 30px;
  text-align: center;
}
.login-logo { height: 26px; width: auto; margin: 0 auto 22px; display: block; }
.login-title { font-size: 22px; font-weight: 700; color: var(--pl-ink-heading); margin: 0 0 26px; }
.login-sub { font-size: 12.5px; color: var(--pl-orange); font-weight: 700; margin: 0 0 26px; }
.login-form { text-align: left; display: flex; flex-direction: column; gap: 7px; }
.login-form label { font-size: 12.5px; font-weight: 700; color: var(--pl-ink-faded); }
.login-form input[type="password"] {
  font: inherit; font-size: 15px;
  padding: 11px 13px;
  border: 1px solid var(--pl-border);
  border-radius: var(--pl-radius-m);
  background: var(--pl-page-faded);
  color: var(--pl-ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-form input[type="password"]:focus {
  border-color: var(--pl-orange);
  box-shadow: 0 0 0 3px rgba(229,117,40,.18);
  background: var(--pl-page);
}
.login-error { margin: 2px 0 0; font-size: 13px; color: var(--pl-critical); font-weight: 500; }
.login-form button {
  margin-top: 12px;
  font: inherit; font-size: 15px; font-weight: 700;
  color: #fff; background: var(--pl-orange);
  border: 0; border-radius: var(--pl-radius-m);
  padding: 12px 16px; cursor: pointer;
  transition: filter .15s;
}
.login-form button:hover { filter: brightness(1.05); }
.login-form button:active { filter: brightness(.95); }
.login-foot { margin: 22px 0 0; font-size: 12px; line-height: 1.5; color: var(--pl-ink-faded); }

/* ---------- Footer ---------------------------------------- */
.site-footer {
  border-top: 1px solid var(--pl-paper-border);
  background: var(--pl-page-faded);
  padding: 34px clamp(20px, 4vw, 56px) 40px;
}
.footer-inner {
  max-width: 1220px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
}
.footer-links a,
.footer-copyright {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  color: var(--pl-ink-faded);
}
.footer-copyright { color: var(--pl-ink); }
.footer-links a { border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
.footer-links a:hover { color: var(--pl-orange); border-bottom-color: rgba(229,117,40,.4); }
.footer-note {
  margin: 0;
  max-width: 951px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--pl-ink-faded);
}
.footer-certs { display: flex; align-items: center; gap: 20px; }
.footer-certs .cert { display: inline-flex; line-height: 0; }
.footer-certs img { display: block; height: auto; }

/* ---------- Cookie consent banner ------------------------- */
.cookie-banner {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 300;
  width: min(360px, calc(100vw - 36px));
  padding: 18px 18px 16px;
  background: var(--pl-page);
  border: 1px solid var(--pl-paper-border);
  border-radius: var(--pl-radius-l);
  box-shadow: var(--pl-shadow-overlay);
}
.cookie-banner[hidden] { display: none; }
.cookie-banner-title { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--pl-ink-heading); }
.cookie-banner-text { margin: 0 0 14px; font-size: 13px; line-height: 1.5; color: var(--pl-ink-faded); }
.cookie-banner-actions { display: flex; gap: 10px; }
.cookie-banner-actions button {
  flex: 1;
  font: inherit; font-size: 13.5px; font-weight: 700;
  padding: 9px 12px;
  border-radius: var(--pl-radius-m);
  cursor: pointer;
  transition: filter .15s, border-color .15s;
}
.cookie-accept { color: #fff; background: var(--pl-orange); border: 1px solid var(--pl-orange); }
.cookie-accept:hover { filter: brightness(1.05); }
.cookie-accept:active { filter: brightness(.95); }
.cookie-decline { color: var(--pl-ink); background: var(--pl-page); border: 1px solid var(--pl-border); }
.cookie-decline:hover { border-color: var(--pl-ink-faded); }

/* ---------- Responsive ------------------------------------ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .footer-certs { transform: scale(0.85); transform-origin: left center; }
  .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; margin-left: -6px;
    background: transparent; border: 1px solid var(--pl-border);
    border-radius: var(--pl-radius-s); color: var(--pl-ink); cursor: pointer;
  }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0;
    width: min(320px, 84vw); height: calc(100vh - var(--header-h));
    background: var(--pl-paper); z-index: 150;
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: var(--pl-shadow-overlay);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { display: none; position: fixed; inset: var(--header-h) 0 0; background: rgba(0,0,0,.35); z-index: 140; }
  body.nav-open .nav-scrim { display: block; }
  .card-grid { grid-template-columns: 1fr; }
}
