/* Red Wings Rollup — site stylesheet.
   Palette measured directly from the logo (website spec §2, Visual
   identity) — no build step, plain CSS served via FastAPI StaticFiles. */

:root {
  --red: #C3152C;
  --red-deep: #9F1022;
  --cream: #F6F3E7;
  --white: #FFFFFF;
  --text: #2B2420;
  --muted: #6B645C;
  --border: #E4DECD;
  --max-width: 760px;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Header --- */

.site-header {
  border-bottom: 3px solid var(--red);
  background: var(--white);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.site-header img.logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  flex-shrink: 0;
}

.site-header .brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.site-header .brand-name {
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
  color: var(--red);
  text-transform: uppercase;
}

.site-header .brand-tag {
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 480px) {
  .site-header img.logo { width: 56px; height: 56px; }
  .site-header .brand-name { font-size: 1.25rem; }
}

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 18px;
  font-size: 0.92rem;
  font-weight: 600;
}

.site-nav a { color: var(--text); }
.site-nav a:hover { color: var(--red); text-decoration: none; }

/* --- Layout --- */

/* main.wrap (not just `main`) — .wrap's own padding:0 20px is a class
   selector and beats a plain `main` element selector in the cascade, so
   this needs to match or exceed that specificity to actually apply. */
main.wrap { padding-top: 56px; padding-bottom: 56px; min-height: 50vh; }

h1, h2, h3 { line-height: 1.25; }

h1.page-title {
  font-size: 1.9rem;
  margin: 0 0 6px;
}

.subtle { color: var(--muted); font-size: 0.92rem; }

/* --- Rollup summary block --- */

.rollup-summary {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 18px 0 28px;
  font-size: 1.05rem;
}

/* Inline [[cite:ID]] links (website/rollup_render.py) — a picked item
   mentioned mid-narrative, styled to match its story card below via the
   same .platform-icon color rules under "Story cards": those select on
   descendant .platform-icon regardless of ancestor, so platform-rss (and
   the base `a` red) needs no extra rule here, only reddit/twitter, which
   need to win over the plain `a` element selector's default red. */
.rollup-summary p:first-child { margin-top: 0; }
.rollup-summary p:last-child { margin-bottom: 0; }

.inline-cite {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.inline-cite:hover { text-decoration: underline; }
.inline-cite.platform-reddit { color: #D9730D; }
.inline-cite.platform-twitter { color: #1A8CD8; }

/* --- Story cards --- */

.section-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--red-deep);
  margin: 28px 0 10px;
}

.story-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  display: flex;
  gap: 14px;
}

/* Platform accents — see website/templates/_icons.html for why these are
   generic glyphs (document/speech-bubble/@) rather than platform logos. */
.story-card.platform-rss { border-left-color: var(--red); }
.story-card.platform-reddit { border-left-color: #D9730D; }
.story-card.platform-twitter { border-left-color: #1A8CD8; }

.story-thumb {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--cream);
}

.story-body { flex: 1; min-width: 0; }

.story-card .story-blurb { margin: 0 0 8px; }

.story-card .story-meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.story-card .story-source { font-weight: 600; }

.platform-icon {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}

.platform-rss .platform-icon { color: var(--red); }
.platform-reddit .platform-icon { color: #D9730D; }
.platform-twitter .platform-icon { color: #1A8CD8; }

@media (max-width: 480px) {
  .story-thumb { width: 64px; height: 64px; }
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--red-deep);
  border: 1px solid var(--border);
}

/* --- Blog post body ---
   Rendered from Markdown at request time (website/markdown_render.py);
   the source's own heading levels/lists/etc. need real typographic
   treatment here since (unlike the .rollup-summary block) it isn't a
   single short LLM paragraph — it's operator-written long-form content. */

.blog-body {
  font-size: 1.05rem;
  margin-top: 18px;
}

.blog-body h1, .blog-body h2, .blog-body h3 { margin: 1.4em 0 0.5em; }
.blog-body h1 { font-size: 1.5rem; }
.blog-body h2 { font-size: 1.3rem; }
.blog-body h3 { font-size: 1.1rem; }

.blog-body p { margin: 0 0 1em; }

.blog-body ul, .blog-body ol { margin: 0 0 1em; padding-left: 1.4em; }
.blog-body li { margin-bottom: 0.3em; }

.blog-body blockquote {
  margin: 0 0 1em;
  padding: 4px 16px;
  border-left: 4px solid var(--border);
  color: var(--muted);
}

.blog-body code {
  background: var(--cream);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}

.blog-body pre {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
}

.blog-body pre code { background: none; padding: 0; }

.blog-body img { max-width: 100%; border-radius: 8px; }

.blog-body table { border-collapse: collapse; width: 100%; margin: 0 0 1em; }
.blog-body th, .blog-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }

.blog-body hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }

/* --- Archive / rollup list --- */

.rollup-list-item {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.rollup-list-item:first-child { padding-top: 0; }

.rollup-list-item .rollup-date {
  font-weight: 700;
  font-size: 1.05rem;
}

.rollup-list-item .rollup-snippet {
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.94rem;
}

.rollup-list-item mark {
  background: #FBE3C8;
  color: var(--text);
  padding: 0 2px;
  border-radius: 3px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  font-weight: 600;
}

/* --- Search --- */

.search-form {
  display: flex;
  gap: 8px;
  margin: 18px 0 26px;
}

.search-form input[type="text"] {
  flex: 1;
}

/* --- Forms & buttons (shared with admin) --- */

input[type="text"],
input[type="password"],
input[type="date"],
input[type="url"],
input[type="number"],
textarea,
select {
  font-family: inherit;
  font-size: 1rem;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
}

textarea { width: 100%; resize: vertical; }

label { font-weight: 600; font-size: 0.9rem; display: block; margin-bottom: 4px; }

.field { margin-bottom: 16px; }

.btn {
  display: inline-block;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--red);
  color: var(--white);
}

.btn:hover { background: var(--red-deep); text-decoration: none; }

.btn.btn-secondary {
  background: var(--white);
  color: var(--red);
  border: 1px solid var(--red);
}

.btn.btn-secondary:hover { background: var(--cream); }

.btn.btn-danger { background: var(--muted); }
.btn.btn-danger:hover { background: var(--text); }

/* --- Flash / status messages --- */

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  font-weight: 600;
}

.flash.flash-success { background: #E4F3E4; color: #205020; }
.flash.flash-error { background: #FBE3E3; color: var(--red-deep); }

/* --- Footer --- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 40px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- Admin --- */

.admin-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
  font-size: 0.88rem;
  font-weight: 700;
}

.admin-nav a { color: var(--muted); }
.admin-nav a.active, .admin-nav a:hover { color: var(--red); text-decoration: none; }
.admin-nav .spacer { margin-left: auto; }
.admin-nav form { margin: 0; }
.admin-nav button.link-btn {
  background: none; border: none; padding: 0; font: inherit; font-weight: 700;
  color: var(--muted); cursor: pointer;
}
.admin-nav button.link-btn:hover { color: var(--red); }

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--white);
}

table.admin-table th, table.admin-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}

table.admin-table th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; }

.status-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}

.status-pill.status-success, .status-pill.status-published { background: #E4F3E4; color: #205020; }
.status-pill.status-failed, .status-pill.status-error { background: #FBE3E3; color: var(--red-deep); }
.status-pill.status-running, .status-pill.status-draft { background: #FBF0D6; color: #8a6d1a; }
.status-pill.status-unpublished { background: var(--cream); color: var(--muted); }

.item-picker {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  background: var(--white);
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.item-picker-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.item-picker-row:last-child { border-bottom: none; }

.item-picker-row input[type="checkbox"] { margin-top: 4px; }

.item-picker-row .item-picker-body { flex: 1; }

.item-picker-row input[type="text"] { width: 100%; margin-top: 6px; }
.item-picker-row input[type="number"] { width: 70px; }

.manual-item-form {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 10px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px) {
  .grid-2 { grid-template-columns: 1fr; }
  .site-header .brand-tag { display: none; }
}
