/* Layout and components. Colours and fonts come from theme.css. Each block is labelled so it can be moved or restyled. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font); }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: -.03em; }
h2 { font-size: 1.25rem; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.notice { padding: .7em 1em; border: 1px solid var(--line); background: var(--card); margin: 1em 0; }
.notice.error { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- page ---------- */
main { margin-left: var(--rail-width); padding: 2rem clamp(1rem, 4vw, 3rem) 4rem; }

/* ---------- avatar ---------- */
.av { border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; color: #fff; font-weight: 700; flex: none; background: var(--line); }

/* ---------- navigation: rail ---------- */
.rail { position: fixed; inset: 0 auto 0 0; width: var(--rail-width); background: var(--rail-bg); color: var(--rail-fg); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 12px 0; z-index: 20; }
.rail a, .rail button { color: inherit; text-decoration: none; background: none; border: 0; cursor: pointer; }
.rail-cats { writing-mode: vertical-rl; display: flex; gap: 1.4rem; font-size: .8rem; letter-spacing: .18em; text-transform: uppercase; }
.rail-cats a { transition: transform .15s; opacity: .85; }
.rail-cats a:hover, .rail-cats a:focus-visible { transform: translateX(4px); opacity: 1; }
.rail-title { display: none; font-weight: 700; letter-spacing: .1em; }
.menu-btn { writing-mode: vertical-rl; letter-spacing: .18em; text-transform: uppercase; font-size: .8rem; padding: 10px 6px; }

/* ---------- navigation: overlay ---------- */
.overlay { position: fixed; inset: 0; background: var(--rail-bg); color: var(--rail-fg); z-index: 10; display: none; padding: 3rem 2rem 2rem calc(var(--rail-width) + 2rem); overflow-y: auto; }
.overlay.open { display: block; }
.overlay a { display: block; color: inherit; text-decoration: none; font-size: clamp(2.6rem, 10vw, 6rem); font-weight: 700; letter-spacing: -.04em; line-height: 1.05; }
.overlay a:hover, .overlay a:focus-visible { color: var(--accent); }
.overlay .small { display: flex; gap: 1.5rem; margin-top: 2rem; }
.overlay .small a, .overlay .small button { font-size: 1rem; letter-spacing: 0; font-weight: 400; background: none; border: 0; color: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

/* ---------- navigation: narrow frame = top bar ---------- */
@media (max-width: 600px) {
  .rail { inset: 0 0 auto 0; width: auto; height: 48px; flex-direction: row; padding: 0 12px; }
  .rail-cats { display: none; }
  .rail-title { display: block; }
  .menu-btn { writing-mode: horizontal-tb; letter-spacing: .12em; padding: 6px; }
  main { margin-left: 0; padding-top: calc(48px + 1.5rem); }
  .home-title { display: none; } /* the top bar already shows the forum name */
  .overlay { padding: calc(48px + 1.5rem) 1.2rem 2rem; }
}

/* ---------- embedded in an iframe ----------
   The host grows the frame to the full page height, so "fixed" would mean "relative to the whole page".
   Embedded mode therefore uses an ordinary top bar and keeps nothing pinned to the viewport. */
.embedded body { position: relative; }
.embedded .rail { position: relative; inset: auto; width: auto; height: 48px; flex-direction: row; padding: 0 12px; gap: 1rem; }
.embedded .rail-title { display: block; }
.embedded .rail-cats { writing-mode: horizontal-tb; flex: 1; justify-content: center; gap: 1.2rem; }
.embedded .rail-cats a:hover, .embedded .rail-cats a:focus-visible { transform: translateY(-2px); }
.embedded .menu-btn { writing-mode: horizontal-tb; letter-spacing: .12em; padding: 6px; }
.embedded main { margin-left: 0; padding-top: 1.5rem; }
.embedded .home-title { display: none; }
.embedded .overlay { position: absolute; inset: 0; padding: 5rem 1.5rem 2rem; }
.embedded .tagbar { position: static; transform: none; flex-direction: row; flex-wrap: wrap; border-radius: 0; margin: 1.5rem 0 0; }

/* ---------- front page: tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin: 1.5rem 0 2.5rem; }
.tile { display: block; text-decoration: none; background: var(--card); border: 1px solid var(--line); padding: 1rem; min-height: 8rem; }
.tile:hover, .tile:focus-visible { border-color: var(--fg); }
.tile b { font-size: 1.25rem; letter-spacing: -.02em; display: block; }
.tile .subs { color: var(--muted); font-size: .85rem; margin: .25rem 0 .9rem; }
.tile .newest { font-size: .85rem; border-top: 1px solid var(--line); padding-top: .5rem; overflow-wrap: anywhere; }

/* ---------- front page: feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: .8rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.feed .body { min-width: 0; flex: 1; }
.feed .title { font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.feed .title:hover { text-decoration: underline; }
.feed .snip { color: var(--muted); overflow-wrap: anywhere; }
.meta { font-size: .8rem; color: var(--muted); }

/* ---------- front page: floating tag bar ---------- */
.tagbar { position: fixed; right: 0; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 8px 10px; background: var(--fg); border-radius: 14px 0 0 14px; z-index: 5; }
.tagbar button { background: none; border: 0; color: var(--bg); cursor: pointer; text-align: left; padding: 2px 4px; font-size: .85rem; }
.tagbar button[aria-pressed="true"] { background: var(--accent); }
@media (max-width: 600px) { .tagbar { top: auto; bottom: 0; left: 0; right: 0; transform: none; flex-direction: row; flex-wrap: wrap; border-radius: 0; } main { padding-bottom: 5rem; } }

/* ---------- category page ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin: 1rem 0; }
.seg button { border: 1px solid var(--fg); background: none; padding: .25rem .8rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.subcats { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: .5rem 0; }
.threads.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.card { background: var(--card); border: 1px solid var(--line); padding: .9rem; display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.card .by { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.card h3 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.threads.list { display: flex; flex-direction: column; }
.threads.list .card { flex-direction: row; align-items: center; gap: .8rem; padding: .5rem .8rem; border-top: 0; }
.threads.list .card h3 { flex: 1; font-size: 1rem; }
.threads.list .by .name { display: none; }

/* ---------- thread ---------- */
.post { display: flex; gap: .9rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.post .main { min-width: 0; flex: 1; }
.post .text { white-space: pre-wrap; overflow-wrap: anywhere; margin: .3rem 0 0; }
.post .placeholder { color: var(--muted); font-style: italic; }
.post .text a { text-decoration: underline; overflow-wrap: anywhere; }
.post-img { display: block; max-width: 100%; max-height: 28rem; height: auto; margin: .5rem 0; background: var(--line); }
.fmtbar { display: flex; gap: .4rem; }
.fmtbar button { border: 1px solid var(--line); background: var(--card); padding: .15rem .6rem; cursor: pointer; font-size: .85rem; }
.fmtbar .fmt-bold { font-weight: 700; }
.fmtbar .fmt-italic { font-style: italic; }
.post .actions button { background: none; border: 0; padding: 0 .6rem 0 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .8rem; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: .8rem; max-width: 34rem; margin: 1rem 0; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.form input[type=text], .form input[type=email], .form input[type=password], .form textarea { border: 1px solid var(--fg); background: var(--card); padding: .55rem .65rem; width: 100%; }
.form textarea { min-height: 7rem; resize: vertical; }
.btn { align-self: flex-start; background: var(--fg); color: var(--bg); border: 0; padding: .6rem 1.2rem; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.alt { background: none; color: var(--fg); border: 1px solid var(--fg); }
.tagpick { display: flex; flex-wrap: wrap; gap: .4rem 1rem; border: 0; padding: 0; margin: 0; }
.profile-head { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 1rem; }

/* ---------- sign-up extras ---------- */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.captcha { min-height: 65px; }

/* ---------- moderation ---------- */
.report { border-top: 1px solid var(--line); padding: 1rem 0; }
.report .text { margin: .4rem 0; padding-left: .8rem; border-left: 3px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.modbar { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }
.modbar button, .report .actions button { border: 1px solid var(--fg); background: none; padding: .2rem .7rem; cursor: pointer; font-size: .85rem; }
.modlog { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.modlog li { padding: .35rem 0; border-top: 1px solid var(--line); }
.reportform { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .3rem; }
.reportform input { border: 1px solid var(--fg); background: var(--card); padding: .3rem .5rem; min-width: 16rem; }
