/* ==========================================================================
   Home — Contact #contact (24:60, H7: the note no key marks)
   The catalogue's one true night. The seventh harmonic falls 31 cents flat of
   B♭, where no key is: a firefly settles there on first entry and its light
   falls through a crack cut in the B♭ key, the six node lines of mode 7 light
   left to right, and the two addresses ring as strings in mode 7 (contact.js
   writes the letters and their string).
   Tokens and anatomy live in css/home.css; everything here is scoped to
   html[data-page="home"] .contact.
   ========================================================================== */

html[data-page="home"] .contact {
  --keys-h: clamp(104px, 12vw, 188px);
  --pad-b: clamp(40px, 5vw, 88px);
  --mail-gap: clamp(12px, 2vw, 28px);
  /* Room for the focus ring around each address row (pulled back out with a
     negative margin, so the content stays on its lines). */
  --mail-pad: clamp(8px, 1.2vw, 18px);
  --bone: #f7f1f3;
  --firefly: #e9c452;
  --ember: #ff6b4a;
  padding-bottom: var(--pad-b);
  overflow: hidden;
}

/* --- Node lines: six hairlines at k/7, lit left to right on first entry -------
   They stop 24 px above the keyboard strip, which sits on the bottom padding. */
html[data-page="home"] .contact .nodes {
  bottom: calc(var(--keys-h) + var(--pad-b) + 24px);
  background-image: none;
  opacity: 1;
}

html[data-page="home"] .contact .contact__node {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(100% * var(--k) / 7);
  width: 1px;
  background: linear-gradient(180deg, transparent 0, var(--bone) 9%, var(--bone) 86%, transparent 100%);
  opacity: 0.06;
  transition: opacity 1100ms var(--ease-settle) calc(var(--k) * 90ms);
}

html[data-page="home"] .contact.is-lit .contact__node {
  opacity: 0.18;
}

/* The caption reads in firefly once the climb closes. */
html[data-page="home"] .contact .nodes__cap {
  transition: color 900ms var(--ease-settle) 630ms;
}

html[data-page="home"] .contact.is-lit .nodes__cap {
  color: rgb(233 196 82 / 0.78);
}

/* The minute on the far wall: 24:60 in bone. */
html[data-page="home"] .contact .room {
  color: var(--bone);
  opacity: 0.07;
}

/* --- Head and statement ---------------------------------------------------------- */
html[data-page="home"] .contact .contact__head {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: clamp(22px, 2.6vw, 40px);
}

html[data-page="home"] .contact .section-tc b {
  color: var(--firefly);
}

html[data-page="home"] .contact .contact__title {
  grid-column: 1 / span 8;
  max-width: 11.5em;
  margin: 0;
  font-family: var(--f-serif);
  font-weight: 500;
  font-stretch: normal;
  font-variation-settings: normal;
  font-synthesis: none;
  font-size: clamp(2.25rem, 5.4vw, 5.75rem);
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--bone);
}

html[data-page="home"][lang="en"] .contact .contact__title {
  font-weight: 400;
  font-size: clamp(2.25rem, 5.8vw, 6.25rem);
  line-height: 1.04;
  letter-spacing: -0.018em;
  max-width: 12em;
}

/* Japanese display serif: the served Shippori Mincho subset has no palt
   metrics, so full-width kana are tightened with tracking instead (詰め組み). */
html[data-page="home"][lang="ja-JP"] .contact .contact__title {
  font-size: clamp(2rem, 4.8vw, 5.25rem);
  letter-spacing: -0.04em;
  max-width: 12.5em;
}

html[data-page="home"] .contact .contact__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  margin-top: clamp(32px, 4vw, 64px);
}

html[data-page="home"] .contact .contact__body {
  grid-column: 1 / span 6;
  max-width: 34em;
  margin: 0;
  color: rgb(247 241 243 / 0.9);
  font-size: var(--t-body);
  line-height: 1.85;
}

html[data-page="home"][lang="ja-JP"] .contact .contact__body {
  word-break: auto-phrase;
}

html[data-page="home"][lang="en"] .contact .contact__body {
  max-width: 62ch;
  line-height: 1.6;
}

html[data-page="home"] .contact .contact__body strong {
  font-family: var(--f-mono);
  font-size: 0.8125em;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--bone);
}

/* --- Ringing addresses ------------------------------------------------------------ */
html[data-page="home"] .contact .mails {
  grid-column: 1 / -1;
  margin: clamp(56px, 7vw, 120px) 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

html[data-page="home"] .contact .mails li {
  border-bottom: 1px solid var(--line);
}

html[data-page="home"] .contact .mail {
  display: grid;
  /* The address starts on the first node line (1/7 of the width). */
  grid-template-columns: clamp(2.75rem, calc(100vw / 7 - var(--gutter) - var(--mail-gap)), 9rem) minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--mail-gap);
  margin-inline: calc(-1 * var(--mail-pad));
  padding: clamp(22px, 3vw, 44px) var(--mail-pad) clamp(26px, 3.4vw, 50px);
  border-radius: 6px;
  color: var(--bone);
  text-decoration: none;
  outline-offset: 6px;
}

html[data-page="home"] .contact .mail__index {
  align-self: start;
  padding-top: 0.5em;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--ember);
}

html[data-page="home"] .contact .mail__addr {
  --wdth: 112;
  position: relative;
  justify-self: start;
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  font-family: var(--f-latin);
  font-size: clamp(1.375rem, 4.1vw, 4.25rem);
  font-weight: 700;
  font-stretch: 112%;
  font-variation-settings: "wdth" var(--wdth);
  font-synthesis: none;
  line-height: 1.05;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

html[data-page="home"] .contact .mail__addr .ch {
  display: inline-block;
  transition: color 320ms var(--ease-settle);
  transition-delay: calc(var(--ci) * 12ms);
}

/* The string the letters ride: flat at rest, mode 7 while ringing. */
html[data-page="home"] .contact .mail__string {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.36em;
  width: 100%;
  height: 24px;
  overflow: visible;
  pointer-events: none;
}

html[data-page="home"] .contact .mail__string path {
  fill: none;
  stroke: var(--bone);
  stroke-opacity: 0.26;
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  transition: stroke 320ms, stroke-opacity 320ms;
}

html[data-page="home"] .contact .mail__arrow {
  font-family: var(--f-mono);
  font-size: clamp(1.25rem, 2.2vw, 2.25rem);
  line-height: 1;
  color: var(--fg-3);
  transition: transform 520ms var(--ease-settle), color 320ms;
}

html[data-page="home"] .contact .mail:is(:hover, :focus-visible) .ch {
  color: var(--firefly);
}

html[data-page="home"] .contact .mail:is(:hover, :focus-visible) .mail__string path {
  stroke: var(--firefly);
  stroke-opacity: 0.9;
}

/* The arrow lifts inside the row's padding, clear of the focus ring. */
html[data-page="home"] .contact .mail:is(:hover, :focus-visible) .mail__arrow {
  transform: translate(4px, -4px);
  color: var(--firefly);
}

html[data-page="home"] .contact.is-ringing .mail__addr .ch {
  will-change: transform;
}

/* --- The keyboard strip: two octaves drawn in light --------------------------------
   15 white keys as hairlines (full height at E|F and B|C, below the black keys
   elsewhere), 10 black keys lit from the front with a bright lip. The marker
   sits at A + 69% of the way from A to B♭: x = 5.845 white keys, inside the
   B♭ key (5.7 … 6.3), so a crack is cut through that key for its light. */
html[data-page="home"] .contact .keys {
  --keys: 15;
  --oct: 2;
  --wk: calc(100% / var(--keys));
  --black-h: 62%;
  --at: calc(var(--wk) * 5.845);
  --key-line: rgb(247 241 243 / 0.3);
  position: relative;
  height: var(--keys-h);
  margin-top: clamp(72px, 9vw, 150px);
  pointer-events: none;
  user-select: none;
}

html[data-page="home"] .contact .keys__bed {
  position: absolute;
  inset: 0;
  border-top: 1px solid rgb(247 241 243 / 0.36);
  border-bottom: 1px solid rgb(247 241 243 / 0.2);
  background:
    /* B|C and E|F: full-height seams, one tile per octave */
    linear-gradient(90deg, var(--key-line) 0 1px, transparent 1px calc(300% / 7), var(--key-line) calc(300% / 7) calc(300% / 7 + 1px), transparent calc(300% / 7 + 1px)) 0 0 / calc(100% * 7 / var(--keys)) 100% repeat-x,
    /* every white-key seam, below the black keys */
    repeating-linear-gradient(90deg, var(--key-line) 0 1px, transparent 1px var(--wk)) 0 100% / 100% calc(100% - var(--black-h)) no-repeat,
    /* the white keys catch moonlight towards the front */
    linear-gradient(180deg, rgb(247 241 243 / 0) 34%, rgb(247 241 243 / 0.05) calc(100% - 3px), rgb(247 241 243 / 0.1) calc(100% - 3px));
}

/* Black keys: C♯ D♯ · F♯ G♯ A♯ per octave, centred on the seams, 0.6 key wide.
   Drawn as light through a key-shaped mask: dim at the back, brighter towards
   the front, with a bright lip where the moonlight catches the edge. */
html[data-page="home"] .contact .keys__bed::before {
  --keymask: linear-gradient(
    90deg,
    transparent 10%,
    #000 10% 18.571%,
    transparent 18.571% 24.286%,
    #000 24.286% 32.857%,
    transparent 32.857% 52.857%,
    #000 52.857% 61.429%,
    transparent 61.429% 67.143%,
    #000 67.143% 75.714%,
    transparent 75.714% 81.429%,
    #000 81.429% 90%,
    transparent 90%
  );
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  right: var(--wk);
  height: var(--black-h);
  background: linear-gradient(
    180deg,
    rgb(247 241 243 / 0.035) 0,
    rgb(247 241 243 / 0.1) calc(100% - 3px),
    rgb(247 241 243 / 0.46) calc(100% - 3px) calc(100% - 1px),
    rgb(247 241 243 / 0.12) calc(100% - 1px)
  );
  -webkit-mask: var(--keymask) 0 0 / calc(100% / var(--oct)) 100% repeat-x;
  mask: var(--keymask) 0 0 / calc(100% / var(--oct)) 100% repeat-x;
}

/* B♭, the key the note hides in: a faint gold wash once the firefly lands. */
html[data-page="home"] .contact .keys__bb {
  position: absolute;
  left: calc(var(--wk) * 5.7);
  top: 0;
  width: calc(var(--wk) * 0.6);
  height: var(--black-h);
  background: linear-gradient(180deg, rgb(233 196 82 / 0.03), rgb(233 196 82 / 0.16) calc(100% - 3px), rgb(233 196 82 / 0.6) calc(100% - 3px) calc(100% - 1px), transparent calc(100% - 1px));
  opacity: 0;
  transition: opacity 1400ms var(--ease-settle) 700ms;
}

/* The crack: a slit of night through B♭ at −31¢, its edges catching the light. */
html[data-page="home"] .contact .keys__crack {
  position: absolute;
  left: calc(var(--at) - 2px);
  top: 1px;
  width: 5px;
  height: calc(var(--black-h) - 1px);
  background: var(--night, #141842);
  box-shadow:
    inset 1px 0 rgb(233 196 82 / 0.22),
    inset -1px 0 rgb(233 196 82 / 0.22);
  transition: box-shadow 1200ms var(--ease-settle) 600ms;
}

html[data-page="home"] .contact.is-tuned .keys__bb {
  opacity: 1;
}

html[data-page="home"] .contact.is-tuned .keys__crack {
  box-shadow:
    inset 1px 0 rgb(233 196 82 / 0.55),
    inset -1px 0 rgb(233 196 82 / 0.55),
    0 0 12px rgb(233 196 82 / 0.18);
}

/* The pool of firefly light on A below the crack. */
html[data-page="home"] .contact .keys__glow {
  position: absolute;
  left: var(--at);
  top: 0;
  width: calc(var(--wk) * 3.4);
  height: 100%;
  translate: -50% 0;
  /* The arrival overshoot grows down and out from the key line, never above it. */
  transform-origin: 50% 0;
  background: radial-gradient(50% 78% at 50% 0%, rgb(233 196 82 / 0.3), rgb(233 196 82 / 0.08) 55%, transparent 100%);
  opacity: 0;
  transition: opacity 1600ms var(--ease-settle) 900ms;
}

html[data-page="home"] .contact.is-tuned .keys__glow {
  opacity: 1;
}

/* A → B♭ on the top edge, lit in firefly: the semitone the note hides in. */
html[data-page="home"] .contact .keys__span {
  position: absolute;
  left: calc(var(--wk) * 5.5);
  width: calc(var(--wk) * 0.5);
  top: -1px;
  height: 7px;
  border: 1px solid rgb(233 196 82 / 0.55);
  border-bottom: 0;
  opacity: 0;
  transition: opacity 900ms var(--ease-settle) 700ms;
}

html[data-page="home"] .contact.is-tuned .keys__span {
  opacity: 1;
}

html[data-page="home"] .contact .keys__note {
  position: absolute;
  font-family: var(--f-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1;
  color: var(--fg-3);
  translate: -50% 0;
}

html[data-page="home"] .contact .keys__note--a {
  left: calc(var(--wk) * 5.5);
  bottom: 14px;
}

html[data-page="home"] .contact .keys__note--bb {
  left: calc(var(--wk) * 6.08);
  top: calc(var(--black-h) - 24px);
}

/* The marker: a 10 px firefly on the top edge, its light falling into the crack. */
html[data-page="home"] .contact .keys__marker {
  position: absolute;
  left: var(--at);
  top: 0;
  width: 0;
  height: 100%;
  z-index: 1;
}

html[data-page="home"] .contact .keys__dot {
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--firefly);
  box-shadow:
    0 0 0 3px rgb(20 24 66 / 0.9),
    0 0 14px 3px rgb(233 196 82 / 0.75),
    0 0 46px 12px rgb(233 196 82 / 0.28);
}

/* The ripple of its arrival (only drawn on first entry with motion). */
html[data-page="home"] .contact .keys__dot::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid rgb(233 196 82 / 0.8);
  border-radius: 50%;
  opacity: 0;
}

/* Down through the crack: the thread of light. Up: the trail it fell along. */
html[data-page="home"] .contact .keys__thread {
  position: absolute;
  left: 0;
  top: -84px;
  width: 1px;
  height: calc(84px + var(--black-h) + 12%);
  background: linear-gradient(
    180deg,
    rgb(233 196 82 / 0) 0,
    rgb(233 196 82 / 0.42) calc(84px - 8px),
    rgb(233 196 82 / 0.9) 84px,
    rgb(233 196 82 / 0.7) calc(100% - 12%),
    rgb(233 196 82 / 0) 100%
  );
}

html[data-page="home"] .contact .keys__cap {
  position: absolute;
  left: 12px;
  top: -30px;
  font-family: var(--f-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1;
  color: var(--firefly);
  white-space: nowrap;
}

/* First entry: the firefly drifts down 60 px into the crack (contact.js arms it),
   flares as it lands and sends one ripple across the keys; then all of it settles
   to the calm rest state above. */
html[data-page="home"] .contact.is-armed .keys__marker {
  translate: 0 -60px;
  opacity: 0;
}

html[data-page="home"] .contact.is-armed.is-tuned .keys__marker {
  translate: 0 0;
  opacity: 1;
  transition:
    translate 1200ms var(--ease-settle),
    opacity 520ms var(--ease-settle);
}

html[data-page="home"] .contact.is-armed.is-tuned .keys__dot {
  animation: contact-flare 1700ms var(--ease-settle) 620ms both;
}

html[data-page="home"] .contact.is-armed.is-tuned .keys__dot::after {
  animation: contact-ripple 1600ms cubic-bezier(0.2, 0.7, 0.3, 1) 680ms forwards;
}

html[data-page="home"] .contact.is-armed.is-tuned .keys__glow {
  animation: contact-pool 2400ms var(--ease-settle) 640ms both;
}

@keyframes contact-flare {
  0% {
    box-shadow:
      0 0 0 3px rgb(20 24 66 / 0.9),
      0 0 14px 3px rgb(233 196 82 / 0.75),
      0 0 46px 12px rgb(233 196 82 / 0.28);
  }
  22% {
    box-shadow:
      0 0 0 3px rgb(20 24 66 / 0.9),
      0 0 34px 12px rgb(233 196 82 / 0.95),
      0 0 120px 46px rgb(233 196 82 / 0.5);
  }
  100% {
    box-shadow:
      0 0 0 3px rgb(20 24 66 / 0.9),
      0 0 14px 3px rgb(233 196 82 / 0.75),
      0 0 46px 12px rgb(233 196 82 / 0.28);
  }
}

/* A flat ellipse lying on the keys, like a ring on water seen at an angle;
   the inset grows (not a scale) so the line stays one pixel. */
@keyframes contact-ripple {
  0% {
    opacity: 0.95;
    inset: -1px;
  }
  100% {
    opacity: 0;
    inset: -44px -150px;
  }
}

@keyframes contact-pool {
  0% {
    opacity: 0;
    scale: 0.5 0.7;
  }
  30% {
    opacity: 1;
    scale: 1.45 1.15;
  }
  100% {
    opacity: 1;
    scale: 1 1;
  }
}

/* --- Tablet and phone ------------------------------------------------------------- */
@media (max-width: 900px) {
  html[data-page="home"] .contact .contact__title {
    grid-column: 1 / -1;
  }
  html[data-page="home"] .contact .contact__body {
    grid-column: 1 / -1;
  }
  html[data-page="home"] .contact .room {
    top: calc(var(--band) + 8px);
  }
}

@media (max-width: 600px) {
  /* Three node lines on phones: 2/7, 4/7, 6/7 (nth-of-type counts the caption
     span first, so the even ones are k = 1, 3, 5). */
  html[data-page="home"] .contact .contact__node:nth-of-type(even) {
    display: none;
  }
  html[data-page="home"] .contact .nodes__cap {
    left: calc(200% / 7 + 8px);
  }
  /* The numeral moves down behind the title, clear of the caption and the head. */
  html[data-page="home"] .contact .room {
    top: calc(var(--band) + 104px);
  }
  html[data-page="home"][lang="ja-JP"] .contact .contact__title {
    font-size: clamp(1.5rem, 7.4vw, 1.875rem);
  }
  html[data-page="home"] .contact .mail {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "index arrow"
      "addr addr";
    row-gap: 10px;
    padding-block: 20px 26px;
  }
  html[data-page="home"] .contact .mail__index {
    grid-area: index;
    padding-top: 0;
    align-self: center;
  }
  html[data-page="home"] .contact .mail__arrow {
    grid-area: arrow;
    font-size: 1.25rem;
  }
  html[data-page="home"] .contact .mail__addr {
    --wdth: 90;
    grid-area: addr;
    font-size: clamp(1.25rem, 6.6vw, 1.875rem);
    font-stretch: 90%;
    letter-spacing: -0.015em;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  html[data-page="home"] .contact .mail__string {
    bottom: -0.42em;
  }
  html[data-page="home"] .contact {
    --keys-h: 112px;
  }
  html[data-page="home"] .contact .keys {
    --keys: 8;
    --oct: 1;
  }
}

/* --- Reduced motion and the low tier: letters still, marker in place, all lit ----- */
@media (prefers-reduced-motion: reduce) {
  html[data-page="home"] .contact .contact__node {
    opacity: 0.18;
    transition: none;
  }
  html[data-page="home"] .contact .keys__marker {
    translate: none !important;
    opacity: 1 !important;
  }
  html[data-page="home"] .contact :is(.keys__glow, .keys__span, .keys__bb) {
    opacity: 1;
  }
  html[data-page="home"] .contact :is(.keys__dot, .keys__glow),
  html[data-page="home"] .contact .keys__dot::after {
    animation: none !important;
  }
  /* The flat string under each address is its underline: it lights on hover. */
  html[data-page="home"] .contact .mail:is(:hover, :focus-visible) .mail__string path {
    stroke-width: 2px;
  }
  html[data-page="home"] .contact .mail:is(:hover, :focus-visible) .mail__arrow {
    transform: none;
  }
}

html[data-page="home"][data-tier="low"] .contact .contact__node {
  opacity: 0.18;
  transition: none;
}

html[data-page="home"][data-tier="low"] .contact :is(.keys__glow, .keys__span, .keys__bb) {
  opacity: 1;
  transition: none;
}

html[data-page="home"][data-tier="low"] .contact :is(.keys__dot, .keys__glow),
html[data-page="home"][data-tier="low"] .contact .keys__dot::after {
  animation: none;
}
