@import url('/fonts/fonts.css');

/* ───────────────────────────────────────────────────────────────────────────
   Scratchpad
   Every pad has a lifespan, so the page is built on one: a line runs down the
   left, the note sits at its origin, replies hang off it in order, and it ends
   at the moment the pad deletes itself.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light dark;

  --display: 'Bricolage Grotesque', 'Schibsted Grotesk', system-ui, sans-serif;
  --sans: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /*
   * The accent is not fixed: --pad-hue is set from how long the pad lives, so an
   * hour-long note runs hot and a permanent one sits in violet. Everything that
   * carries the pad's identity reads from it.
   */
  --pad-hue: 190;

  --ground: #f0eef4;
  --raised: #f8f7fa;
  --tint: hsl(var(--pad-hue) 46% 97%);
  --ink: #221f33;
  --ink-soft: #605a76;
  --ink-faint: #8e88a3;
  --rule: #d6d1e2;
  --rule-soft: #e2dfeb;
  --accent: hsl(var(--pad-hue) 58% 42%);
  --accent-line: hsl(var(--pad-hue) 55% 50%);
  --accent-soft: hsl(var(--pad-hue) 58% 42% / 0.12);
  --mint: #157f68;
  --mint-soft: rgba(21, 127, 104, 0.14);
  --danger: #b4402f;

  --gutter: 3.25rem;
  --measure: 44rem;
  --radius: 4px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

/*
 * Dark is applied by attribute rather than by media query: an inline script in
 * each page resolves the reader's choice — system, light, or dark — before the
 * first paint, so a manual pick and the system setting go through one path.
 */
:root[data-theme='dark'] {
    --ground: #171526;
    --raised: #1e1b2f;
    --tint: hsl(var(--pad-hue) 30% 14%);
    --ink: #efecf7;
    --ink-soft: #a8a1c0;
    --ink-faint: #726c8c;
    --rule: #332e4a;
    --rule-soft: #2a2640;
    --accent: hsl(var(--pad-hue) 72% 70%);
    --accent-line: hsl(var(--pad-hue) 68% 62%);
    --accent-soft: hsl(var(--pad-hue) 72% 70% / 0.16);
    --mint: #7fd1b9;
    --mint-soft: rgba(127, 209, 185, 0.14);
    --danger: #f08080;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(1.5rem, 5vw, 3.5rem) 1.25rem 5rem;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

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

h1,
h2,
p {
  margin: 0;
}

.frame {
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter));
  margin: 0 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.is-hidden {
  display: none !important;
}

/* ─── masthead ──────────────────────────────────────────────────────────── */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-left: var(--gutter);
  margin-bottom: clamp(2rem, 6vw, 3.5rem);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

.wordmark-bar {
  width: 3px;
  height: 1.05rem;
  background: var(--accent);
  border-radius: 2px;
}

.masthead-note,
.presence {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.masthead-end {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
}

.theme {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}

.theme:hover {
  color: var(--ink-soft);
  border-bottom-color: var(--accent);
}

.theme svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.presence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: background 300ms var(--ease);
}

.presence.is-live {
  color: var(--mint);
}

.presence.is-live .presence-dot {
  background: var(--mint);
  animation: pulse 3s var(--ease) infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--mint-soft);
  }
  50% {
    box-shadow: 0 0 0 5px transparent;
  }
}

/* ─── compose: the lede ─────────────────────────────────────────────────── */
.lede {
  padding-left: var(--gutter);
  margin-bottom: 2.25rem;
}

.lede h1 {
  font-family: var(--display);
  font-size: clamp(2.6rem, 8vw, 4.25rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.lede p {
  max-width: 32rem;
  margin-top: 1.1rem;
  font-size: 0.98rem;
  color: var(--ink-soft);
}

/* ─── compose: the writing surface ──────────────────────────────────────── */
.surface {
  position: relative;
  padding: 1.5rem 1.5rem 0;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

/* the live edge, coloured by the lifespan chosen below */
.surface::before {
  content: '';
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -1px;
  width: 3px;
  background: var(--accent);
  border-radius: var(--radius) 0 0 var(--radius);
}

.surface-title {
  width: 100%;
  padding: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.surface-title::placeholder {
  color: var(--ink-faint);
}

.surface-title:focus,
.surface-body:focus {
  outline: 0;
}

.surface-body {
  display: block;
  width: 100%;
  min-height: 14rem;
  margin-top: 0.9rem;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.85;
  color: var(--ink);
  background: transparent;
  border: 0;
  resize: vertical;
}

.surface-body::placeholder {
  color: var(--ink-faint);
}

/* ─── compose: the retention dial ───────────────────────────────────────── */
.dial {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
  margin: 0 -1.5rem;
  padding: 1.1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--rule-soft);
}

.dial-scale {
  display: flex;
  margin: 0;
  padding: 0;
  border: 0;
}

.tick {
  position: relative;
  padding: 0.9rem 0.7rem 0.15rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 160ms var(--ease);
}

.tick input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* the scale line, drawn once across every tick */
.tick::before {
  content: '';
  position: absolute;
  top: 0.55rem;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
}

.tick:nth-of-type(1) {
  --tick-hue: 8;
}
.tick:nth-of-type(2) {
  --tick-hue: 32;
}
.tick:nth-of-type(3) {
  --tick-hue: 190;
}
.tick:nth-of-type(4) {
  --tick-hue: 248;
}
.tick:nth-of-type(5) {
  --tick-hue: 285;
}

/* each tick's own mark, which fills in when chosen */
.tick::after {
  content: '';
  position: absolute;
  top: 0.15rem;
  left: 50%;
  width: 1px;
  height: 0.8rem;
  background: hsl(var(--tick-hue, 190) 55% 60% / 0.75);
  transform: translateX(-50%);
  transition: background 160ms var(--ease), height 160ms var(--ease), top 160ms var(--ease);
}

.tick:hover {
  color: var(--ink-soft);
}

.tick:has(input:checked) {
  color: var(--ink);
  font-weight: 500;
}

.tick:has(input:checked)::after {
  top: 0;
  height: 1.15rem;
  background: hsl(var(--tick-hue, 190) 62% 48%);
}

.tick:has(input:focus-visible) {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
  border-radius: 2px;
}

.tick:has(input:disabled) {
  cursor: default;
  opacity: 0.7;
}

.dial-readout {
  flex: 1 1 10rem;
  min-width: 0;
}

.dial-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.dial-verdict {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
}

.dial-date,
.counter,
.pad-slug,
.hint {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.counter.is-over {
  color: var(--danger);
}

/* ─── buttons ───────────────────────────────────────────────────────────── */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ground);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
}

.button:hover {
  opacity: 0.85;
}

.button:active {
  transform: translateY(1px);
}

.button[disabled] {
  cursor: not-allowed;
  opacity: 0.35;
}

.action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}

.action:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.action.is-danger {
  color: var(--danger);
  border-bottom-color: transparent;
}

.action.is-danger:hover {
  border-bottom-color: var(--danger);
}

.action svg,
.button svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── compose: the issued link ──────────────────────────────────────────── */
.issued {
  margin-top: 1.25rem;
  padding: 1.35rem 1.5rem 1.5rem;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  animation: settle 420ms var(--ease) both;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.issued-label,
.issued-note {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.issued-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0 0.75rem;
}

.issued-link {
  flex: 1 1 16rem;
  min-width: 0;
  padding-bottom: 0.35rem;
  font-family: var(--mono);
  font-size: clamp(0.95rem, 2.6vw, 1.25rem);
  color: var(--ink);
  border-bottom: 1px solid var(--accent);
  overflow-x: auto;
  white-space: nowrap;
}

.issued-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1.1rem;
}

/* ─── the thread ────────────────────────────────────────────────────────── */
.thread {
  position: relative;
  padding-left: var(--gutter);
}

.lifeline {
  position: absolute;
  top: 0.6rem;
  bottom: 0.6rem;
  left: calc(var(--gutter) / 2 - 1px);
  width: 2px;
}

/*
 * Solid colour from the note down to the newest reply — everything that has
 * happened — then a fade to nothing at the moment the pad deletes itself.
 */
.lifeline-track {
  display: block;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(
    to bottom,
    hsl(var(--pad-hue) 62% 48%) 0,
    var(--accent-line) var(--lived, 60%),
    color-mix(in oklab, var(--accent-line) 32%, transparent) var(--lived, 60%),
    transparent 100%
  );
}

.node {
  position: relative;
  padding-bottom: 2rem;
}

.node-marker {
  position: absolute;
  top: 0.35rem;
  left: calc(var(--gutter) / -2 - 6px);
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: 3px solid var(--ground);
  border-radius: 50%;
}

.node-marker-origin {
  width: 16px;
  height: 16px;
  top: 0.15rem;
  left: calc(var(--gutter) / -2 - 8px);
}

.node-compose .node-marker,
.node-terminus .node-marker,
.node-empty .node-marker {
  top: -6px;
}

.reply .reply-mark {
  top: 0.9rem;
}

.node-marker-open {
  background: var(--ground);
  border: 2px solid var(--rule);
}

.node-marker-end {
  background: var(--ground);
  border: 2px solid var(--ink-faint);
}

.node-stamp {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

/* ─── the pad itself ────────────────────────────────────────────────────── */
.pad-title {
  margin-top: 0.35rem;
  font-family: var(--display);
  font-size: clamp(1.75rem, 5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.pad-body {
  margin-top: 1.1rem;
  padding: 1.25rem 1.4rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.85;
  color: var(--ink);
  background: var(--tint);
  border: 1px solid var(--rule-soft);
  border-left: 2px solid var(--accent-line);
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.pad-body a,
.reply-text a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.pad-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.9rem;
}

.pad-slug {
  margin-right: auto;
}

/* ─── replies ───────────────────────────────────────────────────────────── */
.node-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.reply {
  position: relative;
  padding-top: 1.35rem;
  padding-bottom: 1.35rem;
}

/*
 * A hairline between entries, reaching left to meet the lifeline so the split
 * reads as a mark on the timeline rather than a box edge. Each one carries a
 * trace of its author's colour.
 */
.node-list .reply::before,
.node-compose::before,
.node-terminus::before {
  content: '';
  position: absolute;
  top: 0;
  left: calc(var(--gutter) / -2);
  right: 0;
  height: 1px;
  background: linear-gradient(
    to right,
    hsl(var(--hue, var(--pad-hue)) 45% 55% / 0.45),
    hsl(var(--hue, var(--pad-hue)) 45% 55% / 0.14) 45%,
    var(--rule-soft)
  );
}

.reply.is-new {
  animation: arrive 420ms var(--ease) both;
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* a reply's marker is its author: a coloured square sitting on the line */
.reply-mark {
  position: absolute;
  top: 0.1rem;
  left: calc(var(--gutter) / -2 - 13px);
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 500;
  color: hsl(var(--hue, 20) 60% 22%);
  background: hsl(var(--hue, 20) 68% 78%);
  border: 3px solid var(--ground);
  border-radius: 4px;
}

.reply-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.reply-head .who {
  color: hsl(var(--hue, 20) 52% 36%);
}

.reply-head .who.is-mine {
  color: var(--mint);
}

.reply-text {
  margin-top: 0.3rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.node-empty p {
  font-size: 0.9rem;
  color: var(--ink-faint);
}

/* ─── the reply box ─────────────────────────────────────────────────────── */
.node-compose {
  padding-top: 1.35rem;
}

.node-compose .node-stamp {
  margin-bottom: 0.5rem;
}

.node-compose textarea {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.15rem 0 0.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  resize: vertical;
  transition: border-color 160ms var(--ease);
}

.node-compose textarea::placeholder {
  color: var(--ink-faint);
}

.node-compose textarea:focus {
  outline: 0;
  border-bottom-color: var(--accent);
}

.compose-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.hint {
  display: inline-flex;
  gap: 0.25rem;
}

kbd {
  padding: 0.05rem 0.3rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.compose-foot .counter {
  margin-left: auto;
}

/* ─── the end of the line ───────────────────────────────────────────────── */
.node-terminus {
  padding-top: 1.35rem;
  padding-bottom: 0;
}

.terminus-label {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-soft);
}

.terminus-time {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.terminus-time.is-soon {
  color: var(--accent);
}

/* ─── notices and footer ────────────────────────────────────────────────── */
.notice {
  margin-bottom: 1.5rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  color: var(--danger);
  background: var(--accent-soft);
  border-left: 2px solid var(--danger);
}

.notice:empty {
  display: none;
}

.colophon {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  padding-left: var(--gutter);
  margin-top: 3rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.colophon a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

.colophon a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ─── the void ──────────────────────────────────────────────────────────── */
.void {
  position: relative;
  padding-left: var(--gutter);
}

/* the last inch of a lifeline, ending in nothing */
.void-line {
  position: absolute;
  top: -3.5rem;
  left: calc(var(--gutter) / 2 - 1px);
  width: 2px;
  height: 6rem;
  background: linear-gradient(to bottom, transparent, var(--accent));
  opacity: 0.6;
}

.void-line::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: -5px;
  width: 12px;
  height: 12px;
  background: var(--ground);
  border: 2px solid var(--ink-faint);
  border-radius: 50%;
}

.void h1 {
  font-family: var(--display);
  font-size: clamp(2.4rem, 7vw, 3.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
}

.void p {
  max-width: 26rem;
  margin: 1rem 0 2rem;
  color: var(--ink-soft);
}

/* ─── narrow screens ────────────────────────────────────────────────────── */
@media (max-width: 40rem) {
  :root {
    --gutter: 2.25rem;
  }

  .surface {
    padding: 1.15rem 1.15rem 0;
  }

  .dial {
    margin: 0 -1.15rem;
    padding: 1rem 1.15rem 1.15rem;
  }

  .dial-scale {
    flex: 1 1 100%;
  }

  .tick {
    flex: 1 1 auto;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    text-align: center;
  }

  .pad-body {
    padding: 1rem 1.05rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* Last, so these outrank the light-mode rules of the same weight. */
:root[data-theme='dark'] .reply-head .who {
  color: hsl(var(--hue, 20) 70% 76%);
}

:root[data-theme='dark'] .reply-mark {
  color: hsl(var(--hue, 20) 85% 84%);
  background: hsl(var(--hue, 20) 45% 30%);
}
