/* ==========================================================================
   Huseyn Abdulla — personal site
   Colors follow the University of Tennessee, Knoxville brand:
   Tennessee Orange #FF8200, White #FFFFFF, Smokey #4B4B4B (brand.utk.edu).
   Bright orange is used for accents only; UT's guidelines advise against
   orange text on white, so small colored text uses a darker orange.
   ========================================================================== */

:root {
  --paper:        #FFFFFF;  /* page background (UT White) */
  --smokey:       #4B4B4B;  /* sidebar (UT Smokey) */
  --ink:          #2B2B2B;  /* main text */
  --muted:        #636363;  /* secondary text */
  --rule:         #E3E3E3;  /* dividers */
  --orange:       #FF8200;  /* Tennessee Orange: lines, bars, underlines */
  --orange-text:  #A65400;  /* readable orange for small text on white */
  --orange-soft:  #FFF2E3;  /* tag background */

  /* Sidebar text */
  --rail-ink:     #FFFFFF;
  --rail-muted:   #D6D6D6;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans:  "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --rail-w: 21.5rem;
  --measure: 40rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #1C1C1C;
    --smokey:      #2B2B2B;
    --ink:         #ECECEC;
    --muted:       #B3B3B3;
    --rule:        #353535;
    --orange-text: #FFA040;
    --orange-soft: #3A2A18;
    --rail-muted:  #CFCFCF;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

p, ul, ol, dl, figure, blockquote, address { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
em { font-style: italic; }

a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--orange);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { color: var(--orange-text); }

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  background: var(--orange);
  color: #000;
  font-family: var(--sans);
  font-size: 0.875rem;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ---------- Layout ---------- */
@media (min-width: 60em) {
  body {
    display: grid;
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
  }
}

/* ---------- Rail (Smokey sidebar) ---------- */
.rail {
  background: var(--smokey);
  color: var(--rail-ink);
  border-top: 6px solid var(--orange);
}

.rail-inner {
  position: sticky;
  top: 0;
  height: calc(100vh - 6px);
  height: calc(100dvh - 6px);
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  padding: 3rem 2rem 2.25rem;
  overflow-y: auto;
}

.portrait {
  position: relative;
  width: 8.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px var(--orange);
  margin-bottom: 1.4rem;
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 1;
}
.portrait-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 2.5rem;
  color: var(--rail-ink);
}

.name {
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.name a { color: var(--rail-ink); text-decoration: none; }
.name a:hover { color: var(--rail-ink); }

.role {
  margin-top: 0.6rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--rail-muted);
}

.site-nav ul { display: grid; gap: 0.1rem; }
.site-nav a {
  display: block;
  position: relative;
  padding: 0.3rem 0 0.3rem 1rem;
  margin-left: -1rem;
  font-family: var(--sans);
  font-size: 0.9375rem;
  color: var(--rail-muted);
  text-decoration: none;
}
.site-nav a::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 0;
  background: var(--orange);
  transform: translateY(-50%);
  transition: height 0.2s ease;
}
.site-nav a:hover { color: var(--rail-ink); }
.site-nav a.is-active { color: var(--rail-ink); font-weight: 600; }
.site-nav a.is-active::before { height: 1.15em; }

.rail-links {
  margin-top: auto;
  display: grid;
  gap: 0.35rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
}
.rail-links a { color: var(--rail-muted); text-decoration-thickness: 1px; }
.rail-links a:hover { color: var(--rail-ink); }

.menu-toggle { display: none; }

/* ---------- Main column ---------- */
.content {
  padding: 5rem clamp(1.5rem, 6vw, 6rem) 3rem;
  max-width: calc(var(--measure) + 12rem);
}

/* Intro + people/processes/policies diagram (the one animated moment on the page) */
.intro {
  padding-bottom: 4.5rem;
  border-bottom: 1px solid var(--rule);
}

.tri {
  display: block;
  width: min(100%, 25rem);
  height: auto;
  margin: 0 auto 2.25rem;
  overflow: visible;
}
.tri-edge {
  fill: none;
  stroke: var(--muted);
  stroke-opacity: 0.55;
  stroke-width: 2;
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  animation: tri-draw 0.7s ease-out forwards;
}
.tri-edge-1 { animation-delay: 1.0s; }
.tri-edge-2 { animation-delay: 1.25s; }
.tri-edge-3 { animation-delay: 1.5s; }

.tri-dot { fill: var(--orange); }

.tri-ring {
  fill: var(--paper);
  stroke: var(--orange);
  stroke-width: 3;
}
.tri-icon * {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tri-icon .gear-teeth {
  stroke-width: 4.5;
  stroke-linecap: butt;
  stroke-dasharray: 4.91 4.91;  /* 8 teeth around the circle */
}
.tri-label {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  fill: var(--ink);
  text-anchor: middle;
}

.tri-node {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: tri-pop 0.55s cubic-bezier(.3, 1.45, .5, 1) forwards;
}
.tri-node-1 { animation-delay: 0.2s; }
.tri-node-2 { animation-delay: 0.45s; }
.tri-node-3 { animation-delay: 0.7s; }

.tri-center {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: tri-pop 0.55s cubic-bezier(.3, 1.45, .5, 1) forwards 1.9s;
}
.tri-icon .leaf { fill: var(--orange); stroke: var(--orange); stroke-width: 1.5; }
.tri-icon .leaf-vein { stroke: var(--paper); stroke-width: 1.4; }
.tri-icon .coin { fill: var(--orange); stroke: var(--paper); stroke-width: 1.6; }
.tri-icon .coin-sign {
  fill: var(--paper);
  stroke: none;
  font-family: var(--sans);
  font-size: 8.2px;
  font-weight: 700;
  text-anchor: middle;
}

@keyframes tri-pop  { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
@keyframes tri-draw { to { stroke-dashoffset: 0; } }
@keyframes tri-fade { to { opacity: 1; } }

.lede {
  max-width: 26em;
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.125rem);
  line-height: 1.3;
  font-weight: 400;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}

/* Typing effect on the opening sentence. The untyped part keeps its space
   (just invisible) so the layout never shifts while it types. */
.lede .tw-rest { color: transparent; }
.lede .tw-caret {
  display: inline-block;
  width: 2px;
  height: 0.95em;
  margin: 0 1px 0 1px;
  background: var(--orange);
  vertical-align: -0.08em;
  animation: tw-blink 0.9s steps(1) infinite;
}
.lede .tw-caret.is-done { animation: tw-blink 0.9s steps(1) 3, tw-out 0.4s ease 2.7s forwards; }
@keyframes tw-blink { 50% { opacity: 0; } }
@keyframes tw-out { to { opacity: 0; } }

/* Sections */
.section {
  padding: 4.5rem 0;
  border-bottom: 1px solid var(--rule);
}

h2, h3 { margin: 0; font-weight: 500; }

h2 {
  font-size: 2.125rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: 2rem;
}

h3 {
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  margin: 3rem 0 1rem;
}
.section-head + h3,
h2 + h3 { margin-top: 0; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-bottom: 2rem;
}
.section-head h2 { margin-bottom: 0; }

.quiet-link {
  font-family: var(--sans);
  font-size: 0.875rem;
  text-decoration-thickness: 1px;
}

.prose { max-width: var(--measure); }
.prose p + p { margin-top: 1.1em; }

.plain-list { max-width: var(--measure); }
.plain-list li { padding: 0.2rem 0; }

.note {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
  max-width: var(--measure);
  margin-bottom: 1.25rem;
}

/* Publications */
.pub {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.35rem 0;
  border-top: 1px solid var(--rule);
}

.pub-year {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--orange-text);
  padding-top: 0.2rem;
}
.pub-year.is-repeat { opacity: 0; }

.pub-body { max-width: var(--measure); }
.pub-title {
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 500;
  text-wrap: pretty;
}
.pub-title a { text-decoration-thickness: 1px; text-decoration-color: var(--rule); }
.pub-title a:hover { text-decoration-color: var(--orange); }

/* Trophy on award-winning papers; links to the award in Honors */
.award-link {
  display: inline-flex;
  vertical-align: -0.12em;
  margin-left: 0.3rem;
  padding: 0.1rem;
  border-radius: 4px;
  text-decoration: none;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.award-link svg { width: 1.15em; height: 1.15em; }
.award-link .t-fill { fill: var(--orange); stroke: var(--orange-text); stroke-width: 0.8; stroke-linejoin: round; }
.award-link .t-line { fill: none; stroke: var(--orange); stroke-width: 1.8; stroke-linecap: round; }
.award-link:hover { background: var(--orange-soft); transform: translateY(-1px); }

/* Brief highlight on the award line after a trophy is clicked */
.honors li:target,
.honors li.is-flash { animation: award-flash 2.6s ease-out; }
@keyframes award-flash {
  0%, 35% { background: var(--orange-soft); box-shadow: -0.75rem 0 0 var(--orange-soft), 0.75rem 0 0 var(--orange-soft); }
  100%    { background: transparent;        box-shadow: -0.75rem 0 0 transparent,        0.75rem 0 0 transparent; }
}

.pub-authors,
.pub-venue {
  font-size: 1rem;
  color: var(--muted);
  margin-top: 0.3rem;
}
.pub-authors strong { color: var(--ink); font-weight: 600; }
.pub-venue { margin-top: 0.1rem; }

.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.5rem;
  border-radius: 1rem;
  background: var(--orange-soft);
  color: var(--orange-text);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: 0.12em;
}

/* Optional research insights grid */
.insights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1.5rem;
}
.insights img { border: 1px solid var(--rule); border-radius: 4px; }
.insights figcaption {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* Teaching */
.courses { max-width: var(--measure); }
.course {
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.course dt { font-size: 1.1875rem; line-height: 1.4; }
.course dd {
  margin: 0.25rem 0 0;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
}
.course-code {
  display: block;
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--orange-text);
  margin-bottom: 0.15rem;
}

/* Student comments carousel */
.carousel { max-width: var(--measure); }

.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.carousel-track::-webkit-scrollbar { display: none; }

.quote {
  flex: 0 0 100%;
  scroll-snap-align: start;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 3px solid var(--orange);
}
.quote blockquote {
  margin: 0;
  font-size: clamp(1.35rem, 1.1rem + 0.8vw, 1.75rem);
  line-height: 1.35;
  font-style: italic;
  text-wrap: pretty;
}
.quote figcaption {
  margin-top: 0.85rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
}

.carousel-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-left: 1.5rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
}
.carousel-btn {
  display: grid;
  place-items: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.carousel-btn:hover { border-color: var(--orange); background: var(--orange-soft); }
.carousel-btn:disabled { opacity: 0.35; cursor: default; border-color: var(--rule); background: var(--paper); }
.carousel-btn svg { width: 1rem; height: 1rem; }
.carousel-count { min-width: 3.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.carousel-play { margin-left: 0.5rem; }
.carousel-play .icon-play { display: none; }
.carousel-play.is-paused .icon-play { display: block; }
.carousel-play.is-paused .icon-pause { display: none; }

/* Honors */
.honors { max-width: calc(var(--measure) + 4rem); }
.honors li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 1.5rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule);
}
.honor-name { grid-column: 1; line-height: 1.4; }
.honor-org {
  grid-column: 1;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.honor-org:empty { display: none; }
.honor-year {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 0.2rem;
}

/* Media */
.media { max-width: calc(var(--measure) + 4rem); }
.media li {
  display: grid;
  gap: 0.2rem;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.media a {
  line-height: 1.4;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule);
  text-wrap: pretty;
}
.media a:hover { text-decoration-color: var(--orange); }
.media-meta {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
}
.media-note {
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: var(--measure);
  margin-top: 0.3rem;
}

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 2rem 3rem;
}
.contact-grid h3 { margin-top: 2rem; }
.contact-grid > div > h3:first-child { margin-top: 0; }
.big-link { font-size: 1.4rem; }
address { font-style: normal; line-height: 1.55; }

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---------- Wide screens (1400px and up) ----------
   Wider, centered content; the opening sentence sits beside the diagram;
   lists use the extra width while body paragraphs keep a readable length. */
@media (min-width: 87.5em) {
  /* One shared column width, so every section lines up edge to edge */
  :root { --measure: 58rem; }
  .content {
    max-width: calc(var(--measure) + 8rem);
    margin-inline: auto;
    padding-inline: 4rem;
  }
  .intro {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: center;
    column-gap: 3.5rem;
  }
  .intro .lede { order: 1; max-width: none; }
  .intro .tri  { order: 2; width: 100%; max-width: 28rem; margin: 0 0 0 auto; }

  .prose p { line-height: 1.7; }
  .pub-body, .honors, .media, .scene svg { max-width: none; }
  .pubs, .honors, .media, .courses, .carousel, .contact-grid { max-width: var(--measure); }
}

/* ---------- Small screens ---------- */
@media (max-width: 59.99em) {
  html { scroll-padding-top: 5.5rem; }
  body { font-size: 1.125rem; }

  .rail {
    position: sticky;
    top: 0;
    z-index: 50;
    border-top-width: 4px;
  }
  .rail-inner {
    position: static;
    height: auto;
    padding: 0.75rem 1.25rem;
    gap: 0;
    overflow: visible;
  }

  .identity {
    display: flex;
    align-items: center;
    gap: 0.85rem;
  }
  .portrait { width: 2.75rem; margin: 0; flex: none; box-shadow: 0 0 0 2px var(--orange); }
  .portrait-fallback { font-size: 1.1rem; }
  .identity-text { flex: 1; min-width: 0; }
  .name { font-size: 1.125rem; }
  .role { display: none; }

  .menu-toggle {
    display: grid;
    place-items: center;
    width: 2.75rem; height: 2.75rem;
    margin-right: -0.5rem;
    background: none;
    border: 0;
    color: var(--rail-ink);
    cursor: pointer;
  }
  .menu-toggle-bars,
  .menu-toggle-bars::before,
  .menu-toggle-bars::after {
    display: block;
    width: 1.25rem; height: 2px;
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .menu-toggle-bars { position: relative; }
  .menu-toggle-bars::before,
  .menu-toggle-bars::after { content: ""; position: absolute; left: 0; }
  .menu-toggle-bars::before { top: -6px; }
  .menu-toggle-bars::after  { top: 6px; }
  .menu-toggle[aria-expanded="true"] .menu-toggle-bars { background: transparent; }
  .menu-toggle[aria-expanded="true"] .menu-toggle-bars::before { transform: translateY(6px) rotate(45deg); }
  .menu-toggle[aria-expanded="true"] .menu-toggle-bars::after  { transform: translateY(-6px) rotate(-45deg); }

  .site-nav { display: none; padding: 0.75rem 0 0.5rem; }
  .site-nav.is-open { display: block; }
  .site-nav a { margin-left: 0; padding: 0.55rem 0 0.55rem 1rem; font-size: 1rem; }

  .rail-links { display: none; }

  .content { padding-top: 3rem; }
  .tri { width: min(100%, 20rem); margin: 0 auto 1.75rem; }
  .intro { padding-bottom: 3.5rem; }
  .section { padding: 3.5rem 0; }
  h2 { font-size: 1.875rem; }

  .pub { grid-template-columns: 1fr; gap: 0.25rem; }
  .pub-year.is-repeat { display: none; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tri-edge { animation: none; stroke-dashoffset: 0; }
  .tri-node, .tri-center { animation: none; opacity: 1; }
  * { transition: none !important; }
}

/* ---------- Print ---------- */
@media print {
  body { display: block; background: #fff; color: #000; font-size: 11pt; }
  .rail { border: 0; background: none; color: #000; }
  .rail-inner { position: static; height: auto; padding: 0 0 1rem; }
  .name a, .role { color: #000; }
  .site-nav, .menu-toggle, .tri, .skip-link, .footer .quiet-link, .carousel-controls { display: none; }
  .carousel-track { display: block; overflow: visible; }
  .quote { margin-bottom: 1rem; }
  .content { padding: 0; max-width: none; }
  .section { padding: 1.5rem 0; break-inside: avoid-page; }
  a { color: #000; }
}

/* ==========================================================================
   Scenes between sections: a product's journey from factory to returns and
   back into the loop. Markup holds each scene's final composition; while a
   scene is on screen it gets .is-playing and its parts animate into place.
   .is-armed (added by JS) holds the start positions until it plays.
   ========================================================================== */
/* Scene colors. Dark mode uses softer lines, lifted fills and glowing windows
   so the drawings don't glare against the dark background. */
.scene {
  --sc-line: var(--ink);
  --sc-fill: var(--paper);
  --sc-soft: var(--orange-soft);
  --sc-box-line: var(--ink);
  --sc-ground: var(--rule);
}
@media (prefers-color-scheme: dark) {
  .scene {
    --sc-line: #B4B4B4;
    --sc-fill: #262626;
    --sc-soft: rgba(255, 176, 96, 0.55);
    --sc-box-line: #9A4E00;
    --sc-ground: #4A4A4A;
  }
}

.section:has(+ .scene) { border-bottom: 0; padding-bottom: 2.5rem; }
.scene + .section { padding-top: 3.25rem; }

.scene svg {
  display: block;
  width: 100%;
  max-width: calc(var(--measure) + 4rem);
  height: auto;
  overflow: hidden;
  fill: none;
  stroke: var(--sc-line);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.scene .fp { fill: var(--sc-fill); }
.scene .fo { fill: var(--orange); }
.scene .fs { fill: var(--sc-soft); }
.scene .fi { fill: var(--sc-line); stroke: none; }
.scene .bx { stroke: var(--sc-box-line); }
.scene .ns { stroke: none; }
.scene .so { stroke: var(--orange); }
.scene .thin { stroke-width: 1.4; }
.scene .thick { stroke-width: 3; }
.scene .tape { stroke: var(--paper); stroke-width: 2; }
.scene .tape.thin { stroke-width: 1.3; }
.scene .arc { fill: none; stroke-width: 2.4; }
.scene .gear { stroke: var(--orange); stroke-width: 4; stroke-linecap: butt; stroke-dasharray: 2.95 2.95; }
.scene .ground { stroke: var(--sc-ground); stroke-width: 1.5; }
.scene .road { stroke: var(--sc-ground); stroke-width: 2; stroke-dasharray: 10 12; }
.scene .puff { opacity: 0.55; }
.scene .carry { opacity: 0; }
.scene .refurb { opacity: 0; }
.scene .unloaded { opacity: 0; }
.scene .deliver { opacity: 0; transform-box: fill-box; transform-origin: center bottom; }
.scene .sc-text {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  fill: var(--orange-text);
  stroke: none;
  text-anchor: middle;
}
.scene .sc-text-ink { fill: var(--sc-line); font-size: 12px; }

.scene .pop,
.scene .spin,
.scene .wheel,
.scene .leg { transform-box: fill-box; }
.scene .pop, .scene .spin, .scene .wheel { transform-origin: center; }
.scene .leg { transform-origin: top center; }

/* Start positions, held until the scene plays */
.scene.is-armed:not(.is-playing) .mv      { transform: translate(var(--dx, 0), var(--dy, 0)); }
.scene.is-armed:not(.is-playing) .pop,
.scene.is-armed:not(.is-playing) .handoff,
.scene.is-armed:not(.is-playing) .appear,
.scene.is-armed:not(.is-playing) .tag     { opacity: 0; }
.scene.is-armed:not(.is-playing) .carry   { opacity: 1; }
.scene.is-armed:not(.is-playing) .unloaded { opacity: 1; }
.scene.is-armed:not(.is-playing) .refurb  { transform: translateX(-278px); opacity: 1; }

/* Playing */
.scene.is-playing .mv {
  animation: sc-move var(--dur, 3s) cubic-bezier(.45, 0, .25, 1) var(--delay, 0s) both;
}
.scene.is-playing .mv.lin { animation-timing-function: linear; }
.scene.is-playing .mv .wheel { animation: sc-spin 0.55s linear var(--delay, 0s) 5; }
.scene.is-playing .walk .leg-a { animation: sc-swing-a 0.25s ease-in-out var(--delay, 0s) var(--steps, 10) alternate; }
.scene.is-playing .walk .leg-b { animation: sc-swing-b 0.25s ease-in-out var(--delay, 0s) var(--steps, 10) alternate; }
.scene.is-playing .walk .carry { animation: sc-carry 3.05s linear var(--delay, 0s) both; }
.scene.is-playing .handoff {
  animation: sc-move var(--dur) ease-out var(--delay) both, sc-fade-in 0.15s var(--delay) both;
}
.scene.is-playing .mv.appear {
  animation: sc-move var(--dur) linear var(--delay) both, sc-fade-in 0.3s var(--delay) both;
}
.scene.is-playing .pop { animation: sc-pop 0.55s cubic-bezier(.3, 1.5, .5, 1) var(--delay, 0s) both; }
.scene.is-playing .spin { animation: sc-spin 1s ease-in-out var(--delay, 0s) both; }
.scene.is-playing .puff { animation: sc-puff 2s ease-out calc(var(--i) * 0.55s) 3; }
.scene.is-playing .unloaded { animation: sc-out 0.15s linear var(--delay) both; }
.scene.is-playing .deliver { animation: sc-deliver var(--dur) linear var(--delay) both; }
.scene.is-playing .refurb {
  animation: sc-refurb var(--dur) ease-in-out var(--delay) both,
             sc-out 0.2s linear calc(var(--delay) + var(--dur) + 0.15s) both;
}
.scene.is-playing .refurb .tag { animation: sc-tag var(--dur) linear var(--delay) both; }

@keyframes sc-move    { from { transform: translate(var(--dx, 0), var(--dy, 0)); } }
@keyframes sc-fade-in { from { opacity: 0; } }
@keyframes sc-out     { from { opacity: 1; } to { opacity: 0; } }
@keyframes sc-pop     { from { opacity: 0; transform: scale(0.2); } 70% { transform: scale(1.12); } }
@keyframes sc-spin    { to { transform: rotate(360deg); } }
@keyframes sc-swing-a { from { transform: rotate(16deg); } to { transform: rotate(-16deg); } }
@keyframes sc-swing-b { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
@keyframes sc-carry   { 0%, 99% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sc-puff    { 0% { opacity: 0; transform: translateY(8px); } 40% { opacity: 0.9; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes sc-refurb  {
  0%       { transform: translateX(-278px); }
  35%, 60% { transform: translateX(-131px); }
  100%     { transform: none; }
}
@keyframes sc-deliver {
  0%       { opacity: 0; transform: translateX(var(--dx)); }
  6%       { opacity: 1; }
  65%, 78% { opacity: 1; transform: none; }
  100%     { opacity: 0; transform: scale(0.6); }
}
@keyframes sc-tag     { 0%, 62% { opacity: 0; } 72%, 100% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .scene * { animation: none !important; }
}
@media print { .scene { display: none; } }
