/* ══════════════════════════════════════════════════
   Good Reader  -  Shared Base Styles
   Copyright (c) 2026 Stefano Marinelli
   ══════════════════════════════════════════════════ */

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

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-serif: Georgia, 'Times New Roman', Times, serif;
  --font-display: Georgia, 'Times New Roman', Times, serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
}

/* ── Skip to content ─────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 200;
  padding: 8px 16px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}

/* ── Layout ──────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ──────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

.logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

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

.motto {
  display: none;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  line-height: 1.4;
}

@media (min-width: 900px) {
  .motto {
    display: block;
  }
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ── List View ───────────────────────────────── */
.list-header {
  padding: 48px 0 32px;
}

.list-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  letter-spacing: -0.03em;
}

.list-title em {
  font-style: italic;
  color: var(--accent);
}

.list-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.list-toolbar {
  padding: 32px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 12px 16px 12px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s ease;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-dim);
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-filter .tag {
  cursor: pointer;
}

.tag-filter .tag.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* ── Post Grid ───────────────────────────────── */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  padding-bottom: 64px;
}

.post-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.post-card-image {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.post-card:hover .post-card-image img {
  transform: scale(1.05);
}

.post-card-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg-card) 0%, transparent 60%);
}

.post-card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.post-card-tag-body {
  padding: 32px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  border-top: 3px solid var(--accent);
}

.post-card-tag-body .post-card-title {
  font-size: 1.25rem;
  margin-bottom: 0;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  order: -1;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.2s ease;
  background: transparent;
  font-family: inherit;
}

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

a.tag {
  text-decoration: none;
  cursor: pointer;
}

.post-card-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.post-card-date {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.post-card-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Reader View ─────────────────────────────── */
.article {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 80px;
}

.article-hero {
  position: relative;
  width: 100%;
  height: 360px;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 40px;
  background: var(--bg-elevated);
}

.article-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 50%);
}

.article-hero-caption {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1;
}

.article-reading-time {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.article-header {
  margin-bottom: 40px;
}

.article-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.article-date {
  color: var(--text-dim);
}

.article-author {
  font-size: 0.85rem;
}

.article-author a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.article-author a:hover {
  text-decoration: underline;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.article-tags .tag {
  font-size: 0.75rem;
}

.article-body {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text);
}

.article-body p {
  margin-bottom: 1.5em;
}

.article-body em {
  font-style: italic;
}

.article-body strong {
  font-weight: 700;
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

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

.article-body h1,
.article-body h2,
.article-body h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  margin: 1.5em 0 0.5em;
  letter-spacing: -0.01em;
}

.article-body h1 { font-size: 1.75rem; }
.article-body h2 { font-size: 1.4rem; }
.article-body h3 { font-size: 1.15rem; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5em 1em;
  margin: 1.5em 0;
  color: var(--text-muted);
  font-style: italic;
  background: var(--accent-glow);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.article-body ul,
.article-body ol {
  margin: 1em 0 1.5em;
  padding-left: 1.5em;
}

.article-body li {
  margin-bottom: 0.4em;
}

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

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--accent);
}

.article-body pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 1.5em 0;
}

.article-body pre code {
  background: none;
  color: var(--text);
  padding: 0;
}

.article-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 1.5em 0;
}

/* ── Author Index ──────────────────────────── */
.authors-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}

.author-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  text-decoration: none;
  transition: all 0.15s;
}

.author-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.author-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.author-card-count {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ── Footer ──────────────────────────────────── */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

.footer-meta {
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ── Related Posts ──────────────────────────── */
.related-posts {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

.related-posts-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

.related-posts .post-grid {
  padding-bottom: 0;
}

/* ── Post Navigation ────────────────────────── */
.post-nav {
  max-width: 720px;
  margin: 0 auto;
}

.post-nav .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-sans);
  text-decoration: none;
  transition: color 0.2s ease;
  margin: 24px 0 8px;
}

.post-nav .back-btn:hover {
  color: var(--accent);
}

/* ── Page Layout (about, etc.) ──────────────── */
.article.page {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 80px;
}

/* ── Archives ──────────────────────────────── */
.archives {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.archive-year {
  margin-bottom: 48px;
}

.archive-year-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 24px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.archive-month-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  margin-top: 24px;
}

.archive-list {
  list-style: none;
  padding: 0;
}

.archive-list li {
  padding: 4px 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

.archive-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-right: 12px;
}

.archive-list a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s ease;
}

.archive-list a:hover {
  color: var(--accent);
}

/* ── Error Page (404) ───────────────────────── */
.error-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 24px;
  text-align: center;
}

.error-code {
  font-family: var(--font-display);
  font-size: 6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 16px;
}

.error-message {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.error-page .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 1rem;
}

.error-page .back-btn:hover {
  color: var(--accent-hover);
}

/* ── Post Card as link ──────────────────────── */
a.post-card {
  text-decoration: none;
  color: inherit;
}

/* ── Pagination ──────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 0 64px;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.pagination-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.pagination-link.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── Empty / No Results ─────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-dim);
}

.empty-state p {
  font-size: 1.1rem;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  #main { padding: 0 16px; }
  .header-inner { padding: 0 16px; }
  .list-title { font-size: 1.75rem; }
  .list-header { padding: 32px 0 24px; }
  .list-toolbar { padding: 24px 0 16px; }
  .search-input { max-width: 100%; }
  .post-grid { grid-template-columns: 1fr; gap: 16px; }
  .article-title { font-size: 1.75rem; }
  .article-hero { height: 240px; }
  .article-body { font-size: 1rem; }
}

@media (max-width: 480px) {
  .article-title { font-size: 1.5rem; }
  .article-hero { height: 180px; }
}

/* ── Text browser / screen-reader only ──────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
