/* press — page styles. Tokens and shared components only (see docs/DESIGN.md). */
@layer pages {
  /* ── Article lists: the home page card, a newspaper's page, "more from" ── */
  .latest-news-foot { justify-content: space-between; }
  .news-tabs { margin-bottom: var(--sp-2); }
  .news-tabs .flag { width: 20px; height: 14px; object-fit: cover; }
  .news-list { display: flex; flex-direction: column; }
  .news-row { position: relative; display: flex; justify-content: space-between; gap: var(--sp-4); margin: 0 calc(-1 * var(--sp-3)); padding: var(--sp-4) var(--sp-3);
    border-radius: var(--r-md); color: var(--text); transition: background-color var(--t-fast); }
  .news-row + .news-row::before { content: ""; position: absolute; top: 0; left: var(--sp-3); right: var(--sp-3); height: 1px; background: var(--border-subtle); }
  .news-row:hover { color: var(--text); background: var(--surface-2); }
  .news-row:hover::before, .news-row:hover + .news-row::before { opacity: 0; }
  .news-row:hover h3 { color: var(--brand-text); }
  .news-row:focus-visible { outline-offset: -2px; border-radius: var(--r-md); }
  .news-main { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
  .news-main h3 { overflow-wrap: anywhere; transition: color var(--t-fast); }
  .news-main p { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .news-meta { display: flex; flex-wrap: nowrap; margin-top: var(--sp-1); font-size: var(--fs-xs); line-height: 1.4; color: var(--text-3); white-space: nowrap; overflow: hidden; }
  .news-meta span { flex: none; }
  .news-meta span:first-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .news-meta span + span::before { content: "·"; margin: 0 var(--sp-2); }
  .news-meta .news-paper { color: var(--text-2); font-weight: var(--fw-semibold); }
  .news-side { flex: none; padding-top: 2px; }
  .news-skeleton { display: flex; flex-direction: column; gap: var(--sp-5); padding: var(--sp-2) 0; }
  .news-skeleton > div { display: flex; flex-direction: column; gap: var(--sp-2); }

  /* ── #/press: start a newspaper, or write in yours ── */
  .press-start { align-items: start; }
  .press-perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-5); }
  .press-perks li { display: flex; align-items: flex-start; gap: var(--sp-3); }
  .press-perk-ico { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--r-md); color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border-subtle); }
  .press-perks p { margin-top: 2px; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; }
  .press-count { align-self: flex-end; }
  .press-stats { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); font-size: var(--fs-xs); color: var(--text-3); }
  .press-stats .over { color: var(--red-text); font-weight: var(--fw-semibold); }

  /* ── #/newspaper/<slug> ── */
  .paper-head h1 { overflow-wrap: anywhere; }
  .paper-head .t-overline { margin-bottom: var(--sp-1); }
  .paper-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .paper-stats .stat > .icon { flex: none; }
  .paper-stats .stat b a { color: inherit; }
  .paper-stats .stat b a:hover { color: var(--brand-text); }

  /* ── #/article/<slug> ── */
  .article-wrap { width: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--gap); }
  .article-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: calc(-1 * var(--sp-2)); }
  .article-back { max-width: 100%; min-width: 0; }
  .article-top > .btn:not(.article-back) { flex: none; }
  .article { display: flex; flex-direction: column; gap: var(--sp-6); }
  .article-head { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3); padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border-subtle); }
  .article-head h1 { overflow-wrap: anywhere; }
  .article-head-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); align-self: stretch; }
  .article-owner { display: flex; align-items: center; gap: var(--sp-2); }
  .article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-5); font-size: var(--fs-sm); color: var(--text-2); }
  .article-meta > span { display: inline-flex; align-items: center; gap: 6px; }
  .article-meta a { font-weight: var(--fw-semibold); color: var(--text); }
  .article-meta a:hover { color: var(--brand-text); }
  .article-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding-top: var(--sp-5); border-top: 1px solid var(--border-subtle); }
  .vote-count { margin-left: var(--sp-1); padding-left: var(--sp-3); border-left: 1px solid var(--border); }
  .sub-count { margin-left: var(--sp-1); padding-left: var(--sp-3); border-left: 1px solid var(--border); min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
  .sub-btn.primary .sub-count { border-left-color: color-mix(in srgb, currentColor 40%, transparent); }
  @media (min-width: 900px) { .article.card.pad { padding: var(--sp-10) var(--sp-12); } }

  .comments { display: flex; flex-direction: column; }
  .comment { display: flex; gap: var(--sp-3); padding: var(--sp-4) 0; border-bottom: 1px solid var(--border-subtle); }
  .comment:first-child { padding-top: 0; }
  .comment-avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; color: var(--text-2); background: var(--surface-3);
    box-shadow: 0 0 0 1px var(--border); font: var(--fw-semibold) var(--fs-ui) / 1 var(--font-ui); }
  .comment-main { flex: 1; min-width: 0; }
  .comment-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); min-height: 32px; }
  .comment-head a { font-weight: var(--fw-semibold); color: var(--text); }
  .comment-head a:hover { color: var(--brand-text); }
  .comment-time { font-size: var(--fs-xs); color: var(--text-3); }
  .comment-delete { margin-left: auto; }
  .comment-body { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .comment-form { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-5); }
  .comment-form-foot { display: flex; justify-content: flex-end; }
  .article-comments .pagination { margin-top: var(--sp-2); }

  /* ── Rich article text: one typography for the editor and the reader, so what you write is what
     they read. Built on the reading style (.t-read, Inter 17/29); headings in the display face. ── */
  .rich { font-size: var(--fs-lg); line-height: var(--lh-read); color: var(--text); overflow-wrap: anywhere; }
  .rich > * + * { margin-top: var(--sp-5); }
  .rich p { white-space: normal; }
  .rich h2 { font: var(--fw-semibold) var(--fs-h2) / var(--lh-snug) var(--font-display); letter-spacing: var(--ls-display); color: var(--text); margin-top: var(--sp-10); }
  .rich h3 { font: var(--fw-semibold) var(--fs-h3) / var(--lh-snug) var(--font-display); letter-spacing: var(--ls-cta); text-transform: uppercase; color: var(--text-2); margin-top: var(--sp-8); }
  .rich > h2:first-child, .rich > h3:first-child { margin-top: 0; }
  .rich > h2 + *, .rich > h3 + * { margin-top: var(--sp-3); }
  .rich strong, .rich b { font-weight: var(--fw-semibold); color: var(--text); }
  .rich s, .rich strike { color: var(--text-3); }
  .rich a { font-weight: var(--fw-medium); color: var(--text); text-decoration: underline; text-decoration-color: var(--brand); text-decoration-thickness: 2px; text-underline-offset: 4px; }
  .rich a:hover { color: var(--brand-text); }
  .rich blockquote { margin: var(--sp-8) 0; padding: var(--sp-1) 0 var(--sp-1) var(--sp-6); border-left: 3px solid var(--border-strong);
    font: italic var(--fw-medium) var(--fs-h2) / 1.4 var(--font-ui); letter-spacing: -.01em; color: var(--text); }
  .rich ul, .rich ol { margin-left: 0; margin-right: 0; margin-bottom: 0; padding-left: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); }
  .rich li { padding-left: var(--sp-1); }
  .rich li::marker { color: var(--text-3); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
  .rich hr { position: relative; overflow: visible; width: 40%; height: 1px; margin: var(--sp-10) auto; border: 0; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); }
  .rich hr::after { content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; transform: translate(-50%, -50%) rotate(45deg); background: var(--text-3); }
  .rich figure { margin: var(--sp-8) 0; }
  .rich figure img { width: 100%; max-height: 520px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border-subtle); background: var(--surface-2); box-shadow: var(--shadow-1); }
  .rich figcaption { margin-top: var(--sp-2); font-size: var(--fs-sm); line-height: 1.45; color: var(--text-3); text-align: center; }
  .article-body.rich > p:first-child::first-letter { float: left; margin: 6px var(--sp-2) 0 0; font: var(--fw-bold) 4.1em / .8 var(--font-display); color: var(--text); }

  /* ── The editor: a formatting console over a page that already looks like the article ── */
  .rich-editor { border: 1px solid var(--input-border); border-radius: var(--r-lg); background: var(--input-bg); box-shadow: var(--input-shadow);
    transition: border-color var(--t-fast), box-shadow var(--t-fast); }
  .rich-editor:hover { border-color: var(--input-border-hover); }
  .rich-editor:focus-within { border-color: var(--focus); box-shadow: var(--input-shadow), var(--focus-ring); }
  .rich-toolbar { position: sticky; top: 60px; z-index: 3; display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-2);
    border-bottom: 1px solid var(--border-subtle); border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0; background: var(--surface-overlay); }
  .tool-group { display: flex; gap: 2px; padding: 3px; border-radius: calc(var(--r-md) + 3px); background: var(--surface-sunken); border: 1px solid var(--border-subtle); }
  .tool-group.end { margin-left: auto; }
  .tool { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 var(--sp-2); border-radius: var(--r-md);
    color: var(--text-2); font: var(--fw-semibold) var(--fs-ui) / 1 var(--font-ui); transition: color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-base); }
  .tool:hover { color: var(--text); background: var(--surface-3); }
  .tool.on { color: var(--text); background: var(--surface-raised); box-shadow: var(--highlight), 0 1px 3px color-mix(in srgb, var(--ink) 30%, transparent); }
  .tool:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
  .tool.italic { font-style: italic; }
  .tool.strike { text-decoration: line-through; }
  .rich-field { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3); border-bottom: 1px solid var(--border-subtle); background: var(--surface-2); animation: rich-drop var(--t-base) var(--ease); }
  .rich-field input { flex: 2 1 260px; }
  .rich-field input.caption { flex: 1 1 180px; }
  .rich-field .btn { flex: none; }
  .rich-field .hint { flex-basis: 100%; }
  @keyframes rich-drop { from { opacity: 0; transform: translateY(-4px); } }
  /* The page keeps the reader's measure (the article column is 664px of text), centred in the editor. */
  .rich-page { position: relative; min-height: 360px; padding: var(--sp-6) max(var(--sp-8), calc((100% - 664px) / 2)) var(--sp-8); outline: none; cursor: text; }
  .rich-page.is-empty::before { content: attr(data-placeholder); position: absolute; color: var(--text-3); pointer-events: none; }
  .rich-page figure { cursor: default; }
  .rich-page img { pointer-events: none; }
  .rich-page ::selection { background: var(--brand-soft); }

  @media (max-width: 900px) {
    .paper-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 720px) {
    .rich-toolbar { top: 56px; }
    .paper-head > .btn { width: 100%; }
  }
  @media (max-width: 560px) {
    .press-page .card-head, .news .card-head { flex-wrap: wrap; }
    .press-page .card-head > div, .news .card-head > div { flex: 1 1 220px; }
    .tool-group.end { margin-left: 0; }
    .tool { min-width: 40px; height: 40px; }
    .rich-page { padding: var(--sp-4); }
    .rich blockquote { padding-left: var(--sp-4); }
    .article-body.rich > p:first-child::first-letter { font-size: 3.4em; }
    /* Small in-row buttons keep a 40px touch target. */
    .press-page .btn.sm::before, .news .btn.sm::before { content: ""; position: absolute; inset: -4px 0; }
  }
  @media (prefers-reduced-motion: reduce) {
    .rich-field { animation: none; }
  }
  /* The filters stay on one row; when they do not fit beside the title, the row moves under it. */
  .news-feed .card-head { flex-wrap: wrap; }
  .news-feed .card-head > div:first-child { flex: 1 1 260px; }
  .news-filters { flex: none; display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: var(--sp-3); max-width: 100%; }
  .news-filter { width: 200px; max-width: 100%; }
  /* Room for the longest category name ("Social interactions entertainment"). */
  .news-filter.wide { width: 290px; }
  .news-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
  .news-event { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4) 0; }
  .news-event + .news-event { border-top: 1px solid var(--border-subtle); }
  .news-event-flag .flag { width: 28px; height: 20px; object-fit: cover; }
  .news-event-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
  .news-event time { flex: none; color: var(--text-3); }
  .news-foot { justify-content: center; }
  @media (max-width: 560px) { .news-filters { width: 100%; flex-wrap: wrap; justify-content: stretch; } .news-filter { flex: 1 1 100%; width: auto; } }
}
