/*
 * Product demo visuals
 * ====================
 *
 * Theme-aware HTML/CSS mock-ups of the extension, used on the landing page and
 * /extension/about in place of raster screenshots. A screenshot captured in the
 * light theme sits badly on the dark one, cannot animate, and cannot be read by
 * anything but eyes; these are built from the same design tokens as the rest of
 * the site, so they follow the theme and stay sharp at any density.
 *
 * .wdemo    a browser window reading an article, animated end to end:
 *           point at a marked word -> definition card -> mark it known.
 * .wpanel   the side panel listing every unfamiliar word on the page.
 * .wquiet   the same page after one week, one month and six months.
 *
 * Sizing: everything inside .wdemo is expressed in em from a single clamp()ed
 * font-size driven by container width, so the whole frame scales as one picture
 * and its line breaks never move. Below the compact breakpoint the frame stops
 * scaling and switches composition instead.
 */

/* Browser demo ------------------------------------------------------------ */

.wdemo {
  width: min(100%, 64rem);
  margin-inline: auto;
  container-type: inline-size;
  /* The hero centres its copy; the page inside the frame is a real page. */
  text-align: left;
}

.wdemo__frame {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  font-size: 0.8125rem;
  font-size: clamp(0.6rem, 1.55cqi, 1rem);
}

.wdemo__chrome {
  display: flex;
  padding: 0.6em 0.85em;
  align-items: center;
  gap: 0.75em;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}

.wdemo__dots {
  display: flex;
  flex: none;
  gap: 0.35em;
}

.wdemo__dots span {
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--line);
}

.wdemo__url {
  min-width: 0;
  flex: 1;
  padding: 0.25em 0.7em;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 0.85em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wdemo__viewport {
  position: relative;
  padding: 1.9em 2.2em 2.1em;
}

.wdemo__article {
  max-width: 42em;
  margin-inline: auto;
  color: var(--ink);
}

.wdemo__kicker {
  margin: 0;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.wdemo__headline {
  margin: 0.5em 0 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 2.1em;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.wdemo__byline {
  margin: 0.7em 0 0;
  padding-bottom: 1.1em;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 0.95em;
}

.wdemo__body {
  margin: 1.15em 0 0;
  font-size: 1.15em;
  line-height: 1.62;
}

/* Mirrors how the extension marks an unfamiliar word inside the page. The
   negative margin keeps the mark from claiming inline space, so a word that
   stops being marked does not leave a gap behind. */
.wdemo__w {
  margin: 0 -0.1em;
  padding: 0 0.1em;
  background: var(--accent-soft);
  font-style: normal;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.16em;
}

.wdemo__anchor {
  position: relative;
}

/* The definition card and the pointer both hang off the marked word, so they
   stay attached to it whatever the frame is scaled to. */
.wdemo__card {
  position: absolute;
  z-index: 3;
  top: 1.85em;
  left: -1.1em;
  width: 21em;
  padding: 0.95em 1.05em 1.05em;
  background: var(--panel);
  /* Sits on top of the article, so it needs an edge the page tint cannot
     swallow in either theme. */
  border: 1px solid var(--wordy-border-strong);
  box-shadow: var(--shadow-overlay);
  font-size: 0.8em;
  font-style: normal;
  line-height: 1.5;
  opacity: 0;
  text-align: left;
  text-decoration: none;
}

.wdemo__card-head {
  display: flex;
  padding-bottom: 0.7em;
  align-items: center;
  gap: 0.5em;
  border-bottom: 1px solid var(--line);
}

.wdemo__card-word {
  margin-right: auto;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.5em;
  line-height: 1.1;
}

.wdemo__pill {
  display: inline-flex;
  padding: 0.2em 0.6em;
  align-items: center;
  gap: 0.4em;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--ink);
  font-size: 0.9em;
  font-weight: 600;
}

.wdemo__pill::before {
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.wdemo__play {
  display: grid;
  width: 1.9em;
  height: 1.9em;
  flex: none;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--dim);
  font-size: 0.85em;
}

/* The card lives inside a <p>, so it is built from spans and needs its block
   boxes back. */
.wdemo__def {
  display: block;
  margin: 0.75em 0 0;
  color: var(--ink);
  font-size: 0.95em;
}

.wdemo__def + .wdemo__def {
  color: var(--dim);
}

.wdemo__card-actions {
  display: flex;
  margin-top: 0.95em;
  padding-top: 0.85em;
  gap: 0.4em;
  border-top: 1px solid var(--line);
}

.wdemo__act {
  padding: 0.42em 0.8em;
  background: var(--accent);
  color: oklch(0.18 0.01 80);
  font-size: 0.95em;
  font-weight: 600;
}

/* The counter the extension parks on the edge of the page. */
.wdemo__badge {
  position: absolute;
  z-index: 2;
  top: 7.5em;
  right: 0;
  display: grid;
  padding: 0.5em 0.7em;
  justify-items: center;
  background: var(--accent);
  color: oklch(0.18 0.01 80);
  font-family: var(--font-mono);
  line-height: 1;
}

.wdemo__badge-count {
  display: grid;
  font-size: 1.5em;
  font-weight: 700;
}

.wdemo__badge-count span {
  grid-area: 1 / 1;
}

.wdemo__badge-label {
  margin-top: 0.35em;
  font-size: 0.7em;
  letter-spacing: 0.1em;
}

.wdemo__cursor {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  width: 1.6em;
  height: 1.6em;
  filter: drop-shadow(0 1px 2px oklch(0 0 0 / 0.4));
  opacity: 0;
  pointer-events: none;
  transform: translate(13em, 8.5em);
}

.wdemo__cursor path {
  fill: var(--ink);
  stroke: var(--bg);
  stroke-width: 1.4;
}

/* Animation --------------------------------------------------------------- */

.wdemo__cursor {
  animation: wdemo-cursor 11s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.wdemo__card {
  animation: wdemo-card 11s ease infinite;
}

.wdemo__w--target {
  animation: wdemo-target 11s ease infinite;
}

.wdemo__act--known {
  animation: wdemo-press 11s ease infinite;
}

.wdemo__badge-count span:first-child {
  animation: wdemo-count-out 11s ease infinite;
}

.wdemo__badge-count span:last-child {
  animation: wdemo-count-in 11s ease infinite;
}

/* One loop: point at the marked word (16%), read the card (20-66%), press
   Known (59-62%), watch the mark and the counter drop (66-71%), reset (98%). */
@keyframes wdemo-cursor {
  0%,
  4% {
    opacity: 0;
    transform: translate(13em, 8.5em);
  }
  7% {
    opacity: 1;
    transform: translate(13em, 8.5em);
  }
  16%,
  52% {
    opacity: 1;
    transform: translate(0.9em, 0.75em);
  }
  57%,
  66% {
    opacity: 1;
    transform: translate(1.3em, 10.9em);
  }
  76% {
    opacity: 1;
    transform: translate(13em, 8.5em);
  }
  80%,
  100% {
    opacity: 0;
    transform: translate(13em, 8.5em);
  }
}

@keyframes wdemo-card {
  0%,
  15% {
    opacity: 0;
    transform: translateY(-0.35em) scale(0.98);
  }
  20%,
  66% {
    opacity: 1;
    transform: none;
  }
  70%,
  100% {
    opacity: 0;
    transform: translateY(-0.2em) scale(0.99);
  }
}

@keyframes wdemo-target {
  0%,
  14% {
    background-color: var(--accent-soft);
    text-decoration-color: var(--accent);
  }
  18%,
  66% {
    background-color: color-mix(in oklch, var(--accent) 28%, var(--accent-soft));
    text-decoration-color: var(--accent);
  }
  71%,
  92% {
    background-color: transparent;
    text-decoration-color: transparent;
  }
  98%,
  100% {
    background-color: var(--accent-soft);
    text-decoration-color: var(--accent);
  }
}

@keyframes wdemo-press {
  0%,
  58% {
    background-color: var(--accent);
    transform: none;
  }
  59.5%,
  62% {
    background-color: color-mix(in oklch, var(--accent) 78%, var(--ink));
    transform: scale(0.95);
  }
  64%,
  100% {
    background-color: var(--accent);
    transform: none;
  }
}

@keyframes wdemo-count-out {
  0%,
  66% {
    opacity: 1;
  }
  69%,
  92% {
    opacity: 0;
  }
  98%,
  100% {
    opacity: 1;
  }
}

@keyframes wdemo-count-in {
  0%,
  66% {
    opacity: 0;
  }
  69%,
  92% {
    opacity: 1;
  }
  98%,
  100% {
    opacity: 0;
  }
}

/* Narrow frames ----------------------------------------------------------- */

@container (max-width: 39.99rem) {
  .wdemo__frame {
    font-size: clamp(0.72rem, 3.15cqi, 1rem);
  }

  .wdemo__viewport {
    padding: 1.3em 1.3em 12.5em;
  }

  .wdemo__headline {
    font-size: 1.55em;
  }

  .wdemo__byline,
  .wdemo__body--extra {
    display: none;
  }

  .wdemo__kicker {
    letter-spacing: 0.1em;
  }

  .wdemo__badge {
    top: 5em;
  }

  /* Without a positioned anchor the card resolves against the viewport, which
     is where it fits on a phone: pinned to the bottom, full width. */
  .wdemo__anchor {
    position: static;
  }

  .wdemo__card {
    top: auto;
    right: 1.3em;
    bottom: 1.3em;
    left: 1.3em;
    width: auto;
    font-size: 0.85em;
  }

  .wdemo__cursor {
    display: none;
  }
}

/* Side panel -------------------------------------------------------------- */

.wpanel {
  width: min(100%, 30rem);
  margin-inline: auto;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  font-size: 0.8125rem;
}

.wpanel__bar {
  display: flex;
  padding: 0.7rem 0.85rem;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.wpanel__mark {
  width: 0.55rem;
  height: 0.55rem;
  background: var(--accent);
}

.wpanel__bar i {
  color: var(--dim);
  font-size: 0.8125rem;
}

.wpanel__bar i:first-of-type {
  margin-left: auto;
}

.wpanel__row {
  display: flex;
  padding: 0.5rem 0.85rem;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.wpanel__box {
  display: grid;
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  place-items: center;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-xs);
  color: transparent;
  font-size: 0.75rem;
  line-height: 1;
}

.wpanel__word {
  margin-right: auto;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 0.9375rem;
}

.wpanel__count {
  padding: 0.05rem 0.4rem;
  background: var(--accent-soft);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

.wpanel__row i {
  color: var(--dim);
  font-size: 0.75rem;
}

.wpanel__foot {
  padding: 0.85rem;
  background: var(--panel2);
}

.wpanel__foot-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
}

.wpanel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.wpanel__chip {
  padding: 0.3rem 0.65rem;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
}

.wpanel__box {
  animation: wpanel-tick 9s ease infinite;
}

.wpanel__row:nth-child(2) .wpanel__box {
  animation-delay: 0.2s;
}

.wpanel__row:nth-child(3) .wpanel__box {
  animation-delay: 0.4s;
}

.wpanel__row:nth-child(4) .wpanel__box {
  animation-delay: 0.6s;
}

.wpanel__row:nth-child(5) .wpanel__box {
  animation-delay: 0.8s;
}

.wpanel__row:nth-child(6) .wpanel__box {
  animation-delay: 1s;
}

.wpanel__row:nth-child(7) .wpanel__box {
  animation-delay: 1.2s;
}

.wpanel__row:nth-child(8) .wpanel__box {
  animation-delay: 1.4s;
}

.wpanel__row:nth-child(9) .wpanel__box {
  animation-delay: 1.6s;
}

.wpanel__chip--known {
  animation: wpanel-flash 9s ease infinite;
}

@keyframes wpanel-tick {
  0%,
  6% {
    background: transparent;
    border-color: var(--border-dark);
    color: transparent;
  }
  10%,
  68% {
    background: var(--accent);
    border-color: var(--accent);
    color: oklch(0.18 0.01 80);
  }
  74%,
  100% {
    background: transparent;
    border-color: var(--border-dark);
    color: transparent;
  }
}

@keyframes wpanel-flash {
  0%,
  62% {
    background: var(--accent-soft);
    color: var(--ink);
  }
  67%,
  72% {
    background: var(--accent);
    color: oklch(0.18 0.01 80);
  }
  78%,
  100% {
    background: var(--accent-soft);
    color: var(--ink);
  }
}

/* Quieting page ----------------------------------------------------------- */

.wquiet {
  display: grid;
  padding: 1px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.wquiet__step {
  display: grid;
  margin: 0;
  padding: 1.25rem 1.3rem 1.4rem;
  align-content: start;
  gap: 0.9rem;
  background: var(--panel);
}

.wquiet__label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.wquiet__label::before {
  width: 4px;
  height: 4px;
  background: var(--accent);
  content: "";
}

.wquiet__page {
  margin: 0;
  color: var(--dim);
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  line-height: 1.75;
}

.wquiet__page em {
  padding: 0 0.1em;
  background: var(--accent-soft);
  color: var(--ink);
  font-style: normal;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.16em;
}

.wquiet__note {
  color: var(--ink);
  font-size: 0.8125rem;
}

@media (max-width: 767.98px) {
  .wquiet {
    grid-template-columns: 1fr;
  }
}

/* Account ----------------------------------------------------------------- */

.waccount {
  width: min(100%, 42rem);
  margin-inline: auto;
}

.waccount__sources {
  display: grid;
  margin: 0;
  padding: 1px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  list-style: none;
}

.waccount__sources li {
  display: flex;
  padding: 0.85rem 0.6rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
}

.waccount__sources i {
  color: var(--accent);
  font-size: 1rem;
}

/* A plain tree: a stem under each source, a bar joining them, one drop into
   the account below. */
.waccount__link {
  position: relative;
  height: 2.75rem;
}

.waccount__link::before {
  position: absolute;
  top: 1.25rem;
  right: 16.667%;
  left: 16.667%;
  border-top: 1px solid var(--line);
  content: "";
}

.waccount__link::after {
  position: absolute;
  top: 1.25rem;
  bottom: 0;
  left: 50%;
  border-left: 1px solid var(--line);
  content: "";
}

.waccount__stem {
  position: absolute;
  top: 0;
  height: 1.25rem;
  border-left: 1px solid var(--line);
}

.waccount__stem:nth-child(1) {
  left: 16.667%;
}

.waccount__stem:nth-child(2) {
  left: 50%;
}

.waccount__stem:nth-child(3) {
  left: 83.333%;
}

.waccount__card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.waccount__card-head {
  display: flex;
  padding: 0.8rem 1rem;
  align-items: center;
  gap: 0.55rem;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.waccount__mark {
  width: 0.55rem;
  height: 0.55rem;
  background: var(--accent);
}

.waccount__total {
  margin-left: auto;
  color: var(--accent);
}

.waccount__row {
  display: flex;
  padding: 0.6rem 1rem;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.waccount__row:last-child {
  border-bottom: 0;
}

.waccount__name {
  min-width: 0;
  margin-right: auto;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 0.9375rem;
}

.waccount__delta {
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--known);
  color: var(--known);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

.waccount__delta--flat {
  border-color: var(--line);
  color: var(--dim);
}

.waccount__count {
  min-width: 4ch;
  color: var(--accent);
  font-weight: 700;
  text-align: right;
}

@media (max-width: 575.98px) {
  .waccount__sources {
    grid-template-columns: 1fr;
  }

  .waccount__link {
    height: 1.75rem;
  }

  .waccount__link::before,
  .waccount__stem {
    display: none;
  }

  .waccount__link::after {
    top: 0;
  }
}

/* Motion ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  /* Hold the frame on the moment that explains the product, rather than on
     whatever the last keyframe happens to be. */
  .wdemo__cursor,
  .wdemo__card,
  .wdemo__w--target,
  .wdemo__act--known,
  .wdemo__badge-count span,
  .wpanel__box,
  .wpanel__chip--known {
    animation: none !important;
  }

  .wdemo__card {
    opacity: 1;
  }

  .wdemo__badge-count span:last-child {
    opacity: 0;
  }

  .wpanel__box {
    background: var(--accent);
    border-color: var(--accent);
    color: oklch(0.18 0.01 80);
  }
}
