/* 
 * Apollonian Gasket Visualizer Stylesheet.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg-workspace: #040406;
  --panel-bg: rgba(10, 10, 12, 0.82);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-hover: rgba(255, 255, 255, 0.18);
  --text-primary: #f4f4f5;
  --text-secondary: rgba(244, 244, 245, 0.65);
  --text-muted: rgba(244, 244, 245, 0.45);
  --accent: #22d3ee;
  --accent-hover: #67e8f9;
  --accent-glow: rgba(34, 211, 238, 0.25);
  
  --input-bg: rgba(255, 255, 255, 0.03);
  --input-bg-hover: rgba(255, 255, 255, 0.05);
  --input-border: rgba(255, 255, 255, 0.06);
  --input-border-hover: rgba(255, 255, 255, 0.12);
  
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", SFMono-Regular, monospace;
  
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-panel: 0 24px 70px rgba(0, 0, 0, 0.75);
  --shadow-hud: 0 4px 16px rgba(0, 0, 0, 0.4);
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-workspace);
  color: var(--text-primary);
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Glassmorphism Floating Control Panel */
.studio {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 360px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(24px) saturate(130%);
  -webkit-backdrop-filter: blur(24px) saturate(130%);
  z-index: 10;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), 
              opacity 0.35s ease,
              border-color 0.3s ease;
}

.studio:hover {
  border-color: var(--panel-border-hover);
}

/* Panel Collapse States */
.studio.is-collapsed {
  transform: translateX(calc(100% + 40px)) scale(0.96);
  opacity: 0;
  pointer-events: none;
}

/* Panel Header styling */
.studio__header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.studio__badge {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(34, 211, 238, 0.04);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  align-self: flex-start;
}

.studio__title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.studio__subtitle {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* Scroll Area for configs */
.studio__scroll-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 24px;
  overflow-y: auto;
}

/* Scrollbar customizations */
.studio__scroll-area::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.studio__scroll-area::-webkit-scrollbar-track {
  background: transparent;
}

.studio__scroll-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.studio__scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Section columns layout */
.studio__section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

/* Core grid layout of designer swatches */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}

/* A highly luxurious split circle choice button */
.swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--input-border);
  background: var(--swatch-bg);
  cursor: pointer;
  position: relative;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              border-color 0.2s ease,
              box-shadow 0.2s ease;
}

.swatch:hover {
  transform: scale(1.12);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

.swatch.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(239, 223, 182, 0.25), 
              0 0 8px rgba(259, 223, 182, 0.35);
  transform: scale(1.12);
  z-index: 2;
}

.swatch__inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--swatch-bg);
}

.swatch__dot {
  width: 55%;
  height: 55%;
  border-radius: 50%;
  background: var(--swatch-circle);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* Compact alternative picker */
.color-pickers-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compact-color {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.compact-color:hover {
  border-color: var(--input-border-hover);
  background: var(--input-bg-hover);
}

.compact-color__swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Direct input color hack */
.compact-color__swatch input[type="color"] {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  cursor: pointer;
}

.compact-color__info {
  display: flex;
  flex-direction: column;
}

.compact-color__label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.compact-color__value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
}

/* Tactile numeric and range input packaging */
.control-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  transition: border-color 0.2s ease;
}

.control-box:hover {
  border-color: var(--input-border-hover);
}

.control-box__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-box__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.control-box__inputs {
  display: flex;
  align-items: center;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

/* Stepper trigger */
.stepper-btn {
  width: 28px;
  height: 28px;
  border: 0;
  margin: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.stepper-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent);
}

.stepper-btn:active {
  background: rgba(255, 255, 255, 0.1);
}

.number-input {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--input-border);
  border-right: 1px solid var(--input-border);
  background: transparent;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}

.number-input.wide-input {
  width: 44px;
}

.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Custom sliders */
.slider-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  margin: 6px 0 2px;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-workspace);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  background: var(--accent-hover);
}

.control-box__desc {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-muted);
}

/* Elegant styled speed layout */
.toggle-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
}

.toggle-card__main {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-card__main input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Create an elegant slide switch instead of default box */
.toggle-card__main::before {
  content: "";
  display: block;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.25s ease, border-color 0.25s ease;
  position: relative;
}

.toggle-card__main::after {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  position: absolute;
  left: 20px;
  /* alignment */
  transform: translateX(25px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.25s ease;
}

.toggle-card__main:has(input[type="checkbox"]:checked)::before {
  background: rgba(239, 223, 182, 0.15);
  border-color: rgba(239, 223, 182, 0.3);
}

.toggle-card__main:has(input[type="checkbox"]:checked)::after {
  background: var(--accent);
  transform: translateX(40px);
}

.toggle-card__text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.toggle-card__sub {
  border-top: 1px dashed rgba(255, 255, 255, 0.04);
  padding-top: 10px;
  transition: opacity 0.2s ease, max-height 0.25s ease;
}

.toggle-card:has(input[type="checkbox"]:not(:checked)) .toggle-card__sub {
  opacity: 0.35;
  pointer-events: none;
}

.speed-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.speed-control__label {
  font-size: 0.74rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.thin-slider {
  margin: 0;
  height: 4px;
}

/* Stylized checkboxes: Beautiful Custom Segmented Pills */
.style-checkboxes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.custom-pill {
  position: relative;
  cursor: pointer;
}

.custom-pill input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.custom-pill__button {
  display: block;
  padding: 8px 6px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 500;
  text-align: center;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.custom-pill:hover .custom-pill__button {
  border-color: var(--input-border-hover);
  background: var(--input-bg-hover);
  color: var(--text-primary);
}

.custom-pill input[type="checkbox"]:checked + .custom-pill__button {
  background: rgba(239, 223, 182, 0.08);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Floating Action Camera Controller */
.floating-action {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(10, 10, 12, 0.85);
  color: var(--accent);
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              border-color 0.25s ease, 
              color 0.25s ease;
}

.floating-action:hover {
  transform: scale(1.05);
  border-color: var(--accent);
  color: #fff;
}

.floating-action:active {
  transform: scale(0.96);
}

/* Integrated Diagnostic Stats Panel */
.studio__footer {
  padding: 18px 24px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.stats-panel__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stats-panel__grid {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 1.1fr;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.02);
  background: rgba(0, 0, 0, 0.18);
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric__label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric__value {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
}

.interaction-tip {
  font-size: 0.68rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
}

/* Studio Toggle Floating Trigger */
.studio-toggle {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.25s ease, 
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s ease;
}

.studio-toggle:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

/* Hide toggle unless panel is collapsed */
.studio:not(.is-collapsed) ~ .studio-toggle {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9) translateY(-10px);
}

.toggle-icon {
  transition: transform 0.4s ease;
}

.studio-toggle:hover .toggle-icon {
  transform: rotate(35deg);
}

/* Responsive constraints */
@media (max-width: 640px) {
  .studio {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: 48vh;
  }
  
  .studio-toggle {
    top: 12px;
    right: 12px;
    bottom: auto;
  }
  
  .floating-action {
    bottom: calc(48vh + 24px);
    left: 50%;
    transform: translateX(-50%);
  }
  .floating-action:hover {
    transform: translateX(-50%) scale(1.05);
  }
  .floating-action:active {
    transform: translateX(-50%) scale(0.96);
  }
}
