/* =========================
   Color Theme Variables
========================= */
:root {
  --bg: #fff;         /* Light background */
  --text: #000;       /* Dark text */
  --border: #ccc;     /* Light border */
  --text-muted: #555; /* Muted text for subtle elements */
}

body.dark {
  --bg: #000;         /* Dark background */
  --text: #fff;       /* Light text */
  --border: #444;     /* Dark border */
  --text-muted: #aaa; /* Muted text for dark mode */
}

/* =========================
   Base Styles & Transitions
========================= */
* {
  box-sizing: border-box;
  transition: background 0.4s, color 0.4s, border-color 0.4s, transform 0.3s ease;
}

body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* =========================
   Header + Navigation
========================= */
header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav a {
  margin-right: 1rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
}

nav a:hover,
nav a:focus {
  text-decoration: underline;
}

#mode-toggle {
  font-size: 1.2rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 0.25rem;
  line-height: 1;
}

.lang-switch {
  display: inline-block;
  margin-left: 1rem;
}

.lang-switch button {
  background: none;
  border: none;
  color: inherit;
  font-weight: bold;
  cursor: pointer;
  padding: 0 0.5rem;
}

.lang-switch button.active {
  text-decoration: underline;
}

/* Base container for header */
.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 0;
}

/* Logo */
.logo {
  font-weight: 700;
  font-size: 1.5rem;
  flex-shrink: 0;
}

/* Navigation links */
.main-nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  flex-grow: 1;
  justify-content: center;
}

.main-nav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

/* Controls: dark mode toggle + language switch */
.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

#mode-toggle {
  font-size: 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

.lang-switch button {
  background: none;
  border: 1px solid var(--text);
  color: var(--text);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-weight: 600;
  border-radius: 3px;
  user-select: none;
}

.lang-switch button.active {
  background: var(--text);
  color: var(--bg);
}

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
  .header-container {
    justify-content: center;
  }
  
  .main-nav {
    flex-basis: 100%;
    justify-content: center;
    margin-bottom: 0.5rem;
  }
  
  .header-controls {
    justify-content: center;
    gap: 0.5rem;
  }
}


/* =========================
   Hero Section
========================= */
.hero {
  text-align: center;
  padding: 3rem 2rem 2rem; /* less bottom padding to reduce space */
  max-width: 700px;
  margin: 0 auto;
}

.hero-image {
  margin-top: 1.5rem;
  text-align: center;
}

.hero-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.hero-image img {
  max-width: 350px;
  border-radius: 75%;
  object-fit: cover;
}

/* =========================
   Game Section
========================= */
#game-selector-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 2rem 0;
  user-select: none;
  text-align: center;
}

#game-selector-buttons button {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
  flex: 1 1 120px;
  max-width: 160px;
}

#game-selector-buttons button.active,
#game-selector-buttons button:hover,
#game-selector-buttons button:focus {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  outline: none;
}

.game-container {
  margin-bottom: 3rem;
  display: none;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
  max-width: 100%;
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  user-select: none;
  padding: 0 1rem;
  box-sizing: border-box;
}

.game-container.active {
  display: block;
}

canvas {
  width: 100%;
  height: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
  cursor: none;
  transition: background 0.3s, border-color 0.3s;
  border-radius: 4px;
}

#start-aste,
#start-dino,
#start-flappy {
  margin-top: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.3s, color 0.3s;
}

#start-aste:hover,
#start-dino:hover,
#start-flappy:hover,
#start-aste:focus,
#start-dino:focus,
#start-flappy:focus {
  opacity: 0.85;
  outline: none;
}

#score,
#dino-score,
#flappy-score {
  margin-left: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* =========================
   Responsive Tweak
========================= */
@media (max-width: 480px) {
  #game-selector-buttons button {
    font-size: 0.95rem;
    padding: 0.5rem;
    max-width: 100%;
  }

  canvas {
    width: 100% !important;
    height: auto !important;
  }

  .game-container {
    padding: 0 0.5rem;
  }
}

/* =========================
   About Section (Skills Bars Compact)
========================= */
.skills {
  margin-top: 2rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem 2rem;
}

.skill {
  margin-bottom: 0;
}

.skill span {
  display: inline-block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
  font-size: 0.9rem;
}

.bar {
  background: var(--border);
  border-radius: 5px;
  height: 12px;
  width: 100%;
  overflow: hidden;
}

.fill {
  background: var(--text);
  height: 100%;
  border-radius: 5px 0 0 5px;
  width: 0; /* animated with JS */
  transition: width 3s ease;
}

.skills.animated .fill {
  /* width set inline */
}

/* Responsive fallback: single column on smaller screens */
@media (max-width: 500px) {
  .skills {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Shared Section Styling
========================= */
.section {
  padding: 3rem 2rem;
  max-width: 800px;
  max-height: auto;
  margin: 0 auto;
}

/* =========================
   Portfolio Grid Layout
========================= */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.portfolio-grid .item {
  border: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0s ease;
  text-align: center;
  user-select: none;
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
}

.portfolio-grid .item:hover,
.portfolio-grid .item:focus {
  border-color: var(--text);
  transform: scale(1.05);
  outline: none;
}

.portfolio-grid .item h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.portfolio-grid .item p {
  margin: 0;
  color: var(--text);
  opacity: 0.8;
}

/* =========================
   Tags under portfolio items
========================= */
.portfolio-grid .tags {
  display: block;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.3s ease, max-height 0.3s ease;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  transform: translateY(5px);
  transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease;
}

.portfolio-grid .item:hover .tags,
.portfolio-grid .item:focus .tags {
  opacity: 1;
  max-height: 50px; /* enough height for tags */
  transform: translateY(0);
}

/* =========================
   Modal Styling
========================= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg);
  color: var(--text);
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
  padding: 1.5rem;
  border-radius: 6px;
  box-shadow: 0 0 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
}

#modal-close {
  align-self: flex-end;
  font-size: 2rem;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  margin-bottom: 1rem;
  line-height: 1;
}

#modal-body h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

#modal-body iframe {
  flex-grow: 1;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 400px;
  max-height: 600px;
  overflow: auto;
}

#modal-body p {
  margin: 1rem 0;
  line-height: 1.5;
}

#modal-body a {
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
  align-self: flex-start;
}

/* =========================
   Responsive Portfolio Grid
========================= */
@media (max-width: 900px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Contact Form Styling
========================= */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
}

label {
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  color: var(--text);
}

input,
textarea {
  padding: 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border 0.2s;
  border-radius: 3px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--text);
}

button[type="submit"] {
  background: var(--text);
  color: var(--bg);
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  align-self: start;
  transition: opacity 0.2s ease;
  border-radius: 3px;
}

button[type="submit"]:hover,
button[type="submit"]:focus {
  opacity: 0.85;
  outline: none;
}

.alt-contact {
  margin-top: 2rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}

/* =========================
   Footer
========================= */
footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}