@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@700;900&display=swap");

* {
  box-sizing: border-box;
}
body {
  background: #0a0a0a;
  color: white;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  margin: 0;
}
h2 {
  margin: 0 0 35px 0;
  font-size: 32px;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  color: #00ff00;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}
.canvas-wrapper {
  margin-bottom: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  width: 100%;
  max-width: 960px;
  height: min(70vh, 760px);
  aspect-ratio: var(--canvas-aspect, 1 / 1);
  transition: height 0.2s ease;
}
canvas {
  border: 2px solid #333;
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.1);
  display: block;
}
/* Ensure p5 canvas centers and scales nicely */
#canvas-container {
  display: flex;
  justify-content: center;
  align-items: center;
}
#canvas-container canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}
.controls-container {
  width: 100%;
  max-width: 900px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 20px;
}
.controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.controls-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #7f7f7f;
  font-weight: 700;
}
#controlsToggleBtn {
  font-size: 11px;
  padding: 6px 10px;
  border-color: #00ccff;
  color: #00ccff;
}
#controlsToggleBtn:hover {
  background: #00ccff;
  color: #000;
}
.control-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #333;
}
.control-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.section-title {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  font-weight: 600;
}
.control-row {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}
.control-group {
  display: flex;
  gap: 8px;
  align-items: center;
}
.control-group.full {
  flex: 1;
  min-width: 200px;
}
label {
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  white-space: nowrap;
  min-width: 75px;
}
input[type="file"],
input[type="range"],
select,
button {
  padding: 8px 12px;
  background: #282828;
  color: white;
  border: 1px solid #444;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
input[type="range"] {
  flex: 1;
  min-width: 100px;
  cursor: pointer;
}
select {
  min-width: 80px;
}
button {
  white-space: nowrap;
  color: #00ff00;
  font-weight: 600;
  border-color: #00ff00;
}
button:hover {
  background: #00ff00;
  color: #000;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}
button:active {
  transform: scale(0.98);
}
#playBtn {
  min-width: 60px;
  padding: 8px 20px;
  font-size: 13px;
}
#fullscreenBtn {
  min-width: 100px;
}
.time-display {
  font-size: 11px;
  color: #888;
  min-width: 60px;
  text-align: center;
}
.preset-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.preset-btn {
  padding: 6px 12px;
  font-size: 11px;
  color: #00ccff;
  border-color: #00ccff;
  flex: 0 1 auto;
}
.preset-btn:hover {
  background: #00ccff;
  color: #000;
}
.slider-value {
  font-size: 11px;
  color: #00ff00;
  font-weight: 600;
  min-width: 35px;
  text-align: center;
}
.grid-options {
  display: flex;
  gap: 12px;
  align-items: center;
}
#videoInput::file-selector-button {
  background: #282828;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 10px;
}
#videoInput::file-selector-button:hover {
  background: #333;
}
#canvas-container:fullscreen {
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
}
#canvas-container:fullscreen canvas {
  max-width: 100vw;
  max-height: 100vh;
}
footer {
  width: 100%;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #333;
  font-size: 12px;
  color: #888;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  text-align: center;
}
footer a {
  color: #00ff00;
  text-decoration: none;
  transition: color 0.2s ease;
  display: inline-block;
}
footer a:hover {
  color: #00ccff;
}

/* GitHub corner ribbon */
.github-corner {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1000;
}
.github-corner:hover .octo-arm {
  animation: octocat-wave 560ms ease-in-out;
}
@keyframes octocat-wave {
  0%,
  100% {
    transform: rotate(0);
  }
  20%,
  60% {
    transform: rotate(-25deg);
  }
  40%,
  80% {
    transform: rotate(10deg);
  }
}
@media (max-width: 500px) {
  .github-corner:hover .octo-arm {
    animation: none;
  }
  .github-corner .octo-arm {
    animation: octocat-wave 560ms ease-in-out;
  }
}

/* App layout: canvas + controls sidebar */
.app {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
  max-width: 1200px;
}
.canvas-area {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
}
.controls-area {
  flex: 0 0 320px;
  max-width: 365px;
}
.controls-container {
  position: sticky;
  top: 20px;
  width: 100%;
  box-sizing: border-box;
}

body.controls-collapsed .control-section {
  display: none;
}
body.controls-collapsed .control-section.playback-section {
  display: block;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
body.controls-collapsed .controls-container {
  padding: 12px 16px;
}
body.controls-collapsed .controls-header {
  margin-bottom: 10px;
}

/* Mobile: controls on top, stable canvas below */
@media (max-width: 800px) {
  .app {
    flex-direction: column;
  }
  .controls-area {
    position: static;
    flex: none;
    width: 100%;
    max-width: none;
    order: -1;
  }
  .controls-container {
    position: static;
    border-radius: 12px;
    margin: 0;
    padding: 14px;
    max-width: none;
  }
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .canvas-wrapper {
    margin-bottom: 12px;
    height: min(55dvh, 420px);
    max-width: 100%;
  }
  body.controls-collapsed .controls-container {
    padding-bottom: 10px;
  }
  body.controls-collapsed .app {
    gap: 8px;
  }
  body.controls-collapsed .canvas-wrapper {
    height: min(40dvh, 300px);
    align-items: flex-start;
  }
  body.controls-collapsed #canvas-container {
    align-items: flex-start;
    justify-content: flex-start;
  }
  .github-corner svg {
    width: 56px;
    height: 56px;
  }
  .playback-section .control-row {
    flex-direction: column;
    align-items: stretch;
  }
  .playback-section .control-group.full {
    min-width: 0;
    width: 100%;
  }
  .playback-section #playBtn {
    width: 100%;
  }
}
