/* SendKey brand system, third edition: 1-bit.
   Paper and ink only. Every gray in the imagery is a dither pattern; the
   pixel display face is self-hosted, so the strict CSP stays intact.
   Hard edges, hard shadows, zero border radius. */

@font-face {
  font-family: "Press Start 2P";
  src: url("/assets/fonts/press-start-2p-latin.woff2") format("woff2");
  font-display: swap;
}

:root {
  --paper: #f2efe9;
  --paper-2: #e7e3d8;
  --field: #faf8f3;
  --ink: #141412;
  --ink-2: #45453f;
  --ink-3: #73736a;
  --ink-dim: #b9b5a9; /* secondary text on inverted panels */

  --font-px: "Press Start 2P", ui-monospace, monospace;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  /* 50% checker, drawn by CSS so it needs no asset */
  --checker: repeating-conic-gradient(var(--ink) 0 25%, transparent 0 50%);

  /* resolves per theme at the root, so pinned scopes (the terminal) can
     still draw their outer edge in the theme's contrast color */
  --edge: var(--ink);

  color-scheme: light;
}

/* Dark theme: ink and paper trade places. Same two colors, same rules;
   inverted panels (the headline block, the page tail, errors) simply come
   out light instead of black. theme.js stamps data-theme before first
   paint; the media block covers users with JavaScript disabled. */
:root[data-theme="dark"] {
  --paper: #121210;
  --paper-2: #1a1a17;
  --field: #191916;
  --ink: #f2efe9;
  --ink-2: #c9c5b9;
  --ink-3: #96938a;
  --ink-dim: #5a574f;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121210;
    --paper-2: #1a1a17;
    --field: #191916;
    --ink: #f2efe9;
    --ink-2: #c9c5b9;
    --ink-3: #96938a;
    --ink-dim: #5a574f;
    color-scheme: dark;
  }
}

/* transitions exist only while theme.js flips the attribute */
.theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color 0.25s ease, color 0.25s ease,
    border-color 0.25s ease, box-shadow 0.25s ease, fill 0.25s ease !important;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
}

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

h1, h2, h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-px);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 1.45;
  letter-spacing: 0;
}

p { margin: 0; }

a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
/* inversion on hover only where hover is real; on touch screens the style
   would stick to the link after a tap */
@media (hover: hover) {
  a:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
}

code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  background: var(--paper-2);
  border: 1px solid var(--ink);
  padding: 0 0.3em;
}

.hidden { display: none !important; }

.wrap {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 24px;
}

.mono { font-family: var(--font-mono); }

:focus-visible {
  outline: 2px dotted var(--ink);
  outline-offset: 3px;
}

/* ---- logo ------------------------------------------------------------- */

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logo:hover { background: none; color: var(--ink); }
@media (hover: hover) {
  .logo:hover .wordmark { background: var(--ink); color: var(--paper); }
}
.logo-mark {
  width: auto;
  height: 26px;
  display: block;
  image-rendering: pixelated;
  fill: currentColor; /* inline svg: the mark follows the theme */
}
.wordmark {
  font-family: var(--font-px);
  font-size: 13px;
  text-transform: uppercase;
  color: var(--ink);
  padding: 2px 3px;
}

/* ---- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 9px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.06s steps(2), box-shadow 0.06s steps(2);
}
.btn:hover { background: var(--ink); color: var(--paper); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: 3px 3px 0 var(--ink); }

.btn-ghost { background: var(--paper); color: var(--ink); }
.btn-ghost:hover { background: var(--paper); color: var(--ink); }

.btn-sm { padding: 5px 10px; font-size: 12px; box-shadow: 2px 2px 0 var(--ink); }
.btn-sm:hover { box-shadow: 3px 3px 0 var(--ink); }
.btn-sm:active { box-shadow: 1px 1px 0 var(--ink); }
.btn-lg { width: 100%; padding: 12px 18px; font-size: 14px; }

/* theme toggle: a square inverting itself, same glyph in both themes */
.theme-btn { padding: 5px 7px; }
.theme-btn svg {
  width: 15px;
  height: 15px;
  display: block;
  fill: currentColor;
}

/* on ink panels the shadow and border flip to paper */
.inv .btn { border-color: var(--paper); box-shadow: 3px 3px 0 var(--paper); }
.inv .btn:hover { box-shadow: 4px 4px 0 var(--paper); }
.inv .btn:active { box-shadow: 1px 1px 0 var(--paper); }
.inv .btn-ghost { background: var(--ink); color: var(--paper); }

/* ---- cards and windows -------------------------------------------------- */

.card {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 22px;
  box-shadow: 5px 5px 0 var(--ink);
}

/* System-style window: striped title bar, close box, plated title */
.win {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
}
.win-bar {
  position: relative;
  height: 30px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.win-bar::before {
  content: "";
  position: absolute;
  inset: 7px 8px;
  background: repeating-linear-gradient(
    to bottom,
    var(--ink) 0 2px,
    transparent 2px 5px
  );
}
.win-close {
  position: absolute;
  left: 14px;
  top: 50%;
  translate: 0 -50%;
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--paper);
}
.win-title {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  background: var(--paper);
  padding: 0 10px;
  font-family: var(--font-px);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}
.win-body { padding: 20px; }

/* ---- pills, labels ------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 2px solid var(--ink);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
}
.pill-dot {
  width: 7px;
  height: 7px;
  background: var(--ink);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 16px;
}
.eyebrow::before { content: "[ "; }
.eyebrow::after { content: " ]"; }

.lbl {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  margin-bottom: 7px;
}

/* ---- form controls ------------------------------------------------------- */

textarea, input[type="password"], input[type="text"], input:not([type]), select {
  width: 100%;
  background: var(--field);
  border: 2px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 96px; }
textarea::placeholder, input::placeholder { color: var(--ink-3); }
textarea:focus, input:focus, select:focus {
  outline: 2px dotted var(--ink);
  outline-offset: 2px;
}

.select { position: relative; }
.select select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
}
.select svg {
  position: absolute;
  right: 12px;
  top: 50%;
  translate: 0 -50%;
  width: 12px;
  height: 12px;
  fill: var(--ink);
  pointer-events: none;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.check input {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 2px solid var(--ink);
  background: var(--field);
  cursor: pointer;
  flex: none;
}
/* checked = filled with the 50% dither, the most 1-bit checkbox there is */
.check input:checked {
  background: var(--checker) 0 0 / 4px 4px, var(--field);
}
.check input:focus-visible { outline: 2px dotted var(--ink); outline-offset: 2px; }

/* ---- messages ----------------------------------------------------------- */

.msg-err {
  display: block;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 12px;
  margin-top: 12px;
}
.msg-err::before { content: "!! "; }
.msg-err:empty { display: none; }

.msg-ok {
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.msg-ok::before { content: "✓ "; }

.note {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
}
.note strong { color: var(--ink); }

.linkbox {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}
.linkbox input { flex: 1; min-width: 0; font-weight: 700; }

/* ---- dither utilities ----------------------------------------------------- */

.dither-fade {
  height: 32px;
  background: url("/assets/px/fade.png") repeat-x bottom / 8px 64px;
  image-rendering: pixelated;
}
.dither-fade-flip { transform: scaleY(-1); }

/* ---- small screens -------------------------------------------------------- */

@media (max-width: 560px) {
  /* 16px is the threshold below which iOS Safari zooms the page on focus;
     matching it keeps the viewport still while typing */
  textarea, input[type="password"], input[type="text"], input:not([type]), select {
    font-size: 16px;
  }
  textarea::placeholder, input::placeholder { font-size: 15px; }
  /* slightly taller small buttons for touch */
  .btn-sm { padding: 7px 12px; }
}

/* ---- motion ------------------------------------------------------------- */

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