/* MIRL Collate · close-looking comparison for two or more images.
   No framework, no build.

   Design: a journal page and a plate room, not an application. Paper ground,
   ink rules, images set as numbered PLATES with their captions beneath them,
   catalogue-entry fields ruled like a printed form, citations as footnotes.
   Type: Spectral (a scholarly text serif) for the voice of the page;
   IBM Plex Mono (catalogue-card lettering) for apparatus and controls.
   Both vendored locally in fonts/. Square corners throughout. */

@font-face { font-family: "Spectral"; src: url("../fonts/spectral-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("../fonts/spectral-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("../fonts/spectral-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Spectral"; src: url("../fonts/spectral-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --mono: "Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  --bg: #f6f2e9;          /* paper */
  --surface: #fffdf6;     /* a lighter leaf, for menus */
  --stage: #e5dfd0;       /* mount board behind the plates */
  --ink: #221d14;
  --ink-2: #5f584a;
  --ink-3: #92896f;
  --line: #ddd5c2;        /* hairline rule */
  --line-2: #bfb59c;      /* stronger rule */
  --soft: #efe9da;        /* hover wash */
  --accent: #7e2c19;      /* oxide red: numerals, active states, marks */
  --radius: 0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--serif); font-size: 17px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.label { font-family: var(--mono); color: var(--ink-3); font-size: 12.5px; text-transform: uppercase; letter-spacing: .14em; }

/* ---- masthead: centered, over a double rule, like a journal ---- */
header.app {
  position: relative; display: block; text-align: center;
  padding: 26px 44px 18px; background: var(--bg);
  border-bottom: 3px double var(--line-2);
}
header.app h1 { font-size: 34px; margin: 0; font-weight: 600; letter-spacing: .01em; line-height: 1.05; }
header.app .tag { display: block; margin-top: 5px; font-style: italic; color: var(--ink-2); font-size: 17px; }
header.app .spacer { display: none; }
header.app a {
  position: absolute; right: 44px; top: 32px;
  font-family: var(--mono); color: var(--ink-3); text-decoration: none;
  font-size: 12px; text-transform: uppercase; letter-spacing: .14em;
}
header.app a:hover { color: var(--accent); }

/* ---- the apparatus line: controls as typography, not buttonry ---- */
.toolbar {
  display: flex; align-items: baseline; gap: 26px; flex-wrap: wrap;
  padding: 15px 44px 13px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.group { display: flex; align-items: baseline; gap: 18px; }

.seg { display: inline-flex; gap: 18px; border: 0; background: none; }
.seg button {
  border: 0; background: none; padding: 2px 1px; cursor: pointer;
  font-family: var(--serif); font-size: 16.5px; color: var(--ink-2);
}
.seg button:hover { color: var(--ink); }
.seg button.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }

/* plain controls read as text; .stamp ones read as a stamped label */
button.btn {
  border: 0; background: none; padding: 2px 1px; cursor: pointer;
  font-family: var(--serif); font-size: 16.5px; color: var(--ink-2);
}
button.btn:hover { color: var(--ink); box-shadow: inset 0 -1px 0 var(--line-2); }
button.btn.toggle::before { content: "○ "; color: var(--ink-3); }
button.btn.toggle.on::before { content: "● "; color: var(--accent); }
button.btn.toggle.on { color: var(--ink); box-shadow: none; }
button.btn:disabled { opacity: .4; cursor: default; box-shadow: none; }

button.btn.stamp {
  font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink); border: 1px solid var(--ink); padding: 8px 15px; background: transparent;
}
button.btn.stamp:hover { background: var(--ink); color: var(--bg); box-shadow: none; }

select, input[type="text"], input[type="url"], textarea {
  font-family: var(--serif); font-size: 16px; color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px solid var(--line-2);
  border-radius: 0; padding: 5px 2px;
}
select:focus, input:focus, textarea:focus { outline: none; border-bottom: 1.5px solid var(--accent); }
input::placeholder, textarea::placeholder { color: var(--ink-3); font-style: italic; }
input[type="range"] { accent-color: var(--accent); }
label.inline { display: inline-flex; align-items: center; gap: 9px; font-size: 15px; color: var(--ink-2); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 50;
  background: var(--surface); border: 1px solid var(--ink);
  min-width: 290px; padding: 8px;
  box-shadow: 5px 5px 0 rgba(34, 29, 20, .12);
}
.menu.hidden { display: none; }
.menu button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--ink); padding: 11px 12px; font-family: var(--serif); font-size: 16px; cursor: pointer;
}
.menu button:hover { background: var(--soft); color: var(--accent); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 2px; }

/* ---- the plates ---- */
.main { flex: 1; display: flex; min-height: 0; }

.stage { position: relative; flex: 1; min-width: 0; background: var(--stage); }
.viewers { position: absolute; inset: 0; display: grid; gap: 1px; background: var(--line-2); }
.viewers.side { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.viewers.grid { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.viewers.overlay { grid-template-columns: 1fr; grid-template-rows: 1fr; }

.pane { position: relative; display: flex; flex-direction: column; background: var(--stage); overflow: hidden; }
.pane .osd-wrap { position: relative; flex: 1; min-height: 0; }
/* OpenSeadragon forces position:relative inline on its host element, which
   would collapse it to height 0; override so it fills its wrap. */
.pane .osd { position: absolute !important; inset: 0 !important; }

/* the caption sits BENEATH the image, like a plate in a book */
.pane .pane-cap {
  display: flex; align-items: baseline; gap: 12px;
  padding: 10px 16px 12px; background: var(--bg); border-top: 1px solid var(--line-2);
}
.pane .pane-cap .plate { font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); white-space: nowrap; }
.pane .pane-cap .name { font-style: italic; font-size: 16px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane .pane-cap .cap-actions { margin-left: auto; display: flex; gap: 14px; }
.pane .pane-cap .cap-actions button {
  border: 0; background: none; cursor: pointer; padding: 0;
  font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3);
}
.pane .pane-cap .cap-actions button:hover { color: var(--accent); }
.pane.drop .osd-wrap::after { content: ""; position: absolute; inset: 10px; border: 1px dashed var(--accent); pointer-events: none; }

.empty-pane {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 15px; color: var(--ink-3);
  text-align: center; padding: 30px; pointer-events: none;
}
.empty-pane::before { content: ""; position: absolute; inset: 16px; border: 1px dashed var(--line-2); }
.empty-pane .big { font-size: 30px; opacity: .45; }
.empty-pane button { pointer-events: auto; }
.empty-pane div { font-size: 15.5px; }

/* loading + error states while a (IIIF) image is fetched */
.pane-loading, .pane-error {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; z-index: 5;
  text-align: center; padding: 30px; pointer-events: none;
  font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3);
}
.pane-loading::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--line-2); border-top-color: var(--accent); animation: pane-spin .8s linear infinite;
}
@keyframes pane-spin { to { transform: rotate(360deg); } }
.pane-error { font-family: var(--serif); text-transform: none; letter-spacing: 0; color: var(--ink-2); font-size: 16px; }
.pane-error-hint { color: var(--ink-3); font-size: 14.5px; line-height: 1.6; max-width: 340px; font-style: italic; }

/* curtain divider for overlay mode */
.curtain { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ink); z-index: 8; cursor: ew-resize; display: none; }
.curtain::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 28px; height: 28px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--ink);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .25);
}
.stage.curtain-on .curtain { display: block; }

/* annotation marks: figure callouts, a ring of ink on paper */
.pin {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--ink);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.pin span { font-family: var(--mono); color: var(--accent); font-size: 12.5px; font-weight: 500; }
.stage.annotate .pane .osd { cursor: crosshair; }

/* ---- the apparatus column ---- */
.sidebar { width: 408px; background: var(--bg); border-left: 1px solid var(--line-2); display: flex; flex-direction: column; }
.sidebar.collapsed { width: 0; border-left: 0; overflow: hidden; }
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); padding: 0 30px; counter-reset: tab; }
.tabs button {
  background: transparent; border: 0; color: var(--ink-2); padding: 17px 0 15px;
  font-family: var(--serif); font-size: 16px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button::before { counter-increment: tab; content: counter(tab, upper-roman) ".  "; font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); letter-spacing: .06em; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button.on::before { color: var(--accent); }
.tab-body { flex: 1; overflow-y: auto; padding: 26px 30px; }
.tab-body.hidden { display: none; }

/* catalogue entries, separated by double rules rather than boxed */
.card { background: transparent; border: 0; border-bottom: 3px double var(--line-2); padding: 6px 0 24px; margin-bottom: 24px; }
.card h3 { margin: 0 0 16px; font-size: 19px; font-weight: 600; letter-spacing: 0; color: var(--ink); display: flex; align-items: baseline; gap: 10px; }
.card h3 .dot { width: 8px; height: 8px; background: var(--accent); display: inline-block; flex: none; align-self: center; }
.field { margin-bottom: 15px; }
.field label { display: block; font-family: var(--mono); font-size: 12.5px; color: var(--ink-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .12em; }
.field input, .field textarea, .field select { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.anno-item { display: flex; gap: 14px; padding: 15px 0; border: 0; border-bottom: 1px solid var(--line); margin-bottom: 0; background: transparent; }
.anno-item .num {
  flex: none; width: 27px; height: 27px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--ink); color: var(--accent);
  font-family: var(--mono); font-size: 12.5px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.anno-item .grow { flex: 1; min-width: 0; }
.anno-item .meta { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-top: 6px; text-transform: uppercase; letter-spacing: .1em; }
.anno-item input { width: 100%; margin-bottom: 6px; }
.anno-item .x { background: transparent; border: 0; color: var(--ink-3); cursor: pointer; font-size: 19px; line-height: 1; }
.anno-item .x:hover { color: var(--accent); }

/* the citation, set as a footnote with a hanging indent */
.cite-out {
  background: transparent; border: 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  padding: 16px 2px; font-size: 17px; line-height: 1.7; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; min-height: 76px;
  padding-left: 1.4em; text-indent: -1.4em;
}
.cite-out em { font-style: italic; }
.hint { color: var(--ink-2); font-size: 15.5px; line-height: 1.7; }
.hint code { font-family: var(--mono); font-size: 13.5px; background: var(--soft); padding: 1px 5px; color: var(--ink); }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--ink); border: 1px solid var(--ink);
  padding: 12px 20px; font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  z-index: 200; box-shadow: 4px 4px 0 rgba(34, 29, 20, .15);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.sr { position: absolute; left: -9999px; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
