/* The live flight card with the route that moves on: the flight widget of a travel app, a dark glass card on a black
   page. GSAP moves the outer .shell (entrance and press); the inner .card has the CSS hover. The route is an SVG drawn
   in pixels by script.js and redrawn on resize; the light that follows the plane is .card__glow. */
:root {
  --page: #000000;            /* the page */
  --glass-a: #171b24;         /* the glass at the top */
  --glass-b: #0b0d12;         /* the glass at the bottom */
  --edge: rgba(200, 220, 255, 0.10); /* the edge of the card */
  --ink: #eef1f6;             /* the words */
  --muted: #7d8596;           /* the small words */
  --dim: #4b5262;             /* the quietest words and the dashes */
  --route: #7fb0ff;           /* the light of the travelled route */
  --on-time: #6fdba5;         /* the pill: on time */
  --descending: #f3b766;      /* the pill: descending */
  --landed: #9cc3ff;          /* the pill: landed */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

.shell {
  width: min(380px, 100%);
  opacity: 0;
  will-change: transform;
}

/* the glass card */
.card {
  --mx: 30%;
  --my: 0%;
  --pc: var(--on-time);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(12px, 3.4vh, 20px) clamp(14px, 4.6vw, 20px) clamp(8px, 2vh, 12px);
  border-radius: 24px;
  background:
    radial-gradient(120% 70% at 50% -20%, rgba(120, 160, 255, 0.10), transparent 60%),
    linear-gradient(170deg, var(--glass-a), var(--glass-b));
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 1px rgba(0, 0, 0, 0.6),
    0 18px 40px -18px rgba(0, 0, 0, 0.9),
    0 50px 90px -40px rgba(40, 80, 170, 0.35);
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.15), box-shadow 0.5s ease;
}

/* a fine grain on the glass */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  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='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1 0'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}

/* the soft light that travels with the plane */
.card__glow {
  position: absolute;
  left: 0;
  top: 0;
  width: 260px;
  height: 200px;
  margin: -100px 0 0 -130px;
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--route) 26%, transparent), color-mix(in srgb, var(--route) 8%, transparent) 55%, transparent);
  opacity: 0.9;
  will-change: transform;
}

/* the sheen that follows the pointer */
.card__sheen {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(320px 200px at var(--mx) var(--my), rgba(255, 255, 255, 0.06), transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
    box-shadow:
      inset 0 0 0 1px rgba(200, 220, 255, 0.16),
      inset 0 1px 0 rgba(255, 255, 255, 0.1),
      0 1px 1px rgba(0, 0, 0, 0.6),
      0 24px 50px -20px rgba(0, 0, 0, 0.95),
      0 60px 100px -40px rgba(60, 100, 200, 0.45);
  }

  .card:hover .card__sheen {
    opacity: 1;
  }

  .card:hover .toggle__face {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.06);
  }
}

/* the head: the flight and the status */
.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 12px;
  white-space: nowrap;
}

.brand__mark {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: var(--route);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand__flight {
  font-weight: 620;
  font-variation-settings: 'wdth' 106;
  letter-spacing: 0.02em;
}

.brand__date {
  color: var(--muted);
}

.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 10px;
  overflow: hidden;
  border-radius: 999px;
  flex: none;
  font-size: 11.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.01em;
  color: var(--pc);
  background: color-mix(in srgb, var(--pc) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pc) 28%, transparent);
  white-space: nowrap;
}

.pill__words {
  position: relative;
  display: inline-block;
}

.pill__words > span {
  display: inline-block;
}

.pill__shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 60%;
  background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--pc) 40%, transparent), transparent);
  transform: translateX(-120%);
  pointer-events: none;
}

/* the two ends */
.ends {
  display: flex;
  justify-content: space-between;
  margin-top: clamp(10px, 2.8vh, 18px);
}

.end {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.end--to {
  align-items: flex-end;
  text-align: right;
}

.end__code {
  font-size: clamp(28px, min(9.6vw, 8.6vh), 38px);
  line-height: 1;
  font-weight: 640;
  font-variation-settings: 'wdth' 112;
  letter-spacing: -0.01em;
  color: var(--ink);
  transition: color 0.6s ease;
}

.end--from .end__code {
  color: color-mix(in srgb, var(--ink) 72%, var(--muted));
}

.end__city {
  font-size: 12px;
  color: var(--muted);
}

.end__time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.end__label {
  display: inline-block;
  color: var(--muted);
}

/* the route */
.route {
  position: relative;
  height: clamp(44px, 13vh, 86px);
  margin: clamp(-30px, -3.4vh, -12px) clamp(-4px, -1vw, -2px) 0;
}

.route__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.route__base {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 1.5 5;
}

.route__lit {
  fill: none;
  stroke: url(#litGrad);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.route__glow {
  fill: none;
  stroke: url(#litGrad);
  stroke-width: 5;
  stroke-linecap: round;
  opacity: 0.55;
  filter: url(#litBlur);
}

.lit-stop-a {
  stop-color: var(--route);
  stop-opacity: 0;
}

.lit-stop-b {
  stop-color: var(--route);
  stop-opacity: 0.75;
}

.lit-stop-c {
  stop-color: #ffffff;
  stop-opacity: 1;
}

.route__tick {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.plane {
  fill: #f6f8fc;
}

.plane--shadow {
  fill: #000000;
  opacity: 0.55;
}

/* the facts */
.facts {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 10px;
  margin-top: clamp(8px, 2.2vh, 14px);
  padding-top: clamp(8px, 2.2vh, 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.fact {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fact:not(.fact--left) {
  align-items: flex-end;
  text-align: right;
}

.fact__label {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.fact__value {
  font-size: 13px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fact__value--big {
  font-size: clamp(17px, min(5.4vw, 4.8vh), 21px);
  font-weight: 620;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.01em;
}

.fact__unit {
  color: var(--muted);
  font-weight: 450;
}

/* the rolling characters */
.roll {
  display: inline-flex;
  font-variant-numeric: tabular-nums;
  white-space: pre;
}

.slot {
  position: relative;
  display: inline-block;
  overflow: hidden;
  line-height: 1.2;
  vertical-align: bottom;
}

.slot > span {
  display: inline-block;
}

.slot > span.out {
  position: absolute;
  left: 0;
  top: 0;
}

/* the details */
.more {
  height: 0;
  overflow: hidden;
}

.more__inner {
  padding-top: clamp(8px, 2vh, 12px);
}

.cells {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: clamp(6px, 1.6vh, 9px) 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.cell__label {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.cell__value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: clamp(15px, 4.4vh, 18px);
  font-weight: 620;
  font-variation-settings: 'wdth' 106;
}

.cell--belt {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--route) 30%, transparent);
  background: color-mix(in srgb, var(--route) 7%, transparent);
}

.cell__icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--route);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bags {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: clamp(6px, 1.6vh, 9px);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.bags__track {
  position: relative;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.bags__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--route) 40%, transparent), var(--route));
  transform-origin: left center;
  transform: scaleX(0);
}

.bags__eta {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* the toggle */
.toggle {
  display: block;
  width: 100%;
  margin-top: clamp(6px, 1.6vh, 10px);
}

.toggle__face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: clamp(28px, 7vh, 34px);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 540;
  color: var(--muted);
  transition: color 0.3s ease, background-color 0.3s ease;
}

.toggle:focus-visible {
  outline: none;
}

.toggle:focus-visible .toggle__face {
  box-shadow: 0 0 0 1.5px var(--route);
  color: var(--ink);
}

.toggle__words {
  display: inline-block;
}

.toggle__chev {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
