/* Parchment: cream page, sand banner, Garamond throughout, centered column */
:root {
  --bg: #fbf7ef;
  --band: #f1e8d8;
  --text: #3b3125;
  --soft: #8a7b66;
  --line: #e0d4c0;
  --mark: #9c6b3c;
  --serif: "IM Fell English", "EB Garamond", Garamond, "Times New Roman", serif;
  --display: "IM Fell Double Pica", "IM Fell English", Garamond, "Times New Roman", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.6;
}

.banner { background: var(--band); padding: 2.75rem 1rem 2.25rem; text-align: center; }
.banner a { color: inherit; text-decoration: none; }
.site-name {
  margin: 0;
  font-weight: 500;
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  line-height: 1.1;
  text-wrap: balance;
}

.nav { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg); }
.nav ul {
  list-style: none;
  margin: 0 auto;
  padding: 0 1rem;
  max-width: 62rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .2rem 2.25rem;
}
.nav a {
  display: block;
  padding: .8rem 0 .7rem;
  color: var(--soft);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--mark); }
a:focus-visible { outline: 2px solid var(--mark); outline-offset: 3px; }

main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
  display: grid;
  gap: 2rem;
  justify-items: center;
}
main.wide { max-width: 72rem; justify-items: stretch; }
main.game-page { max-width: none; padding: 1rem 1rem 1rem; justify-items: center; }
.game-page .game {
  width: min(100%, calc(var(--fit-h, 70vh) * 2));
  height: auto; aspect-ratio: 2 / 1; min-height: 0;
  border: 0; border-radius: 0; background: transparent;
}
/* phones held upright keep a tall frame, with the touch controls under the game */
@media (orientation: portrait) and (pointer: coarse) {
  .game-page .game { width: 100%; height: 85vh; aspect-ratio: auto; }
}

a { color: var(--mark); }
.big-link { font-size: 1.35rem; }

img { max-width: 100%; height: auto; }
.email { display: block; width: 15rem; max-width: 100%; }

main.about-page { max-width: 62rem; }
.about {
  display: grid;
  grid-template-columns: 1fr 22rem;
  gap: 3rem;
  align-items: center;
}
@media (max-width: 760px) {
  .about { grid-template-columns: minmax(0, 1fr); }
  .about .portrait { order: -1; justify-self: center; width: 22rem; }
}
.portrait {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.bio { font-size: 1.25rem; line-height: 1.75; text-wrap: pretty; }
.bio p { margin: 0 0 1.1em; }
.bio p:last-child { margin-bottom: 0; }
.bio .name { font-variant: small-caps; letter-spacing: .04em; font-size: 1.08em; }

.game {
  display: block;
  width: 100%;
  height: 85vh;
  min-height: 34rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.embed { display: grid; gap: .6rem; justify-items: end; }
.fs {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .35rem .9rem;
  cursor: pointer;
}
.fs:hover { border-color: var(--mark); }
.fs:focus-visible { outline: 2px solid var(--mark); outline-offset: 3px; }

/* Canon Canonum: original chart beside a typeset recreation */
.page-title { margin: 0; text-align: center; font-weight: 500; font-size: clamp(1.8rem, 4vw, 2.4rem); line-height: 1.2; }
.page-intro { margin: 0 auto; max-width: 40rem; text-align: justify; hyphens: auto; }
.page-intro p { margin: 0 0 .8rem; }
.page-intro p:last-child { margin-bottom: 0; }
.canon {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: 30rem;
  display: grid;
  justify-items: center;
}
.canon.is-modern { max-width: 40rem; }
.canon-img { display: block; width: 100%; max-width: 30rem; }
.canon [hidden] { display: none; }
.cc { width: 100%; }
.canon-flip { position: absolute; top: 0; left: calc(100% + 1rem); white-space: nowrap; }
.cc {
  --ink: #3b2a1c;
  --red: #b4352a;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums;
}
.cc-col + .cc-col { border-left: 1px solid var(--line); }
.cc-row {
  display: grid;
  grid-template-columns: 4.8rem 1rem 4.4rem 1fr;
  align-items: center;
  column-gap: .3rem;
  min-height: 6.1rem;
  padding: .55rem .9rem;
}
.cc-row + .cc-row { border-top: 1px solid var(--line); }
.cc-label { font-size: 2.6rem; font-weight: 500; line-height: 1; white-space: nowrap; }
.cc-two { display: grid; gap: .25rem; font-size: 1.5rem; }
.cc-l { position: relative; display: flex; align-items: center; gap: .2rem; }
.cc-ruled { padding-bottom: .2rem; border-bottom: 1px solid var(--ink); }
.cc-ln, .cc-notes { display: grid; color: var(--red); font-size: 1rem; font-weight: 400; line-height: 1.2; }
.cc-ln { font-size: .8rem; }
.cc-one { font-size: 1.5rem; align-self: center; padding-top: .9rem; }
.cc-nums { display: grid; font-size: 1.9rem; line-height: 1.12; letter-spacing: .02em; }
.cc-notes { align-self: center; grid-auto-rows: 2.13rem; align-items: center; padding-left: .35rem; }
.cc-mid { grid-auto-rows: auto; }

@media (max-width: 960px) {
  .page-intro { text-align: left; }
  .canon-flip { position: static; order: 1; margin-top: 1rem; font-size: .9rem; }
}
@media (max-width: 560px) {
  .cc { grid-template-columns: minmax(0, 1fr); }
  .cc-col + .cc-col { border-left: 0; border-top: 1px solid var(--line); }
}

/* Titles in the Fell Double Pica face (the Petrucci look of Mensurator) */
h1, h2, h3, .site-name, .page-title, .cc-label { font-family: var(--display); font-weight: 400; }
.nav a { font-family: var(--serif); }

/* Cantus firmus: the app takes the whole width of the screen, under the banner and navigation */
main.edge { display: block; max-width: none; padding: 0; }
.embed.edge { position: relative; display: block; width: 100%; }
.edge .game { display: block; width: 100%; height: 40rem; min-height: 0; border: 0; border-radius: 0; border-top: 1px solid var(--line); background: var(--bg); }
.edge .game:fullscreen { height: 100vh !important; }
.edge .fs { position: absolute; top: .55rem; right: .9rem; z-index: 2; opacity: .85; }

/* Home: welcome text and the four project panels */
main.home { max-width: 60rem; gap: 2.5rem; }
.welcome { max-width: 38rem; text-align: center; font-size: 1.3rem; line-height: 1.7; text-wrap: pretty; }
.welcome p { margin: 0 0 .6rem; }
.welcome p:first-child { font-family: var(--display); font-size: 1.6rem; }
.welcome p:last-child { margin-bottom: 0; }
.panels {
  list-style: none; margin: 0; padding: 0; width: 100%;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem;
}
@media (max-width: 640px) { .panels { grid-template-columns: minmax(0, 1fr); } }
.panel {
  display: block; height: 100%;
  color: var(--text); text-decoration: none;
  background: #fffdf8; border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; text-align: center;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.panel:hover { border-color: var(--mark); box-shadow: 0 6px 18px rgba(80, 60, 30, .12); transform: translateY(-2px); }
.panel img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-bottom: 1px solid var(--line); }
.panel h2 { margin: .9rem 1rem .1rem; font-size: 1.6rem; line-height: 1.2; }
.panel h2:last-child { margin-bottom: 1.1rem; }
.panel p { margin: 0 1rem 1.1rem; color: var(--soft); font-size: 1.1rem; }

/* Nav: "More" opens a small dropdown (menu.js; without it, on hover or keyboard focus) */
.nav .has-menu { position: relative; }
.nav .menu {
  display: none; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); z-index: 20;
  list-style: none; margin: 0; padding: .35rem 0; min-width: max-content;
  background: #fffdf8; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(80, 60, 30, .12);
}
html:not(.js-menu) .nav .has-menu:hover .menu, html:not(.js-menu) .nav .has-menu:focus-within .menu { display: block; }
/* with menu.js: More opens on a tap, a click or the mouse resting on it; the menu sits on the screen so a scrolling bar cannot cut it off */
.nav .has-menu.open > .menu {
  display: block; position: fixed; transform: none; z-index: 100; overflow-y: auto; overscroll-behavior: contain;
}
/* on a phone the open menu stands in a box of its own on the page (menu.js), where nothing can clip it */
.nav.menu-portal { position: static; border: 0; background: transparent; padding: 0; margin: 0; }
.nav.menu-portal .menu {
  display: block; position: fixed; transform: none; z-index: 100; overflow-y: auto; overscroll-behavior: contain;
}
@media (pointer: coarse) { .nav .menu a { padding: .75rem 1.4rem; } }
.nav .menu a { padding: .45rem 1.2rem; border-bottom: 0; white-space: nowrap; }
.nav .menu a:hover { background: var(--band); }
@media (max-width: 760px) {
  .nav { position: relative; } .nav ul { position: static; } .nav .has-menu { position: static; }
  .nav .menu { max-width: calc(100vw - 2rem); } .nav .menu a { white-space: normal; text-align: center; }
}

/* Magic black and white PDF compressor */
main.tool { max-width: 44rem; justify-items: stretch; }
.drop {
  display: grid; place-items: center; gap: .3rem; min-height: 11rem; padding: 1.5rem;
  border: 2px dashed var(--line); border-radius: 10px; background: #fffdf8;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--mark); background: var(--band); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--mark); outline-offset: 3px; }
.drop-main { font-family: var(--display); font-size: 1.5rem; }
.drop-file { color: var(--soft); font-size: 1rem; overflow-wrap: anywhere; }
.opts { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem 2rem; font-size: 1.05rem; }
.opts label { display: flex; align-items: center; gap: .6rem; }
.opts select { font: inherit; font-size: 1rem; color: var(--text); background: #fffdf8; border: 1px solid var(--line); border-radius: 4px; padding: .2rem .4rem; }
.opts input[type=range] { width: 9rem; accent-color: var(--mark); }
.opts output { min-width: 2.2em; font-variant-numeric: tabular-nums; }
.result { display: grid; justify-items: center; gap: .9rem; text-align: center; }
.result[hidden] { display: none; }
.status { color: var(--soft); font-variant-numeric: tabular-nums; }
.sizes { font-size: 1.35rem; font-variant-numeric: lining-nums tabular-nums; }
.bar { width: 100%; max-width: 20rem; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--mark); transition: width .2s; }
.dl { display: inline-block; font-size: 1.15rem; text-decoration: none; padding: .45rem 1.3rem; }
.dl[hidden] { display: none; }
.preview { display: block; width: 100%; max-width: 30rem; border: 1px solid var(--line); background: #fff; image-rendering: auto; }
.tool-desc { margin: -1rem auto 0; max-width: 34rem; text-align: center; color: var(--soft); text-wrap: balance; }

/* Contact: short intro, message form, email image */
main.contact-page { max-width: 36rem; justify-items: stretch; gap: 1.6rem; }
.contact-intro { margin: 0; text-align: center; font-size: 1.25rem; line-height: 1.7; text-wrap: pretty; }
.contact-form { display: grid; gap: 1.1rem; padding: 1.75rem; background: #fffdf8; border: 1px solid var(--line); border-radius: 6px; }
.contact-form label { display: grid; gap: .3rem; font-size: 1.05rem; color: var(--soft); }
.contact-form input, .contact-form textarea {
  font: inherit; font-size: 1.1rem; color: var(--text); width: 100%;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: .5rem .7rem;
}
.contact-form textarea { resize: vertical; min-height: 9rem; line-height: 1.5; }
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--mark); box-shadow: 0 0 0 2px rgba(156, 107, 60, .18); }
.contact-form .honey { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.send {
  justify-self: center; font: inherit; font-size: 1.15rem; color: var(--text);
  background: var(--band); border: 1px solid var(--line); border-radius: 4px; padding: .45rem 2.2rem; cursor: pointer;
}
.send:hover { border-color: var(--mark); }
.send:disabled { opacity: .6; cursor: default; }
.send:focus-visible { outline: 2px solid var(--mark); outline-offset: 3px; }
.form-status { margin: 0; min-height: 1.6em; text-align: center; font-size: 1.05rem; color: var(--soft); }
.form-status:empty { display: none; }
.form-status.ok { color: #4f6b3a; }
.form-status.err { color: #a2412f; }
.contact-page .email { justify-self: center; }
@media (max-width: 480px) { .contact-form { padding: 1.2rem; } }

/* App and tool pages: the name is a box in the banner's beige at the left of the navigation, the links centred on the screen */
.nav .brand { display: none; }
body.compact .banner { display: none; }
body.compact .nav { position: relative; border-top: 0; }
body.compact .nav .brand {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 1;
  display: flex; align-items: center;
  padding: 0 1.15rem;
  background: var(--band); color: var(--text); text-decoration: none; white-space: nowrap;
  font-family: var(--display); font-size: 1.28rem; line-height: 1.2; border-bottom: 0;
}
body.compact .nav .brand:hover { background: #eadfcb; color: var(--text); }
body.compact .nav ul { padding-top: 0; padding-bottom: 0; gap: .1rem 2rem; }
body.compact .nav a:not(.brand) { padding: .55rem 0 .45rem; }
/* too narrow to share the line: the name sits above the links */
@media (max-width: 1290px) {
  body.compact .nav .brand { position: static; justify-content: center; padding: .4rem 1rem; }
}

/* App and tool pages (nav.js): the bar folds to the left into a small S square while the mouse is lower on the page */
body.compact .nav .b-s, body.compact .nav .b-rest { display: inline-block; }
body.compact .nav .b-rest { overflow: hidden; max-width: 14em; vertical-align: bottom; white-space: pre; }
body.compact.nav-fold .nav { transition: border-color .3s ease; }
body.compact.nav-fold .nav > ul { max-height: 14rem; transition: max-height .3s ease, opacity .25s ease, transform .3s ease; }
body.compact.nav-fold .nav .brand { transition: left .3s ease, top .3s ease, border-radius .3s ease, padding .3s ease, box-shadow .3s ease; }
body.compact.nav-fold .nav .b-rest { transition: max-width .3s ease, opacity .2s ease; }
body.compact.nav-folded .nav { border-bottom-color: transparent; }
body.compact.nav-folded .nav > ul { max-height: 0; opacity: 0; transform: translateX(-2.5rem); overflow: hidden; pointer-events: none; }
body.compact.nav-folded .nav .brand {
  position: absolute; z-index: 60; display: flex; justify-content: center; align-items: center;
  left: var(--s-left, 14px); top: var(--s-top, 8px); bottom: auto;
  min-width: var(--s-size, 40px); height: var(--s-size, 40px); padding: 0;
  border-radius: 11px; box-shadow: 0 1px 4px rgba(42, 34, 24, .14);
  font-size: 1.45rem; line-height: 1;
}
body.compact.nav-folded .nav .b-rest { max-width: 0; opacity: 0; }
body.compact.nav-folded .edge .game { border-top: 0; }
body.compact.nav-folded main.game-page { padding-top: 3.5rem; }

/* Small screens: the links stay on one line, as on a big screen, and scroll sideways when they do not fit */
@media (max-width: 760px) {
  .nav ul { flex-wrap: nowrap; justify-content: safe center; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; gap: .2rem 1.6rem; }
  .nav ul::-webkit-scrollbar { display: none; }
  .nav li { flex: none; }
  .nav .menu { top: 100%; }
}
