/* MIRL Rephoto · align a historical photograph to a current one, or square a
   slanted facade to a flat elevation. No build step.

   Design: an architectural drawing sheet, not an application. A ruled frame
   around the workspace, a title block, modes as numbered sheets (R-01, R-02,
   R-03), labels in drawing lettering, point marks in the blue and red of
   checking pencils: blue for THEN (the blueprint), red for NOW (the red-line).
   Type: IBM Plex Mono for lettering and dimensions, Spectral for prose notes.
   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: #f4f2ea;          /* drafting paper */
  --surface: #fcfaf2;     /* a lighter leaf, for menus */
  --stage: #e8e6dd;       /* the board under the photographs */
  --ink: #25231c;
  --ink-2: #5d5a4d;
  --ink-3: #918c76;
  --line: #dcd7c6;        /* hairline rule */
  --line-2: #b9b29a;      /* stronger rule */
  --soft: #edeadd;        /* hover wash */
  --frame: #25231c;       /* the sheet frame */
  --blue: #2d4f6e;        /* THEN: blueprint / blue pencil */
  --red: #a93221;         /* NOW: red-line markup */
  --accent: #a93221;      /* interaction marks default to the red pencil */
  --then: var(--blue);
  --now: var(--red);
  --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; }

/* ---- the sheet edge: lettered strip across the top ---- */
header.app {
  display: flex; align-items: baseline; gap: 18px;
  padding: 20px 26px 14px; background: var(--bg);
}
header.app h1 { font-size: 25px; margin: 0; font-weight: 600; letter-spacing: .005em; line-height: 1; }
header.app .tag { font-style: italic; color: var(--ink-2); font-size: 16.5px; }
header.app .spacer { flex: 1; }
header.app a { 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(--red); }

/* sheet index: the modes are numbered sheets in the set */
.toolbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 4px 26px 14px; background: var(--bg);
}
.group { display: flex; align-items: center; gap: 14px; }

.seg { display: inline-flex; gap: 22px; border: 0; background: none; }
.seg button {
  border: 0; background: none; padding: 3px 1px; cursor: pointer;
  font-family: var(--mono); font-size: 13.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2);
}
.seg button .sheetno { color: var(--ink-3); margin-right: 8px; }
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--red); }
.seg button.on .sheetno { color: var(--red); }
.seg button:disabled { opacity: .4; cursor: default; }

/* every working control on a drawing reads as a stamped label */
button.btn {
  font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink); border: 1px solid var(--ink); padding: 8px 14px; background: transparent; cursor: pointer;
}
button.btn:hover { background: var(--ink); color: var(--bg); }
button.btn.toggle.on { background: var(--red); border-color: var(--red); color: var(--bg); }
button.btn:disabled { opacity: .4; cursor: default; background: transparent; color: var(--ink); }
button.btn.primary { background: var(--ink); color: var(--bg); }
label.inline { display: inline-flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
input[type="range"] { accent-color: var(--red); }

select, input[type="text"], input[type="url"], input[type="number"] {
  font-family: var(--mono); font-size: 14.5px; color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; padding: 5px 2px;
}
select:focus, input:focus { outline: none; border-bottom: 1.5px solid var(--red); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible), [tabindex]:focus:not(:focus-visible) { outline: none; }
input::placeholder { color: var(--ink-3); }

.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: 300px; padding: 8px;
  box-shadow: 5px 5px 0 rgba(37, 35, 28, .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(--red); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 2px; }

/* ---- the framed sheet ---- */
.main { flex: 1; display: flex; min-height: 0; margin: 0 26px 26px; border: 1.5px solid var(--frame); background: var(--bg); }
.stage { position: relative; flex: 1; min-width: 0; background: var(--stage); overflow: hidden; }

/* ---- R-01: two photographs, control points ---- */
.pairs { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-2); }
.imgpanel { position: relative; background: var(--stage); overflow: hidden; }
.imgpanel img { position: absolute; user-select: none; -webkit-user-drag: none; }
.imgpanel.click { cursor: crosshair; }
.panel-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; gap: 12px; align-items: center; padding: 11px 16px;
  font-family: var(--mono); font-size: 12.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-2);
  background: var(--bg); border-bottom: 1px solid var(--line-2); pointer-events: none;
}
.panel-head .swatch { width: 10px; height: 10px; border-radius: 50%; }
.panel-head button { pointer-events: auto; text-transform: uppercase; letter-spacing: .1em; font-size: 11.5px; padding: 5px 10px; }
.imgpanel.drop::after { content: ""; position: absolute; inset: 10px; border: 1px dashed var(--red); pointer-events: none; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: var(--ink-3); text-align: center; padding: 26px; }
.empty::before { content: ""; position: absolute; inset: 52px 16px 16px; border: 1px dashed var(--line-2); }
.empty .big { font-size: 30px; opacity: .5; }
.empty button { pointer-events: auto; }
.empty div { font-size: 15.5px; }
.empty .hint { font-style: italic; }

.dot {
  position: absolute; width: 19px; height: 19px; border-radius: 50%;
  border: 2px solid var(--bg); transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4); cursor: grab;
  display: flex; align-items: center; justify-content: center; z-index: 7;
}
.dot span { font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: #fff; }
.dot.then { background: var(--then); }
.dot.now { background: var(--now); }
.dot.next { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(169, 50, 33, .45); } 50% { box-shadow: 0 0 0 8px rgba(169, 50, 33, 0); } }

/* ---- R-02 / R-03: layered output ---- */
.layer { position: absolute; inset: 0; overflow: hidden; }
.nowspace { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.nowspace img { position: absolute; top: 0; left: 0; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
.rcurtain { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ink); z-index: 9; cursor: ew-resize; display: none; }
.rcurtain::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 .rcurtain { display: block; }
.stage.measure { cursor: crosshair; }

/* measurement: a red-line dimension string */
.mdot { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--bg); border: 2px solid var(--red); transform: translate(-50%, -50%); z-index: 10; }
.mline { position: absolute; height: 1.5px; background: var(--red); transform-origin: 0 50%; z-index: 9; }
.mlabel {
  position: absolute; background: var(--bg); color: var(--red); border: 1px solid var(--red);
  font-family: var(--mono); font-size: 13.5px; font-weight: 500; letter-spacing: .04em;
  padding: 3px 9px; transform: translate(-50%, -150%); z-index: 11; white-space: nowrap;
}

/* ---- the title block and schedules ---- */
.sidebar { width: 420px; background: var(--bg); border-left: 1.5px solid var(--frame); display: flex; flex-direction: column; overflow: hidden; }
.sidebar.collapsed { width: 0; border-left: 0; }
#sidebar-body { flex: 1; overflow-y: auto; }

.titleblock { border-bottom: 1.5px solid var(--frame); padding: 0; flex: none; }
.titleblock .tb-org { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-3); padding: 14px 24px 0; }
.titleblock .tb-title { font-family: var(--serif); font-size: 21px; font-weight: 600; padding: 3px 24px 13px; }
.titleblock .tb-cells { display: grid; grid-template-columns: 1fr 1.4fr 1fr; border-top: 1px solid var(--line-2); }
.titleblock .tb-cell { padding: 9px 14px 11px; border-right: 1px solid var(--line-2); }
.titleblock .tb-cell:first-child { padding-left: 24px; }
.titleblock .tb-cell:last-child { border-right: 0; }
.titleblock .tb-cell span { display: block; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); margin-bottom: 2px; }
.titleblock .tb-cell b { font-family: var(--mono); font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; }

.sect { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.sect h3 { margin: 0 0 14px; font-family: var(--mono); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .12em; color: var(--ink); }
.hint { color: var(--ink-2); font-size: 15.5px; line-height: 1.7; }
.hint b { color: var(--ink); font-weight: 600; }
.step { display: flex; gap: 13px; margin-bottom: 13px; font-size: 15.5px; color: var(--ink-2); line-height: 1.55; }
.step .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--red);
}

.quality { display: flex; align-items: center; gap: 15px; padding: 14px 0 4px; background: transparent; border: 0; }
.quality .big { font-family: var(--mono); font-size: 30px; font-weight: 500; line-height: 1; color: var(--ink); }
.quality.warn .big { color: var(--red); }
.quality .hint { font-style: italic; }

.pairtable { width: 100%; font-family: var(--mono); font-size: 13px; border-collapse: collapse; }
.pairtable th { text-align: left; color: var(--ink-3); font-weight: 400; padding: 7px 5px; border-bottom: 1px solid var(--line-2); text-transform: uppercase; letter-spacing: .1em; font-size: 11.5px; }
.pairtable td { padding: 7px 5px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.pairtable .del { color: var(--ink-3); cursor: pointer; font-size: 15px; }
.pairtable .del:hover { color: var(--red); }

.field { margin-bottom: 14px; }
.field label { display: block; font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .12em; }
.field input { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.readout { font-family: var(--mono); font-size: 26px; font-weight: 500; color: var(--red); line-height: 1.1; }

.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(37, 35, 28, .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); }
