/* System Generation: the Governance panel. Clicking Governance in the design
   system screenshot opens a light window that plays guidelines being managed,
   added, and deconflicted (home-governance.js sets data-state on each rule).
   Wide: the window fills the design system screenshot on the right (features.png
   at 1024x568, page at 568,59) and clips to that page so the slide-in stays
   inside it. Sizes scale with the picture (--gov-unit is one unit of the
   1024-wide drawing). Narrow: the window replaces the picture and uses real
   pixel sizes. */

.home-media:has(.hf-gov) {
  container-type: inline-size;
}

/* --gov-unit: one unit of the 1024-wide design system screenshot, so the
   window, its corners and the click spot grow and shrink with the picture.
   It is a local scale for this panel only, not a design contract token. The
   panel is a picture of an app, so Grum drift inside it is ignored (see
   "Homepage example animations" in AGENTS.md). */
.hf-gov-clip,
.hf-gov,
.hf-gov-hotspot {
  --gov-unit: calc(100cqw / 1024);
}

/* The row in the screenshot, with a ring that invites the click. */
.hf-gov-hotspot {
  position: absolute;
  left: 61.7%;
  top: 69.2%;
  width: 9.6%;
  height: 3.5%;
  padding: 0;
  border: 0;
  border-radius: calc(var(--gov-unit) * 6);
  background: transparent;
  cursor: pointer;
}

.hf-gov-hotspot::before {
  content: "";
  position: absolute;
  inset: calc(var(--gov-unit) * -4);
  border: 1px solid var(--primary-base);
  border-radius: calc(var(--gov-unit) * 9);
  opacity: 0;
  animation: hf-gov-ping 2.4s ease-out infinite;
}

.hf-gov-hotspot:hover,
.hf-gov-hotspot.is-hover,
.hf-gov-hotspot:focus-visible {
  background: var(--fade-dark-10);
}

/* The pretend cursor. Its top-left corner is the arrow's tip; the script sets
   left/top and the transition glides it there. */
.hf-gov-cursor {
  /* Same picture-scale unit as .hf-gov (see the top of this file); set again
     here because the cursor sits outside the window. */
  --gov-unit: calc(100cqw / 1024);
  position: absolute;
  left: 86%;
  top: 44%;
  z-index: 3;
  width: calc(var(--gov-unit) * 19);
  height: calc(var(--gov-unit) * 23);
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px var(--fade-dark-20));
  transition:
    left 0.9s cubic-bezier(0.45, 0, 0.2, 1),
    top 0.9s cubic-bezier(0.45, 0, 0.2, 1),
    opacity 0.3s;
}

.hf-gov-cursor.is-on {
  opacity: 1;
}

.hf-gov-cursor svg {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.12s;
  transform-origin: 10% 8%;
}

.hf-gov-cursor.is-press svg {
  transform: scale(0.82);
}

.hf-gov-cursor::after {
  content: "";
  position: absolute;
  left: calc(var(--gov-unit) * -12);
  top: calc(var(--gov-unit) * -12);
  width: calc(var(--gov-unit) * 24);
  height: calc(var(--gov-unit) * 24);
  border: 2px solid var(--primary-base);
  border-radius: 50%;
  opacity: 0;
}

.hf-gov-cursor.is-click::after {
  animation: hf-gov-ripple 0.5s ease-out;
}

@keyframes hf-gov-ripple {
  from {
    opacity: 1;
    transform: scale(0.3);
  }
  to {
    opacity: 0;
    transform: scale(1.4);
  }
}

.hf-gov-hotspot:focus-visible {
  outline: 2px solid var(--primary-base);
  outline-offset: 2px;
}

@keyframes hf-gov-ping {
  0% {
    opacity: 0.9;
    transform: scale(0.94);
  }
  70%,
  100% {
    opacity: 0;
    transform: scale(1.12);
  }
}

.hf-gov-more {
  display: none;
  margin-top: var(--corner-medium);
}

/* Clip to the design system screenshot so the window cannot outgrow that page
   while it slides in from the right. */
.hf-gov-clip {
  position: absolute;
  left: calc(568 / 1024 * 100%);
  top: calc(59 / 568 * 100%);
  width: calc(456 / 1024 * 100%);
  height: calc(509 / 568 * 100%);
  overflow: hidden;
  border-radius: calc(var(--gov-unit) * 12) 0 0 0;
  pointer-events: none;
}

/* The window. Fills the clip, so it reads as a page of the screenshot. */
.hf-gov {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--dark);
  border-radius: calc(var(--gov-unit) * 12) 0 0 0;
  background: var(--white);
  color: var(--text-primary);
  font-family: var(--font-body);
  pointer-events: auto;
  animation: hf-gov-open 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.hf-gov[hidden] {
  display: none;
}

/* Slides in from the right of the screenshot, and back out the same way. */
.hf-gov.is-leaving {
  animation: hf-gov-close 0.45s cubic-bezier(0.64, 0, 0.78, 0) forwards;
}

@keyframes hf-gov-open {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hf-gov-close {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.hf-gov-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--gov-unit) * 8);
  padding: calc(var(--gov-unit) * 8) calc(var(--gov-unit) * 14);
  border-bottom: 1px solid var(--dark);
  background: var(--background);
}

.hf-gov-crumb {
  margin: 0;
  color: var(--text-secondary);
  font-size: calc(var(--gov-unit) * 10);
  font-weight: var(--body-small-weight);
  line-height: 1.4;
}

.hf-gov-close {
  display: grid;
  place-items: center;
  width: calc(var(--gov-unit) * 22);
  height: calc(var(--gov-unit) * 22);
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--corner-small);
  background: transparent;
  cursor: pointer;
}

.hf-gov-close img {
  width: calc(var(--gov-unit) * 12);
  height: calc(var(--gov-unit) * 12);
  min-width: 10px;
  min-height: 10px;
}

.hf-gov-close:hover,
.hf-gov-close:focus-visible {
  background: var(--fade-dark-10);
}

.hf-gov-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: calc(var(--gov-unit) * 8);
  min-width: 0;
  min-height: 0;
  padding: calc(var(--gov-unit) * 14);
}

.hf-gov-body > * {
  min-width: 0;
}

.hf-gov h3 {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-headline);
  font-size: calc(var(--gov-unit) * 19);
  font-weight: var(--headline-small-weight);
  line-height: 1.2;
}

.hf-gov-sub {
  margin: 0;
  color: var(--text-secondary);
  font-size: calc(var(--gov-unit) * 10.5);
  font-weight: var(--body-small-weight);
  line-height: 1.4;
}

/* Steps: they follow the animation, and can be clicked to jump. */
.hf-gov-pips {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--gov-unit) * 6);
}

.hf-gov-pip {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--gov-unit) * 5);
  padding: calc(var(--gov-unit) * 3) calc(var(--gov-unit) * 8) calc(var(--gov-unit) * 3) calc(var(--gov-unit) * 4);
  border: 1px solid var(--dark);
  border-radius: var(--corner-full);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: calc(var(--gov-unit) * 9.5);
  font-weight: var(--body-small-weight);
  line-height: 1.3;
  cursor: pointer;
  transition:
    background 0.25s,
    color 0.25s,
    border-color 0.25s;
}

.hf-gov-pip b {
  display: grid;
  place-items: center;
  width: calc(var(--gov-unit) * 14);
  height: calc(var(--gov-unit) * 14);
  min-width: 14px;
  min-height: 14px;
  border-radius: var(--corner-full);
  background: var(--background);
  font-weight: var(--body-small-bold-weight);
}

.hf-gov-pip:focus-visible {
  outline: 2px solid var(--primary-base);
  outline-offset: 2px;
}

.hf-gov-pip.is-current {
  border-color: var(--primary-base);
  background: var(--primary-light);
  color: var(--primary-base);
}

.hf-gov-pip.is-current b {
  background: var(--primary-base);
  color: var(--white);
}

/* The guidelines. */
.hf-gov-rules {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: calc(var(--gov-unit) * 6);
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.hf-gov-rule {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: calc(var(--gov-unit) * 10);
  row-gap: calc(var(--gov-unit) * 2);
  padding: calc(var(--gov-unit) * 8) calc(var(--gov-unit) * 10);
  border: 1px solid var(--dark);
  border-radius: calc(var(--gov-unit) * 8);
  background: var(--white);
  transition:
    background 0.3s,
    border-color 0.3s,
    opacity 0.4s,
    transform 0.4s;
}

.hf-gov-text,
.hf-gov-meta {
  grid-column: 1;
  margin: 0;
}

.hf-gov-text {
  color: var(--text-primary);
  font-size: calc(var(--gov-unit) * 11.5);
  font-weight: var(--body-small-bold-weight);
  line-height: 1.3;
  transition: color 0.3s;
}

.hf-gov-meta {
  color: var(--text-secondary);
  font-family: var(--font-token);
  font-size: calc(var(--gov-unit) * 9);
  font-weight: var(--token-regular-weight);
  line-height: 1.3;
}

.hf-gov-badge {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: calc(var(--gov-unit) * 3) calc(var(--gov-unit) * 8);
  border-radius: var(--corner-full);
  background: var(--green-faded);
  color: var(--text-primary);
  font-size: calc(var(--gov-unit) * 9.5);
  font-weight: var(--body-small-bold-weight);
  line-height: 1.3;
  transition:
    background 0.3s,
    color 0.3s;
}

.hf-gov-rule[data-state="hidden"] {
  opacity: 0;
  transform: translateY(calc(var(--gov-unit) * -8));
  visibility: hidden;
}

.hf-gov-rule[data-state="new"] {
  border-color: var(--primary-base);
  background: var(--primary-light);
}

.hf-gov-rule[data-state="new"] .hf-gov-badge {
  background: var(--primary-base);
  color: var(--white);
}

.hf-gov-rule[data-state="conflict"] {
  border-color: var(--error-base);
  background: var(--error-light);
}

.hf-gov-rule[data-state="conflict"] .hf-gov-badge {
  background: var(--error-base);
  color: var(--white);
}

.hf-gov-rule[data-state="superseded"] {
  background: var(--background);
}

.hf-gov-rule[data-state="superseded"] .hf-gov-text {
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.hf-gov-rule[data-state="superseded"] .hf-gov-badge {
  background: var(--dark);
  color: var(--text-secondary);
}

/* The status line at the bottom. */
.hf-gov-banner {
  margin: auto 0 0;
  padding: calc(var(--gov-unit) * 8) calc(var(--gov-unit) * 10);
  border-radius: calc(var(--gov-unit) * 8);
  background: var(--background);
  color: var(--text-secondary);
  font-size: calc(var(--gov-unit) * 10.5);
  font-weight: var(--body-small-weight);
  line-height: 1.35;
  overflow-wrap: break-word;
  transition:
    background 0.3s,
    color 0.3s;
}

.hf-gov[data-gov-tone="error"] .hf-gov-banner {
  background: var(--error-faded);
  color: var(--error-base);
}

.hf-gov[data-gov-tone="good"] .hf-gov-banner {
  background: var(--green-faded);
  color: var(--text-primary);
}

/* Narrow screens: the drawing is too small to click or read, so the window
   replaces it, with a visible button to open it. */
@media (max-width: 960px) {
  .hf-gov-hotspot,
  .hf-gov-cursor {
    display: none;
  }

  .hf-gov-more {
    display: inline-flex;
  }

  /* The picture is hidden here, so --gov-unit stops scaling and becomes a
     fixed size. 1.15px keeps the window close to its wide-screen look. */
  .hf-gov-clip,
  .hf-gov,
  .hf-gov-hotspot {
    --gov-unit: 1.15px;
  }

  .hf-gov-clip {
    position: static;
    width: 100%;
    height: auto;
    overflow: visible;
    border-radius: 0;
    pointer-events: auto;
  }

  .hf-gov {
    position: static;
    width: 100%;
    height: auto;
    border-radius: calc(var(--gov-unit) * 12);
  }

  .home-media:has(.hf-gov:not([hidden])) {
    height: auto;
    aspect-ratio: auto;
    overflow: visible;
  }

  .home-flow:has(.hf-gov:not([hidden])) {
    width: 100%;
    height: auto;
    aspect-ratio: auto;
  }

  .home-flow:has(.hf-gov:not([hidden])) > svg,
  .home-flow:has(.hf-gov:not([hidden])) > img {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hf-gov,
  .hf-gov-hotspot::before {
    animation: none;
  }

  .hf-gov-cursor {
    display: none;
  }

  .hf-gov-hotspot::before {
    opacity: 0.7;
  }

  .hf-gov-rule,
  .hf-gov-text,
  .hf-gov-badge,
  .hf-gov-banner,
  .hf-gov-pip {
    transition: none;
  }
}
