/* "Crafting a haptic design system" case study.
   Everything shared with the MX Master 4 page (title, cover, chapter bar,
   section intros, cards, dark strips, caption styles, bottom bar) comes
   from case-study.css. This file only adds the blocks that are new on
   this page. Sizes come from the Figma frame (1280px wide). */

/* ---------- Role diagram ---------- */

.hs-role {
  margin: -30px 0 0; /* 10px under the intro, like the other intros */
  display: flex;
  justify-content: center;
}

/* Drawn in code (SVG), so it stays sharp at any size. */
.hs-role__svg {
  width: 100%;
  max-width: 650px;
  height: auto;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
}

/* ---------- Visual + side caption (atomic system, use cases) ---------- */

.hs-split {
  display: grid;
  grid-template-columns: auto minmax(0, 380px);
  justify-content: start; /* visual first, caption right next to it */
  gap: 30px;
  align-items: start;
  margin-top: -30px;
}

/* A caption that sits on its own (not under an image). Same hierarchy
   as every other caption: orange 12px title, then 16px text. */
.hs-aside,
.hs-caption {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 16px;
  line-height: normal;
  letter-spacing: -0.01em;
  max-width: 380px;
  margin: 0;
}

.hs-caption {
  margin-top: 10px;
}

/* Atoms, molecules, organisms */
.hs-atoms {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 196px));
  gap: 8px;
}

.hs-atoms figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hs-atoms img {
  width: 100%;
  height: auto;
  aspect-ratio: 196 / 299;
}

.hs-atoms figcaption {
  color: var(--color-text);
}

/* Four use cases on a grey panel */
.hs-usecases {
  display: grid;
  grid-template-columns: repeat(2, 236px);
  gap: 28px 28px;
  padding: 36px;
  background: #e6e6e6;
}

.hs-usecases figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hs-usecases img {
  width: 100%;
  height: auto;
}

.hs-usecases figcaption {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 16px;
  line-height: normal;
  letter-spacing: -0.01em;
}

.hs-usecases figcaption .small-title {
  display: block;
  margin-bottom: 7px;
  color: var(--color-text);
}

/* Hovering a use case dims the screenshot but keeps its green haptic
   marks (circles, attention lines) at full brightness, so the eye goes
   straight to them. The marks are a separate transparent layer on top. */
.hs-uc-media {
  position: relative;
  width: 100%;
  aspect-ratio: 189 / 172;
}

.hs-uc-media img {
  display: block;
}

.hs-uc-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hs-uc-media > img:first-child {
  transition: filter 0.3s ease;
}

.hs-usecases figure:hover .hs-uc-media > img:first-child {
  filter: brightness(0.3) saturate(0.6);
}

@media (prefers-reduced-motion: reduce) {
  .hs-uc-media > img:first-child { transition: none; }
}

/* ---------- Waveform library (black box) ---------- */

.hs-library {
  margin: -30px 0 0;
}

.hs-library__box {
  background: #000000;
  padding: 130px 20px;
  display: flex;
  justify-content: center;
}

.wave-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 152px);
  gap: 3px 3.94px;
}

.wave-grid li {
  height: 76px;
  background: #ececec;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wave-grid img {
  width: 152px;
  height: 46px;
}

.wave-grid .small-title {
  margin-top: 2px;
  font-size: 11.8px;
  text-align: center;
  color: var(--color-text);
}

/* ---------- Waveforms with an example video ----------
   Tiles with a small play mark have a real example. On hover (or tap)
   the tile grows to 2.5x, above its neighbours, and plays the clip;
   when the cursor leaves it shrinks back to the waveform and its name. */
.wave-grid li {
  position: relative;
}

.wave-grid li.has-video {
  cursor: pointer;
}

/* the little play mark in the corner */
.wave-grid__play {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--color-signal);
}

/* Magnifier lens: hovering a waveform with a clip opens a round lens
   over it (like zooming into text on an iPhone). The rest of the library
   blurs and fades behind it, and the clip fills the circle. Moving to
   another waveform glides the lens there. */
.hs-library__box {
  position: relative;
  overflow: hidden;
}

.wave-grid {
  transition: filter 0.35s ease, opacity 0.35s ease;
}

.hs-library__box.is-zoomed .wave-grid {
  filter: blur(2.5px);
  opacity: 0.6;
}

.hs-lens {
  --lens: min(260px, 70vw);
  position: absolute;
  left: 0;
  top: 0;
  width: var(--lens);
  height: var(--lens);
  margin: calc(var(--lens) / -2) 0 0 calc(var(--lens) / -2); /* centred on its point */
  border-radius: 50%;
  overflow: hidden;
  border: 6px solid #ffffff;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: scale(0.3);
  transition:
    opacity 0.25s ease,
    transform 0.4s cubic-bezier(0.2, 0.9, 0.25, 1.1),
    left 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    top 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
  z-index: 5;
}

.hs-library__box.is-zoomed .hs-lens {
  opacity: 1;
  transform: scale(1);
}

.hs-lens video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* fills the circle, no black bands */
}

/* the waveform's name, on a small pill at the bottom of the lens */
.hs-lens__label {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 20px;
  background: #ffffff;
  color: var(--color-text);
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
}

.wave-grid li.has-video:focus-visible {
  outline: 2px solid var(--color-signal);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .hs-lens, .wave-grid { transition: none; }
}

/* "Engine" sits alone in the middle of the last row. */
.wave-grid__last { grid-column: 3; }

/* Whisper collision: two tiny blue pulses, drawn in CSS. */
.wave-grid__whisper {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding-top: 8px;
}

.wave-grid__whisper i {
  width: 5px;
  height: 8px;
  border-radius: 33px;
  background: #5bb1f5;
}

/* ---------- Design process ---------- */

.hs-process .card img {
  aspect-ratio: 380 / 435;
}

/* ---------- User testing: full-width images ---------- */

.hs-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: -30px;
}

.hs-figure {
  margin: 0;
}

.hs-wide {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1159 / 575;
  object-fit: cover;
}

.hs-wide--matrix {
  aspect-ratio: 1159 / 521;
}

/* ---------- Devices ---------- */

.hs-devices .card img {
  aspect-ratio: 379 / 396;
  border-radius: 20px;
}

/* ---------- White cards inside the partnership strips ---------- */

.hs-card {
  flex: none;
  height: 506px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: #ffffff;
  color: var(--color-text);
  border-radius: 20px;
}

.hs-card--grey {
  background: #ededed;
}

.hs-card__title {
  margin: 0;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 12px;
  line-height: 14px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.hs-card__events {
  width: 989px;
  height: 391px;
  margin-top: auto;
  object-fit: cover;
  object-position: left top;
  border-radius: 12px;
}

.hs-card__video {
  width: 692px;
  height: 391px;
  margin-top: auto;
  object-fit: cover;
  background: #000;
}

/* Four Windows animations in a row, each with a rule and a label. */
.hs-anims {
  list-style: none;
  margin: auto 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 253px);
  gap: 20px;
}

.hs-anims li {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.hs-anims video {
  width: 253px;
  height: 126px;
  object-fit: cover;
  border-bottom: 1px solid var(--color-text);
  padding-bottom: 9px;
  box-sizing: content-box;
}

.hs-anims .small-title {
  color: var(--color-text);
}

.hs-reqs {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.hs-reqs img {
  width: 500px;
  height: auto;
  border-radius: 16px;
}

/* Strip caption with an app icon on its left. */
.strip__caption--icon {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  max-width: none;
}

.strip__caption--icon > img {
  flex: none;
  width: 54px;
  height: auto;
  margin-top: 4px;
}

/* ---------- Design principles: smaller images ----------
   These images are abstract, so the band uses short landscape crops
   instead of the tall portrait ones on the MX Master 4 page. */
.hs-principles .card-row--3 .card img,
.hs-principles .card-row--3 .card video {
  aspect-ratio: 380 / 200;
  object-fit: cover;
  border-radius: 16px;
}

/* Show the lower part of each picture: the ripple origin and the [!]. */
.hs-principles__discretion { object-position: 50% 78%; }
.hs-principles__meaning    { object-position: 50% 76%; }

/* ---------- Atoms → effects reveal ----------
   Hovering the three panels swaps each one for its haptic equivalent
   (Atoms → Effects, Molecules → Waveforms, Organisms → Series), with a
   cross-fade, as in the Figma component. On touch screens it plays by
   itself once the panels are on screen (js/haptic-system.js). */
.hs-atoms__media {
  position: relative;
}

.hs-atoms__reveal {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hs-atoms figcaption {
  display: grid;
}

.hs-atoms__a,
.hs-atoms__b {
  grid-area: 1 / 1;
  transition: opacity 0.4s ease;
}

.hs-atoms__b { opacity: 0; }

.hs-atoms:hover .hs-atoms__reveal,
.hs-atoms:focus-visible .hs-atoms__reveal,
.hs-atoms.is-on .hs-atoms__reveal,
.hs-atoms:hover .hs-atoms__b,
.hs-atoms:focus-visible .hs-atoms__b,
.hs-atoms.is-on .hs-atoms__b { opacity: 1; }

.hs-atoms:hover .hs-atoms__a,
.hs-atoms:focus-visible .hs-atoms__a,
.hs-atoms.is-on .hs-atoms__a { opacity: 0; }

/* the three panels reveal one after the other */
.hs-atoms figure:nth-child(2) .hs-atoms__reveal { transition-delay: 0.08s; }
.hs-atoms figure:nth-child(3) .hs-atoms__reveal { transition-delay: 0.16s; }

.hs-atoms:focus-visible { outline: 2px solid var(--color-signal); outline-offset: 4px; }

/* ---------- Waveform matrix ----------
   Built in code: axes in SVG, waveforms as real text. Hovering colour-
   codes every waveform, as in the Figma component. */
.hs-matrix {
  position: relative;
  /* a dotted canvas, like FigJam, instead of a plain black graph */
  background:
    radial-gradient(circle, #2b2b2b 1px, transparent 1.4px) 0 0 / 22px 22px,
    #000000;
  padding: 24px 20px;
  display: flex;
  justify-content: center;
}

.hs-matrix:focus-visible { outline: 2px solid var(--color-signal); outline-offset: -2px; }

.hs-matrix__stage {
  position: relative;
  width: 100%;
  max-width: 760px; /* keeps the black box about as tall as in Figma */
  aspect-ratio: 617 / 445;
  container-type: inline-size;
}

.hs-matrix__axes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

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

.hs-chip {
  position: absolute;
  /* centred on its spot and tilted a little, like a sticker; the tilt
     doesn't move it, it rotates around its own centre */
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  padding: 0.4em 1.1em;
  border-radius: 55px;
  background: #ffffff;
  color: var(--color-text);
  box-shadow: 0 1px 9px rgba(0, 0, 0, 0.13);
  font-family: var(--font-label);
  /* bigger than in Figma so the labels stay legible on screen; chips are
     centred on their spot, so growing them doesn't move anything */
  font-size: clamp(8px, calc(10 / 617 * 100cqw), 12px);
  line-height: 1.2;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.35s ease;
  transition-delay: calc(var(--i, 0) * 12ms);
}

/* on hover the stickers straighten up as they take their colour */
.hs-matrix:hover .hs-chip,
.hs-matrix:focus-visible .hs-chip,
.hs-matrix.is-on .hs-chip { transform: translate(-50%, -50%); }

.hs-matrix__axis-labels {
  font-family: var(--font-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hs-matrix:hover .hs-chip--p, .hs-matrix:focus-visible .hs-chip--p, .hs-matrix.is-on .hs-chip--p { background: #814efa; color: #ffffff; }
.hs-matrix:hover .hs-chip--l, .hs-matrix:focus-visible .hs-chip--l, .hs-matrix.is-on .hs-chip--l { background: #ab89fd; }
.hs-matrix:hover .hs-chip--c, .hs-matrix:focus-visible .hs-chip--c, .hs-matrix.is-on .hs-chip--c { background: #ff7f6a; }
.hs-matrix:hover .hs-chip--y, .hs-matrix:focus-visible .hs-chip--y, .hs-matrix.is-on .hs-chip--y { background: #ffd850; }

/* Colour legend: appears in the bottom-right corner together with the
   colours (on hover, keyboard focus, or by itself on touch screens).
   Always in the page for screen readers. */
.hs-matrix__legend {
  position: absolute;
  right: 20px;  /* same distance from the right and bottom edges */
  bottom: 20px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 230px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease 0.15s, transform 0.3s ease 0.15s;
  pointer-events: none;
}

.hs-matrix:hover .hs-matrix__legend,
.hs-matrix:focus-visible .hs-matrix__legend,
.hs-matrix.is-on .hs-matrix__legend {
  opacity: 1;
  transform: none;
}

.hs-matrix__legend dt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 10px;
  line-height: 14px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.hs-matrix__legend dd {
  margin: 1px 0 0 22px;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 12px;
  line-height: 1.3;
  color: #cfcfcf;
}

.hs-swatch {
  flex: none;
  width: 16px;
  height: 10px;
  border-radius: 10px;
}

/* light purple = precision enhancers, dark purple = progress indicators */
.hs-swatch--l { background: #ab89fd; }
.hs-swatch--p { background: #814efa; }
.hs-swatch--y { background: #ffd850; }
.hs-swatch--c { background: #ff7f6a; }

/* ---------- Design process: the three steps appear one by one ----------
   js/haptic-system.js adds "will-reveal" and then "is-revealed" when the
   row scrolls into view. Without JavaScript or with reduced motion on,
   they simply show. */
[data-reveal-sequence].will-reveal > * {
  opacity: 0;
  transform: translateY(24px);
}

[data-reveal-sequence].is-revealed > * {
  opacity: 1;
  transform: none;
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-reveal-sequence].is-revealed > :nth-child(2) { transition-delay: 0.35s; }
[data-reveal-sequence].is-revealed > :nth-child(3) { transition-delay: 0.7s; }

@media (prefers-reduced-motion: reduce) {
  .hs-atoms__reveal, .hs-atoms__a, .hs-atoms__b, .hs-chip { transition: none; }
}

/* ---------- Linked pictures (public documentation) ----------
   The image and its orange title both open the live page. On hover the
   image lifts slightly and the title gets an underline. */
.card__link {
  display: block;
  overflow: hidden;
}

.card__link img {
  transition: transform 0.4s ease, opacity 0.3s ease;
}

.card__link:hover img,
.card__link:focus-visible img {
  transform: scale(1.02);
  opacity: 0.9;
}

.card__link-label {
  text-decoration: none;
}

.card:hover .card__link-label,
.card__link-label:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card__link:focus-visible,
.card__link-label:focus-visible {
  outline: 2px solid var(--color-signal);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .card__link img { transition: none; }
}

/* A link inside a paragraph (e.g. the Windows 11 source). */
.hs-inline-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--color-signal);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.hs-inline-link:hover {
  color: var(--color-signal-text);
}

/* ---------- Smaller screens ---------- */

@media (max-width: 1000px) {
  .hs-split {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .hs-usecases {
    padding: 32px;
    grid-template-columns: repeat(2, minmax(0, 189px));
    gap: 24px 24px;
  }
  .hs-uc-media { width: 100%; height: auto; aspect-ratio: 189 / 172; }
  .hs-usecases img { width: 100%; height: auto; aspect-ratio: 189 / 172; }
}

@media (max-width: 860px) {
  .hs-library__box { justify-content: flex-start; padding-block: 60px; overflow-x: auto; }
  .hs-lens { position: fixed; }
}

@media (max-width: 700px) {
  /* on phones the matrix keeps a readable size and scrolls sideways */
  .hs-matrix { overflow-x: auto; justify-content: flex-start; }
  .hs-matrix__stage { min-width: 620px; }
}

@media (max-width: 640px) {
  .hs-library__box { justify-content: center; padding: 40px 12px; }
  .wave-grid { grid-template-columns: repeat(2, 152px); }
  .wave-grid__last { grid-column: auto; }
  .hs-usecases { padding: 20px; gap: 20px 12px; }
  .hs-atoms { gap: 6px; }
}
