:root {
  /* Winter Palette */
  --winter-ice: #B8E3E9;
  --winter-mist: #93B1B5;
  --winter-teal: #4F7C82;
  --winter-deep: #0B2E33;

  --bg-color: #FDFBF7;        
  --bg-secondary: #FFFFFF;   
  
  --primary-color: var(--winter-deep);
  --accent-main: var(--winter-teal);
  
  --text-color: var(--winter-deep);
  --text-secondary: #546e7a;
  
  --border-color: #E8E8E0;
  --shadow: 0 8px 24px rgba(11, 46, 51, 0.08);
  
  --nav-height: 70px;
}

:root.dark-theme {
  --bg-color: #061A1D;
  --bg-secondary: #0B2E33;
  --text-color: #E0F7FA;
  --text-secondary: #93B1B5;
  --border-color: #1C454A;
  --primary-color: var(--winter-ice);
  --shadow: 0 8px 24px rgba(0,0,0,0.4);
}

::selection {
  background: var(--winter-teal);
  color: var(--bg-secondary);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { 
  scroll-behavior: smooth; 
  scroll-padding-top: var(--nav-height); 
  will-change: scroll-position;
  transition: background-color 0.5s ease, color 0.5s ease;
}

body { 
  font-family: 'Inter', sans-serif; 
  background: var(--bg-color); 
  color: var(--text-color); 
  overflow-x: hidden; 
  transition: background-color 0.5s ease, color 0.5s ease; 
  line-height: 1.6;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-color); transition: background-color 0.5s ease; }
::-webkit-scrollbar-thumb { 
  background: var(--winter-mist); 
  border-radius: 5px; 
  border: 2px solid var(--bg-color);
  transition: background-color 0.5s ease, border-color 0.5s ease;
}
::-webkit-scrollbar-thumb:hover { background: var(--winter-teal); }

/* Japanese Font Stabilization */
html[lang="ja"] body {
  font-size: 0.95em;
  letter-spacing: 0.02em;
}

/* Typography */
h1, h2, h3, .nav-brand { font-family: 'Playfair Display', serif; }

/* Navigation */
.navbar { 
  position: fixed; top: 0; width: 100%; height: var(--nav-height); 
  background: rgba(253, 251, 247, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000; 
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  display: flex; align-items: center; justify-content: center; 
  transition: background-color 0.5s ease, box-shadow 0.5s ease;
}

:root.dark-theme .navbar {
  background: rgba(6, 26, 29, 0.85);
}

.navbar nav { 
  width: 100%; max-width: 1200px; 
  display: flex; justify-content: space-between; padding: 0 20px; align-items: center; 
}
.nav-brand { font-weight: 700; font-size: 1.5rem; color: var(--accent-main); transition: color 0.5s ease; }

.nav-links-container ul { list-style: none; display: flex; gap: 2rem; }
.nav-link { text-decoration: none; color: var(--text-color); font-weight: 500; transition: color 0.5s ease; font-size: 0.95rem; }
.nav-link:hover { color: var(--accent-main); }

.nav-controls { display: flex; gap: 10px; }

button { 
  cursor: pointer; background: transparent; 
  border: 1px solid var(--border-color); 
  color: var(--text-color); 
  padding: 8px 12px; border-radius: 50px; 
  transition: border-color 0.5s ease, color 0.5s ease; font-size: 0.9rem;
}
button:hover { border-color: var(--accent-main); color: var(--accent-main); }

/* Ensure Mobile Toggle is hidden on desktop */
.mobile-toggle { display: none; }

/* Hero */
.hero { 
  min-height: 100vh; 
  background: linear-gradient(135deg, var(--winter-deep) 0%, var(--winter-teal) 100%); 
  display: flex; align-items: center; justify-content: center; 
  text-align: center; padding: 20px; 
  color: white; 
}
.hero h1 { 
  font-size: clamp(2.5rem, 5vw, 4.5rem); 
  margin-bottom: 1rem; 
  background: linear-gradient(to right, #ffffff, var(--winter-ice));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.typing-wrapper {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  margin-bottom: 2rem;
  min-height: 1.5em;
  color: var(--winter-mist);
  font-family: 'Inter', monospace;
  white-space: nowrap;
  overflow: hidden;
}
.cursor {
  display: inline-block;
  width: 2px;
  margin-left: 4px;
  background: var(--winter-mist);
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Buttons */
.btn { display: inline-block; padding: 12px 32px; border-radius: 4px; text-decoration: none; font-weight: 600; margin: 5px; transition: 0.3s; }
.btn.primary { background: var(--winter-ice); color: var(--winter-deep); border: 1px solid var(--winter-ice); }
.btn.primary:hover { background: white; border-color: white; transform: translateY(-2px); }
.btn.outline { background: transparent; color: var(--winter-ice); border: 1px solid var(--winter-ice); }
.btn.outline:hover { background: rgba(184, 227, 233, 0.1); }
.btn:active { transform: scale(0.96); }

/* Sections */
section { padding: 100px 0; transition: background-color 0.5s ease; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
h2 { text-align: center; font-size: 2.5rem; margin-bottom: 60px; color: var(--accent-main); position: relative; transition: color 0.5s ease; }
h2::after { content: ''; display: block; width: 60px; height: 3px; background: var(--winter-mist); margin: 15px auto 0; transition: background-color 0.5s ease; }

/* Layouts */
.about-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 50px;
  align-items: start;
}
.photo-wrapper img { border-radius: 8px; box-shadow: var(--shadow); width: 100%; border: 2px solid var(--winter-ice); transition: box-shadow 0.5s ease, border-color 0.5s ease; }

.about-cards-grid, .skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
}

.about-card, .skill-category { 
  background: var(--bg-secondary); 
  padding: 30px; 
  border-radius: 8px; 
  box-shadow: var(--shadow); 
  border-left: 4px solid var(--winter-teal); 
  transition: transform 0.3s, background-color 0.5s ease, box-shadow 0.5s ease;
  width: 100%; 
  min-height: 180px; 
}
.about-card:hover, .skill-category:hover { transform: translateY(-5px); }

.skill-items span { 
  display: inline-block; background: var(--bg-color); 
  padding: 8px 14px; border-radius: 4px; margin: 5px; 
  font-size: 0.9rem; border: 1px solid var(--border-color); 
  font-weight: 500;
  transition: background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease;
}

/* 3D Carousel */
.portfolio-section { overflow: hidden; user-select: none; }
.carousel-scene {
  position: relative; width: 100%; height: 440px;
  perspective: 1200px; display: flex; justify-content: center;
  margin-bottom: 40px;
}
.carousel {
  width: 300px; height: 400px; position: absolute;
  transform-style: preserve-3d; cursor: grab;
}
.carousel:active { cursor: grabbing; }

.carousel-cell {
  position: absolute; width: 300px; height: 400px; left: 0; top: 0;
  backface-visibility: hidden;
}

.project-card {
  width: 100%; height: 100%; background: var(--bg-secondary);
  border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  min-height: 400px;
  transition: background-color 0.5s ease, box-shadow 0.5s ease, border-color 0.5s ease;
}

.project-image { height: 220px; overflow: hidden; position: relative; }
.project-image img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

.project-overlay {
  position: absolute; inset: 0;
  background: rgba(11, 46, 51, 0.85);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s ease;
}
.project-card:hover .project-overlay { opacity: 1; }

.btn-icon {
  width: 50px; height: 50px; background: var(--winter-ice); color: var(--winter-deep);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin: 0 8px; transition: 0.2s; text-decoration: none;
}
.btn-icon:hover { transform: scale(1.1); background: white; }

.project-content { padding: 25px; flex: 1; display: flex; flex-direction: column; background: linear-gradient(to bottom, var(--winter-deep), var(--winter-teal)); transition: background 0.5s ease; }
.project-content h3 { margin-bottom: 10px; color: white; font-size: 1.4rem; transition: color 0.5s ease; }
.project-content p { transition: color 0.5s ease; }
.project-tags { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.tag { font-size: 0.75rem; background: var(--bg-color); padding: 4px 10px; border-radius: 4px; border: 1px solid var(--winter-mist); color: var(--text-secondary); transition: background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease; }

.carousel-controls { display: flex; justify-content: center; gap: 20px; }
.nav-btn { 
  width: 40px; height: 40px; border-radius: 50%; 
  display: flex; align-items: center; justify-content: center; 
  background: var(--bg-secondary); box-shadow: var(--shadow);
  transition: background-color 0.5s ease, box-shadow 0.5s ease, color 0.5s ease;
}
.drag-hint { text-align: center; margin-top: 15px; color: var(--winter-teal); font-size: 0.9rem; opacity: 0.8; transition: color 0.5s ease; }

/* Contact */
.contact-wrapper { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; }
.contact-method { display: flex; align-items: center; gap: 15px; font-size: 1.1rem; color: var(--text-color); text-decoration: none; margin-top: 20px; transition: color 0.5s ease; }
.social-links { margin-top: 30px; display: flex; gap: 20px; font-size: 1.5rem; }
.social-links a { color: var(--winter-teal); transition: color 0.5s ease; }
.social-links a:hover { color: var(--winter-deep); }

input, textarea { 
  width: 100%; padding: 15px; margin-bottom: 20px; 
  border: 1px solid var(--border-color); border-radius: 4px; 
  background: var(--bg-color); color: var(--text-color); 
  font-family: inherit; font-size: 1rem;
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}
input:focus, textarea:focus { outline: 2px solid var(--winter-teal); border-color: transparent; }

.footer { text-align: center; padding: 40px; background: var(--bg-secondary); margin-top: 80px; border-top: 1px solid var(--border-color); font-size: 0.9rem; color: var(--text-secondary); transition: background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease; }

/* Media Queries */
@media (max-width: 992px) {
  .about-layout { grid-template-columns: 1fr; justify-items: center; }
  .photo-wrapper { max-width: 300px; margin-bottom: 30px; }
}

@media (max-width: 768px) {
  .navbar nav { padding: 0 15px; }
  
  .mobile-toggle { display: block; }
  
  .nav-links-container { 
    position: absolute; top: var(--nav-height); left: 0; width: 100%; 
    background: var(--bg-secondary); 
    max-height: 0; 
    overflow: hidden; 
    visibility: hidden;
    transition: max-height 0.4s ease-in-out, visibility 0.4s; 
    box-shadow: var(--shadow); 
    border-bottom: 1px solid transparent;
  }
  
  .nav-links-container.active { 
    max-height: 500px; 
    visibility: visible;
    border-color: var(--border-color); 
  }
  
  .nav-links-container ul { 
    flex-direction: column; 
    align-items: center; 
    gap: 1.5rem; 
    padding: 30px 0; 
  }
  
  .contact-wrapper { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2.5rem; }
}
