/* EMS Serenissima by Elam Rotem, Early Music Sources, CC BY 4.0. See fonts/LICENSE-EMS_Serenissima.md */
@font-face { font-family: "EMS Serenissima"; src: url("../fonts/EMS_Serenissima.otf") format("opentype"); font-display: block; }
/* Initials: EB Garamond Initials (Georg Duffner) and Libertinus Serif Initials, SIL OFL 1.1; Yinit (Yannis Haralambous), public domain */
@font-face { font-family: "EB Garamond Initials"; src: url("../fonts/EBGaramond-Initials.otf") format("opentype"); font-display: block; }
@font-face { font-family: "Libertinus Serif Initials"; src: url("../fonts/LibertinusSerifInitials-Regular.otf") format("opentype"); font-display: block; }
@font-face { font-family: "Yinit"; src: url("../fonts/Yinit.otf") format("opentype"); font-display: block; }

:root {
  --ink: #1b1712; --muted: #6b6255; --rule: #d8cfbd; --paper: #fdfaf2; --desk: #e9e3d6;
  --panel: #fffdf8; --accent: #8a2a1b; --accent-ink: #fff; --focus: #b5542f; --rubric: #a8261b;
  --textfont: "EB Garamond", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --ui: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--desk); color: var(--ink); font: 14px/1.45 var(--ui); }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- tool */
.sp-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--rule); }
.sp-top h1 { font: 600 22px/1.2 var(--textfont); margin: 0; letter-spacing: .02em; }
.sp-top .beta { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); border: 1px solid var(--accent); border-radius: 3px; padding: 0 5px; }
.sp-top p { margin: 0; color: var(--muted); flex: 1 1 320px; }
.sp-top nav a { margin-left: 14px; }

.sp-main { display: grid; grid-template-columns: 360px 1fr; min-height: calc(100vh - 60px); }
.sp-controls { background: var(--panel); border-right: 1px solid var(--rule); padding: 16px 18px 40px; overflow-y: auto; max-height: calc(100vh - 60px); position: sticky; top: 0; }
.sp-controls h2 { font: 600 13px var(--ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 20px 0 8px; }
.sp-controls h2:first-child { margin-top: 0; }
.sp-field { display: grid; gap: 3px; margin-bottom: 10px; }
.sp-field > span, .sp-field > label { font-size: 12px; color: var(--muted); }
.sp-combo { display: flex; gap: 4px; } .sp-combo select { flex: 1; min-width: 0; }
.sp-combo input[type=number] { width: 58px; padding: 5px 4px; border: 1px solid var(--rule); border-radius: 4px; background: #fff; }
.sp-field input[type=text], .sp-field select, .sp-parts input[type=text], .sp-parts select { width: 100%; padding: 5px 7px; border: 1px solid var(--rule); border-radius: 4px; background: #fff; }
.sp-row { display: flex; gap: 8px; } .sp-row > * { flex: 1; }
.sp-check { display: flex; gap: 7px; align-items: center; margin-bottom: 6px; }
.sp-seg { display: flex; border: 1px solid var(--rule); border-radius: 5px; overflow: hidden; margin-bottom: 10px; }
.sp-seg button { flex: 1; border: 0; background: #fff; padding: 7px; cursor: pointer; }
.sp-seg button + button { border-left: 1px solid var(--rule); }
.sp-seg button[aria-pressed=true] { background: var(--ink); color: var(--paper); }
.sp-drop { display: block; border: 1.5px dashed var(--rule); border-radius: 8px; padding: 16px; text-align: center; background: #fff; cursor: pointer; }
.sp-drop.over { border-color: var(--accent); background: #fbf3ea; }
.sp-drop strong { display: block; margin-bottom: 2px; }
.sp-drop small { color: var(--muted); }
.sp-file { margin-top: 6px; font-size: 12px; color: var(--muted); word-break: break-all; }
.sp-btn { display: inline-block; border: 1px solid var(--rule); background: #fff; border-radius: 5px; padding: 7px 12px; cursor: pointer; }
.sp-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; width: 100%; padding: 10px; }
.sp-btn:disabled { opacity: .45; cursor: default; }
.sp-link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.sp-parts { width: 100%; border-collapse: collapse; font-size: 13px; }
.sp-parts th { text-align: left; font-weight: 500; font-size: 11px; color: var(--muted); padding: 0 4px 4px 0; }
.sp-parts td { padding: 3px 4px 3px 0; vertical-align: middle; }
.sp-parts td.sideCol { width: 74px; } .sp-parts td.sideCol select { padding-left: 4px; padding-right: 2px; }
.sp-parts .nm { font-size: 11px; color: var(--muted); display: block; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-hint { font-size: 12px; color: var(--muted); margin: -4px 0 10px; }

.sp-preview { padding: 20px; overflow: auto; }
.sp-status { max-width: 820px; margin: 0 auto 16px; }
.sp-notice { background: #fbf1df; border: 1px solid #e8cf9f; border-radius: 6px; padding: 9px 13px; margin-bottom: 10px; font-size: 13px; }
.sp-notice.err { background: #fbe4df; border-color: #e6a99c; }
.sp-notice ul { margin: 4px 0 0; padding-left: 18px; }
.sp-empty { max-width: 560px; margin: 60px auto; text-align: center; color: var(--muted); font: 18px/1.5 var(--textfont); }
.sp-scale { transform-origin: 0 0; }
.sp-busy { opacity: .5; transition: opacity .2s; }

.sp-foot { padding: 18px 20px 28px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--rule); background: var(--panel); }
.sp-foot p { margin: 4px 0; max-width: 900px; }

@media (max-width: 860px) {
  .sp-main { grid-template-columns: 1fr; }
  .sp-controls { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); }
  .sp-preview { padding: 12px; }
}

/* ---------------------------------------------------------------- book pages */
#book { display: flex; flex-direction: column; align-items: center; gap: 24px; width: max-content; margin: 0 auto; }
.sp-spread { display: flex; gap: 2px; }
.sp-page { position: relative; background: var(--paper); box-shadow: 0 2px 12px rgba(0,0,0,.22); overflow: hidden; font-family: var(--textfont); color: var(--ink); }
.sp-head { text-align: center; font-size: 19px; letter-spacing: .32em; padding-left: .32em; height: 34px; line-height: 34px; }
.sp-runhead { text-align: center; font-size: 19px; height: 34px; line-height: 34px; margin-bottom: 10px; border-bottom: 0.75px solid var(--ink); }
.sp-runhead.verso { font-style: italic; } .sp-runhead.recto { font-variant: small-caps; letter-spacing: .04em; }
.sp-titleline { display: flex; justify-content: space-between; align-items: baseline; height: 30px; font-size: 16px; border-bottom: 0.75px solid var(--ink); margin-bottom: 14px; }
.sp-t { font-style: italic; } .sp-c { font-variant: small-caps; letter-spacing: .06em; }
.sp-region { position: relative; }
.sp-label { font-size: 15px; letter-spacing: .28em; height: 24px; line-height: 24px; }
.sp-systems { position: relative; }
.sp-sys { position: relative; }
.sp-ems { font-family: "EMS Serenissima"; font-variant-ligatures: common-ligatures; font-feature-settings: "liga" 1; white-space: pre; line-height: 1em; }
.sp-text { font-family: var(--textfont); }
.sp-staff { position: absolute; left: 0; top: 0; }
.sp-syl { position: absolute; transform: translateX(-50%); white-space: pre; line-height: 1; font-family: var(--textfont); }
.sp-credit { position: absolute; left: 0; right: 0; bottom: 22px; text-align: center; font-size: 9.5px; color: var(--muted); font-family: var(--textfont); }
.sp-initial { position: absolute; left: 0; top: 0; border: 2.5px solid var(--ink); padding: 3px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sp-in { width: 100%; height: 100%; border: 1px solid var(--ink); display: flex; align-items: center; justify-content: center; overflow: hidden;
         background: radial-gradient(circle, var(--ink) 0.8px, transparent 1.2px) 0 0 / 5px 5px; background-color: var(--paper); }
.sp-in span { font-family: "IM Fell French Canon", var(--textfont); line-height: 1; padding-top: .08em; color: var(--ink);
              text-shadow: 0 0 2px var(--paper), 0 0 3px var(--paper), 0 0 4px var(--paper), 0 0 6px var(--paper), 0 0 8px var(--paper); }
.sp-initial.sp-blank { border-width: 1px; border-style: dashed; padding: 0; } .sp-blank .sp-in { border: 0; background: none; }
.sp-in img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sp-initial.sp-glyph { border: 0; padding: 0; color: var(--ink); }
.sp-initial.sp-red { color: var(--rubric); } .sp-red .sp-in span { color: var(--rubric); }
.sp-glyph svg { display: block; width: 100%; height: 100%; overflow: visible; fill: currentColor; }

@media print {
  body { background: none; }
  .sp-top, .sp-controls, .sp-status, .sp-foot, .sp-empty { display: none !important; }
  .sp-main { display: block; min-height: 0; }
  .sp-preview { padding: 0; overflow: visible; }
  .sp-scale { transform: none !important; height: auto !important; width: auto !important; }
  #book { display: block; gap: 0; width: auto; }
  .sp-spread { display: block; }
  .sp-page { box-shadow: none; break-after: page; background: #fff; --paper: #fff; }
}
