/* RealizationEngine Reborn. One stylesheet, light and dark.

   Every choice about the look is a named value in the two blocks below. A
   site changes its look with a theme.css in its data folder that sets new
   values; it can add rules of its own too. */

:root {
  color-scheme: light dark;

  /* Type */
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --size: 15px;          /* the text size most other sizes follow */
  --size-phone: 16px;    /* the same, on a narrow screen */
  --leading: 1.5;        /* line height */

  /* Shape */
  --radius: 6px;         /* rounding of boxes and buttons */
  --space: 1rem;         /* how roomy the page is */
  --width: 48rem;        /* the widest a page's column grows */
  --panel-width: 15rem;  /* the width of the folder panel */
  --landing: 30vh;       /* how far down the window a button sits when its page comes back to it */

  /* Colour */
  --ground: #ffffff;
  --panel: #f7f7f8;
  --text: #1a1a1a;
  --quiet: #5f6368;
  --line: #e6e6e8;
  --edge: #d9d9dd;
  --chosen: #e9e9ec;
  --accent: #2447c5;
  --accent-text: #ffffff;
  --accent-line: #c9d3f5;
  --danger: #b3261e;
  --done: #1a7f37;       /* what an action did */
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #151517;
    --panel: #1c1c1f;
    --text: #ececee;
    --quiet: #a3a6ad;
    --line: #2a2a2e;
    --edge: #3a3a40;
    --chosen: #2a2a2f;
    --accent: #8ea6ff;
    --accent-text: #10131f;
    --accent-line: #33406e;
    --danger: #ff8a80;
    --done: #6fcf8d;
  }
}

* { box-sizing: border-box; }

html { font-size: var(--size); }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  line-height: var(--leading);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { margin: 0 0 1rem; font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
/* A folder's name, and beside it, to someone who can't read the folder, the way in. */
.named { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1rem; margin-bottom: 1rem; }
.named h1 { margin: 0; }
.door { color: var(--quiet); }
.door > button { margin-left: 0.6rem; }
/* What asking did, said in place of the way in, starts where it would. */
.door > .notice:only-child { margin: 0; }
h2 { margin: 1.5rem 0 0.5rem; font-size: 1.05rem; font-weight: 600; }

.quiet { color: var(--quiet); }
.small { font-size: 0.87rem; }

/* Layout: the folder tree beside the page; stacked on a phone. */

.frame { display: flex; min-height: 100vh; }

.tree {
  flex: 1 1 var(--panel-width);
  max-width: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: calc(var(--space) * 1.25) 0.75rem;
}

.tree .site { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.65rem 1rem; font-weight: 600; color: var(--text); }
.tree .mark { width: 1.5rem; height: 1.5rem; flex: none; }

.tree a.folder {
  padding-left: calc(0.65rem + var(--depth, 0) * 1rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.1rem;
  padding-block: 0.3rem;
  padding-right: 0.65rem;
  border-radius: var(--radius);
  color: var(--text);
}
.tree a.folder:hover { background: var(--chosen); text-decoration: none; }

/* The current folder is a tab, outlined on three sides. It runs over the
   divider into the page, whose own background, painted after the panel,
   cuts it off: so it opens onto the page exactly at the panel's edge, at
   any zoom. Nothing in it moves: its outline takes a pixel of padding above
   and below, and sits outside it on the left. */
.tree a.folder[aria-current] {
  margin: 0 calc(-0.75rem - 2px) 0 -1px;
  padding-block: calc(0.3rem - 1px);
  padding-right: calc(1.4rem + 2px);
  border: 1px solid var(--edge);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--ground);
  font-weight: 500;
}
.tree a.folder.closed, .tree a.folder.muted, .tree a.folder.shut { color: var(--quiet); }
.count { font-size: 0.8rem; font-weight: 600; color: var(--accent); }

.page { flex: 999 1 35rem; min-width: 0; background: var(--ground); padding: calc(var(--space) * 1.25) calc(var(--space) * 2) calc(var(--space) * 3); }

/* A thread beside the panel: its words no wider than a column's. */
.reading .page > :not(.bar) { max-width: calc(var(--width) - 3rem); }
.column { max-width: var(--width); margin: 0 auto; padding: calc(var(--space) * 1.25) calc(var(--space) * 1.5) calc(var(--space) * 3.5); }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding-bottom: 1.25rem; }
.bar .crumbs { flex: 1 1 12rem; font-size: 0.87rem; color: var(--quiet); }
.bar .crumbs a { color: var(--quiet); }
.bar .crumbs .here { color: var(--text); font-weight: 500; }
.bar form { margin: 0; }
/* What is on the right stays together. */
.bar .links { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }

/* Controls */

input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--ground);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; min-height: 7rem; }
.bar input[type="search"] { width: 14rem; max-width: 100%; height: 2.25rem; padding-block: 0; }

button, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0 0.95rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--ground);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
button.main, a.button.main { border-color: var(--accent); background: var(--accent); color: var(--accent-text); font-weight: 500; }
a.button:hover { text-decoration: none; }
button.link { min-height: 1.5rem; padding: 0; border: 0; background: none; color: var(--accent); }
button.link:hover { text-decoration: underline; }
button.account, a.account { width: 2.25rem; padding: 0; border: 0; border-radius: 50%; background: var(--chosen); font-size: 0.8rem; font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A field that holds something to copy, with its copy button inside its
   right edge: a copy icon that turns to a check once it has copied. */
.copy { position: relative; }
.copy > input { padding-right: 2.75rem; text-overflow: ellipsis; }
.copy > button { position: absolute; top: 50%; right: 0.25rem; transform: translateY(-50%); width: 2rem; min-height: 2rem; padding: 0; border: 0; background: none; color: var(--quiet); }
.copy > button:hover { color: var(--text); }
.copy > button[hidden], .copy > button > svg + svg, .copy > button.done > svg:first-child { display: none; }
.copy > button.done > svg + svg { display: block; color: var(--done); }
.copy > button > svg { width: 1rem; height: 1rem; }
/* Read out, not seen. */
.unseen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

label { display: block; margin: 0.9rem 0 0.3rem; font-size: 0.87rem; font-weight: 500; }
/* A box to tick, or one choice of several, is tall enough to tap. */
label.check { display: flex; align-items: center; gap: 0.5rem; min-height: 1.6rem; font-weight: 400; }
label.check input { width: auto; }
/* A set of choices under one heading, set as closely as a label and its field. */
fieldset { min-width: 0; margin: 0.9rem 0 0; padding: 0; border: 0; }
legend { margin: 0 0 0.3rem; padding: 0; font-size: 0.87rem; font-weight: 500; }
/* Choices one under another, to tick or to pick, sit evenly, as closely as
   a label and its field. */
fieldset label.check, label.check + label.check { margin: 0.35rem 0 0; }
/* What is in a row lines up on its first line of words, so a button stays
   level with the one beside it, however long what it did runs. */
.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.6rem; margin-top: 0.9rem; }
/* In a row, a field takes the room its button leaves; a long choice in a
   list does not widen the page. */
.row > input[type="text"], .row > input[type="email"], .row > select { flex: 1 1 8rem; width: auto; }
.row > select { min-width: 0; }
/* What a row begins with, words or a button and what it did, takes the room
   the rest leave and wraps in it, so what ends the row stays on its line. */
.row > span:first-child, .row > input[type="hidden"] + span { flex: 1 1 0; }
.narrow { max-width: 24rem; margin: 12vh auto 0; padding: 0 1.25rem; }

/* What the last action did, beside the button that did it, or at the top of
   its list or page when that button is gone; in red, why it could not be
   done. On a phone it takes the line under the button. */
.notice { display: block; font-size: 0.87rem; color: var(--done); }
.notice.alert { color: var(--danger); }
span > .notice, button + .notice { display: inline; margin-left: 0.6rem; }
.row > .notice { margin: 0 auto 0 0; }
.tree .notice { margin: 0.75rem 0.65rem 0; }
.box > .notice:first-child { padding-block: 0.6rem 0.2rem; }
/* At the top of a page: under the bar, just above what it is about. */
.bar + .notice { margin: 0 0 1rem; }
.tabs + .notice { margin: 1rem 0; }
.stack > .notice + * { margin-top: 0; }

/* A page that comes back to a button opens with it a little way down, so
   what is just above it shows too. */
:target { scroll-margin-top: var(--landing); }

/* Thread list */

.threads { border-top: 1px solid var(--line); }
.threads > div {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding: calc(var(--space) * 0.8) 0.25rem;
  border-bottom: 1px solid var(--line);
}
.threads > div:hover { background: var(--panel); }
.threads .title { flex: 1 1 18rem; min-width: 0; padding-left: 1.1rem; color: var(--text); }
.threads .title:hover { text-decoration: none; }
/* The whole line opens the thread; a name on it opens the person's page. */
.threads .title::after { content: ""; position: absolute; inset: 0; }
.threads .title:focus-visible { outline: none; }
.threads .title:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }
.threads .who a { position: relative; color: inherit; }
.threads .new .title { padding-left: 0; font-weight: 600; }
.threads .new .title::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.65rem;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.threads .who { flex: 0 0 9rem; color: var(--quiet); }
.threads .replies { flex: 0 0 2.5rem; color: var(--quiet); text-align: right; }
.threads .when { flex: 0 0 5.5rem; color: var(--quiet); text-align: right; }
.threads mark { background: none; color: var(--text); font-weight: 500; }

/* A thread */

.thread { display: flex; flex-direction: column; gap: calc(var(--space) * 0.7); }
.message { display: flex; flex-direction: column; gap: 0.1rem; padding-left: calc(var(--depth, 0) * 1.75rem); }
.message .by { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.65rem; }
.message .name { font-weight: 600; }
.message .name a { color: inherit; }
.message .when { font-size: 0.87rem; color: var(--quiet); }
.tag { padding: 0 0.4rem; border: 1px solid var(--edge); border-radius: calc(var(--radius) * 2 / 3); font-size: 0.8rem; color: var(--quiet); }
.message .acts { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.87rem; }
details.more > summary { display: inline; cursor: pointer; color: var(--quiet); list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.marker { font-size: 0.87rem; color: var(--quiet); padding-left: calc(var(--depth, 0) * 1.75rem); }
.newline { scroll-margin-top: var(--space); display: flex; align-items: center; gap: 0.75rem; font-size: 0.8rem; font-weight: 600; color: var(--accent); }
.newline::after { content: ""; flex: 1; height: 1px; background: var(--accent-line); }
.message.new { position: relative; }
.message.new::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--depth, 0) * 1.75rem - 0.7rem); width: 2px; border-radius: 1px; background: var(--accent); }

.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p, .body ul, .body ol, .body blockquote, .body pre, .body table { margin: 0.55rem 0; }
.body h3, .body h4, .body h5 { margin: 0.9rem 0 0.3rem; font-size: 1rem; font-weight: 600; }
.body blockquote { padding-left: 0.9rem; color: var(--quiet); border-left: 2px solid var(--edge); }
.body pre { padding: 0.75rem; overflow-x: auto; background: var(--panel); border-radius: var(--radius); }
.body code { font-family: var(--mono); font-size: 0.9em; }
.body table { display: block; overflow-x: auto; border-collapse: collapse; }
.body th, .body td { padding: 0.3rem 0.6rem; border: 1px solid var(--line); text-align: left; }

.files { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.files a, .files span.file {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  font-size: 0.87rem;
  color: var(--text);
}

details.collapsed > summary { cursor: pointer; font-size: 0.87rem; color: var(--quiet); }
details.collapsed[open] > summary { margin-bottom: 1rem; }

/* The reply box stands further apart than the messages around it. */
.compose { display: flex; flex-direction: column; gap: 0.6rem; margin-block: calc(var(--space) * 0.7); padding-left: calc(var(--depth, 0) * 1.75rem); }
.message, .marker, #reply, #preview { scroll-margin-top: 1.5rem; }

/* Tables in admin */

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { font-size: 0.87rem; font-weight: 500; color: var(--quiet); }
/* A cell that can hold a long word, such as an email address or a link in a
   reason, breaks it to fit. */
table.list .long { overflow-wrap: anywhere; }
/* A time, such as when someone joined, stays on one line. */
table.list .when { white-space: nowrap; }
.scroll { overflow-x: auto; }

/* The admin menu, under the bar: a word for each admin page, with the one
   the page sits under underlined. The line is its alone, so that in a
   high-contrast mode too only it is underlined; as much room above keeps
   its word level with the others. On a screen too narrow for them all, the
   row scrolls sideways. It has room around it for the ring a focused word
   takes, which it would otherwise cut off, and takes the room back from
   what is around it. */
.tabs { margin: -4px; padding: 4px; overflow-x: auto; scroll-padding-inline: 4px; scrollbar-width: none; }
.bar + .tabs { margin-top: -4px; }
.tabs > div { display: flex; gap: 1.5rem; }
.tabs a { flex: none; display: flex; align-items: center; gap: 0.35rem; min-height: 2.1rem; color: var(--quiet); white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current] { padding-top: 2px; border-bottom: 2px solid var(--text); color: var(--text); font-weight: 500; }

/* A block: one part of a page, set apart by a line, with its heading inside. */
.box { padding: var(--space) calc(var(--space) * 1.25); border: 1px solid var(--line); border-radius: var(--radius); }
.box > :first-child, .box > form:first-child > :first-child { margin-top: 0; }
.box > :last-child { margin-bottom: 0; }
.box table.list th:first-child, .box table.list td:first-child { padding-left: 0; }
.box table.list th:last-child, .box table.list td:last-child { padding-right: 0; }
.box table.list tr:last-child td { border-bottom: 0; }

/* Closed rows in a block, each opening its own form. */
.box:has(> details) { padding-block: calc(var(--space) * 0.25); }
.box > details + details { border-top: 1px solid var(--line); }
.box > details > summary { display: flex; align-items: center; justify-content: space-between; min-height: 2.75rem; cursor: pointer; list-style: none; }
.box > details > summary::-webkit-details-marker { display: none; }
.box > details > summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.25rem;
  border: solid var(--quiet);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-25%) rotate(45deg);
}
.box > details[open] > summary::after { transform: translateY(25%) rotate(-135deg); }
.box > details[open] { padding-bottom: var(--space); }

/* What can't be undone comes last, in its own block. */
.box.danger > details > summary { color: var(--danger); }

@media (max-width: 40rem) {
  html { font-size: var(--size-phone); }
  .frame { flex-wrap: wrap; min-height: 0; }
  .page { padding: var(--space) var(--space) calc(var(--space) * 3); }
  /* The bar is one line. Its breadcrumb is the way up: its last link, or,
     with none, the one part it has; cut short when the line is too short.
     The slashes between the parts are text, which at a size of nothing
     takes no room, and hidden is not read out either. */
  .bar { flex-wrap: nowrap; }
  .bar .crumbs { flex: 1 1 0; min-width: 0; font-size: 0; visibility: hidden; }
  .bar .crumbs > * { display: none; }
  .bar .crumbs > a:last-of-type, .bar .crumbs > :only-child { display: block; overflow: hidden; font-size: 0.87rem; text-overflow: ellipsis; white-space: nowrap; visibility: visible; }
  .bar .links { flex: none; }
  /* The account button stays the circle it is on a wider screen. */
  .bar .account { min-height: 2.25rem; }
  /* The admin menu scrolls from one edge of the screen to the other, and
     opens at the end its underlined word is nearer. A row set right to left
     opens at its right end; the words in it still run left to right. */
  .column > .tabs { margin-inline: calc(var(--space) * -1.5); padding-inline: calc(var(--space) * 1.5); scroll-padding-inline: calc(var(--space) * 1.5); }
  .tabs:has(> div > :nth-last-child(-n+3)[aria-current]) { direction: rtl; }
  .tabs > div { width: max-content; min-width: 100%; direction: ltr; }
  .tree { border-right: 0; border-bottom: 1px solid var(--line); }
  .tree a.folder { min-height: 2.9rem; }
  .tree a.folder[aria-current] { margin-right: -1px; padding-right: 0.65rem; border-right: 1px solid var(--edge); border-radius: var(--radius); }
  .reading .tree { display: none; }
  .named { flex-direction: column; align-items: flex-start; }
  button, a.button, .tabs a { min-height: 2.75rem; }
  .threads .who, .threads .replies, .threads .when { flex: 0 0 auto; text-align: left; }
  .threads .title { flex-basis: 100%; }
  .threads .who, .threads .replies { padding-left: 1.1rem; }
  .wide { display: none; }
  .message, .marker, .compose { padding-left: calc(var(--depth, 0) * 0.9rem); }
  .message.new::before { left: calc(var(--depth, 0) * 0.9rem - 0.5rem); }
  /* A message's actions are tall enough to tap, and no further apart. */
  .message .acts a, details.more > summary { display: inline-flex; align-items: center; min-height: 1.5rem; }
  span > .notice, button + .notice { display: block; margin: 0.3rem 0 0; }
  .row > .notice { flex-basis: 100%; margin: 0; }
}

@media (width > 40rem) {
  /* What a phone alone shows, as .wide is what it leaves out. */
  .phone { display: none; }
  /* The reply box's buttons sit at its right, with a file field beside them
     or not. */
  .compose .row > span:only-child { flex: 0 1 auto; margin-left: auto; }
}

/* Indentation, by class: the site allows no inline styles. */

.d1 { --depth: 1; } .d2 { --depth: 2; } .d3 { --depth: 3; } .d4 { --depth: 4; }
.d5 { --depth: 5; } .d6 { --depth: 6; } .d7 { --depth: 7; } .d8 { --depth: 8; }

.stack > * + * { margin-top: calc(var(--space) * 2); }

.log { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 0.8rem; line-height: 1.6; }

.preview { margin-top: 0.9rem; padding: 0.75rem; border: 1px dashed var(--edge); border-radius: var(--radius); }
.tree form { margin: 0.75rem 0.65rem 0; }
.logo { display: block; max-width: 100%; max-height: 2.5rem; }
h1 > .mark { display: block; width: 3rem; height: 3rem; margin-bottom: 0.75rem; }

/* The formatting table under the box where messages are written. */
details.formatting { margin-top: 0.5rem; }
details.formatting > summary { display: inline; cursor: pointer; font-size: 0.87rem; color: var(--quiet); }
table.cheats { width: 100%; margin-top: 0.6rem; border-collapse: collapse; font-size: 0.87rem; }
table.cheats td { padding: 0.35rem 1.25rem 0.35rem 0; vertical-align: top; border-bottom: 1px solid var(--line); }
table.cheats pre { margin: 0; font-family: var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
