/* #region CSS Variables */
:root {
  --bg: #202020;
  --text: #00ff00;
  --accent: #fefefe;
  --highlight: #ffcc00;
  --link: #66d9ff;
  --link-hover: #a7f3ff;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #fdf6e3;  
    --text: #073642;
    --accent: #586e75;
    --highlight: #b58900;
  }
}

/* Explicit theme overrides */
[data-theme="dark"] {
  --bg: #202020;
  --text: #00ff00;
  --accent: #fefefe;
  --highlight: #ffcc00;
}

[data-theme="light"] {
  --bg: #fdf6e3;
  --text: #073642;
  --accent: #586e75;
  --highlight: #b58900;
  --link: #0066cc;
  --link-hover: #004a99;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}
/* #endregion */

/* Project downloads (buttons) */
.project-downloads {
  margin: 20px 0 40px 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.download-button {
  display: inline-block;
  padding: 10px 16px;
  background: var(--highlight);
  color: var(--bg);
  text-decoration: none;
  border-radius: 6px;
  font-weight: bold;
  border: 2px solid var(--highlight);
}

.download-button:hover {
  background: transparent;
  color: var(--highlight);
}

/* Ensure modal caption is readable on smaller screens */
@media (max-width: 480px) {
  .modal-caption { font-size: 14px; padding: 6px 10px; }
}

/* Project summary header */
#project-summary {
  font-size: 22px; /* smaller than the main title (h1) */
  color: var(--text);
  margin: 0px 0 50px 0; /* even closer to title, larger bottom margin */
  font-weight: 600;
}

/* #region Layout */
html, body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: Consolas, monospace;
  background-color: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

main {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 20px;
  box-sizing: border-box;
  text-align: left;
}

header {
  padding: 20px;
}

footer {
  margin-top: auto;
  width: 100%;
  padding: 10px 0;
  background-color: var(--bg);
  color: var(--text);
  text-align: center;
  line-height: 1.4;

  border-top: 2px solid var(--accent);
}

footer a {
  color: var(--text);
  text-decoration: none;
  margin: 0 8px;
}

footer a:hover {
  text-decoration: underline;
}

/* Global link styles that follow theme variables */
a {
  color: var(--link);
  text-decoration: underline dotted;
}

a:hover,
a:focus {
  color: var(--link-hover);
  text-decoration: underline;
}

a:visited {
  opacity: 0.85;
}

.footer-links {
  margin-bottom: 6px;
}

.footer-copy {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
}
/* #endregion */

/* #region Typography */
h1 {
  font-size: 36px;
  text-align: left;
}

/* Tighten spacing for project title */
#project-title {
  margin: 0 0 6px 0;
}

p {
  font-size: 18px;
  line-height: 1.5;
}
/* #endregion */

/* #region Media */
img, video {
  max-width: 100%;
}

.centerimg {
  display: block;
  margin: auto;
}

/* Image utility classes */
.img-left { 
  float: left; 
  margin: 0 20px 20px 0; 
}

.img-right { 
  float: right; 
  margin: 0 0 20px 20px; 
}

.img-small { max-width: 200px; }
.img-medium { max-width: 400px; }
.img-large { max-width: 600px; }
.img-full { width: 100%; }

.img-rounded { border-radius: 8px; }
.img-circle { border-radius: 50%; }
.img-shadow { box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
.img-border { border: 2px solid var(--accent); }

/* Figure and caption styling */
figure {
  margin: 20px 0;
  padding: 0;
}

figcaption {
  text-align: center;
  font-style: italic;
  font-size: 14px;
  color: var(--accent);
  margin-top: 8px;
  padding: 0 10px;
}

figure.img-left,
figure.img-right {
  margin: 0 20px 20px 0;
  max-width: 300px;
}

figure.img-right {
  margin: 0 0 20px 20px;
}
/* #endregion */

/* #region Components */
/* Navigation */
.main-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 20px 0;
  border-bottom: 1px solid var(--accent);
  margin-bottom: 20px;
}

.nav-brand a {
  color: var(--highlight);
  text-decoration: none;
  font-size: 20px;
  font-weight: bold;
}

.nav-brand a:hover {
  color: var(--text);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-menu > a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.nav-menu > a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Theme Toggle Button */
.theme-toggle {
  border: 2px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  margin-left: 10px;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Dark mode - show light colors in button */
[data-theme="dark"] .theme-toggle {
  background: #fdf6e3;
  border-color: #586e75;
  color: #073642;
}

[data-theme="dark"] .theme-toggle:hover {
  background: #eee8d5;
}

/* Light mode - show dark colors in button */
[data-theme="light"] .theme-toggle {
  background: #202020;
  border-color: #00ff00;
  color: #00ff00;
}

[data-theme="light"] .theme-toggle:hover {
  background: #303030;
}

/* Project link styling */
.project-link {
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
}

.project-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 8px;
}

.project-link:hover .project-overlay {
  opacity: 1;
}

.project-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.project-overlay p {
  margin: 0;
  color: white;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Image Gallery */
.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

/* Gallery Mode 1: Fixed frames (crop mode) */
.image-gallery img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  object-position: center;
  border-radius: 8px;
  transition: transform 0.3s ease;
  cursor: pointer;
}

/* Gallery Mode 2: Fit to content */
.image-gallery.fit-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: flex-start;
  align-items: flex-start;
}

.image-gallery.fit-mode figure {
  flex: 0 0 auto;
  max-width: 400px;
}

.image-gallery.fit-mode img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.image-gallery img:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.image-gallery-large {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.image-gallery-large img {
  height: 300px;
}

.image-gallery-small {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.image-gallery-small img {
  height: 150px;
}

/* External links gallery with overlay styling */
.external-links-gallery .link-card {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  margin: 0;
}

.image-container {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  border-radius: 8px;
}

.image-container img,
.placeholder-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  display: block;
}

.placeholder-image {
  display: block;
  border-radius: 8px;
  position: relative;
}

.youtube-placeholder {
  background: linear-gradient(135deg, #ff0000, #cc0000);
}

.github-placeholder {
  background: linear-gradient(135deg, #24292e, #0d1117);
}

/* Brand Logo Overlay Styling */
.brand-logo-overlay {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  max-width: 80% !important;
  max-height: 80% !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  filter: brightness(0) invert(1) !important;
  opacity: 1 !important;
  transition: all 0.3s ease !important;
}

/* Hover effect for brand logos */
.link-card:hover .brand-logo-overlay {
  opacity: 1 !important;
  transform: translate(-50%, -50%) scale(1.1) !important;
}

/* Image overlay styling */
.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0.4) 50%,
    rgba(0, 0, 0, 0.8) 100%
  );
  display: flex;
  align-items: flex-end;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.overlay-content {
  color: white;
  text-align: left;
  width: 100%;
}

.site-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.youtube-icon {
  color: #ff0000;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

.github-icon {
  color: #f0f6fc;
  text-shadow: 0 0 10px rgba(240, 246, 252, 0.3);
}

.overlay-content h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.overlay-content p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Hover effects */
.link-card:hover .image-overlay {
  opacity: 1;
}

.link-card:hover .image-container img,
.link-card:hover .placeholder-image {
  transform: scale(1.1);
}

.external-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.external-link:hover {
  text-decoration: none;
}

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropbtn {
  color: var(--text);
  padding: 8px 12px;
  font-size: 16px;
  font-family: Consolas, monospace;
  border: none;
  cursor: pointer;
  background-color: inherit;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.dropbtn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% - 2px);
  left: 0;
  z-index: 1000;
  background-color: var(--bg);
  min-width: 200px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 8px 0;
  backdrop-filter: blur(10px);
}

.dropdown-content a {
  color: var(--text);
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  font-family: Consolas, monospace;
  font-size: 14px;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.dropdown-content .dropcat {
  background-color: transparent;
  color: var(--accent);
  font-weight: bold;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 8px 16px 6px 16px;
  margin: 4px 0 8px 0;
  border-left: none;
  border-bottom: 1px solid var(--accent);
  opacity: 0.8;
}

.dropdown-content a:hover:not(.dropcat) {
  background-color: var(--highlight);
  color: var(--bg);
  border-left: 3px solid var(--highlight);
  transform: translateX(4px);
}

.dropdown:hover .dropdown-content {
  display: block;
  animation: dropdownFade 0.3s ease;
}

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

/* Theme-specific dropdown adjustments */
[data-theme="light"] .dropdown-content {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .dropdown-content {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* Logo */
.logo-container {
  display: flex;
  align-items: center;
  padding: 10px;
}

.logo-container img {
  height: 64px;
  width: 64px;
}

/* Image Modal */
.image-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  margin: auto;
  padding: 20px;
  width: 90%;
  max-width: 1200px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-image {
  max-width: 100%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: var(--text);
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
  transition: color 0.3s ease;
}

.modal-close:hover {
  color: var(--highlight);
}

.modal-caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text);
  text-align: center;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 20px;
  border-radius: 4px;
  backdrop-filter: blur(10px);
}

/* Animation for modal */
.image-modal.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* 404 Error Page Styling */
.error-container {
  text-align: center;
  max-width: 600px;
  margin: 40px auto;
  padding: 20px;
}

.error-code {
  font-size: 120px;
  font-weight: bold;
  color: var(--highlight);
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  margin-bottom: 20px;
  font-family: Consolas, monospace;
}

.error-message {
  font-size: 24px;
  color: var(--text);
  margin-bottom: 10px;
  font-weight: bold;
}

.error-description {
  font-size: 16px;
  color: var(--accent);
  margin-bottom: 30px;
  line-height: 1.5;
}

.error-mascot {
  margin: 40px 0;
}

.error-mascot img {
  transition: transform 0.3s ease !important;
  cursor: pointer !important;
}

.error-mascot img:hover,
.error-mascot .home-link:hover img {
  transform: scale(1.05) !important;
}

/* Override other image hover effects for 404 page */
.error-mascot .img-shadow:hover {
  box-shadow: 0 6px 12px rgba(0,0,0,0.4) !important;
}

.error-actions {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 30px;
}

.btn-home, .btn-projects {
  display: inline-block;
  padding: 12px 24px;
  background-color: var(--highlight);
  color: var(--bg);
  text-decoration: none;
  border-radius: 6px;
  font-weight: bold;
  font-family: Consolas, monospace;
  transition: all 0.3s ease;
  border: 2px solid var(--highlight);
}

.btn-home:hover, .btn-projects:hover {
  background-color: transparent;
  color: var(--highlight);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.home-link {
  display: inline-block;
  text-decoration: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .error-code {
    font-size: 80px;
  }
  
  .error-message {
    font-size: 20px;
  }
  
  .error-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .btn-home, .btn-projects {
    width: 200px;
  }
}

/* #endregion */
