/*===== TERMINAL SYSTEM =====
  Shared by every page: reset, ink tokens, the ink switch, the header, the
  section jump overlay, 1-bit windows, hover boxes, buttons, scroll reveals
  and the footer. Section styles build on these. */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
}

h1, h2, h3, h4, p, figure, ul, ol {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button {
  font: inherit;
  color: inherit;
}

/*===== INK =====*/
:root {
  --ink: #0B0B0C;
  --paper: #FFFFFF;
  --blue: #1E5EFF;
  --dim: color-mix(in srgb, var(--ink) 58%, var(--paper));
  --rule: color-mix(in srgb, var(--ink) 17%, var(--paper));
  --text: color-mix(in srgb, var(--ink) 84%, var(--paper));
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --hx-header-h: 56px;
}

html[data-ink="night"] {
  --ink: #F1F1EE;
  --paper: #0B0B0C;
  --blue: #6E9BFF;
  color-scheme: dark;
}

body.hx {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
}

body.hx section[id] {
  scroll-margin-top: var(--hx-header-h);
}

body.hx section[tabindex="-1"]:focus {
  outline: none;
}

/*===== INK SWITCH =====*/
.hx-ink {
  position: fixed;
  z-index: 60;
  top: calc(env(safe-area-inset-top, 0px) + 15px);
  right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 12px var(--mono);
  color: var(--ink);
}

.hx-ink__label {
  color: var(--dim);
}

.hx-ink__opts {
  display: flex;
  border: 1px solid var(--ink);
  background-color: var(--paper);
}

.hx-ink__opts button {
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 10px;
  cursor: pointer;
}

.hx-ink__opts button + button {
  border-left: 1px solid var(--ink);
}

.hx-ink__opts button[aria-pressed="true"] {
  background-color: var(--ink);
  color: var(--paper);
}

.hx-ink__opts button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* switching ink redraws the screen top to bottom, like a terminal */
::view-transition-old(root) {
  animation: none;
}

::view-transition-new(root) {
  animation: hx-redraw .45s steps(12, end) both;
}

@keyframes hx-redraw {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}

/*===== HEADER =====*/
.hx-header {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--hx-header-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background-color: var(--paper);
  border-bottom: 1px solid var(--rule);
  font: 500 13px var(--mono);
  transform: translateY(-100%);
  visibility: hidden;
  transition: transform .28s steps(5, end), visibility 0s linear .28s;
}

.hx-header.is-shown {
  transform: none;
  visibility: visible;
  transition: transform .28s steps(5, end), visibility 0s;
}

.hx-header__nav {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 190px 0 max(16px, env(safe-area-inset-left, 0px));
}

.hx-header__logo {
  font-weight: 700;
  color: var(--blue);
}

.hx-header__links {
  display: flex;
  gap: 6px 18px;
}

.hx-header__link {
  padding: 4px 2px;
  color: var(--dim);
}

.hx-header__link:hover,
.hx-header__link[aria-current] {
  color: var(--ink);
}

.hx-header__link[aria-current] {
  box-shadow: inset 0 -2px 0 var(--blue);
}

.hx-header a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

@media screen and (max-width: 640px) {
  :root {
    --hx-header-h: 92px;
  }
  .hx-header__nav {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .hx-header__links {
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/*===== SECTION JUMP OVERLAY =====*/
.hx-warp {
  position: fixed;
  inset: 0;
  z-index: 70;
  padding: clamp(24px, 6vw, 64px) max(16px, 6vw);
  background-color: var(--paper);
  color: var(--dim);
  font: 500 14px var(--mono);
}

.hx-warp__line {
  margin: 0;
}

.hx-warp.is-in {
  animation: hx-warp-in .36s cubic-bezier(.7, 0, .2, 1) both;
}

.hx-warp.is-out {
  animation: hx-warp-out .38s cubic-bezier(.7, 0, .2, 1) both;
}

@keyframes hx-warp-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes hx-warp-out {
  from { clip-path: inset(0 0 0 0); }
  to { clip-path: inset(0 0 0 100%); }
}

/*===== TYPING CARET =====*/
.hx-caret {
  display: inline-block;
  width: .55em;
  height: 1em;
  vertical-align: -.14em;
  margin-left: .06em;
  background-color: var(--ink);
  animation: hx-blink 1s steps(1) infinite;
}

@keyframes hx-blink {
  50% { opacity: 0; }
}

/*===== SECTION LAYOUT =====*/
.t-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  gap: clamp(64px, 8vw, 104px);
  max-width: 1180px;
  margin: 0 auto;
  padding-block: clamp(80px, 10vw, 128px);
  padding-left: max(clamp(16px, 5vw, 60px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(16px, 5vw, 60px), env(safe-area-inset-right, 0px));
}

/* full screen width, with a little room at the edges */
.t-wrap--wide {
  max-width: none;
  padding-left: max(clamp(16px, 3.5vw, 48px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(16px, 3.5vw, 48px), env(safe-area-inset-right, 0px));
}

.t-prompt {
  margin-bottom: 10px;
  min-height: 1.5em;
  font: 400 13px/1.5 var(--mono);
  color: var(--dim);
}

.t-title {
  font: 800 clamp(30px, 4.6vw, 52px)/1.05 var(--mono);
  letter-spacing: -.03em;
}

.t-subtitle {
  margin-bottom: 22px;
  font: 800 clamp(22px, 3vw, 32px)/1.1 var(--mono);
  letter-spacing: -.02em;
}

/*===== 1-BIT WINDOW =====*/
.t-win {
  background-color: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.t-win__bar {
  display: grid;
  grid-template-columns: 22px 1fr 22px;
  align-items: center;
  height: 28px;
  padding: 6px;
  border-bottom: 2px solid var(--ink);
  background: repeating-linear-gradient(var(--ink) 0 1px, transparent 1px 3px) content-box;
  user-select: none;
}

.t-win__close {
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  background-color: var(--paper);
}

.t-win__title {
  justify-self: center;
  padding: 0 8px;
  background-color: var(--paper);
  font: 700 12px/14px var(--mono);
}

.t-win__status {
  padding: 8px 12px;
  border-top: 2px solid var(--ink);
  font: 500 12px/1.4 var(--mono);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*===== HOVER BOX: hatching and blue corner ticks =====*/
.t-box {
  position: relative;
}

.t-box::before,
.t-box::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 0 solid var(--blue);
  opacity: 0;
  pointer-events: none;
  transition: top .2s, left .2s, right .2s, bottom .2s, opacity .2s;
}

.t-box::before {
  top: -2px;
  left: -2px;
  border-top-width: 2px;
  border-left-width: 2px;
}

.t-box::after {
  bottom: -2px;
  right: -2px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

.t-box:hover,
.t-box:focus-visible {
  background-image: repeating-linear-gradient(135deg, var(--rule) 0 1px, transparent 1px 7px);
}

.t-box:hover::before,
.t-box:focus-visible::before {
  top: -7px;
  left: -7px;
  opacity: 1;
}

.t-box:hover::after,
.t-box:focus-visible::after {
  bottom: -7px;
  right: -7px;
  opacity: 1;
}

/*===== BUTTONS =====*/
.t-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--ink);
  background-color: var(--paper);
  color: var(--ink);
  font: 500 13px/1.2 var(--mono);
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}

.t-btn:hover,
.t-btn:focus-visible {
  background-color: var(--ink);
  color: var(--paper);
}

.t-btn--solid {
  background-color: var(--ink);
  color: var(--paper);
}

.t-btn--solid:hover,
.t-btn--solid:focus-visible {
  border-color: var(--blue);
  background-color: var(--blue);
}

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

/*===== SCROLL REVEAL =====*/
.hx-js .t-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .6s ease, transform .6s cubic-bezier(.2, .7, .2, 1);
}

.hx-js .t-reveal.is-in {
  opacity: 1;
  transform: none;
}

/* boxes inside a revealed part come in one after another */
.hx-js .t-stagger {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .3s ease, transform .3s ease;
  transition-delay: calc(var(--i, 0) * 45ms + .2s);
}

.hx-js .t-stagger.is-in {
  opacity: 1;
  transform: none;
}

/*===== FOOTER =====*/
.t-footer {
  border-top: 1px solid var(--rule);
  font: 500 12.5px/1.5 var(--mono);
  color: var(--dim);
}

.t-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 28px;
  max-width: 1180px;
  margin: 0 auto;
  padding-block: 28px calc(28px + env(safe-area-inset-bottom, 0px));
  padding-left: max(clamp(16px, 5vw, 60px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(16px, 5vw, 60px), env(safe-area-inset-right, 0px));
}

.t-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.t-footer a:hover {
  color: var(--ink);
}

.t-footer a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .hx-caret,
  ::view-transition-new(root) {
    animation: none;
  }
  .hx-header,
  .t-box::before,
  .t-box::after,
  .hx-js .t-reveal,
  .hx-js .t-stagger {
    transition: none;
  }
}
