/* The Knot: CupidRay app teaser, mid-tone direction.
   Ground Dusty Rose #B57B8B (flat). Deep Burgundy #6D1836, Champagne Gold #C8A15A, Warm Ivory #FFF8F0, wine text #2A0712.
   Ojuju, by the Nigerian designer Chisaokwu Joboson, for the headline and the short line; Hanken Grotesk for reading.
   The rope is the hero. */

@font-face {
  font-family: "CR Ojuju";
  src: url("assets/fonts/ojuju-var.woff2") format("woff2");
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "CR Ojuju fallback";
  src: local("Arial Black"), local("Arial");
  size-adjust: 78%;
}

@font-face {
  font-family: "CR Hanken";
  src: url("assets/fonts/hanken-grotesk-var.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
/* A local stand-in, used only while the webfont loads or if it fails. */
@font-face {
  font-family: "CR Hanken fallback";
  src: local("Arial"), local("Helvetica");
  size-adjust: 104%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

:root {
  --rose: #B57B8B;
  --wine: #2A0712;
  --burg: #6D1836;
  --gold: #C8A15A;
  --gold-light: #E9D199;
  --ivory: #FFF8F0;
  --text: "CR Hanken", "CR Hanken fallback", "Segoe UI", Arial, sans-serif;
  --display: "CR Ojuju", "CR Ojuju fallback", "Arial Black", Arial, sans-serif;
  --pad-x: 4vw;
}

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

html {
  background: var(--rose);
  color: var(--wine);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--rose);
  color: var(--wine);
  font: 400 1rem/1.5 var(--text);
  font-kerning: normal;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem var(--pad-x) 1.25rem;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1 1 auto;
}

h1, h2, p, ul { margin: 0; }

/* ---------- headline: the first hero. On phones it stacks over three lines, each filling the width. ---------- */

.top h1 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 0.92;
  color: var(--wine);
}
.ln { display: block; white-space: nowrap; }
.ln-a { font-size: 44vw; }
.ln-b { font-size: 30.5vw; }
.ln-c { font-size: 41vw; }

/* ---------- the knot stage: decorative art, pointer- and finger-driven ---------- */

.stage {
  position: relative;
  height: clamp(15rem, 31svh, 26rem);
  margin: 0 calc(var(--pad-x) * -1);
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.stage.is-grabbing { cursor: grabbing; }

.art {
  position: absolute;
  inset: 0;
  overflow: clip;
  pointer-events: none;
}
.shadow, .gl, .still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.shadow { filter: blur(9px); }
.gl { opacity: 0; transition: opacity 0.35s ease; }
.gl-on .gl { opacity: 1; }
.gl-on .still { visibility: hidden; }

/* ---------- controls: two rope-scale pulls at the knot's outer edges, the status between them ---------- */

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "you them" "mid mid";
  gap: 0.9rem 1.5rem;
  align-items: start;
}
.pull { display: grid; gap: 0.2rem; align-content: start; }
.pull-you { grid-area: you; }
.pull-them { grid-area: them; }
.pull label {
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 1.3;
}

/* The track is a rope: a thick lacquered bar. The thumb is the knot's own end. */
.pull input[type="range"] {
  --p: 96%;
  --fill: var(--burg);
  --empty: #FFF8F0;
  --thumb-hi: #9A4467;
  --thumb: #6D1836;
  --thumb-lo: #3E0C1F;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 46px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: grab;
  touch-action: pan-y;
}
.pull input[type="range"]:active { cursor: grabbing; }
/* The burgundy end pulls outward to the left, so its scale runs from the middle to the left edge. */
.pull-you input[type="range"] { direction: rtl; }
/* Their pull is gold from end to end, like its rope. A fine dark edge keeps the gold readable on the rose. */
.pull-them input[type="range"] {
  --fill: var(--gold);
  --thumb-hi: #F6E6BE;
  --thumb: #C8A15A;
  --thumb-lo: #8A6230;
}

/* Lacquer highlight along the top of the bar, laid over the fill and the empty part alike. */
.pull input[type="range"]::-webkit-slider-runnable-track {
  height: 18px;
  border-radius: 9px;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0) 46%, rgba(42, 7, 18, 0.16) 100%),
    linear-gradient(to right, var(--fill) 0 var(--p), var(--empty) var(--p) 100%);
}
.pull-you input[type="range"]::-webkit-slider-runnable-track {
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0) 46%, rgba(42, 7, 18, 0.16) 100%),
    linear-gradient(to right, var(--empty) 0 calc(100% - var(--p)), var(--fill) calc(100% - var(--p)) 100%);
}
.pull-them input[type="range"]::-webkit-slider-runnable-track { box-shadow: inset 0 0 0 2px var(--wine); }
.pull-them input[type="range"]::-moz-range-track { box-shadow: inset 0 0 0 2px var(--wine); }
.pull-them input[type="range"]::-moz-range-progress { box-shadow: inset 0 0 0 2px var(--wine); }
.pull input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 46px;
  height: 46px;
  margin-top: -14px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, var(--thumb-hi) 0%, var(--thumb) 52%, var(--thumb-lo) 100%);
  border: 3px solid var(--wine);
  box-sizing: border-box;
  box-shadow: inset 0 0 0 5px rgba(255, 248, 240, 0.16);
}
.pull input[type="range"]::-moz-range-track {
  height: 30px;
  border-radius: 15px;
  background: var(--empty);
}
.pull input[type="range"]::-moz-range-progress {
  height: 30px;
  border-radius: 15px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 50%), var(--fill);
}
.pull input[type="range"]::-moz-range-thumb {
  width: 43px;
  height: 43px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, var(--thumb-hi) 0%, var(--thumb) 52%, var(--thumb-lo) 100%);
  border: 3px solid var(--wine);
  box-sizing: border-box;
}

.pull input[type="range"]:focus-visible {
  outline: 3px solid var(--wine);
  outline-offset: 4px;
  border-radius: 4px;
}

.mid {
  grid-area: mid;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  text-align: center;
}
.hint {
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.3;
}
.hint[hidden] { display: none; }
.status {
  min-height: 2.8em;
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.4;
  text-wrap: balance;
  max-width: 30ch;
}

/* ---------- the lower band: one column of text and one row of actions, with the logo on the mauve ---------- */

.lower {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.column {
  display: grid;
  gap: 1rem;
  justify-items: start;
}
.line {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.25rem, 10vw, 3rem);
  line-height: 1;
  text-wrap: balance;
}
.intro {
  max-width: 36ch;
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.5;
  text-wrap: pretty;
}
.nw { white-space: nowrap; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}
.btn, .link {
  font: 700 1.0625rem/1.2 var(--text);
  min-height: 44px;
  padding: 0.7rem 1.25rem;
  border-radius: 0;
  cursor: pointer;
  color: var(--ivory);
  background: var(--wine);
  border: 0;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #3E0C1F; }
.link {
  background: transparent;
  color: var(--wine);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  padding-inline: 0.5rem;
}
.link:hover { text-decoration-thickness: 3px; }

.btn:focus-visible, .link:focus-visible {
  outline: 3px solid var(--wine);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--ivory);
}

/* The logo is the supplied artwork, placed on the ground with clear space and never boxed. */
.logo { display: block; }
.logo img {
  display: block;
  width: min(255px, 100%);
  height: auto;
}
/* Phones and tablets show the logo at the top, on arrival. The desktop poster keeps it in the lower band. */
.logo-low { display: none; }
.logo-top { margin-bottom: 0.7rem; }
.logo-top img { width: 12rem; }

/* ---------- footer: one quiet line over a gold rope ---------- */

.foot {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 1rem;
  font-weight: 500;
}
/* ---------- dialog: a solid burgundy sheet with a smooth gold cord ---------- */

.btn-ivory {
  background: var(--ivory);
  color: var(--wine);
}
.btn-ivory:hover { background: #F2E4D2; }

.sheet {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(46rem, calc(100vw - 2rem));
  height: fit-content;
  border: 0;
  padding: 0;
  background: var(--burg);
  color: var(--ivory);
}
.sheet::backdrop { background: rgba(109, 24, 54, 0.88); }
.sheet[open] { animation: sheet-in 0.28s ease-out both; }
@keyframes sheet-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.sheet .btn-ivory:focus-visible {
  outline-color: var(--gold);
  box-shadow: 0 0 0 3px var(--burg);
}

/* The gold cord runs along the left edge as one smooth lacquered tube, matching the hero. */
.rope {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1.1rem;
  background: linear-gradient(90deg, #5E3E1C 0%, #C8A15A 30%, #F0DBA6 48%, #C8A15A 66%, #8A6230 100%);
}

.sheet-inner {
  display: grid;
  gap: 1.25rem;
  padding: clamp(1.75rem, 4vw, 3rem) clamp(1.5rem, 4vw, 3rem) clamp(1.5rem, 3.5vw, 2.5rem) clamp(2.75rem, 6vw, 4.25rem);
}
.sheet h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.25rem, 5vw, 3.6rem);
  line-height: 1;
  text-wrap: balance;
  color: var(--ivory);
}
.sheet-intro { font-size: 1.125rem; line-height: 1.5; max-width: 40ch; }
.steps {
  list-style: none;
  padding: 0;
  display: grid;
}
.steps li {
  padding: 0.8rem 0;
  border-top: 1px solid rgba(200, 161, 90, 0.65);
  font-size: 1.0625rem;
  line-height: 1.45;
}
.steps li:last-child { border-bottom: 1px solid rgba(200, 161, 90, 0.65); }
.sheet-close {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  line-height: 1.15;
  color: var(--ivory);
}
.sheet-actions { display: flex; justify-content: flex-start; }

/* ---------- phones and tablets: the closing block sits on the page's centre line ---------- */

@media (max-width: 1023.98px) {
  .line { order: -1; }
  .actions { justify-self: stretch; justify-content: center; }
  .actions::before { content: ""; flex-basis: 100%; }
  .actions .link { order: -1; }
  .actions .btn { order: 1; }
  .foot { align-items: center; text-align: center; }
}

/* ---------- phones: the logo, the headline, the ropes, both pulls and the first instruction share the first screen.
   --fixed is everything else on that screen. The headline and the ropes divide what is left of the visible height,
   which is much less than the device height once a phone's browser bars are showing. ---------- */

@media (max-width: 599.98px) {
  :root {
    --fixed: 13.9rem;
    --hs: min(100vw, max(60vw, calc((100svh - var(--fixed)) * 0.6023)));
  }
  body { gap: 1rem; padding-top: 1rem; }
  main { gap: 1rem; }
  .ln-a { font-size: calc(var(--hs) * 0.44); }
  .ln-b { font-size: calc(var(--hs) * 0.305); }
  .ln-c { font-size: calc(var(--hs) * 0.41); }
  .stage { height: clamp(7.75rem, calc(100svh - var(--fixed) - var(--hs) * 1.0626), 26rem); }
}

/* ---------- tablet: a designed portrait composition, 600px to 1023px ---------- */

@media (min-width: 600px) and (max-width: 1023.98px) {
  body { gap: 1.75rem; padding-top: 1.75rem; }
  main { gap: 1.75rem; }
  /* The h1 carries the same size as its spans, so the space between words is set at the headline's own scale. */
  .top h1 { font-size: 17vw; }
  .ln { display: inline; }
  .ln-a, .ln-b { font-size: 17vw; }
  .ln-c { display: block; font-size: 27vw; line-height: 0.9; }
  .stage { height: clamp(18rem, 36svh, 26rem); }
  .controls { grid-template-columns: 1fr 1fr; gap: 1rem 2.5rem; }
  .status { font-size: 1.25rem; max-width: 36ch; }
  .line { font-size: clamp(2.6rem, 9.6vw, 5.2rem); }
  .logo-top img { width: 15rem; }
}

/* ---------- desktop: one composed poster that fills the screen ---------- */

@media (min-width: 1024px) and (min-height: 660px) {
  .logo-top { display: none; }
  .logo-low { display: block; }
  body {
    --pad-x: 3vw;
    gap: 1.25vh;
    padding: 1.3vh var(--pad-x) 1.1vh;
  }
  main {
    gap: 1.9vh;
    min-height: 0;
  }
  .top h1 {
    line-height: 0.96;
    white-space: nowrap;
    font-size: min(12.4vw, 23svh);
  }
  .ln { display: inline; }
  .ln-a, .ln-b, .ln-c { font-size: inherit; }

  .stage {
    flex: 1 1 auto;
    height: auto;
    min-height: clamp(13.5rem, 30vh, 18rem);
    margin-top: 1vh;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr) minmax(15rem, 23rem) minmax(0, 1fr);
    grid-template-areas: "you mid them";
    align-items: center;
    gap: 0 2vw;
  }
  .pull-you { justify-self: start; width: min(100%, 36vw); }
  .pull-them { justify-self: end; width: min(100%, 36vw); }
  .status { font-size: 1.125rem; }

  .lower {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
    gap: 2.5vw;
  }
  .line {
    font-size: clamp(2.5rem, 3.6vw, 4.4rem);
    line-height: 1;
    text-align: right;
    justify-self: end;
    max-width: 11em;
  }
  .column { gap: 1.1vh; }
  .intro { max-width: 46ch; }
  .logo { justify-self: center; }
  .logo img { width: min(255px, 17vw); }

  .foot {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 2vw;
  }
  .foot .f-left, .foot .f-right { flex: 1 1 0; }
  .foot .f-right { text-align: right; }
}

/* Without JavaScript the dialog content reads in place, and the button that opens it is hidden. */
html:not(.js) #open-pre, html:not(.js) .sheet-actions { display: none; }
html:not(.js) .sheet {
  display: block;
  position: relative;
  width: min(46rem, 100%);
  height: auto;
  margin: 2.5rem auto 0;
}
/* Without JavaScript the sliders and their status would do nothing, so the row is hidden. */
html:not(.js) .controls { display: none; }

@media (prefers-reduced-motion: reduce) {
  .gl, .sheet[open] { transition: none; animation: none; }
}

/* Very large screens: reading text grows with the poster */
@media (min-width: 1600px) and (min-height: 900px) {
  html { font-size: 118.75%; }
}
