/* content.css — pages and news: the public extras the blocks need, the
 * draft preview, and the staff editors (the page builder and the post form).
 *
 * Linked by the pages that use it (builder pages, /news, previews, the
 * Pages and News screens). Colours, radii, shadows and easing are tokens
 * from tokens.css, so dark mode needs nothing here. Motion is opacity,
 * transform and colour only, and stops under prefers-reduced-motion (the
 * base stylesheets switch every transition off).
 *
 *   public   .page-hero--photo (.page-hero-media .page-hero-shade) .card-icon
 *            .quote-mark .cta-band--photo .cta-media .news-lead .news-pager
 *            .empty-note .related-title
 *   preview  .preview-bar .preview-error .pb-highlight
 *   staff    .pb-* (page builder)  .md-bar  .input-prefix  .post-*  .template-choices
 */

/* ======================= Public ======================= */

/* Hero with a photo behind the band: the image under a shade, text on top. */
.page-hero--photo { min-height: 380px; display: flex; align-items: flex-end; color: var(--on-dark); background: var(--band) }
.page-hero-media { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover }
.page-hero-shade { position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, var(--scene-top) 0%, var(--hero-shade) 100%) }
.page-hero--photo .page-hero-title, .page-hero--photo .page-hero-lede, .page-hero--photo .breadcrumb, .page-hero--photo .breadcrumb a { color: var(--on-dark) }
.page-hero--photo .eyebrow { color: var(--on-dark-soft) }

/* A card that shows an icon instead of an image. */
.card-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--tint); color: var(--ink); font-size: 22px; transition: background-color .3s, color .3s }
a.link-card:hover .card-icon { background: var(--brand); color: var(--on-brand) }
.link-card.is-static { cursor: default }

/* Quote: a large mark in the accent colour. */
.quote-mark { display: block; font-size: 40px; color: var(--accent); margin-bottom: 12px }

/* Call to action over a photo: the card sits on the image. */
.cta-band--photo { background: var(--band) }
.cta-media { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover }

/* News: the newest story as a wide lead card. */
.news-lead { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); margin-bottom: 32px }
.news-lead .news-media { aspect-ratio: auto; height: 100%; min-height: 340px }
.news-lead .news-body { padding: 40px; align-content: center; gap: 16px }
.news-lead h2 { font-size: var(--text-3xl) }
.news-lead h2 a { color: var(--ink); text-decoration: none !important }
.news-lead h2 a::after { content: ""; position: absolute; inset: 0 }
.news-lead:hover h2 a { text-decoration: underline !important; text-decoration-color: var(--brand) !important }
.news-lead .text-link { justify-self: start }
.news-media .media-placeholder { height: 100% }
.news-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px }
.news-pager .btn:only-child { margin-left: auto }
.empty-note { display: grid; justify-items: center; gap: 12px; padding: 72px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--text-muted); text-align: center }
.empty-note .i { font-size: 32px; color: var(--brand-strong) }
.related-title { margin-bottom: 32px }
@media (max-width: 760px) {
  .news-lead { display: flex }
  .news-lead .news-media { aspect-ratio: 16/9; min-height: 0 }
  .news-lead .news-body { padding: 24px }
  .news-lead h2 { font-size: var(--text-2xl) }
  .page-hero--photo { min-height: 300px }
}

/* ======================= Preview ======================= */

.preview-bar { position: sticky; top: 0; z-index: 70; background: var(--warning-soft); color: var(--warning-text); border-bottom: 1px solid var(--warning-line); font-size: var(--text-sm) }
.preview-bar-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-block: 10px }
.preview-bar span { display: inline-flex; align-items: center; gap: 8px }
.preview-bar a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: inherit; text-decoration-color: currentColor }
.preview-error { display: flex; align-items: center; gap: 10px; margin: 20px 0 0; padding: 12px 16px; border: 1px solid var(--danger-line); border-left: 4px solid var(--danger); border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger-text); font-size: var(--text-sm) }
.page-block { position: relative }
.page-block.pb-highlight::after { content: ""; position: absolute; inset: 0; z-index: 40; pointer-events: none; box-shadow: inset 0 0 0 3px var(--brand); animation: pb-flash 1.6s var(--ease-out) forwards }
@keyframes pb-flash { 0%, 60% { opacity: 1 } 100% { opacity: 0 } }

/* ======================= Staff: shared ======================= */

/* Lists: secondary columns step aside on a phone so status and actions stay in view. */
@media (max-width: 640px) { .table .col-wide, .table .row-actions > a.btn { display: none } .table .cell-title { min-width: 7rem } .table .label-wide { display: none } }
@media (min-width: 641px) { .table .narrow-only { display: none } }
.input-prefix { display: flex; align-items: stretch; border: 1px solid var(--ui-input); border-radius: var(--ui-radius); background: var(--ui-bg); box-shadow: var(--ui-shadow-sm); overflow: hidden }
.input-prefix:focus-within { border-color: var(--ui-ring); box-shadow: 0 0 0 3px var(--ui-ring-soft) }
.input-prefix > span { display: grid; place-items: center; padding: 0 .1rem 0 .7rem; color: var(--ui-muted-fg); font-size: .84rem; white-space: nowrap; background: var(--ui-subtle) }
.staff-app .input-prefix > input { border: 0 !important; box-shadow: none !important; border-radius: 0; padding-left: .35rem }
.template-choices { border: 0; margin: 0; padding: 0; display: grid; gap: .5rem; min-width: 0 }
.template-choices .grid { gap: .6rem }
.template-choices legend { padding: 0; margin-bottom: .5rem }
.empty-state-page { min-height: 50vh }

/* Markdown buttons over a textarea (page builder and post form). */
.md-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .1rem; padding: .25rem; border: 1px solid var(--ui-input); border-bottom: 0; border-radius: var(--ui-radius) var(--ui-radius) 0 0; background: var(--ui-subtle) }
.md-bar button { all: unset; display: inline-grid; grid-auto-flow: column; place-items: center; gap: .3rem; min-width: 1.75rem; height: 1.65rem; padding: 0 .35rem; border-radius: var(--ui-radius-sm); font-size: .78rem; color: var(--ui-soft-fg); cursor: pointer; box-sizing: border-box; transition: background-color .12s, color .12s }
.md-bar button:hover { background: var(--ui-accent); color: var(--ui-fg) }
.md-bar button:focus-visible { outline: 2px solid var(--ui-ring); outline-offset: 1px }
.md-bar button > span:not(.visually-hidden) { font-weight: 600 }
.md-hint { margin-left: auto; padding-right: .4rem; font-size: .7rem; color: var(--ui-muted-fg) }
.md-bar + textarea, .md-bar + .pb-md { border-top-left-radius: 0 !important; border-top-right-radius: 0 !important }

/* ======================= Staff: news post form ======================= */

.post-main { padding-top: 1.25rem }
.staff-app .post-title-input { height: 2.75rem !important; font-size: 1.15rem !important; font-weight: 600 !important; letter-spacing: -.01em }
.staff-app textarea.post-body-input { min-height: 26rem; font: 400 .92rem/1.7 var(--font-sans) !important }
@media (max-width: 640px) { .staff-app textarea.post-body-input { min-height: 16rem; height: 18rem } .md-hint { display: none } }
.field-head { justify-content: space-between }
.post-links { display: grid; gap: .35rem; padding-top: .35rem }
.post-links .link { display: inline-flex; align-items: center; gap: .4rem }
.post-badges { margin-top: .6rem }

/* ======================= Staff: page builder ======================= */

/* The editor fills the workspace: a sticky toolbar, then panel + stage. */
.staff-content.page-builder { max-width: none; padding: 0 }
.pb-toolbar { position: sticky; top: 3.25rem; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .55rem 1rem; background: var(--ui-topbar); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--ui-border) }
.pb-title { display: grid; min-width: 10rem; flex: 1 1 12rem; max-width: 26rem }
.staff-app .pb-title input { height: 1.85rem !important; padding: 0 .3rem !important; border-color: transparent !important; box-shadow: none !important; background: transparent !important; font-size: 1rem !important; font-weight: 650; letter-spacing: -.01em }
.staff-app .pb-title input:hover { background: var(--ui-muted) !important }
.staff-app .pb-title input:focus { background: var(--ui-bg) !important; border-color: var(--ui-ring) !important; box-shadow: 0 0 0 3px var(--ui-ring-soft) !important }
.pb-title .cell-sub { padding-left: .3rem }
.pb-devices > button .i { font-size: .95rem }
.pb-alert { margin: .75rem 1rem 0 }
.pb-layout { display: grid; grid-template-columns: 24rem minmax(0, 1fr); min-height: calc(100vh - 6.6rem) }

/* Left: the block list. */
.pb-panel { position: sticky; top: 6.6rem; align-self: start; height: calc(100vh - 6.6rem); overflow: auto; padding: 1rem; border-right: 1px solid var(--ui-border); background: var(--ui-subtle); scrollbar-width: thin }
.pb-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .65rem }
.pb-panel-head strong { font-size: .86rem; display: inline-flex; align-items: center; gap: .4rem }
.pb-count { display: inline-grid; place-items: center; min-width: 1.3rem; height: 1.3rem; padding: 0 .35rem; border-radius: 999px; background: var(--ui-muted); color: var(--ui-muted-fg); font-size: .7rem; font-weight: 600 }
.pb-count:empty { display: none }
.pb-outline { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem }
.pb-loading { display: grid; gap: .4rem }
.pb-loading .skeleton { display: block; height: 2.9rem }
.pb-block { border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: var(--ui-bg); box-shadow: var(--ui-shadow-sm); transition: border-color .12s, box-shadow .12s, opacity .12s }
.pb-block:hover { border-color: var(--ui-border-strong) }
.pb-block.is-open { border-color: var(--ui-primary-hover); box-shadow: 0 0 0 1px var(--ui-primary-hover) }
.pb-block.is-hidden .pb-block-text, .pb-block.is-hidden .pb-block-icon { opacity: .5 }
.pb-block.is-dragging { opacity: .4 }
.pb-block.is-over { box-shadow: 0 -3px 0 0 var(--ui-ring) }
.pb-block-head { display: flex; align-items: center; gap: .5rem; padding: .45rem .5rem .45rem .35rem; cursor: pointer; border-radius: inherit }
.pb-block-head:focus-visible { outline: 2px solid var(--ui-ring); outline-offset: -2px }
.pb-grip { display: grid; color: var(--ui-faint); cursor: grab; flex: none }
.pb-grip:active { cursor: grabbing }
.pb-block:hover .pb-grip { color: var(--ui-muted-fg) }
.pb-block-icon { display: grid; place-items: center; width: 1.85rem; height: 1.85rem; border-radius: var(--ui-radius-sm); background: var(--ui-muted); color: var(--ui-soft-fg); flex: none }
.pb-block.is-open .pb-block-icon { background: var(--success-soft); color: var(--success) }
.pb-block-text { flex: 1; min-width: 0; display: grid }
.pb-block-text strong { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.pb-block-text small { font-size: .7rem; color: var(--ui-muted-fg) }
.pb-block-actions { display: flex; opacity: 0; transition: opacity .12s }
.pb-block:hover .pb-block-actions, .pb-block.is-open .pb-block-actions, .pb-block-head:focus-within .pb-block-actions { opacity: 1 }
.pb-danger:hover { color: var(--danger) }
.pb-caret { color: var(--ui-muted-fg); font-size: .95rem; flex: none; transition: transform .15s }
.pb-block.is-open .pb-caret { transform: rotate(180deg) }
.pb-block-body { display: grid; gap: .85rem; padding: .85rem; border-top: 1px solid var(--ui-border); animation: pb-open .16s ease-out }
@keyframes pb-open { from { opacity: 0; transform: translateY(-3px) } to { opacity: 1; transform: none } }
.staff-app .pb-md { font: 400 .8rem/1.6 var(--font-mono) !important; min-height: 8rem }
.pb-md-wrap { display: grid }
.pb-empty { display: grid; justify-items: center; gap: .3rem; padding: 2rem 1rem; border: 1.5px dashed var(--ui-border-strong); border-radius: var(--ui-radius); text-align: center; color: var(--ui-muted-fg); font-size: .8rem }
.pb-empty .i { font-size: 1.6rem; color: var(--ui-faint) }
.pb-empty strong { color: var(--ui-fg); font-size: .86rem }
.pb-tip { display: flex; align-items: center; gap: .4rem; margin: .75rem 0 0 !important; font-size: .72rem; color: var(--ui-muted-fg) }
.pb-seo { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--ui-border); font-size: .82rem }
.pb-seo > summary { display: flex; align-items: center; gap: .45rem; cursor: pointer; font-weight: 600; list-style: none; padding: .25rem 0 }
.pb-seo > summary::-webkit-details-marker { display: none }
.pb-seo[open] > summary { margin-bottom: .75rem }

/* Repeatable items inside a block. */
.pb-list { display: grid; gap: .4rem; grid-template-columns: minmax(0, 1fr); min-width: 0 }
/* long titles in a block (a slide, a card) end with … instead of widening the panel */
.pb-block-body { grid-template-columns: minmax(0, 1fr) }
.pb-sub, .pb-field, .pb-sub > summary { min-width: 0 }
.pb-list-head { display: flex; align-items: baseline; justify-content: space-between }
.pb-list-count { font-size: .7rem; color: var(--ui-muted-fg) }
.pb-sub { border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); background: var(--ui-subtle) }
.pb-sub > summary { display: flex; align-items: center; gap: .35rem; padding: .3rem .35rem .3rem .5rem; cursor: pointer; list-style: none; font-size: .8rem; font-weight: 550 }
.pb-sub > summary::-webkit-details-marker { display: none }
.pb-sub-caret { font-size: .85rem; color: var(--ui-muted-fg); transition: transform .15s }
.pb-sub[open] .pb-sub-caret { transform: rotate(90deg) }
.pb-sub-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.pb-sub-actions { display: flex; flex: none }
.pb-sub-body { display: grid; gap: .7rem; padding: .35rem .6rem .75rem; border-top: 1px solid var(--ui-border) }
.pb-add-item { justify-self: start }
.pb-field .media-field { margin: 0 }

/* Right: the preview, framed like a browser on a quiet backdrop. */
.pb-stage { display: grid; justify-items: center; align-content: start; padding: 1rem; background: var(--ui-muted); min-width: 0 }
.pb-frame { width: 100%; height: calc(100vh - 8.6rem); border-radius: var(--ui-radius-lg); overflow: hidden; background: var(--ui-bg); box-shadow: var(--ui-shadow-lg); border: 1px solid var(--ui-border); transition: opacity .2s }
.pb-frame[data-device="mobile"] { width: 390px; max-width: 100% }
.pb-frame.is-loading { opacity: .75 }
.pb-frame iframe { display: block; width: 100%; height: 100%; border: 0 }
/* Desktop renders a real 1280px-wide page and scales it down to the stage, so
   the preview shows the desktop layout, not the tablet one its width implies.
   page-editor.js sets --pb-scale (1 when the stage is wide enough). */
.pb-frame[data-device="desktop"] iframe { width: calc(100% / var(--pb-scale, 1)); height: calc(100% / var(--pb-scale, 1)); transform: scale(var(--pb-scale, 1)); transform-origin: 0 0 }

/* The "Add a block" palette. */
.staff-app dialog.pb-palette { width: min(46rem, calc(100vw - 2rem)) }
.pb-palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .5rem }
.pb-palette-item { all: unset; box-sizing: border-box; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .7rem; align-items: center; padding: .75rem .85rem; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); cursor: pointer; font-size: .84rem; transition: border-color .12s, background-color .12s, transform .12s }
.pb-palette-item:hover, .pb-palette-item:focus-visible { border-color: var(--ui-ring); background: var(--success-soft); transform: translateY(-1px) }
.pb-palette-item:focus-visible { outline: 2px solid var(--ui-ring); outline-offset: 1px }
.pb-palette-icon { grid-row: span 2; display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: var(--ui-radius-sm); background: var(--ui-muted); color: var(--ui-soft-fg); font-size: 1rem }
.pb-palette-item strong { font-weight: 600 }
.pb-palette-item small { grid-column: 2; font-size: .72rem; line-height: 1.35; color: var(--ui-muted-fg) }

@media (max-width: 1100px) {
  .pb-layout { grid-template-columns: minmax(0, 1fr) }
  .pb-panel { position: static; height: auto; max-height: none; border-right: 0; border-bottom: 1px solid var(--ui-border) }
  .pb-frame { height: 75vh }
}
@media (max-width: 640px) {
  .pb-toolbar { top: 3.25rem; padding: .5rem .75rem }
  .pb-title { flex: 1 1 100%; order: -1 }
  .pb-hide-sm, .pb-devices > button span { display: none }
  .pb-stage { padding: .5rem }
  .pb-alert { margin: .5rem .75rem 0 }
}

/* [CMS CORE] Pages screen: built-in pages (lib/cms/builtin-pages.js). */
.card + .card { margin-top: 1.25rem }
.row-child .cell-title { padding-left: 1.25rem; position: relative }
.row-child .cell-title::before { content: ""; position: absolute; left: .35rem; top: .2rem; width: .55rem; height: .6rem; border-left: 1px solid var(--ui-border); border-bottom: 1px solid var(--ui-border) }
.source-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .15rem .9rem; font-size: .85rem }
.cell-sources { min-width: 14rem }
.cell-sources .cell-sub { display: block; margin-top: .25rem }

/* Page builder: group headings in "Add a block", where a list block's entries come from, the how-to panel. */
.pb-palette-group { grid-column: 1 / -1; margin: .75rem 0 .1rem; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ui-muted-fg) }
.pb-palette-group:first-child { margin-top: 0 }
.staff-app dialog.pb-palette .dialog-body { max-height: min(80vh, 46rem); overflow-y: auto }
.pb-source { display: flex; gap: .5rem; align-items: flex-start; margin: 0 0 .75rem; padding: .6rem .75rem; border-radius: var(--ui-radius-sm); background: var(--ui-muted); font-size: .8rem; line-height: 1.45 }
.pb-source .i { margin-top: .15rem; flex: none; color: var(--ui-muted-fg) }
.pb-help { margin: 0 0 .75rem; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: var(--ui-card); font-size: .82rem }
.pb-help > summary { cursor: pointer; padding: .55rem .75rem; font-weight: 600; display: flex; gap: .45rem; align-items: center }
.pb-help ol { margin: 0; padding: 0 .9rem .75rem 2.1rem; display: grid; gap: .35rem; line-height: 1.45; color: var(--ui-muted-fg) }
.pb-help strong { color: var(--ui-fg) }
.choice-inline { display: flex; gap: .5rem; align-items: center; font-size: .85rem; cursor: pointer }

/* Content list block (blocks/content-list) [CMS CORE] */
.content-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line) }
.content-rows > li { display: flex; gap: 1.25rem; align-items: flex-start; padding: 1.25rem 0; border-bottom: 1px solid var(--line) }
.content-row-media { flex: none; width: 7.5rem; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius-sm); background: var(--tint) }
.content-row-media img { width: 100%; height: 100%; object-fit: cover; display: block }
.content-row-body { min-width: 0; display: grid; gap: .35rem }
.content-row-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 }
.content-row-meta:empty { display: none }
.content-row-title { margin: 0; font-size: 1.15rem; line-height: 1.3 }
.content-row-title a { color: inherit; text-decoration: none }
.content-row-title a:hover { text-decoration: underline; text-underline-offset: .2em }
.content-row-text { margin: 0; color: var(--text-muted) }
@media (max-width: 560px) { .content-row-media { width: 5rem } }
.content-table-wrap { overflow-x: auto }
.content-table { width: 100%; border-collapse: collapse; font-size: .95rem }
.content-table th, .content-table td { text-align: left; padding: .7rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top }
.content-table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted) }
.content-table tbody th { font-weight: 600 }

/* Generic entry page (c/[type]/[slug]) [CMS CORE] */
.entry-detail { display: grid; gap: 1.75rem }
.entry-field-label { margin: 0 0 .4rem; font: 600 var(--text-xs)/1.3 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted) }
.entry-field > p { margin: 0 }
.entry-text { white-space: pre-line }
.entry-gallery { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)) }
.entry-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); display: block }
.entry-files, .entry-links, .entry-rows { margin: 0; padding-left: 1.1rem; display: grid; gap: .35rem }
.entry-files { list-style: none; padding-left: 0 }
.entry-files a { display: inline-flex; gap: .45rem; align-items: center }
.entry-rows span { margin-right: .75rem }
