/* Theme variables */
:root {
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --nav-bg: #1f1f1f;
  --border-color: #333;
  --hover-color: #00ffff;
  
  /* 添加淡入淡出效果 */
  --transition-speed: 0.5s;
  --transition-timing: ease;
  
  /* 新增響應式變數 */
  --mobile-padding: 1rem;
  --desktop-padding: 2rem;
  --touch-target-size: 44px;
}

/* Light theme */
[data-theme='light'] {
  --bg-color: #ffffff;
  --text-color: #333333;
  --nav-bg: #f5f5f5;
  --border-color: #dddddd;
  --hover-color: #0066cc;
}

/* Base styles */
* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Courier New', monospace;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  line-height: 1.6;
  
  /* 添加淡入淡出效果 */
  transition: background-color var(--transition-speed) var(--transition-timing),
              color var(--transition-speed) var(--transition-timing);
  
  /* 改善文字渲染 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 改善觸控滾動 */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Navigation - 大幅改善手機版導航 */
.nav-toggle {
  display: none;
  background: none;
  border: 2px solid var(--text-color);
  color: var(--text-color);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.75rem;
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 1001;
  border-radius: 8px;
  min-width: var(--touch-target-size);
  min-height: var(--touch-target-size);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  background-color: rgba(31, 31, 31, 0.9);
}

.nav-toggle:hover {
  color: var(--hover-color);
  border-color: var(--hover-color);
  transform: scale(1.05);
}

.nav-toggle:active {
  transform: scale(0.95);
}

nav {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  position: relative;
  
  /* 添加淡入淡出效果 */
  transition: background-color var(--transition-speed) var(--transition-timing),
              border-color var(--transition-speed) var(--transition-timing);
}

.theme-toggle {
  background: none;
  border: 2px solid var(--border-color);
  color: var(--text-color);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.5rem;
  position: fixed;
  right: 1rem;
  top: 1rem;
  z-index: 1001;
  transition: all 0.3s ease;
  border-radius: 8px;
  min-width: var(--touch-target-size);
  min-height: var(--touch-target-size);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  background-color: rgba(31, 31, 31, 0.9);
}

.theme-toggle:hover {
  color: var(--hover-color);
  border-color: var(--hover-color);
  transform: scale(1.05);
}

nav a {
  color: var(--text-color);
  text-decoration: none;
  transition: all 0.3s ease;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  min-height: var(--touch-target-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

nav a:hover {
  color: var(--hover-color);
  background-color: rgba(0, 255, 255, 0.1);
  transform: translateY(-2px);
}

/* Controls */
.top-controls {
  position: fixed;
  top: 1rem;
  right: 5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 1000;
}

.top-controls button {
  background: rgba(31, 31, 31, 0.9);
  border: 2px solid var(--border-color);
  color: var(--text-color);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 8px;
  min-width: var(--touch-target-size);
  min-height: var(--touch-target-size);
  backdrop-filter: blur(10px);
}

.top-controls button:hover {
  color: var(--hover-color);
  border-color: var(--hover-color);
  transform: scale(1.05);
}

/* Main content */
main {
  padding: var(--desktop-padding);
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  text-align: center;
  flex: 1;
}

h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  margin-bottom: 1.5rem;
  margin-top: 1.5rem;
  text-align: center;
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  margin-bottom: 1rem;
  margin-top: 2rem;
  line-height: 1.3;
}

/* Paragraphs in main content */
main p {
  text-align: center;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

/* 改善手機版響應式設計 */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(31, 31, 31, 0.98);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    z-index: 1000;
    backdrop-filter: blur(20px);
    animation: slideIn 0.3s ease-out;
  }

  nav.active {
    display: flex;
  }
  
  nav a {
    font-size: 1.2rem;
    padding: 1rem 2rem;
    width: 80%;
    max-width: 300px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.05);
  }

  main {
    padding: var(--mobile-padding);
    padding-top: 5rem;
  }
  
  h1 {
    margin-top: 0;
  }

  /* Add space for pages with navigation */
  body:not(.home-page) main {
    margin-top: 1rem;
  }

  .top-controls {
    right: 1rem;
    top: 5.5rem;
  }
}

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

/* 超小螢幕優化 */
@media (max-width: 480px) {
  :root {
    --mobile-padding: 0.75rem;
  }

  .nav-toggle,
  .theme-toggle {
    padding: 0.5rem;
    font-size: 1rem;
  }

  .top-controls {
    top: 4.5rem;
    gap: 0.25rem;
  }

  .top-controls button {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
  }

  nav a {
    font-size: 1.1rem;
    padding: 0.875rem 1.5rem;
  }

  main {
    padding-top: 4rem;
  }
}

/* Portfolio Styles - 改善響應式 */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.portfolio-item {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  background-color: rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
}

.portfolio-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
  border-color: var(--hover-color);
}

.portfolio-image {
  width: 100%;
  height: 200px;
  min-height: 200px;
  max-height: 200px;
  overflow: hidden;
  position: relative;
}

.portfolio-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.portfolio-item:hover .portfolio-image img {
  transform: scale(1.1);
}

.portfolio-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.portfolio-content h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: var(--text-color);
  height: auto;
  min-height: 2.5em;
  display: flex;
  align-items: center;
  overflow: hidden;
  line-height: 1.3;
}

.portfolio-content p {
  color: var(--text-color);
  opacity: 0.8;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  margin-bottom: 1rem;
  text-align: left !important;
  line-height: 1.6;
}

.portfolio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.portfolio-tags span {
  background-color: rgba(0, 255, 255, 0.15);
  color: var(--hover-color);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: clamp(0.7rem, 1.8vw, 0.8rem);
  font-weight: 500;
}

.portfolio-links {
  display: flex;
  gap: 1rem;
  margin-top: auto;
}

.portfolio-links .btn {
  padding: 0.75rem 1.25rem;
  background-color: transparent;
  border: 2px solid var(--hover-color);
  color: var(--hover-color);
  border-radius: 8px;
  text-decoration: none;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  transition: all 0.3s ease;
  min-height: var(--touch-target-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

.portfolio-links .btn:hover {
  background-color: var(--hover-color);
  color: var(--bg-color);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 255, 255, 0.3);
}

/* Responsive portfolio styles */
@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .portfolio-item {
    max-width: 100%;
  }

  .portfolio-links {
    flex-direction: column;
    gap: 0.75rem;
  }

  .portfolio-links .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .portfolio-grid {
    gap: 1rem;
  }

  .portfolio-content {
    padding: 1rem;
  }

  .portfolio-image {
    height: 180px;
    min-height: 180px;
    max-height: 180px;
  }
}

/* About page styles - 大幅改善響應式 */
.about-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  max-width: 900px;
  margin: 0 auto 2rem auto;
  flex-wrap: wrap;
}

.about-photo img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
  border: 4px solid var(--text-color);
  background: #fff;
  transition: all 0.3s ease;
}

.about-photo img:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 35px rgba(0,0,0,0.3);
}

.about-text {
  flex: 1 1 300px;
  min-width: 280px;
  text-align: left;
}

.about-text p {
  margin-bottom: 0 !important;
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  line-height: 1.7;
}

/* Skills section - 改善響應式 */
.skills-section {
  margin: 0 auto 2rem auto;
  max-width: 900px;
  text-align: center;
  padding: 0 var(--mobile-padding);
}

.skills-section h2 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: #0077b6;
  margin-bottom: 0.5rem;
  letter-spacing: 1.5px;
  margin-top: 0;
}

.skills-desc {
  color: var(--text-color);
  opacity: 0.8;
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.skills-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0 auto;
}

.skills-list li {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  color: var(--text-color);
  background: rgba(0, 174, 255, 0.1);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  text-align: center;
  min-height: 80px;
  border: 2px solid transparent;
} 

.skills-list li i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #0099cc;
  transition: all 0.3s ease;
}

.skills-list li:hover {
  background: rgba(0, 174, 255, 0.2);
  transform: translateY(-5px);
  border-color: #0099cc;
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.skills-list li:hover i {
  transform: scale(1.2);
  color: var(--hover-color);
}

/* Life section - 改善響應式 */
.life-section {
  margin: 2rem auto;
  max-width: 900px;
  text-align: center;
  padding: 0 var(--mobile-padding);
}

.life-section h2 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  margin-bottom: 0.5rem;
  color: #0099cc;
  letter-spacing: 2px;
}

.life-desc {
  color: var(--text-color);
  opacity: 0.8;
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.life-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  justify-content: center;
}

.life-photos img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
  border: 3px solid transparent;
}

.life-photos img:hover {
  transform: scale(1.05) rotate(-1deg);
  box-shadow: 0 15px 40px rgba(0,0,0,0.25);
  border-color: var(--hover-color);
}

/* Favorite section - 改善響應式 */
.favorite-section {
  position: relative;
  margin: 2rem auto;
  max-width: 900px;
  text-align: center;
  z-index: 1;
  overflow: visible;
  padding: 0 var(--mobile-padding);
}

.favorite-section h2 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: #e75480;
  margin-bottom: 0.5rem;
  letter-spacing: 2px;
  position: relative;
  z-index: 2;
}

.favorite-desc {
  color: var(--text-color);
  opacity: 0.8;
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 2;
  line-height: 1.6;
}

.favorite-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.5rem;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.favorite-photos img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  border: 3px solid #fff0f5;
  background: #fff;
  transition: all 0.3s ease;
}

.favorite-photos img:hover {
  transform: scale(1.08) rotate(-2deg);
  box-shadow: 0 15px 40px rgba(0,0,0,0.25);
  border-color: #e75480;
}

.floating-flowers {
  pointer-events: none;
  position: absolute;
  left: 0; 
  top: 0; 
  width: 100%; 
  height: 100%;
  z-index: 1;
  overflow: visible;
}

.flower {
  position: absolute;
  top: -40px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  opacity: 0.7;
  filter: blur(1px);
  animation: flower-float linear forwards;
  box-shadow: 0 2px 8px rgba(255,182,193,0.18);
}

@keyframes flower-float {
  0% { 
    transform: translateY(0) scale(1) rotate(0deg); 
  }
  100% { 
    transform: translateY(420px) scale(1.2) rotate(360deg); 
    opacity: 0.2; 
  }
}

/* 手機版響應式優化 */
@media (max-width: 768px) {
  .about-container {
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
  }
  
  .about-text {
    text-align: center;
  }

  .skills-list {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
  }

  .skills-list li {
    padding: 0.75rem;
    min-height: 70px;
  }

  .life-photos {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .life-photos img {
    height: 250px;
  }

  .favorite-photos {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
  }

  .favorite-photos img {
    height: 120px;
  }
}

@media (max-width: 480px) {
  .about-photo img {
    width: 100px;
    height: 100px;
  }

  .skills-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .skills-list li {
    padding: 0.5rem;
    min-height: 60px;
  }

  .skills-list li i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
  }

  .life-photos img {
    height: 200px;
  }

  .favorite-photos {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .favorite-photos img {
    height: 100px;
  }
}

/* Footer Styles */
.site-footer {
  font-size: clamp(0.7rem, 1.8vw, 0.8rem);
  color: #888;
  text-align: center;
  width: 100%;
  padding: 20px var(--mobile-padding);
  margin-top: 40px;
  border-top: 1px solid var(--border-color);
  background-color: rgba(31, 31, 31, 0.5);
}

/* Special styles for homepage footer */
.home-page .site-footer {
  position: relative;
  margin-top: 20px;
}

/* Page specific styles */
.contact-page main,
.about-page main {
  margin-top: 1.2rem;
  padding-top: 0;
}

.about-page h1 {
  margin-top: 0.5rem;
  margin-bottom: 1.2rem;
}

.about-page main,
.portfolio-page main,
.spotify-page main {
  margin: 0 auto;
  padding-left: var(--mobile-padding);
  padding-right: var(--mobile-padding);
  text-align: center;
}

/* Contact page specific styles */
.contact-page main p {
  text-align: center;
  margin-left: 0;
}

/* Ensure main content has enough height to push footer down */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* 改善首頁樣式 */
.home-page body {
  padding: var(--mobile-padding);
}

.content-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
  width: 100%;
  min-height: 80vh;
}

.typewriter {
  font-size: clamp(1.2rem, 4vw, 2rem);
  border-right: 2px solid #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  width: 0;
  animation: typing 4s steps(40, end) forwards, blink 1s step-end infinite;
  max-width: 90vw;
  text-align: center;
}

@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

@keyframes blink {
  0%, 100% { border-color: transparent }
  50% { border-color: #e0e0e0 }
}

.enter {
  opacity: 0;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  margin-top: 3rem;
  animation: fadeIn 2s 4s forwards;
  text-align: center;
  width: 100%;
  display: flex;
  justify-content: center;
  cursor: pointer;
  background: none;
  border: 2px solid #e0e0e0;
  color: #e0e0e0;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  min-height: var(--touch-target-size);
  align-items: center;
}

.enter:hover {
  background: rgba(224, 224, 224, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(224, 224, 224, 0.2);
}

.social-icons {
  display: flex;
  gap: 1.5rem;
  margin-top: 30px;
  opacity: 0;
  animation: fadeIn 2s 3.5s forwards;
  justify-content: center;
  flex-wrap: wrap;
}

.social-icons a {
  color: #e0e0e0;
  font-size: 1.5rem;
  transition: all 0.3s ease;
  padding: 0.5rem;
  border-radius: 50%;
  min-width: var(--touch-target-size);
  min-height: var(--touch-target-size);
  display: flex;
  align-items: center;
  justify-content: center;
}

.social-icons a:hover {
  color: #00ffff;
  background-color: rgba(0, 255, 255, 0.1);
  transform: translateY(-3px) scale(1.1);
}

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

.ip-address {
  margin-top: 15px;
  font-size: clamp(0.7rem, 1.8vw, 0.85rem);
  color: #aaa;
  text-align: center;
  opacity: 0;
  animation: fadeIn 2s 5s forwards;
  line-height: 1.5;
}

/* 手機版首頁優化 */
@media (max-width: 768px) {
  .social-icons {
    gap: 1rem;
    margin-top: 20px;
  }
  
  .enter {
    margin-top: 2rem;
    padding: 0.75rem 1.25rem;
  }
}

@media (max-width: 480px) {
  .social-icons {
    gap: 0.75rem;
  }
  
  .social-icons a {
    font-size: 1.2rem;
  }
  
  .enter {
    margin-top: 1.5rem;
    padding: 0.625rem 1rem;
  }
}

/* 改善按鈕和連結的觸控體驗 */
button, a, .btn {
  -webkit-tap-highlight-color: rgba(0, 255, 255, 0.3);
  touch-action: manipulation;
}

/* 改善表單元素 */
input, textarea, select {
  font-size: 16px; /* 防止iOS縮放 */
  padding: 0.75rem;
  border-radius: 8px;
  border: 2px solid var(--border-color);
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: all 0.3s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--hover-color);
  box-shadow: 0 0 0 3px rgba(0, 255, 255, 0.1);
}

/* 改善可訪問性 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 改善對比度 */
@media (prefers-contrast: high) {
  :root {
    --border-color: #666;
    --hover-color: #ffffff;
  }
}

/* 暗色模式改善 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0a0a0a;
    --text-color: #f0f0f0;
    --nav-bg: #1a1a1a;
  }
}

