/* Comic Lettering Tool. The same brutalist Cappuccino palette as captainepub.com and Comic Scan Cleaner. */
:root {
  --cream: #f2f5df;
  --yellow: #f7d585;
  --orange: #db903b;
  --mauve: #88617f;
  --rust: #892f1d;
  --brown: #3c0909;

  --paper: var(--cream);
  --ink: var(--brown);
  --card: #fffdf4;
  --muted: var(--mauve);
  --accent: var(--rust);
  --accent-ink: var(--cream);
  --header: var(--yellow);
  --desk: #d8d4bd;
  --warn-bg: #fbe6c4;

  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --display: "Arial Black", "Archivo Black", "Lato", "Helvetica Neue", Arial, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f0e0c;
    --ink: var(--cream);
    --card: #2c1613;
    --muted: #c9a9c0;
    --accent: var(--orange);
    --accent-ink: var(--brown);
    --header: #3c0909;
    --desk: #140907;
    --warn-bg: #4a3010;
  }
}

/* The lettering font. Shantell Sans, SIL Open Font License (fonts/OFL.txt). */
@font-face {
  font-family: "Lettering Shantell";
  src: url("fonts/ShantellSans-Variable.ttf") format("truetype");
  font-weight: 300 800;
  font-display: block;
}

* { box-sizing: border-box; }

/* Rules like label { display: flex } would otherwise show elements the page hides. */
[hidden] { display: none !important; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); }
code { font-family: var(--mono); background: var(--paper); border: 1px solid currentColor; padding: 0 3px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--header); border-bottom: 3px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { width: 40px; height: 40px; display: block; }
.kicker { display: block; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; font-weight: 700; }
.name { display: block; font-family: var(--display); font-weight: 900; font-size: 20px; line-height: 1.1; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.status { margin: 0; font-size: 13px; font-weight: 700; max-width: 40ch; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 8px 16px; background: var(--card); border-bottom: 3px solid var(--ink);
}
.group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.group-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

button, .button, select, input, textarea { font: inherit; color: var(--ink); }
button, .button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 2px solid var(--ink); background: var(--card);
  font-weight: 700; line-height: 1.2; cursor: pointer;
}
button:hover:not(:disabled), .button:hover { box-shadow: 3px 3px 0 var(--ink); transform: translate(-1px, -1px); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--accent); }
select { padding: 6px 8px; border: 2px solid var(--ink); background: var(--card); }
input[type="number"] { padding: 5px 8px; border: 2px solid var(--ink); background: var(--paper); width: 100%; }
input[type="color"] { width: 52px; height: 34px; padding: 2px; border: 2px solid var(--ink); background: var(--card); cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 0; }
.stage-column { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }

/* The strip of pages under the page: thumbnails in reading order (right to left for manga) and a button to add more. */
.strip {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--card); border-top: 3px solid var(--ink);
  overflow-x: auto;
}
.strip ol { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
.thumb {
  flex-direction: column; gap: 2px; padding: 3px; border-width: 2px;
  font-size: 12px; background: var(--card);
}
.thumb canvas { display: block; width: 52px; height: auto; background: #ffffff; outline: 1px solid rgba(0, 0, 0, 0.2); }
.thumb[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.add-pages { flex: none; white-space: nowrap; }

/* The page sits in the middle of the desk; auto margins keep it centred without cutting off its top when zoomed. */
.stage-wrap { position: relative; display: flex; overflow: auto; min-height: 0; background: var(--desk); }
#stage {
  flex: none; display: block; margin: auto;
  background: #ffffff;
  box-shadow: 0 0 0 2px var(--ink), 8px 8px 0 rgba(0, 0, 0, 0.3);
  touch-action: pan-x pan-y pinch-zoom;
  user-select: none; -webkit-user-select: none;
}
#stage .bubble, #stage .handle { touch-action: none; cursor: move; }
#stage .handle.nw, #stage .handle.se { cursor: nwse-resize; }
#stage .handle.ne, #stage .handle.sw { cursor: nesw-resize; }
#stage .handle.tail { cursor: crosshair; }
.stage-wrap.dropping { outline: 4px dashed var(--accent); outline-offset: -8px; }

.empty {
  margin: auto; max-width: 480px; padding: 24px 26px;
  background: var(--card); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink);
}
.empty h1 { font-family: var(--display); font-weight: 900; font-size: 26px; line-height: 1.1; margin: 0 0 10px; }
.empty-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.inspector { overflow: auto; padding: 14px 16px 20px; background: var(--card); border-left: 3px solid var(--ink); }
.inspector h2 { font-family: var(--display); font-weight: 900; font-size: 18px; margin: 0 0 10px; }
.tips { margin: 0 0 16px; padding-left: 18px; }
.tips li { margin-bottom: 8px; }
.field { display: block; margin: 0 0 12px; font-weight: 700; }
.field > textarea, .field > select, .field > input:not([type="color"]) { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
textarea { min-height: 96px; padding: 8px; border: 2px solid var(--ink); background: var(--paper); resize: vertical; }
.row { display: flex; flex-wrap: wrap; gap: 0 12px; }
.row > .field { flex: 1 1 120px; }
.colors > .field { flex: 0 0 auto; }
.colors input { display: block; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-weight: 700; cursor: pointer; }
.buttons { gap: 8px; margin-top: 4px; }
.hint { margin: 4px 0 12px; font-size: 12px; color: var(--muted); }
.warn { margin: 0 0 12px; padding: 6px 8px; background: var(--warn-bg); border: 2px solid var(--ink); font-size: 13px; }
.page-info { margin: 4px 0 10px; font-size: 12px; overflow-wrap: anywhere; }
#project-panel { margin-top: 18px; padding-top: 14px; border-top: 2px solid var(--ink); }
input[type="text"] { padding: 5px 8px; border: 2px solid var(--ink); background: var(--paper); }
.footnote { margin-top: 16px; }

dialog {
  max-width: min(560px, calc(100vw - 32px)); padding: 20px 22px;
  color: var(--ink); background: var(--card); border: 3px solid var(--ink); box-shadow: 8px 8px 0 var(--ink);
}
dialog::backdrop { background: rgba(31, 14, 12, 0.55); }
dialog h2 { font-family: var(--display); font-weight: 900; font-size: 22px; margin: 0 0 12px; }
.exports { display: grid; gap: 8px; }
.exports button { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%; }
.exports span { font-weight: 400; font-size: 13px; }
dialog .close { margin-top: 4px; }

@media (max-width: 860px) {
  body { display: block; height: auto; }
  .top { padding: 6px 12px; }
  .name { font-size: 17px; }
  .toolbar { gap: 6px 12px; padding: 6px 12px; }
  button, .button, select { padding: 5px 8px; }
  .workspace { grid-template-columns: 1fr; }
  .stage-wrap { height: 58vh; height: 58dvh; }
  .inspector { border-left: 0; border-top: 3px solid var(--ink); }
  .status { display: none; }
}
