
/* Shared theme colours used throughout the interface. */
:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --panel: #151518;
  --panel-2: #1d1d21;
  --text: #f4f4f5;
  --muted: #a7a7ad;
  --border: #2d2d33;
  --accent: #ffffff;
  --danger: #2a1719;
  --danger-border: #5b2b30;
}

/* Includes padding and borders inside every declared element size. */
* { box-sizing: border-box; }

/* Establishes the page's dark background, text colour, and font stack. */
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Makes form controls use the same typography as the surrounding page. */
button, input, textarea { font: inherit; }

/* Prevents browsers from applying an unrelated default button colour. */
button { color: inherit; }

/* Ensures each application screen fills at least one viewport. */
.view {
  min-height: 100vh;
}

/* JavaScript applies this utility class when a screen should not render. */
.hidden { display: none !important; }

/* Constrains and centres the editor on wide screens. */
#editorView {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 42px;
}

/* Places the title and Clear button at opposite sides of the header. */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

/* Styles the small uppercase product name above the main heading. */
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
}

/* Creates a responsive main heading without browser-default margins. */
h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  letter-spacing: -0.045em;
}

/* Gives the editor and settings a consistent card appearance. */
.editor-shell,
.controls-panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 18px;
}

/* Establishes the positioning boundary for the guide preview. */
.editor-shell {
  position: relative;
  overflow: hidden;
}

/* Draws the editor's live READ HERE guide at the selected percentage. */
#editorReadingGuide {
  position: absolute;
  z-index: 2;
  top: var(--editor-guide-y, 34%);
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  opacity: 0.28;
}

/* Creates the left half of the preview guide line. */
#editorReadingGuide span {
  height: 1px;
  background: linear-gradient(90deg, transparent, #fff);
}

/* Reverses the gradient for the right half of the preview line. */
#editorReadingGuide span:last-child {
  background: linear-gradient(90deg, #fff, transparent);
}

/* Styles the small label at the centre of the preview guide. */
#editorReadingGuide div {
  color: #fff;
  font-size: 9px;
  letter-spacing: 0.16em;
}

/* Styles the script input and makes its width a live CSS-variable preview. */
#scriptInput {
  display: block;
  width: var(--editor-prompt-width, 72%);
  margin: 0 auto;
  min-height: 48vh;
  resize: vertical;
  border: 0;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  outline: none;
  padding: 26px;
  color: var(--text);
  background: transparent;
  line-height: 1.55;
  font-size: 1.05rem;
  transition: width 100ms ease, border-color 100ms ease;
}

/* Reveals subtle text-column boundaries while the editor has focus. */
.editor-shell:focus-within #scriptInput {
  border-left-color: rgba(255,255,255,0.08);
  border-right-color: rgba(255,255,255,0.08);
}

/* Keeps placeholder text visible without competing with real script text. */
#scriptInput::placeholder { color: #68686f; }

/* Arranges settings into four responsive columns. */
.controls-panel {
  margin-top: 16px;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

/* Places each setting name opposite its current value. */
.control label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 9px;
}

/* Makes range controls fill the width of their grid cells. */
input[type="range"] { width: 100%; }

/* Places toggle settings on one wrapping row spanning the panel. */
.toggle-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding-top: 2px;
}

/* Aligns each checkbox with its readable label. */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d0d0d4;
  cursor: pointer;
}

/* Shared base appearance and interaction animation for all buttons. */
.button,
.round-button {
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

/* Strengthens button contrast when a pointer is over it. */
.button:hover,
.round-button:hover {
  border-color: #51515a;
  background: #25252a;
}

/* Gives pressed buttons a small tactile scale response. */
.button:active,
.round-button:active { transform: scale(0.98); }

/* Sizes standard rectangular buttons. */
.button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 11px;
}

/* Uses a high-contrast treatment for the main action. */
.button.primary {
  background: #f4f4f5;
  color: #09090b;
  border-color: #f4f4f5;
  font-weight: 750;
}

/* Slightly dims the primary button on hover. */
.button.primary:hover { background: #dedee2; }

/* Removes the fill from secondary ghost buttons. */
.button.ghost { background: transparent; }

/* Gives Exit a restrained danger treatment. */
.button.danger {
  background: var(--danger);
  border-color: var(--danger-border);
}

/* Makes the start action span the full settings grid. */
.start-button {
  grid-column: 1 / -1;
  min-height: 58px;
  font-size: 1.05rem;
}

/* Styles the keyboard-shortcut reminder beneath the controls. */
.shortcut-note {
  color: var(--muted);
  text-align: center;
  font-size: 0.87rem;
  margin: 16px 0 0;
}

/* Makes the running teleprompter fill and clip to the viewport. */
#prompterView,
/* Establishes a positioning context for every prompt overlay. */
#prompterStage {
  width: 100%;
  height: 100vh;
  background: #000;
  overflow: hidden;
}

#prompterStage {
  position: relative;
}

/* Covers the stage and hides text after it moves beyond the screen. */
#textViewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Controls prompt typography, spacing, movement, and read-state colour. */
#promptText {
  width: var(--prompt-width, 72%);
  margin: 0 auto;
  padding-top: var(--prompt-start, calc(34vh + 12px));
  padding-bottom: 90vh;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  font-size: var(--prompt-font, 56px);
  line-height: var(--prompt-line, 1.5);
  letter-spacing: -0.018em;
  white-space: pre-wrap;
  text-wrap: pretty;
  color: #fff;
  /* Grey above the boundary means read; white below means unread. */
  background: linear-gradient(
    to bottom,
    #77777f 0,
    #77777f calc(var(--read-boundary, 34vh) - 2px),
    #fff calc(var(--read-boundary, 34vh) + 2px),
    #fff 100%
  );
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transform-origin: center center;
  will-change: transform;
}

/* Positions the draggable reading guide across the prompt screen. */
#readingGuide {
  position: absolute;
  z-index: 5;
  top: var(--guide-y, 34%);
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  cursor: ns-resize;
  touch-action: none;
  opacity: 0.6;
}

/* Draws a line fading in towards the guide label. */
#readingGuide span {
  height: 1px;
  background: linear-gradient(90deg, transparent, #fff);
}

/* Reverses that fade after the guide label. */
#readingGuide span:last-child {
  background: linear-gradient(90deg, #fff, transparent);
}

/* Styles the central READ HERE label. */
.guide-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #cfcfd3;
}

/* Positions the temporary status message at the top centre. */
#statusPill {
  position: absolute;
  z-index: 8;
  top: 18px;
  left: 50%;
  translate: -50% 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(24,24,27,0.72);
  backdrop-filter: blur(8px);
  color: #d4d4d8;
  font-size: 0.82rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

/* JavaScript applies this class briefly to reveal a status message. */
#statusPill.visible { opacity: 1; }

/* Creates the dim, full-width progress track along the bottom edge. */
#progressTrack {
  position: absolute;
  z-index: 7;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255,255,255,0.12);
}

/* Starts the bright progress fill empty; JavaScript updates its width. */
#progressBar {
  width: 0%;
  height: 100%;
  background: #fff;
}

/* Floats the controls above the bottom edge and mostly hides them. */
#prompterControls {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 20px;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  background: rgba(18,18,20,0.72);
  backdrop-filter: blur(12px);
  opacity: 0.18;
  transition: opacity 160ms ease;
}

/* Reveals controls for both mouse and keyboard users. */
#prompterStage:hover #prompterControls,
#prompterControls:focus-within {
  opacity: 1;
}

/* Makes speed controls circular and comfortably clickable. */
.round-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.35rem;
}

/* Adapts the editor and prompt controls for tablets and narrow windows. */
@media (max-width: 760px) {
  #editorView {
    width: min(100% - 20px, 1120px);
    padding-top: 18px;
  }

  .controls-panel {
    grid-template-columns: 1fr 1fr;
  }

  #promptText {
    width: min(var(--prompt-width, 88%), 94%);
  }

  #prompterControls {
    max-width: calc(100% - 20px);
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Stacks editor controls into one column on phones. */
@media (max-width: 480px) {
  .controls-panel { grid-template-columns: 1fr; }
  .control, .toggle-row, .start-button { grid-column: 1; }
  #scriptInput { min-height: 42vh; }
}
