/* ── Fonts ──────────────────────────────────────────────────── */
@font-face {
  font-family: 'Merriweather';
  src: url('fonts/merriweather-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'Merriweather';
  src: url('fonts/merriweather-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: 'Merriweather';
  src: url('fonts/Merriweather-Black.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Nord – Polar Night */
  --nord0: #2e3440;
  --nord1: #3b4252;
  --nord2: #434c5e;
  --nord3: #4c566a;
  /* Nord – Snow Storm */
  --nord4: #d8dee9;
  --nord5: #e5e9f0;
  --nord6: #eceff4;
  /* Nord – Aurora accent (terracotta) */
  --nord12: #d08770;

  --bg:          var(--nord5);
  --surface:     var(--nord6);
  --border:      var(--nord4);
  --text:        var(--nord0);
  --muted:       var(--nord3);
  --accent:      var(--nord12);
  --accent-soft: #f2e8e4;
  --rank-bg:     var(--nord1);
  --rank-text:   var(--nord6);
  --shadow:      0 2px 12px rgba(46,52,64,.08);
  --radius:      14px;
  --font-head:   'Merriweather', Georgia, serif;
  --font-body:   'Inter', system-ui, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  background: var(--nord0);
  border-bottom: 1px solid var(--nord1);
  padding: 0 20px;
  height: 36px;
  display: flex;
  align-items: center;
}

.topbar-link {
  font-size: 0.8rem;
  color: var(--nord3);
  text-decoration: none;
}
.topbar-link:hover { color: var(--nord4); }

/* ── Dark header band ───────────────────────────────────────── */
.page-header {
  background: var(--nord0);
  width: 100%;
}

.page-inner {
  max-width: 740px;
  margin: 0 auto;
  padding: 48px 20px 40px;
}

/* ── Page shell (content area) ──────────────────────────────── */
.page {
  max-width: 740px;
  margin: 0 auto;
  padding: 40px 20px 64px;
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  margin-bottom: 0;
}

.site-header h1 {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 2.6rem;
  line-height: 1.15;
  color: var(--nord6);
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--nord4);
  max-width: 560px;
  margin-bottom: 20px;
}

.meta-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
}

.meta-chip {
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 500;
}

.meta-chip--server {
  background: var(--nord2);
  color: var(--nord4);
}

.meta-chip--tag {
  background: var(--nord1);
  color: #88c0d0; /* nord8, Frost teal */
}

.meta-sep {
  color: var(--nord3);
  font-size: 0.7rem;
  padding: 0 1px;
}

/* ── Loading ─────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ───────────────────────────────────────────────────── */
.error-msg {
  background: #f5e0e2;
  border: 1px solid #bf616a;
  border-radius: var(--radius);
  padding: 20px 24px;
  color: #8a3030;
  font-size: 0.9rem;
}

/* ── Post list ───────────────────────────────────────────────── */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 16px;
  padding-left: 20px;
}

/* ── Post card ───────────────────────────────────────────────── */
.post-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 0 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px 24px;
  position: relative;
}

/* rank badge */
.post-rank {
  position: absolute;
  top: -14px;
  left: -20px;
  background: var(--rank-bg);
  color: var(--rank-text);
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.05rem;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 8px;
  width: 52px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(46,52,64,.18);
}

.rank-change {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.58rem;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}
.rank-change.new  { color: #ebcb8b; } /* nord13 gold   */
.rank-change.up   { color: #a3be8c; } /* nord14 sage   */
.rank-change.down { color: #bf616a; } /* nord11 red    */

/* avatar column */
.post-avatar {
  grid-column: 1;
  grid-row: 1;
  padding-top: 4px;
}

.post-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--border);
}

/* content column */
.post-content {
  grid-column: 2;
  min-width: 0;
}

.post-author-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.post-author {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
}
.post-author:hover { color: var(--accent); }

.post-handle {
  font-size: 0.82rem;
  color: var(--muted);
}

.post-date {
  font-size: 0.82rem;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

/* post body */
.post-body {
  font-size: 0.95rem;
  line-height: 1.65;
  word-break: break-word;
  margin-bottom: 12px;
}

.post-body a {
  color: var(--accent);
  text-decoration: none;
}
.post-body a:hover { text-decoration: underline; }

/* media */
.post-media {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.post-media img,
.post-media video {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
}

/* ── OpenGraph card ──────────────────────────────────────────── */
.og-card {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.og-card:hover { border-color: var(--accent); }

.og-image {
  width: 120px;
  min-height: 80px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
  display: block;
}

.og-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.og-provider {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.og-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.og-description {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

@media (max-width: 540px) {
  .og-image { width: 80px; }
}

/* link to post */
.post-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 14px;
}
.post-link:hover { color: var(--accent); }

.post-link svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* stats row */
.post-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
}

.stat svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.stat-engagement {
  margin-left: auto;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-engagement svg {
  width: 15px;
  height: 15px;
}

/* ── Controls bar (filter + sort) ────────────────────────────── */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.segment-control {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segment {
  padding: 7px 18px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segment + .segment {
  border-left: 1px solid var(--border);
}

.segment.active {
  background: var(--nord1);
  color: var(--nord6);
  font-weight: 600;
}

.segment:not(.active):not([disabled]):hover {
  background: var(--border);
  color: var(--text);
}

.segment[disabled] {
  color: var(--border);
  cursor: default;
}

.segment--refresh {
  font-size: 1rem;
  padding: 4px 12px;
  color: var(--muted);
}

.segment--refresh:hover {
  color: var(--text);
  background: var(--border);
}

/* ── Fresh badge ─────────────────────────────────────────────── */
.fresh-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  color: #88c0d0;
  margin-left: 5px;
  vertical-align: middle;
}

/* ── Engagement delta ────────────────────────────────────────── */
.eng-delta {
  font-size: 0.72rem;
  font-weight: 600;
  margin-left: 5px;
}
.eng-delta.up   { color: #a3be8c; }
.eng-delta.down { color: #bf616a; }

/* hide unchanged posts when filter is active */
.post-list.filter-changes .post-card:not([data-changed]) {
  display: none;
}

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}
.site-footer a:hover { color: var(--accent); }

.site-footer .sep {
  margin: 0 8px;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 540px) {
  .site-header h1 { font-size: 2rem; }
  .page-inner { padding: 32px 16px 28px; }
  .page { padding: 28px 16px 48px; }
  .post-card { grid-template-columns: 44px 1fr; padding: 18px 16px; }
  .post-list { padding-left: 16px; }
  .post-avatar img { width: 38px; height: 38px; }
  .post-date { display: none; }
  .stat-engagement { margin-left: 0; }
}
