:root {
  --paper: #f3ecd9;
  --paper-deep: #e6dcc3;
  --ink: #2b241a;
  --ink-soft: rgba(43, 36, 26, 0.55);
  --rule: rgba(43, 36, 26, 0.35);
  --wax: #a5402d;
  --brass: #a98a45;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Libre Caslon Text", Georgia, serif;
  background: var(--paper);
  overflow: hidden;
}

/* ---------------------------------------------------------------- paper */

.paper {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(120, 95, 50, 0.13) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.17 0 0 0 0 0.14 0 0 0 0 0.10 0 0 0 0.08 0'/></filter><rect width='260' height='260' filter='url(%23g)'/></svg>");
}

/* double-rule sheet border, like a patent drawing margin */
.sheet-rule {
  position: fixed;
  inset: 18px;
  z-index: 3;
  pointer-events: none;
  border: 1px solid var(--rule);
  outline: 1px solid var(--rule);
  outline-offset: 4px;
}

#machine {
  position: fixed;
  inset: 0;
  z-index: 2;
  width: 100vw;
  height: 100dvh;
  display: block;
}

.titleblock,
.margin-notes {
  position: fixed;
  z-index: 4;
}

/* ----------------------------------------------------------- titleblock */

.titleblock {
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}

.tb-kicker {
  margin: 0 0 4px;
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.tb-title {
  margin: 0;
  font-weight: 400;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.tb-title::after {
  content: "";
  display: block;
  width: 60%;
  margin: 6px auto 0;
  border-bottom: 1px solid var(--rule);
}

.tb-sub {
  margin: 6px 0 0;
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

/* --------------------------------------------------------- margin notes */

.margin-notes {
  left: 44px;
  bottom: 44px;
  width: 220px;
}

.mn-label {
  margin: 0 0 2px;
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.mn-big {
  margin: 0 0 4px;
  line-height: 1;
}

.mn-big b {
  font-weight: 400;
  font-size: clamp(2rem, 4.6vw, 3rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.mn-big span {
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.mn-small {
  margin: 0 0 16px;
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.mn-fig {
  margin: 0 0 16px;
  font-style: italic;
  font-size: 0.86rem;
  line-height: 1.35;
  border-left: 2px solid var(--wax);
  padding-left: 10px;
}

.mn-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ink-btn {
  appearance: none;
  padding: 7px 10px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}

.ink-btn:hover,
.ink-btn:focus-visible {
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

.ink-btn:focus-visible {
  outline: 2px solid var(--wax);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- intro */

.intro {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(243, 236, 217, 0.86);
  backdrop-filter: blur(2px);
  transition: opacity 800ms ease;
}

.intro.gone {
  opacity: 0;
  pointer-events: none;
}

.intro-sheet {
  text-align: center;
  padding: 44px 6vw 36px;
  max-width: 640px;
  border: 1px solid var(--rule);
  outline: 1px solid var(--rule);
  outline-offset: 5px;
  background: var(--paper);
  box-shadow: 0 30px 60px rgba(60, 45, 20, 0.18);
}

.intro-title {
  margin: 8px 0 18px;
  font-weight: 400;
  font-size: clamp(2.2rem, 7vw, 3.8rem);
  line-height: 1.02;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.intro-copy {
  margin: 0 auto 30px;
  max-width: 50ch;
  font-size: 0.86rem;
  line-height: 1.7;
  font-style: italic;
  color: rgba(43, 36, 26, 0.85);
}

.seal {
  appearance: none;
  position: relative;
  width: 118px;
  height: 118px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #c65a44 0%, var(--wax) 42%, #7d2d20 100%);
  color: #f6dcc9;
  cursor: pointer;
  box-shadow:
    0 2px 0 #5d2016,
    0 10px 22px rgba(90, 30, 20, 0.35),
    inset 0 -3px 6px rgba(0, 0, 0, 0.25);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.seal:hover {
  transform: translateY(-2px);
}

.seal:active {
  transform: translateY(2px) scale(0.98);
  box-shadow:
    0 0 0 #5d2016,
    0 4px 10px rgba(90, 30, 20, 0.35),
    inset 0 3px 6px rgba(0, 0, 0, 0.3);
}

.seal:focus {
  outline: none;
}

.seal:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

.seal-ring {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px dashed rgba(246, 220, 201, 0.7);
}

.seal-text {
  position: relative;
  display: block;
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.62rem;
  line-height: 1.35;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.signature {
  margin: 26px 0 0;
  font-family: "Homemade Apple", cursive;
  font-size: 1.15rem;
  color: rgba(43, 36, 26, 0.8);
  transform: rotate(-3deg);
}

.signature span {
  font-family: "Courier Prime", ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-left: 8px;
}

/* ------------------------------------------------------------- mobile */

@media (max-width: 720px) {
  .titleblock {
    top: 28px;
    white-space: normal;
    width: 86vw;
  }

  .tb-kicker {
    display: none;
  }

  .margin-notes {
    left: 30px;
    bottom: 30px;
    width: 180px;
  }

  .mn-fig {
    display: none;
  }

  .sheet-rule {
    inset: 12px;
  }
}

/* ------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  .intro {
    transition: opacity 150ms ease;
  }

  .seal {
    transition: none;
  }
}
