/* sawyerchristensen.com contact page.
   Light: black on white. Dark: phosphor green on black. Follows the device setting. */

:root {
  --bg: #ffffff;
  --fg: #000000;
  --fg-dim: rgb(0 0 0 / 0.42);
  --fg-faint: rgb(0 0 0 / 0.1);
  --rain: #000000;
  --rain-head: #000000;
  --glow: 0 0 0 transparent;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
  /* The falling-code grid; keep in sync with CELL_W / CELL_H in site.js. */
  --cell-w: 14px;
  --cell-h: 19px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #33ff66;
    --fg-dim: rgb(51 255 102 / 0.45);
    --fg-faint: rgb(51 255 102 / 0.14);
    --rain: #33ff66;
    --rain-head: #e4ffe9;
    --glow: 0 0 14px rgb(51 255 102 / 0.35);
  }
}

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

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

::selection { background: var(--fg); color: var(--bg); }

/* Falling code. Drawn only inside the cursor's reveal; elsewhere the page is a solid color. */
#rain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 0;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(44px, 8vh, 76px);
  /* Top padding clears the menus. */
  padding: calc(var(--cell-h) * 6) 16px 56px;
}

/* ---------- Nav ---------- */
/* Each word's box sits exactly on the falling-code grid (columns of --cell-w, rows of
   --cell-h, matching CELL_W/CELL_H in site.js). site.js sets its width (whole columns)
   and left edge (nearest column to 1/4, 2/4, 3/4 of the width). The box is the page
   color, and the code isn't drawn under it, so a revealed word is always legible. */

.nav {
  position: fixed;
  top: calc(var(--cell-h) * 2);
  left: 0;
  right: 0;
  height: calc(var(--cell-h) * 2);
  z-index: 2;
  pointer-events: none;
}

.nav-link {
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 calc(var(--cell-w) / 2);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  pointer-events: auto;
}

/* Before site.js places them, fall back to plain quarter positions. */
.nav-link[data-at="0.25"] { left: 25%; transform: translateX(-50%); }
.nav-link[data-at="0.5"] { left: 50%; transform: translateX(-50%); }
.nav-link[data-at="0.75"] { left: 75%; transform: translateX(-50%); }
.nav.is-placed .nav-link { transform: none; }

.nav-link span { position: relative; }

/* Underline draws in from the left on hover, and slides out to the right after. */
.nav-link span::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.24s ease-out;
}

.nav-link:hover span::after,
.nav-link:focus-visible span::after {
  transform: scaleX(1);
  transform-origin: left;
}

.nav-link:focus { outline: none; }

@media (prefers-reduced-motion: reduce) {
  .nav-link span::after { transition: none; }
}

/* With a mouse, words are revealed by the same soft circle as the falling code
   (site.js feeds the pointer position and radius in as --px/--py/--pr; each word
   knows its own page offset as --ox/--oy). The stops match the canvas mask. */
@media (hover: hover) and (pointer: fine) {
  .js .nav-link {
    --reveal-mask: radial-gradient(
      circle calc(var(--pr, 0) * 1px)
        at calc((var(--px, -9999) - var(--ox, 0)) * 1px) calc((var(--py, -9999) - var(--oy, 0)) * 1px),
      #000 0%, rgb(0 0 0 / 0.9) 35%, rgb(0 0 0 / 0.45) 65%, rgb(0 0 0 / 0.1) 88%, transparent 100%);
    -webkit-mask-image: var(--reveal-mask);
    mask-image: var(--reveal-mask);
  }

  .js .nav-link:hover,
  .js .nav-link:focus-visible {
    -webkit-mask-image: none;
    mask-image: none;
  }
}

/* Soft bg-colored halo keeps text legible when code falls behind it. */
.contact-title {
  text-shadow: var(--glow), 0 0 3px var(--bg), 0 0 12px var(--bg);
}

/* ---------- Contact ---------- */

.contact {
  width: min(100%, 540px);
}

.contact-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* A little 90s desktop window: pinstriped title bar, hard edges, dithered drop shadow. */
.window {
  position: relative;
  margin: 0;
  background: var(--bg);
  border: 2px solid var(--fg);
}

.window::after {
  content: "";
  position: absolute;
  inset: -2px;
  transform: translate(8px, 8px);
  z-index: -1;
  background: repeating-conic-gradient(var(--fg) 0 25%, transparent 0 50%) 0 0 / 4px 4px;
  pointer-events: none;
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  padding: 0 9px;
  border-bottom: 2px solid var(--fg);
  background:
    repeating-linear-gradient(to bottom, var(--fg) 0 1px, transparent 1px 3px)
    center / calc(100% - 12px) 13px no-repeat;
  user-select: none;
}

.titlebar-box {
  width: 13px;
  height: 13px;
  border: 2px solid var(--fg);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--bg);
}

.window-body {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 14px 14px;
  padding: 22px 20px;
}

.field-label {
  padding-top: 12px;
  font-size: 13px;
  line-height: 20px;
  letter-spacing: 0.04em;
}

.field-input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 2px solid var(--fg);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  line-height: 20px;
  caret-color: var(--fg);
  /* Sunken field. */
  box-shadow: inset 3px 3px 0 var(--fg-faint);
  -webkit-appearance: none;
  appearance: none;
}

.field-input::placeholder { color: var(--fg-dim); opacity: 1; }

.field-input:focus { outline: none; }

.field-input:focus-visible {
  outline: 2px dashed var(--fg);
  outline-offset: 3px;
}

.field-input[aria-invalid="true"] {
  border-style: dashed;
}

textarea.field-input {
  min-height: 150px;
  resize: vertical;
}

.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Centered under the window. Only takes space while Cloudflare is showing a
   challenge (contact.js toggles the class); the margin clears the dithered shadow. */
.turnstile {
  display: flex;
  justify-content: center;
  height: 0;
  overflow: hidden;
}
.turnstile.is-visible {
  height: auto;
  overflow: visible;
  margin-top: 30px;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px 12px 20px;
  border-top: 2px solid var(--fg);
}

.status {
  margin: 0;
  min-width: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  vertical-align: 1px;
  background: currentColor;
}

.status a { color: inherit; }

.send {
  flex: none;
  padding: 8px 16px 8px 18px;
  border: 2px solid var(--fg);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 var(--fg);
  cursor: pointer;
}

.send:not(:disabled):hover {
  background: var(--fg);
  color: var(--bg);
}

.send:disabled {
  cursor: progress;
  opacity: 0.6;
}

.send:not(:disabled):active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.send:focus { outline: none; }

.send:focus-visible {
  outline: 2px dashed var(--fg);
  outline-offset: 5px;
}

/* ---------- Small screens / touch ---------- */

@media (max-width: 520px) {
  .window-body {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 18px 16px;
  }
  .field-label { padding-top: 0; }
  .field-label + .field-input + .field-label { margin-top: 10px; }
  .statusbar { padding-left: 16px; }
}

@media (pointer: coarse) {
  /* 16px stops iOS zooming in on focus. */
  .field-input { font-size: 16px; }
}
