/*
  Medium.com Style Theme
  - Clean, minimal design
  - Serif body text, sans-serif headings
  - Centered content with generous spacing
  - Focus on readability
*/

:root {
  --bg: #ffffff;
  --bg-2: #fff5f5;
  --bg-3: #ffe0e0;
  --text: #1a0000;
  --text-secondary: #8b0000;
  --muted: #cc0000;
  --accent: #dc2626;
  --accent-hover: #b91c1c;
  --border: #fecaca;
  --border-hover: #fca5a5;
  --card-bg: #ffffff;
  --card-border: transparent;
  --link: #dc2626;
  --link-hover: #b91c1c;
  --selection: rgba(220, 38, 38, 0.15);
  --shadow: rgba(220, 38, 38, 0.1);
}


html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Charter", "Georgia", "Times New Roman", serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.58;
  font-size: 21px;
}

::selection { 
  background: var(--selection);
  color: var(--text);
}

a { 
  color: var(--link); 
  text-decoration: none;
  transition: color 200ms ease;
}
a:hover { 
  color: var(--link-hover);
}

.background {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -1;
  background: var(--bg);
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 20px 40px;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--accent);
  z-index: 100;
  max-width: 100%;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
}

.branding {
  display: flex;
  gap: 16px;
  align-items: center;
  transition: transform 200ms ease;
}

.branding:hover {
  transform: translateX(2px);
}

.logo {
  font-size: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--bg);
  border-radius: 8px;
  font-weight: 700;
  font-family: "Inter", sans-serif;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
  transition: all 200ms ease;
}

.logo:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.branding .title h1 {
  margin: 0;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
  color: var(--text);
  font-family: "Inter", sans-serif;
  transition: color 200ms ease;
}

.branding:hover .title h1 {
  color: var(--accent);
}

.branding .title p {
  display: none;
}

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
  padding: 10px 16px;
  min-width: 240px;
  font-size: 14px;
  transition: all 200ms ease;
  font-family: "Inter", sans-serif;
}

.search::placeholder {
  color: var(--muted);
}

.search:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
  min-width: 280px;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 20px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  transition: all 200ms ease;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Inter", sans-serif;
  position: relative;
}

.btn:hover {
  color: var(--accent);
  background: var(--bg-2);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-radius: 20px;
  padding: 10px 24px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-ghost {
  background: transparent;
  border: none;
  padding: 10px 12px;
  border-radius: 20px;
}

.btn-ghost:hover {
  background: var(--bg-2);
  color: var(--accent);
}

/* Tags bar */
.tags-bar {
  padding: 16px 40px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 81px;
  z-index: 99;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tags {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.tags::-webkit-scrollbar {
  display: none;
}

.tag {
  font-size: 13px;
  padding: 0;
  border: none;
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 200ms ease;
  background: transparent;
  white-space: nowrap;
  font-weight: 400;
  font-family: "Inter", sans-serif;
  border-bottom: 1px solid transparent;
  padding-bottom: 4px;
}

.tag:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tag.active {
  color: var(--accent);
  background: transparent;
  border-bottom-color: var(--accent);
}

.tag .tag-count {
  margin-left: 6px;
  opacity: 0.6;
  font-weight: 400;
  font-size: 11px;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 40px;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 40px;
  padding: 20px 0;
}

/* Cards - Medium style */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  position: relative;
  transition: all 300ms ease;
  display: block;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.12), 0 2px 8px rgba(0, 0, 0, 0.15);
  border-color: var(--accent);
}

.card-image-wrapper {
  width: 100%;
  height: 200px;
  position: relative;
  overflow: hidden;
  background: var(--bg-2);
  flex-shrink: 0;
  margin-bottom: 0;
  border-radius: 12px 12px 0 0;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-image-wrapper.no-image .card-image {
  display: none;
}

.card-image-placeholder {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 48px;
  font-weight: 600;
  background: var(--bg-2);
  font-family: "Inter", sans-serif;
}

.card-image-wrapper.no-image .card-image-placeholder {
  display: flex;
}

.card-content {
  padding: 24px;
  background: transparent;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-author {
  display: none;
}

.card-title-box {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  font-family: "Inter", sans-serif;
  letter-spacing: -0.3px;
}

.card:hover h3 {
  color: var(--accent);
}

.card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.5;
  font-family: "Charter", serif;
}

.card .meta {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  padding-top: 16px;
  border-top: none;
  font-family: "Inter", sans-serif;
  gap: 12px;
}

.view {
  display: block;
}

.view--hidden {
  display: none;
}

/* Post view */
.post {
  display: grid;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
}

.post-title {
  font-size: 42px;
  margin: 0 0 32px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.8px;
  font-family: "Inter", sans-serif;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  font-family: "Inter", sans-serif;
}

.back-link {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 14px;
  transition: color 200ms ease;
  font-family: "Inter", sans-serif;
}

.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-tags {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.post-tags .tag {
  text-transform: none;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--text-secondary);
  border-bottom: 1px solid transparent;
  padding-bottom: 0;
  background: var(--bg-2);
  padding: 4px 12px;
  border-radius: 99px;
}

.post-tags .tag:hover {
  background: var(--bg-3);
}

.post-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 60px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Table of contents */
.toc {
  position: sticky;
  top: 140px;
  align-self: start;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  display: block;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.05);
  width: 200px;
  flex-shrink: 0;
}

.toc h4 {
  margin: 0 0 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-family: "Inter", sans-serif;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
}

.toc a {
  display: block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 6px;
  border-left: 3px solid transparent;
  transition: all 200ms ease;
  font-family: "Inter", sans-serif;
}

.toc a:hover {
  color: var(--accent);
  background: var(--bg-3);
  border-left-color: var(--accent);
  padding-left: 16px;
}

/* Content - Medium style */
.content {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 40px 0;
  line-height: 1.7;
  font-size: 21px;
  font-family: "Charter", "Georgia", serif;
  max-width: 900px;
}

.content h2,
.content h3,
.content h4 {
  margin-top: 64px;
  margin-bottom: 32px;
  font-weight: 700;
  scroll-margin-top: 100px;
  color: var(--text);
  font-family: "Inter", sans-serif;
  line-height: 1.3;
}

.content h2 {
  font-size: 36px;
  margin-top: 72px;
  padding-bottom: 0;
  border-bottom: none;
  letter-spacing: -0.6px;
}

.content h2:first-child {
  margin-top: 0;
}

.content h3 {
  font-size: 28px;
  letter-spacing: -0.4px;
  margin-top: 56px;
}

.content h4 {
  font-size: 22px;
  letter-spacing: -0.2px;
  margin-top: 48px;
}

.content p {
  color: var(--text);
  line-height: 1.75;
  margin-bottom: 28px;
  font-size: 21px;
  font-family: "Charter", "Georgia", serif;
}

.content code {
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  color: var(--text);
  font-weight: 400;
}

.content pre {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  overflow-x: auto;
  margin: 40px 0;
  line-height: 1.7;
  font-size: 16px;
}

.content pre code {
  background: transparent;
  padding: 0;
  color: var(--text);
}

.content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 28px;
  margin: 40px 0;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 20px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.content ul,
.content ol {
  margin: 32px 0;
  padding-left: 36px;
}

.content li {
  margin: 16px 0;
  line-height: 1.75;
  color: var(--text);
}

.content a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--text-secondary);
  text-decoration-thickness: 1px;
  transition: all 200ms ease;
}

.content a:hover {
  color: var(--text);
  text-decoration-color: var(--text);
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 40px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.content table th,
.content table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.content table th {
  background: transparent;
  font-weight: 600;
  font-family: "Inter", sans-serif;
}

.content table tr:last-child td {
  border-bottom: none;
}

.content hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 56px 0;
}

.content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 56px auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.content figure {
  margin: 56px 0;
}

.content figcaption {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 12px;
  font-family: "Inter", sans-serif;
}

/* Footer */
.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 40px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 80px;
  background: var(--bg);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  font-family: "Inter", sans-serif;
}

.site-footer strong {
  color: var(--text);
  font-weight: 600;
}

.back-to-top-link {
  display: none;
}

/* Loading indicator */
.loading-indicator {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 120px 20px;
  color: var(--text-secondary);
}

.loading-indicator[aria-hidden="false"] {
  display: flex;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 120px 20px;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 24px;
  opacity: 0.5;
}

.empty-state h3 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  font-family: "Inter", sans-serif;
}

.empty-state p {
  margin: 0 0 32px;
  font-size: 16px;
  font-family: "Charter", serif;
}

.clear-filters {
  margin-top: 8px;
  background: var(--text);
  color: var(--bg);
  border: none;
  padding: 10px 24px;
  border-radius: 99px;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  transition: all 200ms ease;
  font-family: "Inter", sans-serif;
}

.clear-filters:hover {
  background: var(--accent-hover);
}

/* Scroll to top button */
.scroll-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  border: none;
  cursor: pointer;
  font-size: 18px;
  font-weight: 500;
  box-shadow: 0 2px 8px var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.9);
  transition: all 300ms ease;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Inter", sans-serif;
}

.scroll-to-top:hover {
  transform: translateY(-4px) scale(1);
  box-shadow: 0 4px 12px var(--shadow);
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Focus states */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Card animations */
.card {
  animation: fadeInUp 0.5s ease-out;
  animation-fill-mode: both;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 960px) {
  .post-body {
    grid-template-columns: 1fr;
  }

  .toc {
    position: relative;
    top: 0;
    max-height: none;
    margin-bottom: 40px;
  }

  .site-header {
    flex-wrap: wrap;
    padding: 16px 24px;
  }

  .branding {
    flex: 1 1 100%;
    margin-bottom: 12px;
  }

  .actions {
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }

  .search {
    flex: 1 1 100%;
    min-width: 0;
  }

  .tags-bar {
    padding: 12px 24px;
    top: auto;
  }

  .container {
    padding: 40px 24px;
  }

  .post-grid {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .post {
    max-width: 100%;
  }

  .content {
    font-size: 18px;
  }

  .content p {
    font-size: 18px;
  }

  .scroll-to-top {
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 640px) {
  html, body {
    font-size: 18px;
  }

  .branding .title h1 {
    font-size: 14px;
  }

  .post-title {
    font-size: 32px;
  }

  .card-image-wrapper {
    height: 180px;
  }

  .card h3 {
    font-size: 20px;
  }

  .content {
    font-size: 18px;
  }

  .content h2 {
    font-size: 28px;
  }

  .content h3 {
    font-size: 24px;
  }

  .content p {
    font-size: 18px;
  }
}
