/* The live translation card of Velino, a made-up travel translator, on a soft warm page. White card with a hairline
   edge and three layers of shadow, a little grain, a light sheen that follows the pointer. The English line on top,
   the Italian under the seam; the threads that join every word to its match are an SVG under the words. */
:root {
  --page: #eeece7;          /* the page */
  --card: #ffffff;          /* the card */
  --well: #f7f6f3;          /* the Italian pane */
  --ink: #17181b;           /* the words */
  --muted: #8d8b85;         /* the small words */
  --unheard: #c9c6bf;       /* an English word not heard yet */
  --accent: #2d55e6;        /* the one colour: the pair, the thread, the meter */
  --wash: rgba(45, 85, 230, 0.1); /* the wash behind a lit pair */
  --edge: rgba(23, 24, 27, 0.08); /* the hairline edge */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background:
    radial-gradient(120% 80% at 50% 0%, #f6f5f1 0%, var(--page) 60%, #e6e3dc 100%);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  max-height: 100vh;
  display: grid;
  place-items: center;
  padding: min(16px, 3vh) 14px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.tr {
  position: relative;
  width: min(460px, 100%);
  padding: clamp(12px, 3.2vh, 18px) clamp(14px, 4vw, 20px) clamp(10px, 2.6vh, 14px);
  border-radius: 22px;
  background: var(--card);
  box-shadow:
    0 0 0 1px var(--edge),
    0 1px 1px rgba(23, 24, 27, 0.04),
    0 8px 18px -8px rgba(23, 24, 27, 0.12),
    0 34px 60px -28px rgba(23, 24, 27, 0.28);
  isolation: isolate;
  overflow: hidden;
  opacity: 0;
}

/* a whisper of grain */
.tr::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  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%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the top edge catches the light */
.tr::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 1), transparent);
  pointer-events: none;
}

.tr__sheen {
  position: absolute;
  z-index: -1;
  left: 0;
  top: 0;
  width: 320px;
  height: 320px;
  margin: -160px 0 0 -160px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(45, 85, 230, 0.07), transparent);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the head */
.tr__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: clamp(8px, 2.2vh, 14px);
}

.tr__brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 640;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.01em;
}

.tr__mark {
  width: 20px;
  height: 20px;
  padding: 3px;
  border-radius: 7px;
  background: var(--ink);
  fill: none;
  stroke: #fff;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tr__mark-tick {
  stroke: #8fa6ff;
}

.tr__pair {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--well);
  box-shadow: inset 0 0 0 1px var(--edge);
}

.tr__lang {
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 560;
  color: var(--ink);
}

.tr__swap {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--edge), 0 2px 4px -2px rgba(23, 24, 27, 0.25);
  cursor: pointer;
}

.tr__swap svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the panes */
.tr__pane {
  position: relative;
  padding: clamp(8px, 2vh, 12px) 4px;
}

.tr__pane--out {
  margin: 0 -8px;
  padding: clamp(8px, 2vh, 12px) 12px clamp(6px, 1.6vh, 10px);
}

/* the well of the Italian pane is a layer of its own, under the threads; the words sit over them */
.tr__pane--out::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--well), rgba(247, 246, 243, 0.6));
  box-shadow: inset 0 0 0 1px rgba(23, 24, 27, 0.04);
}

.tr__label,
.tr__line,
.tr__note {
  position: relative;
  z-index: 3;
}

.tr__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.tr__wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 12px;
}

.tr__wave i {
  display: block;
  width: 2px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleY(0.25);
}

.tr__line {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.26em;
  row-gap: 0.06em;
  min-height: 2.5em;
  align-content: flex-start;
  margin: clamp(4px, 1.2vh, 8px) 0 0;
  font-size: clamp(17px, min(5.2vw, 4.4vh), 24px);
  line-height: 1.22;
  letter-spacing: -0.018em;
}

.tr__line--src {
  font-weight: 470;
}

.tr__line--out {
  font-weight: 600;
}

/* a word: the outer box moves (Flip), the inner one changes (text, weight, wash) */
.w {
  position: relative;
  display: inline-block;
  cursor: default;
}

.w__in {
  position: relative;
  display: inline-block;
  padding: 0 0.1em;
  margin: 0 -0.1em;
  border-radius: 0.28em;
  font-variation-settings: 'wdth' var(--wd, 100);
  white-space: nowrap;
  transition: background-color 0.28s ease, color 0.28s ease, opacity 0.28s ease;
}

.tr__line--src .w__in {
  color: var(--unheard);
}

.tr__line--out .w__in.is-draft {
  color: var(--muted);
  font-weight: 450;
}

.w.is-on .w__in {
  background-color: var(--wash);
  color: var(--accent);
}

.tr.is-focus .w:not(.is-on) .w__in {
  opacity: 0.38;
}

.tr__note {
  min-height: 18px;
  line-height: 18px;
  margin: clamp(2px, 1vh, 6px) 0 0;
  font-size: 12px;
  color: var(--muted);
}

.tr__note b {
  font-weight: 600;
  color: var(--accent);
}

.tr__seam {
  height: clamp(10px, 3vh, 18px);
}

/* ---------------------------------------------------------------- the threads */
.tr__threads {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.tr__threads path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-opacity: 0.14;
  transition: stroke 0.28s ease, stroke-opacity 0.28s ease, stroke-width 0.28s ease;
}

.tr__threads path.is-on {
  stroke: var(--accent);
  stroke-opacity: 0.9;
  stroke-width: 1.5;
}

.tr__threads circle {
  fill: var(--card);
  stroke: var(--ink);
  stroke-opacity: 0.2;
  stroke-width: 1;
  transition: stroke 0.28s ease, stroke-opacity 0.28s ease;
}

.tr__threads circle.is-on {
  stroke: var(--accent);
  stroke-opacity: 1;
}

.tr.is-focus .tr__threads path:not(.is-on) {
  stroke-opacity: 0.06;
}

/* ---------------------------------------------------------------- the foot */
.tr__foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: clamp(8px, 2vh, 12px);
}

.tr__conf {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tr__meter {
  position: relative;
  width: 54px;
  height: 3px;
  border-radius: 3px;
  background: rgba(23, 24, 27, 0.08);
  overflow: hidden;
}

.tr__meter-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
}

.tr__tools {
  display: inline-flex;
  gap: 6px;
}

.tr__tool {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--edge), 0 2px 5px -3px rgba(23, 24, 27, 0.3);
  cursor: pointer;
}

.tr__tool svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.tr__tick {
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

@media (hover: hover) {
  .tr__tool:hover,
  .tr__swap:hover {
    box-shadow: 0 0 0 1px rgba(23, 24, 27, 0.16), 0 4px 10px -4px rgba(23, 24, 27, 0.35);
  }
  .w:hover .w__in {
    cursor: pointer;
  }
}

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