/* =========================================================
   MATRIX RAIN STUDIO
   By Fotios Mpouris · matrix.fotiosmpouris.com
   ========================================================= */

:root {
  --accent: #00ff41;
  --accent-dim: #00ff4180;
  --bg: #000;
  --panel: rgba(8, 12, 8, 0.92);
  --panel-border: rgba(0, 255, 65, 0.25);
  --text: #d8ffd8;
  --text-dim: #8ab38a;
  --text-bright: #fff;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Canvas ===== */
#rain-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  cursor: crosshair;
}

/* ===== Brand Corner ===== */
.brand-corner {
  position: fixed;
  top: 18px;
  left: 22px;
  z-index: 10;
  text-decoration: none;
  color: var(--text-dim);
  font-family: "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0.5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  transition: color 0.3s;
}
.brand-corner:hover { color: var(--accent); }
.brand-name { font-weight: bold; }
.brand-tagline { font-size: 10px; opacity: 0.7; }

/* ===== Studio Toggle Button ===== */
.studio-toggle {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--accent);
  padding: 10px 16px;
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-transform: uppercase;
  transition: all 0.2s;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
}
.studio-toggle:hover {
  background: rgba(0, 255, 65, 0.1);
  box-shadow: 0 0 24px rgba(0, 255, 65, 0.3);
  transform: translateY(-1px);
}
.toggle-icon { font-size: 16px; }

/* ===== Hint Banner ===== */
.hint {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  color: var(--text-dim);
  font-family: "Courier New", monospace;
  font-size: 12px;
  text-align: center;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 24px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  transition: opacity 1.5s;
  opacity: 1;
}
.hint.fade { opacity: 0; }
.hint kbd {
  display: inline-block;
  background: rgba(0, 255, 65, 0.12);
  border: 1px solid var(--panel-border);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
  margin: 0 2px;
}

/* ===== Studio Panel ===== */
.studio {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 380px;
  max-width: 100vw;
  background: var(--panel);
  border-left: 1px solid var(--panel-border);
  z-index: 30;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
}
.studio.open { transform: translateX(0); }

.studio-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.studio-header h1 {
  font-family: "Courier New", monospace;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 1px;
  font-weight: bold;
  text-transform: uppercase;
}
.studio-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.3px;
}

.studio-close {
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 22px;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s;
}
.studio-close:hover {
  background: rgba(255, 60, 60, 0.15);
  border-color: rgba(255, 60, 60, 0.5);
  color: #ff6060;
}

.studio-body {
  padding: 18px 22px 22px;
  overflow-y: auto;
  flex: 1;
}
.studio-body::-webkit-scrollbar { width: 6px; }
.studio-body::-webkit-scrollbar-track { background: transparent; }
.studio-body::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 3px; }

/* ===== Control Blocks ===== */
.control-block {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px dashed rgba(0, 255, 65, 0.1);
}
.control-block:last-child { border-bottom: none; padding-bottom: 0; }

.control-label {
  display: flex;
  justify-content: space-between;
  font-family: "Courier New", monospace;
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  font-weight: bold;
}
.control-value {
  color: var(--text);
  font-weight: normal;
  background: rgba(0, 255, 65, 0.08);
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 11px;
}

/* ===== Charset Buttons ===== */
.charset-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.cs-btn {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 255, 65, 0.2);
  color: var(--text);
  padding: 9px 10px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.18s;
  text-align: left;
}
.cs-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 255, 65, 0.06);
}
.cs-btn.active {
  background: rgba(0, 255, 65, 0.18);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.3);
}

.custom-text-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 255, 65, 0.2);
  color: var(--text);
  padding: 9px 12px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  border-radius: 3px;
  outline: none;
  transition: border-color 0.2s;
}
.custom-text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.2);
}
.custom-text-input::placeholder { color: var(--text-dim); }

/* ===== Color Swatches ===== */
.color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: var(--swatch);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
  position: relative;
  box-shadow: 0 0 10px var(--swatch);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 14px var(--swatch), 0 0 0 2px rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}
.color-custom {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px dashed rgba(0, 255, 65, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 18px;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
}
.color-custom:hover { border-color: var(--accent); transform: scale(1.1); }
.color-custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  border: none;
}

/* ===== Range sliders ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(0, 255, 65, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent);
  transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent);
}

/* ===== Checkboxes ===== */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text);
}
.checkbox-row:last-child { margin-bottom: 0; }
.checkbox-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: all 0.15s;
}
.checkbox-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-row input[type="checkbox"]:checked::after {
  content: "✓";
  color: #000;
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
}

/* ===== Action Buttons ===== */
.actions { display: flex; flex-direction: column; gap: 8px; }
.action-btn {
  background: rgba(0, 255, 65, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 11px 14px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}
.action-btn:hover {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 14px rgba(0, 255, 65, 0.5);
}
.action-btn.ghost {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--text-dim);
}
.action-btn.ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: var(--text);
  box-shadow: none;
}

/* ===== Footer ===== */
.studio-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed rgba(0, 255, 65, 0.15);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
}
.studio-footer a { color: var(--accent); text-decoration: none; }
.studio-footer a:hover { text-decoration: underline; }
.footer-meta { font-size: 10px; opacity: 0.7; margin-top: 4px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 12px 20px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.2);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
  .studio {
    width: 100vw;
    height: 80vh;
    top: auto;
    bottom: 0;
    border-left: none;
    border-top: 1px solid var(--panel-border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .studio.open { transform: translateY(0); }
  .studio-toggle {
    bottom: 18px;
    top: auto;
    right: 18px;
    padding: 12px 18px;
  }
  .brand-corner { font-size: 11px; }
  .brand-tagline { display: none; }
  .hint {
    bottom: 80px;
    font-size: 10px;
    padding: 8px 14px;
  }
  .hint kbd { display: none; }
  .charset-buttons { grid-template-columns: 1fr 1fr 1fr; }
  .color-swatch, .color-custom { width: 40px; height: 40px; }
}

/* Hide hint on small screens after a moment, anyway */
@media (hover: none) {
  .hint p::before {
    content: "Tap ⚙ to open Studio";
  }
  .hint p { display: none; }
  .hint p::before { display: block; }
}
