﻿/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --primary:        #1a3a5c;
  --primary-dark:   #0d2340;
  --primary-light:  #254d78;
  --accent:         #2563eb;
  --accent-hover:   #1d4ed8;
  --accent-2:       #7c3aed;
  --accent-3:       #059669;
  --warn:           #d97706;

  --bg:             #f0f4f8;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #dde3ed;

  --text:           #1e2d3d;
  --text-muted:     #5a6a7d;
  --text-light:     #8898aa;

  --radius-sm:      4px;
  --radius:         8px;
  --radius-lg:      14px;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:         0 4px 12px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);

  --transition:     0.2s ease;
  --font-sans:      'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:      'Cascadia Code', 'Fira Code', Consolas, 'Courier New', monospace;
}

/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition), opacity var(--transition);
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.page-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  padding: 2.5rem 0 3rem;
}

@media (max-width: 900px) {
  .page-content {
    grid-template-columns: 1fr;
    /* Ensure there is enough vertical space between stacked elements */
    gap: 1.5rem; 
  }
  .sidebar {
    /* Remove order: -1; so sidebar follows content */
    order: initial; 
  }
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, #1f4a7a 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,.35);
  /* Subtle dot pattern for personality */
  background-image:
    radial-gradient(circle, rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, #1f4a7a 100%);
  background-size: 20px 20px, 100% 100%;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
}
.brand-link:hover { color: #fff; text-decoration: none; opacity: 0.9; }

.brand-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 6px rgba(255,210,0,.5));
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255,210,0,.4)); }
  50%       { filter: drop-shadow(0 0 10px rgba(255,210,0,.8)); }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.site-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.site-tagline {
  font-size: 0.75rem;
  opacity: 0.75;
  letter-spacing: 0.03em;
  font-weight: 400;
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.site-nav a {
  color: rgba(255,255,255,.85);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.site-nav a:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}

@media (max-width: 600px) {
  .header-inner { flex-direction: column; gap: 0.75rem; }
  .site-nav { flex-wrap: wrap; justify-content: center; }
}

/* ── Post cards ─────────────────────────────────────────────────────────── */
.posts-area { min-width: 0; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity var(--transition);
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.post-card:hover::before { opacity: 1; }

.post-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.post-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.post-card-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.6rem;
  letter-spacing: -0.02em;
}
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--accent); text-decoration: none; }

.post-excerpt {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.read-more {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  transition: gap var(--transition);
}
.read-more:hover { gap: 0.4em; text-decoration: none; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: transform var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.badge-tag {
  background: #e0ecff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.badge-tag:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
  transform: scale(1.05);
}

.badge-cat {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #ddd6fe;
}

/* ── Full post ───────────────────────────────────────────────────────────── */
.post-full {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.post-header {
  padding: 2rem 2.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
}

.post-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.03em;
  margin: 0.5rem 0 0;
  color: var(--text);
}

.post-body {
  padding: 2rem 2.5rem;
  font-size: 1.03rem;
  line-height: 1.75;
}

.post-body h1, .post-body h2, .post-body h3, .post-body h4 {
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--primary);
}
.post-body h2 { font-size: 1.5rem; }
.post-body h3 { font-size: 1.25rem; }
.post-body h4 { font-size: 1.05rem; }

.post-body p { margin: 0 0 1.2rem; }

.post-body a { color: var(--accent); }

.post-body img {
  border-radius: var(--radius);
  margin: 1.5rem auto;
  box-shadow: var(--shadow);
}

.post-body ul, .post-body ol {
  padding-left: 1.6rem;
  margin-bottom: 1.2rem;
}
.post-body li { margin-bottom: 0.35rem; }

.post-body blockquote {
  border-left: 4px solid var(--accent);
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  background: var(--surface-2);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-style: italic;
}

.post-body pre {
  background: #0d1117;
  color: #e6edf3;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: #eef1f6;
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--accent-2);
}

.post-body pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
.post-body th {
  background: var(--primary);
  color: #fff;
  padding: 0.6rem 0.9rem;
  text-align: left;
  font-weight: 600;
}
.post-body td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.post-body tr:nth-child(even) td { background: var(--surface-2); }

.post-footer {
  padding: 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.page-numbers {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
}

.page-num, .page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.6rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.page-num:hover, .page-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
}
.page-num.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-self: start;
  position: sticky;
  top: 80px;
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

/* Bio card */
.bio-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
  border: 3px solid var(--border);
  display: block;
}

/* Fallback initials avatar (used when no photo is configured) */
.bio-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

.bio-initials {
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}

.bio-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 1.1rem;
}

.bio-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Word cloud ──────────────────────────────────────────────────────────── */
#word-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  line-height: 1.5;
  min-height: 80px;
}

.cloud-tag {
  display: inline-block;
  font-weight: 600;
  text-decoration: none;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  transition: transform 0.18s ease, opacity 0.18s ease;
  letter-spacing: -0.01em;
}
.cloud-tag:hover {
  transform: scale(1.18) rotate(-2deg);
  opacity: 0.85;
  text-decoration: none;
}

/* ── Search page ─────────────────────────────────────────────────────────── */
.search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.8rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.search-label {
  display: block;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--primary);
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.search-status {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  min-height: 1.4em;
}

.search-result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.search-result-card:hover { box-shadow: var(--shadow); }

.search-result-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
}
.search-result-title a { color: var(--text); }
.search-result-title a:hover { color: var(--accent); }

.search-result-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.search-result-excerpt {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Archive page ────────────────────────────────────────────────────────── */
.page-heading {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 1.5rem;
  letter-spacing: -0.03em;
}

.archive-year {
  margin-bottom: 2rem;
}

.archive-year-heading {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}

.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.archive-item:hover { background: var(--surface); }

.archive-item time {
  font-size: 0.8rem;
  color: var(--text-light);
  min-width: 3.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.archive-item a {
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.archive-item a:hover { color: var(--accent); text-decoration: none; }

/* Tag page */
.tag-highlight {
  color: var(--accent);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,.65);
  padding: 1.75rem 0;
  margin-top: 3rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-copy {
  font-size: 0.85rem;
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 0.85rem;
  color: rgba(255,255,255,.55);
  transition: color var(--transition);
}
.footer-links a:hover { color: #fff; text-decoration: none; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #0f1722;
    --surface:    #1a2535;
    --surface-2:  #1f2d42;
    --border:     #2d3f56;
    --text:       #dce6f0;
    --text-muted: #8ba0b8;
    --text-light: #5a7090;
  }

  .post-body code { background: #1e2d42; color: #a5b4fc; }
  .badge-tag { background: #1e3a6e; color: #93c5fd; border-color: #2d5b9e; }
  .badge-cat { background: #2d1f52; color: #c4b5fd; border-color: #4c3490; }
  #search-input { background: var(--surface-2); }
}

@media print {
  .site-header, .site-footer, .sidebar, .pagination { display: none; }
  .page-content { grid-template-columns: 1fr; }
  .post-body { font-size: 11pt; }
}
