:root {
  color-scheme: light;
  font-family: ui-rounded, system-ui, sans-serif;
  color: #402e24;
  background: #fbf4e8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }

main {
  width: min(100%, 37rem);
  min-height: 100svh;
  margin-inline: auto;
  padding: clamp(1rem, 5vw, 1.75rem);
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
}

button {
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.control {
  min-height: 3rem;
  padding: .55rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  border: 1px solid #dac9b4;
  border-radius: 2rem;
  background: #fffaf2;
  font-weight: 650;
}

.mute { margin-inline-start: auto; }
.mute[aria-pressed="true"] { background: #594535; color: #fffaf2; }
.speaker::before { content: "◖))"; font-weight: 800; }
.mute[aria-pressed="true"] .speaker::before { content: "◖×"; }
:focus-visible { outline: 3px solid #80432f; outline-offset: 4px; }

#picker-view, .animal { margin-block: auto; padding-block: 1.25rem; }

.page-title {
  margin: 0 0 .55em;
  text-align: center;
  font-size: clamp(2rem, 10vw, 3.75rem);
}

.picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.7rem, 3vw, 1rem);
}

.picker button, .picture {
  overflow: hidden;
  border-radius: clamp(1.1rem, 6vw, 2.1rem);
  background: #f2dfc5;
}

.picker button {
  padding: 0;
  border: 2px solid #fffaf2;
  box-shadow: 0 3px 0 #d9c4ac, 0 8px 20px #69422214;
}

.picker button:active { box-shadow: 0 1px 0 #d9c4ac; }
img { display: block; width: 100%; height: auto; }

.animal { text-align: center; }
.picture {
  position: relative;
  width: min(100%, 63svh);
  margin-inline: auto;
  border: 3px solid #fffaf2;
  box-shadow: 0 10px 28px #6942221f;
}

h1 {
  margin: .35em 0 0;
  font: 700 clamp(3.3rem, 15vw, 6rem)/1 Georgia, serif;
  letter-spacing: -.045em;
}

@media (max-height: 500px) and (orientation: landscape) {
  main { padding-block: .75rem; }
  #picker-view, .animal { padding-block: .6rem; }
  .picker { width: min(100%, 49svh); margin-inline: auto; }
  .page-title { font-size: 2rem; }
  .picture { width: min(100%, 50svh); }
  h1 { font-size: 2.6rem; }
}

/* Feather the head layer into the original art so the neck and scenery stay put. */
.head-layer {
  display: none;
  position: absolute;
  inset: 0;
  mask-image: radial-gradient(
    ellipse var(--head-width) var(--head-height) at var(--head-x) var(--head-y),
    #000 80%, transparent 100%
  );
}

.picture[data-animal="cat"]   { --head-x: 53%; --head-y: 24%; --head-width: 33%; --head-height: 30%; }
.picture[data-animal="cow"]   { --head-x: 68%; --head-y: 24%; --head-width: 34%; --head-height: 33%; }
.picture[data-animal="horse"] { --head-x: 67%; --head-y: 26%; --head-width: 31%; --head-height: 30%; }

@media (prefers-reduced-motion: no-preference) {
  .picture.moving .head-layer { display: block; }
  .picture.moving .head-layer img {
    transform-origin: var(--head-x) calc(var(--head-y) + 15%);
    animation: lift-head 820ms ease-in-out;
  }
}

@keyframes lift-head {
  42% { transform: translateY(-1.8%) rotate(-9deg); }
}

main {
  --inset: clamp(1rem, 5vw, 1.75rem);
  padding-inline: max(var(--inset), env(safe-area-inset-left)) max(var(--inset), env(safe-area-inset-right));
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: max(.75rem, env(safe-area-inset-bottom));
}

.toolbar { position: relative; z-index: 2; pointer-events: none; }
.toolbar > * { pointer-events: auto; }

.parent-link {
  align-self: center;
  padding-block: .65rem;
  color: #694938;
  font-size: .8rem;
}

.wordmark {
  align-self: center;
  padding: .35rem 1.15rem;
  border-radius: 2rem;
  background: #f1e4d3;
  color: #694938;
  font: 700 .85rem Georgia, serif;
  letter-spacing: .045em;
}

.dog-return {
  position: fixed;
  z-index: 1;
  inset: 0;
  width: 100%;
  border: 0;
  background: transparent;
}

.dog-return:focus-visible { outline-offset: -5px; }
.dog-bark-pose { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .dog-view .picture { animation: reveal-dog 200ms ease-out; }

  .dog-view .dog-bark-pose {
    display: block;
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scaleY(.92);
    transform-origin: 50% 34%;
    transition: opacity 45ms ease-out 55ms, transform 100ms ease-out;
  }

  .dog-view .barking .dog-bark-pose {
    opacity: 1;
    transform: scaleY(1);
    transition-delay: 0s;
  }
}

@keyframes reveal-dog {
  from { opacity: .7; }
}

.credits {
  line-height: 1.5;
}

.credits h1 { font-size: clamp(2.5rem, 12vw, 4rem); }
.credits h2 { margin-bottom: 0; }
.credits a { color: #80432f; }
