/* Risograph: cream stock, hard black keylines, offset shadows, and two spot
   inks overprinted. Fonts are vendored under fonts/ so the page needs no
   third-party request and stays inside the app's default-src 'self' policy. */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/space-mono-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/space-mono-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/space-mono-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/space-mono-700-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;

  --paper: #fdf6e8;
  --card: #fffdf7;
  --ink: #141210;
  --muted: #6e6558;
  --keyline: #141210;

  --orange: #ff5c2b;
  --blue: #2b4bff;
  --yellow: #ffd84d;
  --red: #d61f3c;
  --green: #1f8a4c;

  --on-orange: #fdf6e8;
  --on-blue: #fdf6e8;
  --on-ink: #fdf6e8;
  --on-green: #ffffff;
  --on-red: #fdf6e8;

  --rule: 3px;
  --drop: 4px;
  --drop-lg: 8px;
  --sans: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --mono: "Space Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  /* Halftone speckle, as if the stock took the ink unevenly. */
  background-image:
    radial-gradient(var(--dot, rgb(20 18 16 / .055)) 1px, transparent 1px),
    radial-gradient(var(--dot, rgb(20 18 16 / .04)) 1px, transparent 1px);
  background-size: 14px 14px, 22px 22px;
  background-position: 0 0, 7px 11px;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: var(--rule) solid var(--blue);
  outline-offset: 2px;
}

/* ---- top bar ---------------------------------------------------------- */

.topbar {
  display: flex;
  gap: .7rem;
  align-items: center;
  padding: .8rem max(1rem, calc((100vw - 880px) / 2));
  background: var(--orange);
  color: var(--on-orange);
  border-bottom: var(--rule) solid var(--keyline);
}

.brand {
  color: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.045em;
  text-decoration: none;
  /* Misregistered second impression. */
  text-shadow: 2px 2px 0 var(--blue);
  transition: text-shadow .12s steps(2), transform .12s steps(2);
}

.brand:hover { text-shadow: 4px 4px 0 var(--blue); transform: translate(-1px, -1px); }

.code-form { display: flex; flex: 1; gap: .5rem; min-width: 0; }
.code-form input { min-width: 0; width: 100%; }

input, textarea {
  border: var(--rule) solid var(--keyline);
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  padding: .45rem .7rem;
  box-shadow: var(--drop) var(--drop) 0 var(--keyline);
}

input::placeholder, textarea::placeholder { color: #a99e8c; }

input:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--drop) var(--drop) 0 var(--blue);
}

button {
  border: var(--rule) solid var(--keyline);
  border-radius: 0;
  padding: .45rem 1rem;
  background: var(--blue);
  color: var(--on-blue);
  font-weight: 700;
  box-shadow: var(--drop) var(--drop) 0 var(--keyline);
  transition: transform .1s steps(2), box-shadow .1s steps(2);
}

/* Press: the button drops onto its own shadow. */
button:active {
  transform: translate(var(--drop), var(--drop));
  box-shadow: 0 0 0 var(--keyline);
}

button.quiet { background: var(--card); color: var(--ink); }
button.danger { background: var(--red); color: var(--on-red); }

/* ---- layout ----------------------------------------------------------- */

main {
  width: min(880px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
}

.tabs { display: flex; gap: .55rem; }
.browse-tab { margin-left: auto; }

.tab {
  background: var(--card);
  color: var(--ink);
  padding: .35rem 1.15rem;
  font-weight: 700;
}

.tab.active {
  background: var(--ink);
  color: var(--on-ink);
  box-shadow: var(--drop) var(--drop) 0 var(--orange);
}

.status {
  min-height: 1.5rem;
  margin: 1.1rem 0 .9rem;
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--blue);
}

.status:not(:empty)::before { content: "▸ "; }
.status.error { color: var(--red); }

/* ---- paste browser ---------------------------------------------------- */

.paste-list {
  border: var(--rule) solid var(--keyline);
  background: var(--card);
  box-shadow: var(--drop-lg) var(--drop-lg) 0 var(--keyline);
}

.paste-list-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.1rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: var(--rule) solid var(--keyline);
}

.paste-list-item:last-child { border-bottom: 0; }
.paste-list-item:hover { background: var(--yellow); color: #14120f; }
.paste-list-item strong { font-family: var(--mono); overflow-wrap: anywhere; }
.paste-list-item span { color: var(--muted); text-align: right; }
.paste-list-item:hover span { color: inherit; }

.browse-empty { margin: 0; padding: 3rem 1rem; text-align: center; color: var(--muted); }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 700;
}

.pagination button:disabled { opacity: .45; cursor: default; }

.markdown, #edit-form {
  min-height: 55vh;
  padding: 1.9rem;
  border: var(--rule) solid var(--keyline);
  background: var(--card);
  box-shadow: var(--drop-lg) var(--drop-lg) 0 var(--keyline);
}

/* ---- rendered markdown ------------------------------------------------ */

.markdown:empty { display: none; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }

.markdown h1, .markdown h2, .markdown h3,
.markdown h4, .markdown h5, .markdown h6 {
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
  margin: 1.8rem 0 .8rem;
}

.markdown h1 { font-size: 2.1rem; }
.markdown h2 { font-size: 1.6rem; }
.markdown h3 { font-size: 1.25rem; }

.markdown h1::after, .markdown h2::after {
  content: "";
  display: block;
  height: var(--rule);
  margin-top: .5rem;
  background: var(--orange);
}

.markdown img { max-width: 100%; border: var(--rule) solid var(--keyline); }

.markdown code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--yellow);
  border: 1px solid var(--keyline);
  padding: .04em .35em;
}

.markdown pre {
  overflow: auto;
  padding: 1rem 1.1rem;
  background: var(--blue);
  color: var(--on-blue);
  border: var(--rule) solid var(--keyline);
  box-shadow: var(--drop) var(--drop) 0 var(--keyline);
}

.markdown pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: .82rem;
}

.markdown blockquote {
  margin: 1.4rem 0;
  padding: .2rem 0 .2rem 1.1rem;
  border-left: var(--rule) solid var(--orange);
  color: var(--muted);
}

.markdown a {
  color: var(--blue);
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
}

.markdown a:hover { background: var(--yellow); color: var(--ink); }

.markdown hr { border: 0; border-top: var(--rule) solid var(--keyline); margin: 2rem 0; }

.markdown table { border-collapse: collapse; width: 100%; }
.markdown th, .markdown td { border: 1px solid var(--keyline); padding: .4rem .6rem; text-align: left; }
.markdown th { background: var(--yellow); font-weight: 700; }

/* ---- empty state ------------------------------------------------------ */

.empty { padding: 5rem 1rem; text-align: center; }
.empty h1 {
  margin: 0 0 .6rem;
  font-size: clamp(1.9rem, 6vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -.04em;
  text-shadow: 3px 3px 0 var(--orange);
}
.empty p { margin: 0; color: var(--muted); }

/* ---- editor ----------------------------------------------------------- */

#edit-form { display: flex; flex-direction: column; gap: 1.1rem; }

#editor {
  flex: 1;
  min-height: 50vh;
  resize: vertical;
  font-family: var(--mono);
  font-size: .9rem;
  line-height: 1.7;
}

.edit-actions, .dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

/* Chunky checkbox, drawn rather than native. The auto margin keeps Delete
   beside Save on the right rather than stranded in the middle. */
.edit-actions label {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 700;
  cursor: pointer;
}

#public {
  appearance: none;
  width: 1.35rem;
  height: 1.35rem;
  flex: none;
  border: var(--rule) solid var(--keyline);
  background: var(--card);
  box-shadow: 3px 3px 0 var(--keyline);
  display: grid;
  place-content: center;
}

#public::after {
  content: "✓";
  font-size: .9rem;
  font-weight: 700;
  line-height: 1;
  color: var(--on-green);
  opacity: 0;
}

#public:checked { background: var(--green); }
#public:checked::after { opacity: 1; }

/* ---- login dialog ----------------------------------------------------- */

dialog {
  width: min(380px, calc(100% - 2rem));
  padding: 1.6rem;
  border: var(--rule) solid var(--keyline);
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--drop-lg) var(--drop-lg) 0 var(--keyline);
}

dialog::backdrop { background: rgb(66 22 8 / .62); }

dialog form { display: grid; gap: .8rem; }

dialog h2 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.04em;
  text-shadow: 2px 2px 0 var(--blue);
}

dialog label { font-weight: 700; font-size: .85rem; }

.error {
  min-height: 1.4em;
  margin: 0;
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 700;
  color: var(--red);
}

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

/* ---- responsive ------------------------------------------------------- */

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .code-form { order: 2; flex-basis: 100%; }
  main { margin-top: 1.4rem; }
  .markdown, #edit-form { padding: 1.1rem; box-shadow: var(--drop) var(--drop) 0 var(--keyline); }
  .edit-actions { flex-wrap: wrap; }
  .paste-list-item { flex-direction: column; gap: .15rem; }
  .paste-list-item span { text-align: left; }
  .pagination { gap: .5rem; }
  .pagination button { padding-inline: .6rem; }
  /* Wide tables scroll on their own rather than pushing the page sideways. */
  .markdown table { display: block; width: max-content; max-width: 100%; overflow-x: auto; }
}

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

/* ---- dark: same inks, printed on black stock -------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14120f;
    --card: #1d1a16;
    --ink: #f7efdd;
    --muted: #a2977f;
    --keyline: #f7efdd;

    --orange: #ff6b3d;
    --blue: #6f86ff;
    --yellow: #f0c33c;
    --red: #ff6b7d;
    /* The dark-stock red is light enough that it needs dark text on it. */
    --on-red: #14120f;
    /* Lifted off the light-scheme green so the tick still carries on black
       stock, but kept dark enough to hold a white tick. */
    --green: #2ea363;

    --on-orange: #14120f;
    --on-blue: #14120f;
    --on-ink: #14120f;
    --on-green: #ffffff;

    --dot: rgb(247 239 221 / .05);
  }

  /* On dark stock the ink sits on the paper, so the drop shadow reads as the
     keyline colour and panels need their own fill to stay legible. */
  .tab { background: var(--card); }
  .tab.active { background: var(--ink); color: var(--on-ink); }
  .markdown pre { color: var(--on-blue); }
  .markdown code { color: #14120f; }
  .markdown th { color: #14120f; }
  button.quiet { background: var(--card); color: var(--ink); }
  dialog::backdrop { background: rgb(20 18 15 / .8); }
}
