@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Spectral:wght@300;400;600&display=swap');

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666666;
  --accent: #d97706;
  --accent-light: #fef3c7;
  --border: #e5e5e5;
  --danger: #dc2626;
  --success: #059669;
  
  --font-display: 'Spectral', serif;
  --font-mono: 'DM Mono', monospace;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --text: #e5e5e5;
    --text-muted: #a3a3a3;
    --accent: #fbbf24;
    --accent-light: #451a03;
    --border: #333333;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
header {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-bottom: 2rem;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.waluigi-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.site-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
}

/* Three Column Layout */
.three-column-layout {
  display: grid;
  grid-template-columns: 180px 1fr 260px;
  gap: 2.5rem;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Left Sidebar Navigation */
.left-sidebar {
  position: sticky;
  top: 120px;
  height: fit-content;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-family: var(--font-mono);
  font-size: 1rem;
}

.sidebar-nav a:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 500;
}

/* Main Content */
.main-content {
  min-width: 0;
}

/* Right Sidebar Tag Cloud */
.right-sidebar {
  position: sticky;
  top: 120px;
  height: fit-content;
}

.tag-cloud-widget {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.tag-cloud-widget h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.tag-cloud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.tag-cloud .tag-item {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-cloud .tag-item:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.no-tags {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-style: italic;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--accent);
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.admin-link {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.admin-link:hover {
  background: var(--accent);
  color: white;
}

/* Posts */
.posts-container {
  margin-bottom: 3rem;
}

.post {
  background: var(--surface);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  position: relative;
}

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

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.post-meta time {
  opacity: 0.8;
}

.post-type {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 500;
}

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

.tag {
  color: var(--accent);
  text-decoration: none;
  padding: 0.2rem 0.6rem;
  background: var(--accent-light);
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 0.75rem;
}

.tag:hover {
  background: var(--accent);
  color: white;
}

.post-content {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.post-content.collapsed {
  max-height: 150px;
  overflow: hidden;
  position: relative;
}

.post-content.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: linear-gradient(transparent, var(--surface));
}

.see-more-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 0.5rem 0;
  transition: all 0.2s ease;
}

.see-more-btn:hover {
  text-decoration: underline;
}

.post-content h1,
.post-content h2,
.post-content h3 {
  font-family: var(--font-display);
  margin: 1.5rem 0 0.75rem;
  line-height: 1.3;
}

.post-content h1 { font-size: 1.75rem; }
.post-content h2 { font-size: 1.5rem; }
.post-content h3 { font-size: 1.25rem; }

.post-content p {
  margin-bottom: 1rem;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: all 0.2s ease;
}

.post-content a:hover {
  text-decoration-thickness: 2px;
}

.post-content code {
  font-family: var(--font-mono);
  background: var(--accent-light);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.post-content pre {
  background: var(--accent-light);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
  border-left: 3px solid var(--accent);
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content ul,
.post-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
  color: var(--text-muted);
}

.post-image {
  margin: 1rem 0;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
}

.post-image:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

.post-image img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

/* PDF Thumbnail */
.pdf-thumbnail {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--accent-light);
  padding: 1rem;
  text-align: center;
  margin: 1rem 0;
}

.pdf-thumbnail:hover {
  border-color: var(--accent);
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

.pdf-thumbnail-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.pdf-thumbnail-text {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent);
  font-weight: 500;
}

/* Lightbox Modal */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 95%;
  max-height: 95%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-content iframe {
  width: 90vw;
  height: 90vh;
  border: none;
  border-radius: 8px;
  background: white;
}

.lightbox-close {
  position: fixed;
  top: 2rem;
  right: 2rem;
  background: white;
  color: black;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.lightbox-close:hover {
  background: var(--accent);
  color: white;
  transform: rotate(90deg);
}

.post-link {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.post-link a {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.post-link a:hover {
  text-decoration: underline;
}

.pdf-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-weight: 500;
}

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

.delete-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  opacity: 0;
  transition: all 0.2s ease;
}

.post:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.1);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 3rem 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.page-btn {
  color: var(--accent);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.page-btn:hover {
  background: var(--accent);
  color: white;
}

.page-numbers {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.page-number {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  min-width: 2.5rem;
  text-align: center;
}

.page-number:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.page-number.active {
  background: var(--accent);
  color: white;
  font-weight: 500;
}

.page-ellipsis {
  color: var(--text-muted);
  padding: 0 0.25rem;
}

/* Tags Page */
.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2rem 0;
}

.tag-cloud-item {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.tag-cloud-item:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tag-count {
  opacity: 0.6;
  font-size: 0.85em;
}

.tag-filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.tag-filter-header h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.clear-filter {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  transition: color 0.2s ease;
}

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

/* Admin Form */
.admin-container {
  max-width: 1200px;
  margin: 0 auto 2rem;
  background: var(--surface);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.admin-container h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.form-group textarea {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.tag-suggestions {
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.tag-suggestion {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid transparent;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.tag-suggestion:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
}

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

.btn-primary:hover {
  background: #b45309;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
  border-color: var(--text);
  color: var(--text);
}

.message {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.message.success {
  background: rgba(5, 150, 105, 0.1);
  color: var(--success);
  border: 1px solid var(--success);
}

.message.error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.markdown-guide {
  max-width: 1200px;
  margin: 0 auto 3rem;
  background: var(--bg);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.markdown-guide h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.guide-content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.guide-item {
  padding: 1rem;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.guide-item strong {
  display: block;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent);
}

.guide-item pre {
  background: var(--bg);
  padding: 0.75rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  border: 1px solid var(--border);
  margin: 0;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-style: italic;
}

.empty-state a {
  color: var(--accent);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1200px) {
  .three-column-layout {
    grid-template-columns: 180px 1fr 240px;
    gap: 2rem;
  }
}

@media (max-width: 1024px) {
  .three-column-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .left-sidebar,
  .right-sidebar {
    position: static;
  }
  
  .left-sidebar {
    order: -1;
  }
  
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .right-sidebar {
    order: 1;
  }
}

@media (max-width: 640px) {
  .container,
  .three-column-layout {
    padding: 0 1rem;
  }
  
  header {
    padding: 1.5rem 0 1rem;
  }
  
  .site-title {
    font-size: 1.5rem;
  }
  
  .waluigi-logo {
    width: 40px;
    height: 40px;
  }
  
  .sidebar-nav {
    font-size: 0.8rem;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .post {
    padding: 1.25rem;
  }
  
  .pagination {
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .guide-grid {
    grid-template-columns: 1fr;
  }
}
