/*
Theme Name: Dwellr Viral
Theme URI: https://dwellr.com
Author: Dwellr
Author URI: https://dwellr.com
Description: Ultra-light, ultra-fast viral WordPress theme optimized for Core Web Vitals. No 3rd party scripts.
Version: 1.0.0
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: dwellr-viral
*/

/* ===== CSS RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-light: #555555;
  --border: #e8e8e8;
  --accent: #e63946;
  --accent-hover: #c1121f;
  --max-width: 1200px;
  --sidebar-width: 320px;
  --gap: 24px;
  --radius: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--text); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; display: block; }

/* ===== CONTAINER ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

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

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-branding {
  flex-shrink: 0;
}

.site-logo img {
  max-height: 50px;
  width: auto;
  display: block;
}

.site-logo-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.site-logo-text a { color: var(--text); }

.header-nav ul {
  display: flex;
  list-style: none;
  gap: 24px;
}

.header-nav a {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  margin: 5px 0;
  transition: 0.3s;
}

/* ===== MAIN LAYOUT ===== */
.site-main {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: var(--gap);
  padding: 32px 0;
}

.main-content {
  min-width: 0;
}

/* ===== LATEST POSTS SECTION ===== */
.latest-posts {
  margin-bottom: 48px;
}

/* ===== POST GRID ===== */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

.post-card {
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.post-card .thumbnail-wrap {
  position: relative;
  padding-top: 56.25%; /* 16:9 ratio */
  overflow: hidden;
  background: #f0f0f0;
}

.post-card .thumbnail-wrap img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

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

.post-card .post-content {
  padding: 16px;
}

.post-card .post-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== CATEGORY SECTIONS ===== */
.category-section {
  margin-bottom: 48px;
}

.category-section .section-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--text);
  display: inline-block;
}

.category-section .section-title a:hover { color: var(--accent); }

/* ===== SIDEBAR ===== */
.site-sidebar {
  position: sticky;
  top: 80px;
  height: fit-content;
}

.sidebar-widget {
  background: #fafafa;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.sidebar-widget .widget-title {
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
}

/* Trending Posts Sidebar */
.trending-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.trending-item:last-child { border-bottom: none; }

.trending-item .trend-thumb {
  flex-shrink: 0;
  width: 90px;
  height: 60px;
  border-radius: 4px;
  overflow: hidden;
  background: #f0f0f0;
}

.trending-item .trend-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.trending-item .trend-info {
  flex: 1;
  min-width: 0;
}

.trending-item .trend-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 40px 0;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  transition: all 0.15s ease;
}

.pagination a:hover {
  background: var(--accent);
  color: #fff;
}

.pagination .current {
  background: var(--accent);
}

/* ===== SINGLE POST ===== */
.single-post .post-header {
  max-width: 800px;
  margin: 0 auto 32px;
  text-align: center;
}

.single-post .post-title {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.single-post .featured-image {
  margin: 0 0 32px;
  border-radius: var(--radius);
  overflow: hidden;
}

.single-post .featured-image img {
  width: 100%;
  height: auto;
}

.single-post .post-content {
  max-width: 720px;
  margin: 0 auto;
  font-size: 18px;
  line-height: 1.8;
}

.single-post .post-content p { margin-bottom: 24px; }
.single-post .post-content h2 { font-size: 28px; margin: 40px 0 20px; }
.single-post .post-content h3 { font-size: 22px; margin: 32px 0 16px; }
.single-post .post-content img { border-radius: var(--radius); margin: 24px 0; }

/* ===== BREADCRUMBS ===== */
.breadcrumbs {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.breadcrumbs a { color: var(--text-light); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { margin: 0 8px; color: #ccc; }
.breadcrumbs .current { color: var(--text); font-weight: 600; }

/* ===== RELATED POSTS ===== */
.related-posts {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 2px solid var(--border);
}

.related-posts .section-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 24px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.related-card .thumbnail-wrap {
  position: relative;
  padding-top: 56.25%;
  overflow: hidden;
  border-radius: var(--radius);
  background: #f0f0f0;
}

.related-card .thumbnail-wrap img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

.related-card .post-title {
  font-size: 15px;
  font-weight: 600;
  margin-top: 10px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== CATEGORY ARCHIVE ===== */
.archive-header {
  text-align: center;
  padding: 40px 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 32px;
}

.archive-header .archive-title {
  font-size: 32px;
  font-weight: 800;
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--text);
  color: #888;
  padding: 40px 0;
  margin-top: 60px;
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-footer a { color: #aaa; }
.site-footer a:hover { color: #fff; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .site-main { grid-template-columns: 1fr; }
  .site-sidebar { position: static; margin-top: 40px; }
  .post-grid { grid-template-columns: repeat(2, 1fr); }
  .related-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .post-grid { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: repeat(2, 1fr); }
  .single-post .post-title { font-size: 26px; }
  .single-post .post-content { font-size: 16px; }
  .header-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 16px; }
  .header-nav.active { display: block; }
  .header-nav ul { flex-direction: column; gap: 12px; }
  .menu-toggle { display: block; }
  .site-footer .container { flex-direction: column; gap: 12px; text-align: center; }
}

@media (max-width: 480px) {
  .related-grid { grid-template-columns: 1fr; }
  .pagination a, .pagination span { padding: 10px 20px; font-size: 13px; }
}

/* ===== ACCESSIBILITY ===== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  z-index: 9999;
}

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

/* Print styles */
@media print {
  .site-header, .site-sidebar, .pagination, .related-posts, .site-footer { display: none; }
  .single-post .post-content { max-width: 100%; }
}


/* ===== GALLERY STYLES ===== */
.dwellr-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 32px 0;
}

.dwellr-gallery.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.dwellr-gallery.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    cursor: pointer;
    aspect-ratio: 1;
    background: #f0f0f0;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.08);
}

/* View Icon Overlay */
.gallery-item .view-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.gallery-item:hover .view-overlay {
    opacity: 1;
}

.gallery-item .view-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.8);
    transition: transform 0.25s ease;
}

.gallery-item:hover .view-icon {
    transform: scale(1);
}

.gallery-item .view-icon svg {
    width: 22px;
    height: 22px;
    fill: #1a1a1a;
}

.gallery-item .gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.gallery-item:hover .gallery-caption {
    opacity: 1;
}

/* ===== LIGHTBOX STYLES ===== */
.dwellr-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.dwellr-lightbox.active {
    display: flex;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: pointer;
}

.lightbox-container {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 80px;
}

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

.lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    transition: opacity 0.2s ease;
}

.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255,255,255,0.25);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10;
}

.lightbox-nav:hover {
    background: rgba(255,255,255,0.25);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Gallery Responsive */
@media (max-width: 1024px) {
    .dwellr-gallery {
        grid-template-columns: repeat(3, 1fr);
    }
    .lightbox-container {
        padding: 60px 60px;
    }
}

@media (max-width: 768px) {
    .dwellr-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .lightbox-container {
        padding: 50px 40px;
    }
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
    .lightbox-close {
        top: 10px;
        right: 15px;
        width: 38px;
        height: 38px;
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .dwellr-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }
    .gallery-item .view-icon {
        width: 36px;
        height: 36px;
    }
    .gallery-item .view-icon svg {
        width: 16px;
        height: 16px;
    }
}
