/* AMELIA — "being rebuilt" page. Palette drawn from the Amelia portrait:
   navy hair underlayer, teal shirt, golden streak, lavender coat shading. */
:root {
  --bg: #f5f2ea;
  --bg-2: #e9f1ee;
  --ink: #161a3a;
  --ink-2: #454a68;
  --ink-3: #5d6180;
  --teal: #127c7f;
  --teal-ink: #0e6769;
  --gold: #e3a21a;
  --lav: #8d7fd3;
  --grid: rgba(18, 124, 127, 0.07);
  --grid-major: rgba(18, 124, 127, 0.13);
  --sheet: #dcebe7;
  --sheet-grid: rgba(18, 124, 127, 0.15);
  --sheet-edge: rgba(18, 124, 127, 0.30);
  --line: rgba(22, 26, 58, 0.34);
  --glow: rgba(98, 214, 207, 0.34);
  --track: rgba(22, 26, 58, 0.10);
  --sheen: rgba(255, 255, 255, 0.28);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1030;
    --bg-2: #0f1a44;
    --ink: #eef0fa;
    --ink-2: #b4b9d6;
    --ink-3: #8c92b6;
    --teal: #5fd4cd;
    --teal-ink: #6fdcd5;
    --gold: #f4b942;
    --lav: #a99cf0;
    --grid: rgba(111, 220, 213, 0.05);
    --grid-major: rgba(111, 220, 213, 0.10);
    --sheet: #15235a;
    --sheet-grid: rgba(140, 222, 230, 0.13);
    --sheet-edge: rgba(140, 222, 230, 0.28);
    --line: rgba(206, 214, 255, 0.40);
    --glow: rgba(95, 212, 205, 0.20);
    --track: rgba(238, 240, 250, 0.12);
    --sheen: rgba(255, 255, 255, 0.18);
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; overflow-x: hidden; overflow-x: clip; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Backdrop: drifting blueprint grid + breathing wash ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(160deg, var(--bg) 20%, var(--bg-2) 100%);
  -webkit-mask-image: radial-gradient(130% 95% at 62% 42%, #000 45%, transparent 100%);
          mask-image: radial-gradient(130% 95% at 62% 42%, #000 45%, transparent 100%);
}
.grid {
  position: absolute;
  inset: -120px;
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  animation: drift 48s linear infinite;
  will-change: transform;
}
.wash {
  position: absolute;
  inset: -10%;
  background: radial-gradient(42% 46% at 68% 44%, var(--glow), transparent 72%);
  animation: breathe 9s ease-in-out infinite;
  will-change: transform, opacity;
}

/* ---------- Layout ---------- */
.page {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 72px) clamp(16px, 5vw, 64px) 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  align-items: center;
  gap: clamp(24px, 5vw, 72px);
}

/* ---------- Copy ---------- */
.copy { max-width: 520px; }

.brand {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 12px;
  margin: 0 0 clamp(28px, 6vh, 56px);
  font-family: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.28em;
  color: var(--ink);
}
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark rect { fill: var(--teal); }
.brand-mark path { fill: none; stroke: var(--bg); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark circle { fill: var(--gold); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-family: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal-ink);
}
.pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--gold);
  animation: ping 2.4s cubic-bezier(0.2, 0.6, 0.35, 1) infinite;
}

h1 {
  margin: 0;
  font-family: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
  font-weight: 560;
  font-optical-sizing: auto;
  font-size: clamp(40px, 5.4vw, 72px);
  line-height: 1.03;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

.lede {
  margin: 18px 0 30px;
  max-width: 36ch;
  font-size: clamp(17px, 1.35vw, 19px);
  color: var(--ink-2);
  text-wrap: pretty;
}

.progress {
  position: relative;
  width: min(100%, 340px);
  height: 6px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  animation: travel 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  will-change: transform;
}

.phases {
  margin: 16px 0 0;
  font-family: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.phases span { margin: 0 0.5em; color: var(--gold); }

/* ---------- Art ---------- */
.art {
  position: relative;
  margin: 0;
  width: 100%;
  max-width: 620px;
  justify-self: center;
  aspect-ratio: 1 / 1.08;
}
.stage, .figure-wrap, .motes {
  translate: calc(var(--mx, 0) * var(--depth, 0) * 1px) calc(var(--my, 0) * var(--depth, 0) * 1px);
}
.stage { position: absolute; inset: 0; --depth: 5; }

.sheet {
  position: absolute;
  left: 7%;
  width: 86%;
  top: 3%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--sheet);
  box-shadow: inset 0 0 0 1px var(--sheet-edge);
}
.sheet-grid {
  position: absolute;
  inset: -40px;
  background-image:
    linear-gradient(var(--sheet-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--sheet-grid) 1px, transparent 1px);
  background-size: 20px 20px;
  animation: drift-small 30s linear infinite;
  will-change: transform;
}
.ring-box {
  position: absolute;
  left: 3%;
  width: 94%;
  top: -1%;
  aspect-ratio: 1;
  overflow: hidden;
}
.ring {
  display: block;
  width: 100%;
  height: 100%;
  animation: spin 90s linear infinite;
  will-change: transform;
}
.ring circle { fill: none; stroke: var(--line); stroke-width: 0.6; stroke-dasharray: 1.2 3.4; }

.notes { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.notes path, .notes circle { fill: none; stroke: var(--line); stroke-width: 1.2; stroke-linecap: round; }
.notes text {
  fill: var(--ink-3);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-anchor: middle;
}
.note { opacity: 0; animation: note 14s ease-in-out infinite; }
.n1 { animation-delay: 0s; }
.n2 { animation-delay: -3.5s; }
.n3 { animation-delay: -7s; }
.n4 { animation-delay: -10.5s; }

.figure-wrap {
  position: absolute;
  left: 4%;
  width: 92%;
  bottom: 0;
  --depth: 9;
}
.figure { position: relative; animation: float 7s ease-in-out infinite; will-change: transform; }
.figure img { display: block; width: 100%; height: auto; }
.blink { position: absolute; inset: 0; opacity: 0; animation: blink 6.4s step-end infinite; animation-delay: 1.8s; }
.sheen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask: url("amelia-mask.png") center / 100% 100% no-repeat;
          mask: url("amelia-mask.png") center / 100% 100% no-repeat;
}
.sheen span {
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: 0;
  width: 20%;
  background: linear-gradient(100deg, transparent 0%, var(--sheen) 50%, transparent 100%);
  transform: translateX(-130%) skewX(-8deg);
  animation: sweep 9s cubic-bezier(0.5, 0, 0.3, 1) infinite;
  animation-delay: 2.5s;
  will-change: transform;
}

.motes { position: absolute; inset: 0; pointer-events: none; --depth: 3; }
.motes i {
  position: absolute;
  left: var(--x);
  bottom: 14%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
  animation: rise var(--t) linear infinite;
  animation-delay: var(--d);
  will-change: transform, opacity;
}
.motes i:nth-child(1) { --x: 8%;  --d: 0s;    --t: 9s; }
.motes i:nth-child(2) { --x: 22%; --d: -3s;   --t: 11s; }
.motes i:nth-child(3) { --x: 37%; --d: -6s;   --t: 10s; }
.motes i:nth-child(4) { --x: 55%; --d: -1.5s; --t: 12s; }
.motes i:nth-child(5) { --x: 68%; --d: -8s;   --t: 9.5s; }
.motes i:nth-child(6) { --x: 81%; --d: -4.5s; --t: 11.5s; }
.motes i:nth-child(7) { --x: 92%; --d: -7s;   --t: 10.5s; }
.motes i:nth-child(3n + 2) { background: none; width: 11px; height: 11px; border-radius: 0; }
.motes i:nth-child(3n + 2)::before,
.motes i:nth-child(3n + 2)::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  background: var(--teal);
  width: 100%;
  height: 1.8px;
}
.motes i:nth-child(3n + 2)::after { width: 1.8px; height: 100%; }
.motes i:nth-child(3n) { background: var(--lav); border-radius: 2px; width: 6px; height: 6px; }

/* ---------- Footer ---------- */
.foot {
  position: relative;
  z-index: 1;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  text-align: center;
  font-family: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--ink-3);
}

/* ---------- Phone + portrait tablet (stacked) ---------- */
@media (max-width: 780px), (max-width: 1100px) and (orientation: portrait) {
  body { font-size: 16px; }
  .page {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding-top: 18px;
    align-items: start;
    align-content: center;
  }
  .art { order: -1; max-width: 400px; aspect-ratio: 1 / 1.02; }
  .copy { max-width: 560px; width: 100%; justify-self: center; }
  .brand { position: absolute; top: 18px; left: 16px; margin: 0; font-size: 12px; gap: 10px; }
  .brand-mark { width: 26px; height: 26px; }
  .page { padding-top: 56px; }
  h1 { font-size: clamp(34px, 9.4vw, 58px); }
  .lede { margin: 12px 0 22px; }
  .notes text { font-size: 13px; }
}
@media (min-width: 781px) and (max-width: 1100px) and (orientation: portrait) {
  .art { max-width: 480px; }
  .brand { top: 32px; left: max(16px, calc(50% - 280px)); }
}

/* ---------- Motion ---------- */
@keyframes drift { to { transform: translate3d(120px, 120px, 0); } }
@keyframes drift-small { to { transform: translate3d(20px, 20px, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}
@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -9px, 0); }
}
@keyframes blink {
  0% { opacity: 0; }
  95% { opacity: 1; }
  97.4%, 100% { opacity: 0; }
}
@keyframes sweep {
  0% { transform: translateX(-130%) skewX(-8deg); }
  26%, 100% { transform: translateX(560%) skewX(-8deg); }
}
@keyframes rise {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
  12% { opacity: 0.85; }
  80% { opacity: 0.55; }
  100% { transform: translate3d(0, -280px, 0) rotate(90deg); opacity: 0; }
}
@keyframes note {
  0%, 100% { opacity: 0; transform: translate3d(0, 4px, 0); }
  10%, 40% { opacity: 1; transform: translate3d(0, 0, 0); }
  52%, 99.9% { opacity: 0; transform: translate3d(0, -4px, 0); }
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.7; }
  80%, 100% { transform: scale(3); opacity: 0; }
}
@keyframes travel {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(238%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .note { opacity: 1; }
  .motes { display: none; }
  .progress-bar { width: 100%; transform: none; opacity: 0.35; }
  .stage, .figure-wrap, .motes { translate: none; }
}
