/* Base styles and reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Font loading states */
html {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.1s ease;
}

html:not(.fonts-loaded) {
  visibility: hidden;
  opacity: 0;
}

html.fonts-failed {
  visibility: visible;
  opacity: 1;
}

/* Japanese font fallback */
html.japanese-font-failed {
  --font-main: 'Montserrat', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Meiryo', 'Yu Gothic', 'MS PGothic', sans-serif;
}

:root {
  --text-color: #333333;
  --bg-color: #ffffff;
  --accent-color: #000000;
  --spacing: clamp(1rem, 2vw, 2rem);
  --font-main: 'Montserrat', 'Noto Sans JP', 'Noto Sans JP Fallback', sans-serif;
}

/* Font loading optimizations */
@font-face {
  font-family: 'Noto Sans JP';
  font-display: swap;
  src: local('Noto Sans JP'),
       url(https://fonts.gstatic.com/s/notosansjp/v52/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFBEj75g.woff2) format('woff2');
  unicode-range: U+3000-30FF, U+FF00-FFEF, U+4E00-9FAF;
}

html {
  font-size: 62.5%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* Navigation */
.main-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 2rem;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.95);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 24px;
  position: relative;
  z-index: 1001;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--text-color);
  position: absolute;
  left: 0;
  transition: all 0.3s ease;
}

.hamburger span:first-child {
  top: 0;
}

.hamburger span:nth-child(2) {
  top: 50%;
  transform: translateY(-50%);
}

.hamburger span:last-child {
  bottom: 0;
}

.hamburger.active span:first-child {
  transform: translateY(11px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:last-child {
  transform: translateY(-11px) rotate(-45deg);
}

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

.lang-switcher {
  display: flex;
  gap: 1rem;
}

.lang-btn {
  font-size: 1.4rem;
  padding: 0.5rem 1.5rem;
  border: 1px solid var(--text-color);
  background: none;
  border-radius: 2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #666;
  min-width: 7rem;
  font-weight: 500;
}

.lang-btn[data-lang="ja"] {
  font-size: 1.3rem;
}

.lang-btn.active {
  background-color: var(--text-color);
  color: var(--bg-color);
  font-weight: 600;
}

.lang-btn:hover:not(.active) {
  background-color: rgba(51, 51, 51, 0.1);
  color: var(--text-color);
}

.nav-buttons {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.nav-button {
  font-size: 1.6rem;
  color: var(--text-color);
  text-decoration: none;
  padding: 1rem 2rem;
  border: 1px solid var(--text-color);
  border-radius: 3rem;
  transition: all 0.3s ease;
}

.nav-button:hover {
  background-color: var(--text-color);
  color: var(--bg-color);
}

@media (max-width: 768px) {
  .main-nav {
    padding: 1rem;
  }

  .hamburger {
    display: block;
  }

  .nav-content {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.98);
    flex-direction: column;
    justify-content: center;
    gap: 4rem;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    padding: 2rem;
  }

  .nav-content.active {
    transform: translateX(0);
  }

  .nav-buttons {
    flex-direction: column;
    align-items: center;
    gap: 2rem;
  }

  .nav-button {
    width: 200px;
    text-align: center;
  }

  .lang-switcher {
    flex-direction: row;
    gap: 1rem;
  }

  .lang-btn {
    min-width: 100px;
  }
}

/* Typography */
h1, h2, h3 {
  color: var(--accent-color);
  line-height: 1.2;
}

h2 {
  font-size: clamp(2.4rem, 4vw, 3.2rem);
  margin-bottom: 4rem;
  text-align: center;
}

h3 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

p {
  font-size: 1.6rem;
  margin-bottom: 2rem;
}

/* Hero Section */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing);
}

.logo-container {
  max-width: 300px;
  width: 100%;
}

.main-logo {
  width: 100%;
  height: auto;
  border-radius: 50%;
  opacity: 0;
  transform: translateY(20px);
}

/* Projects Section */
.projects {
  padding: 8rem var(--spacing);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 4rem;
  max-width: 1200px;
  margin: 0 auto;
}

.project-card {
  text-decoration: none;
  color: var(--text-color);
  background: var(--bg-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
}

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

.project-image-container {
  position: relative;
  overflow: hidden;
}

.project-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.project-card:hover .project-image {
  transform: scale(1.05);
}

.hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hover-overlay span {
  color: white;
  font-size: 1.8rem;
  font-weight: 600;
}

.project-card:hover .hover-overlay {
  opacity: 1;
}

.project-info {
  padding: 2rem;
}

.project-tags {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.project-tags span {
  font-size: 1.2rem;
  padding: 0.4rem 1.2rem;
  background-color: #f5f5f5;
  border-radius: 2rem;
}

/* About Section */
.about {
  padding: 8rem var(--spacing);
  background-color: var(--bg-color);
}

.about-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

/* Flow Section */
.flow {
  padding: 8rem var(--spacing);
  background-color: #f9f9f9;
}

.flow-container {
  display: flex;
  justify-content: center;
  gap: 4rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 0;
}

.flow-step {
  flex: 1;
  max-width: 350px;
  background: var(--bg-color);
  border-radius: 1.5rem;
  padding: 3rem 2rem;
  text-align: center;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.flow-step:hover {
  transform: translateY(-5px);
}

.step-number {
  position: absolute;
  top: -2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 4rem;
  height: 4rem;
  background: var(--accent-color);
  color: var(--bg-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
}

.step-icon {
  margin: 2rem 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.flow-step h3 {
  margin: 2rem 0;
  font-size: 2.2rem;
}

.flow-step p {
  color: #666;
  font-size: 1.5rem;
  line-height: 1.6;
}

@media (max-width: 768px) {
  .flow-container {
    flex-direction: column;
    align-items: center;
    gap: 6rem;
  }

  .flow-step {
    width: 100%;
  }
}

/* Contact Section */
.contact {
  padding: 8rem var(--spacing);
}

.contact-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 4rem;
  text-align: left;
}

.form-group {
  position: relative;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 1.5rem 2rem;
  font-size: 1.6rem;
  font-family: var(--font-main);
  border: 1px solid #e0e0e0;
  border-radius: 0.8rem;
  background-color: #ffffff;
  transition: all 0.3s ease;
}

.form-group textarea {
  min-height: 150px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #999;
}

.contact-button {
  display: inline-block;
  font-size: 1.8rem;
  color: var(--accent-color);
  text-decoration: none;
  padding: 1.5rem 3rem;
  border: 2px solid var(--accent-color);
  border-radius: 3rem;
  background: none;
  cursor: pointer;
  font-family: var(--font-main);
  margin-top: 1rem;
  transition: all 0.3s ease;
}

.contact-button:hover {
  background-color: var(--accent-color);
  color: var(--bg-color);
}

.form-status {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 0.5rem;
  font-size: 1.4rem;
  display: none;
}

.form-status.success {
  display: block;
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.form-status.error {
  display: block;
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.contact-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Media Queries */
@media (max-width: 768px) {
  .nav-buttons {
    gap: 1rem;
  }
  
  .nav-button {
    padding: 0.8rem 1.5rem;
    font-size: 1.4rem;
  }
  
  .projects-grid {
    grid-template-columns: 1fr;
  }
}