/* ===== Tokens ===== */
:root {
  --paper: #F5F6F8;
  --surface: #FFFFFF;
  --ink: #0F1B2D;
  --muted: #5B6678;
  --line: #DDE1E8;
  --brand: #1F3A8A;
  --brand-dark: #14264F;
  --accent: #E3A02B;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --container: 1120px;
  --header-h: 80px;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 100px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-family: var(--serif); font-weight: 600; line-height: 1.15; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }

/* ===== Header ===== */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header.is-scrolled { box-shadow: 0 2px 18px rgba(15, 27, 45, .08); }
.scroll-progress { position: absolute; left: 0; bottom: -1px; height: 3px; width: 0; background: var(--accent); z-index: 2; }

.nav-inner { display: flex; align-items: center; gap: 40px; min-height: var(--header-h); }
.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo img { height: 52px; width: auto; max-width: 240px; object-fit: contain; }

.nav-menu { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a {
  position: relative; padding: 8px 16px; font-size: .95rem; font-weight: 500; color: var(--muted);
  transition: color .2s;
}
.nav-links a::after {
  content: ''; position: absolute; left: 16px; right: 16px; bottom: 2px; height: 2px;
  background: var(--brand); transform: scaleX(0); transform-origin: left; transition: transform .25s;
}
.nav-links a:hover, .nav-links a.active { color: var(--ink); }
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }

.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-search {
  display: flex; align-items: center; gap: 10px;
  width: 220px; height: 42px; padding: 0 16px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); transition: border-color .2s, box-shadow .2s, background .2s;
}
.nav-search:focus-within { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 58, 138, .12); }
.nav-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: .9rem; color: var(--ink); }

.btn-back {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 999px;
  background: var(--brand); color: #fff;
  font-size: .875rem; font-weight: 500; white-space: nowrap;
  transition: background .2s, color .2s;
}
.btn-back:hover { background: var(--accent); color: var(--ink); }

.nav-toggle {
  display: none; width: 44px; height: 44px; margin-left: auto; padding: 0;
  background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  flex-direction: column; justify-content: center; align-items: center; gap: 5px;
}
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--ink); transition: transform .25s, opacity .2s; }
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== Posts grid ===== */
.posts-section { padding-top: 48px; padding-bottom: 80px; }
.search-note { margin-bottom: 28px; color: var(--muted); }
.search-note a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }

.posts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }

.featured-post {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  transition: transform .25s, box-shadow .25s;
}
.featured-post:hover { transform: translateY(-4px); box-shadow: 0 14px 32px rgba(15, 27, 45, .10); }

.post-img-col { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--line); }
.post-img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.featured-post:hover .post-img { transform: scale(1.04); }

.post-num {
  position: absolute; top: 12px; left: 12px;
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--brand-dark); color: #fff; border-radius: 8px;
  font-family: var(--serif); font-size: 1.2rem; font-weight: 600; line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}

.post-text-col { display: flex; flex-direction: column; align-items: flex-start; flex: 1; padding: 22px 22px 24px; min-width: 0; }
.author-date { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); }
.sep { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

.post-title {
  margin: 10px 0; font-size: 1.55rem; letter-spacing: -.005em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-title a:hover { color: var(--brand); }
.post-excerpt {
  color: var(--muted); line-height: 1.7; margin-bottom: 20px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.featured-post .read-link {
  margin-top: auto; padding-bottom: 2px; color: var(--brand); font-weight: 500; font-size: .9rem;
  border-bottom: 2px solid var(--accent);
}
.featured-post .read-link:hover { color: var(--brand-dark); }
.empty-state { grid-column: 1 / -1; padding: 60px 0; text-align: center; color: var(--muted); }
.empty-state a { color: var(--brand); text-decoration: underline; }

/* ===== Pagination ===== */
.pagination-wrap { margin-top: 48px; display: flex; justify-content: center; }
.pagination-wrap nav { display: flex; justify-content: center; }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.pagination li a, .pagination li span {
  display: grid; place-items: center; min-width: 42px; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: .9rem; color: var(--ink); transition: border-color .2s, color .2s;
}
.pagination li a:hover { border-color: var(--brand); color: var(--brand); }
.pagination li.active span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination li.disabled span { color: #a3abb8; background: var(--paper); }

/* ===== Single post ===== */
.single-post { max-width: 760px; margin: 0 auto; }
.back-link {
  display: inline-flex; align-items: center; margin-bottom: 28px; padding: 8px 18px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--brand); font-size: .9rem; font-weight: 500; transition: border-color .2s;
}
.back-link:hover { border-color: var(--brand); }
.single-post .post-title {
  display: block; margin: 0 0 16px; font-size: clamp(2.2rem, 5vw, 3.4rem); letter-spacing: -.01em;
}
.single-img { width: 100%; max-height: 460px; object-fit: cover; border-radius: 12px; margin: 32px 0; }
.post-body { font-size: 1.075rem; line-height: 1.85; color: #243044; margin-top: 28px; }
.post-body p { margin: 0 0 1.4em; }
.post-body h2, .post-body h3 { margin: 1.8em 0 .6em; color: var(--ink); }
.post-body h2 { font-size: 2rem; }
.post-body h3 { font-size: 1.5rem; }
.post-body img { border-radius: 10px; margin: 1.5em 0; }
.post-body a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.post-body blockquote {
  margin: 1.8em 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--accent);
  font-family: var(--serif); font-size: 1.5rem; line-height: 1.4; color: var(--ink);
}
.post-body ul, .post-body ol { padding-left: 1.4em; margin: 0 0 1.4em; }

.latest-posts { max-width: var(--container); margin: 80px auto 0; padding-top: 48px; border-top: 1px solid var(--line); }
.latest-posts h2 { font-size: 2rem; margin-bottom: 28px; }
.latest-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.latest-card {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; transition: border-color .2s;
}
.latest-card:hover { border-color: var(--brand); }
.latest-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; }
.latest-card h3 { font-size: 1.35rem; margin-top: 4px; }

/* ===== Footer ===== */
.site-footer { background: var(--brand-dark); color: #cfd6e6; }
.footer-grid { display: grid; grid-template-columns: 1.1fr 2fr .7fr; gap: 56px; padding-top: 64px; padding-bottom: 56px; }
.footer-logo { display: inline-block; padding: 6px 10px; background: #fff; border-radius: 8px; }
.footer-logo img { height: 48px; width: auto; max-width: 220px; object-fit: contain; }
.footer-brand p { margin: 18px 0 22px; max-width: 28ch; color: #9fabc6; }

.site-footer h3 { font-size: 1.6rem; color: #fff; margin-bottom: 24px; }
.site-footer h4 { font-family: var(--sans); font-size: .85rem; font-weight: 500; color: var(--accent); margin-bottom: 8px; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 40px; }
.contact-item p { line-height: 1.8; }
.contact-item a, .footer-links a { transition: color .2s; }
.contact-item a:hover, .footer-links a:hover { color: var(--accent); }
.footer-links { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.footer-links h3 { margin-bottom: 14px; }

.btn-site {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .4); color: #fff; font-size: .875rem; font-weight: 500;
  transition: background .2s, color .2s, border-color .2s;
}
.btn-site:hover { background: var(--accent); border-color: var(--accent); color: var(--ink); }

.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .12); font-size: .85rem; color: #9fabc6; }
.footer-bottom-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 64px; }
.footer-site-link:hover { color: var(--accent); }

.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 90;
  width: 46px; height: 46px; border: 0; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 1.2rem; cursor: pointer;
  box-shadow: 0 6px 20px rgba(15, 27, 45, .25);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .25s, transform .25s, visibility .25s;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .nav-inner { gap: 16px; }
  .nav-toggle { display: flex; }
  .nav-menu {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 16px;
    padding: 20px 24px 24px; background: var(--surface);
    border-bottom: 1px solid var(--line); box-shadow: 0 14px 24px rgba(15, 27, 45, .08);
    display: none;
  }
  .nav-menu.open { display: flex; }
  .nav-links { flex-direction: column; align-items: stretch; gap: 0; }
  .nav-links a { padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .nav-links a::after { display: none; }
  .nav-actions { flex-direction: column; align-items: stretch; }
  .nav-search { width: 100%; }
  .btn-back { justify-content: center; }
  .posts-grid, .latest-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 40px; }
  .footer-contact { grid-column: 1 / -1; order: 3; }
}
@media (max-width: 720px) {
  .posts-grid, .latest-grid { grid-template-columns: 1fr; }
  .logo img { height: 44px; }
  .footer-grid { grid-template-columns: 1fr; padding-top: 48px; }
  .contact-grid { grid-template-columns: 1fr; }
  .footer-bottom-inner { flex-direction: column; justify-content: center; padding: 18px 24px; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}