/* Written for iOS 14.3+: no flex gap, no inset shorthand, no aspect-ratio, dvh only with a vh fallback. */

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: #000;
}

body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  color: #fff;
  background: #000;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Camera preview fills the screen, mirrored like a selfie camera (the recorded file is not mirrored). */
#preview {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  background: #000;
  z-index: 0;
}

#prompter {
  grid-row: 1;
  position: relative;
  z-index: 1;
  min-height: 0;
  overflow-y: scroll;
  scrollbar-width: none;
  touch-action: none; /* finger moves are handled by pointer events in js/scroller.js */
  overscroll-behavior: none;
  background: rgba(0, 0, 0, 0.35);
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#prompter::-webkit-scrollbar {
  display: none;
}

#script {
  padding: 30vh 20px 70vh;
  padding: 30dvh 20px 70dvh;
  font-size: var(--font-size, 40px);
  line-height: 1.4;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  overflow-wrap: anywhere;
}

#script p {
  margin: 0 0 0.6em;
}

#controls {
  grid-row: 2;
  position: relative;
  z-index: 2;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.8);
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  padding: 0 8px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: #374151;
  touch-action: manipulation;
}

button:active {
  background: #4b5563;
}

button:disabled {
  opacity: 0.4;
}

body.recording #record {
  background: #dc2626;
}

body.recording #record::before {
  content: "\25CF  ";
}

.sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 16px;
  margin-top: 8px;
  font-size: 14px;
}

.sliders input {
  width: 100%;
  margin: 4px 0 0;
}

#editor {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: 1fr auto;
  row-gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  background: #111827;
}

#editor[hidden] {
  display: none;
}

#text {
  width: 100%;
  min-height: 0;
  padding: 12px;
  border: 1px solid #374151;
  border-radius: 12px;
  resize: none;
  font: inherit;
  font-size: 18px; /* 16px or more stops iOS zooming into the field */
  color: #fff;
  background: #1f2937;
}

#status {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 30;
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 15px;
  background: rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

#status:empty {
  display: none;
}

#debug {
  position: fixed;
  top: calc(60px + env(safe-area-inset-top));
  left: 8px;
  right: 8px;
  z-index: 40;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  font: 11px/1.35 Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #a7f3d0;
  background: rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
