/**
 * Noisemaker JS Demo - Layout & Structure
 */

body {
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

/* Left panel */
#left-panel {
  position: fixed;
  top: 1rem;
  left: 1rem;
  bottom: 1rem;
  width: 500px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  border: none;
  z-index: 1000;
}

/* Canvas container */
#canvas-container {
  position: fixed;
  top: 0;
  left: calc(500px + 3rem);
  width: calc(100vw - 500px - 3rem);
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  box-sizing: border-box;
}

#canvas-container canvas {
  width: min(1024px, calc(100vw - 540px - 4rem), calc(100vh - 4rem));
  height: min(1024px, calc(100vw - 540px - 4rem), calc(100vh - 4rem));
  border: 1px solid var(--hf-border);
  box-shadow: var(--hf-shadow-md);
  background:
    repeating-conic-gradient(
      color-mix(in srgb, var(--hf-bg-surface) 60%, var(--hf-bg-base) 40%) 0% 25%,
      color-mix(in srgb, var(--hf-bg-elevated) 50%, var(--hf-bg-surface) 50%) 0% 50%
    )
    50% / 20px 20px;
}

/* Shader effect panels */
.shader-effect {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.effect-title {
  background: color-mix(
    in srgb,
    var(--hf-accent-1) var(--hf-header-opacity),
    transparent var(--hf-header-transparency)
  );
  border-bottom: 1px solid var(--hf-border);
  padding: var(--hf-space-2) var(--hf-space-3);
  font-size: var(--hf-size-sm);
  font-weight: var(--hf-weight-bold);
  color: var(--hf-text-bright);
  text-transform: var(--hf-text-transform, lowercase);
  letter-spacing: var(--hf-tracking-wide);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--hf-space-2);
  cursor: pointer;
  transition: background var(--hf-transition);
}

.effect-title-text {
  display: inline;
}

.effect-title:hover {
  background: color-mix(
    in srgb,
    var(--hf-accent-1) calc(var(--hf-header-opacity) + 5%),
    transparent calc(var(--hf-header-transparency) - 5%)
  );
}

.effect-title::before {
  content: '▼';
  font-size: 0.65rem;
  transition: transform 0.2s ease;
  order: -1;
}

.shader-effect.collapsed .effect-title::before {
  transform: rotate(-90deg);
}

/* Header effect - no collapse functionality */
#header-effect .effect-title::before {
  display: none;
}

#header-effect .effect-title {
  padding: 0.75em 0.875em;
}

#header-effect .effect-title a:hover {
  color: var(--hf-accent);
}

.effect-content {
  padding: 0.5rem;
}

.shader-effect.collapsed .effect-content {
  display: none !important;
}

/* Control group styling */
.control-group {
  display: grid;
  grid-template-columns: 80px 1fr 35px;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.control-group.control-group--full-width {
  grid-template-columns: 1fr;
}

.control-header {
  display: contents;
}

.control-label {
  font-size: var(--hf-size-sm);
  font-weight: var(--hf-weight-semibold);
  color: var(--hf-text-dim);
  text-transform: lowercase;
  letter-spacing: var(--hf-tracking-wide);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.control-value {
  font-size: var(--hf-size-xs);
  font-family: var(--hf-font-family-mono);
  color: var(--hf-text-dim);
  text-align: left;
}

/* Button row styling */
.button-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Code panel styling */
.code-content {
  background: var(--hf-bg-base);
  border: 1px solid var(--hf-border);
  border-radius: var(--hf-radius-sm);
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
}

.code-content pre {
  margin: 0;
  padding: 0.5rem;
  font-family: var(--hf-font-family-mono);
  font-size: var(--hf-size-sm);
  line-height: 1.4;
  color: var(--hf-text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Status styling */
#status {
  font-size: var(--hf-size-xs);
  font-family: var(--hf-font-family-mono);
  color: var(--hf-text-dim);
  line-height: 1.4;
  padding: 0.25rem 0;
}

/* Error banner */
#errorBanner {
  position: absolute;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  width: min(90%, 420px);
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--hf-red) 12%, var(--hf-bg-base) 88%);
  border: 1px solid color-mix(in srgb, var(--hf-red) 40%, transparent 60%);
  border-radius: var(--hf-radius-sm);
  color: color-mix(in srgb, var(--hf-red) 35%, var(--hf-text-normal) 65%);
  font-size: var(--hf-size-sm);
  white-space: pre-wrap;
  z-index: 1001;
}

#errorBanner:empty {
  display: none;
}

/* Loading overlay */
#loadingOverlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--hf-bg-base) 90%, transparent 10%);
  backdrop-filter: var(--hf-glass-blur-sm);
  padding: 1rem 1.5rem;
  border-radius: var(--hf-radius);
  border: 1px solid var(--hf-border);
  box-shadow: var(--hf-shadow-lg);
  font-size: var(--hf-size-base);
  color: var(--hf-accent);
  font-weight: var(--hf-weight-semibold);
  pointer-events: none;
  z-index: 1000;
}

/* Field row for inline inputs */
.field-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--hf-size-sm);
  color: var(--hf-text-normal);
}

.inline-field span {
  color: var(--hf-text-dim);
  font-size: var(--hf-size-xs);
  text-transform: lowercase;
}

.inline-field input {
  width: 4.5rem;
}

/* Ecosystem info text */
.noisemaker-info {
  font-size: var(--hf-size-xs);
  color: color-mix(in srgb, var(--hf-text-dim) 60%, transparent 40%);
  line-height: 1.4;
  padding: 0.5rem 0.5rem 0.75rem;
  text-align: center;
}

.noisemaker-info a {
  color: var(--hf-accent);
  text-decoration: none;
}

.noisemaker-info a:hover {
  opacity: 0.8;
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  font-size: var(--hf-size-sm);
  color: var(--hf-text-dim);
}

/* Responsive: mobile — exact noisedeck pattern */
@media (max-width: 960px) {
  body {
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
  }

  #app-container {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh;
    height: 100dvh;
  }

  #canvas-container {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: calc(100dvh * var(--mobile-canvas-fraction, 0.35)) !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    order: -1;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #canvas-container canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    border: none !important;
    box-shadow: none !important;
  }

  #mobile-divider {
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: row-resize;
    touch-action: none;
    user-select: none;
    flex-shrink: 0;
  }

  #mobile-divider::after {
    content: '';
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--hf-accent);
  }

  #left-panel {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    bottom: auto !important;
    width: 100% !important;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
  }

  #errorBanner {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    width: 100%;
  }

  #loadingOverlay {
    position: fixed;
  }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 961px) {
  #mobile-divider {
    display: none;
  }
}
