:root {
  --paper: #faf8f3;
  --ink: #141414;
  --muted: #5b5852;
  --bio: #0f7c8a;
  --cargo: #c7781a;
  --logcase: #e3121f;
  --enter: cubic-bezier(.2, .8, .25, 1);
  --skel: #e8e4da;
}
* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: Alegreya, Georgia, serif;
  font-size-adjust: from-font; /* Georgia matches Alegreya's x-height until the swap: no reflow */
  -webkit-font-smoothing: antialiased;
}

/* Hero: the logo is the whole message, shown still and immediately */
.hero {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem 4rem;
  position: relative;
}
.hero h1 { line-height: 0; }
.hero img {
  width: min(86vw, 760px);
  max-height: 70svh;
  height: auto;
  object-fit: contain;
}
.cue {
  position: absolute;
  bottom: 1rem;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 50%;
}
.cue svg { width: 28px; height: 28px; }
.cue:hover { color: var(--ink); }
.cue:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Apps: one centered slide at a time (JS); without JS they simply stack */
main {
  max-width: 1000px;
  min-height: 100svh;
  margin: 0 auto;
  padding: 4rem 1rem;
  display: grid;
  align-content: center;
  gap: 2.5rem;
}
.app { display: grid; gap: 1.5rem; align-items: center; }
.slides { display: grid; gap: 4rem; }
@media (min-width: 800px) {
  .app { grid-template-columns: 1.3fr 1fr; gap: 3.5rem; }
}
/* Every slide shares one grid cell, so the stage keeps the tallest height and never jumps */
.js .slides { view-transition-name: slides; touch-action: pan-y; }
.js .app { grid-area: 1 / 1; align-self: center; }
.js .app:not(.current) { visibility: hidden; }
.art { width: 100%; display: grid; place-items: center; }

.controls { display: flex; justify-content: center; align-items: center; gap: 1.25rem; }
.controls[hidden] { display: none; }
.step {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.step svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.step:hover { background: var(--ink); color: var(--paper); }
.dots { display: flex; gap: .25rem; }
.dots button {
  /* 10px dot inside a 24px target: the transparent border is the extra hit area */
  box-sizing: content-box;
  width: 10px; height: 10px;
  border: 7px solid transparent;
  border-radius: 99px;
  background: var(--muted) padding-box;
  opacity: .45;
  cursor: pointer;
  padding: 0;
  transition: width .35s var(--enter), opacity .35s;
}
.dots button[aria-current="true"] { width: 28px; opacity: 1; background-color: var(--ink); }
.step:focus-visible, .dots button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#bio .art { aspect-ratio: 400 / 200; }
#cargo .art { aspect-ratio: 400 / 220; }
.art svg { width: 100%; height: auto; overflow: visible; }
h2 {
  font-size: clamp(2.6rem, 7vw, 4.5rem);
  font-style: italic;
  font-weight: 700;
  line-height: 1.05;
}
.app p { margin-top: .9rem; font-size: clamp(1.125rem, 1rem + .5vw, 1.3rem); line-height: 1.4; color: var(--muted); max-width: 26ch; }

/* Hand-drawn ink: round caps, a slight wobble via the SVG filter */
.ink { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
#bio .pulse { stroke: var(--bio); }
#bio .dot { fill: var(--bio); }
#cargo .load { fill: var(--cargo); }
#cargo .wheel { transform-box: fill-box; transform-origin: center; }
#logcase .logo { width: min(62%, 260px); height: auto; }
#logcase .art { gap: 1.2rem; }
.tiles { display: flex; gap: .8rem; }
.tiles span {
  width: clamp(56px, 12vw, 88px);
  aspect-ratio: 3 / 4;
  border: 4px solid var(--ink);
  border-radius: 10px 14px 9px 12px; /* uneven corners: drawn, not drafted */
  background: #fff;
}
.tiles span::after {
  content: "";
  display: block;
  margin: 60% 18% 0;
  height: 5px;
  border-radius: 3px;
  background: var(--logcase);
}

/* Without JS every scene is complete. With JS, art waits for its entrance;
   each animation is finite and ends on that same complete frame. */
@media (prefers-reduced-motion: no-preference) {
  /* Skeleton: grey breathing blocks until main.js adds .in, then the real content fades in */
  .js .app .art, .js .app h2, .js .app p { transition: background-color .5s ease-out, color .5s ease-out; }
  .js .app:not(.in) .art,
  .js .app:not(.in) h2,
  .js .app:not(.in) p {
    background-color: var(--skel);
    color: transparent;
    border-radius: 12px;
    animation: breathe .9s ease-in-out infinite alternate;
  }
  .js .app:not(.in) :is(h2, p) { width: fit-content; border-radius: 6px; }
  .js .app:not(.in) .art > * { visibility: hidden; }

  /* Scenes replay each time their slide comes in. `both` fill holds the start frame
     during delays and the complete frame at the end. */
  .js #bio.in .pulse { stroke-dasharray: 1; animation: trace 1.4s cubic-bezier(.45, 0, .55, 1) both; }
  .js #bio.in .dot { transform-box: fill-box; transform-origin: center; animation: dot .45s 1.25s var(--enter) both; }

  /* 110 units of travel on an 18-unit wheel ≈ 350° of turn, so the wheels don't skid */
  .js #cargo.in .truck { animation: drive 1.3s var(--enter) both; }
  .js #cargo.in .wheel { animation: roll 1.3s var(--enter) both; }

  .js #logcase.in .logo { animation: pop .6s var(--enter) both; }
  .js #logcase.in .tiles span { animation: rise .5s var(--enter) both; }
  .js #logcase.in .tiles span:nth-child(1) { animation-delay: .35s; }
  .js #logcase.in .tiles span:nth-child(2) { animation-delay: .45s; }
  .js #logcase.in .tiles span:nth-child(3) { animation-delay: .55s; }

  /* Slide change: old app eases out, new one glides in from the side you're heading to */
  ::view-transition-old(slides) { animation: .35s ease-in both out-left; }
  ::view-transition-new(slides) { animation: .6s .1s var(--enter) both in-right; }
  html[data-dir="back"]::view-transition-old(slides) { animation-name: out-right; }
  html[data-dir="back"]::view-transition-new(slides) { animation-name: in-left; }
}
@keyframes breathe { from { opacity: .5; } }
@keyframes trace { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes dot { from { opacity: 0; transform: scale(.3); } }
@keyframes drive { from { transform: translateX(-110px); opacity: 0; } 30% { opacity: 1; } }
@keyframes roll { from { transform: rotate(-350deg); } }
@keyframes pop { from { opacity: 0; transform: scale(.9); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes out-left { to { opacity: 0; translate: -6% 0; } }
@keyframes out-right { to { opacity: 0; translate: 6% 0; } }
@keyframes in-right { from { opacity: 0; translate: 6% 0; } }
@keyframes in-left { from { opacity: 0; translate: -6% 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

footer {
  padding: 3rem 1rem 2.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
}
