/* ==========================================================================
   1. Base & Variables
   ========================================================================== */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #D5F5D9;
  --text-rgb: 44, 62, 80;
  --text: rgba(var(--text-rgb), .75);
  --text-light: rgba(var(--text-rgb), .4);
  --text-strong: rgba(var(--text-rgb), .94);
  --accent: #2a2b2d;
  --font: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --card-bg: #C9E9CD;
  --card-hover: #C3E3C7;
  --button-bg: #CBEBD1;
  --button-hover: #C8E8CC;
  --card-radius: 10px;
  --gap: 16px;
}

html.dark-theme {
  --bg: #1A2421;
  --text-rgb: 225, 232, 229;
  --accent: #fff;
  --card-bg: #1F2E2A;
  --card-hover: #253833;
  --button-bg: #202D29;
  --button-hover: #283B36;
}

html {
  overflow-y: scroll;
  scroll-behavior: smooth;
}

body {
  overflow-x: clip;
  min-height: 100vh;
  margin: 0;
  font: normal 14px/1.2 var(--font);
  color: var(--text);
  background-color: var(--bg);
  letter-spacing: -0.009em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   2. Theme Toggle
   ========================================================================== */

.theme-toggle {
  display: inline-flex;
  align-items: center;
}

.theme-toggle > input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-toggle > label {
  position: relative;
  display: block;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background-color: rgba(var(--text-rgb), .1);
  cursor: pointer;
  transition: background-color 0.3s;
}

.theme-toggle > label:hover {
  background-color: rgba(var(--text-rgb), .18);
}

.theme-toggle_handle {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--bg);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.theme-toggle input:checked + label .theme-toggle_handle {
  transform: translateX(14px);
}

.theme-toggle svg {
  position: absolute;
  top: 3px;
  width: 12px;
  height: 12px;
  z-index: 2;
}

.theme-toggle .sun {
  left: 3px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.theme-toggle .moon {
  right: 3px;
  fill: currentColor;
}

/* ==========================================================================
   3. Layout & Tab Panels
   ========================================================================== */

.container {
  padding: 16px;
  opacity: 0;
  animation: fadeIn 0.4s ease-out forwards;
}

.grid {
  display: grid;
  align-items: flex-start;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

.tab-panel {
  display: contents;
}

.tab-panel.hidden {
  display: none !important;
}

/* ==========================================================================
   4. Hero Card
   ========================================================================== */

.hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  aspect-ratio: 0.88;
  gap: 32px;
}

.hero-nav {
  display: flex;
  gap: 20px;
}

.hero-nav > div {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.hero-nav > div:last-child {
  align-items: flex-end;
  text-align: right;
}

.hero-nav .nav-label {
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hero-nav .nav-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-nav .nav-links button,
.hero-nav .nav-links a {
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
  color: inherit;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s;
}

.hero-nav .nav-links button:hover,
.hero-nav .nav-links a:hover {
  text-decoration: underline;
}

.hero-nav .nav-links .active {
  color: var(--text-strong);
  font-weight: 600;
}

.hero-nav .nav-links .active::after {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  flex-shrink: 0;
  vertical-align: middle;
  background: var(--text-strong);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center / contain;
}

.hero-bottom {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-logo {
  display: inline-block;
  font-size: 28px;
  font-weight: 900;
  color: var(--text-strong);
  letter-spacing: -0.5px;
}

.hero-tagline {
  line-height: 156%;
  margin: 0;
  transition: opacity 0.2s ease;
}

.hero-footer span {
  font-size: 12px;
  color: var(--text-light);
}

/* ==========================================================================
   5. Product Card
   ========================================================================== */

.tools-item {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  position: relative;
  aspect-ratio: 0.88;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.tools-item:hover {
  background: var(--card-hover);
}

.tools-item .item-img-wrap {
  display: block;
  width: 50%;
  aspect-ratio: 1 / 1;
  position: relative;
  z-index: 2;
  cursor: pointer;
}

.tools-item .img-spacer {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
  transition: margin 220ms ease-in-out;
}

.tools-item:hover .img-spacer {
  margin-top: -8px;
}

.tools-item .img-spacer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tools-item .item-info {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 3;
}

.tools-item .item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-light);
}

.tools-item .item-meta .meta-dot {
  opacity: 0.4;
}

.tools-item .item-name {
  font-weight: 500;
}

/* ==========================================================================
   6. Load More
   ========================================================================== */

.load-more {
  padding: 36px 8px 26px;
  text-align: center;
}

.load-more a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 18px;
  font-size: 15px;
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s;
}

.load-more a:hover {
  background: var(--button-hover);
  text-decoration: none;
}

/* ==========================================================================
   7. Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .container {
    padding: 16px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .tools-item .item-img-wrap {
    width: 50%;
  }

  .tools-item .img-spacer {
    width: 100%;
  }

  .tools-item .item-info {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .hero {
    aspect-ratio: 0.88;
    gap: 24px;
  }

  .hero-nav {
    gap: 16px;
  }
}

@media (min-width: 769px) and (max-width: 999px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 2460px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 3200px) {
  .grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ==========================================================================
   8. Animation
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   9. Lightbox
   ========================================================================== */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background-color: rgba(0, 0, 0, 0.2);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s;
  overscroll-behavior: contain;
}

.lightbox-overlay._active {
  opacity: 1;
  visibility: visible;
}

.lightbox-container {
  width: 90%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: scale(0.9);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-overlay._active .lightbox-container {
  transform: scale(1);
}

.lightbox-container img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.lightbox-bottom {
  opacity: 0;
  transition: opacity 0.4s ease 0.1s;
}

.lightbox-overlay._active .lightbox-bottom {
  opacity: 1;
}

.lightbox-detail-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 20px;
  border-radius: 20px;
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 300;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: 0.5px;
}

.lightbox-detail-btn:hover {
  background-color: rgba(255, 255, 255, 0.95);
  color: #000;
  transform: translateY(-1px);
}
