/* The Pentametric Cycle — shared styles */
:root {
  --bg: #f7f4ee;
  --panel: #fffdf9;
  --ink: #1f1f1f;
  --muted: #5f5b55;
  --rule: #ddd6ca;
  --accent: #2b5d8a;      /* octave blue, Fibonacci squares */
  --accent2: #b4532a;     /* fifth rust, Holden geometry */
  --c0: #d9d9d9;          /* silence */
  --c1: #4f7cac;          /* unison */
  --c2: #2b5d8a;          /* octave */
  --c3: #b4532a;          /* fifth */
  --c4: #d99a5b;          /* fourth */
  --fill: #e9eef4;
  --ok: #2e7d4f;
  --accent3: #6b5a9e;     /* exploratory */
  --c5: var(--accent3);   /* the silence read as 5 (major third 5:4) */
  --accent4: #9a6b12;     /* exotic */
  --accent5: #2e7d73;     /* library */
  /* mirror pairs (an interval and its inversion), Lluis's colours from his study of the matrix and Coltrane's circle */
  --p0: #f3d55b; --p1: #8db8ec; --p2: #f2bb86; --p3: #cfa0e6; --p4: #f08f8f; --p5: #9fd69a; --p6: #d0cdc8;
  --serif: "EB Garamond", "Garamond", "Georgia", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Consolas", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17161a; --panel: #201f24; --ink: #ece8e1; --muted: #a8a29a; --rule: #38363c;
    --accent: #7fa8d4; --accent2: #e08a5e; --c0: #4a4950; --c1: #7fa8d4; --c2: #4f86c0;
    --c3: #e08a5e; --c4: #e8b77f; --fill: #26303b; --ok: #6cc391; --accent3: #b3a2e0; --accent4: #e0b45c; --accent5: #6cc3b5;
    --p0: #8f7a1f; --p1: #2f5f93; --p2: #94602c; --p3: #6d4088; --p4: #923838; --p5: #3d7a39; --p6: #55535a;
  }
}
:root[data-theme="dark"] {
  --bg: #17161a; --panel: #201f24; --ink: #ece8e1; --muted: #a8a29a; --rule: #38363c;
  --accent: #7fa8d4; --accent2: #e08a5e; --c0: #4a4950; --c1: #7fa8d4; --c2: #4f86c0;
  --c3: #e08a5e; --c4: #e8b77f; --fill: #26303b; --ok: #6cc391; --accent3: #b3a2e0; --accent4: #e0b45c; --accent5: #6cc3b5;
    --p0: #8f7a1f; --p1: #2f5f93; --p2: #94602c; --p3: #6d4088; --p4: #923838; --p5: #3d7a39; --p6: #55535a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--sans); font-size: 16px; line-height: 1.55; }
a { color: var(--accent); }
.greek { font-family: var(--serif); }
header.site {
  border-bottom: 1px solid var(--rule); background: var(--panel);
}
header.site .inner, main, footer.site .inner { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
header.site .inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
header.site .brand { font-family: var(--serif); font-size: 1.35rem; text-decoration: none; color: var(--ink); }
header.site .brand .greek { white-space: nowrap; }
header.site .brand-en { font-family: var(--serif); font-size: 1.05rem; color: var(--muted); white-space: nowrap; }
header.site .brand-sep { color: var(--muted); }
@media (max-width: 600px) { header.site .brand-en { display: block; margin: 0; } header.site .brand-sep { display: none; } }
.kind { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; margin: 0 6px 6px 0; }
.kind.u { color: var(--accent); border: 1px solid var(--accent); }
.kind.p { color: var(--accent2); border: 1px solid var(--accent2); }
.kind.e { color: var(--accent3); border: 1px solid var(--accent3); }
.kind.x { color: var(--accent4); border: 1px solid var(--accent4); }
.kind.l { color: var(--accent5); border: 1px solid var(--accent5); }
.kind + h1 { margin-top: 4px; }
main { padding-top: 28px; padding-bottom: 40px; }
h1 { font-family: var(--serif); font-weight: 500; font-size: 2.2rem; line-height: 1.15; margin: 0 0 6px; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 1.45rem; margin: 30px 0 8px; }
.lede { color: var(--muted); max-width: 70ch; margin: 0 0 22px; font-size: 1.05rem; }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 820px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 0 0 12px; }
.controls label { display: inline-block; font-size: .95rem; }
.controls label > input, .controls label > select { vertical-align: middle; margin: 0 6px 0 0; }
.controls label > output { margin-left: 6px; font-family: var(--mono); }
input[type="range"] { accent-color: var(--accent2); width: 180px; max-width: 100%; }
input[type="number"], select {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--rule);
  border-radius: 6px; padding: 5px 8px;
}
input[type="number"] { width: 9ch; }
button {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--rule);
  border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
button.primary { background: var(--accent2); color: #fff; border-color: var(--accent2); }
button:hover { border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 3px 9px; font-size: .9rem; }
table.data { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { font-weight: 600; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); font-size: .9rem; }
.scroll-x { overflow-x: auto; }
.readout { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .95rem; }
.readout dt { color: var(--muted); }
.readout dd { margin: 0; font-family: var(--mono); font-size: .9rem; }
.note { color: var(--muted); font-size: .9rem; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; border: 1px solid var(--rule); color: var(--muted); }
.tag.proved { border-color: var(--ok); color: var(--ok); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .9rem; color: var(--muted); }
.legend > span { display: inline-block; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: -1px; margin-right: 6px; }
svg { display: block; width: 100%; height: auto; }
svg text { font-family: var(--sans); fill: var(--ink); }
.ok { color: var(--ok); font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.card { display: block; text-decoration: none; color: var(--ink); background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 16px; }
.card:hover { border-color: var(--accent2); }
.card h3 { font-family: var(--serif); font-weight: 500; font-size: 1.25rem; margin: 8px 0 4px; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }
footer.site { border-top: 1px solid var(--rule); color: var(--muted); font-size: .88rem; }
footer.site .inner { padding-top: 16px; padding-bottom: 24px; }
.formula { font-family: var(--serif); font-size: 1.35rem; text-align: center; margin: 6px 0 14px; }

/* ---- navigation: a drawer that opens from the right ---- */
header.site { position: sticky; top: 0; z-index: 20; }
.menu-toggle { flex: none; font-size: .95rem; padding: 6px 14px; }
.menu-toggle .mt-close { display: none; }
body.menu-open .menu-toggle .mt-open { display: none; }
body.menu-open .menu-toggle .mt-close { display: inline; }
.nav-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.28); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
body.menu-open .nav-scrim { opacity: 1; pointer-events: auto; }
nav.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100vw); z-index: 40;
  background: var(--panel); border-left: 1px solid var(--rule); box-shadow: -8px 0 24px rgba(0,0,0,.12);
  transform: translateX(100%); transition: transform .22s ease; overflow-y: auto; padding: 16px 16px 32px;
  visibility: hidden;
}
body.menu-open nav.drawer { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer-head .t { font-family: var(--serif); font-size: 1.15rem; }
.drawer a { text-decoration: none; color: var(--ink); }
.drawer .home { display: block; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.drawer .home:hover, .drawer .home[aria-current="page"] { background: var(--bg); }
.drawer details { border: 1px solid var(--rule); border-radius: 8px; margin: 0 0 10px; }
.drawer summary { list-style: none; cursor: pointer; padding: 10px 12px; border-left: 4px solid var(--rule); border-radius: 8px; }
.drawer summary::-webkit-details-marker { display: none; }
.drawer summary .sec { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.drawer summary .sec::after { content: "▸"; color: var(--muted); transition: transform .15s; margin-left: auto; }
.drawer details[open] summary .sec::after { transform: rotate(90deg); }
.drawer summary .desc { display: block; font-size: .85rem; color: var(--muted); margin-top: 2px; }
.drawer details.u summary { border-left-color: var(--accent); } .drawer details.u .sec { color: var(--accent); }
.drawer details.e summary { border-left-color: var(--accent3); } .drawer details.e .sec { color: var(--accent3); }
.drawer details.x summary { border-left-color: var(--accent4); } .drawer details.x .sec { color: var(--accent4); }
.drawer details.p summary { border-left-color: var(--accent2); } .drawer details.p .sec { color: var(--accent2); }
.drawer details.l summary { border-left-color: var(--accent5); } .drawer details.l .sec { color: var(--accent5); }
.drawer ul { list-style: none; margin: 0; padding: 0 0 6px; }
.drawer li a { display: block; padding: 7px 12px 7px 16px; border-top: 1px solid var(--rule); }
.drawer li a small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.35; }
.drawer li a:hover { background: var(--bg); }
.drawer li a[aria-current="page"] { background: var(--bg); font-weight: 600; box-shadow: inset 3px 0 0 var(--ink); }
.drawer details[data-current] summary .sec::before { content: "●"; font-size: .7em; }
select { max-width: 100%; }
.controls label { max-width: 100%; }

/* wide screens: the open menu is docked beside the page instead of covering it */
body.no-anim nav.drawer, body.no-anim .nav-scrim { transition: none !important; }
@media (min-width: 1000px) {
  body.menu-open { padding-right: 360px; }
  body.menu-open .nav-scrim { opacity: 0; pointer-events: none; }
  body.menu-open nav.drawer { box-shadow: none; }
  .drawer .menu-close { display: none; }
}

/* Legendre symbol (n over 5 in tall brackets, no fraction bar), so it is never read as n ÷ 5 */
.leg { display: inline-flex; align-items: center; vertical-align: middle; white-space: nowrap; line-height: 1; margin: 0 .05em; }
.leg::before, .leg::after { font-size: 1.75em; font-weight: 300; line-height: 1; transform: scaleX(.8); }
.leg::before { content: "("; } .leg::after { content: ")"; }
.leg .st { display: inline-flex; flex-direction: column; align-items: center; font-size: .72em; line-height: 1.05; padding: 0 .05em; }

/* hide an element (used by pages to show controls only when they apply) */
.hidden { display: none !important; }

/* the "silence: 0 · 5" switch (Lluis's reading, shared by all pages) */
.sil-switch { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); margin: 0 0 12px; flex-wrap: wrap; }
.sil-switch .seg2 { display: inline-flex; border: 1px solid var(--accent3); border-radius: 999px; overflow: hidden; }
.sil-switch .seg2 button { border: 0; border-radius: 0; padding: 2px 14px; background: transparent; color: var(--accent3); font-weight: 600; min-height: 0; }
.sil-switch .seg2 button.on { background: var(--accent3); color: var(--panel); }
.sil-switch .why { font-size: .85rem; }
.sil-switch .now5 { color: var(--accent3); }

/* library pages (papers, images, GeoGebra) */
.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.libcard { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; text-align: left; padding: 0; color: var(--ink); font: inherit; }
.libcard:hover, .libcard:focus-visible { border-color: var(--accent5); }
.libcard img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: center; background: #fff; display: block; border-bottom: 1px solid var(--rule); }
.libcard .cap { padding: 8px 10px 10px; font-size: .9rem; line-height: 1.35; }
.libcard .cap b { display: block; font-weight: 600; font-size: .82rem; color: var(--muted); margin-bottom: 3px; word-break: break-word; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 200; display: none; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.lightbox.on { display: flex; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 150px); background: #fff; border-radius: 6px; }
.lightbox .lbcap { color: #f2efe9; max-width: 900px; text-align: center; margin: 10px 0 6px; font-size: .95rem; }
.lightbox .lbbar { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.lightbox .lbbar a, .lightbox .lbbar button { color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); border-radius: 6px; padding: 5px 12px; font: inherit; font-size: .9rem; text-decoration: none; cursor: pointer; }
.paper { display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: start; }
.paper img { width: 150px; border: 1px solid var(--rule); border-radius: 4px; background: #fff; }
@media (max-width: 620px) { .paper { grid-template-columns: 1fr; } .paper img { width: 120px; } }
.pdfview { width: 100%; height: 80vh; border: 1px solid var(--rule); border-radius: 8px; background: #fff; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btnrow a.button, .btnrow button { display: inline-block; padding: 6px 14px; border: 1px solid var(--rule); border-radius: 6px; background: var(--panel); color: var(--ink); text-decoration: none; font: inherit; font-size: .92rem; cursor: pointer; }
.btnrow .primary { background: var(--accent5); border-color: var(--accent5); color: #fff; }
#ggbBox { width: 100%; min-height: 200px; background: #fff; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.filelist { columns: 2 320px; font-size: .9rem; margin: 0; padding-left: 18px; }
.filelist li { break-inside: avoid; margin-bottom: 3px; }
