/* FIX: Theme definitions moved to <html> tag
  This supports the instant theme loader script.
*/
html {
  /* --- Dark Mode (Default) --- */
  --bg1: #0f0f10;
  --bg2: #121216;
  --accent: #ff6b6b;
  --accent-yellow: #ffd36b;
  --text-primary: #ffffff;
  --text-secondary: rgba(255,255,255,0.9);
  --muted: rgba(255,255,255,0.65);
  --glass: rgba(255,255,255,0.04);
  --border-color: rgba(255,255,255,0.06);
  --card-bg: var(--glass);
  --input-bg: var(--bg1);
  --btn-primary-text: #111;
  --nav-link-hover-bg: var(--glass);
  --nav-link-hover-text: var(--accent);
  /* Theme-aware image placeholders */
  --img-bg-color: '121216';
  --img-text-color: 'ff6b6b';
  --img-text-color-alt: 'ffd36b';
  --img-text-color-plain: 'ffffff';
  --img-text-color-muted: 'aaaaaa';
  /* Footer */
  --footer-bg: var(--bg1);
}

/* --- Light Mode --- */
html.light-mode {
  --bg1: #f4f4f5; /* Light gray */
  --bg2: #ffffff; /* White */
  --accent: #e65c5c; /* Darker accent */
  --accent-yellow: #e6b85c;
  --text-primary: #18181b; /* Near black */
  --text-secondary: #3f3f46; /* Dark gray */
  --muted: #71717a; /* Medium gray */
  --glass: rgba(0,0,0,0.03);
  --border-color: rgba(0,0,0,0.08);
  --card-bg: #ffffff; /* Cards are white */
  --input-bg: #f4f4f5; /* Inputs are light gray */
  --btn-primary-text: #ffffff; /* White text on gradient */
  --nav-link-hover-bg: var(--glass);
  --nav-link-hover-text: var(--accent);
  /* Theme-aware image placeholders */
  --img-bg-color: 'ffffff';
  --img-text-color: 'e65c5c';
  --img-text-color-alt: 'e6b85c';
  --img-text-color-plain: '18181b';
  --img-text-color-muted: '71717a';
  /* Footer */
  --footer-bg: #ffffff; /* Solid white footer */
}

*{box-sizing:border-box}

/* FIXED: HTML element now switches background color for light mode */
html {
  background: var(--bg2);
  transition: background 0.3s ease;
}
body{
  height:100%;
  margin:0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  /* FIXED: body gradient also uses theme variables */
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 12px;
}
::-webkit-scrollbar-track {
  background: var(--bg1); /* Dark track */
  transition: background 0.3s ease;
}
::-webkit-scrollbar-thumb {
  background: var(--accent); /* Fallback */
  background: linear-gradient(0deg, var(--accent), var(--accent-yellow)); /* Vertical gradient */
  border-radius: 10px;
  border: 2px solid var(--bg1); /* Creates a little space */
  transition: background 0.3s ease, border-color 0.3s ease;
}
html.light-mode ::-webkit-scrollbar-thumb {
   border-color: var(--bg2);
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(0deg, #ff8181, #ffe396); /* Lighter hover */
}
html.light-mode ::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(0deg, #e87676, #e6c581);
}

/* --- Splash Screen --- */
#splash-screen {
  position: fixed;
  inset: 0;
  background: var(--bg1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.5s ease-out, visibility 0.5s, background 0.3s ease;
}
#splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
}
@keyframes glow {
  0%, 100% {
    text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent), 0 0 30px rgba(255,107,107,0.5);
  }
  50% {
    text-shadow: 0 0 20px var(--accent), 0 0 30px var(--accent), 0 0 40px rgba(255,107,107,0.7);
  }
}
html.light-mode @keyframes glow {
  0%, 100% {
    text-shadow: 0 0 10px var(--accent), 0 0 20px rgba(230,92,92,0.5);
  }
  50% {
    text-shadow: 0 0 20px var(--accent), 0 0 30px rgba(230,92,92,0.7);
  }
}
.splash-brand {
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 44px;
  line-height: 1;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: glow 3s ease-in-out infinite;
}
.splash-brand .slash {
  color: var(--accent);
  background: linear-gradient(90deg,var(--accent),var(--accent-yellow));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.splash-enter-btn {
  margin-top: 40px;
  background: linear-gradient(90deg,var(--accent),var(--accent-yellow));
  color: var(--btn-primary-text);
  border: 0;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease, color 0.3s ease;
}
.splash-enter-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 30px rgba(255,107,107,0.3);
}
html.light-mode .splash-enter-btn:hover {
  box-shadow: 0 8px 30px rgba(230,92,92,0.3);
}
.splash-enter-btn:disabled {
  background: var(--glass);
  color: var(--muted);
  cursor: wait;
  transform: none;
  box-shadow: none;
}

/* --- Main Site --- */
#main-site {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 28px;
  /* Opacity set by inline style from PHP */
  transition: opacity 0.5s ease-in;
}

/* Left Column (News Feed) */
.content-area {
  display: flex;
  flex-direction: column;
  gap: 24px;
  /* This ensures the column doesn't collapse */
  min-width: 0;
  /* Animation for page loads */
  animation: fadeInPage 0.5s;
}
@keyframes fadeInPage {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Right Column (Sidebar) */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 32px;
  height: fit-content;
}

/* General Card Styling */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 24px;
  transition: background 0.3s ease, border-color 0.3s ease;
}
html.light-mode .card {
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

/* --- Image Slideshow --- */
.slideshow-container {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--glass);
  aspect-ratio: 16 / 9;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.slide {
  display: none;
  width: 100%;
  height: 100%;
  position: relative; /* For link */
}
.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  vertical-align: middle;
  transition: opacity 0.3s ease;
}
/* This is the clickable link for a slide */
.slide-link {
    position: absolute;
    inset: 0;
    z-index: 2;
    /* To visually indicate it's clickable (optional) */
    /* cursor: pointer; */ 
}
.slide .text-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4vw;
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  text-align: center;
  padding: 20px;
  line-height: 1.2;
  z-index: 1; /* Below link */
}
.slide.active {
  display: block;
  animation: fade 1.5s;
}
@keyframes fade {
  from {opacity: .4}
  to {opacity: 1}
}
/* Next & previous buttons */
.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 16px;
  margin-top: -22px;
  color: white;
  font-weight: bold;
  font-size: 20px;
  transition: 0.3s ease;
  border-radius: 0 8px 8px 0;
  user-select: none;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(5px);
  z-index: 3; /* Above link */
}
.next {
  right: 0;
  border-radius: 8px 0 0 8px;
}
.prev:hover, .next:hover {
  background: rgba(255, 107, 107, 0.5); /* Accent color on hover */
}

/* --- News Feed --- */
.news-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.news-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  overflow: hidden;
  transition: background 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
html.light-mode .news-item {
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.news-item:hover {
  background: rgba(255,255,255,0.06);
}
html.light-mode .news-item:hover {
  background: #fafafa;
  border-color: rgba(0,0,0,0.12);
}
.news-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
  margin: auto;
  display: block;
}
/* THIS IS THE FIX: Styles the placeholder text */
.news-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg1); /* Slightly darker background */
  font-size: 34px; /* <<< MADE BIGGER */
  font-weight: 800;
  color: var(--accent); /* Use accent color */
  text-align: center;
  padding: 10px;
  line-height: 1.3;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 200px; /* <<< ADDED MIN-HEIGHT FOR CENTERING */
}
html.light-mode .news-image-placeholder {
  background: var(--input-bg); /* Use light gray */
}

.news-content {
  padding: 24px;
  padding-left: 0;
  display: flex;
  flex-direction: column;
}
.news-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
  cursor: pointer;
  transition: color 0.2s ease;
  color: var(--text-primary);
  text-decoration: none;
}
.news-title:hover {
  color: var(--accent);
}
.news-snippet {
  color: var(--muted);
  font-size: 14px;
  margin-top: 12px;
  line-height: 1.6;
  flex-grow: 1;
  transition: color 0.3s ease;
}
.btn {
  background: transparent;
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  text-align: center;
}
.btn.primary {
  background: linear-gradient(90deg,var(--accent),var(--accent-yellow));
  color: var(--btn-primary-text);
  border: 0;
}
.btn.primary:hover {
  background: linear-gradient(90deg, #ff8181, #ffe396);
}
html.light-mode .btn.primary:hover {
  background: linear-gradient(90deg, #e87676, #e6c581);
}
.btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.read-more-btn {
  margin-top: 16px;
  align-self: flex-start;
}

/* --- Sidebar Navigation --- */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  padding: 14px 20px;
  border-radius: 12px;
  transition: color 0.2s ease, background 0.2s ease;
  display: block;
}
.nav-link:hover {
  color: var(--nav-link-hover-text);
  background: var(--nav-link-hover-bg);
}
.nav-link.active {
  color: var(--btn-primary-text);
  background: linear-gradient(90deg,var(--accent),var(--accent-yellow));
}

/* --- Theme Toggle Switch --- */
.nav-link-switch {
  color: var(--muted);
  font-weight: 600;
  font-size: 16px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: color 0.2s ease;
}
.theme-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 2px;
  background-color: var(--muted);
  transition: .4s;
  border-radius: 50%;
}
html.light-mode .slider {
  background-color: var(--input-bg);
}
input:checked + .slider {
  background-color: var(--accent);
  border-color: var(--accent);
}
html.light-mode input:checked + .slider {
  background-color: var(--accent);
}
input:checked + .slider:before {
  transform: translateX(19px);
  background-color: white;
}

/* --- Sidebar Subscribe --- */
.subscribe-box h3 {
  margin-top: 0;
  font-weight: 600;
}
.subscribe-box p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
  transition: color 0.3s ease;
}
.subscribe-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  color: var(--text-primary);
  font-size: 14px;
  margin-top: 16px;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.subscribe-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255,107,107,0.3);
}
html.light-mode .subscribe-input:focus {
  box-shadow: 0 0 10px rgba(230,92,92,0.3);
}
.subscribe-btn {
  width: 100%;
  margin-top: 12px;
}

/* Universal Footer */
footer{
  grid-column: 1 / -1;
  margin-top: 18px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  /* UPDATED: Solid background for footer */
  background: var(--footer-bg);
  padding-bottom: 24px; /* Add padding for solid bg */
  transition: border-color 0.3s ease, color 0.3s ease, background 0.3s ease;
}

/* --- Full Page Sections (Journal, Shop, etc.) --- */
/* Page sections are now loaded by PHP, so CSS hiding is not needed. */
.page-header {
  font-weight: 800;
  font-size: 44px;
  line-height: 1;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-header .slash {
  color: var(--accent);
  background: linear-gradient(90deg,var(--accent),var(--accent-yellow));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Loading Indicator */
.loading-indicator {
  color: var(--muted);
  font-size: 16px;
  padding: 40px;
  text-align: center;
  transition: color 0.3s ease;
}

/* Article Page Styling */
.article-content {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  transition: color 0.3s ease;
  /* THIS IS THE FIX: Removed text-align: center; */
}
.article-content p {
  margin-bottom: 20px;
}
.article-content img {
  max-width: 100%;
  border-radius: 12px;
  margin: 20px 0;
  transition: opacity 0.3s ease;
}
/* Article images should be centered */
.article-content img {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Comments Section - REMOVED */

/* Form styles for Contact Page */
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.comment-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  color: var(--text-primary);
  font-size: 15px;
  resize: vertical;
  font-family: 'Inter', sans-serif;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.comment-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255,107,107,0.3);
}
html.light-mode .comment-input:focus {
  box-shadow: 0 0 10px rgba(230,92,92,0.3);
}
.comment-submit-btn {
  align-self: flex-start;
}

/* Responsive Design */
@media (max-width: 980px) {
  #main-site {
    grid-template-columns: 1fr;
    margin: 0;
    padding: 20px;
  }
  .sidebar {
    position: static;
    top: 0;
    order: -1; /* Move sidebar to top on mobile */
  }
  .splash-brand {
    font-size: 40px;
  }
  .page-header {
    font-size: 40px;
  }
  .news-item {
    grid-template-columns: 1fr;
  }
  .news-image, .news-image-placeholder {
    height: 200px;
    border-radius: 18px 18px 0 0;
  }
  .news-content {
    padding: 24px;
    padding-left: 24px;
  }
  .slide .text-overlay {
    font-size: 8vw;
  }
}
@media (max-width: 520px) {
  #main-site {
    padding: 12px;
  }
  .splash-brand {
    font-size: 30px;
  }
  .page-header {
    font-size: 30px;
  }
  .slideshow-container {
    aspect-ratio: 4 / 3;
  }
  .nav-link-switch span {
    display: none; /* Hide "Light Mode" text on mobile */
  }
  .news-item {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .news-image, .news-image-placeholder {
    border-radius: 18px 18px 0 0;
  }
  .news-content {
    padding: 24px;
    padding-left: 24px;
  }
  .card {
    padding: 20px;
  }
  .sidebar-nav {
    padding: 12px;
  }
  .nav-link {
    padding: 12px 16px;
  }
  .nav-link-switch {
    padding: 12px 16px;
  }
  .slide .text-overlay {
    font-size: 10vw;
  }
}