/* ==========================================================================
   ART — Swiss/Minimal Style
   ========================================================================== */

/* Hide audio controls when inside iframe (SPA mode) */
html.in-iframe #playButton,
html.in-iframe #bgAudio,
html.in-iframe .audio-visualizer,
html.in-iframe .side-control--audio {
  display: none !important;
}

:root {
  --bg: #fff;
  --fg: #000;
  --muted: #555;
  --border: #e0e0e0;
  --side-logo-w: 40.25px;
  --side-logo-top: 20px;
  --side-logo-pad: 73.6px;
  --side-footer-bottom: calc(20px + var(--nmz-safe-bottom, 0px) + var(--nmz-browser-bottom, 0px));
  --social-invert: 0;
}

html {
  min-height: 100%;
  background: var(--bg);
}

html[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #fff;
  --muted: #a0a0a0;
  --border: #333;
  --social-invert: 1;
}

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

h1 {
  font-size: inherit;
  font-weight: inherit;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: var(--nmz-content-vh, 100vh);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: none;
}

body.loaded {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   Page Loader
   ========================================================================== */
.page-loader {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  min-height: var(--nmz-content-vh, 100vh);
  background: var(--fg);
  z-index: 9998;
  transition: opacity 0.6s ease;
  will-change: opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.page-loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   Scroll Progress Indicator
   ========================================================================== */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--fg);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 200;
  pointer-events: none;
}

/* ==========================================================================
   Floating Title (animació d'entrada)
   ========================================================================== */
.floating-title {
  position: fixed;
  z-index: 10000;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-size-adjust: 0.52;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 0.9;
  color: var(--bg);
  margin: 0;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: top 0.6s ease, transform 0.6s ease, opacity 0.24s ease;
}

.floating-title.skip-animation {
  transition: opacity 0.24s ease;
  top: 128px;
  transform: translate(-50%, 0);
  color: var(--fg);
  position: absolute;
}

body.shell-title-pending .floating-title.skip-animation {
  opacity: 0;
  pointer-events: none;
}

.floating-title.in-position {
  top: 128px;
  transform: translate(-50%, 0);
}

.floating-title.colored {
  color: var(--fg);
}

.floating-title.settled {
  position: absolute;
}

@media (max-width: 768px) {
  .floating-title {
    font-size: 36px;
  }
  .floating-title.skip-animation,
  .floating-title.in-position {
    top: calc(0px + var(--nmz-safe-top, 0px));
  }
}

/* ==========================================================================
   Side Logo (rotated vertical)
   ========================================================================== */
.side-logo {
  position: fixed;
  left: 0;
  top: calc(var(--side-logo-top) + var(--nmz-safe-top, 0px));
  z-index: 101;
  background: var(--fg);
  padding: var(--side-logo-pad) 0;
  width: var(--side-logo-w);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-decoration: none;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.4s cubic-bezier(.4,0,.2,1), transform 0.4s cubic-bezier(.4,0,.2,1);
}

.side-logo svg {
  width: 142.6px;
  height: 16.1px;
  transform: rotate(-90deg);
  flex-shrink: 0;
}

.side-logo svg path,
.side-logo svg polygon,
.side-logo svg circle {
  fill: var(--bg);
}

@media (max-width: 991px) {
  :root {
    --side-logo-w: 42px;
    --side-logo-pad: 80px;
  }

  .side-logo svg {
    width: 132px;
    height: 14.8px;
  }
}

@media (max-width: 480px) {
  :root {
    --side-logo-w: 36px;
    --side-logo-pad: 68px;
  }
}

/* ==========================================================================
   Side Copyright (vertical)
   ========================================================================== */
.side-copy {
  position: fixed;
  left: calc(var(--side-logo-w) / 2 + 14px);
  bottom: var(--side-footer-bottom);
  width: var(--side-logo-w);
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--fg);
  opacity: 0.7;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  pointer-events: none;
  z-index: 171;
  transform: translateX(-50%) rotate(180deg);
  transform-origin: center;
  transition: opacity 0.4s ease;
}

.side-copy-heart {
  display: inline-block;
  transform: rotate(90deg) translateY(2px);
}

html[data-theme="dark"] .side-copy {
  opacity: 0.6;
}

@media (max-width: 991px) {
  .side-copy {
    left: calc(var(--side-logo-w) / 2 + 10px);
    bottom: var(--side-footer-bottom);
  }
}

/* ==========================================================================
   Side Controls (dreta)
   ========================================================================== */
.side-controls {
  position: fixed;
  right: calc(20px + var(--nmz-safe-right, 0px));
  top: calc(20px + var(--nmz-safe-top, 0px));
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-control {
  width: 48px;
  height: 48px;
  background: var(--bg);
  border: 1px solid var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
  transition: background 0.2s ease, color 0.2s ease;
}

#playButton {
  position: fixed;
  right: calc(20px + var(--nmz-safe-right, 0px));
  bottom: var(--side-footer-bottom);
  top: auto;
  z-index: 140;
}

.side-control:hover {
  background: var(--fg);
}

.side-control img {
  width: 24px;
  height: 24px;
  filter: invert(var(--social-invert));
  transition: filter 0.2s ease;
}

.side-control:hover img {
  filter: invert(calc(1 - var(--social-invert)));
}

.side-control svg {
  width: 24px;
  height: 24px;
  fill: var(--fg);
  stroke: var(--fg);
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.side-control:hover svg {
  fill: var(--bg);
  stroke: var(--bg);
}

.side-control--back svg path {
  fill: var(--fg);
  stroke: none;
  transition: fill 0.2s ease;
}

.side-control--back:hover svg path {
  fill: var(--bg);
}

/* Tooltip for back button */
.side-control--back::after {
  content: attr(aria-label);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.side-control--back:hover::after {
  opacity: 1;
}

.side-control .play-icon {
  stroke: none;
}

.side-control .theme-icon path:first-child {
  fill: none;
}

/* Audio Visualizer inside play button */
.side-control .audio-visualizer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.side-control .audio-visualizer.active {
  opacity: 1;
}

.side-control .viz-bar {
  width: 3px;
  height: 100%;
  background: var(--fg);
  animation: vizPulse 0.8s ease-in-out infinite alternate;
}

.side-control:hover .viz-bar {
  background: var(--bg);
}

.side-control .viz-bar:nth-child(1) { animation-delay: 0s; }
.side-control .viz-bar:nth-child(2) { animation-delay: 0.15s; }
.side-control .viz-bar:nth-child(3) { animation-delay: 0.3s; }
.side-control .viz-bar:nth-child(4) { animation-delay: 0.45s; }
.side-control .viz-bar:nth-child(5) { animation-delay: 0.6s; }

@keyframes vizPulse {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

/* Pending state: esperant interaccio per reproduir */
.side-control .audio-visualizer.pending {
  animation: pendingPulse 1s ease-in-out infinite;
}

@keyframes pendingPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@media (max-width: 991px) {
  #playButton {
    right: calc(20px + var(--nmz-safe-right, 0px));
    bottom: var(--side-footer-bottom);
  }
}

/* Hover: transform to pause icon */
.side-control:hover .audio-visualizer.active {
  gap: 4px;
}

.side-control:hover .audio-visualizer.active .viz-bar:nth-child(1),
.side-control:hover .audio-visualizer.active .viz-bar:nth-child(3),
.side-control:hover .audio-visualizer.active .viz-bar:nth-child(5) {
  opacity: 0;
  width: 0;
}

.side-control:hover .audio-visualizer.active .viz-bar:nth-child(2),
.side-control:hover .audio-visualizer.active .viz-bar:nth-child(4) {
  width: 3px;
  height: 14px;
  animation: none;
  transform: scaleY(1);
  border-radius: 1px;
}

/* Hero */
.art-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 120px 32px 60px;
  border-bottom: 1px solid var(--border);
}

/* Placeholder per l'espai del títol flotant */
.art-title-placeholder {
  height: 48px;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .art-title-placeholder {
    height: 28px;
  }
}

.art-subtitle {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: transparent;
  letter-spacing: 0.02em;
  transition: color 0.5s ease 0.4s;
}

.art-subtitle.visible {
  color: var(--muted);
}

.art-subtitle.skip-animation {
  transition: none;
  color: var(--muted);
}

/* Project Grid */
.art-grid {
  display: grid;
  grid-template-columns: 1fr;
  padding-left: var(--side-logo-w);
}

@media (min-width: 992px) {
  .art-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.project-card {
  border-bottom: 1px solid var(--border);
}

.project-link {
  display: grid;
  grid-template-columns: 80px 1fr 40px;
  align-items: center;
  gap: 32px;
  padding: 32px;
  text-decoration: none;
  color: var(--fg);
  transition: background 0.2s ease, color 0.2s ease;
}

.project-link:hover {
  background: var(--fg);
  color: var(--bg);
}

.project-link:hover .project-meta,
.project-link:hover .project-desc {
  color: var(--bg);
  opacity: 0.7;
}

.project-number {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  opacity: 0.5;
}

.project-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-title {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.project-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.project-desc {
  font-size: 14px;
  color: var(--muted);
  max-width: 400px;
  transition: color 0.2s ease;
}

/* Coming soon / disabled projects */
.project-card--disabled {
  opacity: 0.4;
}

.project-card--disabled .project-link {
  pointer-events: none;
  cursor: default;
}

.project-card--disabled .project-link:hover {
  background: transparent;
  color: var(--fg);
}

.project-card--disabled .project-link:hover .project-meta,
.project-card--disabled .project-link:hover .project-desc {
  color: var(--muted);
  opacity: 1;
}

.project-arrow {
  font-size: 24px;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.project-link:hover .project-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --side-logo-w: 38px;
    --side-logo-top: 0px;
    --side-logo-pad: 74px;
    --side-logo-right-pad: 12px;
  }

  .side-controls {
    top: calc(0px + var(--nmz-safe-top, 0px));
    bottom: auto;
    right: calc(20px + var(--nmz-safe-right, 0px));
    flex-direction: column;
  }

  .side-control {
    width: 44px;
    height: 44px;
  }

  .page-loader {
    transition: none;
  }

  .art-hero {
    padding: 16px 20px 32px calc(20px + var(--side-logo-w) + var(--side-logo-right-pad));
  }

  .art-subtitle {
    transform: translateX(calc(-0.5 * (var(--side-logo-w) + var(--side-logo-right-pad))));
  }

  .art-grid {
    padding-left: calc(var(--side-logo-w) + var(--side-logo-right-pad));
  }

  .project-link {
    display: grid !important;
    grid-template-columns: 40px 1fr 24px;
    gap: 16px;
    padding: 24px 20px;
    align-items: center;
  }

  .project-number {
    font-size: 12px;
  }

  .project-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
  }

  .project-title {
    font-size: 18px;
    text-align: left;
  }

  .project-meta {
    font-size: 12px;
    text-align: left;
  }

  .project-desc {
    font-size: 13px;
    display: block;
    color: var(--fg);
    text-align: left;
  }

  .project-arrow {
    justify-self: end;
    align-self: center;
    opacity: 0.3;
    transform: none;
  }
}

/* Hide social links (Instagram, LinkedIn) on mobile - only show on home */
@media (max-width: 991px) {
  .side-control[href*="instagram"],
  .side-control[href*="linkedin"] {
    display: none !important;
  }
}
