/* CSS Reset & Variables */
:root {
  --color-white: #ffffff;
  --color-black: #000000;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--color-white);
  color: var(--color-black);
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Cursor with Mix Blend Mode Difference */
.custom-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background-color: var(--color-white);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.custom-cursor.hovered {
  transform: translate(-50%, -50%) scale(2.5);
}

/* Hide default cursor on desktop where custom cursor is active */
@media (min-width: 1025px) {
  body {
    cursor: none;
  }
  a, button, .lang-btn, .work-item {
    cursor: none;
  }
}

@media (max-width: 1024px) {
  .custom-cursor {
    display: none;
  }
}

/* Brutalist Grid Layout */
.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  background-color: var(--color-black);
  gap: 1px; /* Creates the border lines between cells */
  border: 1px solid var(--color-black);
}

@media (min-width: 1025px) {
  .portfolio-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(50vh, auto) minmax(50vh, auto);
  }
}

/* Grid Cell Styles */
.grid-cell {
  background-color: var(--color-white);
  color: var(--color-black);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.grid-cell:hover {
  background-color: var(--color-black);
  color: var(--color-white);
}

/* Quadrant 1: Profile Cell */
.cell-profile {
  gap: 3rem;
}

.name-display {
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.role-display {
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0.75rem;
  font-weight: 700;
}

.location-display {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 0.25rem;
  opacity: 0.8;
}

.profile-footer {
  margin-top: auto;
}

.cell-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid currentColor;
  padding-bottom: 0.5rem;
}

/* Quadrant 2: Details — Modular Synthesizer Patch Bay */
.synth-cell {
  padding: 1.5rem !important; /* Slightly tighter padding for the panel layout */
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  align-items: stretch;
}

.synth-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  border: 1px solid currentColor;
  font-family: 'Space Mono', monospace;
  background-color: transparent;
  transition: border-color 0.4s ease;
}

.synth-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid currentColor;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.9;
}

.synth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  flex: 1;
  height: 100%;
}

.synth-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid currentColor;
  padding: 1rem;
  gap: 0.75rem;
  justify-content: space-between;
}

.synth-col:last-child {
  border-right: none;
}

.col-header {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  opacity: 0.7;
  border-bottom: 1px dashed currentColor;
  padding-bottom: 0.25rem;
  margin-bottom: 0.25rem;
}

/* Module Card */
.module-card {
  border: 1px solid currentColor;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background-color: transparent;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  min-height: 90px;
}

.mod-meta {
  font-size: 0.55rem;
  opacity: 0.6;
  letter-spacing: 0.05em;
}

.mod-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  justify-content: space-between;
}

.mod-title {
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  font-size: clamp(0.85rem, 1.1vw, 1.15rem);
  font-weight: 700;
  line-height: 1.25;
}

.mod-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

/* Dial (Knob) */
.dial-container {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dial-label {
  font-size: 0.55rem;
  opacity: 0.5;
}

.synth-dial {
  width: 18px;
  height: 18px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  position: relative;
  transform: rotate(var(--rotation, 0deg));
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.synth-dial::after {
  content: '';
  position: absolute;
  top: 1.5px;
  left: 50%;
  width: 1.5px;
  height: 5px;
  background-color: currentColor;
  transform: translateX(-50%);
}

/* Jack Port */
.jack-port {
  width: 14px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  position: relative;
  background-color: var(--color-white);
  transition: background-color 0.3s;
}

.jack-port::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background-color: var(--color-black);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: background-color 0.3s;
}

/* Invert Jack inner color when cell is black */
.grid-cell:hover .jack-port {
  background-color: var(--color-black);
}
.grid-cell:hover .jack-port::after {
  background-color: var(--color-white);
}

/* Patch Cables SVG Overlay */
.synth-cables {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.cable-path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  opacity: 0.45;
  transition: stroke-width 0.3s, opacity 0.3s;
}

.cable-path.active {
  stroke-width: 4;
  opacity: 1;
}

.cable-path.active-signal {
  stroke-dasharray: 6, 4;
  animation: signalFlow 0.8s linear infinite;
}

@keyframes signalFlow {
  to {
    stroke-dashoffset: -20;
  }
}

/* Modulation dial rotation */
.module-card.modulating .synth-dial {
  animation: modulateDial 1.5s ease-in-out infinite alternate;
}

@keyframes modulateDial {
  from {
    transform: rotate(var(--rotation, 0deg));
  }
  to {
    transform: rotate(calc(var(--rotation, 0deg) + 60deg));
  }
}

/* Highlight connected cards on hover */
.synth-panel:has(.module-card:hover) .module-card:not(.active-highlight) {
  opacity: 0.35;
}

.module-card.active-highlight {
  border-width: 1.5px;
  background-color: rgba(0, 0, 0, 0.03);
}

.cell-details:hover .module-card.active-highlight {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Responsive Synth Grid */
@media (max-width: 1024px) {
  .synth-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .synth-col {
    border-right: none;
    border-bottom: 1px solid currentColor;
    gap: 1rem;
    padding: 1rem 0.5rem;
  }
  .synth-col:last-child {
    border-bottom: none;
  }
  .synth-cables {
    display: none; /* Hide patch cables on mobile/stacked view */
  }
  .module-card {
    min-height: auto;
    flex-direction: column;
    gap: 0.25rem;
  }
  .mod-body {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
  }
  .mod-title {
    font-size: 0.95rem;
  }
  .mod-controls {
    margin-top: 0;
    gap: 1rem;
    flex-shrink: 0;
  }
}

/* Quadrant 3: Works Cell */
.cell-works {
  justify-content: flex-start;
  max-height: 100%;
}

.works-list {
  display: flex;
  flex-direction: column;
}

.work-item {
  border-bottom: 1px solid currentColor;
  padding: 1.5rem 0;
  transition: padding-left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.work-item:hover {
  padding-left: 1rem;
}

.work-cat {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.75;
}

.work-title {
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.work-desc {
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  font-size: 0.95rem;
  font-weight: 300;
  opacity: 0.8;
  line-height: 1.5;
}

/* Quadrant 4: Connect & Language Selector */
.cell-connect {
  gap: 4rem;
}

.contact-prompt {
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  font-size: 1rem;
  font-weight: 300;
  opacity: 0.8;
}

.cell-connect .social-links a {
  color: inherit;
}

.email-link {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.3rem, 3vw, 2.5rem);
  font-weight: 700;
  color: currentColor;
  text-decoration: none;
  border-bottom: 2px solid currentColor;
  display: inline-block;
  margin-top: 1rem;
  transition: border-bottom-width 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.email-link:hover {
  border-bottom-width: 6px;
}

.footer-control-row {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

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

.lang-btn {
  background-color: transparent;
  color: currentColor;
  border: 1px solid currentColor;
  padding: 0.4rem 0.8rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  transition: background-color 0.2s, color 0.2s;
}

.lang-btn.active {
  background-color: var(--color-black);
  color: var(--color-white);
  border-color: var(--color-black);
}

/* Invert the active language button color when cell is hovered */
.cell-connect:hover .lang-btn.active {
  background-color: var(--color-white);
  color: var(--color-black);
  border-color: var(--color-white);
}

.footer-copy {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

/* Custom Stark Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--color-white);
}

.grid-cell:hover::-webkit-scrollbar-track {
  background: var(--color-black);
}

::-webkit-scrollbar-thumb {
  background: var(--color-black);
}

.grid-cell:hover::-webkit-scrollbar-thumb {
  background: var(--color-white);
}

/* Responsive adjustments for smaller viewports */
@media (max-width: 1024px) {
  .grid-cell {
    padding: 2.5rem;
  }
  
  .cell-profile, .cell-connect {
    gap: 2.5rem;
  }

  .footer-control-row {
    gap: 1.5rem;
  }
}

@media (max-width: 480px) {
  .grid-cell {
    padding: 1.75rem;
  }
  
  .name-display {
    font-size: 2.2rem;
  }



  .canvas-container {
    min-height: 200px;
  }
}
