/* The look of the hilbert6 website, tutorial and reference manual (web/, built with Verso and
 * verso-web-components) on the web blueprint. Loaded after plasTeX's theme-white.css,
 * leanblueprint's and plastexdepgraph's stylesheets (`extra-css` in plastex.cfg).
 *
 * 1. Design tokens: the website's, with its deep-teal accent and its dark theme.
 * 2. The website header (markup in webtheme/site-header.html), with the measurements of the
 *    website's `Site.headerCss` and verso-web-components' navbar.css.
 * 3. Page: fonts, colours, table of contents, text column, headings and links.
 * 4. Theorem, definition and proof boxes, and the Lean declarations dialog.
 * 5. The dependency graph page.
 *
 * The status colours of the dependency graph (leanblueprint) are drawn into the graph itself and
 * are not changed here. */

/* ── 1. Design tokens ───────────────────────────────────────────────────────── */

:root {
  --color-six: #e11d48;
  --font-primary: 'Open Sans', Arial, sans-serif;
  --font-code: 'Fira Code', monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 2rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-md: 0.5rem;
  --container-width: 1240px;
  --transition-base: 0.3s;
  --site-header-height: 4.5rem;
  --toc-width: 18rem;
  --text-width: 47rem;

  --color-surface: #fff;
  --color-primary: #0f766e;
  --color-primary-light: #14b8a6;
  --color-secondary: #607D8B;
  --color-text: #333;
  --color-text-light: #64748b;
  --color-bg: #F9FBFD;
  --color-bg-translucent: rgba(249, 251, 253, 0.81);
  --color-border: #E4EBF3;
  --color-border-nav: #E4EBF3;
  --color-border-light: #D1D9E2;
  --color-hover: rgba(15, 118, 110, 0.08);
  --color-active: rgba(15, 118, 110, 0.12);
  --color-link: var(--color-primary);
  --color-link-hover: #0d9488;
  --color-shadow: rgba(35, 55, 139, 0.1);
  --card-bg: #fff;
  --code-bg: #f3f6f9;
}

.dark-theme {
  --color-six: #fb7185;
  --color-surface: #121212;
  --color-primary: #0d9488;
  --color-primary-light: #5eead4;
  --color-secondary: #aabfc9;
  --color-text: #eee;
  --color-text-light: #bbb;
  --color-bg: #181818;
  --color-bg-translucent: rgba(24, 24, 24, 0.85);
  --color-border: #333;
  --color-border-nav: #333;
  --color-border-light: #444;
  --color-hover: rgba(45, 212, 191, 0.14);
  --color-active: rgba(45, 212, 191, 0.16);
  --color-link: #5eead4;
  --color-link-hover: #5eead4;
  --color-shadow: rgba(0, 0, 0, 0.5);
  --card-bg: #1f1f1f;
  --code-bg: #262626;
}

html { color-scheme: light; }
html.dark-theme { color-scheme: dark; }

/* ── 2. The website header ──────────────────────────────────────────────────── */

body > header.site-header {
  display: flex; flex-shrink: 0; align-items: center; box-sizing: border-box;
  height: var(--site-header-height); margin: 0; padding: 0; box-shadow: none; text-shadow: none;
  position: relative; z-index: 1000; justify-content: flex-start;
  background-color: var(--color-bg-translucent); color: var(--color-text);
  border-bottom: 1px solid var(--color-border-nav);
  font-family: var(--font-primary); font-size: 1rem; font-weight: 400; line-height: 1.2;
}
header.site-header * { box-sizing: border-box; }
header.site-header .navbar {
  display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1;
  flex: 1; min-width: 0; height: 100%; padding: 0 var(--space-8); border-bottom: 0;
}
header.site-header .navbar-container.container {
  display: flex; justify-content: space-between; align-items: center;
  max-width: min(var(--container-width), 100vw); width: 100%; margin: 0 auto; padding: 0 var(--space-4);
}
header.site-header ul, header.site-header menu, header.site-header li {
  margin: 0; padding: 0; list-style: none; font-size: inherit;
}
header.site-header button { background: none; border: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; }
header.site-header a, header.site-header a:visited { text-decoration: none; }
header.site-header .nav-logo.wordmark {
  display: flex; align-items: center; color: var(--color-text);
  font-family: var(--font-primary); font-size: 1.4rem; font-weight: 600; line-height: 1.2;
  letter-spacing: 0.01em; margin: 0 var(--space-6) 0 0; padding: 0;
}
header.site-header .nav-logo.wordmark:hover { color: var(--color-primary); }
header.site-header .wordmark-six { color: var(--color-six); }
header.site-header .desktop-menu {
  display: flex; justify-content: space-between; align-items: center; width: 100%; gap: var(--space-6);
}
header.site-header .desktop-menu-part { display: flex; align-items: center; gap: var(--space-2); }
header.site-header .nav-item { display: flex; align-items: center; }
header.site-header .nav-link {
  display: flex; align-items: center; justify-content: center; gap: 10px; position: relative;
  color: var(--color-text); background: transparent; border: none; border-radius: var(--radius-md);
  font-family: var(--font-primary); font-size: 0.9rem; font-weight: 500; line-height: 1.2;
  padding: var(--space-3) var(--space-4); margin: 0; white-space: nowrap; cursor: pointer;
  transition: all var(--transition-base);
}
header.site-header .nav-link::before {
  content: ''; position: absolute; inset: 0; z-index: -1; border-radius: var(--radius-md);
  background: var(--color-hover); opacity: 0; transition: opacity var(--transition-base);
}
header.site-header .nav-link:hover { color: var(--color-primary); }
header.site-header .nav-link:hover::before { opacity: 1; }
header.site-header .nav-link svg { width: 20px; height: 20px; }
header.site-header .nav-item.active .nav-link { background-color: var(--color-active); color: var(--color-primary); }
.dark-theme header.site-header .nav-link svg { fill: var(--color-text); stroke: var(--color-text); }
.dark-theme header.site-header .nav-item.active .nav-link,
.dark-theme header.site-header .nav-link:hover { color: #5eead4; }

/* Narrow screens: the navigation button and, beside it, the table-of-contents button */
header.site-header .nav-toggle { display: none; align-items: center; }
header.site-header .nav-toggle-checkbox { display: none; }
header.site-header .nav-toggle-label {
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: var(--fs-xl); line-height: 1.2; padding: var(--space-3); color: var(--color-text);
}
header.site-header .toc-toggle-button { display: flex; align-items: center; padding: var(--space-3); color: var(--color-text); }
header.site-header .toc-toggle-button svg { width: 1.25rem; height: 1.25rem; }
body:not(:has(nav.toc)) header.site-header .toc-toggle-button { display: none; }
header.site-header .mobile-nav {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background-color: var(--color-bg); border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-8);
}
header.site-header .mobile-nav .nav-list { display: flex; flex-direction: column; width: 100%; }
header.site-header .mobile-nav .nav-item { margin: var(--space-1) 0; width: 100%; }
header.site-header .mobile-nav .nav-link { width: 100%; justify-content: flex-start; padding: var(--space-2) var(--space-4); }

header.site-header .desktop-menu .nav-link { padding-left: var(--space-2); padding-right: var(--space-2); }
@media (max-width: 1150px) { header.site-header .navbar { padding: 0 var(--space-2); } }
@media (max-width: 1024px) {
  body > header.site-header { background-color: var(--color-bg); }
  header.site-header .desktop-menu { display: none; }
  header.site-header .nav-toggle { display: flex; }
  header.site-header .navbar:has(.nav-toggle-checkbox:checked) .mobile-nav { display: block; }
}
@media (max-width: 768px) {
  header.site-header .navbar { padding: 0 var(--space-2); }
}

/* ── 3. Page ────────────────────────────────────────────────────────────────── */

body {
  font-family: var(--font-primary); color: var(--color-text); background-color: var(--color-surface);
}
h1, h2, h3, h4, h5, h6 { font-family: var(--font-primary); color: var(--color-text); font-weight: 600; }
code, kbd, pre, samp, .texttt, .ttfamily, code.verb { font-family: var(--font-code); font-size: 0.9em; }
::selection { color: #fff; background: var(--color-primary); }

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

/* Table of contents */
nav.toc {
  background-color: var(--color-bg); border-right: 1px solid var(--color-border);
  margin-right: 0; padding: 0 0 var(--space-8);
}
@media (min-width: 1024px) {
  nav.toc { width: var(--toc-width); max-width: var(--toc-width); }
}
nav.toc a.toc-title {
  display: block; padding: var(--space-6) var(--space-2) var(--space-2) 0.8rem; text-decoration: none;
  color: var(--color-text); font-size: var(--fs-lg); font-weight: 600; line-height: 1.3;
}
nav.toc a.toc-title:hover { color: var(--color-primary); }
.toc ul { font-size: var(--fs-base); }
.toc ul li, .toc ul li.current { background-color: transparent; font-weight: 400; }
.toc ul a {
  color: var(--color-text); font-size: var(--fs-base); line-height: 1.35;
  padding-top: 0.35rem; padding-bottom: 0.35rem; border-radius: var(--radius-md);
}
.toc ul a:hover { background: var(--color-hover); color: var(--color-primary); }
.toc ul li.current > a { color: var(--color-primary); font-weight: 600; }
.toc ul li.active > a { font-weight: 600; }
.toc ul ul a { font-size: var(--fs-sm); }
span.expand-toc { color: var(--color-text-light); font-size: 75%; }
span.toc_ref { color: var(--color-text-light); }

/* Text column: as in the books, centred in the space beside the table of contents */
div.content { padding: var(--space-6); line-height: 1.45; }
div.content-wrapper { max-width: var(--text-width); margin-left: auto; margin-right: auto; }
@media (min-width: 1024px) {
  div.content { padding: var(--space-6) var(--space-6) var(--space-8); }
}
div.content > p, div.main-text p { margin: var(--space-4) 0; }
ol, ul { font-size: var(--fs-base); }
li > p { margin: 0.25rem 0; }

div.main-text h1 { font-size: 2.3rem; line-height: 1.25; margin: var(--space-6) 0 1.3rem; }
div.main-text h2 { font-size: 1.7rem; line-height: 1.3; margin: var(--space-8) 0 var(--space-4); }
div.main-text h3 { font-size: 1.4rem; line-height: 1.4; margin: var(--space-6) 0 var(--space-2); }
div.main-text h4 { font-size: 1.15rem; line-height: 1.4; margin: var(--space-6) 0 var(--space-2); }
.titlepage h1 { font-weight: 600; }
.titlepage .author { color: var(--color-text-light); }

ul.breadcrumbs { color: var(--color-text-light); font-size: var(--fs-sm); margin-bottom: var(--space-2); }
ul.breadcrumbs a { color: var(--color-text-light); }
ul.breadcrumbs a:hover { color: var(--color-primary); }

.local_toc ul a { color: var(--color-text); }
.local_toc ul a:hover { color: var(--color-primary); }

pre.verbatim { background-color: var(--code-bg); border-radius: var(--radius-md); }
table, .tabular { background-color: transparent; color: var(--color-text); }
footer#footnotes { border-color: var(--color-border); }
footer#footnotes h1 { color: var(--color-text); }

/* Previous / up / next and the show-more buttons, bottom right */
nav.prev_up_next {
  background: var(--color-bg); border: 1px solid var(--color-border); border-right: 0; border-bottom: 0;
  border-top-left-radius: var(--radius-md);
}
nav.prev_up_next a, nav.prev_up_next svg.showmore { color: var(--color-text); text-shadow: none; }
nav.prev_up_next a:hover, nav.prev_up_next svg.showmore:hover { color: var(--color-primary); }

/* A target (followed link) flashes in the accent colour */
@keyframes hilbert6-target { from { background-color: var(--color-active); } to { background-color: transparent; } }
div[class*=_thmwrapper]:target, div.hilite { animation: hilbert6-target 1s ease; }

/* ── 4. Theorem, definition and proof boxes ─────────────────────────────────── */

/* plasTeX gives a box the classes `<kind>_thmwrapper theorem-style-<style>` */
div[class*=_thmwrapper] {
  margin: var(--space-6) 0; background: var(--card-bg);
  border: 1px solid var(--color-border-light); border-left: 4px solid var(--color-secondary);
  border-radius: var(--radius-md);
}
div.theorem_thmwrapper, div.proposition_thmwrapper, div.lemma_thmwrapper, div.corollary_thmwrapper {
  border-left-color: var(--color-primary);
}
div[class$=_thmheading] {
  align-items: baseline; flex-wrap: wrap; gap: 0 0.1rem; line-height: 1.5;
  padding: var(--space-2) var(--space-4); background: var(--color-bg);
  border-bottom: 1px solid var(--color-border); border-top-right-radius: var(--radius-md);
}
span[class$=_thmcaption] { color: var(--color-text); }
div[class$=_thmcontent] { margin-left: 0; padding: var(--space-2) var(--space-4); }
div[class$=_thmcontent] > p:first-child { margin-top: var(--space-2); }
div[class$=_thmcontent] > p:last-child { margin-bottom: var(--space-2); }

/* The status mark (\leanok, \mathlibok) and the hover links (#, L∃∀N, uses) after the heading */
div.thm_header_extras { margin-left: var(--space-2); color: var(--color-primary); }
div.thm_header_hidden_extras { margin-left: var(--space-2); font-weight: 400; }
div.thm_header_hidden_extras a.icon, div.thm_header_hidden_extras a { color: var(--color-text-light); }
div.thm_header_hidden_extras a:hover { color: var(--color-primary); }
button.modal {
  color: var(--color-primary); font-family: var(--font-primary); font-size: var(--fs-sm); font-weight: 600;
  padding: 0 var(--space-2); border-radius: var(--radius-md);
}
button.modal:hover { background: var(--color-hover); }
a.github_link { color: var(--color-text-light); }

/* Proofs */
div[class$=proof_heading] { margin-top: var(--space-4); color: var(--color-text); }
div.proof_content { margin-left: var(--space-2); padding: var(--space-2) var(--space-4); border-left: 2px solid var(--color-border-light); }
span.expand-proof { color: var(--color-text-light); }

/* The dialogs (Lean declarations, uses) */
div.modal-content {
  background-color: var(--card-bg); color: var(--color-text); border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md); box-shadow: 0 6px 18px var(--color-shadow);
}
div.modal-content header {
  background: var(--color-bg); color: var(--color-text); border-bottom: 1px solid var(--color-border);
  border-top-left-radius: var(--radius-md); border-top-right-radius: var(--radius-md);
}
div.modal-content header h1 { color: var(--color-text); font-weight: 600; }
div.modal-content header button.closebtn { color: var(--color-text); }
div.modal-content a, a.lean_decl { color: var(--color-link); }
ul.uses a.lean_decl, ul.tooltip_list a.lean_decl { font-family: var(--font-code); font-size: 0.9em; }

/* ── 5. Dependency graph page ───────────────────────────────────────────────── */

body:has(div#graph) div.wrapper { flex-direction: column; }
body:has(div#graph) div.content { padding: var(--space-4) var(--space-8) 0; overflow: hidden; margin-bottom: 0; }
body:has(div#graph) h1#doc_title {
  position: static; margin: 0 0 var(--space-2); color: var(--color-text);
  font-size: var(--fs-xl); font-weight: 600; line-height: 1.2;
}
#Legend span.title { font-size: var(--fs-lg); font-weight: 600; align-items: center; color: var(--color-text); }
#Legend div.bar { background: var(--color-text); }
#Legend dl {
  top: calc(var(--site-header-height) + 6.5rem); left: var(--space-8); z-index: 2; font-size: var(--fs-base);
  padding: var(--space-4); background: var(--card-bg); color: var(--color-text);
  border: 1px solid var(--color-border-light); border-radius: var(--radius-md); box-shadow: 0 6px 18px var(--color-shadow);
}
/* The graph keeps a white canvas in both themes, so that its status colours read as in the legend */
div#graph {
  height: calc(100vh - var(--site-header-height) - 7rem); margin-top: var(--space-2);
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
div#statements { background-color: var(--color-bg); color: var(--color-text); border-top: 1px solid var(--color-border); }
div.dep-modal-content {
  background-color: var(--card-bg); color: var(--color-text); border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md); box-shadow: 0 6px 18px var(--color-shadow);
}
div.dep-modal-container { margin-top: calc(var(--site-header-height) + var(--space-4)); }
div.dep-modal-content a, div.dep-modal-content .tooltip { color: var(--color-link); }
ul.tooltip_list {
  background-color: var(--card-bg); border: 1px solid var(--color-border-light); border-radius: var(--radius-md);
  box-shadow: 0 6px 18px var(--color-shadow);
}
button.dep-closebtn { color: var(--color-text); }
