/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f4f6f8;
  color: #2c3e50;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Container for main content */
.container {
  max-width: 1300;
  margin: 2rem auto;
  padding: 0 1rem;
  flex-grow: 1;
}

@media (max-width: 600px) {
  .container {
    padding: 0 0.5rem;
  }
}

/* Header hero */
.hero {
  text-align: center;
  background: linear-gradient(90deg, #2c3e50, #3498db);
  color: white;
  padding: 3rem 1rem;
  border-radius: 8px;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
}

.hero p {
  font-size: 1.2rem;
  font-weight: 300;
}

/* Navigation bar */
nav {
  width: 100vw;
  background-color: #222;
  padding: 0.5rem 1rem;
}

nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 2rem;
}

nav ul li a {
  color: #ddd;
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 1rem;
  display: block;
  transition: background-color 0.3s ease, color 0.3s ease;
}

nav ul li a:hover,
nav ul li a.active {
  background-color: #3498db;
  color: white;
  border-radius: 4px;
}

/* Projects grid */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.project-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease-in-out;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.project-card:hover {
  transform: translateY(-5px);
}

.project-card img {
  max-width: 100%;
  border-radius: 10px;
  margin-bottom: 1rem;
  object-fit: cover;
}

.project-card h3 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
  color: #2c3e50;
}

.project-card p {
  flex-grow: 1;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: #555;
}

.project-card a {
  align-self: flex-start;
  color: #3498db;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: border-color 0.3s ease;
}

.project-card a:hover {
  border-color: #3498db;
}

/* Content section for detailed pages */
.content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
  max-width: 1300px;
  margin: 0 auto 3rem auto;
}

.content h2 {
  color: #2c3e50;
  margin-bottom: 1rem;
  margin-top: 2rem;
  border-bottom: 2px solid #3498db;
  padding-bottom: 0.3rem;
}

.content p, 
.content ul, 
.content ol {
  margin-left: 1rem;
  margin-bottom: 1rem;
  color: #444;
  font-size: 1rem;
}

.content ul li,
.content ol li {
  margin-bottom: 0.6rem;
  line-height: 1.5;
}

.content a {
  color: #3498db;
  font-weight: 600;
  text-decoration: none;
}

.content a.btn {
  color: #fff;
  font-weight: bold;
}

.content a:hover {
  text-decoration: underline;
}

.diagram {
  display: block;
  max-width: 100%;
  margin: 2rem auto;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
}

/* Demo Walkthroughs */
.demo-block {
  text-align: center;
  margin-bottom: 3rem;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background-color: #19a6ec;
  color: rgb(243, 243, 245);
  text-decoration: none;
  cursor: pointer;
  font-weight: bold;
  border-radius: 6px;
  font-weight: 600;
  font-size: 1.1rem;
  transition: background-color 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn:hover {
  background-color: #217dbb;
}

/* CheerpJ Canvas */
.centered-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 800px; /* Or use viewport height: 100vh */
  background-color: #f1f3f1; 
  padding: 20px;
}

canvas {
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
}

/* Back-to-Top icon */
.back-to-top-wrapper {
  position: fixed;
  bottom: 30px;
  right: 30px;
  text-align: center;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

.back-to-top-wrapper.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top {
  background-color: #3498db;
  border-radius: 50%;
  padding: 0.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  text-decoration: none;
  margin: 0 auto;
  transition: background-color 0.3s ease;
}

.back-to-top:hover {
  background-color: #2980b9;
}

.back-to-top-text {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: #2c3e50;
  font-weight: 500;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Animate text only when wrapper is shown */
.back-to-top-wrapper.show .back-to-top-text {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 500px) {
  .back-to-top-text {
    display: none;
  }
}

/* Footer */
footer {
  width: 100vw;
  text-align: center;
  padding: 1.5rem 1rem;
  background-color: #8f8c8c;
  color: #f0f0f0;
  font-size: 0.9rem;
  border-top: 1px solid #444;
  margin-top: auto;
}

footer a {
  color: #3F48CC;
  text-decoration: none;
}

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

/* Responsive typography */
@media (max-width: 600px) {
  .hero h1 {
    font-size: 2rem;
  }

  nav ul {
    flex-direction: column;
    gap: 1rem;
  }
}
