:root {
  --primary: #798C72; /* Sage green */
  --primary-hover: #62755B;
  --secondary: #98A991; /* Lighter sage */
  --secondary-hover: #84967C;
  --accent: #D2C4A7; /* Soft sand */
  --bg-color: #F4F6F2;
  --text-dark: #2C3628;
  --text-light: #657360;
  --text-inverse: #ffffff;
  --error: #e66a70;
  
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(121, 140, 114, 0.15);
  --border-radius-lg: 0;
  --border-radius-md: 0;
  --border-radius-sm: 0;
  
  --font-heading: 'Playfair Display', serif;
  --font-body: 'Quicksand', sans-serif;
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 2rem; /* Ensure some bottom clearance to prevent cropping in iframes */
}

.hidden {
  display: none !important;
}

.mt-4 {
  margin-top: 1.5rem;
}
.text-center {
  text-align: center;
}

/* Glassmorphism Panel */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--border-radius-lg);
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-dark);
}

/* Layout */
.site-wrapper {
  display: flex;
  flex-direction: column;
}

/* Hero Section */
.hero {
  position: relative;
  min-height: 300px;
  max-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  text-align: center;
  overflow: hidden;
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(121, 140, 114, 0.4) 0%, rgba(244, 246, 242, 0.9) 100%);
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
  max-height: 100%;
  overflow-y: auto;
  padding: 3rem 2rem;
  background: rgba(255,255,255,0.7);
}

.badge {
  display: inline-block;
  padding: 0.35rem 1rem;
  background-color: var(--accent);
  color: var(--text-dark);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 0;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-dark);
  max-width: 600px;
  margin: 0 auto;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 2rem 1.5rem 4rem;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 3;
  margin-top: -3rem;
}

/* Tabs */
.tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 1rem 2rem;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Forms */
.upload-form {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem;
  max-width: 700px;
  margin: 0 auto;
}

.file-drop-area {
  position: relative;
  border: 2px dashed var(--primary);
  border-radius: var(--border-radius-md);
  padding: 3rem 2rem;
  text-align: center;
  background-color: rgba(121, 140, 114, 0.05);
  transition: all 0.3s ease;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.file-drop-area:hover, .file-drop-area.dragover {
  background-color: rgba(121, 140, 114, 0.1);
  border-color: var(--primary-hover);
}

.file-icon {
  color: var(--primary);
  margin-bottom: 1rem;
}

.file-prompt {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
}

.file-subprompt {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

#media-input {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
}

#file-preview-container {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-color);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#file-preview {
  max-width: 100%;
  max-height: 80%;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin-bottom: 1rem;
  object-fit: contain;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-row {
  display: flex;
  gap: 1.5rem;
}

.form-row .form-group {
  flex: 1;
}

@media (max-width: 600px) {
  .form-row { flex-direction: column; gap: 0; }
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #dcd7df;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(121, 140, 114, 0.2);
}

/* Buttons */
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 2rem;
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--text-inverse);
  box-shadow: 0 4px 15px rgba(121, 140, 114, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(121, 140, 114, 0.4);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(121, 140, 114, 0.1);
  color: var(--primary);
  border: 1px solid rgba(121, 140, 114, 0.2);
}

.btn-secondary:hover {
  background: rgba(121, 140, 114, 0.15);
}

.btn-text {
  background: none;
  border: none;
  color: var(--error);
  font-weight: 600;
  cursor: pointer;
}

.btn-text:hover { text-decoration: underline; }

/* Post Entry / Share */
.post-entry {
  text-align: center;
  padding: 3rem 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.success-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

.user-submission {
  margin: 2rem 0;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.user-submission img {
  width: 100%;
  max-height: 450px;
  object-fit: contain;
  background: rgba(0,0,0,0.02);
  display: block;
}

.user-caption {
  padding: 1rem;
  background: rgba(255,255,255,0.9);
  font-style: italic;
}

.share-box {
  background: rgba(255,255,255,0.6);
  padding: 1.5rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 1.5rem;
}

.share-url-container {
  display: flex;
  margin-top: 1rem;
  gap: 0.5rem;
}

.share-url-container input {
  margin-bottom: 0;
  flex: 1;
}

.share-url-container button {
  width: auto;
  white-space: nowrap;
}

.bonus-info {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
}

.post-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.post-entry-actions .btn-primary,
.post-entry-actions .btn-secondary {
  width: auto;
  margin-top: 0;
}

@media (max-width: 600px) {
  .post-entry-actions {
    flex-direction: column;
  }
  .post-entry-actions .btn-primary,
  .post-entry-actions .btn-secondary {
    width: 100%;
  }
}

/* Gallery Grid */
.gallery-carousel-wrapper {
  position: relative;
}

.carousel-nav {
  display: none; /* Hidden on desktop */
}

.gallery-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

@media (max-width: 767px) {
  .carousel-nav {
    display: flex;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary);
    border: 1px solid rgba(121, 140, 114, 0.3);
    width: 40px; 
    height: 40px;
    border-radius: 0;
    font-size: 1.25rem;
    cursor: pointer;
    align-items: center; 
    justify-content: center;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
  }
  
  .carousel-nav:hover {
    background: var(--primary);
    color: white;
  }
  
  .carousel-nav.prev { left: -15px; }
  .carousel-nav.next { right: -15px; }

  .gallery-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
    padding-bottom: 0;
    overflow: hidden;
  }
  
  .gallery-card {
    display: none !important;
    animation: fadeInRandom 0.4s ease-out forwards;
    flex: none;
    width: auto;
  }
  
  .gallery-card.mobile-visible {
    display: flex !important;
  }
  
  .gallery-card .card-content {
    display: none;
  }
}

@keyframes fadeInRandom {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.gallery-card {
  background: var(--glass-bg);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  border: 1px solid var(--glass-border);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.gallery-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(121, 140, 114, 0.15);
}

.card-img-wrapper {
  position: relative;
  padding-top: 100%; /* Square aspect ratio */
  overflow: hidden;
  cursor: pointer;
  border-radius: inherit;
}

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

.gallery-card:hover .card-img-wrapper img {
  transform: scale(1.05);
}

.card-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-caption {
  font-size: 0.95rem;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-author {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  flex: 1;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(0,0,0,0.05);
  padding-top: 0.75rem;
}

.btn-vote {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-vote:hover { color: var(--text-dark); }

.btn-vote.voted {
  color: var(--secondary);
  cursor: default;
}
.btn-vote.voted svg {
  fill: var(--secondary);
}

.vote-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
}

/* Lightbox */
.lightbox {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.lightbox.hidden {
  opacity: 0;
  pointer-events: none;
}

.lightbox-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(20, 15, 25, 0.85);
  backdrop-filter: blur(8px);
}

.lightbox-container {
  position: relative;
  width: 90%;
  max-width: 1000px;
  height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content {
  display: flex;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--bg-color);
  border-radius: var(--border-radius-lg);
}

@media (max-width: 768px) {
  .lightbox-content { flex-direction: column; }
}

.lightbox-image-container {
  flex: 2;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-image-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox-details {
  flex: 1;
  min-width: 300px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.lightbox-author {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.lightbox-caption {
  font-size: 1.1rem;
  color: var(--text-dark);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.lightbox-actions {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lightbox-vote-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lightbox-vote-container .btn-vote {
  font-size: 1.1rem;
  padding: 0.5rem 1rem;
  background: rgba(121, 140, 114, 0.1);
  border-radius: 0;
}
.lightbox-vote-container .btn-vote.voted {
  background: rgba(121, 140, 114, 0.15);
}

.lightbox-share {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0;
  transition: all 0.2s ease;
  display: flex;
}
.btn-icon:hover {
  background: rgba(0,0,0,0.05);
  color: var(--primary);
}

.lightbox-close {
  position: absolute;
  top: -40px; right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  width: 50px; height: 50px;
  border-radius: 0;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}
.lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.lightbox-nav.prev { left: -60px; }
.lightbox-nav.next { right: -60px; }

@media (max-width: 1100px) {
  .lightbox-nav.prev { left: 10px; z-index: 10; }
  .lightbox-nav.next { right: 10px; z-index: 10; }
  .lightbox-close { top: 10px; right: 10px; z-index: 10; background: rgba(0,0,0,0.5); border-radius: 0; width: 40px; height: 40px; }
}

/* Utilities */
.spinner {
  width: 40px; height: 40px;
  border: 4px solid rgba(121, 140, 114, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gallery-loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

.error-msg {
  color: var(--error);
  background: rgba(230, 106, 112, 0.1);
  padding: 1rem;
  border-radius: var(--border-radius-sm);
  margin-bottom: 1.5rem;
  font-weight: 600;
  text-align: center;
}

.status-message {
  text-align: center;
  padding: 2rem;
  background: var(--glass-bg);
  border-radius: var(--border-radius-lg);
  margin-bottom: 2rem;
  font-size: 1.25rem;
  font-family: var(--font-heading);
  box-shadow: var(--glass-shadow);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}
.empty-img {
  max-width: 300px;
  width: 100%;
  border-radius: var(--border-radius-md);
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.empty-state h3 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

/* Countdown */
.countdown-container {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.3);
}
.countdown-label {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.countdown {
  display: flex;
  justify-content: center;
  gap: 1rem;
}
.time-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.5);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  min-width: 70px;
}
.time-block span {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.time-block small {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dark);
}

#wbx-powered-by-slot {
  margin: 2rem auto;
  text-align: center;
}

/* Rules Tab */
.rules-container {
  padding: 3rem 2.5rem;
  max-width: 800px;
  margin: 0 auto;
}

.rules-container h2 {
  margin-bottom: 2rem;
  text-align: center;
  color: var(--primary);
  font-size: 2rem;
}

.rules-list {
  padding-left: 1.5rem;
  color: var(--text-dark);
}

.rules-list li {
  margin-bottom: 1.25rem;
  font-size: 1.1rem;
  line-height: 1.6;
}

@media (max-width: 600px) {
  .rules-container {
    padding: 2rem 1.5rem;
  }
  .rules-container h2 {
    font-size: 1.5rem;
  }
}
