/* ============================================================
   🎮 ShenCaiYiYi.com — Minecraft Pixel Style Theme
   ============================================================ */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
  /* Minecraft color palette */
  --mc-grass-top: #7C9C5E;
  --mc-grass-side: #6B8E4E;
  --mc-dirt: #8B6914;
  --mc-dirt-dark: #6B4F10;
  --mc-stone: #808080;
  --mc-stone-dark: #555555;
  --mc-cobble: #666666;
  --mc-wood: #6B3E11;
  --mc-wood-light: #8B5E2B;
  --mc-gold: #FFD700;
  --mc-sky: #87CEEB;
  --mc-white: #FFFFFF;
  --mc-black: #1a1a1a;
  --mc-bedrock: #333333;
  --mc-water: #3B6CEA;
  --mc-fire: #FF4500;
  --mc-glowstone: #FFF5CC;

  /* Pixel sizing */
  --pixel-unit: 4px;
  --border-thick: 4px;

  /* Layout */
  --header-height: 80px;
  --footer-height: 60px;
  --max-width: 1200px;
}

/* ---- Reset & Base ---- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 18px;
  color: var(--mc-white);
  line-height: 1.6;
  min-height: 100vh;
  /* Sky gradient background */
  background: linear-gradient(180deg,
    #4a90d9 0%,
    var(--mc-sky) 30%,
    #a8d8ea 55%,
    var(--mc-grass-top) 55%,
    var(--mc-grass-side) 60%,
    var(--mc-dirt) 80%,
    var(--mc-dirt-dark) 100%
  );
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ---- Pixel Border Utility ---- */
.pixel-border {
  border: var(--border-thick) solid var(--mc-stone);
  border-image: none;
  box-shadow:
    inset calc(var(--pixel-unit) * -1) calc(var(--pixel-unit) * -1) 0 0 rgba(0,0,0,0.3),
    inset var(--pixel-unit) var(--pixel-unit) 0 0 rgba(255,255,255,0.2);
  position: relative;
}

/* ---- Cloud decoration ---- */
.cloud {
  position: fixed;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  width: 120px;
  height: 40px;
  z-index: 0;
  pointer-events: none;
  animation: cloud-float 20s linear infinite;
}
.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.cloud::before {
  width: 60px;
  height: 50px;
  top: -20px;
  left: 20px;
}
.cloud::after {
  width: 80px;
  height: 40px;
  top: -15px;
  left: 50px;
}
@keyframes cloud-float {
  from { transform: translateX(-200px); }
  to { transform: translateX(calc(100vw + 200px)); }
}

/* ---- Header ---- */
.pixel-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background:
    repeating-linear-gradient(
      90deg,
      var(--mc-dirt) 0px, var(--mc-dirt) 16px,
      var(--mc-dirt-dark) 16px, var(--mc-dirt-dark) 32px
    ),
    linear-gradient(180deg, var(--mc-dirt), var(--mc-dirt-dark));
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: var(--border-thick) solid var(--mc-stone-dark);
  box-shadow:
    0 var(--pixel-unit) 0 0 rgba(0,0,0,0.3),
    0 calc(var(--pixel-unit) * 3) 10px rgba(0,0,0,0.3);
}

.header-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  color: var(--mc-white);
  text-shadow:
    calc(var(--pixel-unit) * 1) calc(var(--pixel-unit) * 1) 0 var(--mc-stone-dark),
    0 0 10px rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
}

.header-title .pixel-icon {
  width: 40px;
  height: 40px;
  background: var(--mc-gold);
  border: 2px solid var(--mc-stone-dark);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.3), inset -2px -2px 0 rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.header-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 10px 16px;
  background: var(--mc-stone);
  color: var(--mc-white);
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.3),
    inset -2px -2px 0 rgba(0,0,0,0.3),
    2px 2px 0 rgba(0,0,0,0.3);
  transition: all 0.05s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pixel-btn:hover {
  background: var(--mc-stone-dark);
  box-shadow:
    inset 2px 2px 0 rgba(0,0,0,0.3),
    inset -2px -2px 0 rgba(255,255,255,0.2);
  transform: translateY(2px);
}

.pixel-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.pixel-btn.gold {
  background: var(--mc-gold);
  color: var(--mc-black);
}

.pixel-btn.green {
  background: var(--mc-grass-top);
  color: var(--mc-white);
}

/* ---- Main Content ---- */
.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 16px;
  position: relative;
  z-index: 1;
  min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

/* ---- Stats Bar (Dirt block style) ---- */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 12px 20px;
  margin-bottom: 24px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--mc-dirt) 0px, var(--mc-dirt) 8px,
      var(--mc-dirt-dark) 8px, var(--mc-dirt-dark) 16px
    );
  border: var(--border-thick) solid var(--mc-stone-dark);
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.15),
    inset -2px -2px 0 rgba(0,0,0,0.3);
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
  color: var(--mc-white);
  font-size: 16px;
  text-shadow: 1px 1px 0 var(--mc-black);
}

.stat-item .stat-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  display: block;
  color: var(--mc-gold);
}

.stat-item .stat-label {
  font-size: 12px;
  opacity: 0.8;
}

/* ---- Photo Grid ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 8px;
}

.photo-card {
  background: var(--mc-wood);
  border: var(--border-thick) solid var(--mc-wood-light);
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.2),
    inset -3px -3px 0 rgba(0,0,0,0.3),
    4px 4px 0 rgba(0,0,0,0.3);
  padding: 8px;
  cursor: pointer;
  transition: all 0.1s;
  position: relative;
  overflow: hidden;
}

.photo-card:hover {
  transform: translateY(-4px);
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.2),
    inset -3px -3px 0 rgba(0,0,0,0.3),
    6px 8px 0 rgba(0,0,0,0.3);
}

.photo-card:active {
  transform: translateY(0px);
  box-shadow:
    inset 2px 2px 0 rgba(0,0,0,0.3),
    inset -2px -2px 0 rgba(255,255,255,0.2);
}

.photo-card .photo-frame {
  position: relative;
  width: 100%;
  padding-bottom: 75%; /* 4:3 aspect ratio */
  background: var(--mc-bedrock);
  overflow: hidden;
  border: 2px solid var(--mc-stone-dark);
}

.photo-card .photo-frame img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  transition: transform 0.3s ease;
}

.photo-card:hover .photo-frame img {
  transform: scale(1.05);
}

.photo-card .photo-info {
  padding: 10px 4px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.photo-card .photo-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--mc-white);
  text-shadow: 1px 1px 0 var(--mc-black);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-card .photo-stats {
  display: flex;
  gap: 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--mc-gold);
}

/* Like badge on cards */
.like-badge, .comment-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ---- Crafting Table Loading Animation ---- */
.crafting-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.crafting-grid {
  display: grid;
  grid-template-columns: 32px 32px 32px;
  grid-template-rows: 32px 32px 32px;
  gap: 2px;
  background: var(--mc-wood);
  padding: 8px;
  border: var(--border-thick) solid var(--mc-stone-dark);
  margin-bottom: 16px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.2), inset -2px -2px 0 rgba(0,0,0,0.3);
}

.crafting-cell {
  background: var(--mc-wood-light);
  border: 1px solid var(--mc-wood);
}

.crafting-cell.active {
  background: var(--mc-gold);
  animation: craft-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes craft-pulse {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

.crafting-loader-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--mc-white);
  text-shadow: 2px 2px 0 var(--mc-black);
  animation: blink 1.2s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-state .grass-block {
  display: inline-block;
  width: 64px;
  height: 64px;
  background: var(--mc-grass-top);
  border: 3px solid var(--mc-stone-dark);
  margin-bottom: 16px;
  box-shadow:
    inset 3px 3px 0 rgba(255,255,255,0.2),
    inset -3px -3px 0 rgba(0,0,0,0.3);
}

.empty-state h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: var(--mc-white);
  text-shadow: 2px 2px 0 var(--mc-black);
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 18px;
  color: rgba(255,255,255,0.8);
}

/* ---- Footer (Grass Block) ---- */
.pixel-footer {
  background:
    repeating-linear-gradient(
      90deg,
      var(--mc-grass-side) 0px, var(--mc-grass-side) 16px,
      var(--mc-dirt) 16px, var(--mc-dirt) 32px
    ),
    linear-gradient(180deg, var(--mc-grass-side), var(--mc-dirt));
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: var(--border-thick) solid var(--mc-stone-dark);
  box-shadow:
    0 calc(var(--pixel-unit) * -1) 0 0 rgba(0,0,0,0.3);
}

.footer-text {
  font-family: 'VT323', monospace;
  font-size: 16px;
  color: var(--mc-white);
  text-shadow: 1px 1px 0 var(--mc-black);
  opacity: 0.9;
}

/* ---- Notification Toast ---- */
.pixel-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--mc-dirt);
  border: var(--border-thick) solid var(--mc-stone-dark);
  padding: 12px 24px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--mc-white);
  z-index: 9999;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.2),
    inset -2px -2px 0 rgba(0,0,0,0.3),
    4px 4px 0 rgba(0,0,0,0.3);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  text-shadow: 1px 1px 0 var(--mc-black);
}

.pixel-toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .header-title {
    font-size: 14px;
  }

  .header-title .pixel-icon {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }

  .pixel-btn {
    font-size: 8px;
    padding: 8px 10px;
  }

  .stats-bar {
    gap: 16px;
    padding: 8px 12px;
  }

  .stat-item {
    font-size: 14px;
  }

  .stat-item .stat-value {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .photo-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .header-nav {
    display: none;
  }

  .header-title {
    font-size: 12px;
  }
}

/* ---- Modal / Lightbox ---- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
  background: var(--mc-wood);
  border: var(--border-thick) solid var(--mc-wood-light);
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.2),
    inset -3px -3px 0 rgba(0,0,0,0.3),
    0 0 40px rgba(0,0,0,0.5);
  padding: 8px;
}

.modal-content img {
  max-width: 100%;
  max-height: calc(90vh - 120px);
  display: block;
  image-rendering: auto;
}

.modal-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 36px;
  height: 36px;
  background: var(--mc-stone);
  border: 3px solid var(--mc-stone-dark);
  color: var(--mc-white);
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.3),
    inset -2px -2px 0 rgba(0,0,0,0.3);
}

.modal-close:hover {
  background: var(--mc-fire);
}

.modal-details {
  padding: 12px 8px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-like-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 6px 12px;
  background: var(--mc-gold);
  color: var(--mc-black);
  border: none;
  cursor: pointer;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.3),
    inset -2px -2px 0 rgba(0,0,0,0.3);
  transition: all 0.05s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-like-btn:hover {
  background: #e6c200;
  box-shadow:
    inset 2px 2px 0 rgba(0,0,0,0.3),
    inset -2px -2px 0 rgba(255,255,255,0.2);
  transform: translateY(2px);
}

.modal-like-btn.liked {
  background: var(--mc-fire);
  color: var(--mc-white);
}

.modal-comments {
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  margin-top: 8px;
  background: var(--mc-bedrock);
  border: 2px solid var(--mc-stone-dark);
}

.comment-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--mc-stone-dark);
  font-size: 14px;
}

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

.comment-author {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--mc-gold);
}

.comment-text {
  color: var(--mc-white);
  margin-top: 2px;
}

.comment-time {
  font-size: 10px;
  color: var(--mc-stone);
  float: right;
}

.comment-form {
  display: flex;
  gap: 8px;
  padding: 8px;
  margin-top: 8px;
}

.pixel-input {
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 6px 10px;
  background: var(--mc-white);
  border: 3px solid var(--mc-stone-dark);
  color: var(--mc-black);
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.1);
  outline: none;
}

.pixel-input:focus {
  border-color: var(--mc-gold);
}

.pixel-input.name-input {
  width: 100px;
}

.pixel-input.comment-input {
  flex: 1;
}

/* ---- Photo Detail Page ---- */
.photo-detail-container {
  max-width: 900px;
  margin: 0 auto;
}

.photo-detail-card {
  background: var(--mc-wood);
  border: var(--border-thick) solid var(--mc-wood-light);
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.2),
    inset -3px -3px 0 rgba(0,0,0,0.3),
    4px 4px 0 rgba(0,0,0,0.3);
  padding: 12px;
}

.photo-detail-card .detail-image {
  width: 100%;
  margin-bottom: 16px;
  background: var(--mc-bedrock);
  border: 2px solid var(--mc-stone-dark);
}

.photo-detail-card .detail-image img {
  width: 100%;
  display: block;
  image-rendering: auto;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.detail-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: var(--mc-white);
  text-shadow: 2px 2px 0 var(--mc-black);
}

.detail-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.detail-like-count {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--mc-gold);
}

.detail-description {
  font-size: 18px;
  color: var(--mc-white);
  text-shadow: 1px 1px 0 var(--mc-black);
  margin-bottom: 16px;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-left: 4px solid var(--mc-gold);
}

.comments-section {
  background: var(--mc-dirt-dark);
  border: var(--border-thick) solid var(--mc-stone-dark);
  padding: 16px;
  margin-top: 16px;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.15),
    inset -2px -2px 0 rgba(0,0,0,0.3);
}

.comments-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--mc-white);
  text-shadow: 1px 1px 0 var(--mc-black);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--mc-stone);
}

.comments-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.no-comments {
  color: rgba(255,255,255,0.5);
  font-size: 16px;
  text-align: center;
  padding: 20px;
}

/* ---- Back button ---- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

/* ---- Search / Filter ---- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  justify-content: center;
}

.search-input {
  font-family: 'VT323', monospace;
  font-size: 18px;
  padding: 10px 16px;
  background: var(--mc-white);
  border: 3px solid var(--mc-stone-dark);
  color: var(--mc-black);
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.1);
  outline: none;
  width: 100%;
  max-width: 400px;
}

.search-input:focus {
  border-color: var(--mc-gold);
}

/* ---- Scroll to top ---- */
.scroll-top {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: var(--mc-dirt);
  border: 3px solid var(--mc-stone-dark);
  color: var(--mc-white);
  font-size: 20px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.2),
    inset -2px -2px 0 rgba(0,0,0,0.3);
}

.scroll-top.show {
  display: flex;
}

.scroll-top:hover {
  background: var(--mc-grass-top);
}
