/* Grid Template - Minimal grid layout */

:root {
  --grid-bg: #ffffff;
  --grid-text: #1a1a1a;
  --grid-text-secondary: #666666;
  --grid-border: #e5e5e5;
  --grid-accent: #0066cc;
  --grid-gap: 16px;
  --grid-item-min: 160px;
}

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

body.grid-body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--grid-bg);
  color: var(--grid-text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.grid-header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grid-logo {
  text-decoration: none;
  color: var(--grid-text);
}

.grid-logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.grid-logo-img {
  height: 32px;
  width: auto;
}

.grid-menu-toggle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.grid-menu-toggle span {
  width: 24px;
  height: 2px;
  background: var(--grid-text);
  transition: 0.2s;
}

/* Mobile Menu */
.grid-mobile-menu {
  position: fixed;
  top: 0;
  right: -100%;
  width: 280px;
  height: 100vh;
  background: var(--grid-bg);
  transition: right 0.3s ease;
  z-index: 1000;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}

.grid-mobile-menu.active {
  right: 0;
}

.grid-mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--grid-border);
}

.grid-mobile-logo {
  font-weight: 700;
  color: var(--grid-text);
  text-decoration: none;
}

.grid-mobile-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 8px;
}

.grid-mobile-nav ul {
  list-style: none;
  padding: 16px;
}

.grid-mobile-nav li {
  border-bottom: 1px solid var(--grid-border);
}

.grid-mobile-nav a {
  display: block;
  padding: 12px 0;
  color: var(--grid-text);
  text-decoration: none;
  font-weight: 500;
}

/* Main Content */
.grid-main {
  flex: 1;
  padding: 16px;
}

.grid-container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Posts Grid - As many as fit horizontally */
.grid-posts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-item-min), 1fr));
  gap: var(--grid-gap);
}

.grid-item {
  display: flex;
  flex-direction: column;
}

.grid-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.grid-image {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 8px;
  background: #f0f0f0;
  position: relative;
}

.grid-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ff4757;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
}

.grid-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.grid-link:hover .grid-image img {
  transform: scale(1.05);
}

.grid-title {
  margin-top: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.grid-meta {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--grid-text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.grid-author {
  font-weight: 500;
}

.grid-separator {
  color: #ccc;
}

.grid-reading-time {
  color: var(--grid-text-secondary);
}

/* Category Page */
.grid-header {
  margin-bottom: 24px;
}

.grid-category-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.grid-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--grid-text-secondary);
}

.grid-empty a {
  display: inline-block;
  margin-top: 16px;
  color: var(--grid-accent);
  text-decoration: none;
  font-weight: 500;
}

/* Article Page */
.grid-article-container {
  max-width: 800px;
}

.grid-article-header {
  margin-bottom: 24px;
}

.grid-back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--grid-accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
}

.grid-article-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.grid-article-image {
  margin-bottom: 24px;
  border-radius: 8px;
  overflow: hidden;
}

.grid-article-image img {
  width: 100%;
  height: auto;
  display: block;
}

.grid-article-body {
  font-size: 1rem;
  line-height: 1.7;
}

.grid-article-body h2,
.grid-article-body h3,
.grid-article-body h4 {
  margin-top: 32px;
  margin-bottom: 16px;
  font-weight: 600;
}

.grid-article-body h2 {
  font-size: 1.5rem;
}

.grid-article-body h3 {
  font-size: 1.25rem;
}

.grid-article-body p {
  margin-bottom: 16px;
}

.grid-ad-section {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--grid-border);
}

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

.grid-related-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Footer */
.grid-footer {
  background: #f8f8f8;
  border-top: 1px solid var(--grid-border);
  padding: 24px 16px;
  margin-top: auto;
}

.grid-footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--grid-text-secondary);
}

.grid-footer-links {
  display: flex;
  gap: 16px;
}

.grid-footer-links a {
  color: var(--grid-text-secondary);
  text-decoration: none;
}

.grid-footer-links a:hover {
  color: var(--grid-text);
}

/* Responsive */
@media (min-width: 480px) {
  .grid-posts {
    --grid-item-min: 180px;
  }
}

@media (min-width: 768px) {
  .grid-posts {
    --grid-item-min: 200px;
    --grid-gap: 20px;
  }

  .grid-main {
    padding: 24px;
  }

  .grid-title {
    font-size: 0.9375rem;
  }

  .grid-article-title {
    font-size: 2.25rem;
  }
}

@media (min-width: 1024px) {
  .grid-posts {
    --grid-item-min: 220px;
    --grid-gap: 24px;
  }
}
