/* ============================================
   634.nakajima Portfolio - Modern Redesign
   ============================================ */

/* --- Custom Properties --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #0f0f18;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(99, 102, 241, 0.3);
  --text-primary: #e8e8e8;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-light: #8b5cf6;
  --accent-cyan: #22d3ee;
  --nav-height: 64px;
  --section-pad: clamp(60px, 10vw, 120px);
  --container-max: 1200px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Noto Sans JP', 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 15px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-light);
}

ul, ol {
  list-style: none;
}

h1, h2, h3, h4, h5 {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* --- Container --- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 32px);
}

/* --- Section --- */
.section {
  padding: var(--section-pad) 0;
}

.section-title {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 48px;
}

/* --- Scroll Animations --- */
.fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ============================================
   NAVIGATION
   ============================================ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 1000;
  transition: background var(--transition), box-shadow var(--transition);
}

.nav.scrolled {
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 var(--border-subtle);
}

.nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav-logo {
  font-family: 'Logo', monospace;
  font-size: 1.6rem;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.nav-links {
  display: flex;
  gap: 32px;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: relative;
  padding: 4px 0;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width var(--transition);
}

.nav-links a:hover {
  color: var(--text-primary);
}

.nav-links a:hover::after {
  width: 100%;
}

/* Mobile menu button */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  margin: 5px 0;
  transition: var(--transition);
}

/* ============================================
   HERO
   ============================================ */
.hero {
  position: relative;
  height: 100vh;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, var(--bg-primary) 75%);
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
}

.hero-title {
  font-family: 'Logo', monospace;
  font-size: clamp(3rem, 10vw, 7rem);
  color: var(--text-primary);
  letter-spacing: 2px;
  text-shadow: 0 0 60px rgba(99, 102, 241, 0.3);
  margin-bottom: 16px;
}

.hero-tagline {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.15em;
}

.hero-scroll {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  animation: float 2s ease-in-out infinite;
}

.hero-scroll-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--accent), transparent);
}

@keyframes float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(8px); }
}

/* ============================================
   PROJECTS GRID
   ============================================ */
.projects-section {
  background: var(--bg-secondary);
}

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 20px;
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.1);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.1);
}

.project-card-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.project-card-body {
  padding: 20px;
}

.project-card-year {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.project-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.4;
}

.project-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   PROJECT MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  max-width: 900px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 10;
  width: 40px;
  height: 40px;
  margin: 16px 16px 0 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-body {
  padding: 20px 32px 40px;
}

.modal-title {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  margin-bottom: 4px;
}

.modal-year {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.85;
  margin-bottom: 28px;
}

.modal-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}

.modal-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* YouTube lazy load thumbnail */
.youtube-lazy {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #111;
  cursor: pointer;
}

.youtube-lazy img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.youtube-lazy .play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 48px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.youtube-lazy:hover .play-btn {
  background: #e00;
}

.play-btn::after {
  content: '';
  display: block;
  border-style: solid;
  border-width: 10px 0 10px 18px;
  border-color: transparent transparent transparent #fff;
  margin-left: 3px;
}

/* ============================================
   ABOUT
   ============================================ */
.about-section {
  background: var(--bg-primary);
}

.about-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 48px;
  align-items: start;
}

.about-photo {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 20%;
  border: 3px solid var(--border-subtle);
}

.about-name {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.about-affiliation {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.about-role {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-style: italic;
  margin-bottom: 20px;
}

.about-lab-link {
  display: inline-block;
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.research-themes {
  margin-bottom: 32px;
}

.research-themes h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.theme-item {
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.theme-item-en {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 4px;
}

.theme-item-ja {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.about-bio,
.about-education,
.about-career {
  margin-bottom: 28px;
}

.about-bio h3,
.about-education h3,
.about-career h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.about-bio p,
.about-education p,
.about-career p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ============================================
   WORKS (PUBLICATIONS)
   ============================================ */
.works-section {
  background: var(--bg-secondary);
}

.works-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0;
}

.works-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.works-tab:hover {
  color: var(--text-secondary);
}

.works-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.works-panel {
  display: none;
}

.works-panel.active {
  display: block;
}

.works-list {
  counter-reset: work-item;
}

.works-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.works-list li:last-child {
  border-bottom: none;
}

/* ============================================
   SINGING & MUSIC SECTIONS
   ============================================ */
.extra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.extra-item {
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}

.extra-item:hover {
  border-color: var(--border-glow);
}

.extra-item a {
  font-weight: 600;
  font-size: 0.95rem;
}

.extra-item p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================
   CONTACT
   ============================================ */
.contact-section {
  background: var(--bg-primary);
}

.contact-content {
  max-width: 600px;
}

.contact-content p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.contact-content a {
  font-weight: 600;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  padding: 32px 0;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================
   BACK TO TOP
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 100;
  backdrop-filter: blur(8px);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: rgba(99, 102, 241, 0.3);
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .nav-links {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 260px;
    background: rgba(10, 10, 15, 0.98);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: 80px 32px;
    gap: 24px;
    transform: translateX(100%);
    transition: transform var(--transition);
  }

  .nav-links.open {
    transform: translateX(0);
  }

  .nav-toggle {
    display: block;
    z-index: 1001;
  }

  .nav-toggle.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .nav-toggle.open span:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .about-photo {
    margin: 0 auto;
  }

  .about-info {
    text-align: center;
  }

  .research-themes,
  .about-bio,
  .about-education,
  .about-career {
    text-align: left;
  }

  .projects-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .modal-body {
    padding: 16px 20px 32px;
  }

  .works-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .works-tabs::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    gap: 6px;
  }

  .filter-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
  }
}
