/*
 * Wellbrad — the holdco page.
 *
 * One still image sits fixed behind everything and the content scrolls over it. The
 * palette is monochrome on purpose: the apps each have their own colour and type, and
 * this page is the company behind them, not any one of them. Display type is Ambroise
 * Std, a Didot revival served by Adobe Fonts (the closest licensed match to the reference
 * wordmark — see AGENTS.md for the measurement); Playfair Display is self-hosted as the
 * fallback face. Everything else is Geist at regular weight — only the jump links are bold.
 */

/* Fallback only: fetched if Adobe Fonts does not answer. */
@font-face {
  font-family: 'Wellbrad Display';
  src: url('/fonts/display.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

@font-face {
  font-family: 'Geist';
  src: url('/fonts/geist.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #000;
  --fg: #e6e6e6;
  --fg-strong: #fff;
  --muted: #9a9a9a;
  --hair: rgba(255, 255, 255, 0.1);
  --hair-strong: rgba(255, 255, 255, 0.24);
  --glass: rgba(3, 3, 3, 0.64);
  --glass-strong: rgba(0, 0, 0, 0.82);
  --font-display: 'ambroise-std', Didot, 'Wellbrad Display', Georgia, serif;
  --font-text: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --header-h: 4rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --radius: 22px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 0.32s;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  /* Smooth only once the page has loaded: with it on from the start, Chromium's initial
     jump to a URL fragment gets interrupted and the page lands at the top. main.js adds
     the class after load and performs that first jump itself. */
  scroll-behavior: auto;
  /* Anchor jumps land below the fixed header instead of underneath it. */
  scroll-padding-top: calc(var(--header-h) + 0.5rem);
  -webkit-text-size-adjust: 100%;
}

html.is-loaded {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1.0625rem/1.6 var(--font-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--fg-strong);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- backdrop ---------- */

.backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  /* The large viewport unit keeps the image still while a phone's toolbar collapses;
     the plain unit is the fallback for browsers without it. */
  height: 100vh;
  height: 100lvh;
  z-index: -1;
  background: var(--bg);
  overflow: hidden;
}

.backdrop img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Anchored to the bottom so the mountains and water are always in frame: a window
     taller than the image's 16:9 crops the sides, a wider one crops the empty sky. */
  object-position: 50% 100%;
}

/* ---------- skip link ---------- */

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--fg-strong);
  color: #000;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  transition: top var(--dur) var(--ease-out);
}

.skip:focus {
  top: 1rem;
}

/* ---------- reading progress ---------- */

.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 60;
  pointer-events: none;
}

.progress__bar {
  height: 100%;
  width: 100%;
  background: rgba(255, 255, 255, 0.75);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---------- header ---------- */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  transition:
    background-color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
  border-bottom: 1px solid transparent;
}

.header.is-scrolled {
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.header__brand {
  font: 700 1.4rem/1 var(--font-display);
  letter-spacing: -0.01em;
  color: var(--fg-strong);
  text-decoration: none;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out);
}

.header.is-scrolled .header__brand {
  opacity: 1;
  transform: none;
}

.nav {
  display: flex;
  gap: 2.25rem;
}

.nav a {
  position: relative;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  transition: color var(--dur) var(--ease-out);
}

.nav a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.15rem;
  height: 1px;
  background: var(--fg-strong);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease-out);
}

.nav a:hover,
.nav a[aria-current='true'] {
  color: var(--fg-strong);
}

.nav a:hover::after,
.nav a[aria-current='true']::after {
  transform: scaleX(1);
}

.nav-toggle {
  display: none;
  appearance: none;
  background: none;
  border: 1px solid var(--hair-strong);
  color: var(--fg-strong);
  font: 600 0.85rem var(--font-text);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-content: center;
  text-align: center;
  padding: var(--header-h) var(--gutter) 8vh;
}

.hero__inner {
  will-change: transform, opacity;
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.4rem, 12.3vw, 13rem);
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--fg-strong);
  /* Stays hidden until the display face has loaded, so the entrance never plays on a fallback. */
  opacity: 0;
}

.is-ready .wordmark {
  animation:
    wordmark-rise 1.3s var(--ease-out) forwards,
    wordmark-float 7s ease-in-out 1.3s infinite;
}

@keyframes wordmark-rise {
  from {
    opacity: 0;
    transform: scale(0.74) translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes wordmark-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-9px);
  }
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: calc(1.75rem + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.5s var(--ease-out);
}

.is-ready .scroll-cue {
  opacity: 1;
  transition-delay: 1.2s;
}

.is-ready .scroll-cue.is-hidden {
  opacity: 0;
  transition-delay: 0s;
  pointer-events: none;
}

.scroll-cue__chevron {
  animation: cue-bob 2.2s ease-in-out infinite;
}

@keyframes cue-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

/* ---------- sections ---------- */

.section {
  padding: 14vh var(--gutter);
  outline: none;
}

.section + .section {
  padding-top: 0;
}

.panel {
  max-width: 66rem;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.5rem);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.7s var(--ease-out),
    transform 0.7s var(--ease-out);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.eyebrow {
  margin: 0 0 1rem;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

h2 {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--fg-strong);
  max-width: 24ch;
}

.prose {
  max-width: 62ch;
}

.prose p {
  margin: 0 0 1rem;
}

.prose p:last-child {
  margin-bottom: 0;
}

/* ---------- apps: folder tabs, one per built app ---------- */

.tabs {
  margin-top: 2rem;
  --tab-bg: #121212;
  --tab-bg-idle: #0b0b0b;
}

/* The first tab's left edge sits on the panel's left edge, like a folder. */
.tabs__list {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.35rem;
  padding: 0;
}

.tabs__tab {
  appearance: none;
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 0.55rem 0.8rem 0.5rem;
  margin-bottom: -1px;
  border: 1px solid var(--hair);
  border-bottom-color: transparent;
  border-radius: 14px 14px 0 0;
  background: var(--tab-bg-idle);
  cursor: pointer;
  opacity: 0.55;
  transition:
    opacity var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
}

.tabs__tab img {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 22%;
}

.tabs__tab:hover {
  opacity: 0.9;
}

.tabs__tab[aria-selected='true'] {
  opacity: 1;
  background: var(--tab-bg);
  border-color: var(--hair-strong);
  border-bottom-color: transparent;
}

.tabs__tab:focus-visible {
  outline: 2px solid var(--fg-strong);
  outline-offset: 2px;
  border-radius: 14px 14px 0 0;
}

.tabs__panel {
  border: 1px solid var(--hair-strong);
  border-radius: 0 18px 18px 18px;
  background: var(--tab-bg);
}

.tabs__panel:focus-visible {
  outline-offset: 4px;
}

.app {
  display: block;
  padding: 1.5rem 1.75rem;
  border-radius: 0 18px 18px 18px;
  text-decoration: none;
  color: inherit;
}

.app__body {
  display: block;
  min-width: 0;
}

.app__name {
  display: block;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--fg-strong);
  margin-bottom: 0.4rem;
}

.app__text {
  display: block;
  color: var(--fg);
}

.app__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.badge {
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--hair-strong);
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--fg-strong);
}

.app__link {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--hair-strong);
  transition: color var(--dur) var(--ease-out);
}

.app:hover .app__link,
.app:focus-visible .app__link {
  color: var(--fg-strong);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- contact ---------- */

.panel--contact {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(2rem, 5vw, 4rem);
}

.form {
  display: grid;
  gap: 1.1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field label {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  font: inherit;
  color: var(--fg-strong);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hair-strong);
  border-radius: 12px;
  transition:
    border-color var(--dur) var(--ease-out),
    background-color var(--dur) var(--ease-out);
}

.field textarea {
  resize: vertical;
  min-height: 8rem;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--fg-strong);
  background: rgba(255, 255, 255, 0.06);
}

.field input:user-invalid,
.field textarea:user-invalid {
  border-color: rgba(255, 255, 255, 0.5);
}

.hp {
  position: absolute;
  left: -200vw;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
}

.button {
  appearance: none;
  border: 0;
  padding: 0.9rem 1.5rem;
  border-radius: 999px;
  background: var(--fg-strong);
  color: #000;
  font: 600 0.95rem var(--font-text);
  cursor: pointer;
  transition:
    transform var(--dur) var(--ease-out),
    opacity var(--dur) var(--ease-out);
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: scale(0.98);
}

.button[disabled] {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.form__status {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  min-height: 1.4em;
}

.form__status.is-success {
  color: var(--fg-strong);
}

.form.is-sent .field,
.form.is-sent .cf-turnstile,
.form.is-sent .button {
  display: none;
}

/* ---------- footer ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  max-width: 66rem;
  margin: 0 auto;
  padding: 3rem var(--gutter) calc(6rem + var(--safe-b));
  font-size: 0.85rem;
  color: var(--muted);
}

.footer p {
  margin: 0;
}

.footer__nav {
  display: flex;
  gap: 1.5rem;
}

.footer__nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color var(--dur) var(--ease-out);
}

.footer__nav a:hover {
  color: var(--fg-strong);
}

/* ---------- floating controls ---------- */

.cta,
.to-top {
  position: fixed;
  bottom: calc(1.25rem + var(--safe-b));
  z-index: 40;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out);
}

.cta.is-visible,
.to-top.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.cta {
  right: 1.25rem;
  padding: 0.85rem 1.4rem;
  border-radius: 999px;
  background: var(--fg-strong);
  color: #000;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.cta:hover {
  transform: translateY(-2px);
}

.to-top {
  left: 1.25rem;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--hair-strong);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--fg-strong);
  cursor: pointer;
}

.to-top:hover {
  border-color: var(--fg-strong);
}

/* ---------- document pages (privacy) ---------- */

.doc {
  padding-top: calc(var(--header-h) + 8vh);
}

.doc .prose h2 {
  font-size: 1.35rem;
  margin: 2rem 0 0.6rem;
}

.doc .updated {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- responsive ---------- */

@media (max-width: 880px) {
  .panel--contact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .nav-toggle {
    display: inline-block;
  }

  .nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem var(--gutter) 1rem;
    background: rgba(0, 0, 0, 0.9);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity var(--dur) var(--ease-out),
      transform var(--dur) var(--ease-out),
      visibility 0s linear var(--dur);
  }

  .nav.is-open {
    transform: none;
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
  }

  .nav a {
    padding: 0.9rem 0;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .nav a::after {
    display: none;
  }

  .header.is-open {
    background: rgba(0, 0, 0, 0.9);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  .header.is-open .header__brand {
    opacity: 1;
    transform: none;
  }

  .hero {
    padding-bottom: 22vh;
  }

  .footer {
    padding-bottom: calc(7rem + var(--safe-b));
  }
}

@media (max-width: 480px) {
  :root {
    --gutter: 0.875rem;
  }

  .panel {
    padding: 1.5rem 1.25rem;
    border-radius: 18px;
  }

  .app {
    padding: 1.25rem;
  }
}

/* Turnstile's flexible widget is never narrower than 300px; the smallest phones get it scaled. */
@media (max-width: 340px) {
  .cf-turnstile {
    transform: scale(0.88);
    transform-origin: left top;
  }
}

/* Without backdrop blur the glass would read as a faint tint over the landscape, so it goes near-solid. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel,
  .header.is-scrolled,
  .header.is-open,
  .nav,
  .to-top {
    background: rgba(0, 0, 0, 0.92);
  }
}

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html,
  html.is-loaded {
    scroll-behavior: auto;
  }

  .is-ready .wordmark {
    animation: none;
    opacity: 1;
  }

  .scroll-cue__chevron {
    animation: none;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero__inner {
    transform: none !important;
    opacity: 1 !important;
  }
}
