/* Shared wide container style */
.container-wide {
  max-width: 1000px;
  padding: 0 2em;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
/* Custom Properties */
:root {
  --bg-color-light: #f2f3f0;
  --bg-color-dark: #071912;
  --text-color-light: #0f2a1f;
  --text-color-dark: #e6efe8;
  --accent-color: #014D2B;
  --card-bg-light: #ffffff;
  --card-bg-dark: #0f2b20;
  --link-color-light: #00331f;
  --link-color-dark: #1f6f44;
  --shadow: 0 6px 22px rgba(0,18,10,0.18);
  --border-radius: 1em;
  --transition-smooth: 300ms ease;
  --border-light: 1.5px solid #e0e0e0;
  --border-dark: 1.5px solid #2a4a3a;
}

/* Use border-box everywhere to make width/padding calculations predictable */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

/* Base Styles */
body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-color-light);
  color: var(--text-color-light);
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Theme Styles */
.dark-theme {
  background: var(--bg-color-dark);
  color: var(--text-color-dark);
}

/* Theme Toggle Button */
/* Theme Toggle */
.theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform var(--transition-smooth), opacity var(--transition-smooth);
  z-index: 1000;
  border-radius: 50%;
  overflow: hidden;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  transition: opacity var(--transition-smooth);
}

.theme-toggle .sun-icon {
  opacity: 0;
}

.theme-toggle .moon-icon {
  opacity: 1;
}

.dark-theme .theme-toggle .sun-icon {
  opacity: 1;
}

.dark-theme .theme-toggle .moon-icon {
  opacity: 0;
}

/* Header Styles */
header {
  margin-top: 3.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.title-content {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.name {
  font-size: 2.2em;
  font-weight: 700;
  margin: 0;
  color: var(--text-color-light);
}

.dark-theme .name {
  color: var(--text-color-dark);
}

.subtitle {
  font-size: 1.2em;
  font-weight: 400;
  color: var(--accent-color);
  margin: 0;
}

.location {
  font-size: 1em;
  color: #888;
  margin: 0;
}

/* Card Styles */

.main-card {
  background: var(--card-bg-light);
  box-shadow: var(--shadow);
  border-radius: var(--border-radius);
  border: var(--border-light);
  padding: 1em 1.5em;
  margin-bottom: .5em;
  width: 100%;
  max-width: 700px;
  transition: background-color var(--transition-smooth), border-color var(--transition-smooth), color var(--transition-smooth);
  margin-left: auto;
  margin-right: auto;
}

.bubble-card {
  background: var(--card-bg-light);
  box-shadow: var(--shadow);
  border-radius: var(--border-radius);
  border: var(--border-light);
  padding: 1em 1.5em;
  margin-bottom: 1.5em;
  transition: background-color var(--transition-smooth), border-color var(--transition-smooth), color var(--transition-smooth);
  text-align: center;
}

.contact-card {
  background: var(--card-bg-light);
  box-shadow: var(--shadow);
  border-radius: var(--border-radius);
  padding: 1.2em;
  margin: 1em auto;
  width: fit-content;
  min-width: 300px;
  transition: background var(--transition-smooth);
  border: var(--border-light);
}

.dark-theme .contact-card,
.dark-theme .bubble-card,
.dark-theme .main-card,
.dark-theme .card {
  background: var(--card-bg-dark);
  border-color: #393e46;
}

/* Link Styles */
.links {
  display: flex;
  justify-content: center;
  gap: 2em;
  margin: 0;
  flex-wrap: wrap;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 0.7em;
  text-decoration: none;
  color: var(--link-color-light);
  font-weight: 500;
  font-size: 1.15em;
  background: transparent;
  border-radius: 0.6em;
  padding: 0.5em 0.8em;
  transition: background 0.2s, color 0.2s;
}

.link-item:hover {
  background: var(--accent-color);
  color: #fff;
}

.dark-theme .link-item {
  color: var(--link-color-dark);
}

.dark-theme .link-item:hover {
  background: var(--accent-color);
  color: #fff;
}

.link-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: background 0.3s;
}

/* Footer Styles */
.footer {
  margin-top: auto;
  margin-bottom: 1.5em;
  color: #888;
  font-size: 0.97em;
  text-align: center;
}

/* Profile Styles */
/* Base (mobile-first) headshot size */
.headshot {
  width: 200px; /* small screens */
  height: auto;
  border-radius: 1em;
  box-shadow: var(--shadow);
  background: #fff;
  display: block;
  margin: 0;
}

.profile-flex {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 2.5em;
}

/* Snake Game Styles */
.snake-card {
  background: var(--card-bg-light);
  box-shadow: var(--shadow);
  border-radius: 1em;
  border: 2px solid #014D2B;
  padding: 2em 2.5em;
  margin: 2em auto 1em auto;
  width: 100%;
  max-width: 520px; /* slightly wider card on desktop for better padding */
  text-align: center;
  transition: background 0.3s, border-color 0.3s;
}

.dark-theme .snake-card {
  background: var(--card-bg-dark);
  border-color: var(--accent-color);
}

#snakeCanvas {
  display: block;
  margin: 0 auto;
  border-radius: 0.7em;
  border: 2px solid var(--accent-color);
  background: var(--card-bg-light);
  transition: background 0.3s, border-color 0.3s;
  max-width: 100%;
  height: auto;
}

.dark-theme #snakeCanvas {
  background: var(--card-bg-dark);
  border-color: var(--accent-color);
}

.snake-score {
  margin-top: 1em;
  font-size: 1.2em;
  color: var(--accent-color);
}

.snake-instructions {
  margin-top: 0.5em;
  color: var(--text-color-light);
  font-size: 0.95em;
}
.dark-theme .snake-instructions {
  color: var(--text-color-dark);
}

/* Play button */
.snake-play-btn {
  margin: 1em auto;
  padding: 0.6em 1.2em;
  font-size: 1.1em;
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 0.5em;
  cursor: pointer;
  transition: background 0.2s;
  display: block;
}

.snake-play-btn:hover {
  background: #015d34;
}

.snake-play-btn:disabled {
  background: #666;
  cursor: not-allowed;
}

/* Mobile Controls */
.mobile-controls {
  display: none;
  margin-top: 1em;
  user-select: none;
}

.arrow-row {
  display: flex;
  justify-content: center;
  gap: 0.5em;
  margin-bottom: 0.5em;
}

.arrow-row:last-child {
  margin-bottom: 0;
}

.arrow-btn {
  width: 65px;
  height: 65px;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 2.2em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.arrow-btn:hover {
  background: #015d34;
  transform: scale(1.05);
}

.arrow-btn:active {
  background: #01422a;
  transform: scale(0.95);
}

.dark-theme .arrow-btn {
  background: var(--accent-color);
}

.dark-theme .arrow-btn:hover {
  background: #1f6f44;
}

/* Show mobile controls on small screens */
@media (max-width: 768px) {
  .mobile-controls {
    display: block;
  }
  
  .snake-instructions {
    display: none;
  }
}

/* Small-screen layout: center headshot above content and keep toggle fixed */
@media (max-width: 480px) {
  .snake-section {
    display: flex;
    justify-content: center;
    width: 100vw;
    box-sizing: border-box;
  }

  .snake-card {
    margin: 1em;
    width: calc(100% - 2em);
    max-width: 450px;
    padding: 1.5em 1em;
    box-sizing: border-box;
  }
  
  #snakeCanvas {
    width: 100%;
    height: auto;
    max-width: calc(100vw - 6em);
    max-height: calc(100vw - 6em);
  }

  .profile-flex {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    padding: 0 1rem;
    position: relative;
  }

  .headshot {
    width: 200px;
    float: none;
    margin: 0 auto 1rem auto;
    border-radius: 1em;
    transform: none;
    display: block;
    box-shadow: var(--shadow);
  }

  .main-card {
    margin-left: 0;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
    padding: 1rem;
  }

  .main-card p { overflow-wrap: anywhere; }

  .profile-flex::after { content: ''; display: block; clear: both; }

  /* Make contact card / links fit the device width and stack nicely */
  .contact-card { width: calc(100% - 2rem); min-width: 0; margin: 0.8rem auto; box-sizing: border-box; padding: 0.9rem 1rem; }
  .links { flex-direction: column; gap: 0.75rem; align-items: stretch; }
  .link-item { justify-content: flex-start; width: 100%; padding: 0.65em 0.9em; border-radius: 0.6rem; }
  .link-icon { width: 36px; height: 36px; }

  /* Prevent the snake card and canvas from causing horizontal overflow on small screens */
  .snake-card { width: calc(100% - 2rem); max-width: none; box-sizing: border-box; margin: 1.25rem auto; padding: 1.25rem; }
  #snakeCanvas { width: 100%; height: auto; max-width: 400px; display: block; }
}

/* Desktop and larger: float headshot left and let text wrap */
/* Medium screens: slightly larger headshot and floated */
@media (min-width: 481px) and (max-width: 991px) {
  .profile-flex { display: block; }
  .headshot {
    width: 220px; /* medium screens */
    float: left;
    margin: 0 1rem 0.75rem 0;
    border-radius: 0.75rem;
    transform: translateX(-12px);
    z-index: 2;
    box-shadow: var(--shadow);
  }
  .main-card { padding-left: calc(1em + 220px - 12px); }
}

/* Large screens: smaller headshot to fit the layout */
@media (min-width: 992px) {
  .profile-flex {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 3rem; /* spacing between headshot and content */
    padding: 0 2em;
  }
  .headshot {
    width: 260px; /* large screens */
    float: none;
    margin: 0; /* spacing handled by flex gap */
    border-radius: 0.75rem;
    transform: none;
  }
  .main-card {
    padding-left: 2.5em; /* restore standard inner padding */
  }
}

/* Responsive Styles */
@media (max-width: 768px) {
  .profile-flex {
    flex-direction: column;
    align-items: center;
    gap: 1.5em;
    padding: 0 1em;
  }
  /* headshot width handled by base or medium breakpoint; no override here */
}