/* ============================================
   Light.W Theme - Main Stylesheet
   Version: 1.0.0
   Primary Color: #3cc376
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --lw-primary: #3cc376;
  --lw-primary-hover: #34b06a;
  --lw-bg: #fafafa;
  --lw-card: #ffffff;
  --lw-foreground: #262626;
  --lw-muted: #808080;
  --lw-border: #e6e6e6;
  --lw-radius: 0.375rem;
}

/* ---------- Icons ---------- */
.lw-icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

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

body {
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--lw-foreground);
  background-color: var(--lw-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(128, 128, 128, 0.5);
}

/* ============================================
   Header
   ============================================ */
.lw-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--lw-card);
  border-bottom: 1px solid var(--lw-border);
}

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

/* Logo */
.lw-logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--lw-primary);
  flex-shrink: 0;
}
.lw-logo span {
  font-weight: 300;
  color: var(--lw-foreground);
}

/* Search */
.lw-search {
  display: flex;
  align-items: center;
  margin: 0 2rem;
  flex: 1;
  max-width: 400px;
}
.lw-search-form {
  position: relative;
  width: 100%;
}
.lw-search-input {
  width: 100%;
  height: 36px;
  padding: 0 40px 0 16px;
  border-radius: 999px;
  border: 1px solid var(--lw-border);
  background: var(--lw-card);
  color: var(--lw-foreground);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s ease;
}
.lw-search-input:focus {
  border-color: var(--lw-primary);
}
.lw-search-btn {
  position: absolute;
  right: 0;
  top: 0;
  height: 36px;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--lw-primary);
  cursor: pointer;
  font-size: 1rem;
}

/* Nav */
.lw-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}
.lw-nav a {
  font-size: 0.875rem;
  color: var(--lw-muted);
  transition: color 0.2s ease;
}
.lw-nav a:hover,
.lw-nav a.active {
  color: var(--lw-primary);
}
.lw-nav a.active {
  font-weight: 500;
}
.lw-nav-user {
  color: var(--lw-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.2s ease;
  background: none;
  border: none;
}
.lw-nav-user:hover {
  color: var(--lw-foreground);
}

/* Mobile Toggle */
.lw-mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--lw-foreground);
  font-size: 1.25rem;
  cursor: pointer;
}

/* Mobile Menu */
.lw-mobile-menu {
  display: none;
  border-top: 1px solid var(--lw-border);
  background: var(--lw-card);
  padding: 12px 16px 16px;
}
.lw-mobile-menu.active {
  display: block;
}
.lw-mobile-menu .lw-search-form {
  margin-bottom: 8px;
}
.lw-mobile-menu .lw-search-input {
  background: var(--lw-bg);
}
.lw-mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lw-mobile-nav a {
  padding: 8px 0;
  font-size: 0.875rem;
  color: var(--lw-muted);
}
.lw-mobile-nav a:hover {
  color: var(--lw-primary);
}

@media (max-width: 767px) {
  .lw-search,
  .lw-nav {
    display: none;
  }
  .lw-mobile-toggle {
    display: block;
  }
}

/* ============================================
   Main Content
   ============================================ */
.lw-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 12px 8px;
}
@media (min-width: 768px) {
  .lw-main {
    padding: 16px 16px 8px;
  }
}

/* ============================================
   Masonry Grid
   ============================================ */
.masonry-grid {
  column-count: 3;
  column-gap: 12px;
}
.masonry-item {
  break-inside: avoid;
  margin-bottom: 12px;
}

@media (max-width: 991px) {
  .masonry-grid {
    column-count: 2;
    column-gap: 10px;
  }
}
@media (max-width: 575px) {
  .masonry-grid {
    column-count: 2;
    column-gap: 8px;
  }
}

/* ============================================
   Image Card
   ============================================ */
.lw-card {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--lw-radius);
  background: #e5e5e5;
}
.lw-card img {
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.lw-card:hover img {
  transform: scale(1.05);
}
.lw-card-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0.3) 60%, transparent);
  padding: 40px 12px 12px;
}
.lw-card-title {
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.lw-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.75rem;
}
.lw-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lw-card-meta .lw-icon {
  width: 12px;
  height: 12px;
}

/* Post page: images in masonry without card overlay */
article .masonry-grid .lw-card {
  border-radius: 4px;
  cursor: default;
}
article .masonry-grid .lw-card:hover img {
  transform: none;
}

/* ============================================
   Pagination
   ============================================ */
.lw-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 0;
}
.lw-pagination a,
.lw-pagination span {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--lw-muted);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.lw-pagination a:hover {
  background: #f0f0f0;
}
.lw-pagination .current {
  background: var(--lw-primary);
  color: #fff;
}
.lw-pagination .disabled {
  color: rgba(128, 128, 128, 0.4);
  pointer-events: none;
}
.lw-pagination .dots {
  pointer-events: none;
}

/* ============================================
   Post Detail
   ============================================ */
.lw-post-header {
  margin-bottom: 16px;
}
.lw-post-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--lw-foreground);
  line-height: 1.4;
  text-wrap: balance;
  margin-bottom: 8px;
}
@media (min-width: 768px) {
  .lw-post-title {
    font-size: 1.5rem;
  }
}
.lw-post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--lw-muted);
}
.lw-post-meta span,
.lw-post-meta a {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lw-post-meta a:hover {
  color: var(--lw-primary);
}
.lw-post-meta .lw-icon {
  width: 14px;
  height: 14px;
}

/* Download Buttons */
.lw-download-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 860px;
  margin: 0 auto 32px;
}
.lw-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--lw-primary);
  border: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
  text-decoration: none;
}
.lw-download-btn:hover {
  opacity: 0.9;
  color: #fff;
}
.lw-download-btn .lw-icon {
  width: 16px;
  height: 16px;
}

/* Prev / Next */
.lw-post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto 32px;
}
@media (max-width: 575px) {
  .lw-post-nav {
    grid-template-columns: 1fr;
  }
}
.lw-post-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 999px;
  background: var(--lw-primary);
  transition: opacity 0.2s ease;
}
.lw-post-nav-item:hover {
  opacity: 0.9;
}
.lw-post-nav-item.next {
  justify-content: flex-end;
  text-align: right;
}
.lw-post-nav-icon {
  color: #fff;
  flex-shrink: 0;
}
.lw-post-nav-icon .lw-icon {
  width: 20px;
  height: 20px;
}
.lw-post-nav-inner {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.lw-post-nav-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}
.lw-post-nav-link {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: block;
  min-width: 0;
}
.lw-post-nav-link:hover {
  color: #fff;
}

/* Related Posts */
.lw-related {
  max-width: 1200px;
  margin: 0 auto 16px;
  padding-top: 8px;
}
.lw-related-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--lw-foreground);
  margin-bottom: 12px;
}
.lw-related-grid {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  -ms-overflow-style: none;
  scrollbar-width: none;
  justify-content: flex-start;
}
.lw-related-grid::-webkit-scrollbar {
  display: none;
}
.lw-related-item {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  border-radius: var(--lw-radius);
  overflow: hidden;
  background: #e5e5e5;
}
@media (min-width: 768px) {
  .lw-related-item {
    width: 135px;
    height: 120px;
  }
}
.lw-related-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.lw-related-item:hover img {
  transform: scale(1.05);
}

/* ============================================
   Category Header
   ============================================ */
.lw-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.lw-category-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--lw-foreground);
}
.lw-category-header .count {
  font-size: 0.75rem;
  color: var(--lw-muted);
}

/* ============================================
   Search Header
   ============================================ */
.lw-search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.lw-search-header .lw-icon {
  width: 16px;
  height: 16px;
  color: var(--lw-muted);
}
.lw-search-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--lw-foreground);
}
.lw-search-header .count {
  font-size: 0.75rem;
  color: var(--lw-muted);
}

/* ============================================
   Empty State
   ============================================ */
.lw-empty {
  padding: 80px 0;
  text-align: center;
  color: var(--lw-muted);
  font-size: 0.875rem;
}

/* ============================================
   404 Page
   ============================================ */
.lw-404 {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lw-404-inner {
  text-align: center;
  padding: 80px 0;
}
.lw-404-code {
  font-size: 4.5rem;
  font-weight: 700;
  color: var(--lw-primary);
  margin-bottom: 16px;
}
.lw-404-text {
  color: var(--lw-muted);
  margin-bottom: 24px;
}
.lw-404-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--lw-primary);
  transition: opacity 0.2s ease;
}
.lw-404-btn:hover {
  opacity: 0.9;
  color: #fff;
}

/* ============================================
   Footer
   ============================================ */
.lw-footer {
  margin-top: auto;
  border-top: 1px solid var(--lw-border);
  background: var(--lw-card);
}
.lw-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
@media (max-width: 575px) {
  .lw-footer-inner {
    flex-direction: column;
  }
}
.lw-footer-copy {
  font-size: 0.75rem;
  color: var(--lw-muted);
}
.lw-footer-copy a:hover {
  color: var(--lw-primary);
}
.lw-footer-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}
.lw-footer-nav a {
  font-size: 0.75rem;
  color: var(--lw-muted);
}
.lw-footer-nav a:hover {
  color: var(--lw-primary);
}

/* ============================================
   Page Template (single page like "About")
   ============================================ */
.lw-page-content {
  max-width: 800px;
  margin: 0 auto;
  padding-bottom: 32px;
}
.lw-page-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--lw-foreground);
  margin-bottom: 8px;
}
.lw-page-content .lw-page-date {
  font-size: 0.75rem;
  color: var(--lw-muted);
  margin-bottom: 24px;
}
.lw-page-content .lw-page-body {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--lw-foreground);
}
.lw-page-content .lw-page-body p {
  margin-bottom: 1em;
}
.lw-page-content .lw-page-body img {
  border-radius: var(--lw-radius);
  margin: 1em 0;
}
.lw-page-content .lw-page-body a {
  color: var(--lw-primary);
}
.lw-page-content .lw-page-body a:hover {
  text-decoration: underline;
}

/* ============================================
   Back to Top
   ============================================ */
.lw-back-top {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 999;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: var(--lw-primary);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  box-shadow: 0 2px 12px rgba(60,195,118,0.35);
}
.lw-back-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.lw-back-top:hover {
  opacity: 0.9;
}
.lw-back-top .lw-icon {
  width: 18px;
  height: 18px;
}
