/* ============================================================
   06 — Local · "Neighborhood Board"
   Corkboard warmth. Type-coded left borders, pinned-note cards.
   System fonts only (no font-src).
   ============================================================ */

:root {
  --bg: #FAF6EE;
  --board: #F1E9DA;
  --surface: #FFFDF9;
  --hairline: #E0D5C2;
  --ink: #2B2620;
  --muted: #6D6354;

  --notice: #C3452E;
  --rec: #2E7D57;
  --event: #3A6EA5;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* The UA's `[hidden] { display: none }` loses to any author `display` rule
   below, and every demo here toggles `element.hidden` to show and hide
   panels. Without this, hiding silently stops working. */
[hidden] { display: none !important; }

/* A long unbroken token -- a pasted URL, a 200-character "word" -- must wrap
   rather than push its container past its grid track and break the row.
   `anywhere` rather than `break-word` on purpose: only `anywhere` reduces the
   element's min-content width, and a grid or flex item defaults to
   `min-width: auto`, which refuses to shrink below its longest word. With
   `break-word` alone, demo-06 and demo-10 still blew 1.4k px past the viewport.
   The `min-width: 0` below is the other half of the same fix. */
h1, h2, h3, h4, p, li, a, span, strong, em, code, label, time,
button, input, textarea { overflow-wrap: anywhere; }
.card, .post, .listing, .idea, .topic, .question, .profile-card, .submission,
.lesson, .resource, .nominee, .archive-item, .member-card, .comment, .reply,
.answer, .idea-body-wrap { min-width: 0; }


body {
  margin: 0;
  padding-block-end: 96px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.6;
}

.wrap { max-width: 780px; margin-inline: auto; padding: 0 20px; }

h1, h2 { margin: 0; font-weight: 700; letter-spacing: -0.015em; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
/* --event is 4.4:1 on the corkboard ground and 5.2:1 on a card. The type tags
   all sit inside cards so they keep the exact hue; a bare link on the board
   does not, so links get their own darker tone (5.4:1 on the board). Adding the
   board background is what dropped this below AA — it passed on the old flat
   page colour. */
a { color: #33608F; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar {
  padding-block: clamp(34px, 6vw, 60px) 22px;
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: flex-end;
}
.topbar h1 { font-size: clamp(27px, 3.6vw, 40px); line-height: 1.12; }
.topbar > div > p { color: var(--muted); max-width: 50ch; margin-top: 10px; }

.identity-picker { font-size: 12px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.identity-picker select {
  font: inherit; font-size: 14px; letter-spacing: 0; text-transform: none;
  margin-left: 6px; min-height: 44px; padding: 9px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 8px;
}

/* ---------- Compose ---------- */

.new-post {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 22px;
  margin-bottom: 26px;
  box-shadow: 0 1px 0 var(--hairline), 0 14px 28px -22px rgba(43,38,32,0.55);
}
.new-post h2 { font-size: 18px; margin-bottom: 16px; }

.field { display: block; margin-bottom: 14px; }
.field label { display: block; font-size: 12px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--hairline);
  border-radius: 7px; padding: 11px 13px; min-height: 44px;
}
.field textarea { resize: vertical; min-height: 5rem; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); }

.btn {
  font: inherit; font-weight: 650; cursor: pointer;
  min-height: 44px; padding: 12px 22px;
  background: var(--ink); color: var(--bg);
  border: 0; border-radius: 8px;
  transition: transform 140ms ease;
}
.btn:hover { transform: translateY(-1px); }

.btn-ghost {
  font: inherit; font-size: 13px; cursor: pointer;
  min-height: 44px; padding: 10px 15px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 8px;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

/* ---------- Filter tabs ---------- */

.filter-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filter-tab {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  min-height: 44px; padding: 10px 18px;
  background: var(--board); color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 999px;
  transition: background 140ms ease, color 140ms ease;
}
.filter-tab:hover { color: var(--ink); }
.filter-tab.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Feed ---------- */

.post-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }

.post {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 5px solid var(--muted);
  border-radius: 4px;
  padding: 20px 22px;
  box-shadow: 0 1px 0 var(--hairline), 0 14px 30px -24px rgba(43,38,32,0.6);
}
.post[data-type="notice"] { border-left-color: var(--notice); }
.post[data-type="rec"]    { border-left-color: var(--rec); }
.post[data-type="event"]  { border-left-color: var(--event); }

.type-tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  margin-bottom: 8px; color: var(--muted);
}
.post[data-type="notice"] .type-tag { color: var(--notice); }
.post[data-type="rec"]    .type-tag { color: var(--rec); }
.post[data-type="event"]  .type-tag { color: var(--event); }

.post-title { font-size: 19px; line-height: 1.3; margin-bottom: 8px; }
.post-meta { font-size: 13px; color: var(--muted); margin-top: 12px; }
.post-meta strong { color: var(--ink); font-weight: 650; }

/* ---------- Comments ---------- */

.comments { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.comments:empty { margin: 0; }
.comment {
  background: var(--board);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
}
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comment-meta strong { color: var(--ink); font-weight: 650; }
.comment-body { margin: 0; }

.post > .btn-ghost { margin-top: 14px; }

/* ---------- Comment panel ---------- */

.new-comment {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  padding: 16px 20px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  box-shadow: 0 -14px 34px -26px rgba(43,38,32,0.8);
}
.reply-panel-body { flex: 1 1 18rem; }
.reply-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.new-comment textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 10px 12px; min-height: 44px; resize: vertical;
}

/* ---------- Toasts ---------- */

.toast-stack { position: fixed; right: 16px; bottom: 108px; display: grid; gap: 8px; z-index: 50; }
.toast {
  font-size: 13px; background: var(--ink); color: var(--bg);
  border-radius: 8px; padding: 12px 16px;
  box-shadow: 0 16px 34px -20px rgba(43,38,32,0.9);
}
.toast.error { background: var(--notice); color: #FFFFFF; }

/* ---------- Motion ---------- */

.motion .post { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .motion .post { opacity: 1 !important; transform: none !important; }
  .btn, .filter-tab { transition: none !important; }
}


/* ---------- Pinned, on actual paper ---------- */
/* "Neighborhood Board" was only a colour scheme. Give it the board: a faint
   paper tooth under everything, and a pin at the top of every notice. */

body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(43,38,32,0.055) 1px, transparent 0);
  background-size: 7px 7px;
}

.post { padding-top: 26px; }
.post::after {
  content: "";
  position: absolute; top: 11px; left: 50%; transform: translateX(-50%);
  width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #FFF 0 18%, currentColor 22% 100%);
  box-shadow: 0 2px 3px rgba(43,38,32,0.45);
}
.post[data-type="notice"]::after { color: var(--notice); }
.post[data-type="rec"]::after    { color: var(--rec); }
.post[data-type="event"]::after  { color: var(--event); }

/* Masthead: a street sign rather than a heading. */
.topbar h1 {
  display: inline-block;
  background: var(--ink); color: var(--bg);
  padding: 10px 20px 12px;
  border-radius: 3px;
  box-shadow: 4px 4px 0 rgba(43,38,32,0.22);
}


/* ---------- Compose affordance ---------- */
.compose-jump { margin: 0 0 22px; }
.btn-jump {
  font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
  min-height: 44px; padding: 12px 20px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 999px;
  box-shadow: 0 1px 0 var(--hairline);
}
.btn-jump:hover { border-color: var(--ink); }
.new-post { margin-top: 34px; }


/* ---------- Board tally ---------- */
/* A community board says what is on it. Three counts on an index card, pinned
   beside the sign. */

.pl-stats {
  display: flex; gap: 20px; margin: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 14px 20px;
  box-shadow: 0 6px 18px -14px rgba(58,42,28,0.55);
  transform: rotate(-0.7deg);
}
.pl-stats div { text-align: center; }
.pl-stats dt {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 3px;
}
.pl-stats dd {
  margin: 0; font-size: 26px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
/* Each figure takes the colour the feed already uses for that type, so the
   tally and the cards below it read as one system. */
.pl-stats div:nth-child(1) dd { color: var(--notice); }
.pl-stats div:nth-child(2) dd { color: var(--rec); }
.pl-stats div:nth-child(3) dd { color: var(--event); }

@media (max-width: 640px) {
  .pl-stats { flex-wrap: wrap; }
}


/* ---------- An actual board ---------- */
/* Six cards in one 740px column is a feed, not a noticeboard. Widen to the
   board, run the notices in two columns so they pack the way pinned paper
   does, and let each sheet sit at its own small angle. */

@media (min-width: 900px) {
  .wrap { max-width: 1060px; }

  .post-list {
    display: block;             /* grid rows would keep the ragged bottoms */
    columns: 2;
    column-gap: 22px;
  }
  .post {
    break-inside: avoid;
    margin-bottom: 22px;
    /* The rotation has to come off the pin, not the corner, or the pushpin
       drifts away from the paper it is holding. */
    transform-origin: 50% 11px;
  }
  .post:nth-child(3n+1) { rotate: -0.55deg; }
  .post:nth-child(3n+2) { rotate: 0.4deg; }
  .post:nth-child(3n+3) { rotate: -0.15deg; }
  .post:hover { rotate: 0deg; transition: rotate 180ms ease; }
}

@media (prefers-reduced-motion: reduce) {
  .post, .post:hover { rotate: none; transition: none; }
}

/* The ground the paper is pinned to. Cork at this scale is tone and grain, not
   a photograph — two offset dot fields over the board colour. */
body {
  background-color: var(--board);
  background-image:
    radial-gradient(circle at 50% 50%, rgba(120, 92, 58, 0.055) 0 1.1px, transparent 1.6px),
    radial-gradient(circle at 50% 50%, rgba(70, 52, 30, 0.04) 0 0.9px, transparent 1.4px);
  background-size: 13px 13px, 21px 19px;
  background-position: 0 0, 6px 9px;
}


/* --- corrections after review --- */
@media (min-width: 900px) {
  /* Under a degree the tilt is invisible and the sheets just look misaligned.
     Either commit to it or drop it.

     And it has to ride on the independent `rotate` property, not `transform`:
     the entrance animation settles by leaving anime's inline `transform` on
     each card, and an inline style beats anything here — which is why the
     first attempt at this rendered perfectly square. `rotate` composes with
     `transform` instead of being overwritten by it. */
  .post:nth-child(3n+1) { rotate: -1.1deg; }
  .post:nth-child(3n+2) { rotate: 0.85deg; }
  .post:nth-child(3n+3) { rotate: -0.35deg; }

  /* The standfirst still broke at 50ch on a 1018px board. */
  .topbar > div > p { max-width: 62ch; }
}
@media (prefers-reduced-motion: reduce) {
  .post, .post:hover { rotate: none; }
}
