/* The AI summary card that shortens itself keeping the key phrases: the summary card of Quire, an invented AI reading
   app, in frosted glass on a near black page with two soft lights and a little grain. Every word is a span of its
   own (.w, moved by GSAP); inside it the highlight (.w__hl) and the letters (.w__t) belong to GSAP or CSS, never both
   on the same element. */
:root {
  --page: #0b0b0e;          /* the page */
  --glass: rgba(26, 26, 34, 0.62); /* the body of the card */
  --edge: rgba(255, 255, 255, 0.09); /* its edge at rest */
  --ink: #ececf1;           /* the words */
  --muted: #8b8b98;         /* the small words */
  --faint: #5d5d69;         /* the words that are about to go */
  --accent: #9a8cff;        /* the violet of the AI: highlight, beam, thumb glow */
  --warm: #ffb27a;          /* the warm light behind the card */
  --mint: #7fe0b8;          /* the copied check */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background:
    radial-gradient(60vmax 44vmax at 18% 8%, color-mix(in srgb, var(--warm) 14%, transparent), transparent 70%),
    radial-gradient(56vmax 46vmax at 86% 96%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* the grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

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

/* the card's top is set by the script so that it stays still while the card grows and shrinks below it */
.stage {
  min-height: 100svh;
  max-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  overflow: hidden;
}

.wrap {
  position: relative;
  width: min(90vw, 384px);
  opacity: 0;
}

/* a long soft shadow and a warm glow under the card */
.wrap::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -18px;
  height: 60%;
  border-radius: 40px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 22%, transparent), transparent);
  filter: blur(26px);
  opacity: 0.55;
  pointer-events: none;
}

.card {
  --mx: 30%;
  --my: 0%;
  position: relative;
  border-radius: 22px;
  padding: clamp(14px, 3.6vh, 22px) clamp(14px, 4.6vw, 22px) clamp(12px, 3vh, 18px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 40%),
    var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  backdrop-filter: blur(22px) saturate(1.3);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 12px 24px -10px rgba(0, 0, 0, 0.6),
    0 40px 80px -36px rgba(0, 0, 0, 0.9);
}

/* the rim catches the light where the pointer is: a radial light shown only on the 1px border */
.card__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(180px 140px at var(--mx) var(--my), rgba(255, 255, 255, 0.5), color-mix(in srgb, var(--accent) 40%, transparent) 40%, transparent 72%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
  opacity: 0.7;
}

/* the beam that runs along the top edge while the AI reads */
.card__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.card__beam {
  position: absolute;
  top: 0;
  left: 0;
  width: 46%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 35%, #ffffff 50%, var(--accent) 65%, transparent);
  box-shadow: 0 0 12px 1px color-mix(in srgb, var(--accent) 70%, transparent);
  opacity: 0;
}

.card__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 34%, #1b1b24), #15151c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 6px 14px -6px color-mix(in srgb, var(--accent) 60%, transparent);
}

.card__icon svg {
  width: 20px;
  height: 20px;
  overflow: visible;
}

.card__spark {
  fill: #f2efff;
}

.card__spark--small {
  fill: color-mix(in srgb, var(--accent) 70%, #ffffff);
}

.card__titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.card__title {
  font-size: 15px;
  font-weight: 620;
  font-variation-settings: 'wdth' 106;
  letter-spacing: 0.005em;
}

.card__sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__count {
  margin-left: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 5px 10px 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  flex: none;
}

/* the rolling digits: one column of 0 to 9 for each digit */
.roll {
  display: inline-flex;
  height: 1.2em;
  line-height: 1.2em;
  align-items: flex-start;
  overflow: hidden;
  color: var(--ink);
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}

.roll__col {
  display: flex;
  flex-direction: column;
}

.roll__col span {
  display: block;
  height: 1.2em;
  text-align: center;
}

/* the length switch */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: clamp(12px, 3vh, 18px);
  padding: 3px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.seg__thumb {
  position: absolute;
  top: 3px;
  left: 0;
  height: calc(100% - 6px);
  width: 0;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 4px 12px -4px rgba(0, 0, 0, 0.7),
    0 0 18px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}

.seg__btn {
  position: relative;
  z-index: 1;
  height: clamp(28px, 7vh, 32px);
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.35s ease;
}

.seg__btn[aria-pressed='true'] {
  color: var(--ink);
}

.seg__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 9px;
}

.seg__label {
  display: inline-block;
  font-size: 13px;
  font-weight: 540;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.seg__btn[aria-pressed='true'] .seg__label {
  font-variation-settings: 'wdth' 112;
}

.seg__btn:active .seg__label {
  transform: scale(0.94);
}

@media (hover: hover) {
  .seg__btn:hover {
    color: var(--ink);
  }
}

/* the summary */
.sum {
  position: relative;
  margin-top: clamp(12px, 3vh, 18px);
  overflow: visible;
}

.sum__text {
  position: relative;
  margin: 0;
  font-size: clamp(14px, min(4.1vw, 3.7vh), 16px);
  line-height: 1.58;
  letter-spacing: -0.003em;
  color: var(--ink);
}

.w {
  position: relative;
  display: inline-block;
  white-space: nowrap;
}

.w.is-off {
  display: none;
}

/* the soft light behind a key phrase; GSAP grows it from the left */
.w__hl {
  position: absolute;
  left: -2px;
  right: -0.3em;
  top: 0.16em;
  bottom: 0.12em;
  border-radius: 3px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 26%, transparent), color-mix(in srgb, var(--accent) 16%, transparent));
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--accent) 45%, transparent), 0 0 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  opacity: 0;
  pointer-events: none;
}

.w__t {
  position: relative;
  display: inline-block;
  font-weight: var(--wg, 420);
}

/* the old form of a word that changes (three to Three), fading inside the same word */
.w__old {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 420;
  white-space: nowrap;
}

.sum__ghosts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sum__ghost {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font-size: clamp(14px, min(4.1vw, 3.7vh), 16px);
  line-height: 1.58;
  letter-spacing: -0.003em;
  color: var(--faint);
  font-weight: 420;
}

/* the light that sweeps across the words while the AI reads */
.sum__glint {
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 0;
  width: 38%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.14) 45%, color-mix(in srgb, var(--accent) 22%, transparent) 55%, transparent);
  mix-blend-mode: plus-lighter;
  filter: blur(6px);
  opacity: 0;
  pointer-events: none;
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: clamp(12px, 3vh, 18px);
  padding-top: clamp(10px, 2.6vh, 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.card__source {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}

.card__source svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.card__source-name {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__source-meta {
  white-space: nowrap;
}

.card__source-meta::before {
  content: '';
  display: inline-block;
  width: 1px;
  height: 10px;
  margin-right: 7px;
  vertical-align: -1px;
  background: rgba(255, 255, 255, 0.14);
}

.copy {
  flex: none;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.copy__face {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 12px 0 10px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 4px 10px -4px rgba(0, 0, 0, 0.6);
  transition: background 0.3s ease;
}

@media (hover: hover) {
  .copy:hover .copy__face {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
  }
}

.copy__icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.copy__check {
  stroke: var(--mint);
  stroke-width: 1.6;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.copy__words {
  font-size: 12.5px;
  font-weight: 560;
  min-width: 3.6em;
  text-align: left;
}

@media (max-width: 360px) {
  .card__source-meta {
    display: none;
  }
}
