/* The beta forum (Server/forum), on top of page.css: forms, the thread list
   and posts, all plain on the page. */

/* Colors for the kinds of thread and their status, beside base.css's own. */
:root {
  --rust: #9C3A17;
  --green: #2B5E39;
  --blue: #284C86;
}
@media (prefers-color-scheme: dark) {
  :root {
    --rust: #E58F6B;
    --green: #7CC79A;
    --blue: #93B4EC;
  }
}

main.forum { gap: 28px; }
main.forum h1 { font-size: clamp(36px, 5vw, 66px); line-height: 1.02; letter-spacing: -0.025em; }
header.page { display: flex; flex-direction: column; gap: 8px; }
.eyebrow { color: var(--muted); }
.back { align-self: flex-start; color: var(--muted); }
.hint { font-size: 15px; color: var(--muted); font-weight: 400; }
.error { color: var(--rust); font-weight: 600; }

/* Settings (admins), All threads, the signed-in name and sign-out */
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 26px; }
.signout { display: flex; align-items: center; gap: 16px; }
.signout button { background: none; color: inherit; padding: 0; font-weight: inherit; text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.signout button:hover { background: none; color: var(--muted); }

/* Forms */
.stack { display: flex; flex-direction: column; align-items: stretch; gap: 18px; max-width: 46rem; }
label { display: block; font-weight: 700; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea { display: block; margin-top: 6px; font: inherit; font-weight: 400; color: var(--ink); background: var(--panel); border: 1px solid var(--muted); border-radius: 0; padding: 10px 12px; width: 100%; }
label.check input { margin-top: 0; }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=file] { background: none; border: 0; padding: 0; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
button, .button {
  align-self: flex-start; display: inline-block; cursor: pointer;
  font: inherit; font-weight: 700;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 0; padding: 12px 18px; text-decoration: none;
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
[hidden] { display: none; }
button.danger { background: var(--rust); }
button.danger:hover { background: var(--ink); color: var(--paper); }
button:hover, .button:hover { background: var(--amber); color: var(--night); }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); align-items: end; gap: 18px; }

/* Thread list */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 16px; }
.tabs a { text-decoration: none; color: var(--muted); padding: 4px 0; }
.tabs a[aria-current] { color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.threads, .posts, .split { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0; }
.threads li, .posts > li { padding: 16px 0; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 6px; }
.threads .title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.threads .title a { font-weight: 700; font-size: 22px; line-height: 1.2; text-decoration: none; }
.threads .title a:hover { text-decoration: underline; text-decoration-color: var(--amber); }
.threads .empty { color: var(--muted); }
.unread { font-size: 15px; font-weight: 700; color: var(--line-text); }

.badge { font-size: 15px; font-weight: 600; color: var(--ink); }
.badge.kind-announcement, .badge.role-admin { color: var(--line-text); }
.badge.kind-problem { color: var(--rust); }
.badge.kind-idea, .badge.status-fixed { color: var(--green); }
.badge.kind-question { color: var(--blue); }
.badge.status-closed { color: var(--muted); }
.badge.status-pinned { color: var(--safety); }
/* Outlined pills, so they never read as part of the kind beside them: private in the plain ink color, a poll in the blue line color. */
.badge.status-private, .badge.status-poll { border: 1px solid currentColor; border-radius: 999px; padding: 0 9px; }
.badge.status-private { color: var(--ink); }
.badge.status-poll { color: var(--line-text); }

/* A thread's posts: who and when on the left, the words on the right */
.posts > li { scroll-margin-top: 20px; }
@media (min-width: 800px) {
  .posts > li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); column-gap: 40px; }
  /* The reply box under the words it answers */
  .posts + .stack { max-width: none; margin-left: calc((100% - 40px) / 4 + 40px); }
}
.posts .body { display: flex; flex-direction: column; gap: 12px; overflow-wrap: anywhere; }
.pictures { display: flex; flex-wrap: wrap; gap: 10px; }
.pictures img { max-height: 240px; width: auto; }
/* The post quoted when deleting it */
blockquote { margin: 0; color: var(--muted); display: flex; flex-direction: column; gap: 10px; }
.post-tools { display: flex; gap: 18px; font-size: 15px; }
.post-tools a { color: var(--muted); }
.admin-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; padding: 14px 0; border-block: 1px solid var(--rule); }
.admin-controls label { font-size: 15px; }
.admin-controls select { width: auto; padding: 6px 10px; }
.admin-controls button { padding: 8px 14px; }
.admin-controls a { align-self: center; font-size: 15px; color: var(--muted); }

/* A poll: the question, then the vote form or the bars. Plain rules, no card. */
.poll { display: flex; flex-direction: column; gap: 14px; padding: 16px 0; border-block: 1px solid var(--rule); }
.poll h2 { font-size: 24px; line-height: 1.2; }
.poll-choices { display: flex; flex-direction: column; gap: 10px; }
.poll-results { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 14px; max-width: 46rem; }
.poll-results li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 4px 16px; }
.poll-label { overflow-wrap: anywhere; font-weight: 600; }
.poll-label .you { font-size: 14px; font-weight: 700; color: var(--line-text); margin-left: 6px; }
.poll-count { font-size: 15px; color: var(--muted); white-space: nowrap; }
.poll progress { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 10px; appearance: none; border: 0; border-radius: 0; background: var(--panel); color: var(--amber); }
.poll progress::-webkit-progress-bar { background: var(--panel); box-shadow: inset 0 0 0 1px var(--rule); }
.poll progress::-webkit-progress-value { background: var(--amber); }
.poll progress::-moz-progress-bar { background: var(--amber); }
.poll-controls button { padding: 8px 14px; font-size: 15px; }
@media (max-width: 720px) {
  .poll-results li { grid-template-columns: minmax(0, 1fr); }
  .poll-count { grid-row: 3; }
}

/* The new thread form's poll: folded until asked for, with a few answers shown */
.poll-fields { max-width: 46rem; border-block: 1px solid var(--rule); padding: 12px 0; }
.poll-fields summary { cursor: pointer; font-weight: 700; }
.poll-fields .stack { margin-top: 14px; }
.poll-options { display: flex; flex-direction: column; gap: 8px; }
.poll-options input { margin-top: 0; }
.link-button { align-self: flex-start; background: none; color: inherit; padding: 4px 0; font-weight: 400; text-decoration: underline; text-decoration-color: var(--amber); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.link-button:hover { background: none; color: var(--muted); }

/* The picture viewer (forum-viewer.js): a picture in front of the thread, fitted to
   the screen. A tap on the dim area, the Close button or Escape closes it, and the
   page behind doesn't scroll while it's open. */
html.viewer-open { overflow: hidden; }
dialog.viewer { position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: var(--paper); }
dialog.viewer[open] { display: flex; align-items: center; justify-content: center; }
dialog.viewer::backdrop { background: rgba(0, 0, 0, 0.88); }
dialog.viewer img { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); width: auto; height: auto; object-fit: contain; }
.viewer-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
  width: 44px; height: 44px; padding: 0; display: flex; align-items: center; justify-content: center;
  font-size: 30px; line-height: 1; background: var(--night); color: var(--paper); border: 1px solid var(--muted); border-radius: 50%;
}

/* Settings (admins): headings between its parts, and the Split page's replies */
main.forum h2.list-heading { margin-top: 12px; }
.split { gap: 14px; }
.split label.check { align-items: flex-start; }
.split label.check input { margin-top: 4px; }

@media (max-width: 720px) {
  .signout span { display: none; }
}

/* Pull down to refresh (forum-refresh.js, only in the Home Screen app): a small
   bar parked just above the top edge. As the page is pulled, the page and the bar
   move down together by --pull (set on <html>), so the bar looks attached to the
   top of the page. */
.pull-refresh {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 190px; margin: 0 auto;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--rule); border-top: 0; border-bottom: 2px solid var(--amber);
  font-size: 14px; pointer-events: none;
  transform: translateY(calc(var(--pull, 0) * 1px - 100%));
}
/* iOS's own rubber-band bounce is off; the page is moved by the rule below instead */
html.installed-app, html.installed-app body { overscroll-behavior-y: none; }
/* The page's content (not body itself, which would make it the bar's containing
   block) moves by the same amount, only while pulling or sliding back, so at rest
   nothing carries a transform */
html.installed-app.pulling body > :not(.pull-refresh) { transform: translateY(calc(var(--pull, 0) * 1px)); }
/* The arrow turns half way round by the pull that counts (70 = PULL_AT) */
.pull-glyph { display: inline-block; font-size: 18px; line-height: 1; transform: rotate(calc(min(var(--pull, 0) / 70, 1) * 180deg)); }
/* After letting go, it slides back (or holds) smoothly instead of following the finger */
html.settling .pull-refresh, html.settling .pull-glyph,
html.installed-app.settling body > :not(.pull-refresh) { transition: transform 0.2s ease-out; }
