/* ============================================================
   Deckle — design tokens
   Identity: ink on cool paper, cobalt spine, Fraunces display.
   The spine (agenda rail with filled dots) is the signature.
   ============================================================ */
:root {
  /* colour */
  --paper: #f3f5f4;
  --surface: #ffffff;
  --ink: #14201c;
  --ink-2: #46564f;
  --ink-3: #6d7c76;
  --line: #d9dfdc;
  --line-strong: #b9c3bf;
  --cobalt: #1f45e0;
  --cobalt-ink: #1b3bc4;   /* text-safe on paper/surface */
  --cobalt-wash: #e8ecfc;
  --danger: #b3261e;
  --ok: #17714a;

  /* type */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-xs: 12px; --fs-s: 13.5px; --fs-m: 15px; --fs-l: 18px;
  --fs-xl: 26px; --fs-xxl: clamp(30px, 5.5vw, 44px);

  /* space, shape, depth, motion */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 40px;
  --radius: 8px; --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(20, 32, 28, .08), 0 1px 6px rgba(20, 32, 28, .06);
  --shadow-2: 0 4px 12px rgba(20, 32, 28, .12), 0 12px 40px rgba(20, 32, 28, .12);
  --speed: 150ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-m);
  color: var(--ink);
  background: var(--paper);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-height: 44px;
  font-size: var(--fs-s);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--speed), border-color var(--speed), transform var(--speed);
}
.btn:hover { background: var(--paper); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn-primary:hover { background: var(--cobalt-ink); border-color: var(--cobalt-ink); }
.btn-quiet { background: transparent; border-color: transparent; }
.btn-quiet:hover { background: rgba(20, 32, 28, .06); border-color: transparent; }
.btn-full { display: block; width: 100%; text-align: left; }
.btn-icon { min-width: 44px; padding: 6px; border: none; background: transparent; font-size: 22px; line-height: 1; }
.link-btn {
  background: none; border: none; padding: 2px; cursor: pointer;
  color: var(--cobalt-ink); text-decoration: underline; font-size: inherit;
  min-height: 44px;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 21px;
  color: var(--ink);
  text-decoration: none;
  padding-right: var(--sp-2);
  border-right: 1px solid var(--line);
}
.deck-title {
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  font-size: var(--fs-m);
  font-weight: 600;
  color: var(--ink);
  padding: 10px var(--sp-2);
  width: min(340px, 34vw);
  min-height: 44px;
}
.deck-title:hover { border-color: var(--line); }
.deck-title:focus { border-color: var(--line-strong); background: var(--surface); outline: none; }
.deck-title::placeholder { color: var(--ink-3); font-weight: 500; }
.save-status { font-size: var(--fs-xs); color: var(--ink-3); min-width: 52px; }
.save-status.saved::before { content: "✓ "; color: var(--ok); }
.topbar-spacer { flex: 1; }

/* ---------- first-run composer ---------- */
.composer {
  max-width: 720px;
  margin: 0 auto;
  padding: 12vh var(--sp-5) var(--sp-6);
  text-align: center;
}
.composer-headline {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-xxl);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-6);
}
.composer-input-wrap { position: relative; }
.composer-input-wrap::before {
  /* the first spine dot, waiting to be lit */
  content: "";
  position: absolute; left: -26px; top: 50%;
  width: 12px; height: 12px; margin-top: -6px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--surface);
}
.composer-input {
  width: 100%;
  font-size: var(--fs-l);
  padding: 18px 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--ink);
}
.composer-input:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px var(--cobalt-wash), var(--shadow-1); }
.composer-input::placeholder { color: var(--ink-3); }
.composer-alt { margin-top: var(--sp-5); color: var(--ink-2); font-size: var(--fs-s); }

/* ---------- editor layout ---------- */
.editor {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 0;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

/* ---------- agenda (the spine) ---------- */
.agenda {
  position: sticky; top: 61px;
  max-height: calc(100vh - 61px);
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-6) var(--sp-5);
}
.agenda-head {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--sp-3);
  padding-left: 26px;
}
.agenda-list { list-style: none; position: relative; }
/* the spine line */
.agenda-list::before {
  content: "";
  position: absolute; left: 5px; top: 12px; bottom: 12px;
  width: 2px; background: var(--line-strong);
  border-radius: 1px;
}
.agenda-row, .agenda-add-row {
  display: flex; align-items: center; gap: var(--sp-3);
  position: relative;
}
.spine-dot {
  flex: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--paper);
  cursor: grab;
  touch-action: none;
  z-index: 1;
}
.agenda-row.active .spine-dot { border-color: var(--cobalt); background: var(--cobalt); }
.agenda-row.dragging { opacity: .4; }
.agenda-row.drag-over-before { box-shadow: 0 -2px 0 var(--cobalt); }
.agenda-row.drag-over-after { box-shadow: 0 2px 0 var(--cobalt); }
.spine-dot-ghost { border-style: dashed; background: transparent; cursor: default; }
.agenda-input {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  padding: 10px var(--sp-2);
  min-height: 42px;
  font-size: var(--fs-s);
  font-weight: 500;
  color: var(--ink);
}
.agenda-input:hover { border-color: var(--line); }
.agenda-input:focus { outline: none; border-color: var(--line-strong); background: var(--surface); }
.agenda-input::placeholder { color: var(--ink-3); }
.agenda-row.active .agenda-input { color: var(--cobalt-ink); font-weight: 600; }
.agenda-del {
  flex: none;
  border: none; background: none;
  color: var(--ink-3);
  font-size: 16px; line-height: 1;
  width: 32px; height: 42px;
  cursor: pointer;
  border-radius: var(--radius);
  opacity: 0;
}
.agenda-row:hover .agenda-del, .agenda-row:focus-within .agenda-del { opacity: 1; }
.agenda-del:hover { color: var(--danger); background: rgba(179, 38, 30, .07); }

/* ---------- slides ---------- */
.slides { padding: var(--sp-5) var(--sp-5) 30vh; }
.slides-list { display: flex; flex-direction: column; gap: var(--sp-5); }
.slide-card { position: relative; }
.slide-card.dragging { opacity: .4; }
.slide-card.drag-over-before { box-shadow: 0 -3px 0 var(--cobalt); }
.slide-card.drag-over-after { box-shadow: 0 3px 0 var(--cobalt); }
.slide-frame {
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 5.5% 7%;
  transition: box-shadow var(--speed), border-color var(--speed);
}
.slide-card.current .slide-frame { border-color: var(--cobalt); box-shadow: 0 0 0 3px var(--cobalt-wash), var(--shadow-1); }
.slide-num {
  position: absolute; right: 12px; bottom: 8px;
  font-size: var(--fs-xs); color: var(--ink-3);
}
.slide-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(18px, 3.2vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  min-height: 1.2em;
  border-bottom: 3px solid var(--cobalt);
  padding-bottom: .35em;
  margin-bottom: .55em;
  align-self: flex-start;
  max-width: 100%;
}
.slide-title:empty::before { content: attr(data-ph); color: var(--ink-3); }
.slide-title:focus, .slide-bullet:focus { outline: none; }
.slide-bullets { list-style: none; display: flex; flex-direction: column; gap: .35em; overflow: hidden; }
.slide-bullet {
  font-size: clamp(13px, 1.9vw, 20px);
  line-height: 1.45;
  color: var(--ink-2);
  padding-left: 1.1em;
  position: relative;
  min-height: 1.4em;
}
.slide-bullet::before { content: "—"; position: absolute; left: 0; color: var(--cobalt); }
.slide-bullet:empty::before { color: var(--line-strong); }
.slide-bullet:only-child:empty::after { content: attr(data-ph); color: var(--ink-3); }
.slide-frame.image { padding: 0; background: #101512; }
.slide-frame.image img { width: 100%; height: 100%; object-fit: contain; display: block; }
.slide-fidelity {
  position: absolute; left: 12px; top: 10px;
  font-size: var(--fs-xs);
  background: #fff7e0; color: #6d5410;
  border: 1px solid #e5d491;
  border-radius: 6px;
  padding: 3px 8px;
}

.slide-tools {
  display: flex; align-items: center; gap: var(--sp-1);
  margin-top: var(--sp-1);
  min-height: 32px;
}
.slide-tool {
  border: none; background: none;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--speed);
}
.slide-card:hover .slide-tool, .slide-card:focus-within .slide-tool { opacity: 1; }
.slide-tool:hover { background: rgba(20, 32, 28, .07); color: var(--ink); }
.slide-tool.danger:hover { color: var(--danger); background: rgba(179, 38, 30, .07); }
.slide-notes {
  width: 100%;
  margin-top: var(--sp-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  font-size: var(--fs-s);
  color: var(--ink-2);
  resize: vertical;
  min-height: 60px;
}
.slide-notes:focus { outline: none; border-color: var(--line-strong); }

/* ---------- agenda toggle (mobile) ---------- */
.agenda-toggle {
  position: fixed; left: var(--sp-4); bottom: var(--sp-4); z-index: 55;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 48px;
  font-weight: 700;
  font-size: var(--fs-s);
  cursor: pointer;
  display: none;
}

/* ---------- side panel ---------- */
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: min(400px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  padding: var(--sp-4) var(--sp-5) var(--sp-6);
  overflow-y: auto;
}
.side-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.side-panel h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-xl); }
.side-panel h3 {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: var(--sp-2);
}
.share-block { margin-bottom: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.share-url-row { display: flex; gap: var(--sp-2); }
.share-url {
  flex: 1; min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px var(--sp-3);
  font-size: var(--fs-s);
  color: var(--cobalt-ink);
  background: var(--paper);
}
.panel-note { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.5; }
.panel-error { font-size: var(--fs-s); color: var(--danger); line-height: 1.5; }

/* ---------- present mode ---------- */
.present {
  position: fixed; inset: 0; z-index: 100;
  background: #0c110f;
  display: flex; flex-direction: column;
}
.stage { flex: 1; position: relative; overflow: hidden; cursor: pointer; }
.stage-slide {
  position: absolute; left: 50%; top: 50%;
  width: 1280px; height: 720px;
  transform-origin: center;
  background: var(--surface);
  display: flex; flex-direction: column;
  padding: 64px 90px;
  border-radius: 4px;
}
.stage-slide .slide-title { font-size: 58px; }
.stage-slide .slide-bullet { font-size: 30px; }
.stage-slide.image { padding: 0; background: #101512; align-items: center; justify-content: center; }
.stage-slide.image img { max-width: 100%; max-height: 100%; }
.hud {
  display: flex; align-items: stretch; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: #161d1a;
  color: #cfd8d4;
  border-top: 1px solid #29332f;
  min-height: 112px;
}
.hud-notes-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.hud-count { font-size: var(--fs-xs); color: #8a9691; font-variant-numeric: tabular-nums; }
.hud-notes { font-size: var(--fs-m); line-height: 1.5; overflow-y: auto; max-height: 84px; white-space: pre-wrap; }
.hud-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #8a9691; margin-bottom: 4px; }
.hud-next-thumb {
  width: 148px; aspect-ratio: 16/9;
  background: #f3f5f4; color: var(--ink);
  border-radius: 6px;
  overflow: hidden;
  font-size: 8px;
  display: flex; flex-direction: column;
  padding: 6px 8px;
}
.hud-next-thumb .t { font-family: var(--font-display); font-weight: 600; font-size: 10px; border-bottom: 1px solid var(--cobalt); padding-bottom: 2px; margin-bottom: 3px; }
.hud-next-thumb .b { color: var(--ink-2); overflow: hidden; }
.hud-next-thumb img { width: 100%; height: 100%; object-fit: contain; }
.hud-next-thumb.end { align-items: center; justify-content: center; color: var(--ink-3); font-size: 10px; }
.hud-timer {
  font-variant-numeric: tabular-nums;
  font-size: 30px; font-weight: 600;
  align-self: center;
  color: #eef2f0;
}
.hud-exit { color: #cfd8d4; align-self: center; }
.hud-exit:hover { background: rgba(255,255,255,.08); }

/* ---------- import progress ---------- */
.import-bar {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80;
  width: min(420px, calc(100vw - 32px));
  background: var(--ink);
  color: #eef2f0;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.import-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: var(--cobalt);
  opacity: .35;
  transition: width var(--speed);
}
.import-label { position: relative; font-size: var(--fs-s); font-weight: 600; }

/* ---------- shortcuts overlay ---------- */
.shortcuts {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(12, 17, 15, .5);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
}
.shortcuts-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-5);
  width: 420px; max-width: 100%;
}
.shortcuts-card h2 { font-family: var(--font-display); margin-bottom: var(--sp-4); }
.shortcuts-card dl div { display: flex; gap: var(--sp-3); padding: 6px 0; border-bottom: 1px solid var(--line); }
.shortcuts-card dt {
  font-family: ui-monospace, Menlo, monospace;
  font-size: var(--fs-xs);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 8px;
  white-space: nowrap;
  align-self: center;
}
.shortcuts-card dd { font-size: var(--fs-s); color: var(--ink-2); align-self: center; }
.shortcuts-card .btn { margin-top: var(--sp-4); }

/* ---------- drop veil, toast, footer ---------- */
.drop-veil {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(31, 69, 224, .12);
  border: 3px dashed var(--cobalt);
  display: flex; align-items: center; justify-content: center;
}
.drop-veil-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-4) var(--sp-6);
  font-family: var(--font-display);
  font-size: var(--fs-xl);
}
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 110;
  background: var(--ink); color: #eef2f0;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: var(--fs-s);
  box-shadow: var(--shadow-2);
  max-width: calc(100vw - 32px);
}
.page-foot { text-align: center; padding: var(--sp-6) var(--sp-4); }
.page-foot a { color: var(--ink-3); font-size: var(--fs-xs); }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .editor { grid-template-columns: 1fr; }
  .agenda {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 50;
    max-height: 60vh;
    padding-bottom: 84px; /* keep rows clear of the floating toggle */
    background: var(--surface);
    border-top: 1px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-2);
    transform: translateY(105%);
    transition: transform var(--speed);
  }
  .agenda.open { transform: translateY(0); }
  .agenda-toggle { display: block; }
  .agenda-toggle[aria-expanded="true"] { border-color: var(--cobalt); color: var(--cobalt-ink); }
  .agenda-del { opacity: 1; }
  .slide-tool { opacity: 1; }
  .deck-title { width: auto; flex: 1; min-width: 80px; }
  .save-status { display: none; }
  .btn { padding: 10px 12px; }
  .topbar { flex-wrap: wrap; }
  .hud-next { display: none; }
  .hud { min-height: 84px; }
  .hud-timer { font-size: 22px; }
  .composer { padding-top: 8vh; }
  .composer-input-wrap::before { display: none; }
}
