:root {
  /* Simple Dark Theme */
  --bg-color: #121212;
  --text-main: #e0e0e0;
  --text-muted: #a0a0a0;
  --accent-color: #4ade80;
  --card-bg: #1e1e1e;
  --card-border: #333333;
  --header-bg: #121212;

  /* Spacing & Layout */
  --container-width: 1200px;
  --header-height: 70px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Transitions */
  --transition-fast: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Manrope', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition-fast);
}

ul {
  list-style: none;
}

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

/* Utilities */
.container {
  width: 90%;
  max-width: var(--container-width);
  margin: 0 auto;
}

.text-gradient {
  color: var(--accent-color);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.95rem;
}

.btn.primary {
  background-color: var(--accent-color);
  color: #121212;
  border: 1px solid var(--accent-color);
}

.btn.primary:hover {
  opacity: 0.9;
}

.btn.secondary {
  background-color: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-main);
}

.btn.secondary:hover {
  border-color: var(--text-muted);
}

/* Background Effect - Removed */
.background-gradient {
  display: none;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--card-border);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: 2rem;
}

.nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.nav a:hover,
.nav a.active {
  color: var(--accent-color);
}

/* Hero Section */
.hero {
  padding-top: calc(var(--header-height) + 60px);
  padding-bottom: 60px;
  min-height: 60vh;
  display: flex;
  align-items: center;
}

.hero-content {
  max-width: 700px;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

.hero-subtitle {
  font-size: clamp(1.1rem, 2.5vw, 1.25rem);
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.hero-description {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 540px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 1rem;
}

/* Sections */
.section {
  padding: 60px 0;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 2.5rem;
  letter-spacing: -0.02em;
  text-align: center;
  position: relative;
  display: inline-block;
  left: 50%;
  transform: translateX(-50%);
}

.section-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 4px;
  background: var(--accent-color);
  margin: 0.5rem auto 0;
  border-radius: 2px;
}

/* News Section */
.news-container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.news-list {
  list-style: none;
}

.news-item {
  display: flex;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px solid var(--card-border);
}

.news-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.news-item:first-child {
  padding-top: 0;
}

.news-date {
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  color: var(--accent-color);
  margin-right: 2rem;
  min-width: 100px;
  font-size: 0.95rem;
}

.news-text {
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.6;
}

@media (max-width: 600px) {
  .news-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .news-date {
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
  }
}

/* SNS Grid */
.sns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.sns-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: border-color 0.2s;
}

.sns-card:hover {
  border-color: var(--accent-color);
}

.sns-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.sns-name {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.sns-id {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Portfolio Grid */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* Portfolio Card - Base Styles */
.portfolio-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  /* Prepare for FLIP animation */
  transform-origin: top left;
  will-change: top, left, width, height, transform;
  transition: none;
  /* JS will handle transitions */
}

.portfolio-card .card-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.portfolio-card.expanded .card-close {
  display: inline-flex;
}

.portfolio-card:hover {
  border-color: var(--text-muted);
}

/* Placeholder to prevent layout shift */
.portfolio-card-placeholder {
  opacity: 0;
  pointer-events: none;
}

/* Expanded State - Controlled by JS for animation */
.portfolio-card.expanded {
  position: fixed;
  z-index: 2000;
  border-radius: 0;
  border: none;
  background: var(--bg-color);
  overflow-y: auto;
  padding: 2rem;
  cursor: default;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

/* Animating Class */
.portfolio-card.animating {
  transition:
    top 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    left 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 0.5s ease;
}

.portfolio-card.expanded .portfolio-image {
  height: 300px;
  /* Reduced from 40vh for better content visibility */
  max-height: 500px;
  width: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 2rem;
  transition: height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.portfolio-card.expanded .portfolio-content {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  opacity: 0;
  /* Fade in content after expansion */
  animation: fadeInContent 0.4s ease 0.3s forwards;
  /* Expanded表示時は中央にまとまるように配置 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1.25rem;
  flex: 1 1 auto;
  min-height: calc(100vh - 300px - 4rem);
}

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

.portfolio-card.expanded .portfolio-title {
  font-size: 2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 1rem;
}

/* Close button style */
.portfolio-card.expanded .portfolio-title::after {
  content: '×';
  /* Close icon */
  font-size: 2.5rem;
  font-weight: 300;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
}

.portfolio-card.expanded .portfolio-title::after:hover {
  color: var(--text-main);
}

.portfolio-card.expanded .portfolio-desc {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  order: 2;
}

.portfolio-card.expanded .portfolio-tags span {
  font-size: 0.9rem;
  padding: 0.4rem 1rem;
}

/* Expanded表示ではスキルタグを通常のフローに戻し、中央付近にテキストを配置しやすくする */
.portfolio-card.expanded .portfolio-tags {
  margin-top: auto;
  order: 4;
  gap: 0.75rem;
}

.portfolio-card.expanded .portfolio-title {
  order: 1;
}

.portfolio-card.expanded .portfolio-hidden-details {
  order: 3;
}

/* Hidden Details */
.portfolio-hidden-details {
  display: none;
  /* Hidden by default */
}

.portfolio-card.expanded .portfolio-hidden-details {
  display: block;
  margin-top: 2rem;
  font-size: 1rem;
  line-height: 1.8;
}

/* Responsive adjustments for full screen */
@media (max-width: 768px) {
  .portfolio-card.expanded {
    padding: 1rem;
  }

  .portfolio-card.expanded .portfolio-title {
    font-size: 1.5rem;
  }

  .portfolio-card.expanded .portfolio-image {
    height: 30vh;
  }

  .portfolio-card.expanded .portfolio-content {
    min-height: auto;
    justify-content: flex-start;
    gap: 1rem;
  }
}

/* Normal State Styles */
.portfolio-image {
  height: 180px;
  background-color: #252525;
  /* Fallback color */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  transition: height 0.3s ease;
  flex-shrink: 0;
}

.portfolio-image::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(#334155 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.5;
}

.portfolio-content {
  padding: 1.25rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Site Decoration (Dynamic) */
.site-decoration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Parent: Handles vertical movement (Drop/Retract) */
.hanging-item {
  position: absolute;
  top: 0;
  transform: translateY(-120%);
  /* Start hidden above */
  transition: transform 2s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Smooth bouncy drop */
  will-change: transform;
}

.hanging-item.visible {
  transform: translateY(0);
}

/* Child: Handles swaying (Rotation) */
.hanging-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: top center;
  animation: gentleSwing 4s ease-in-out infinite alternate;
  will-change: transform;
}

.hanging-item .string {
  width: 2px;
  /* Slightly thicker */
  height: var(--length);
  background: linear-gradient(to bottom, transparent, rgba(74, 222, 128, 0.3) 50%, rgba(74, 222, 128, 0.6));
  box-shadow: 0 0 4px rgba(74, 222, 128, 0.2);
}

.hanging-item .motif {
  font-size: 2rem;
  /* Larger motif */
  color: var(--accent-color);
  margin-top: -10px;
  filter: drop-shadow(0 0 10px var(--accent-glow));
  animation: twinkle 3s ease-in-out infinite alternate;
}

@keyframes gentleSwing {
  0% {
    transform: rotate(4deg);
  }

  100% {
    transform: rotate(-4deg);
  }
}

@keyframes twinkle {
  0% {
    opacity: 0.5;
    transform: scale(0.9);
  }

  100% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* Hide on mobile */
@media (max-width: 768px) {

  .site-decoration,
  .side-glow,
  .falling-stars-container {
    display: none;
  }
}

/* Side Glow Effect */
.side-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(to right, rgba(74, 222, 128, 0.05), transparent 15%),
    linear-gradient(to left, rgba(74, 222, 128, 0.05), transparent 15%);
}

/* Falling Stars Effect */
.falling-stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.falling-star {
  position: absolute;
  top: -20px;
  color: var(--accent-color);
  opacity: 0;
  animation: fall linear forwards;
  text-shadow: 0 0 5px var(--accent-glow);
}

@keyframes fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 0.5;
  }

  90% {
    opacity: 0.5;
  }

  100% {
    transform: translateY(110vh) rotate(360deg);
    opacity: 0;
  }
}

.portfolio-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.portfolio-title::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-muted);
}

.portfolio-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.portfolio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  margin-top: auto;
  /* Push tags to bottom in card view */
}

.portfolio-tags span {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: #2a2a2a;
  color: var(--accent-color);
  opacity: 0.4;
  margin-top: -5px;
  text-shadow: 0 0 10px var(--accent-glow);
}

@keyframes swing {
  0% {
    transform: rotate(2deg);
  }

  100% {
    transform: rotate(-2deg);
  }
}

/* Hide decoration on small screens to avoid clutter */
@media (max-width: 1024px) {
  .site-decoration {
    .site-decoration {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 0;
      overflow: hidden;
    }

    /* Parent: Handles vertical movement (Drop/Retract) */
    .hanging-item {
      position: absolute;
      top: 0;
      transform: translateY(-120%);
      /* Start hidden above */
      transition: transform 2s cubic-bezier(0.34, 1.56, 0.64, 1);
      /* Smooth bouncy drop */
      will-change: transform;
    }

    .hanging-item.visible {
      transform: translateY(0);
    }

    /* Child: Handles swaying (Rotation) */
    .hanging-inner {
      display: flex;
      flex-direction: column;
      align-items: center;
      transform-origin: top center;
      animation: gentleSwing 4s ease-in-out infinite alternate;
      will-change: transform;
    }

    .hanging-item .string {
      width: 2px;
      /* Slightly thicker */
      height: var(--length);
      background: linear-gradient(to bottom, transparent, rgba(74, 222, 128, 0.3) 50%, rgba(74, 222, 128, 0.6));
      box-shadow: 0 0 4px rgba(74, 222, 128, 0.2);
    }

    .hanging-item .motif {
      font-size: 2rem;
      /* Larger motif */
      color: var(--accent-color);
      margin-top: -10px;
      filter: drop-shadow(0 0 10px var(--accent-glow));
      animation: twinkle 3s ease-in-out infinite alternate;
    }

    @keyframes gentleSwing {
      0% {
        transform: rotate(4deg);
      }

      100% {
        transform: rotate(-4deg);
      }
    }

    @keyframes twinkle {
      0% {
        opacity: 0.5;
        transform: scale(0.9);
      }

      100% {
        opacity: 1;
        transform: scale(1.1);
      }
    }

    /* Hide on mobile */
    @media (max-width: 768px) {

      .site-decoration,
      .side-glow,
      .falling-stars-container {
        display: none;
      }
    }

    /* Side Glow Effect */
    .side-glow {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 0;
      background:
        linear-gradient(to right, rgba(74, 222, 128, 0.05), transparent 15%),
        linear-gradient(to left, rgba(74, 222, 128, 0.05), transparent 15%);
    }

    /* Falling Stars Effect */
    .falling-stars-container {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 0;
      overflow: hidden;
    }

    .falling-star {
      position: absolute;
      top: -20px;
      color: var(--accent-color);
      opacity: 0;
      animation: fall linear forwards;
      text-shadow: 0 0 5px var(--accent-glow);
    }

    @keyframes fall {
      0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
      }

      10% {
        opacity: 0.5;
      }

      90% {
        opacity: 0.5;
      }

      100% {
        transform: translateY(110vh) rotate(360deg);
        opacity: 0;
      }
    }

    .portfolio-title {
      font-size: 1.1rem;
      font-weight: 700;
      margin-bottom: 0.5rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .portfolio-title::after {
      content: '+';
      font-size: 1.2rem;
      font-weight: 400;
      color: var(--text-muted);
    }

    .portfolio-desc {
      color: var(--text-muted);
      font-size: 0.9rem;
      margin-bottom: 1rem;
      line-height: 1.5;
    }

    .portfolio-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin-bottom: 0.5rem;
      margin-top: auto;
      /* Push tags to bottom in card view */
    }

    .portfolio-tags span {
      font-size: 0.75rem;
      padding: 0.2rem 0.6rem;
      background: #2a2a2a;
      color: var(--accent-color);
      opacity: 0.4;
      margin-top: -5px;
      text-shadow: 0 0 10px var(--accent-glow);
    }

    @keyframes swing {
      0% {
        transform: rotate(2deg);
      }

      100% {
        transform: rotate(-2deg);
      }
    }

    /* Hide decoration on small screens to avoid clutter */
    @media (max-width: 1024px) {
      .site-decoration {
        display: none;
      }
    }

    /* Responsive */
    @media (max-width: 768px) {
      .hero-title {
        font-size: 2.25rem;
      }

      .hamburger-menu {
        display: block;
      }

      .nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        background-color: var(--bg-color);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: right 0.3s ease;
        border-left: 1px solid var(--card-border);
        z-index: 1000;
      }

      .nav.active {
        right: 0;
      }

      .header-inner {
        justify-content: space-between;
      }
    }

    /* Portfolio Link Cards */
    .portfolio-links {
      display: grid;
      gap: 1rem;
      margin-top: 1rem;
    }

.portfolio-link-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(74, 222, 128, 0.35);
  border-radius: 12px;
  text-decoration: none;
  color: var(--accent-color);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

    .portfolio-link-card:hover {
      background: rgba(255, 255, 255, 0.08);
      border-color: rgba(74, 222, 128, 0.6);
      transition: background 0.3s ease, border-color 0.3s ease;
    }

    .portfolio-link-card:hover .link-icon {
      background: rgba(74, 222, 128, 0.2);
      color: var(--accent-color);
    }

    .link-content {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }

.link-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent-color) !important;
  text-decoration: underline;
}

.portfolio-note {
  color: var(--text-muted);
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
}

    .link-url {
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    .link-action {
      font-size: 1.2rem;
      color: var(--text-muted);
      transition: transform 0.3s ease, color 0.3s ease;
    }

  .portfolio-link-card:hover .link-action {
      color: var(--accent-color);
      transform: translateX(4px);
    }
  }
}

/* Force accent color on sample links (desktop/any) */
.portfolio-hidden-details .portfolio-link-card,
.portfolio-hidden-details .portfolio-link-card .link-title {
  color: var(--accent-color) !important;
}

.portfolio-hidden-details .portfolio-link-card .link-title {
  text-decoration: underline;
}

.portfolio-hidden-details .portfolio-link-card {
  border-color: rgba(74, 222, 128, 0.45);
}

.portfolio-hidden-details .portfolio-link-card:hover {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.7);
}
