/* Atkinson Hyperlegible (Braille Institute, SIL OFL, design/AtkinsonHyperlegible-OFL.txt):
   built for legibility, e.g. I l 1 and 0 O are clearly different. Latin subset, self-hosted. */
@font-face { font-family: "Atkinson"; src: url(/fonts/atkinson-regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url(/fonts/atkinson-bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url(/fonts/atkinson-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

/* Colours from the old MyBB "Tranquil" theme (see design/global.css); text colours darkened
   for contrast: --text 9.7:1, --muted 5.3:1 on white */
:root {
  --page: #eaeaea;
  --box: #ffffff;
  --head: #687880;
  --head-text: #ffffff;
  --text: #444444;
  --muted: #6b6b6b;
  --sub: #f0f0f0;
  --line: #dadada;
  --border: #e0e0e0;
  --highlight: #d4eff7;
  --mark: #fff6bf;
  --error: #f30;
}

* { box-sizing: border-box; }
/* The hidden attribute must win over display rules like .icon { display: flex } */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  /* 16 px is the common floor for screen body text; 1.45 suits lines of up to ~80 characters */
  font: 16px/1.45 "Atkinson", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* width of the chat: time + name + ~80 characters + gaps, padding, delete button */
  --chat-w: calc(2.6em + 6em + 58ch + 16px + 24px + 60px);
}
a { color: var(--head); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* One header bar: logo, navigation, chat controls (chat only), user + logout */
.top { background: var(--head); color: var(--head-text); }
.top .bar { display: flex; align-items: center; gap: 4px 14px; min-height: 52px; padding: 0 16px; }
.top .mid { display: flex; align-items: center; gap: 4px 14px; flex: 1; min-width: 0; }
.top .logo { display: block; padding: 6px 0; }
.top .logo img { display: block; height: 32px; width: auto; }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--head-text); text-decoration: none; padding: 5px 10px; border-radius: 3px; opacity: .85; }
.nav a:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.nav a.active { opacity: 1; font-weight: 700; background: rgba(255, 255, 255, .2); }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 6px; }
/* Wide screens: logo | middle zone exactly as wide as the centered chat | user far right */
@media (min-width: 701px) {
  .top .bar { display: grid; grid-template-columns: minmax(auto, 1fr) minmax(0, var(--chat-w)) minmax(auto, 1fr); column-gap: 16px; }
  .top .user { justify-self: end; }
}
.user .who { font-size: 14px; }
.link { background: none; border: 0; cursor: pointer; font: inherit; }

/* main.wrap: more specific than .wrap, whose padding shorthand would otherwise reset the top */
main.wrap { padding-top: 16px; padding-bottom: 32px; }
.box { background: var(--box); border: 1px solid var(--border); margin-bottom: 16px; }
.thead {
  margin: 0; padding: 8px 12px; background: var(--head); color: var(--head-text);
  font-size: 14px; display: flex; justify-content: space-between; align-items: center;
}
.status { font-weight: normal; font-size: 12px; opacity: .85; white-space: nowrap; }
.tools { display: flex; align-items: center; gap: 10px; }
.icon { display: flex; padding: 4px; background: none; color: var(--head-text); border-radius: 3px; opacity: .7; }
.icon:hover { opacity: 1; }
.icon[aria-pressed="true"] { opacity: 1; background: rgba(255, 255, 255, .25); }
/* Delete buttons only show while an admin has switched on edit mode */
.shout .mod { display: none; }
body.edit-mode .shout .mod { display: inline; }
.pad { padding: 12px; }

label { display: block; margin-bottom: 10px; font-size: 13px; }
input, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px;
  border: 1px solid #ccc; font: inherit; color: inherit;
}
button {
  padding: 8px 14px; border: 0; background: var(--head); color: var(--head-text);
  font: inherit; cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
#login-view, .narrow { max-width: 420px; margin: 40px auto; }
.turnstile { margin: 4px 0 10px; min-height: 65px; }
.error { color: var(--error); margin: 8px 0; }
.hint { color: var(--muted); font-size: 12px; }

.shout-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; background: var(--sub); border-bottom: 1px solid var(--line); }
.shout-form textarea { margin: 0; min-height: 4.4em; max-height: 50vh; resize: vertical; line-height: 1.4; }
.shout-buttons { display: flex; flex-direction: column; gap: 6px; }
.shout-buttons .attach { background: var(--box); color: var(--text); border: 1px solid #ccc; font-size: 16px; padding: 4px 10px; }
#chat-view.dragging .shout-form { outline: 2px dashed var(--head); outline-offset: -6px; background: var(--highlight); }
.upload-status { margin: 0; font-size: 12px; color: var(--muted); background: var(--sub); border-bottom: 1px solid var(--line); padding-top: 4px; padding-bottom: 6px; }
.upload-status progress { width: 160px; vertical-align: middle; margin-left: 6px; }
.shout .msg a.file, .shout .msg a.pic { display: inline-block; padding: 3px 8px; margin: 2px 0; border: 1px solid var(--border); background: var(--sub); text-decoration: none; }
.shout .msg a.file .size, .shout .msg .file.gone { color: var(--muted); font-size: 12px; }
/* Pictures: label + image in the markup. Archive: always the image. Chat: the label with
   hover preview by default, the image when the viewer switched to "shown" (body.assets-shown). */
.pic-label { display: none; }
.shout .msg a.pic { cursor: zoom-in; }
.shout .msg a.pic .pic-label { display: inline; }
.shout .msg a.pic .pic-full { display: none; }
body.assets-shown .shout .msg a.pic { padding: 0; border: 0; background: none; }
body.assets-shown .shout .msg a.pic .pic-label { display: none; }
body.assets-shown .shout .msg a.pic .pic-full { display: inline; max-height: 300px; }
.pic-preview { position: fixed; z-index: 20; padding: 4px; background: var(--box); border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(0, 0, 0, .2); pointer-events: none; }
.pic-preview img { display: block; max-width: 320px; max-height: 300px; min-width: 60px; min-height: 40px; }
.lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; cursor: zoom-out; padding: 16px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 80px); object-fit: contain; }
.lightbox-open { color: #fff; font-size: 13px; }

.shouts { list-style: none; margin: 0; padding: 0 0 6px; }
/* Day separators carry the date (messages show hh:mm only); they stick while scrolling */
.shouts li.day {
  position: sticky; top: 0; z-index: 1; padding: 6px 12px; margin-top: 4px;
  background: var(--sub); border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700;
}
.shouts li.day:first-child { margin-top: 0; }
.shout { padding: 1px 12px; overflow-wrap: anywhere; }
/* A new speaker gets air and a hairline; the same speaker again (.same) a smaller gap that is
   still clearly more than a wrapped line */
.shout:not(.same) { margin-top: 8px; padding-top: 7px; border-top: 1px solid #ececec; }
.shout.same {
  padding-top: 6px;
  /* short hairline over the text column only (--text-x: where the text starts) */
  background: linear-gradient(#efefef, #efefef) no-repeat;
  background-position: var(--text-x) 0;
  background-size: calc(100% - var(--text-x) - 12px) 1px;
}
.shouts li.day + .shout { border-top: 0; margin-top: 0; }
.shout .time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shout .msg img { max-width: 100%; max-height: 300px; vertical-align: middle; }
.shout .msg img.smilie { max-height: 1.5em; }
.shout .video iframe { width: 320px; max-width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; }
.shout.new { animation: flash 1.5s ease-out; }
@keyframes flash { from { background-color: var(--highlight); } }
.shout .mod { font-size: 12px; }
.shout .edited { padding: 0; background: none; color: var(--muted); font-size: 12px; text-decoration: underline dotted; cursor: pointer; }
.shout .original { display: block; margin: 2px 0 2px; padding: 3px 8px; border-left: 2px solid var(--border); background: var(--sub); color: var(--muted); font-size: 14px; }
.shout .original-label { font-size: 12px; font-weight: 700; }
.shout .edit-btn { margin-left: 6px; padding: 0 5px; background: none; color: var(--head); border: 1px solid var(--border); border-radius: 3px; font-size: 12px; }
.shout .edit-box { margin: 2px 0; font-size: 16px; min-height: 2.2em; resize: vertical; }
.shout .edit-hint { display: block; font-size: 12px; color: var(--muted); }
.shout .edit-hint.over { color: var(--error); }
.shout .mod button { padding: 0 4px; background: none; color: var(--head); text-decoration: underline; font-size: 12px; }

/* Desktop: fixed columns time | name | text, text at most ~80 characters per line */
@media (min-width: 701px) {
  /* the chat box is only as wide as its columns, centered like the header's middle zone */
  #chat-view { max-width: var(--chat-w); margin-left: auto; margin-right: auto; }
  .shout {
    /* the name column is exactly as wide as the longest name on screen (--name-w, measured
       in chat.js) and right-aligned, so every name sits right next to its text. 58ch of the
       wide digit 0 ≈ 80 average characters per line. */
    display: grid; grid-template-columns: 2.6em var(--name-w, 6em) minmax(0, 58ch) auto;
    column-gap: 8px; align-items: baseline;
    --text-x: calc(12px + 2.6em + 8px + var(--name-w, 6em) + 8px);
  }
  .shout .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
  .shout.same .name { visibility: hidden; } /* every message keeps its time */
}
/* Phone: a header line "Name 21:52" above the text. Follow-ups by the same person have no
   header; their time sits small at the right end of the first line. */
@media (max-width: 700px) {
  .shout {
    display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "name time mod" "msg msg msg";
    column-gap: 6px; align-items: baseline; --text-x: 10px;
  }
  .shout .name { grid-area: name; font-weight: 700; }
  .shout .time { grid-area: time; font-size: 12px; }
  .shout .msg { grid-area: msg; min-width: 0; }
  .shout .mod { grid-area: mod; }
  .shout.same { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "msg time mod"; }
  .shout.same .name { display: none; } /* every message keeps its time */
}
.more { display: block; width: 100%; background: var(--sub); color: var(--text); }

/* --- Forum archive ------------------------------------------------------- */
.archive-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.crumbs { font-size: 13px; }
.archive-search { display: flex; gap: 6px; flex: 0 1 340px; }
.archive-search input { margin: 0; }
.note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; padding: 0 5px; font-size: 11px; background: var(--highlight); color: var(--text); border-radius: 2px; }
.badge.muted { background: var(--sub); color: var(--muted); }

table.tborder { width: 100%; border-collapse: collapse; background: var(--box); border: 1px solid var(--border); margin-bottom: 16px; }
.tborder caption.thead { display: table-caption; text-align: left; font-weight: bold; }
.tborder .tcat td { background: var(--sub); color: var(--muted); font-size: 12px; font-weight: bold; padding: 6px 10px; }
.tborder td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.tborder td.stat { width: 80px; text-align: right; white-space: nowrap; }
.tborder td.last { width: 230px; font-size: 13px; }
.tborder a.title { font-weight: bold; text-decoration: none; }
.tborder a.title:hover { text-decoration: underline; }

.thread-title { font-size: 20px; margin: 0 0 8px; color: var(--text); }
.posts { background: var(--box); border: 1px solid var(--border); margin-bottom: 12px; }
.post { border-top: 1px solid var(--line); }
.post:first-child { border-top: 0; }
.post-head { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px; background: var(--sub); }
.post-head .author { font-weight: bold; }
.post-body { padding: 10px 12px 14px; overflow-wrap: anywhere; font-size: 16px; line-height: 1.55; max-width: calc(75ch + 24px); }
.post-body img { max-width: 100%; height: auto; vertical-align: middle; }
.post-body img.smilie { max-height: 1.6em; }
.post-body .video iframe { width: 480px; max-width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; }
.post-body blockquote { margin: 8px 0; padding: 6px 10px; background: #fafafa; border: 1px solid var(--border); border-left: 3px solid var(--head); }
.post-body blockquote cite { display: block; font-style: normal; font-weight: bold; font-size: 12px; margin-bottom: 4px; }
.post-body pre.code { background: #f6f6f6; border: 1px solid var(--border); padding: 8px; overflow-x: auto; white-space: pre-wrap; }
.post-body details.spoiler { margin: 6px 0; padding: 4px 8px; border: 1px dashed var(--border); }
.post-body details.spoiler summary { cursor: pointer; color: var(--head); }

.pager { margin: 8px 0; font-size: 13px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager a, .pager .current, .pager .gap { padding: 2px 8px; border: 1px solid var(--border); background: var(--box); text-decoration: none; }
.pager .current { background: var(--head); color: var(--head-text); border-color: var(--head); }
.pager .gap { border: 0; background: none; }

.results { list-style: none; margin: 0 0 12px; padding: 0; background: var(--box); }
.results li { padding: 10px 12px; border-top: 1px solid var(--line); }
.results li:first-child { border-top: 0; }
.results .title { font-weight: bold; text-decoration: none; }
.snippet { margin-top: 4px; font-size: 13px; }
.snippet mark { background: var(--mark); }

@media (max-width: 700px) {
  .tborder td.stat, .tborder .tcat td.stat { display: none; }
  .tborder td.last { width: 40%; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 8px; }
  main.wrap { padding-top: 10px; }
  .top .bar, .top .mid { gap: 2px 8px; }
  .top .bar { min-height: 44px; padding: 0 8px; }
  .top .logo img { height: 22px; }
  .nav a { padding: 4px 7px; }
  .user .who { display: none; } /* no room; the logout button has a tooltip */
  .tools { gap: 4px; }
  .thead { padding: 5px 10px; }
  .shout-form { padding: 6px 8px; gap: 6px; }
  /* 16 px: smaller inputs make iPhone Safari zoom into the page on focus */
  .shout-form textarea { min-height: 2.6em; font-size: 16px; }
  .shout-buttons { flex-direction: row; }
  .shout { padding: 1px 10px; }
}
