/* ===================================================================== *
 * The one stylesheet.
 *
 * Every colour, size and space in the app comes from here. Before this
 * file there were five pages carrying six hex values between them by
 * copy-paste, and a sixth page that had quietly gone its own way; they
 * agreed only because the same values had been typed again each time.
 *
 * Two rules that are not style:
 *
 *   - No font is fetched. A tool whose whole argument is that nothing
 *     leaves the page cannot open a connection to a font host on load,
 *     so everything here is a face the machine already has.
 *   - Colour is never the only carrier. A taken-out page is dimmed AND
 *     labelled; a refusal is red AND says what went wrong.
 * ===================================================================== */

:root {
  /* --- ground and ink ---------------------------------------------- */
  --ground: #f7f9f8;        /* the desk */
  --card:   #ffffff;        /* chrome that sits on it */
  --sunk:   #eef2f0;        /* pressed, hovered, recessed */
  --ink:    #141917;
  --quiet:  #5e6a65;
  --faint:  #93a09a;
  --rule:   #dde4e1;

  /* --- the key, carried over from the form filler ------------------- */
  --key:      #0f6b5c;
  --key-ink:  #ffffff;
  --key-soft: #e4f1ed;
  --key-edge: #bcdcd4;

  /* --- meaning, never decoration ------------------------------------ */
  --warn:      #9a5b00;     /* worth your attention before you go on */
  --warn-soft: #fdf4e6;
  --warn-edge: #ecd9b4;
  --stop:      #a3341a;     /* refused, or cannot be taken back */
  --stop-soft: #fcf0ec;
  --stop-edge: #eecabe;
  --good:      #15694f;
  --good-soft: #e6f4ef;
  --good-edge: #bedfd2;

  /* --- shape and depth ---------------------------------------------- */
  --r-sm: 6px; --r: 8px; --r-lg: 11px;
  --lift:    0 1px 2px rgba(14,30,25,.06), 0 6px 16px -6px rgba(14,30,25,.10);
  --lift-lg: 0 2px 4px rgba(14,30,25,.07), 0 14px 32px -10px rgba(14,30,25,.16);

  /* --- faces the machine already has -------------------------------- */
  --ui: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --rail: 164px;
  --panel: 310px;
}

/* The two stamps and the bare preference, so an explicit choice beats the
   operating system in either direction and the un-stamped document (which
   is what most people have) still gets a complete palette. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #101614; --card: #19211e; --sunk: #141b19;
    --ink: #e7eeeb; --quiet: #94a39d; --faint: #6b7a74;
    --rule: #263230;
    --key: #4fbda6; --key-ink: #06201b; --key-soft: #15302b; --key-edge: #27514a;
    --warn: #e0a955; --warn-soft: #2b2214; --warn-edge: #4a3a1c;
    --stop: #f0845e; --stop-soft: #2d1912; --stop-edge: #543024;
    --good: #5fc9a6; --good-soft: #132b24; --good-edge: #27503f;
    --lift:    0 1px 2px rgba(0,0,0,.40), 0 6px 16px -6px rgba(0,0,0,.50);
    --lift-lg: 0 2px 4px rgba(0,0,0,.45), 0 14px 32px -10px rgba(0,0,0,.60);
  }
}
:root[data-theme="dark"] {
  --ground: #101614; --card: #19211e; --sunk: #141b19;
  --ink: #e7eeeb; --quiet: #94a39d; --faint: #6b7a74;
  --rule: #263230;
  --key: #4fbda6; --key-ink: #06201b; --key-soft: #15302b; --key-edge: #27514a;
  --warn: #e0a955; --warn-soft: #2b2214; --warn-edge: #4a3a1c;
  --stop: #f0845e; --stop-soft: #2d1912; --stop-edge: #543024;
  --good: #5fc9a6; --good-soft: #132b24; --good-edge: #27503f;
  --lift:    0 1px 2px rgba(0,0,0,.40), 0 6px 16px -6px rgba(0,0,0,.50);
  --lift-lg: 0 2px 4px rgba(0,0,0,.45), 0 14px 32px -10px rgba(0,0,0,.60);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 14.5px/1.55 var(--ui); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; overflow: hidden;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===================================================================== *
 * Type
 * ===================================================================== */
h1, h2, h3 { margin: 0; letter-spacing: -.012em; text-wrap: balance; font-weight: 650; }
h2 { font-size: 16.5px; }
h3 { font-size: 13.5px; }
p  { margin: .4rem 0 0; }
a  { color: var(--key); }
.lbl { font-size: 11px; font-weight: 650; letter-spacing: .07em;
       text-transform: uppercase; color: var(--faint); }
.note { font-size: 12.8px; color: var(--quiet); margin: .35rem 0 0; }
.num  { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }

/* ===================================================================== *
 * Chrome: the top bar
 * ===================================================================== */
.top { display: flex; align-items: center; gap: .85rem; flex: none;
       padding: .62rem 1rem; background: var(--card);
       border-bottom: 1px solid var(--rule); }
.mark { display: flex; align-items: center; gap: .5rem; font-weight: 650;
        font-size: 15.5px; letter-spacing: -.015em; }
.mark .glyph { width: 24px; height: 24px; border-radius: 7px; background: var(--key);
               display: grid; place-items: center; flex: none; }
.mark .glyph i { display: block; width: 9px; height: 11px; border-radius: 1.5px;
                 border: 1.6px solid var(--key-ink); border-bottom-width: 4px; }
/* The wordmark. Lowercase and tight, because it is a four-letter word and
   setting a four-letter word loosely makes it look like an abbreviation
   somebody forgot to expand. */
.mark .word { font-weight: 650; letter-spacing: -.03em; }

.open { display: flex; align-items: baseline; gap: .5rem; min-width: 0;
        padding-left: .9rem; border-left: 1px solid var(--rule); }
.open .name { font-weight: 550; white-space: nowrap; overflow: hidden;
              text-overflow: ellipsis; max-width: 30ch; }
.open .facts { color: var(--quiet); font-size: 13px; white-space: nowrap; }
.open .facts span + span::before { content: "·"; margin: 0 .4rem; color: var(--faint); }

.promise { margin-left: auto; display: flex; align-items: center; gap: .4rem;
           font-size: 12.5px; color: var(--key); background: var(--key-soft);
           border: 1px solid var(--key-edge); border-radius: 999px;
           padding: .22rem .72rem .22rem .55rem; white-space: nowrap; }
.promise svg { width: 13px; height: 13px; flex: none; }

/* ===================================================================== *
 * Chrome: the three columns
 * ===================================================================== */
.body { flex: 1; display: grid; min-height: 0;
        grid-template-columns: var(--rail) minmax(0, 1fr) var(--panel); }

.rail { border-right: 1px solid var(--rule); background: var(--card);
        padding: .85rem .55rem; display: flex; flex-direction: column; gap: 2px;
        overflow: auto; }
.rail .lbl { padding: 0 .55rem .4rem; }
.rail button { display: flex; align-items: center; gap: .6rem; width: 100%;
               padding: .46rem .55rem; border-radius: var(--r); border: 0;
               background: none; color: var(--quiet); font: inherit;
               text-align: left; cursor: pointer; }
.rail button:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.rail button[aria-current="true"] { background: var(--key-soft); color: var(--key);
                                    font-weight: 600; }
.rail button:disabled { color: var(--faint); cursor: default; }
.rail svg { width: 17px; height: 17px; flex: none; }
.rail .spacer { flex: 1; }

.canvas { overflow: auto; min-width: 0; padding: 1.25rem 1.5rem 2.5rem; }
.panel { border-left: 1px solid var(--rule); background: var(--card);
         overflow: auto; padding: 1.05rem; display: flex; flex-direction: column;
         gap: 1.05rem; }
.panel > header p { color: var(--quiet); font-size: 13px; }

/* Below three columns' worth of room the panel goes under the canvas
   rather than squeezing both into unreadability. */
@media (max-width: 1080px) {
  .body { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--rule); }
}
@media (max-width: 720px) {
  .body { grid-template-columns: 1fr; }
  .rail { flex-direction: row; overflow-x: auto; border-right: 0;
          border-bottom: 1px solid var(--rule); padding: .4rem; }
  .rail .lbl, .rail .spacer { display: none; }
  .rail button { width: auto; white-space: nowrap; }
  .open { display: none; }
  .canvas { padding: 1rem; }
}

/* ===================================================================== *
 * Controls
 * ===================================================================== */
button, .btn {
  font: inherit; font-size: 13.5px; border-radius: var(--r); cursor: pointer;
  padding: .4rem .75rem; border: 1px solid var(--rule);
  background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover:not(:disabled), .btn:hover { background: var(--sunk); }
button:disabled { color: var(--faint); cursor: default; }
button:focus-visible, .btn:focus-visible, a:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--key); outline-offset: 2px;
}
button svg { width: 15px; height: 15px; }

.key { background: var(--key); border-color: var(--key); color: var(--key-ink);
       font-weight: 600; }
.key:hover:not(:disabled) { background: var(--key); filter: brightness(1.09); }
.key:disabled { background: var(--sunk); border-color: var(--rule); filter: none; }
.stop { color: var(--stop); border-color: var(--stop-edge); background: var(--stop-soft); }
.stop:hover:not(:disabled) { background: var(--stop); border-color: var(--stop);
                             color: var(--card); }
.ghost { border-color: transparent; background: none; color: var(--quiet); }
.ghost:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.wide { width: 100%; }
.icon { padding: .4rem; }

input[type=text], input[type=password], input[type=search], textarea, select {
  font: inherit; font-size: 13.5px; color: var(--ink); background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--r); padding: .36rem .55rem;
  width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 5.5rem; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
label { display: flex; align-items: center; gap: .45rem; font-size: 13.5px; }
input[type=checkbox] { accent-color: var(--key); width: 15px; height: 15px; flex: none; }

.strip { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
         margin-bottom: 1.05rem; }
.strip .bar { width: 1px; align-self: stretch; background: var(--rule); margin: 0 .25rem; }
.set { display: flex; flex-direction: column; gap: .45rem; }
.pair { display: flex; gap: .45rem; }
.pair > * { flex: 1; }

details > summary { cursor: pointer; font-size: 12.8px; color: var(--quiet);
                    list-style-position: outside; }
details > summary:hover { color: var(--ink); }
details[open] > summary { margin-bottom: .5rem; }

/* ===================================================================== *
 * Saying what happened
 * ===================================================================== */
.said { font-size: 13px; border-radius: var(--r-lg); padding: .6rem .72rem;
        border: 1px solid var(--rule); background: var(--sunk); color: var(--ink);
        white-space: pre-wrap; }
.said.good { background: var(--good-soft); border-color: var(--good-edge); color: var(--good); }
.said.warn { background: var(--warn-soft); border-color: var(--warn-edge); color: var(--warn); }
.said.stop { background: var(--stop-soft); border-color: var(--stop-edge); color: var(--stop); }
.said b { font-weight: 650; }

.counts { display: flex; gap: 1.1rem; padding-top: .85rem; border-top: 1px solid var(--rule); }
.counts div { display: flex; flex-direction: column; }
.counts b { font-size: 21px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }

/* ===================================================================== *
 * Paper: a page of a document, wherever one is shown
 * ===================================================================== */
.sheet { background: #fff; border-radius: 5px; box-shadow: var(--lift);
         overflow: hidden; position: relative; display: block; }
.sheet canvas, .sheet img { display: block; width: 100%; height: auto; }

.pages { display: grid; gap: 1.1rem; max-width: 1240px;
         grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.pg { position: relative; cursor: pointer; user-select: none; }
.pg .sheet { aspect-ratio: 17/22; transition: box-shadow .14s, transform .14s; }
.pg:hover .sheet { box-shadow: var(--lift-lg); transform: translateY(-2px); }
.pg .cap { display: flex; align-items: center; justify-content: center; gap: .3rem;
           margin-top: .42rem; font-size: 12.5px; color: var(--quiet); }
.pg[aria-selected="true"] .sheet { box-shadow: 0 0 0 2.5px var(--key), var(--lift-lg); }
.pg[aria-selected="true"] .cap { color: var(--key); font-weight: 600; }
.pg.out .sheet { opacity: .34; box-shadow: none; outline: 1px dashed var(--rule);
                 outline-offset: -1px; }
.pg.out:hover .sheet { transform: none; }
.pg.out .cap { color: var(--warn); }
.pg .waiting { position: absolute; inset: 0; display: grid; place-items: center;
               color: var(--faint); font-size: 12px; }

/* ===================================================================== *
 * Nothing open yet
 * ===================================================================== */
.empty { display: grid; place-items: center; height: 100%; text-align: center;
         padding: 2rem; }
.empty .inner { max-width: 30rem; display: flex; flex-direction: column;
                align-items: center; gap: .7rem; }
.empty h2 { font-size: 19px; }
.empty p { color: var(--quiet); }
.drop { border: 1.5px dashed var(--rule); border-radius: var(--r-lg);
        padding: 1.6rem 2rem; width: 100%; background: var(--card); }
.drop.over { border-color: var(--key); background: var(--key-soft); }

/* Last, so it wins on source order against any layout rule above: the
   thing left on screen otherwise is a control for a state the app is
   not in. */
[hidden], .hide { display: none !important; }

/* ===================================================================== *
 * Fill: inputs standing exactly where the blanks are
 *
 * These live here rather than in the tool, because the whole point of
 * this file is that there is nowhere else for a colour or a radius to
 * come from. A tool brings behaviour; it does not bring a palette.
 * ===================================================================== */
.stage { display: flex; justify-content: center; }
.stage .sheet { position: relative; }
.stage .sheet canvas { display: block; }

.spot { position: absolute; padding: 0 2px; border-radius: 3px;
        border: 1px solid var(--key-edge); background: rgba(15,107,92,.07);
        color: var(--ink); font-family: var(--ui); line-height: 1; }
.spot:hover { background: rgba(15,107,92,.13); }
.spot:focus { outline: 2px solid var(--key); outline-offset: 0;
              background: var(--card); }
.spot.done { background: rgba(15,107,92,.03); border-color: var(--key); }
.spot.stuck { border-style: dashed; border-color: var(--warn-edge);
              background: rgba(154,91,0,.06); color: var(--quiet); cursor: not-allowed; }

.meter { height: 5px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--key); transition: width .2s; }

.qs { list-style: none; margin: 0; padding: 0; display: flex;
      flex-direction: column; gap: 3px; }
.qs .pagehead { font-size: 11px; font-weight: 650; letter-spacing: .07em;
                text-transform: uppercase; color: var(--faint);
                padding: .7rem .1rem .2rem; }
.q { display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
     width: 100%; text-align: left; padding: .38rem .5rem; border-radius: var(--r-sm);
     border: 1px solid transparent; background: none; font-size: 13.2px;
     color: var(--ink); cursor: pointer; }
.q:hover { background: var(--sunk); }
.q.on { background: var(--key-soft); border-color: var(--key-edge); }
.q.stuck { color: var(--quiet); cursor: default; }
.q.stuck:hover { background: none; }
.q .lab { line-height: 1.35; }
.q.guessy .lab { border-bottom: 1px dotted var(--faint); }
.q .ans { font-weight: 600; color: var(--key); font-size: 12.6px; }
.q .meta { font-size: 11.6px; color: var(--faint); }
.ansin { margin: 2px 0 .5rem; }

/* Undo and redo in the top bar carry the ink when they can be pressed.
   A ghost button at --quiet and a disabled one at --faint are two greys
   nobody can tell apart, and the whole use of those two buttons is
   knowing at a glance whether there is anything behind you. */
.top .ghost:not(:disabled) { color: var(--ink); }
