/* ═══════════════════════════════════════════════════════
   Dot Matrix — style.css
   Clean-room rebuild. No third-party design system deps.
   ═══════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────── */
:root,
[data-theme='light'] {
  /* Surfaces */
  --color-bg:        #f2f2f2;
  --color-surface:   #ebebeb;
  --color-border:    #d8d8d8;

  /* Text */
  --color-text:      #1a1a1a;
  --color-text-muted:#6b6b6b;
  --color-text-inv:  #f2f2f2;

  /* Brand accent — orange */
  --color-accent:        #fc6803;
  --color-accent-hover:  #e05500;
  --color-accent-active: #c44900;

  /* Button */
  --color-btn-bg:      #1a1a1a;
  --color-btn-text:    #f2f2f2;
  --color-btn-hover:   #333333;

  /* State */
  --color-error:   #c0392b;
  --color-success: #1a6e3b;

  /* Type */
  --font-display: 'trade-gothic-next-condensed', sans-serif;
  --font-serif:   'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont,
                  'Segoe UI', sans-serif;
  --font-system:  system-ui, -apple-system, BlinkMacSystemFont,
                  'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
                  'Open Sans', 'Helvetica Neue', sans-serif;

  /* Fluid type scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-hero: clamp(3rem,     1rem    + 7vw,    7rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Geometry */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-full: 9999px;

  /* Motion */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-mid:  300ms;

  /* Logo size — scales with the smaller viewport axis but
     caps so it doesn't shrink on ultrawide or bloat on tall screens. */
  --logo-size: clamp(200px, 32vmin, 420px);
}

/* ── Dark mode ──────────────────────────────────────────── */
[data-theme='dark'],
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:         #111111;
    --color-surface:    #1a1a1a;
    --color-border:     #2e2e2e;
    --color-text:       #e8e8e8;
    --color-text-muted: #888888;
    --color-text-inv:   #111111;
    --color-accent:        #ff7a1f;
    --color-accent-hover:  #fc6803;
    --color-accent-active: #e05500;
    --color-btn-bg:    #e8e8e8;
    --color-btn-text:  #111111;
    --color-btn-hover: #cccccc;
    --color-error:     #e06c75;
    --color-success:   #98c379;
  }
}

[data-theme='dark'] {
  --color-bg:         #111111;
  --color-surface:    #1a1a1a;
  --color-border:     #2e2e2e;
  --color-text:       #e8e8e8;
  --color-text-muted: #888888;
  --color-text-inv:   #111111;
  --color-accent:        #ff7a1f;
  --color-accent-hover:  #fc6803;
  --color-accent-active: #e05500;
  --color-btn-bg:    #e8e8e8;
  --color-btn-text:  #111111;
  --color-btn-hover: #cccccc;
  --color-error:     #e06c75;
  --color-success:   #98c379;
}

/* ── Reset ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: clamp(14px, 0.75rem + 0.5vw, 18px);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition:
    background-color var(--duration-mid) var(--ease-out-expo),
    color var(--duration-mid) var(--ease-out-expo);
}

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

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

/* Let h1 use UA default 2em sizing — matches the original. */
h1 { text-wrap: balance; }

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

::selection {
  background: color-mix(in srgb, var(--color-accent) 20%, transparent);
  color: var(--color-text);
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out-expo),
    color var(--duration-fast) var(--ease-out-expo),
    border-color var(--duration-fast) var(--ease-out-expo);
}

.theme-toggle:hover {
  background: var(--color-border);
  color: var(--color-text);
}

/* Show/hide sun vs moon based on current theme */
[data-theme='light'] .icon-sun,
[data-theme='dark']  .icon-moon {
  display: none;
}

[data-theme='dark'] .icon-sun,
[data-theme='light'] .icon-moon {
  display: block;
}

/* Fallback for system preference before JS runs */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun  { display: block; }
  :root:not([data-theme]) .icon-moon { display: none;  }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-moon { display: block; }
  :root:not([data-theme]) .icon-sun  { display: none;  }
}

/* ── Page layout ────────────────────────────────────────── */
/* Flex column, vertically centered. All vertical rhythm
   is controlled by explicit margins on each element. */
.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  padding: clamp(2rem, 4vh, 5rem) 0;
  position: relative;
  z-index: 1;
}

/* ── Logo ───────────────────────────────────────────────── */
/* Circle + letterforms + underline = single locked object.
   Width controls size; height is auto from the SVG aspect ratio
   so the underline stays tightly coupled to the glyphs. */
.logo-wrap {
  position: relative; /* contain the sphere canvas */
  width: var(--logo-size);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.logo {
  position: relative;
  z-index: 1; /* above sphere canvas */
  width: 100%;
  height: auto;
  transition: transform var(--duration-mid) var(--ease-out-expo);
  will-change: transform;
}

.logo .dm-glyph  { fill: var(--color-text); }
.logo .dm-circle { fill: #fc6803; }

.logo-wrap:hover .logo,
.logo-wrap:focus-visible .logo {
  transform: scale(1.06);
}

/* ── Headline ───────────────────────────────────────────── */
/* h1 inherits body font-size calc(10px + 2vmin).
   The UA default h1 size is 2em, giving ~56px at typical viewports.
   This matches the original’s large display-scale headline. */
/* Pushed down 0.5× its own x-height below the logo. */
.headline {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 400;
  font-size: clamp(1.8rem, 1.2rem + 2.5vw, 3.2rem);
  letter-spacing: normal;
  text-align: center;
  line-height: normal;
  color: var(--color-text);
  margin-top: 0.5ex;
}

.headline-accent {
  color: var(--color-accent);
  font-family: var(--font-display);
  font-weight: 700;
}

/* The trailing "." uses system font for a round dot —
   condensed typefaces have narrow periods that look odd standalone. */
.headline-dot {
  color: var(--color-accent);
  font-family: var(--font-system);
  font-weight: 400;
}


/* ── Narrative section ──────────────────────────────────── */
/* Continuation of hero atmosphere — gradient fades in from
   the hero's background, off-white type on a darker ground. */
.narrative {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: clamp(4rem, 8vw, 8rem) clamp(1.5rem, 5vw, 3rem);
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--color-bg) 85%, #000) 35%,
    color-mix(in srgb, var(--color-bg) 70%, #000) 100%
  );
}

[data-theme='dark'] .narrative {
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--color-bg) 85%, #000) 35%,
    color-mix(in srgb, var(--color-bg) 60%, #000) 100%
  );
}

.narrative-inner {
  max-width: 38rem;
  margin: 0 auto;
}

/* Eyebrow — tracked small caps, display font */
.narrative-eyebrow {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-10);
  opacity: 0;
}

/* Body — editorial serif, soft off-white */
.narrative-body {
  opacity: 0;
}

.narrative-body p {
  font-family: var(--font-serif);
  font-size: clamp(1.05rem, 0.9rem + 0.6vw, 1.3rem);
  font-weight: 400;
  line-height: 1.7;
  color: color-mix(in srgb, var(--color-text) 75%, transparent);
  letter-spacing: 0.005em;
}

/* CTA block — "Follow the work." + form as one unit */
.narrative-cta {
  margin-top: var(--space-12);
  opacity: 0;
}

.narrative-cta-label {
  font-family: var(--font-serif);
  font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.1rem);
  font-style: italic;
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
  margin-bottom: var(--space-6);
}

/* Signature — bare name, arrives last */
.narrative-signature {
  margin-top: var(--space-12);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--color-text) 45%, transparent);
  opacity: 0;
}

/* Scroll-triggered entrance — staggered fade-up */
.narrative.is-visible .narrative-eyebrow {
  animation: fade-up 0.6s var(--ease-out-expo) both;
}
.narrative.is-visible .narrative-body {
  animation: fade-up 0.6s var(--ease-out-expo) 0.15s both;
}
.narrative.is-visible .narrative-cta {
  animation: fade-up 0.6s var(--ease-out-expo) 0.3s both;
}
.narrative.is-visible .narrative-signature {
  animation: fade-up 0.6s var(--ease-out-expo) 0.5s both;
}

/* ── Form ───────────────────────────────────────────────── */
/* Form elements at 80% of base size. */
.waitlist-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  font-size: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
}

/* Honeypot — absolutely invisible to real users */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.form-row {
  display: flex;
  gap: 0;
}

.form-row .email-input {
  margin-right: 8px;
}

/* 2× original width, font reduced 15% for readability at length */
.email-input {
  flex: 0 0 auto;
  width: 240px;
  padding: 8px 16px;
  font-size: 0.85em;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: #ffffff;
  color: var(--color-text);
  font-size: inherit;
  transition: all 0.3s ease;
}

[data-theme='dark'] .email-input {
  background: var(--color-surface);
}

.email-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.email-input:hover {
  border-color: var(--color-text-muted);
}

.email-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 15%, transparent);
}

.email-input[aria-invalid='true'] {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-error) 12%, transparent);
}

/* 80% scale: padding 8/16 (down from 10/20) */
.btn-signup {
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--color-accent);
  color: #000000;
  border: none;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: inherit;
  font-weight: 400;
  letter-spacing: normal;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.btn-signup:hover {
  background: #a4a4a4;
}

.btn-signup:active {
  transform: scale(0.97);
}

.btn-signup:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Loading state */
.btn-signup[data-loading='true'] {
  position: relative;
  color: transparent;
}

.btn-signup[data-loading='true']::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-color: var(--color-btn-text) transparent transparent transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Form status message */
.form-status {
  font-size: var(--text-xs);
  min-height: 1.4em;
  text-align: center;
  transition: color var(--duration-fast);
}

.form-status[data-state='error'] {
  color: var(--color-error);
}

.form-status[data-state='success'] {
  color: var(--color-success);
}

.form-status[data-state='rate-limit'] {
  color: var(--color-text-muted);
}

/* ── Success state ──────────────────────────────────────── */
.waitlist-form[data-submitted='true'] .form-row {
  display: none;
}

.waitlist-form[data-submitted='true'] .form-status {
  font-size: var(--text-sm);
  color: var(--color-success);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .page {
    padding: var(--space-8) var(--space-5);
  }

  .narrative {
    padding: var(--space-16) var(--space-6);
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-row .email-input {
    margin-right: 0;
    margin-bottom: 8px;
  }

  .btn-signup,
  .email-input {
    width: 100%;
  }
}

/* ── Fade-in entrance animation ─────────────────────────── */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo-wrap   { animation: fade-up 0.6s var(--ease-out-expo) both; }
.headline    { animation: fade-up 0.6s var(--ease-out-expo) 0.1s both; }

/* ═══════════════════════════════════════════════════════
   Sparkler cursor — WebGL overlay
   Three.js canvas sits over the page, transparent bg.
   Desktop only (pointer: fine). Respects reduced motion.
   ═══════════════════════════════════════════════════════ */

/* Hide the native cursor when sparkler is active */
@media (pointer: fine) {
  .sparkler-active,
  .sparkler-active * {
    cursor: none !important;
  }

  /* Safe zone: restore cursor over the narrative content */
  .sparkler-active .narrative-inner,
  .sparkler-active .narrative-inner * {
    cursor: auto !important;
  }
  .sparkler-active .narrative-inner .btn-signup {
    cursor: pointer !important;
  }
}

/* The Three.js sparkler canvas — fullscreen overlay, non-interactive */
.sparkler-canvas {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  width: 100vw;
  height: 100vh;
}

/* 3D sphere canvas — positioned inside .logo-wrap, behind the SVG */
.sphere-canvas {
  pointer-events: none;
  z-index: 0;
}

/* Touch devices: hide sparkler cursor overlay only; keep sphere + gradient */
@media (pointer: coarse) {
  .sparkler-canvas { display: none; }
}

/* Respect reduced motion — hide all animated layers */
@media (prefers-reduced-motion: reduce) {
  .sparkler-canvas,
  .sphere-canvas,
  .atmosphere-gradient { display: none; }
}
