/* Base Styles */
:root {
  --primary-color: #79589F; /* Heroku purple */
  --primary-light: #9E7CC1; /* Lighter purple */
  --primary-dark: #4A3171; /* Darker purple */
  --secondary-color: #3F1D6C; /* Deep purple */
  --accent-color: #FD9A69; /* Heroku orange accent */
  --text-color: #333;
  --light-text: #fff;
  --light-gray: #f5f5f5;
  --medium-gray: #ddd;
  --dark-gray: #666;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, Times, serif;
  --max-width: 1200px;
  --gradient-bg: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

html, body {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--text-color);
  background-color: #fff;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

footer {
  flex-shrink: 0;
}

a {
  color: var(--primary-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  color: var(--primary-light);
}

h1, h2, h3, h4, h5, h6 {
  margin-bottom: 1rem;
  line-height: 1.2;
}

p, ul, ol {
  margin-bottom: 1.5rem;
}

/* Layout */
header, main, footer {
  padding: 1rem;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Navigation */
nav ul {
  display: flex;
  list-style: none;
  gap: 1.5rem;
}

nav a {
  font-weight: 600;
}

/* Header */
header {
  background: var(--gradient-bg);
  color: var(--light-text);
  padding: 0.5rem 2rem;
  line-height: 1;
}

header a {
  color: var(--light-text);
}

/* Footer */
footer {
  background: var(--gradient-bg);
  color: var(--light-text);
  text-align: right;
  padding: 0.75rem 2rem;
  margin-top: 2rem;
  font-size: 0.9rem;
  line-height: 1;
}

footer p {
  margin-bottom: 0;
}

/* Home Page */
.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
  background: var(--gradient-bg);
  color: var(--light-text);
  margin-bottom: 2rem;
  border-radius: 5px;
  position: relative;
  overflow: hidden;
}

.hero .profile-container {
  position: relative;
  z-index: 2;
}

/* Profile Section */
.profile-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 0;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1rem;
}

.profile-image {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.profile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-content {
  text-align: center;
  width: 100%;
}

.profile-content h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--light-text);
}

.bio {
  font-size: 1.1rem;
  max-width: 100%;
  margin: 0 auto 1rem;
  color: var(--light-text);
  opacity: 0.9;
  white-space: normal;
  overflow: visible;
  line-height: 1.5;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
}

.social-links a {
  color: var(--light-text);
  transition: color 0.2s ease, transform 0.2s ease;
}

.social-links a:hover {
  color: var(--accent-color);
  transform: translateY(-3px);
}

.social-links svg {
  width: 28px;
  height: 28px;
}

@media (min-width: 768px) {
  .profile-container {
    flex-direction: row;
    text-align: left;
    align-items: flex-start;
  }
  
  .profile-content {
    text-align: left;
    padding-left: 2rem;
  }
  
  .bio {
    margin-left: 0;
  }
  
  .social-links {
    justify-content: flex-start;
  }
}

.featured {
  display: flex;
  flex-wrap: nowrap;
  gap: 2rem;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

.card {
  flex: 1;
  border: 1px solid var(--medium-gray);
  border-radius: 5px;
  padding: 1.5rem;
  background-color: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-width: 0; /* Allows cards to shrink below their content size */
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.card h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.card p {
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.button {
  display: inline-block;
  background: var(--gradient-bg);
  color: white;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  margin-top: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-weight: 600;
}

.button:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Blog */
.blog-list {
  display: grid;
  gap: 2rem;
}

.post-preview {
  border-bottom: 1px solid var(--medium-gray);
  padding-bottom: 2rem;
}

.post-preview:last-child {
  border-bottom: none;
}

.post-preview time {
  color: var(--dark-gray);
  font-size: 0.9rem;
  display: block;
  margin-bottom: 0.5rem;
}

.read-more {
  font-weight: 600;
  color: var(--primary-color);
}

.read-more:hover {
  color: var(--primary-light);
}

/* Post */
.post header {
  background-color: transparent;
  background-image: none;
  color: var(--text-color);
  border-bottom: 1px solid var(--medium-gray);
  margin-bottom: 2rem;
  padding: 0 0 1rem 0;
}

.post time {
  color: var(--dark-gray);
  font-size: 0.9rem;
  display: block;
  margin-bottom: 1rem;
}

.post-content h1, 
.post-content h2, 
.post-content h3 {
  margin-top: 2rem;
  color: var(--primary-dark);
}

.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  border-radius: 5px;
}

.post-content pre {
  background-color: var(--light-gray);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.post-content code {
  font-family: monospace;
  background-color: var(--light-gray);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}

.post-content pre code {
  background-color: transparent;
  padding: 0;
}

.tags {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tags li {
  background-color: var(--light-gray);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-size: 0.8rem;
  transition: background-color 0.2s ease;
}

.tags li:hover {
  background-color: var(--primary-light);
}

.tags li a {
  color: var(--text-color);
}

.tags li:hover a {
  color: white;
  text-decoration: none;
}

/* Tags */
.tags-list {
  list-style: none;
  margin: 2rem 0;
}

.tags-list li {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.tags-list li:hover {
  transform: translateX(5px);
}

.tag-count {
  color: var(--dark-gray);
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

/* CV */
.cv section {
  margin-bottom: 2rem;
}

.cv h2 {
  color: var(--primary-dark);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 0.5rem;
  margin-top: 2rem;
}

.cv h3 {
  color: var(--primary-color);
}

/* Algorithm Cheatsheet Styles */
.algorithms-header {
  text-align: center;
  margin: 2rem 0;
  padding: 2rem;
  background: var(--gradient-bg);
  color: var(--light-text);
  border-radius: 8px;
}

.algorithms-header h1 {
  margin-top: 0;
  font-size: 2.5rem;
}

.algorithms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.algorithm-card {
  background-color: var(--light-gray);
  border-radius: 8px;
  padding: 1.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  text-decoration: none;
  color: var(--text-color);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-left: 4px solid var(--primary-color);
}

.algorithm-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

.algorithm-card h2 {
  margin-top: 0;
  color: var(--primary-color);
  font-size: 1.5rem;
}

.algorithm-card p {
  margin-bottom: 0;
  flex-grow: 1;
  color: var(--dark-gray);
  font-size: 0.95rem;
}

/* Algorithm Page Styles */
.algorithm-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

.algorithm-header {
  text-align: center;
  margin: 2rem 0;
  padding: 2rem;
  background: var(--gradient-bg);
  color: var(--light-text);
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.algorithm-header h1 {
  margin-top: 0;
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.algorithm-description {
  font-size: 1.2rem;
  margin-bottom: 0;
  opacity: 0.9;
}

.algorithm-content {
  background-color: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  margin-bottom: 2rem;
}

.algorithm-content h2 {
  color: var(--primary-color);
  font-size: 1.8rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--light-gray);
}

.algorithm-content h3 {
  color: var(--primary-dark);
  font-size: 1.4rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.algorithm-content ul, .algorithm-content ol {
  padding-left: 1.5rem;
}

.algorithm-content li {
  margin-bottom: 0.5rem;
}

.algorithm-content pre {
  background-color: var(--light-gray);
  padding: 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-left: 4px solid var(--primary-color);
}

.algorithm-content code {
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.9rem;
}

.algorithm-content p code {
  background-color: var(--light-gray);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.algorithm-navigation {
  margin: 3rem 0;
}

.algorithm-nav-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.algorithm-nav-previous, .algorithm-nav-next {
  flex: 1;
}

.algorithm-nav-index {
  text-align: center;
  margin: 0 1rem;
}

.algorithm-index-link {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  border-radius: 4px;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

.algorithm-index-link:hover {
  background-color: var(--primary-dark);
  text-decoration: none;
  color: white;
}

.algorithm-nav-link {
  display: block;
  padding: 1rem;
  background-color: var(--light-gray);
  border-radius: 6px;
  transition: transform 0.3s ease, background-color 0.3s ease;
  text-decoration: none;
  color: var(--text-color);
}

.algorithm-nav-link:hover {
  transform: translateY(-3px);
  background-color: #fff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  text-decoration: none;
}

.algorithm-nav-direction {
  display: block;
  font-size: 0.8rem;
  color: var(--dark-gray);
  margin-bottom: 0.25rem;
}

.algorithm-nav-title {
  display: block;
  font-weight: bold;
  color: var(--primary-color);
}

.algorithm-nav-previous {
  text-align: left;
}

.algorithm-nav-next {
  text-align: right;
}

/* Animation Styles */
@keyframes float {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.8;
  }
  50% {
    transform: translateY(-20px) rotate(180deg);
    opacity: 0.4;
  }
  100% {
    transform: translateY(0) rotate(360deg);
    opacity: 0.8;
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-15px);
  }
  60% {
    transform: translateY(-7px);
  }
}

.floating-element {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.6;
  z-index: 1;
  animation: float 10s infinite ease-in-out;
  filter: blur(1px);
}

.floating-element.square {
  border-radius: 0;
}

.floating-element.triangle {
  width: 0 !important;
  height: 0 !important;
  background-color: transparent !important;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-bottom: 25px solid;
  border-bottom-color: inherit;
}

.floating-element.diamond {
  transform: rotate(45deg);
}

.typing {
  border-right: 2px solid white;
  white-space: normal;
  overflow: visible;
  animation: blink-caret 0.75s step-end infinite;
}

.typing-done {
  border-right: none;
}

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: white }
}

.bounce {
  animation: bounce 1s;
}

/* Responsive adjustments for animations */
@media (max-width: 768px) {
  .floating-element {
    opacity: 0.3;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .featured {
    flex-direction: column;
  }
  
  nav ul {
    flex-direction: column;
    gap: 0.5rem;
  }
}
