/* Foundation, layout primitives and shared components (buttons, fields, links, nodes). */

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

* {
  margin: 0;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  background: var(--c-bg);
  color: var(--c-fg);
}

body {
  min-height: 100dvh;
  font-size: var(--t-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
  overflow-x: clip;
  background: var(--c-bg);
}

img,
picture,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

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

h1,
h2,
h3,
h4 {
  font-weight: inherit;
  font-size: inherit;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

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

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

/* Accessibility */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
}

#main:focus {
  outline: none;
}

.skip-link {
  position: fixed;
  left: var(--margin);
  top: 0.75rem;
  z-index: 100;
  padding: 0.7em 1.1em;
  background: var(--c-fg);
  color: var(--c-bg);
  font-weight: 500;
  border-radius: var(--radius-pill);
  translate: 0 -200%;
}

.skip-link:focus-visible {
  translate: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Lenis */
html.lenis,
html.lenis body {
  height: auto;
}

.lenis:not(.lenis-autoToggle).lenis-stopped {
  overflow: clip;
}

.lenis [data-lenis-prevent] {
  overscroll-behavior: contain;
}

/* Reveals: hidden until revealed, only when motion is allowed and JS runs */
.motion [data-split],
.motion [data-reveal] {
  visibility: hidden;
}

.split-line {
  padding-bottom: 0.1em;
  margin-bottom: -0.1em;
}

/* Grid: 12 columns, outer margin wider than the gutter (the thread runs in it) */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
  padding-inline: var(--margin);
}

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

/* Type helpers */
.t-xl {
  font-size: var(--t-xl);
  line-height: 0.98;
  letter-spacing: -0.04em;
  font-weight: 500;
}

.t-l {
  font-size: var(--t-l);
  line-height: 1.04;
  letter-spacing: -0.03em;
  font-weight: 500;
}

.t-m {
  font-size: var(--t-m);
  line-height: 1.32;
  letter-spacing: -0.012em;
}

.t-s {
  font-size: var(--t-s);
  line-height: 1.45;
}

.muted {
  color: var(--c-muted);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* Thread node + kicker: the dot the line passes through, and the section name beside it */
.kicker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  line-height: 1.2;
}

.node {
  --size: 0.75rem;
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: 1.5px solid var(--c-thread);
  background: var(--c-bg);
}

.node::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--c-thread);
  scale: 0;
  transition: scale 0.6s var(--ease-out);
}

.node.is-on::after,
html:not(.motion) .node::after {
  scale: 1;
}

/* Buttons: the fill floods from the pointer's side (js/buttons.ts) */
.btn {
  --btn-bg: var(--c-fg);
  --btn-fg: var(--c-bg);
  --btn-fill: var(--c-accent);
  --btn-fill-fg: var(--c-fg);
  --btn-border: var(--c-fg);
  position: relative;
  isolation: isolate;
  overflow: clip;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  min-height: 3.25rem;
  padding: 0.85em 1.5em;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.1;
  white-space: nowrap;
  transition: color 0.35s var(--ease-soft), border-color 0.35s var(--ease-soft);
}

.btn__fill {
  position: absolute;
  inset: -1px;
  z-index: -1;
  background: var(--btn-fill);
  clip-path: circle(0% at 50% 50%);
  pointer-events: none;
}

.btn__arrow {
  display: inline-block;
  transition: translate 0.45s var(--ease-out);
}

.btn.is-filled,
.btn:active {
  color: var(--btn-fill-fg);
  border-color: var(--btn-fill);
}

.btn:active .btn__fill {
  clip-path: circle(150% at 50% 50%);
}

@media (hover: hover) {
  .btn:hover .btn__arrow {
    translate: 0.25em 0;
  }
}

.btn:focus-visible .btn__arrow {
  translate: 0.25em 0;
}

.btn--outline {
  --btn-bg: transparent;
  --btn-fg: var(--c-fg);
  --btn-fill: var(--c-fg);
  --btn-fill-fg: var(--c-bg);
}

.btn--small {
  min-height: 2.75rem;
  padding: 0.65em 1.15em;
  font-size: var(--t-s);
}

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

@media (prefers-reduced-motion: reduce) {
  .btn:focus-visible {
    color: var(--btn-fill-fg);
    border-color: var(--btn-fill);
  }

  .btn:focus-visible .btn__fill {
    clip-path: none;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) {
  .btn:hover {
    color: var(--btn-fill-fg);
    border-color: var(--btn-fill);
  }

  .btn:hover .btn__fill {
    clip-path: none;
  }
}

/* Links: nav underline draws (a stroke being traced); inline links keep an underline at rest */
.draw {
  background: linear-gradient(currentColor 0 0) left 100% / 0% 1px no-repeat;
  padding-bottom: 0.15em;
  transition: background-size 0.5s var(--ease-out);
}

@media (hover: hover) {
  .draw:hover {
    background-size: 100% 1px;
  }
}

.draw:focus-visible,
.draw[aria-current='true'] {
  background-size: 100% 1px;
}

.link {
  background: linear-gradient(currentColor 0 0) left 100% / 100% 1px no-repeat;
  padding-bottom: 0.1em;
  transition: background-size 0.4s var(--ease-out), color 0.3s;
}

@media (hover: hover) {
  .link:hover {
    color: var(--c-accent-ink);
    background-size: 0% 1px;
    background-position: right 100%;
  }
}

.link:focus-visible {
  color: var(--c-accent-ink);
}

@media (prefers-reduced-motion: reduce) {

  .draw,
  .link {
    transition: none;
  }
}

/* Fields: hairline, catalogue-like */
.field {
  display: grid;
  gap: 0.35rem;
}

.field__label {
  font-size: var(--t-s);
  font-weight: 500;
}

.field__label .opt {
  color: var(--c-muted);
  font-weight: 400;
}

.field__input {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-fg);
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.field__input::placeholder {
  color: #6f7972;
}

@media (hover: hover) {
  .field__input:hover {
    border-color: var(--c-fg);
  }
}

.field__input:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgb(46 156 64 / 0.22);
}

.field__input:focus-visible {
  outline: none;
}

textarea.field__input {
  min-height: 8.5rem;
  resize: vertical;
}

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% - 1.15rem) 50%, calc(100% - 0.8rem) 50%;
  background-size: 0.35rem 0.35rem;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
  font-size: var(--t-s);
  color: var(--c-muted);
}

.check input {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: -0.05rem;
  accent-color: var(--c-accent);
}

.check a {
  display: inline-block;
  padding-block: 0.35rem 0.25rem;
}

/* Media frame: image clipped, scales inside on hover */
.frame {
  position: relative;
  overflow: clip;
  background: #dfe3dc;
  border-radius: var(--radius-m);
}

.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: scale 1.1s var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
