/* Boolean Functions for Cryptography — the Boolean Planet.
   Standalone stylesheet for the static site (no build framework).
   Palette: deep ink ground, a single teal accent, warm neutral panels.
   Type: Spectral (serif display) + Source Sans 3 (body) + JetBrains Mono (data). */

@import url('https://fonts.googleapis.com/css2?family=Spectral:wght@500;600;700&family=Source+Sans+3:wght@400;600&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --ink: #1a1d24;
  --page: #ffffff;
  --panel: #f5f6f8;
  --accent: #0f7b8a;
  --accent-dk: #0a5b66;
  --muted: #5b6470;
  --rule: #e3e6ea;
  --cyan: #6fd3df;
  --sans: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --serif: "Spectral", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.4rem;
}
main.container { padding-top: 2.2rem; padding-bottom: 3rem; }

/* ── Masthead (two-line header: centered title + nav row) ────────────────── */
.site-head {
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid var(--accent);
  text-align: center;
  padding: 0.75rem 1rem 0.6rem;
}
.site-head .masthead-title {
  display: inline-block;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: #fff;
  text-decoration: none;
}
.site-head .masthead-title:hover { color: #fff; }
.masthead-nav {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1.5rem;
}
.masthead-nav a.navlink {
  color: #c9cfd8;
  text-decoration: none;
  font-size: 0.9rem;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}
.masthead-nav a.navlink:hover { color: #fff; }
.masthead-nav a.navlink.active { color: #fff; border-bottom-color: var(--cyan); }

/* ── Headings & text ─────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--serif);
  letter-spacing: -0.01em;
  text-wrap: balance;
  line-height: 1.2;
}
h1 { font-size: 2.1rem; font-weight: 700; margin: 0 0 1rem; }
h2 { font-size: 1.5rem; font-weight: 600; margin: 2.4rem 0 0.8rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.18rem; font-weight: 600; margin: 1.8rem 0 0.6rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent-dk); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }
strong { font-weight: 600; }

/* ── Hero (home) ─────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(160deg, #1a1d24 0%, #232838 100%);
  color: #f4f6f8;
  border-radius: 14px;
  padding: 3rem 2.4rem;
  margin: 0.5rem 0 2.4rem;
  position: relative;
  overflow: hidden;
}
.hero .tagline {
  font-family: var(--mono);
  color: var(--cyan);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin-bottom: 0.6rem;
}
.hero h1 { font-size: 2.6rem; margin: 0 0 0.8rem; color: #fff; }
.hero p { color: #c9cfd8; max-width: none; margin-bottom: 0; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.hero::after {
  content: "0110 1000 0110 0001 0110 0110 0111 0101 0110 1100 0110 1100 0110 0101 0111 0010";
  position: absolute;
  right: -1%; bottom: -0.6rem;
  font-family: var(--mono);
  font-size: 3rem;
  line-height: 1.15;
  color: rgba(111, 211, 223, 0.06);
  white-space: pre-wrap;
  width: 42%;
  pointer-events: none;
  user-select: none;
}

/* ── Property cards ──────────────────────────────────────────────────────── */
.prop-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
  margin: 1.6rem 0;
}
.prop-cards .card {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}
.prop-cards .num {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent-dk);
  font-variant-numeric: tabular-nums;
}
.prop-cards .lbl {
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.2rem;
}

/* ── Lists ───────────────────────────────────────────────────────────────── */
ul { padding-left: 1.2rem; }
li { margin: 0.35rem 0; }

/* ── Definition-style entries (publications) ─────────────────────────────── */
.entry { margin: 0 0 1.6rem; }
.entry .ref-title { font-weight: 600; }
.entry .ref-meta { color: var(--muted); }
.entry .ref-note { margin-top: 0.4rem; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; margin: 1.2rem 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.94rem;
  font-variant-numeric: tabular-nums;
}
th, td { padding: 0.4rem 0.7rem; text-align: left; border-bottom: 1px solid var(--rule); }
thead th { border-bottom: 2px solid var(--accent); white-space: nowrap; }
td.num, th.num { text-align: right; }
table code { font-family: var(--mono); background: none; padding: 0; color: var(--accent-dk); }

/* ── Code ────────────────────────────────────────────────────────────────── */
code { font-family: var(--mono); font-size: 0.9em; background: var(--panel); padding: 0.1em 0.35em; border-radius: 4px; }
pre {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }

/* ── Callout ─────────────────────────────────────────────────────────────── */
.callout-note {
  background: #eef6f8;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  margin: 1.4rem 0;
}
.callout-note p:last-child { margin-bottom: 0; }

/* ── Class connection diagrams (SVG trees) ───────────────────────────────── */
.diagram-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 1.5rem 2.5rem;
  margin: 1.6rem 0 0.6rem;
}
.diagram { margin: 0; text-align: center; }
.diagram svg { max-width: 100%; height: auto; }
.diagram figcaption { color: var(--muted); font-size: 0.86rem; margin-top: 0.5rem; }
.diagram .edge { stroke: #b9c0c9; stroke-width: 2; }
.diagram .node circle { fill: #eef0f3; stroke: var(--muted); stroke-width: 1.5; }
.diagram .node text { fill: var(--ink); font-family: var(--mono); font-size: 13px; text-anchor: middle; }
.diagram .root circle { fill: #ffffff; stroke: var(--accent); stroke-width: 2.5; }
.diagram .bent circle { fill: var(--accent); stroke: var(--accent-dk); stroke-width: 2; }
.diagram .bent text { fill: #ffffff; }
.diagram .nl-axis { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.diagram-legend { text-align: center; color: var(--muted); font-size: 0.85rem; margin-bottom: 1rem; }
.diagram-legend .key {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  vertical-align: middle; margin: 0 0.3rem 0 1.1rem;
}
.diagram-legend .key.root { background: #fff; border: 2px solid var(--accent); }
.diagram-legend .key.bent { background: var(--accent); border: 2px solid var(--accent-dk); }

/* ── Resources page ──────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.res-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-dk);
  background: #e3f1f3;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  vertical-align: middle;
}
.res-note { color: var(--muted); font-size: 0.92em; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.88rem;
}
.site-footer .foot-inner {
  max-width: 900px; margin: 0 auto; padding: 1.4rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
}

/* ── Focus & motion ──────────────────────────────────────────────────────── */
a:focus-visible, .navlink:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

@media (max-width: 560px) {
  .hero { padding: 2rem 1.4rem; }
  .hero h1 { font-size: 2rem; }
  .hero::after { display: none; }
}

/* collapsible data tables */
main details { margin: 1.2rem 0; border: 1px solid var(--rule); border-radius: 6px; padding: 0.6rem 0.9rem; }
main details summary { cursor: pointer; color: var(--accent-dk); }
main details[open] summary { margin-bottom: 0.6rem; }

/* ── Class Graph Explorer ────────────────────────────────────────────────── */
.gx-controls { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; margin: 1.2rem 0 0.8rem; }
.gx-controls button, .gx-controls select {
  font: inherit; font-size: 0.9rem; padding: 0.35rem 0.75rem; border-radius: 6px;
  border: 1px solid var(--rule); background: #fff; color: var(--ink); cursor: pointer;
}
.gx-controls label { font-size: 0.9rem; color: var(--muted); display: flex; gap: 0.4rem; align-items: center; }
.gx-seg { display: inline-flex; }
.gx-seg button { border-radius: 0; margin-left: -1px; }
.gx-seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.gx-seg button:last-child { border-radius: 0 6px 6px 0; }
.gx-seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.gx-primary { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.gx-controls button:focus-visible, .gx-controls select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.gx-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .gx-wrap { grid-template-columns: minmax(0, 1fr); } }
.gx-canvas { border: 1px solid var(--rule); border-radius: 8px; background: #fbfcfd; padding: 0.5rem; }
#gx-svg { width: 100%; height: auto; display: block; }
.gx-axis line { stroke: #eceff2; stroke-width: 1; }
.gx-axis text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.gx-links line { stroke: #c3c9d0; stroke-width: 1.3; transition: opacity .2s, stroke .2s; }
.gx-node { cursor: pointer; outline: none; }
.gx-node circle { stroke: #fff; stroke-width: 1.5; transition: opacity .2s, stroke .2s; }
.gx-node text { fill: var(--ink); font-size: 11px; font-family: var(--mono); text-anchor: middle; pointer-events: none; transition: opacity .2s; }
.gx-node:focus-visible circle, .gx-node.is-focus circle { stroke: var(--ink); stroke-width: 3; }
#gx-svg.gx-has-focus .gx-node:not(.is-focus):not(.is-nb) { opacity: 0.25; }
#gx-svg.gx-has-focus .gx-links line { opacity: 0.12; }
#gx-svg.gx-has-focus .gx-links line.is-on { opacity: 1; stroke: var(--accent); stroke-width: 2.5; }
#gx-svg.gx-climbing .gx-node:not(.is-visited) { opacity: 0.35; }
#gx-svg.gx-climbing .gx-links line { opacity: 0.25; }
#gx-svg.gx-climbing .gx-links line.is-path { opacity: 1; stroke: #e7298a; stroke-width: 3.5; }
.gx-node.is-here circle { stroke: #e7298a; stroke-width: 4; }

.gx-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: 0.8rem; color: var(--muted); padding: 0.4rem 0.3rem 0; }
.gx-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 0.35rem; vertical-align: -1px; }
.gx-size-key { margin-left: auto; font-style: italic; }

.gx-info { border: 1px solid var(--rule); border-radius: 8px; padding: 0.9rem 1rem; font-size: 0.88rem; background: #fff; min-height: 200px; }
.gx-info h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.gx-info h4 { margin: 0.9rem 0 0.4rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.gx-info dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.7rem; margin: 0; }
.gx-info dt { color: var(--muted); }
.gx-info dd { margin: 0; overflow-wrap: anywhere; }
.gx-info code { font-size: 0.8rem; }
.gx-hint, .gx-muted { color: var(--muted); }
.gx-flips { list-style: none; padding: 0; margin: 0; }
.gx-flips li { display: grid; grid-template-columns: 4.6rem 1fr auto; gap: 0.4rem; align-items: center; margin: 0.2rem 0; font-size: 0.82rem; }
.gx-flips li > :last-child { grid-column: 2 / 4; }
.gx-flips button { font: inherit; font-size: 0.82rem; border: none; background: none; color: var(--accent-dk); text-decoration: underline; cursor: pointer; padding: 0; text-align: left; }
.gx-bar { height: 7px; background: var(--panel); border-radius: 4px; overflow: hidden; }
.gx-bar i { display: block; height: 100%; background: var(--accent); }
.gx-dir { color: var(--muted); margin-left: 0.3rem; }

.gx-log { font-size: 0.86rem; margin: 0.8rem 0 0; padding-left: 1.4rem; max-height: 16rem; overflow: auto; }
.gx-log li { margin: 0.15rem 0; }
.gx-log .gx-end { list-style: none; margin-left: -1.4rem; font-weight: 600; color: var(--accent-dk); margin-top: 0.4rem; }

/* ── Function Analyser ───────────────────────────────────────────────────── */
.fa-box { border: 1px solid var(--rule); border-radius: 8px; padding: 1rem; background: #fbfcfd; margin: 1.2rem 0; }
.fa-box label { font-weight: 600; display: block; margin-bottom: 0.4rem; }
.fa-box textarea { width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: 0.9rem; padding: 0.5rem; border: 1px solid var(--rule); border-radius: 6px; resize: vertical; }
.fa-box textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fa-actions { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; margin-top: 0.6rem; }
.fa-actions button { font: inherit; font-size: 0.85rem; padding: 0.3rem 0.7rem; border-radius: 6px; border: 1px solid var(--rule); background: #fff; color: var(--ink); cursor: pointer; }
.fa-help { font-size: 0.82rem; color: var(--muted); margin: 0.6rem 0 0; }
.fa-muted { color: var(--muted); font-size: 0.85rem; }
.fa-error { color: #b42318; font-weight: 600; }
.fa-props { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
.fa-props dt { color: var(--muted); }
.fa-props dd { margin: 0; overflow-wrap: anywhere; }
.fa-anf { font-family: var(--mono); font-size: 0.88rem; }
@media (max-width: 560px) { .fa-props { grid-template-columns: 1fr; } .fa-props dd { margin-bottom: 0.4rem; } }

/* ── AES linear redundancy demo ──────────────────────────────────────────── */
.aes-demo { border: 1px solid var(--rule); border-radius: 8px; padding: 0.9rem 1rem; background: #fbfcfd; margin: 1.2rem 0; }
.aes-demo button { font: inherit; font-size: 0.9rem; padding: 0.35rem 0.8rem; border-radius: 6px; border: 1px solid var(--rule); background: #fff; color: var(--ink); cursor: pointer; margin-right: 0.4rem; }
.aes-demo table code { font-size: 0.78rem; }

/* ── Drop-down menu groups ───────────────────────────────────────────────── */
.navgroup { position: relative; display: inline-block; }
.navgroup { margin: 0; border: 0; padding: 0; }
.navgroup > summary { list-style: none; cursor: pointer; display: inline; margin: 0;
  color: #c9cfd8; font-size: 0.9rem; padding-bottom: 3px; border-bottom: 2px solid transparent; }
.navgroup > summary:hover { color: #fff; }
.navgroup > summary.active { color: #fff; border-bottom-color: var(--cyan); }
.navgroup > summary::-webkit-details-marker { display: none; }
.navgroup > summary::after { content: " ▾"; font-size: 0.75em; opacity: 0.8; }
.navgroup[open] > summary { color: #fff; }
.navmenu {
  position: absolute; top: calc(100% + 0.45rem); left: 50%; transform: translateX(-50%);
  background: var(--ink); border: 1px solid #3a4150; border-top: 2px solid var(--accent);
  border-radius: 0 0 8px 8px; padding: 0.4rem 0; min-width: 14rem; z-index: 30;
  display: flex; flex-direction: column; text-align: left; box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.navmenu a { color: #c9cfd8; text-decoration: none; font-size: 0.9rem; padding: 0.45rem 1rem; white-space: nowrap; }
.navmenu a:hover, .navmenu a:focus-visible { background: #2a3040; color: #fff; outline: none; }
.navmenu a[aria-current="page"] { color: #fff; border-left: 3px solid var(--cyan); padding-left: calc(1rem - 3px); }
.navgroup > summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 2px; }
