@font-face {
  font-family: "Bradley DJR";
  src: url("/fonts/bradley-djr.woff2") format("woff2");
  font-display: swap;
}

:root {
  --paper: #f5f2e9;
  --cream: #f8f4e3;
  --sepia: #704214;
  --sepia-dark: #55310e;
  --ink: #3b2410;
  --grain: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAQMAAAAk8RryAAAABlBMVEUAAAAAAAClZ7nPAAAAAnRSTlMAGovxNEIAAAAOSURBVBiVY2AYBaMAAAJJAAFEkgPyAAAAAElFTkSuQmCC");
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Playfair Display", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

[hidden] {
  display: none !important;
}

.handwritten {
  font-family: "Homemade Apple", cursive;
  font-weight: 400;
}

/* ---------- screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  animation: fade-in 0.35s ease both;
}

.paper {
  background: var(--paper);
}

.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.1;
  pointer-events: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ---------- buttons ---------- */

.btn {
  position: relative;
  z-index: 1;
  width: min(100%, 340px);
  padding: 16px 24px;
  border: 1px solid var(--sepia);
  border-radius: 10px;
  background: var(--sepia);
  color: var(--paper);
  font: inherit;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: clamp(1.3rem, 6.2vw, 1.65rem);
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.btn:active {
  transform: scale(0.96);
  background: var(--sepia-dark);
}

.btn.outline {
  background: transparent;
  color: var(--sepia);
}

.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid #e58a2c;
  outline-offset: 3px;
}

.icon-btn {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 12px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.35);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- welcome ---------- */

#welcome {
  gap: 18px;
  text-align: center;
}

#welcome h1 {
  margin: 8px 0 0;
  font-family: "Bradley DJR", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.2rem, 11vw, 3.2rem);
  line-height: 1.15;
  color: var(--ink);
}

#hogging {
  padding-inline: clamp(36px, 10vw, 96px);
}

/* app.js sizes the font so the longer line exactly fills the space between
   the side padding. */
.hog-text {
  margin: 0;
  color: #000;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 400;
  line-height: 1.15;
  text-align: center;
}

.hog-text span {
  display: block;
  white-space: nowrap;
}

.sample-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 112px;
  padding: 8px 8px 22px;
  background: var(--cream);
  box-shadow: 0 10px 24px rgb(60 36 16 / 0.22), 0 2px 4px rgb(60 36 16 / 0.15);
  transform-origin: top center;
  animation: sway 4s ease-in-out infinite;
}

.sample-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: linear-gradient(160deg, #3a2a1c, #1d140c);
  font-size: 2rem;
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(3deg);
  }
}

.error {
  max-width: 340px;
  margin: 0;
  color: #9b2c1a;
  font-size: 0.95rem;
  line-height: 1.45;
}

/* ---------- camera ---------- */

.camera {
  padding: 0;
  background: #000;
  color: #fff;
}

.camera video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* contain, not cover: zooming the preview would shrink the capture area to
     a fraction of the sensor and throw away resolution. */
  object-fit: contain;
  transform: scaleX(-1); /* mirror, like looking in a mirror */
}

/* The capture area. Everything outside it is dimmed, so what you see inside
   the frame is exactly what ends up on the strip. */
.frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100vw - 4px, (100dvh - 112px) * 4 / 3);
  aspect-ratio: 4 / 3;
  border: 2px solid rgb(255 255 255 / 0.85);
  border-radius: 6px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.55);
}

.get-ready {
  margin: 0;
  padding: 14px 22px;
  border-radius: 10px;
  background: rgb(0 0 0 / 0.5);
  font-size: 1.3rem;
  text-align: center;
}

.countdown {
  position: absolute;
  font-size: clamp(6rem, 30vw, 11rem);
  line-height: 1;
  text-shadow: 0 4px 24px rgb(0 0 0 / 0.5);
}

.countdown.tick {
  animation: tick 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes tick {
  from {
    transform: scale(2);
    opacity: 0;
  }
  35% {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.9);
    opacity: 0.9;
  }
}

.dots {
  position: absolute;
  bottom: calc(28px + var(--safe-bottom));
  display: flex;
  gap: 10px;
}

.dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.45);
  transition: background-color 0.2s;
}

.dots span.done {
  background: #4ade80;
}

/* Full-screen white flash; on a phone it doubles as a front "flash" that
   lights up faces right as the frame is grabbed. */
.flash {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.flash.on {
  opacity: 1;
}

.flash.off {
  opacity: 0;
  transition: opacity 0.45s ease-out;
}

/* ---------- printing ---------- */

#printing {
  justify-content: flex-start;
  gap: 18px;
  padding-top: calc(28px + var(--safe-top));
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.2rem;
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* Width that keeps the whole strip on screen, given its aspect ratio
   (height / width) which app.js sets as --strip-ratio. */
.printer {
  --strip-w: min(64vw, 230px, (100dvh - 330px) / var(--strip-ratio, 2.9));
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.slot {
  position: relative;
  z-index: 2;
  width: calc(var(--strip-w) + 44px);
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(#1d140c, #3a2a1c);
  box-shadow: 0 3px 6px rgb(0 0 0 / 0.3) inset, 0 1px 0 rgb(255 255 255 / 0.4);
}

.paper-window {
  margin-top: -7px;
  padding: 0 14px 20px;
  overflow: hidden;
}

.print-strip {
  display: block;
  width: var(--strip-w);
  box-shadow: 0 8px 18px rgb(60 36 16 / 0.28);
  transform: translateY(-101%);
}

/* The strip feeds out of the slot in jerky steps, like a real printer. */
.print-strip.go {
  animation: feed 4.2s 0.6s both;
}

@keyframes feed {
  0% {
    transform: translateY(-101%);
    animation-timing-function: ease-out;
  }
  22% {
    transform: translateY(-74%);
    animation-timing-function: ease-in-out;
  }
  28% {
    transform: translateY(-72%);
    animation-timing-function: ease-out;
  }
  50% {
    transform: translateY(-40%);
    animation-timing-function: ease-in-out;
  }
  56% {
    transform: translateY(-38%);
    animation-timing-function: ease-out;
  }
  80% {
    transform: translateY(-6%);
    animation-timing-function: cubic-bezier(0.3, 1.4, 0.5, 1);
  }
  100% {
    transform: translateY(0);
  }
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: auto;
  animation: fade-in 0.5s ease both;
}

@media (prefers-reduced-motion: reduce) {
  .sample-strip,
  .pulse {
    animation: none;
  }
  .print-strip.go {
    animation-duration: 1.2s;
  }
}
