/* The services card of a made-up brand studio with a Heart or Reason switch that calls for a touch with a spring.
   The tone colours below are the two ends; script.js mixes them live on the card (--bg, --ink, --muted, --accent,
   --line, --cta-ink) and works out the contrast of the button while they move. */
:root {
  --page: #e9e6e1;          /* the page, the warm paper of the site */
  --page-deep: #dcd8d1;     /* the edge of the page light */
  --bg: #f7ebe2;            /* the card (set by the script) */
  --ink: #2a1610;           /* the words (set by the script) */
  --muted: #8a6455;         /* the small words (set by the script) */
  --accent: #e2643c;        /* the tone colour, button and glow (set by the script) */
  --line: rgba(42, 22, 16, 0.12); /* hairlines (set by the script) */
  --cta-ink: #2a1610;       /* the words on the button, black or white by contrast (set by the script) */
  --knob: #fffdfb;          /* the knob of the switch */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: radial-gradient(120% 90% at 50% 40%, var(--page) 55%, var(--page-deep));
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 28px) 12px;
  overflow: hidden;
}

/* a soft pool of the tone colour under the card */
.stage::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(760px, 120vw);
  height: min(560px, 90vh);
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 16%, transparent), transparent);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the card */
.card {
  position: relative;
  width: min(480px, 92vw);
  padding: clamp(12px, 3.2vh, 24px) clamp(12px, 4vw, 24px) clamp(12px, 3vh, 22px);
  border-radius: clamp(16px, 3.4vh, 24px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 38%),
    var(--bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5),
    0 0 0 1px var(--line),
    0 1px 2px rgba(30, 20, 16, 0.06),
    0 8px 18px -6px rgba(30, 20, 16, 0.12),
    0 36px 70px -28px rgba(30, 20, 16, 0.32);
  isolation: isolate;
  opacity: 0;
}

.card__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .45 0 0 0 0 .42 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: -1;
}

/* ---------------------------------------------------------------- the head: mark and switch */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(12px, 3.2vh, 14px);
  font-weight: 600;
  font-variation-settings: 'wdth' 108;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.mark__sign {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.mark__arc {
  stroke: var(--accent);
}

.toggle {
  position: relative;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* the glow that breathes around the switch: from 40 to 50 px in 3 s, as on the site */
.toggle__halo {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 40px 0 color-mix(in srgb, var(--accent) 55%, transparent);
  animation: respiro 3s ease-in-out infinite alternate;
}

@keyframes respiro {
  to {
    box-shadow: 0 0 50px 5px color-mix(in srgb, var(--accent) 55%, transparent);
  }
}

.toggle__track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: clamp(150px, 44vw, 184px);
  height: clamp(32px, 8.6vh, 38px);
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 9%, var(--bg));
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.14),
    inset 0 0 8px 3px rgba(0, 0, 0, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.85);
}

.toggle__knob {
  position: absolute;
  left: 3px;
  top: 3px;
  bottom: 3px;
  width: calc(50% - 3px);
  will-change: transform;
}

.toggle__face {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, var(--knob) 55%, #f3efea);
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(0, 0, 0, 0.05),
    0 0 0 0.5px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.12),
    0 4px 10px -2px rgba(0, 0, 0, 0.14);
  transition: box-shadow 0.25s ease;
}

.toggle.is-pressed .toggle__face {
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(0, 0, 0, 0.05),
    0 0 0 0.5px rgba(0, 0, 0, 0.1),
    0 1px 1px rgba(0, 0, 0, 0.16),
    0 2px 4px -2px rgba(0, 0, 0, 0.12);
}

.toggle__label {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: clamp(12px, 3.3vh, 13.5px);
  font-weight: 480;
  font-variation-settings: 'wdth' 96;
  color: var(--muted);
  transition: font-variation-settings 0.5s cubic-bezier(0.215, 0.61, 0.355, 1), font-weight 0.5s, color 0.4s;
  user-select: none;
}

.toggle__label.is-on {
  font-weight: 620;
  font-variation-settings: 'wdth' 112;
  color: var(--ink);
}

/* ---------------------------------------------------------------- the photo */
.photo {
  position: relative;
  margin: clamp(10px, 2.8vh, 18px) 0 0;
  height: clamp(70px, 21vh, 176px);
  border-radius: clamp(10px, 2.2vh, 14px);
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 12%, var(--bg));
  box-shadow: 0 0 0 1px var(--line), 0 10px 22px -16px rgba(30, 20, 16, 0.5);
  isolation: isolate;
}

.photo__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  visibility: hidden;
}

.photo__img[data-img='0'] {
  object-position: 50% 46%;
}

.photo__img[data-img='1'] {
  object-position: 50% 38%;
}

.photo__img.is-on {
  visibility: visible;
}

/* a thin light on the top edge of the photo */
.photo::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.28));
  pointer-events: none;
  z-index: 3;
}

.photo__case {
  position: absolute;
  overflow: clip;
  padding: 0 4px 2px 0;
  left: clamp(8px, 2vh, 12px);
  bottom: clamp(7px, 1.8vh, 11px);
  z-index: 4;
  font-size: 11px;
  font-weight: 560;
  font-variation-settings: 'wdth' 104;
  color: #ffffff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

/* the glass chip with the contrast worked out live */
.ratio {
  position: absolute;
  right: clamp(6px, 1.6vh, 10px);
  top: clamp(6px, 1.6vh, 10px);
  z-index: 4;
  width: 138px;
  padding: 6px 8px 7px;
  border-radius: 10px;
  color: #1a1512;
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: blur(8px) saturate(1.3);
  backdrop-filter: blur(8px) saturate(1.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.35), 0 6px 14px -8px rgba(0, 0, 0, 0.35);
}

.ratio__head {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
}

.ratio__name {
  flex: 1;
  color: rgba(26, 21, 18, 0.62);
  font-variation-settings: 'wdth' 92;
}

.ratio__value {
  font-weight: 640;
  font-variation-settings: 'wdth' 100;
}

.ratio__grade {
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 680;
  letter-spacing: 0.02em;
  color: #ffffff;
  background: #1a1512;
}

.ratio__track {
  position: relative;
  display: block;
  height: 3px;
  margin-top: 6px;
  border-radius: 3px;
  background:
    linear-gradient(90deg, transparent calc(10% - 0.5px), rgba(26, 21, 18, 0.45) 0 calc(10% + 0.5px), transparent 0) 0 0 / 100% 100% no-repeat,
    linear-gradient(90deg, transparent calc(17.5% - 0.5px), rgba(26, 21, 18, 0.45) 0 calc(17.5% + 0.5px), transparent 0) 0 0 / 100% 100% no-repeat,
    linear-gradient(90deg, transparent calc(30% - 0.5px), rgba(26, 21, 18, 0.45) 0 calc(30% + 0.5px), transparent 0) 0 0 / 100% 100% no-repeat,
    rgba(26, 21, 18, 0.14);
}

.ratio__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
}

.ratio__pin {
  position: absolute;
  top: 50%;
  left: 0;
  width: 2px;
  height: 9px;
  margin: -4.5px 0 0 -1px;
  border-radius: 1px;
  background: #1a1512;
}

/* ---------------------------------------------------------------- swaps (stacked in one cell) */
.swap,
.title,
.rows {
  display: grid;
}

.swap > *,
.title > *,
.rows > * {
  grid-area: 1 / 1;
}

.swap__item,
.title__set,
.rows__set {
  visibility: hidden;
}

.swap__item.is-on,
.title__set.is-on,
.rows__set.is-on {
  visibility: visible;
}

/* ---------------------------------------------------------------- the title */
.title {
  margin-top: clamp(10px, 2.8vh, 20px);
}

.title__set {
  margin: 0;
  font-size: clamp(19px, min(6.2vw, 5.6vh), 31px);
  line-height: 1.06;
  letter-spacing: -0.015em;
}

.title__set--heart {
  font-family: 'Newsreader Variable', Georgia, serif;
  font-style: italic;
  font-weight: 420;
  font-size: clamp(21px, min(6.8vw, 6.1vh), 34px);
  line-height: 1;
}

.title__set--reason {
  font-weight: 600;
  font-variation-settings: 'wdth' 112;
  letter-spacing: -0.025em;
}

.mask {
  display: block;
  overflow: clip;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.line {
  display: block;
  will-change: transform;
}

/* ---------------------------------------------------------------- the services */
.rows {
  margin-top: clamp(6px, 2vh, 14px);
}

.rows__set {
  margin: 0;
  padding: 0;
  list-style: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 9px;
  height: clamp(24px, 6.6vh, 38px);
  border-top: 1px solid var(--line);
  font-size: clamp(12px, 3.4vh, 14px);
  font-variation-settings: 'wdth' 100;
}

.row__tick {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row__name {
  flex: 1;
  font-weight: 520;
  white-space: nowrap;
}

.row__time {
  color: var(--muted);
  font-size: 0.88em;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the foot: fee and button */
.foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: clamp(8px, 2.4vh, 16px);
  padding-top: clamp(8px, 2.4vh, 16px);
  border-top: 1px solid var(--line);
}

.fee {
  margin: 0;
  display: grid;
  gap: 2px;
}

.fee__label {
  font-size: 11px;
  color: var(--muted);
  font-variation-settings: 'wdth' 96;
  white-space: nowrap;
}

.fee__value {
  display: flex;
  align-items: baseline;
  font-size: clamp(16px, 4.8vh, 22px);
  font-weight: 640;
  font-variation-settings: 'wdth' 100;
  letter-spacing: -0.01em;
  line-height: 1.1;
  white-space: nowrap;
}

.fee__small {
  font-size: 0.62em;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

/* a digit reel: two runs of 0 to 9 stacked, only one row seen */
.reel {
  position: relative;
  display: inline-block;
  height: 1.1em;
  overflow: clip;
  vertical-align: bottom;
  text-align: center;
}

.reel__col {
  display: block;
  will-change: transform;
}

.reel__col > span {
  display: block;
  height: 1.1em;
}

.cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  height: clamp(32px, 8.6vh, 40px);
  padding: 0 clamp(12px, 3.6vw, 16px);
  border-radius: 999px;
  color: var(--cta-ink);
  text-decoration: none;
  font-size: clamp(12px, 3.4vh, 13.5px);
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.cta__bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%),
    var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.14),
    0 8px 18px -8px color-mix(in srgb, var(--accent) 80%, transparent);
  z-index: -1;
}

.cta__words,
.cta__arrow {
  position: relative;
}

.cta__arrow {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .cta:hover .cta__arrow {
    transform: translateX(2px);
  }

  .cta__arrow {
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

@media (max-width: 360px) {
  .ratio {
    width: 118px;
  }

  .ratio__name {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toggle__halo {
    animation: none;
  }
}
