/* Emogram: graph-paper ground, ink curve, paper Stickies, highlighter overlap. */

/* Fonts, served by Emogram itself (copied from @fontsource by scripts/copy-fonts.js). */
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/bricolage-grotesque-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/fonts/bricolage-grotesque-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/instrument-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/fonts/instrument-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/instrument-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #f4f6f9; --surface: #ffffff; --fg: #1b2030; --muted: #5b6377; --line: #d6dbe5; --grid: #e7ebf2;
  --ink: #2346a8; --ink-soft: rgba(35, 70, 168, 0.12);
  --paper: #ffe98a; --paper-edge: #e8cf5c; --paper-ink: #3a3000;
  --hl: rgba(255, 196, 0, 0.38); --hl-edge: #1b2030;
  --danger: #b42318; --danger-soft: rgba(180, 35, 24, 0.08); --ok: #1f7a4d;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b; --surface: #191e29; --fg: #e6e9f1; --muted: #9aa2b6; --line: #2c3343; --grid: #1f2532;
    --ink: #92b1ff; --ink-soft: rgba(146, 177, 255, 0.14);
    --paper: #f2db6c; --paper-edge: #c9b24a; --paper-ink: #2a2300;
    --hl: rgba(255, 200, 40, 0.26); --hl-edge: #e6e9f1;
    --danger: #ff8a80; --danger-soft: rgba(255, 138, 128, 0.1); --ok: #6fd3a0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0; }

.page { max-width: 1240px; margin: 0 auto; padding: 0 24px 64px; display: flex; flex-direction: column; gap: 18px; }
.narrow { max-width: 560px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }

/* App header */
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 24px; max-width: 1240px; margin: 0 auto; }
.brand { font-family: var(--display); font-weight: 700; font-size: 22px; text-decoration: none; color: var(--fg); }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--fg); white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; padding-inline: 8px; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn:disabled { opacity: 0.5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 14px; }
.field > label { font-weight: 600; }
.field small { color: var(--muted); }
.field input, .field textarea, .field select, .input {
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; color: var(--fg); width: 100%;
}
.field textarea { min-height: 96px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; }
.error { color: var(--danger); font-size: 14px; }
.notice { background: var(--ink-soft); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.notice.warn { background: var(--danger-soft); }
ul.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }

/* Tables */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.done { color: var(--ok); border-color: var(--ok); }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--c); vertical-align: middle; margin-right: 6px; }

/* Screen-size rules: Interviewees need a laptop; Researchers get a note on small screens. */
.laptop-block { display: none; }
@media (max-width: 1023px) {
  .laptop-only { display: none !important; }
  .laptop-block { display: flex; }
}
.small-screen-note { display: none; }
@media (max-width: 1023px) { .small-screen-note { display: block; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Gram board ---------- */
.board { position: relative; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; user-select: none; -webkit-user-select: none; }
.board.editable { cursor: crosshair; touch-action: none; }
.board-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board-svg .grid { stroke: var(--grid); stroke-width: 1; fill: none; }
.board-svg .axis { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.board-svg .axis-fill { fill: var(--muted); }
.board-svg .lab { fill: var(--muted); font-family: var(--mono); font-size: 13px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.board-svg .face { font-size: 28px; }
.board-svg .msg { fill: var(--muted); font-size: 15px; font-family: var(--body); }
.board-svg .curve { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.board-svg .curve-halo { fill: none; stroke: var(--ink-soft); stroke-width: 13; stroke-linecap: round; }
.board-svg .connector { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; fill: none; }

.pin { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--ink);
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px currentColor; color: var(--muted); z-index: 1100; }
.board.editable .pin { cursor: grab; }
.board.editable .pin::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; }
.pin.note-hidden { background: var(--surface); border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--ink); }

.note { position: absolute; background: var(--paper); color: var(--paper-ink); border: 1px solid var(--paper-edge); border-radius: 2px;
  box-shadow: 2px 3px 0 var(--paper-edge), 0 8px 18px -14px rgba(0, 0, 0, 0.6); }
.board.editable .note { cursor: grab; }
.note:hover { z-index: 900 !important; }
.note.sel { z-index: 1000 !important; outline: 2px solid var(--ink); outline-offset: 1px; cursor: default; }
.note.concealed { display: none; }
.note-text { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; margin: 0; padding: 6px 8px; background: transparent;
  color: var(--paper-ink); font-family: var(--body); font-weight: 500; line-height: 1.15; overflow: hidden; resize: none; outline: none;
  white-space: pre-wrap; overflow-wrap: break-word; }
.board.editable div.note-text { pointer-events: none; }
.board:not(.editable) .note.over .note-text { overflow-y: auto; }
textarea.note-text { padding-top: 14px; user-select: text; -webkit-user-select: text; }
.note.sel.over textarea.note-text { overflow-y: auto; }
.note.over:not(.sel)::after { content: "…more"; position: absolute; right: 4px; bottom: 3px; font-size: 10px; font-weight: 600;
  background: var(--paper); padding: 0 3px; border-radius: 2px; box-shadow: -10px 0 8px var(--paper); pointer-events: none; }
.board:not(.editable) .note.over::after { display: none; }
.note .grip { position: absolute; left: 0; right: 0; top: 0; height: 12px; cursor: grab; z-index: 1;
  background-image: radial-gradient(var(--paper-ink) 1px, transparent 1.2px); background-size: 6px 4px; background-position: center; opacity: 0.35; }
.note .tools { position: absolute; right: -2px; bottom: calc(100% + 7px); display: flex; gap: 4px; white-space: nowrap; }
.note.tools-below .tools { bottom: auto; top: calc(100% + 12px); }
.note .tools button { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; font-size: 12px;
  font-weight: 600; padding: 4px 10px; cursor: pointer; box-shadow: 0 4px 10px -6px rgba(0, 0, 0, 0.5); }
.note .resize { position: absolute; right: -6px; bottom: -6px; width: 24px; height: 24px; cursor: nwse-resize; z-index: 2; }
.note .resize::before { content: ""; position: absolute; right: 7px; bottom: 7px; width: 9px; height: 9px;
  border-right: 2px solid var(--paper-ink); border-bottom: 2px solid var(--paper-ink); opacity: 0.45; }
.note.sel .resize::before { opacity: 0.9; }

/* Example Gram: notes appear one by one, then the curve draws itself */
.board.intro .intro-pop { animation: pop 0.4s ease-out both; }
.board.intro .intro-fade { animation: fade 0.4s ease-out both; }
@keyframes pop { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Export dialog ---------- */
dialog.exp { width: min(1040px, calc(100% - 24px)); max-height: calc(100% - 24px); border: 1px solid var(--line); border-radius: 12px;
  padding: 0; background: var(--surface); color: var(--fg); }
dialog.exp::backdrop { background: rgba(10, 12, 20, 0.55); }
.exp-wrap { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.exp-head { display: flex; align-items: center; justify-content: space-between; }
.exp-body { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
@media (max-width: 760px) { .exp-body { grid-template-columns: minmax(0, 1fr); } }
.exp-preview { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
fieldset.fmt { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
fieldset.fmt legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }
.fmt label { position: relative; }
.fmt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.fmt span { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; font-weight: 600; font-size: 13px; }
.fmt input:checked + span { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.fmt input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Editor ---------- */
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.primer { position: sticky; top: 0; z-index: 1200; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--ink);
  border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 16px -12px rgba(0, 0, 0, 0.4); display: flex; flex-direction: column; gap: 2px; }
.primer p { max-width: 80ch; }
.toolbar { gap: 8px 10px; }
.confirm { background: var(--ink-soft); border-radius: 8px; padding: 4px 4px 4px 10px; }
.source { background: var(--paper); color: var(--paper-ink); border: 1px solid var(--paper-edge); border-radius: 3px; padding: 8px 14px;
  font-weight: 600; cursor: grab; touch-action: none; user-select: none; box-shadow: 2px 3px 0 var(--paper-edge); }
.source:active { cursor: grabbing; }
.ghost { position: fixed; z-index: 5000; pointer-events: none; width: 120px; height: 60px; background: var(--paper);
  border: 1px solid var(--paper-edge); border-radius: 2px; opacity: 0.85; }
.hint strong { color: var(--fg); font-weight: 600; }
.start-field { max-width: 460px; }
details.leave { margin-top: 12px; }
details.leave summary { cursor: pointer; }

dialog.walkthrough { width: min(980px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 12px; padding: 22px;
  background: var(--surface); color: var(--fg); }
dialog.walkthrough::backdrop { background: rgba(10, 12, 20, 0.55); }
.wt-example { pointer-events: none; }

/* ---------- Overlay ---------- */
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1023px) { .ov-grid { grid-template-columns: minmax(0, 1fr); } }
.ov-board { aspect-ratio: 1200 / 680; cursor: pointer; }
.board-svg .hot { fill: var(--hl); }
.ov-pin { cursor: pointer; outline: none; }
.ov-pin:hover circle:last-child, .ov-pin:focus-visible circle:last-child { r: 6.5px; }
.ov-pin:focus-visible .ov-pin-ring, .ov-pin-ring { fill: none; stroke-width: 2; }
.ov-pin:focus-visible circle:first-child { stroke: var(--fg); stroke-width: 1.5; }
.board-svg .sel-edge { stroke: var(--hl-edge); stroke-width: 2; fill: none; stroke-linecap: square; }
.person { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px 5px 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.person .sw { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.person[aria-pressed="false"] { opacity: 0.45; font-weight: 500; }
.person[aria-pressed="false"] .sw { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.ov-panel .who { border-top: 1px solid var(--grid); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.colour-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 36px; }
.swatch-row { display: inline-flex; gap: 6px; }
.swatch-btn { width: 30px; height: 24px; padding: 0; cursor: pointer; background: var(--paper); border: 1px solid var(--paper-edge);
  box-shadow: 2px 2px 0 var(--paper-edge); border-radius: 2px; }
.swatch-btn[aria-checked="true"] { outline: 2px solid var(--fg); outline-offset: 2px; }
.swatch-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.note.pickable { cursor: pointer; }
.note.pickable:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.note.picked { outline: 2px solid var(--fg); outline-offset: 2px; z-index: 1000 !important; }
.said { padding: 6px 9px; background: var(--paper); color: var(--paper-ink); border-radius: 2px; font-size: 14px; }

/* ---------- Front page ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; align-items: center; padding: 24px 0 16px; }
@media (max-width: 900px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero-title { font-size: clamp(30px, 4vw, 44px); line-height: 1.08; }
.lede { font-size: 18px; max-width: 60ch; }
figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.shot { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
ol.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 28px; }
.step { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 28px; align-items: center; }
.step p { max-width: 52ch; }
@media (max-width: 900px) { .step { grid-template-columns: minmax(0, 1fr); } }
.step-n { font-family: var(--mono); font-size: 13px; color: var(--ink); border: 1px solid var(--ink); border-radius: 999px;
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; }
.shots-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 760px) { .shots-2 { grid-template-columns: minmax(0, 1fr); } }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cta { align-items: flex-start; }
dialog.exp { overflow: auto; }
.btn.quiet[aria-current="page"] { color: var(--fg); }

/* Automatic deletion countdown */
.expiry { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--fg); background: var(--surface); }
.expiry.soon { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.expiry .muted { font-weight: 500; }
.countdown { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.countdown .days { font-family: var(--display); font-size: 44px; font-weight: 700; line-height: 1; }
.countdown.soon .days { color: var(--danger); }
