:root {
  --page-width: 760px;
  --line: 1px;
}

@media (min-width: 1001px) {
  :root { --line: 2px; }
}

/* Local preferred typeface */
@font-face{
  font-family: 'Univers';
  src: url('font/UniversRegular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html, body {
  /* let body scroll naturally so iOS Safari collapses the address bar */
  height: auto;
  min-height: 100%;
}

body, H1, H2, H3 {
  font-family: 'Univers', 'Helvetica Neue', Arial, sans-serif;
  font-size: clamp(14px, 2vw, 26px);
  margin: 0;
  padding: 0;
  font-weight: 400;
  color: #000000;
  background: #fff;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.page {
  display: flex;
  flex-direction: column;
  flex: 1;
  /* no overflow-y — let the body scroll so iOS Safari collapses its bars */
  padding: 48px 4vw;
  gap: 4vw;
  /* give space so content can scroll beneath the fixed slider; include bottom safe area */
  padding-bottom: calc(clamp(160px, 28vw, 300px) + env(safe-area-inset-bottom, 0px));
}

.content {
  max-width: var(--page-width);
}

.bio p {
  margin: 0 0 18px 0;
}

.bio p:first-child {
  margin-top: 6px;
}

.contact {
  margin-top: 12px;
  font-style: normal;
}

.contact .spacer {
  height: 12px;
}

.slider-container {
  position: fixed;
  /* anchor above the iOS home indicator / safe area */
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, calc(100% - 4vw));
  max-width: 600px;
  padding: clamp(12px, 3vw, 20px);
  padding-bottom: 20px;
  background: #fff;
  border: var(--line) solid #000;
  border-radius: 20px;
  z-index: 100;
  -webkit-user-select: none;
  user-select: none;
}

/* controls layout: use a single grid so all rows share the same column widths */
.controls {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr) auto;
  row-gap: clamp(12px, 2.5vw, 24px);
  align-items: center;
}

.controls-title {
  color: #000000;
  margin: 0 0 clamp(1vw, 1vw, 1vw) 0;
  grid-column: 1 / -1;
}

.control-row {
  /* allow children to participate in the parent grid so columns line up */
  display: contents;
}

.left-label,
.right-label {
  color: #000000;
  min-width: 0;
  text-align: center;
  /* never wrap or truncate; let the slider shrink instead */
  white-space: nowrap;
}

.left-label { padding-right: 30px; }
.right-label { padding-left: 20px; }

.range-wrapper {
  width: 100%;
  min-width: 0;
  max-width: none;
  position: relative;
  height: clamp(28px, 8vw, 36px);
  touch-action: none;
}

.slider {
  /* keep native input for accessibility but visually hide it; interactions captured by native element */
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: clamp(28px, 8vw, 36px);
  transform: translateY(-50%);
  opacity: 0;
  margin: 0;
  padding: 0;
  z-index: 2;
}

/* bio text container: allow overlaying a loader */
#bio-text {
  position: relative;
}

/* loader overlay centered inside the bio text */
.loader {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.65);
  z-index: 1000;
  pointer-events: none;
}
.loader.visible {
  display: flex;
  pointer-events: auto;
}
.loader-wheel {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  border-top-color: #000;
  animation: spin 800ms linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.custom-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: var(--line);
  background: #000;
  border-radius: 0;
  z-index: 1;
}

.ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.ticks span {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(var(--line) * 2);
  height: calc(var(--line) * 2);
  border-radius: 50%;
  background: #000;
}

.custom-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: clamp(20px, 8vw, 39px);
  height: clamp(12px, 5vw, 25px);
  border-radius: 999px;
  border: var(--line) solid #000;
  background: #fff;
  z-index: 3;
  left: 0;
  transition: left 220ms cubic-bezier(.2, .9, .2, 1);
}

.custom-thumb.dragging {
  transition: none;
}

/* playful worm image that appears briefly in the viewport */
.worm {
  position: fixed;
  /* use natural image size but never exceed viewport width */
  width: auto;
  max-width: 100%;
  height: auto;
  pointer-events: auto;
  cursor: pointer;
  display: none;
  z-index: 500;
}

/* counter shown below address when worm clicked */
.worm-counter {
  margin-top: 12px;
  color: #FF0000;
}

/* Responsive layout similar to image: keep content to the left, controls below */
@media (min-width: 980px) {
  .page {
    flex-direction: row;
    align-items: flex-start;
    padding: 72px;
    padding-bottom: calc(400px + 40px);
  }

  .content {
    width: 55%;
    flex: 1;
  }
}

.bio p {
  letter-spacing: 0.1px;
}

/* superscript styling so numeric refs display consistently */
.bio sup {
  font-size: 0.8em;
  line-height: 0.8;
  vertical-align: super;
  margin-left: 0.12em;
}

/* style links inside the bio: regular inline text with underline */
.bio a {
  text-decoration: underline;
  color: black;
}
.bio a:visited {
  color: black;
}
