/*
 * The back office's one stylesheet. No build step: it is served as it is written.
 *
 * Two themes, both measured. Every colour pair below reaches WCAG AA (4.5:1) against
 * the surface it sits on, page and raised panel alike — the old --faint was 2.98:1 and
 * it was the colour on every field label, every table heading and every hint, which is
 * most of the small text in here.
 */

:root {
  color-scheme: light dark;

  --ink: #16191E;        /* body */
  --mut: #4E545E;        /* secondary text, links */
  --faint: #5F656F;      /* labels, table headings, hints */
  --bg: #F6F3ED;         /* the page */
  --panel: #FFFFFF;      /* anything raised off it */
  --line: #C9C3B8;       /* borders */
  --hair: #E2DCD2;       /* the lightest rule that still shows */
  --warm: #7A5B12;       /* the accent: publish, add, the way forward */
  --warn: #9B3A24;       /* refusals */
  --tint: rgba(22, 25, 30, .04);   /* hover */
  --focus: #2B6CB0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

:root[data-theme="dark"], :root:not([data-theme="light"]) {
  --shadow: rgba(0, 0, 0, .5);
}

/* Dark is the app's own palette, lifted enough to pass. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #EDE7DC;
  --mut: #A7ACB6;
  --faint: #8A909B;
  --bg: #0B0E13;
  --panel: #151A21;
  --line: #3E444E;
  --hair: #232932;
  --warm: #D9B65C;
  --warn: #E0806A;
  --tint: rgba(237, 231, 220, .06);
  --focus: #7FB3E8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #EDE7DC;
    --mut: #A7ACB6;
    --faint: #8A909B;
    --bg: #0B0E13;
    --panel: #151A21;
    --line: #3E444E;
    --hair: #232932;
    --warm: #D9B65C;
    --warn: #E0806A;
    --tint: rgba(237, 231, 220, .06);
    --focus: #7FB3E8;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.6 ui-serif, Georgia, serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--mut); text-decoration: none; }
a:hover { color: var(--ink); }

/* Keyboard users get to see where they are. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* MARK: Header */

header {
  display: flex;
  align-items: baseline;
  gap: 20px 26px;
  flex-wrap: wrap;
  padding: 14px 32px;
  border-bottom: 1px solid var(--line);
}
header .name { font-size: 15px; }
nav {
  display: flex;
  gap: 18px;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}
nav a.here { color: var(--ink); }
.mono, nav a {
  font: 400 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em;
}

/* The theme switch. A button, not a checkbox: it does one thing. */
.theme-toggle {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--mut);
  border-radius: 4px;
  padding: 5px 9px;
  cursor: pointer;
  font: 400 10.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }

main { padding: 26px 32px 90px; max-width: 1180px; }

h1 { font-size: 22px; font-weight: 400; margin: 0 0 4px; }
.sub { color: var(--mut); font-style: italic; font-size: 13px; margin: 0 0 26px; }

/* MARK: Notices */

.note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--warm);
  background: var(--panel);
  padding: 11px 15px;
  margin: 0 0 22px;
  font-size: 14px;
}
.note.bad { border-left-color: var(--warn); }

/* MARK: Tables */

/* A table with six columns cannot narrow to a phone, so it scrolls inside its own
   box rather than pushing the page sideways. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
/* Dates break character by character in a squeezed column — "1914-" then "07-28".
   They are the width they are; the table scrolls instead. */
td.when { white-space: nowrap; }
th {
  text-align: left;
  font: 400 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  color: var(--faint);
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--hair); vertical-align: top; }
tr:hover td { background: var(--tint); }

.tag {
  display: inline-block;
  font: 400 9.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px 8px;
  color: var(--mut);
  white-space: nowrap;
}
.tag.draft { border-color: var(--warm); color: var(--warm); }
.dim { color: var(--faint); }

/* MARK: Forms */

form.filters { display: flex; gap: 8px; margin: 0 0 20px; flex-wrap: wrap; align-items: center; }
/* The way forward, pushed to the far end and given room, so it does not read as
   part of the control before it — "CLEAR NEW EVENT" was one phrase at a glance. */
.go-link { color: var(--warm); margin-left: auto; padding-left: 22px; }
.go-link:hover { color: var(--warm); text-decoration: underline; }


input, select, textarea, button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font: 400 14px ui-serif, Georgia, serif;
  padding: 8px 10px;
  max-width: 100%;
}
textarea { width: 100%; resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px var(--tint); }
input:disabled, select:disabled, textarea:disabled { color: var(--faint); background: transparent; }
::placeholder { color: var(--faint); opacity: 1; }

button {
  cursor: pointer;
  background: transparent;
  font: 400 10.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  padding: 9px 15px;
  color: var(--ink);
}
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { cursor: not-allowed; color: var(--faint); }
button.go { border-color: var(--warm); color: var(--warm); }
button.bad { border-color: var(--warn); color: var(--warn); }

label {
  display: block;
  font: 400 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  color: var(--faint);
  margin: 0 0 6px;
}

.field { margin: 0 0 18px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .field { flex: 1 1 220px; }
.err { color: var(--warn); font-size: 13px; margin: 5px 0 0; }
.hint { color: var(--faint); font-size: 12.5px; font-style: italic; margin: 5px 0 0; }

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 11px;
  background: var(--panel);
}
.checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font: 400 13.5px ui-serif, Georgia, serif;
  letter-spacing: 0;
  color: var(--ink);
  cursor: pointer;
}
/* A tap target you can actually hit. */
.checks input[type="checkbox"] { width: 17px; height: 17px; flex: 0 0 auto; }

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* Two columns on a wide screen, one on a narrow one. */
.split { display: flex; gap: 44px; flex-wrap: wrap; }
.split > .wide { flex: 1 1 460px; min-width: 0; }
.split > .aside { flex: 1 1 280px; max-width: 340px; }

/* MARK: The Wikidata lookup */

.lookup-wrap { position: relative; }
#lookup {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
  max-height: 300px; overflow-y: auto;
}
.lookup-hit {
  display: block; width: 100%; text-align: left; border: none;
  border-bottom: 1px solid var(--hair); border-radius: 0; padding: 10px 12px;
  font: 400 14px ui-serif, Georgia, serif; letter-spacing: 0; background: transparent;
}
.lookup-hit:hover { background: var(--tint); }
.lookup-label { display: block; color: var(--ink); }
.lookup-desc { display: block; color: var(--mut); font-size: 12px; font-style: italic; }
.lookup-why {
  display: block; color: var(--faint); font-size: 10.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 3px;
}
.lookup-note { padding: 11px 12px; color: var(--mut); font-size: 13px; font-style: italic; }
.lookup-filled { border-color: var(--warm) !important; transition: border-color .9s ease-out; }

/* MARK: The login page */

body.entrance { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
body.entrance form { width: 100%; max-width: 320px; }
body.entrance h1 { font-size: 20px; margin: 0 0 6px; }
body.entrance input { width: 100%; margin: 0 0 18px; }
body.entrance button { width: 100%; padding: 11px; }

/* MARK: Narrow screens */

@media (max-width: 760px) {
  header { padding: 12px 18px; gap: 12px 18px; }
  nav { margin-left: 0; width: 100%; gap: 14px 16px; }
  main { padding: 20px 18px 80px; }
  h1 { font-size: 20px; }

  /* One field per row: two half-width inputs side by side on a phone are two
     inputs nobody can type in. */
  .row { gap: 0; }
  .row > .field { flex: 1 1 100%; }

  /* iOS zooms the page when a focused input is under 16px. Everything you type
     into is 16px here for that reason alone. */
  input, select, textarea { font-size: 16px; }

  /* A table wider than the screen is cut off at the edge with nothing to say so.
     The fade is the only hint CSS can give without measuring. */
  .table-scroll {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  .split { gap: 28px; }
  /* The form comes first on a phone. Below fifty-five tags it is a long scroll to
     something you came to the page to use. */
  .split > .aside { max-width: none; order: -1; }
  .actions { gap: 8px; }
  .actions form { flex: 0 0 auto; }
  .checks { max-height: 260px; }
}

@media (max-width: 420px) {
  header { padding: 10px 14px; }
  main { padding: 16px 14px 70px; }
}

/* Someone who has asked for less movement gets it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* The dashboard and the Generate screen. */
h2 { font-size: 15px; font-weight: 400; margin: 30px 0 10px; }
a.button {
  display: inline-block;
  border: 1px solid var(--line);
  font: 400 10.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  padding: 9px 15px;
  color: var(--ink);
  text-decoration: none;
}
a.button:hover { border-color: var(--ink); }
a.button.go { border-color: var(--warm); color: var(--warm); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 0 0 18px; }
.tile {
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--line); background: var(--panel);
  padding: 14px 16px; text-decoration: none; color: var(--ink);
}
.tile:hover { border-color: var(--ink); }
.tile .big { font-size: 26px; }
.tile .label { font: 400 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; color: var(--faint); }
.tile .hint { margin: 0; }
.bar { display: block; height: 6px; background: var(--hair); }
.bar > span { display: block; height: 100%; background: var(--warm); }
tr.off td { color: var(--faint); text-decoration: line-through; }
