/* Component layer. Buttons, panels, chips, fields, status, nav, footer. */

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 0 var(--s5);
  height: 44px;
  border: var(--hair) solid var(--line-strong);
  border-radius: var(--r);
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color var(--t-base) var(--ease), color var(--t-base) var(--ease),
    border-color var(--t-base) var(--ease), transform var(--t-micro) var(--ease);
}

.btn:hover {
  border-color: var(--text);
}

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

.btn--primary {
  background: var(--invert-bg);
  color: var(--invert-text);
  border-color: var(--invert-bg);
}

.btn--primary:hover {
  background: var(--text);
  border-color: var(--text);
}

.btn--ghost {
  border-color: var(--line);
  color: var(--text-2);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.btn--icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-color: var(--line);
}

.btn--sm {
  height: 36px;
  padding-inline: var(--s4);
}

.btn--block {
  width: 100%;
}

.btn .ico {
  transition: transform var(--t-base) var(--ease);
}

.btn:hover .ico--shift {
  transform: translateX(3px);
}

/* Highlight. For the one clause in a paragraph that carries the whole point.

   Resting state is always visible, so it works with JavaScript switched off.
   As the clause crosses the middle of the viewport, highlight.js adds .hl--on
   and it inverts: the strongest emphasis a black and white palette can make
   without borrowing a state colour. Everything around it dims at the same
   moment, because contrast is what the eye actually catches. */

.hl {
  position: relative;
  color: var(--text);
  font-weight: 600;
  /* mark carries a yellow background by default. The design has no yellow. */
  background-color: transparent;
  padding: 0.14em 0.28em;
  margin-inline: -0.1em;
  border-radius: 2px;
  background-image: linear-gradient(var(--hl-band), var(--hl-band)),
    linear-gradient(var(--text), var(--text));
  background-repeat: no-repeat;
  background-position: 0 0, 0 100%;
  background-size: 100% 100%, 100% 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: color var(--t-base) var(--ease),
    background-color var(--t-base) var(--ease),
    background-size var(--t-base) var(--ease);
}

/* Active: inverted block. Held while the line sits in the reading band. */
.hl--on {
  color: var(--invert-text);
  background-color: var(--invert-bg);
  background-image: none;
}

/* The surrounding sentence steps back while its highlight is lit. */
p.hl-context {
  color: var(--text-3);
  transition: color var(--t-base) var(--ease);
}

/* Link with an underline that draws in */

.linkline {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--text);
  padding-bottom: 2px;
}

.linkline::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: var(--hair);
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-base) var(--ease);
}

.linkline:hover::after,
.linkline:focus-visible::after {
  transform: scaleX(1);
}

/* Panels with corner ticks */

.panel {
  position: relative;
  background: var(--surface);
  border: var(--hair) solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s6);
  overflow: hidden;
}

.panel--flush {
  padding: 0;
}

.panel--brick::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--brick) var(--hair), transparent var(--hair)),
    linear-gradient(to bottom, var(--brick) var(--hair), transparent var(--hair));
  background-size: 32px 16px, 100% 16px;
  -webkit-mask-image: radial-gradient(120% 100% at 0% 0%, #000, transparent 78%);
  mask-image: radial-gradient(120% 100% at 0% 0%, #000, transparent 78%);
}

.panel > * {
  position: relative;
  z-index: 1;
}

.ticks::before,
.ticks::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: var(--hair) solid var(--line-strong);
  pointer-events: none;
  z-index: 2;
}

.ticks::before {
  top: 8px;
  left: 8px;
  border-right: 0;
  border-bottom: 0;
}

.ticks::after {
  bottom: 8px;
  right: 8px;
  border-left: 0;
  border-top: 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  height: 100%;
  transition: border-color var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}

.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-3px);
}

.card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: var(--hair) solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
}

.card__title {
  font-size: var(--fs-lg);
}

/* Chips and status */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 6px var(--s3);
  border: var(--hair) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
  position: relative;
}

.status-dot--ok {
  background: var(--ok);
}
.status-dot--warn {
  background: var(--warn);
}
.status-dot--err {
  background: var(--err);
}
.status-dot--info {
  background: var(--info);
}

.status-dot--pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.35;
  animation: dot-pulse 2.4s var(--ease) infinite;
}

@keyframes dot-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.45;
  }
  70% {
    transform: scale(1.8);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

.state-ok {
  color: var(--ok);
}
.state-warn {
  color: var(--warn);
}
.state-err {
  color: var(--err);
}
.state-info {
  color: var(--info);
}

/* Fields */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.field > label {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}

.field__input {
  width: 100%;
  padding: var(--s3) var(--s4);
  min-height: 44px;
  background: var(--surface-2);
  border: var(--hair) solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  transition: border-color var(--t-base) var(--ease), background-color var(--t-base) var(--ease);
}

.field__input::placeholder {
  color: var(--text-3);
}

.field__input:hover {
  border-color: var(--line-strong);
}

.field__input:focus {
  outline: none;
  border-color: var(--text);
  background: var(--surface);
}

textarea.field__input {
  resize: vertical;
  min-height: 112px;
  line-height: 1.6;
}

select.field__input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--s8);
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.field__error,
.errorlist {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  font-size: var(--fs-xs);
  color: var(--err);
}

.errorlist li {
  color: var(--err);
  font-size: var(--fs-xs);
}

.field--invalid .field__input {
  border-color: var(--err);
}

.helptext,
.helptext ul {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.5;
}

.helptext li {
  position: relative;
  padding-left: var(--s4);
}

.helptext li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: var(--hair);
  background: var(--line-strong);
}

/* Notice bar */

.notice {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: var(--hair) solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}

.notice--ok {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}
.notice--warn {
  border-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
}
.notice--err {
  border-color: var(--err);
  background: var(--err-soft);
  color: var(--err);
}
.notice--info {
  border-color: var(--info);
  background: var(--info-soft);
  color: var(--info);
}

/* Navigation */

.nav {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: 80;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  border-bottom: var(--hair) solid transparent;
  transition: border-color var(--t-base) var(--ease), background-color var(--t-base) var(--ease);
}

.nav.is-stuck {
  border-bottom-color: var(--line);
}

/* Reading progress along the bottom edge of the nav. Reads the same
   --scroll-progress value the landing rail does. */
.nav__progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: var(--scroll-progress, 0%);
  background: var(--text);
  opacity: 0.9;
  pointer-events: none;
  transition: width var(--t-micro) linear;
}

/* Keyboard hint */

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  border: var(--hair) solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  line-height: 1.4;
  text-align: center;
}

.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
}

/* Spotlight. A lamp that follows the pointer across the brick lattice. */

.spot {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease);
  background: radial-gradient(
    220px circle at var(--mx, 50%) var(--my, 50%),
    var(--glow),
    transparent 68%
  );
}

.spot--wide {
  background: radial-gradient(
    560px circle at var(--mx, 50%) var(--my, 50%),
    var(--glow),
    transparent 66%
  );
}

.is-lit > .spot {
  opacity: 1;
}

/* .panel > * forces position relative and z-index 1 on children, which the
   spotlight must opt out of to sit behind the content. */
.panel > .spot {
  position: absolute;
  z-index: 0;
}

/* Copy button. Swaps to a check for a moment after a successful copy. */

.btn .ico--copied {
  display: none;
}

.btn.is-copied {
  border-color: var(--ok);
  color: var(--ok);
}

.btn.is-copied .ico--copy {
  display: none;
}

.btn.is-copied .ico--copied {
  display: block;
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s5);
  height: 68px;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
}

.mark__glyph {
  width: 30px;
  height: 30px;
  color: var(--text);
}

.mark__text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.mark__name {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: var(--fs-base);
}

.mark__sub {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 3px;
}

.nav__links {
  display: none;
  align-items: center;
  gap: var(--s2);
}

.nav__link {
  position: relative;
  padding: var(--s2) var(--s3);
  border-radius: var(--r);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color var(--t-base) var(--ease);
}

.nav__link:hover,
.nav__link.is-active {
  color: var(--text);
}

.nav__link.is-active::after {
  content: "";
  position: absolute;
  left: var(--s3);
  right: var(--s3);
  bottom: 2px;
  height: var(--hair);
  background: var(--text);
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.nav__cta {
  display: none;
}

.menu-toggle {
  display: inline-flex;
}

.nav__panel {
  display: none;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s4) 0 var(--s6);
  border-top: var(--hair) solid var(--line);
}

.nav__panel.is-open {
  display: flex;
}

.nav__panel a {
  padding: var(--s3) 0;
  border-bottom: var(--hair) solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* The icon shows the theme you would switch to, so the light default offers a
   moon and the dark override offers a sun. */
.theme-toggle .ico--sun {
  display: none;
}

.theme-toggle .ico--moon {
  display: block;
}

[data-theme="dark"] .theme-toggle .ico--sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .ico--moon {
  display: none;
}

@media (min-width: 900px) {
  .nav__links {
    display: flex;
  }

  .nav__cta {
    display: inline-flex;
  }

  .menu-toggle {
    display: none;
  }

  .nav__panel {
    display: none !important;
  }
}

/* Footer */

.footer {
  /* Sized so the wordmark always fits the viewport width. Six characters at
     weight 800 with tight tracking run to roughly 3.6 times the font size. */
  --wordmark: min(21vw, 15rem);

  position: relative;
  border-top: var(--hair) solid var(--line);
  padding-top: var(--s10);
  /* Reserves the room the wordmark needs, so it is never clipped. */
  padding-bottom: calc(var(--wordmark) * 0.78 + 26px);
  overflow: hidden;
  /* Keeps the brick field, which sits at z-index -1, inside the footer. */
  isolation: isolate;
}

.footer__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
  gap: var(--s7);
  padding-bottom: var(--s9);
}

.footer__col h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
  margin-bottom: var(--s4);
}

.footer__col li + li {
  margin-top: var(--s2);
}

.footer__col a {
  color: var(--text-2);
  font-size: var(--fs-sm);
  transition: color var(--t-base) var(--ease);
}

.footer__col a:hover {
  color: var(--text);
}

.footer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding-block: var(--s5);
  border-top: var(--hair) solid var(--line);
  flex-wrap: wrap;
}

.footer > * {
  position: relative;
  z-index: 1;
}

/* Declared after ".footer > *" on purpose. Both selectors have the same
   specificity, so the later one wins, and the earlier version of this rule sat
   above it: position:absolute lost to position:relative, the wordmark dropped
   into the flow, and overflow:hidden cut off whatever spilled. */
.footer__wordmark {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 0;
  font-size: var(--wordmark);
  line-height: 0.78;
  font-weight: 800;
  letter-spacing: -0.06em;
  color: var(--text);
  opacity: 0.06;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .footer__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .footer__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
