:root {
  --vh: 1vh;
  /*--vw: 1vw;*/
}


@font-face {
    font-family: "Fira Mono";
    src: url("./fonts/FiraMono-Regular.ttf") format("truetype");
    font-weight: 400;
}

@font-face {
    font-family: "Fira Mono";
    src: url("./fonts/FiraMono-Medium.ttf") format("truetype");
    font-weight: 500;
}

@font-face {
    font-family: "Fira Mono";
    src: url("./fonts/FiraMono-Bold.ttf") format("truetype");
    font-weight: 700;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

body {
    background: #111;
    color: white;
    font-family: "Fira Mono", monospace, sans-serif;
    margin: 0;
    overflow: hidden;
    height: 100vh;
}

#mainLayout {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    width: 100%;
    height: 100%;
    min-width: 600px; /* Prevent extreme collapse */
    overflow: hidden;
}

#glitchCanvas {
    margin: 0;
}

/* Snap container to bottom of viewport */
#mobile-topbar-target {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #111;
  padding: 0.5em 0.75em;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em;
}

#topBar {
  display: flex;
  gap: 0.5em;
  align-items: center;
  padding: 0.5em;
  background: #222;
  color: white;
  font-size: 0.9em;
  border-bottom: 1px solid #444;
  height: 2em;
}
#topBar input[type="file"] {
  color: white;
}
#topBar button, #topBar select {
  font-size: 0.9em;
width: fit-content;
}
#topBar.mobile {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em;
  padding: 0.5em;
  background: #111;
  color: white;
  font-size: 2em;
  height: fit-content;
  /*text-size-adjust: 100%;*/
}
#topBar.mobile button,
#topBar.mobile select,
#topBar.mobile label {
  /*font-size: 1em;*/
  padding: 0.4em 0.8em;
  border-radius: 4px;
  background: #333;
  color: #eee;
  border: none;
}
#topBar.mobile select {
  width: auto;
  min-width: 6em;
  max-width: 6em;
  /*font-size: 0.95em;*/
}

/* Optional: compress select elements a bit */
#topBar.mobile select {
  min-width: 8em;
}

#freezeAnimation.frozen {
    background: #d22;
}

/* The wrapper only exists to hide the button with its "||" separator; when
   shown, lay both out as ordinary top-bar flex items. */
#freezeAnimationGroup:not([hidden]) {
    display: contents;
}


#exportControls {
  background: #222;
  color: white;
  padding: 0.5em;
  border-bottom: 1px solid #444;
  ;
  font-size: 0.9em;
}

.export-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  align-items: center;
  margin-top: 0.5em;
}

.export-group label {
  display: flex;
  flex-direction: column;
  font-size: 0.85em;
}

.export-buttons {
  display: flex;
  gap: 0.5em;
}

/* Modal styles */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 9999; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  background-color: rgba(0, 0, 0, 0.6); /* Darker, more visible backdrop */
  overflow: auto; /* Enable scrolling if needed */
}

/* Modal content */
.modal-content {
  background-color: #2c3e50; /* Dark background for better contrast */
  color: #ecf0f1; /* Light text color */
  margin: 10% auto;
  padding: 30px;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Close button */
.close-btn {
  color: #ecf0f1;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
  color: #e74c3c;
  cursor: pointer;
}

/* Modal headings */
h2 {
  font-size: 1.6em;
  margin-bottom: 15px;
}

/* Grouped form elements */
.export-group {
  margin-bottom: 15px;
}

.export-group label {
  font-weight: bold;
  display: block;
  margin-bottom: 5px;
}

.export-group input, .export-group select {
  width: 100%;
  padding: 10px;
  font-size: 1em;
  margin: 5px 0;
  border-radius: 4px;
  border: 1px solid #bdc3c7;
}

.export-buttons {
  display: flex;
  justify-content: space-between;
}

.export-buttons button {
  background-color: #3498db;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.export-buttons button:disabled {
  background-color: #7f8c8d;
}

.export-buttons button:hover {
  background-color: #2980b9;
}

#captureOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.8);
  color: white;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlayMessage {
  text-align: center;
  font-size: 1.2em;
}
.overlayMessage button {
  font-size: 1em;
  margin-top: 1em;
}

input, select, textarea, button {
    font-size: 0.9em;
}

#dragBar {
    width: 5px;
    background: #333;
    cursor: ew-resize;
    flex-shrink: 0;
    z-index: 10;
}

#leftPane {
    flex: 0 0 70%;
    max-width: calc(100% - 50px);
    padding: 0;
    text-align: center;
    overflow-x: clip;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    min-width: 100px;
}

#rightPane {
    width: 300px;
    height: calc(100vh - 2.5em);
    flex: 1 1 0;
    min-width: 300px;
    max-width: 100vw;
    background: #222;
    color: white;
    padding: 0;
    border-left: 1px solid #444;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#effectStackHeader {
    padding: 0 0.2em 0.2em 0.2em;
    background: #222;
    border-bottom: 1px solid #444;
    display: flex;
    flex-direction: column;
    gap: 1em;
    overflow-x: hidden;
    /*overflow-y: auto;*/
    flex-shrink: 1;
    flex-grow: 1;
    min-height: 0; /* Allow shrinking */
    max-height: 100%;
    transition: all 0.05s ease;
}

#effectStack {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.1em;
    max-height: 70%;
    flex-shrink: 0;
  transition: all 0.05s ease;
}

.toggle-bar {
  background-color: #333;
  color: white;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.arrow {
  display: inline-block;
  font-size: 1em;
}

#effectStack.collapsed {
  max-height: 20%;
}

.collapsed.toggle-bar .arrow {
  transform: rotate(180deg); /* Rotate arrow */
}

.file-upload-button {
  background: #333;
  color: #eee;
  padding: 0.4em 0.8em;
  border-radius: 4px;
  font-size: 1em;
  cursor: pointer;
  border: none;
}


.effect-config {
  background: #1a1a1a;
  padding: 0.5em;
}

#configForm {
    flex: 1 1 auto;
    padding: 0.5em;
    background: #1a1a1a;
    border-radius: 6px;
    border: 1px solid #333;
}



#effectControls label:empty {
    display: none;
}

#effectControls {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-wrap: nowrap;
}

#addEffect {
    background: #222;
    z-index: 1;
    color: #eee;
    border: 1px solid #666;
    border-radius: 4px;
    font-size: 1.1em;
    line-height: 1.3em;
    height: 1.7em;
    box-sizing: border-box;
    appearance: none;
}

#addEffect:focus {
    border-color: #aaa;
    background-color: #2a2a2a;
}

#addEffectBtn {
  font-size: 1.2em;
  font-weight: 700;
  width: 1.6em;
  height: 1.6em;
  margin-right: 0.4em;
  background-color: #2ecc71; /* vibey console green */
  border: none;
  border-radius: 4px;
  color: black;
  cursor: pointer;
  transition: background 0.2s;
}

#addEffectBtn:hover {
  background-color: #27ae60;
}

canvas {
    display: block;
    margin: 0;
    flex: 1;
}

.effectRow {
    margin-left: 0.5em;
    margin-right: 0.5em;
    padding: 0.5em;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    box-shadow: 0 0 3px rgba(0,0,0,0.2);
    transition: background 0.2s, border 0.2s;
}

.effectRow:hover {
    background: #3a3a3a;
    border-color: #666;
}

.effectRow.selected {
    background: #555;
    border: 1px solid #888;
}

.effectHeader {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.labelRow {
    display: flex;
    align-items: center;
    gap: 6px;
}

.labelWrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.effectLabel {
    flex: 1;
    font-weight: 700;
    font-size: 1.1em;
    outline: none;
    padding: 2px 4px;
    cursor: default;
    border: 1px dashed transparent;
    background: transparent;
}

.effectLabel[contenteditable="true"] {
    border-color: #666;
    background: #111;
    cursor: text;
}

.editButton {
    background: transparent;
    border: none;
    font-size: 1em;
    cursor: pointer;
    color: #ccc;
    padding: 2px;
    transition: color 0.2s;
}

.editButton:hover {
    color: #fff;
}

.effectToggle {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #999;
    background: #222;
    display: inline-block;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.effectToggle:checked {
    border-color: #3af;
}

.effectToggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 6px;
    width: 4px;
    height: 9px;
    border: solid #000;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.2s;
}

.effectToggle:checked::after {
    opacity: 1;
}

.effectRow.unsoloed {
    opacity: 0.4;
}
.effectRow.soloed {
    border-color: #4af;
}

.enableToggle:checked {
    background: #3af;
}

.soloToggle {
    background: #800
}

.soloToggle:checked {
    background: #e00;
}

.effectButton {
    padding: 2px 6px;
    font-size: 0.9em;
    cursor: pointer;
}

.controlGroup {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
}

.busy #appRoot {
  pointer-events: none;
  user-select: none;
  filter: grayscale(0.2);
}

#pdr-loading-modal {
    pointer-events: auto;
}


/* For Firefox */
html {
  scrollbar-width: thin;  /* Use thin scrollbars */
  scrollbar-color: #555 #333; /* Thumb and track color */
}

/* Histogram of the displayed image, above the effect picker. Matches the
   picker: #222 panel, #333 rules, #1a1a1a wells, #0af for active toggles. */
#histogramPanel {
    flex-shrink: 0;
    padding: 0.25rem 0.5rem 0.4rem;
    background: #222;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    font-size: 0.8rem;
}

#histogramPanel > summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: #ccc;
    padding: 0.15rem 0;
    list-style: none;
}

#histogramPanel > summary::-webkit-details-marker {
    display: none;
}

#histogramPanel > summary .hist-title::before {
    content: "▸ ";
    color: #888;
}

#histogramPanel[open] > summary .hist-title::before {
    content: "▾ ";
}

#histogramPanel > summary .hist-title {
    font-weight: 700;
    margin-right: auto;
}

.hist-toggle {
    display: inline-flex;
    border-radius: 4px;
    overflow: hidden;
}

.hist-toggle button {
    font: inherit;
    font-size: 0.75rem;
    padding: 0.1rem 0.45rem;
    background: #444;
    color: #ccc;
    border: none;
    cursor: pointer;
}

.hist-toggle button.active {
    background: #0af;
    color: #111;
}

#histogramCanvas {
    display: block;
    width: 100%;
    height: 80px;
    margin-top: 0.25rem;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    cursor: crosshair;
}

#histogramInfo {
    min-height: 1.2em;
    margin-top: 0.2rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
