/* ─────────────────────────────────────────────────────────────
   MIRACLEWHITE PTE. LTD. — site styles
   Direction: "white paper lab" — warm paper ground, ink text,
   a single cobalt signal colour, serif display + mono labels.
   ───────────────────────────────────────────────────────────── */

:root {
  --paper: #f7f5ef;
  --paper-2: #efece3;
  --ink: #101214;
  --ink-2: #3a3d42;
  --ink-3: #7a7e86;
  --rule: rgba(16, 18, 20, 0.14);
  --rule-strong: rgba(16, 18, 20, 0.5);
  --cobalt: #1d3fd6;
  --cobalt-ink: #142a8f;
  --cobalt-soft: rgba(29, 63, 214, 0.08);

  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-body: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --max: 1240px;
  --gutter: clamp(20px, 4vw, 56px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* paper grain + dot grid */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: radial-gradient(rgba(16, 18, 20, 0.11) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: 14px 14px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.25) 60%, rgba(0, 0, 0, 0.6));
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.25) 60%, rgba(0, 0, 0, 0.6));
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--cobalt); color: #fff; }

.wrap {
  width: min(100% - 2 * var(--gutter), var(--max));
  margin-inline: auto;
}

/* ── type ─────────────────────────────────────────────────── */
.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.mono .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cobalt);
  margin: 0 10px 1px;
  vertical-align: middle;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1;
  margin: 0;
}
h1 { font-size: clamp(48px, 8.2vw, 116px); }
h2 { font-size: clamp(38px, 5.4vw, 72px); }
h3 { font-size: clamp(26px, 2.6vw, 34px); line-height: 1.1; }
h1 em, h2 em, h3 em, .serif-em {
  font-style: italic;
  color: var(--cobalt);
}

.lede {
  font-size: clamp(18px, 1.4vw, 21px);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 34em;
}

/* ── buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
}
.btn .arrow { transition: transform 0.3s var(--ease); }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:hover .arrow { transform: translateX(4px); }
.btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn.primary:hover { background: var(--cobalt-ink); border-color: var(--cobalt-ink); }
.btn:active { transform: scale(0.98); }

/* ── nav ──────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(247, 245, 239, 0.78);
  border-bottom: 1px solid var(--rule);
}
.nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.16em;
  font-weight: 600;
}
.brand .mark {
  width: 22px; height: 22px;
  position: relative;
  border: 1.5px solid var(--ink);
}
.brand .mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--cobalt);
  transition: transform 0.4s var(--ease);
}
.brand:hover .mark::after { transform: rotate(90deg) scale(0.7); }

.nav-links {
  display: flex;
  gap: 34px;
  list-style: none;
  margin: 0; padding: 0;
}
.nav-links a {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  position: relative;
  padding: 6px 0;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%; bottom: 0;
  height: 1.5px;
  background: var(--cobalt);
  transition: right 0.3s var(--ease);
}
.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::after { right: 0; }
.nav-cta { font-size: 14px; padding: 10px 16px; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ── hero ─────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: clamp(64px, 9vw, 128px) 0 clamp(56px, 7vw, 96px);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: end;
}
.hero-copy > * + * { margin-top: 28px; }
.hero h1 {
  text-wrap: balance;
  max-width: 12ch;
}
.hero h1 .line { display: block; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 38px; }

.hero-figure {
  position: relative;
  aspect-ratio: 1;
  max-width: 480px;
  justify-self: end;
  width: 100%;
}
.hero-figure svg { width: 100%; height: 100%; overflow: visible; }
.hero-figure .caption {
  position: absolute;
  left: 0; bottom: -8px;
  transform: translateY(100%);
}

/* orbit animation */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }
@keyframes pulse {
  0%, 100% { r: 5; opacity: 1; }
  50% { r: 8; opacity: 0.55; }
}
@keyframes dash { to { stroke-dashoffset: -600; } }
.orbit-1 { transform-origin: 200px 200px; animation: spin 36s linear infinite; }
.orbit-2 { transform-origin: 200px 200px; animation: spin-rev 52s linear infinite; }
.orbit-3 { transform-origin: 200px 200px; animation: spin 80s linear infinite; }
.core { animation: pulse 3.2s ease-in-out infinite; }
.trace { stroke-dasharray: 6 10; animation: dash 30s linear infinite; }

/* ── ticker ───────────────────────────────────────────────── */
.ticker {
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
  padding: 16px 0;
  background: var(--paper-2);
}
.ticker-track {
  display: flex;
  gap: 0;
  width: max-content;
  animation: ticker 40s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker span {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 0 28px;
  white-space: nowrap;
  position: relative;
}
.ticker span::before {
  content: "";
  position: absolute;
  left: -3px; top: 50%;
  width: 6px; height: 6px;
  margin-top: -3px;
  background: var(--cobalt);
  transform: rotate(45deg);
}
@keyframes ticker { to { transform: translateX(-50%); } }

/* ── sections ─────────────────────────────────────────────── */
section { position: relative; }
.section {
  padding: clamp(72px, 9vw, 140px) 0;
  border-bottom: 1px solid var(--rule);
}
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  gap: clamp(20px, 4vw, 64px);
  align-items: end;
  margin-bottom: clamp(44px, 6vw, 88px);
}
.section-head .lede { margin-top: 20px; }
.section-head .mono { margin-bottom: 18px; display: block; }

/* services */
.services {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}
.service {
  position: relative;
  padding: 36px 32px 44px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: transparent;
  transition: background 0.35s var(--ease);
  min-height: 420px;
  display: flex;
  flex-direction: column;
}
.service:hover { background: #fff; }
.service .num {
  font-family: var(--font-display);
  font-size: 72px;
  line-height: 0.9;
  color: var(--ink);
  transition: color 0.35s var(--ease), transform 0.5s var(--ease);
}
.service:hover .num { color: var(--cobalt); transform: translateX(6px); }
.service h3 { margin: 40px 0 16px; }
.service p { margin: 0; color: var(--ink-2); font-size: 16px; }
.service ul {
  margin: auto 0 0;
  padding: 22px 0 0;
  list-style: none;
  border-top: 1px dashed var(--rule-strong);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  display: grid;
  gap: 8px;
}
.service ul li::before { content: "— "; color: var(--cobalt); }

/* approach */
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  position: relative;
}
.steps::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 11px;
  height: 1px;
  background: var(--rule-strong);
}
.step { position: relative; padding: 40px 28px 0 0; }
.step::before {
  content: "";
  position: absolute;
  left: 0; top: 6px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  transition: background 0.3s, transform 0.3s;
}
.step:hover::before { background: var(--cobalt); border-color: var(--cobalt); transform: scale(1.3); }
.step .mono { display: block; margin-bottom: 14px; }
.step h3 { font-size: 30px; margin-bottom: 12px; }
.step p { margin: 0; color: var(--ink-2); font-size: 15.5px; }

/* lab (dark block) */
.lab {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 0;
  overflow: hidden;
}
.lab::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(247, 245, 239, 0.14) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(60% 70% at 80% 30%, #000 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(60% 70% at 80% 30%, #000 0%, transparent 100%);
  pointer-events: none;
}
.lab .mono { color: rgba(247, 245, 239, 0.55); }
.lab .lede { color: rgba(247, 245, 239, 0.72); }
.lab h2 em { color: #8ea1ff; }
.lab-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: rgba(247, 245, 239, 0.14);
  border: 1px solid rgba(247, 245, 239, 0.14);
}
.lab-card {
  background: var(--ink);
  padding: 34px 32px 38px;
  transition: background 0.35s var(--ease);
}
.lab-card:hover { background: #17191c; }
.lab-card .mono { display: block; margin-bottom: 26px; }
.lab-card h3 { color: var(--paper); margin-bottom: 14px; }
.lab-card p { margin: 0; color: rgba(247, 245, 239, 0.7); font-size: 15.5px; }
.lab-note {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid rgba(247, 245, 239, 0.14);
  color: rgba(247, 245, 239, 0.55);
  font-size: 14px;
  max-width: 60ch;
}

/* company */
.company .wrap {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
  gap: clamp(32px, 6vw, 96px);
}
.company .statement {
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 24px 0 0;
  text-wrap: pretty;
}
.company .statement em { color: var(--cobalt); font-style: italic; }
.facts {
  margin: 0;
  border-top: 1px solid var(--ink);
}
.facts .row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
}
.facts dt { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); padding-top: 3px; }
.facts dd { margin: 0; color: var(--ink); }
.facts dd small { display: block; color: var(--ink-3); font-size: 13px; margin-top: 2px; }

/* contact */
.contact .wrap {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 6vw, 96px);
}
.contact-side > * + * { margin-top: 22px; }
.contact-side address {
  font-style: normal;
  color: var(--ink-2);
  line-height: 1.6;
  font-size: 15.5px;
}
.contact-side .mono { display: block; margin-bottom: 8px; }

form.inquiry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 22px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.field input, .field select, .field textarea {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule-strong);
  padding: 10px 0 12px;
  border-radius: 0;
  outline: none;
  transition: border-color 0.25s;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23101214' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 2px center;
  padding-right: 24px;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-bottom-color: var(--cobalt); }
.field input::placeholder, .field textarea::placeholder { color: rgba(16, 18, 20, 0.35); }
.form-foot {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}
.form-foot small { color: var(--ink-3); font-size: 13px; max-width: 42ch; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.thanks {
  display: none;
  grid-column: 1 / -1;
  padding: 18px 20px;
  border: 1px solid var(--cobalt);
  background: var(--cobalt-soft);
  color: var(--cobalt-ink);
  font-weight: 600;
  font-size: 15px;
}
.thanks.show { display: block; }

/* footer */
footer {
  padding: 40px 0 48px;
}
footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px 40px;
  align-items: flex-start;
}
footer .mono { line-height: 1.9; text-transform: none; letter-spacing: 0.03em; font-size: 12.5px; }
footer .links { display: flex; gap: 22px; }
footer .links a { font-size: 13px; font-weight: 600; color: var(--ink-2); }
footer .links a:hover { color: var(--cobalt); }

/* ── reveal on scroll ─────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 0.08s; }
.reveal[data-delay="2"] { transition-delay: 0.16s; }
.reveal[data-delay="3"] { transition-delay: 0.24s; }
.reveal[data-delay="4"] { transition-delay: 0.32s; }

/* hero load-in */
@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}
.hero .rise { animation: rise 0.9s var(--ease) both; }
.hero .rise:nth-child(2) { animation-delay: 0.1s; }
.hero .rise:nth-child(3) { animation-delay: 0.2s; }
.hero .rise:nth-child(4) { animation-delay: 0.3s; }
.hero-figure { animation: rise 1.2s var(--ease) 0.25s both; }

/* legal page */
.legal { padding: clamp(56px, 7vw, 104px) 0 80px; }
.legal .wrap { max-width: 760px; }
.legal h1 { font-size: clamp(40px, 6vw, 72px); margin-bottom: 12px; }
.legal h2 { font-size: 28px; margin: 44px 0 12px; }
.legal p, .legal li { color: var(--ink-2); font-size: 16px; }
.legal ul { padding-left: 20px; }
.legal .meta { margin-bottom: 40px; }

/* ── responsive ───────────────────────────────────────────── */
@media (max-width: 1000px) {
  .services { grid-template-columns: 1fr 1fr; }
  .service:nth-child(3) { grid-column: 1 / -1; min-height: 0; }
  .steps { grid-template-columns: 1fr 1fr; gap: 28px 24px; }
  .steps::before { display: none; }
  .step { padding-top: 28px; border-top: 1px solid var(--rule-strong); }
  .step::before { top: -6px; }
}
@media (max-width: 840px) {
  .nav-links, .nav-cta { display: none; }
  .nav-toggle { display: inline-block; }
  .nav.open .nav-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: absolute;
    left: 0; right: 0; top: 68px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: 16px var(--gutter) 22px;
  }
  .nav.open .nav-links a { font-size: 18px; padding: 10px 0; }
  .hero .wrap { grid-template-columns: 1fr; }
  .hero-figure { max-width: 340px; justify-self: start; margin-top: 8px; }
  .hero-figure .caption { position: static; transform: none; margin-top: 16px; }
  .section-head, .company .wrap, .contact .wrap { grid-template-columns: 1fr; }
  .lab-grid { grid-template-columns: 1fr; }
  form.inquiry { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-foot, .thanks { grid-column: auto; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .services { grid-template-columns: 1fr; }
  .service { min-height: 0; padding: 28px 22px 32px; }
  .steps { grid-template-columns: 1fr; }
  .facts .row { grid-template-columns: 1fr; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}
