/* BeamerPresenter — friendly web presenter for Beamer PDFs
   present.css : layout + theme for presenter and audience views */

:root {
  --bg: #16181d;
  --panel: #22262e;
  --panel-2: #2b303a;
  --line: #363c47;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #4a9eff;
  --accent-2: #7c5cff;
  --good: #35c46a;
  --warn: #f2b134;
  --bad: #ef4d4d;
  --stage-bg: #0c0d10;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  overflow: hidden; user-select: none;
}

button {
  font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1;
}
button:hover { background: #333a46; border-color: #48505d; }
button:active { transform: translateY(1px); }
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.warnbtn { background: transparent; border-color: var(--line); }
kbd {
  font: 11px/1 ui-monospace, Menlo, Consolas, monospace;
  background: #0d0f13; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 3px 5px; color: var(--muted);
}

/* ---------- mode switching ---------- */
#audienceRoot { display: none; }
body[data-mode="audience"] #presenterRoot { display: none; }
body[data-mode="audience"] #audienceRoot { display: block; }
body[data-mode="audience"] { background: #000; cursor: none; }
body[data-mode="audience"].show-cursor { cursor: default; }

/* ---------- presenter layout ---------- */
#presenterRoot { display: flex; flex-direction: column; height: 100%; }

#topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 12px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
#topbar .spacer { flex: 1; }
#clock { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; letter-spacing: .5px; }
#timerBox {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 10px;
}
#timerBox .times { font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; }
#timerBox .times #target { color: var(--muted); font-weight: 500; }
#timerBox.warn { border-color: var(--warn); }
#timerBox.bad  { border-color: var(--bad); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { background: #3a2020; } }
#slideNo { font-variant-numeric: tabular-nums; font-size: 16px; color: var(--muted); min-width: 62px; text-align: center; }
#topbar .grp { display: flex; gap: 6px; }
#topbar button { padding: 6px 9px; }

#presenterMain { flex: 1; display: flex; min-height: 0; }

#currentPane { flex: 1.55; display: flex; flex-direction: column; min-width: 0; padding: 10px; gap: 8px; }
#sidePane   { flex: 1; display: flex; flex-direction: column; min-width: 260px; padding: 10px 10px 10px 0; gap: 8px; }

.pane-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 2px 2px; display: flex; justify-content: space-between; align-items: center; }

.stage-wrap {
  position: relative; flex: 1; min-height: 0;
  background: var(--stage-bg); border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.stage-wrap canvas { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.stage-wrap .ink { z-index: 3; }
.stage-wrap .slide { z-index: 1; background: #fff; }
#pInk { cursor: crosshair; }
.laser {
  position: absolute; z-index: 5; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(circle, rgba(255,40,40,.95) 0%, rgba(255,40,40,.55) 40%, rgba(255,40,40,0) 70%);
  box-shadow: 0 0 14px 4px rgba(255,40,40,.5);
}
.laser.on { opacity: 1; }
.blank { position: absolute; inset: 0; z-index: 8; display: none; }
.blank.black { display: block; background: #000; }
.blank.white { display: block; background: #fff; }

/* next slide preview */
#nextWrap { flex: 0 0 auto; height: 40%; display: flex; }  /* flex so .stage-wrap fills it */
#nextWrap .stage-wrap { background: var(--stage-bg); }

/* notes */
#notesPane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#notes {
  flex: 1; overflow: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font-size: 17px; line-height: 1.5;
  color: #f2f3f5; white-space: pre-wrap; outline: none;
}
#notes:empty::before { content: "No notes for this slide."; color: var(--muted); }
#notes[contenteditable="true"] { border-color: var(--accent); background: #1c2530; }
#notes img { max-width: 100%; }

/* toolbar */
#toolbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px;
}
#toolbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 3px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,.55); cursor: pointer; padding: 0; }
.swatch.active { outline: 2px solid var(--text); outline-offset: 2px; }
#penWidth { width: 90px; }
#videoBar { display: flex; gap: 6px; flex-wrap: wrap; }
#videoBar button { background: #223528; border-color: #2f5a3c; }
#videoBar button:hover { background: #2a4231; }
#videoBar .playing { background: var(--good); border-color: var(--good); color: #05210f; }

/* overview grid */
#overview {
  position: fixed; inset: 0; z-index: 50; background: rgba(10,11,14,.97);
  display: none; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px; padding: 20px; overflow: auto;
}
#overview.show { display: grid; }
#overview .thumb { position: relative; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: #fff; }
#overview .thumb.cur { border-color: var(--accent); }
#overview .thumb canvas { display: block; width: 100%; }
#overview .thumb .n { position: absolute; left: 6px; bottom: 4px; background: #000a; color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 5px; }
#overview .thumb .vid { position: absolute; right: 6px; top: 6px; background: var(--good); color: #05210f; font-size: 11px; padding: 1px 6px; border-radius: 5px; }

/* ---------- audience ---------- */
#audienceRoot { height: 100%; }
#aStage { position: absolute; inset: 0; background: #000; border-radius: 0; }
#aStage canvas { image-rendering: auto; }
#aVideo { position: absolute; z-index: 6; display: none; }
#aVideo.on { display: block; }
#aVideo video { width: 100%; height: 100%; background: #000; display: block; }
#armAudio {
  position: absolute; inset: 0; z-index: 20; background: #000;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  color: #cfd3d8; cursor: pointer; text-align: center; padding: 30px;
}
#armAudio.hide { display: none; }
#armAudio .big { font-size: 26px; font-weight: 600; color: #fff; }
#armAudio .sub { font-size: 15px; color: var(--muted); max-width: 460px; }

/* presenter monitor of playing video */
#pVideoMon { position: absolute; z-index: 7; inset: 0; background: #000; display: none; }
#pVideoMon.on { display: block; }
#pVideoMon video { width: 100%; height: 100%; object-fit: contain; }
#videoTransport {
  position: absolute; z-index: 8; left: 0; right: 0; bottom: 0;
  display: none; align-items: center; gap: 10px; padding: 8px 12px;
  background: linear-gradient(transparent, #000c 40%);
  font-variant-numeric: tabular-nums;
}
#videoTransport.on { display: flex; }
#videoTransport input[type=range] { flex: 1; }
#videoTransport .vtime { font-size: 13px; color: #dfe3e8; min-width: 96px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: #000a; display: none; align-items: center; justify-content: center; }
.modal.show { display: flex; }
.modal .card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(560px, 92vw); max-height: 90vh; overflow: auto; padding: 20px; }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .row { display: flex; gap: 10px; align-items: center; margin: 9px 0; }
.modal .row label { width: 120px; color: var(--muted); font-size: 14px; flex: 0 0 auto; }
.modal .row input[type=text], .modal .row input[type=number], .modal .row select {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 8px 10px; font: inherit;
}
.modal .box4 { display: flex; gap: 6px; flex: 1; }
.modal .box4 input { width: 100%; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal .vidlist { margin: 6px 0 14px; }
.modal .vidlist .item { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 5px 0; font-size: 14px; }
.modal .vidlist .item .grow { flex: 1; }
.modal .hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; line-height: 1.45; }
.modal .danger { color: var(--bad); border-color: var(--bad); background: transparent; }

/* toast */
#toast {
  position: fixed; z-index: 90; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #0f1115; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px;
  color: var(--text); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* welcome / empty state */
#welcome { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--muted); text-align: center; padding: 20px; z-index: 4; }
#welcome .big { font-size: 20px; color: var(--text); font-weight: 600; }
#welcome.hide { display: none; }

/* ---------- toolbar / topbar selects (Board, Notes) ---------- */
#toolbar select, #topbar select {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; cursor: pointer;
}
#boardStyle { max-width: 170px; }

/* ---------- solo / single-screen "present here" mode ---------- */
/* The slide fills the whole window; the top bar and tool bar stay HIDDEN and reveal
   only when the mouse reaches the top / bottom edge (keyboard nav never flashes them).*/
body.solo #sidePane { display: none; }
body.solo #presenterMain { padding: 0; }
body.solo #currentPane { padding: 0; }
body.solo #currentPane > .pane-label { display: none; }
body.solo #pStage { border-radius: 0; }
body.solo #btnSolo.active { background: var(--accent); border-color: var(--accent); color: #fff; }

body.solo #topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 45;
  box-shadow: 0 6px 20px #0007; transition: transform .28s ease;
  transform: translateY(-100%);                 /* hidden by default */
}
body.solo.show-top #topbar, body.solo #topbar:hover { transform: translateY(0); }

body.solo #toolbar {
  position: fixed; left: 50%; bottom: 14px; z-index: 45; max-width: 96vw;
  background: rgba(18,22,28,.94); box-shadow: 0 8px 26px #0009; transition: transform .28s ease;
  transform: translateX(-50%) translateY(190%);  /* hidden by default */
}
body.solo.show-bottom #toolbar, body.solo #toolbar:hover { transform: translateX(-50%) translateY(0); }

/* hide the cursor only while both bars are hidden */
body.solo.idle:not(.show-top):not(.show-bottom) #pStage { cursor: none; }

/* ---------- no startup white square: hide slide canvases until they hold content ---------- */
body:not(.has-content) .slide { display: none; }

/* ---------- inline SVG tool/board icons ---------- */
.ic { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.boardbtn { padding: 6px 8px; }
.boardbtn.active { background: var(--accent); border-color: var(--accent); }
#boardPattern { max-width: 96px; }

/* ---------- image-overlay control bar ---------- */
#ovBar {
  position: absolute; z-index: 9; top: 10px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: 8px; padding: 5px 8px;
  background: rgba(18,22,28,.92); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 20px #0007;
}
#ovBar.on { display: flex; }
#ovBar #ovIdx { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 44px; text-align: center; }
#ovBar #ovClose { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ---------- clickable link layer (over the slide, under the ink) ---------- */
.stage-wrap .links { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; pointer-events: none; }
body:not(.has-content) .links { display: none; }
.links a.lk { position: absolute; display: block; pointer-events: auto; cursor: pointer; border-radius: 3px; }
.links a.lk:hover { background: rgba(74,158,255,.22); box-shadow: 0 0 0 2px rgba(74,158,255,.65); }

/* ---------- text tool ---------- */
#textFont, #textSize { padding: 5px 6px; }
#textSize { max-width: 60px; }
.textedit {
  position: absolute; z-index: 9; margin: 0; padding: 0 2px;
  background: rgba(20,24,30,.35); border: 1px dashed var(--accent); border-radius: 3px;
  outline: none; resize: none; overflow: hidden; white-space: pre;
  min-width: 14px; caret-color: var(--accent);
}
