/* Plain on purpose: light background, system font, no decoration.
   The real visual design comes later. */

:root {
  color-scheme: light;
  --ink: #111;
  --muted: #5f5f5f;
  --line: #cfcfcf;
  --panel: #ececec;
  --bg: #fff;
  --playhead: #d4302b;
  --focus: #2f6fd6;
}

body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

header,
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

header { padding-top: 24px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
header p { margin: 0; color: var(--muted); }

main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding-top: 24px;
  padding-bottom: 48px;
}

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  header, main { padding-left: 16px; padding-right: 16px; }
}

h2 { font-size: 1rem; margin: 0 0 8px; }

/* ---- Clip strip ---- */

.library { grid-column: 1 / -1; min-width: 0; }

.tiles {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 4px 8px;
  margin: 0 -4px;
}

.tile {
  position: relative;
  flex: 0 0 140px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tile img,
.tile-art {
  box-sizing: border-box;
  width: 140px;
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  background: var(--panel);
  object-fit: cover;
  outline: 3px solid transparent;
  outline-offset: 2px;
}

.tile-art {
  display: grid;
  place-items: center;
  border: 2px dashed var(--line);
  font-size: 2rem;
  color: var(--muted);
}

/* The chosen clip gets a dark ring. */
.tile[aria-pressed="true"] img,
.upload.chosen .tile-art { outline-color: var(--ink); }

.tile:focus-visible { outline: none; }
.tile:focus-visible img,
.upload:focus-within .tile-art { outline-color: var(--focus); }

.tile-title { margin-top: 8px; font-size: 0.9rem; font-weight: 600; }
.tile-note { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }

/* ---- Search ---- */

.search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 20px;
}
.search label { font-weight: 600; }
.search input {
  font: inherit;
  flex: 1 1 200px;
  max-width: 360px;
  padding: 5px 10px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
}
.search input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--muted);
}

/* Results wrap into rows (the library above scrolls sideways instead). */
.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, 140px);
  gap: 16px;
  margin-top: 12px;
  padding: 4px;
}
.results:empty { display: none; }
#more-results { margin-top: 12px; }

.credit { font-size: 0.85rem; overflow-wrap: anywhere; }
.credit a { color: inherit; }

/* The file picker itself is invisible; the whole tile is its label. */
.upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* While a file is dragged over the page. */
body.dropping::after {
  content: 'Drop the video to open it';
  position: fixed;
  inset: 12px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--ink);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.88);
  font-size: 1.25rem;
  font-weight: 600;
  pointer-events: none;
}

/* Both pictures keep the clip's shape; 16:9 holds the space until it loads. */
video,
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto 16 / 9;
  background: var(--panel);
}

/* ---- Timeline ---- */

.timeline {
  position: relative;
  height: 64px;
  margin-top: 8px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.timeline.locked {
  pointer-events: none;
  opacity: 0.6;
}

.track,
.span {
  position: absolute;
  top: 20px;
  height: 8px;
}

.track { left: 0; right: 0; background: var(--line); border-radius: 4px; }
.span { background: var(--ink); }

.playhead {
  position: absolute;
  top: 6px;
  width: 2px;
  height: 36px;
  margin-left: -1px;
  background: var(--playhead);
  pointer-events: none;
}

.mark {
  position: absolute;
  top: 4px;
  box-sizing: border-box;
  width: 14px;
  height: 40px;
  margin-left: -7px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 3px;
  cursor: ew-resize;
}

.mark:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Time labels under the track. */
.ticks { position: absolute; left: 0; right: 0; top: 40px; height: 20px; pointer-events: none; }
.tick {
  position: absolute;
  top: 0;
  padding-left: 4px;
  border-left: 1px solid var(--line);
  font-size: 0.75rem;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Play and zoom ---- */

.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 12px;
}

.zoom { display: inline-flex; gap: 4px; }
.transport .readout { margin: 0; }

.small {
  font: inherit;
  font-size: 0.9rem;
  min-width: 36px;
  padding: 4px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

.small:disabled { opacity: 0.4; cursor: default; }
.small:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#play { min-width: 72px; }

/* The whole clip in miniature. */
.overview {
  position: relative;
  height: 16px;
  margin-top: 4px;
  border-radius: 3px;
  background: var(--panel);
  cursor: pointer;
  touch-action: none;
}
.overview[hidden] { display: none; }
.ov-span { position: absolute; top: 5px; bottom: 5px; background: var(--muted); }
.ov-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--playhead); }
.ov-window {
  position: absolute;
  top: 0;
  bottom: 0;
  box-sizing: border-box;
  min-width: 6px;
  border: 2px solid var(--ink);
  border-radius: 3px;
}

.hint { margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); }

/* ---- Exposure ---- */

.looks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}

.looks legend {
  float: left; /* sits on the same line as the choices */
  margin-right: 4px;
  padding: 0;
  font-weight: 600;
}

.looks label { cursor: pointer; }
.looks:disabled { opacity: 0.45; }
.looks:disabled label { cursor: default; }
.looks span { color: var(--muted); }

/* Strobe and brightness: label, slider, value in three columns. */
.sliders {
  display: grid;
  grid-template-columns: auto minmax(120px, 280px) auto;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
}
.sliders label { font-weight: 600; }
.sliders output { color: var(--muted); font-variant-numeric: tabular-nums; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

#shutter {
  font: inherit;
  font-weight: 600;
  padding: 10px 22px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}

/* Save is the quieter of the two: outlined instead of filled. */
#save {
  font: inherit;
  font-weight: 600;
  padding: 10px 22px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

#shutter:disabled,
#save:disabled { opacity: 0.4; cursor: default; }
#shutter:focus-visible,
#save:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.readout {
  margin: 8px 0 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
