/*
 * CarCom coming-soon page.
 * One theme per colour scheme. site.js reads the --field-* tokens, so the WebGL field and the CSS fallback
 * share one palette. Radius rule: interactive controls are pills, the one surface (legal dialog) is 16px.
 */

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/geist-latin-wght.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #0a0b0d;
  --fg: #eceef2;
  --muted: #a1a7b1;
  --faint: #868c96;
  --hairline: rgb(236 238 242 / 0.14);
  --hairline-strong: rgb(236 238 242 / 0.3);
  --surface: rgb(16 18 22 / 0.96);
  --scrim: rgb(4 5 7 / 0.62);
  --accent: #6ea2ff;
  --shadow: 0 40px 90px -30px rgb(0 0 0 / 0.7);

  --field-bg: #0a0b0d;
  --field-lift: #13161c;
  --field-ink: #e2e6ee;
  --field-accent: #6ea2ff;
  --field-alpha: 0.15;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f4f6;
    --fg: #0e1013;
    --muted: #4c525d;
    --faint: #5c626c;
    --hairline: rgb(14 16 19 / 0.12);
    --hairline-strong: rgb(14 16 19 / 0.28);
    --surface: rgb(251 251 252 / 0.98);
    --scrim: rgb(20 22 26 / 0.28);
    --accent: #2b5dd1;
    --shadow: 0 40px 90px -30px rgb(20 24 32 / 0.35);

    --field-bg: #f3f4f6;
    --field-lift: #fcfcfd;
    --field-ink: #12151b;
    --field-accent: #2b5dd1;
    --field-alpha: 0.13;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  /* Shown until the first WebGL frame lands, and for good where WebGL is unavailable. */
  background: radial-gradient(ellipse 70% 60% at 50% 40%, var(--field-lift), var(--bg) 70%) fixed var(--bg);
  color: var(--fg);
  font-family: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Both languages ship in the markup; <html lang> picks one (set by the Worker, then by the toggle). */
html:not([lang='fr']) [data-l='fr'],
html[lang='fr'] [data-l='en'] {
  display: none !important;
}

a {
  color: inherit;
}

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

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  display: block;
}

/* Field ------------------------------------------------------------------ */

.field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  /*
   * Hidden until the first frame (an undrawn opaque WebGL canvas is black), then shown at once. No opacity
   * fade here: iOS web views (Chrome and every in-app browser on iPhone) can leave a large opacity-animated
   * layer at its start value, so a canvas fading in from 0 stayed invisible there while Safari showed it.
   * The intro is drawn by the shader instead. translateZ(0) gives the canvas its own compositing layer,
   * which those web views need to update it reliably.
   */
  visibility: hidden;
  transform: translateZ(0);
}

.field.is-ready {
  visibility: visible;
}

/* carcom.io/?debug: a status line for checking a device in the field. */
.debug {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  max-width: calc(100vw - 16px);
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgb(0 0 0 / 0.78);
  color: #fff;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: none;
}

/* Page ------------------------------------------------------------------- */

.page {
  position: relative;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: max(var(--gutter), env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right))
    max(var(--gutter), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
}

.wordmark {
  display: inline-flex;
  padding: 6px 0;
  color: var(--fg);
  border-radius: 4px;
}

.wordmark svg {
  display: block;
  height: 15px;
  width: auto;
}

.lang {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}

/* The toggle needs site.js; without it the Worker's Accept-Language pick stands. */
.no-js .lang {
  visibility: hidden;
}

.lang button {
  appearance: none;
  min-width: 40px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--faint);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition:
    color 0.2s,
    background-color 0.2s;
}

.lang button:hover {
  color: var(--fg);
}

.lang button[aria-pressed='true'] {
  color: var(--fg);
  background: var(--hairline);
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-block: clamp(40px, 8vh, 88px);
  text-align: center;
}

.mark {
  display: block;
  width: auto;
  height: clamp(60px, 9vh, 92px);
  margin-bottom: clamp(36px, 6vh, 60px);
  overflow: visible;
  /* site.js raises --pulse as each wave leaves the mark. */
  color: color-mix(in oklab, var(--fg), var(--accent) calc(var(--pulse, 0) * 45%));
}

.copy-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  margin: 0;
  max-width: 15ch;
  font-size: clamp(2.125rem, 1.15rem + 3.7vw, 4rem);
  font-weight: 560;
  line-height: 1.04;
  letter-spacing: -0.042em;
  text-wrap: balance;
}

.lead {
  margin: 20px 0 0;
  /* Each sentence (split by <br> on wider screens) must fit one line in every engine: 46 ch, not less. */
  max-width: 46ch;
  color: var(--muted);
  font-size: clamp(1rem, 0.94rem + 0.28vw, 1.1875rem);
  line-height: 1.55;
  text-wrap: pretty;
}

.contact {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 36px;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px 0 18px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-size: 15px;
  font-weight: 520;
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform 0.4s var(--ease-out),
    background-color 0.2s;
}

.cta:hover {
  background: color-mix(in oklab, var(--fg) 86%, var(--accent));
}

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

.copy {
  appearance: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  color: var(--fg);
  cursor: pointer;
  transition:
    border-color 0.2s,
    transform 0.4s var(--ease-out);
}

.copy[hidden] {
  display: none;
}

.copy:hover {
  border-color: var(--fg);
}

.copy:active {
  transform: scale(0.94);
}

.copy .icon-check,
.copy[data-copied] .icon-copy {
  display: none;
}

.copy[data-copied] .icon-check {
  display: block;
  color: var(--accent);
}

.toast {
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition:
    opacity 0.25s,
    transform 0.4s var(--ease-out);
  pointer-events: none;
}

.toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  flex-wrap: wrap;
  color: var(--faint);
  font-size: 13px;
}

.bottom a {
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.2s;
}

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

/* Legal dialog ------------------------------------------------------------ */

.legal {
  width: min(560px, calc(100vw - 32px));
  max-height: min(84dvh, 720px);
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.legal::backdrop {
  background: var(--scrim);
}

/* showModal() focuses the dialog itself (so screen readers start at its title); that focus needs no ring. */
.legal:focus,
.legal:focus-visible {
  outline: none;
}

.legal-inner {
  max-height: inherit;
  padding: 24px 28px 28px;
  overflow: auto;
}

.legal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.legal h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 560;
  letter-spacing: -0.02em;
}

.close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--muted);
  transition:
    color 0.2s,
    border-color 0.2s;
}

.close:hover {
  color: var(--fg);
  border-color: var(--hairline-strong);
}

.close .icon {
  width: 16px;
  height: 16px;
}

.legal dl {
  display: grid;
  gap: 18px;
  margin: 0;
}

.legal dt {
  margin-bottom: 3px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.legal dd {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

.legal dd a {
  color: var(--fg);
  text-underline-offset: 3px;
}

/* Browsers without <dialog> would render it inline: keep it hidden until targeted. */
dialog:not([open]) {
  display: none;
}

/* Without JavaScript (or <dialog>) the "Legal notice" link targets the dialog: show it in place. */
.no-js .legal:target,
.no-dialog .legal:target {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1;
  height: fit-content;
  margin: auto;
}

/* Motion ------------------------------------------------------------------ */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    animation: rise 1.1s var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 110ms + 380ms);
  }

  .mark.reveal {
    animation-name: mark-in;
    animation-duration: 1.5s;
    animation-delay: 120ms;
  }

  .copy-block > :nth-child(1) {
    --i: 1;
  }
  .copy-block > :nth-child(2) {
    --i: 2;
  }
  .copy-block > :nth-child(3) {
    --i: 3;
  }

  .legal[open] {
    animation: dialog-in 0.45s var(--ease-out);
  }

  .legal[open]::backdrop {
    animation: fade-in 0.3s ease;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes mark-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* Short screens (phones held sideways): everything has to fit above the fold. -------- */

@media (max-height: 520px) and (orientation: landscape) {
  .page {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .top {
    min-height: 32px;
  }

  .wordmark svg {
    height: 13px;
  }

  .hero {
    padding-block: 8px;
  }

  .mark {
    height: 44px;
    margin-bottom: 14px;
  }

  h1 {
    max-width: none;
    font-size: 1.875rem;
  }

  .lead {
    margin-top: 8px;
    font-size: 0.9375rem;
  }

  .contact {
    margin-top: 16px;
  }

  .cta,
  .copy {
    height: 44px;
  }

  .copy {
    width: 44px;
  }
}

/* Large, tall screens: give the copy a little more presence. ---------------------- */

@media (min-width: 1800px) and (min-height: 1000px) {
  h1 {
    font-size: 4.75rem;
  }

  .lead {
    font-size: 1.3125rem;
  }

  .mark {
    height: 104px;
  }
}

/* Small screens ------------------------------------------------------------ */

@media (max-width: 520px) {
  .lead br {
    display: none;
  }

  .bottom {
    justify-content: center;
    text-align: center;
  }

  .legal-inner {
    padding: 20px 20px 24px;
  }
}
