/* Pass 2 — external critique: visual hierarchy, tactile detail, and the switch event */

:root {
  --night: #110c0a;
  --deep: #070709;
  --ink: #f6e4c5;
  --taupe: #c0a588;
  --muted: #a78c73;
  --amber: #f3a93d;
  --amber2: #ffd889;
  --violet: #705c82;
  --line: rgba(239, 198, 143, 0.2);
}

html {
  background: var(--deep);
}

body {
  background-color: var(--night);
  background-image:
    radial-gradient(circle at 75% 11%, rgba(245, 165, 54, 0.09), transparent 21rem),
    linear-gradient(112deg, transparent 0 58%, rgba(108, 78, 55, 0.04) 58% 59%, transparent 59%);
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: rgba(243, 169, 61, 0.2);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0;
  background-image:
    radial-gradient(circle at 13% 18%, #d6d9e5 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 31%, #a9b3d0 0 1px, transparent 1.5px),
    radial-gradient(circle at 48% 68%, #d6d9e5 0 1px, transparent 1.5px),
    radial-gradient(circle at 86% 83%, #8793b1 0 1px, transparent 1.5px);
  background-size: 213px 197px, 287px 271px, 353px 331px, 419px 389px;
  transition: opacity 1.2s ease 0.35s;
}

body.moon::after {
  opacity: 0.55;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 13px 16px;
  color: #1c110b;
  background: var(--amber2);
  font: 700 10px var(--mono);
  letter-spacing: 0.08em;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

h1,
h2,
h3,
.dek,
.guide-intro {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

.site-header {
  backdrop-filter: blur(12px);
  background: linear-gradient(180deg, rgba(9, 7, 8, 0.7), rgba(9, 7, 8, 0.22));
}

.site-header nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.brand-mark {
  filter: drop-shadow(0 0 8px rgba(243, 169, 61, 0.5));
}

.porch-switch {
  touch-action: manipulation;
  border-radius: 4px;
}

.porch-switch:hover .switch-track,
.porch-switch:focus-visible .switch-track {
  box-shadow: 0 0 9px rgba(255, 215, 137, 0.8), 0 0 30px rgba(243, 169, 61, 0.42);
}

#moth-field {
  opacity: 0;
  transition: opacity 1.1s ease 0.55s;
}

body.loaded #moth-field {
  opacity: 0.84;
}

.hero {
  min-height: max(780px, 100svh);
}

.hero-copy::before {
  content: "OBSERVATION / 061";
  position: absolute;
  left: -38px;
  top: 50%;
  color: rgba(214, 181, 139, 0.45);
  font: 8px var(--mono);
  letter-spacing: 0.16em;
  writing-mode: vertical-rl;
  transform: translateY(-50%) rotate(180deg);
}

.hero h1 {
  text-shadow: 0 1px 0 #2c1d16, 0 0 42px rgba(243, 169, 61, 0.08);
}

.hero h1 span:nth-child(2) {
  color: #f2ad46;
  text-shadow: 0 0 32px rgba(243, 169, 61, 0.16);
}

.porch-stage {
  min-height: 700px;
  background-image:
    linear-gradient(90deg, rgba(240, 195, 134, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(240, 195, 134, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 50% 35%, rgba(247, 171, 58, 0.12), transparent 50%);
  background-size: 42px 42px, 42px 42px, auto;
}

.porch-stage::before,
.porch-stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.porch-stage::before {
  inset: 18px;
  border: 1px solid rgba(230, 190, 135, 0.09);
  clip-path: polygon(0 0, 34% 0, 34% 1px, 66% 1px, 66% 0, 100% 0, 100% 100%, 71% 100%, 71% calc(100% - 1px), 29% calc(100% - 1px), 29% 100%, 0 100%);
}

.porch-stage::after {
  inset: 0;
  background: radial-gradient(circle at 50% 31%, transparent 0 20%, rgba(6, 5, 6, 0.2) 58%, rgba(6, 5, 6, 0.58) 100%);
  z-index: 0;
}

.lamp,
.hero-specimen,
.stage-caption {
  z-index: 2;
}

.lamp {
  animation: lamp-breathe 4.8s ease-in-out infinite;
}

.hero-specimen {
  width: min(92%, 640px);
  opacity: 0.98;
  transform: translate(-50%, -50%) rotate(-3deg);
  transform-origin: 50% 40%;
  animation: specimen-settle 1.25s 0.35s both cubic-bezier(0.16, 0.84, 0.24, 1);
}

.hero-specimen svg {
  filter: drop-shadow(0 22px 18px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 28px rgba(240, 168, 65, 0.1));
}

.hero-wing {
  fill: url(#heroBase);
  stroke: #d9b787;
  stroke-width: 2;
}

.hero-specimen > span {
  padding-top: 7px;
  border-top: 1px solid rgba(221, 186, 137, 0.35);
}

.field-link {
  border-left: 1px solid rgba(243, 169, 61, 0.46);
  margin-top: 5px;
}

.light-source {
  position: relative;
}

.light-source.flicker {
  animation: text-flicker 0.42s steps(2, end);
}

.theory-aside {
  max-width: 440px;
  margin: 52px 0 0 auto;
  padding: 18px 0 18px 21px;
  border-left: 1px solid var(--violet);
  color: var(--muted);
  font: 10px/1.75 var(--mono);
}

.theory-aside b {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: 0.06em;
}

.compass-diagram {
  position: relative;
}

.compass-diagram::before {
  content: "THE SAME RULE / TWO DISTANCES";
  position: absolute;
  top: -28px;
  right: 0;
  color: var(--muted);
  font: 8px var(--mono);
  letter-spacing: 0.12em;
}

.diagram-orbit,
.diagram-transect {
  background:
    linear-gradient(90deg, rgba(235, 201, 155, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(235, 201, 155, 0.035) 1px, transparent 1px),
    rgba(8, 7, 9, 0.35);
  background-size: 24px 24px;
}

.census {
  isolation: isolate;
  background-color: #e1caa3;
  background-image:
    radial-gradient(circle at 77% 9%, rgba(255, 248, 217, 0.62), transparent 24rem),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(79, 50, 34, 0.05) 32px),
    linear-gradient(102deg, transparent 0 6%, rgba(104, 72, 51, 0.05) 6% 6.1%, transparent 6.1%);
  box-shadow: inset 0 22px 70px rgba(70, 38, 23, 0.15), inset 0 -24px 80px rgba(92, 59, 34, 0.12);
}

.census::before {
  content: "NFP / FORM M-12";
  position: absolute;
  right: 2vw;
  top: 8rem;
  z-index: -1;
  color: rgba(76, 43, 29, 0.08);
  font: 700 clamp(54px, 9vw, 130px) var(--mono);
  letter-spacing: -0.09em;
  transform: rotate(90deg) translateX(100%);
  transform-origin: right top;
}

.census-head {
  position: relative;
}

.census-head::after {
  content: "COLLECTED 09 AUG 2025 / RELEASE 04:18";
  position: absolute;
  left: 0;
  bottom: -22px;
  color: #76563f;
  font: 7px var(--mono);
  letter-spacing: 0.1em;
}

.ledger {
  margin-top: 14px;
}

.ledger-row {
  font-variant-numeric: tabular-nums;
  touch-action: manipulation;
}

.specimen-row {
  position: relative;
  overflow: hidden;
  transition: color 0.22s ease, background-color 0.22s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.specimen-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: #e5a141;
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.28s ease;
}

.specimen-row:hover::before,
.specimen-row:focus-visible::before,
.specimen-row.active::before {
  transform: scaleY(1);
}

.specimen-row.active em {
  color: #ffc86f;
  opacity: 1;
}

.specimen-view {
  padding: 48px 3vw 0;
  background: radial-gradient(ellipse at 35% 44%, rgba(255, 247, 210, 0.45), transparent 48%);
}

.specimen-view::before {
  content: "RELEASED / NO PIN USED";
  position: absolute;
  right: 0;
  top: 15px;
  color: #7b5e48;
  font: 7px var(--mono);
  letter-spacing: 0.11em;
}

.specimen-view svg {
  transform-origin: center;
}

.dust {
  background-image:
    radial-gradient(circle at 88% 17%, rgba(109, 83, 124, 0.15), transparent 21rem),
    linear-gradient(135deg, #1a110e, #0d0b0c 68%);
}

.dust-texture {
  filter: drop-shadow(20px 28px 30px rgba(0, 0, 0, 0.64));
}

.dust-texture i {
  border: 1px solid rgba(239, 200, 145, 0.17);
}

.night-chart b,
.night-chart span,
.chart-note,
.stage-caption,
.hero-index {
  font-variant-numeric: tabular-nums;
}

.night-chart i {
  background:
    repeating-linear-gradient(90deg, transparent 0 10px, rgba(255, 221, 161, 0.1) 10px 11px),
    linear-gradient(180deg, rgba(244, 174, 70, 0.74), rgba(93, 74, 112, 0.28));
  transform: scaleY(0);
  animation: chart-rise 1.1s 0.2s both cubic-bezier(0.16, 0.84, 0.24, 1);
}

.night-chart > div:nth-child(2) i { animation-delay: 0.28s; }
.night-chart > div:nth-child(3) i { animation-delay: 0.36s; }
.night-chart > div:nth-child(4) i { animation-delay: 0.44s; }
.night-chart > div:nth-child(5) i { animation-delay: 0.52s; }
.night-chart > div:nth-child(6) i { animation-delay: 0.6s; }

.apology {
  min-height: 720px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 9% 45%, rgba(110, 88, 132, 0.38), transparent 28%),
    linear-gradient(135deg, #312438, #141014 49%, #0b090b);
}

.apology::before {
  content: "";
  position: absolute;
  width: 680px;
  height: 680px;
  right: -360px;
  bottom: -320px;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 25px, rgba(178, 150, 192, 0.06) 26px 27px);
}

.apology-number,
.apology-copy,
.final-switch {
  position: relative;
  z-index: 1;
}

.apology-copy > p:not(.eyebrow) {
  max-width: 650px;
}

.final-switch {
  touch-action: manipulation;
}

.mode-wipe {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 84% 8%, rgba(198, 207, 230, 0.2), transparent 22%),
    #070a11;
  transform: scaleX(0);
  transform-origin: right;
}

.mode-flash {
  position: fixed;
  z-index: 61;
  left: var(--pad);
  bottom: 8vh;
  pointer-events: none;
  display: grid;
  gap: 6px;
  opacity: 0;
  color: #d7dbe6;
}

.mode-flash span,
.mode-flash i {
  font: 8px var(--mono);
  letter-spacing: 0.15em;
}

.mode-flash b {
  font: 400 clamp(38px, 6vw, 78px)/0.9 var(--serif);
}

.mode-flash i {
  color: #9ca6c2;
  font-style: normal;
}

body.is-switching .mode-wipe {
  animation: moon-wipe 1.3s both cubic-bezier(0.76, 0, 0.24, 1);
}

body.is-switching .mode-flash {
  animation: mode-flash 1.55s both ease;
}

body.moon {
  --night: #080b12;
  --deep: #04060a;
  --ink: #e8e9e4;
  --taupe: #b8bbc5;
  --muted: #9499a9;
  --amber: #aeb6d0;
  --amber2: #dde2ed;
  --violet: #7580a5;
  --line: rgba(191, 200, 224, 0.2);
}

body.moon #moth-field {
  mix-blend-mode: screen;
  opacity: 0.68;
}

body.moon .hero h1 {
  line-height: 0.9;
  letter-spacing: -0.025em;
  text-shadow: 0 0 38px rgba(190, 202, 229, 0.08);
}

body.moon .hero h1 span:nth-child(2) {
  padding-left: 0.4em;
  color: #c6ccdd;
}

body.moon .hero h1 span:nth-child(3) {
  padding-left: 0.7em;
}

body.moon .porch-stage {
  background-image:
    linear-gradient(90deg, rgba(194, 205, 231, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(194, 205, 231, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 75% 9%, rgba(173, 190, 226, 0.1), transparent 38%);
}

body.moon .hero-specimen {
  opacity: 0.32;
  filter: grayscale(0.7) saturate(0.3);
  transform: translate(-48%, -50%) rotate(1deg);
}

body.moon .theory-aside {
  margin-top: 76px;
  max-width: 510px;
}

body.moon .census {
  background-color: #c8cbd0;
  background-image:
    radial-gradient(circle at 77% 9%, rgba(242, 245, 249, 0.68), transparent 24rem),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(47, 53, 69, 0.06) 40px),
    linear-gradient(102deg, transparent 0 6%, rgba(51, 58, 78, 0.06) 6% 6.1%, transparent 6.1%);
}

body.moon .observation {
  grid-template-columns: 110px minmax(300px, 530px) 1fr;
  gap: 8vw;
}

body.moon .dust-copy > p:not(.eyebrow),
body.moon .observation-copy > p:not(.eyebrow):not(.lead) {
  line-height: 2;
}

body.moon .lamp {
  animation: none;
}

body.moon .apology {
  background:
    radial-gradient(ellipse at 9% 45%, rgba(94, 108, 151, 0.35), transparent 28%),
    linear-gradient(145deg, #222b43, #0e131e 48%, #060910);
}

@keyframes lamp-breathe {
  0%, 100% { filter: drop-shadow(0 20px 54px rgba(255, 170, 65, 0.58)); }
  50% { filter: drop-shadow(0 20px 82px rgba(255, 170, 65, 0.78)); }
}

@keyframes specimen-settle {
  from { opacity: 0; transform: translate(-48%, -46%) rotate(2deg) scale(1.05); }
}

@keyframes text-flicker {
  0%, 100% { opacity: 1; }
  35% { opacity: 0.52; }
  55% { opacity: 0.9; }
  72% { opacity: 0.36; }
}

@keyframes chart-rise {
  to { transform: scaleY(1); }
}

@keyframes moon-wipe {
  0% { opacity: 0; transform: scaleX(0); }
  37% { opacity: 1; transform: scaleX(1); transform-origin: right; }
  63% { opacity: 1; transform: scaleX(1); transform-origin: left; }
  100% { opacity: 0; transform: scaleX(0); transform-origin: left; }
}

@keyframes mode-flash {
  0%, 28% { opacity: 0; transform: translateY(18px); }
  42%, 72% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-12px); }
}

@media (min-width: 951px) {
  .hero-copy {
    padding-right: clamp(36px, 4vw, 72px);
  }

  .observation-copy {
    padding-top: 20px;
  }
}

@media (min-width: 601px) and (max-width: 950px) {
  .site-header {
    grid-template-columns: auto 1fr auto;
    gap: 18px;
  }

  .site-header > nav {
    display: flex;
    justify-content: center;
    min-width: 0;
  }

  .site-header nav a {
    padding-inline: 9px;
    font-size: 8px;
  }

  .hero-copy::before {
    display: none;
  }

  .hero-specimen {
    width: 102%;
  }

  .observation {
    gap: 4vw;
  }

  .apology {
    min-height: 760px;
  }
}

@media (max-width: 600px) {
  :root {
    --pad: 20px;
  }

  .site-header {
    height: 116px;
    grid-template-columns: 1fr auto;
    align-items: start;
    padding-top: 11px;
  }

  .site-header > nav {
    position: absolute;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    left: 0;
    right: 0;
    top: 69px;
    height: 47px;
    border-top: 1px solid var(--line);
    background: rgba(8, 7, 8, 0.74);
  }

  .site-header nav a {
    justify-content: center;
    padding: 0 5px;
    font-size: 8px;
    border-right: 1px solid var(--line);
  }

  .site-header nav a:last-child {
    border-right: 0;
  }

  .site-header nav a::after {
    display: none;
  }

  .hero {
    padding-top: 158px;
  }

  .hero::before {
    top: 116px;
  }

  .hero-copy::before {
    display: none;
  }

  .hero h1 {
    font-size: clamp(54px, 17.5vw, 69px);
    letter-spacing: -0.06em;
  }

  .hero h1 span:nth-child(2) {
    padding-left: 0.25em;
  }

  .porch-stage {
    min-height: 445px;
  }

  .hero-specimen {
    top: 60%;
    width: 98%;
  }

  .hero-specimen > span {
    margin-right: 5%;
  }

  .theory-aside {
    margin: 42px 0 0;
  }

  .census {
    padding-bottom: 72px;
  }

  .census::before {
    display: none;
  }

  .census-head::after {
    line-height: 1.5;
  }

  .ledger {
    margin-top: 28px;
  }

  .specimen-view {
    margin-top: 52px;
    padding: 38px 0 0;
  }

  .specimen-view::before {
    top: 12px;
  }

  .specimen-view svg {
    height: 225px;
  }

  .specimen-meta {
    margin-top: 20px;
  }

  .dust-texture {
    margin-bottom: 58px;
  }

  .night-chart {
    height: 330px;
  }

  .night-chart span {
    line-height: 1.35;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    bottom: -60px;
  }

  .chart-note {
    margin-top: 90px;
  }

  .apology {
    min-height: 0;
  }

  .apology-number {
    margin-bottom: 52px;
  }

  .apology-copy h2 {
    font-size: clamp(48px, 14vw, 56px);
  }

  .mode-flash {
    bottom: 15vh;
  }

  body.moon .hero h1 span:nth-child(2) {
    padding-left: 0.08em;
  }

  body.moon .hero h1 span:nth-child(3) {
    padding-left: 0.35em;
  }

  body.moon .section-pad {
    padding-top: 112px;
    padding-bottom: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lamp,
  .hero-specimen,
  .night-chart i,
  body.is-switching .mode-wipe,
  body.is-switching .mode-flash {
    animation: none;
  }

  #moth-field {
    transition: none;
  }

  body::after,
  .skip-link {
    transition: none;
  }
}
