/* Libre Baskerville is licensed under the SIL Open Font License. */
@font-face {
  font-family: "Libre Baskerville";
  src: url("fonts/libre-baskerville.woff") format("woff");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Libre Baskerville";
  src: url("fonts/libre-baskerville-italic.woff") format("woff");
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --cream: #efe3cc;
  --cream-deep: #e2d2b3;
  --paper: #f7f1e3;
  --paper-edge: #e6d9c2;
  --ink: #1c2438;
  --ink-soft: #3a4258;
  --red: #9b1d2e;
  --red-deep: #711422;
  --red-shadow: #4e0d16;
  --red-bright: #b12336;
  --gold: #c5a35a;
  --gold-light: #e0c57a;
  --gold-deep: #8a7340;
  --navy: #1a2744;
  --baize: #1b4a36;
  --baize-lit: #26614a;
  --baize-dark: #123528;
  --wood: #6d3f26;
  --wood-mid: #8a5634;
  --wood-light: #a56b42;
  --wood-dark: #4a2818;
  --brass: #b08d3e;
  --brass-light: #d4b56a;
  --stamp-ink: #3a1c28;
  --focus: #5a3d0e;
  --font: "Libre Baskerville", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  color-scheme: light;
}

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

html {
  block-size: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-block-size: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  overflow-x: hidden;
  max-width: 100%;
  background: var(--cream);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

a {
  color: inherit;
}

.skip {
  position: absolute;
  inset: 0.6rem auto auto 0.6rem;
  transform: translateY(-150%);
  background: var(--navy);
  color: var(--paper);
  padding: 0.5rem 0.8rem;
  z-index: 10;
  text-decoration: none;
  border-radius: 2px;
}

.skip:focus {
  transform: none;
}

.live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.room {
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* --- wall & hanging sign --- */

.wall {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 1.25rem 1rem 0.5rem;
  position: relative;
  background-color: var(--cream);
  background-image:
    radial-gradient(1200px 480px at 50% 0%, rgba(255, 255, 255, 0.38), transparent 70%),
    radial-gradient(900px 500px at 50% 100%, rgba(120, 80, 40, 0.07), transparent 60%),
    repeating-linear-gradient(
      180deg,
      transparent,
      transparent 3px,
      rgba(90, 60, 30, 0.015) 3px,
      rgba(90, 60, 30, 0.015) 4px
    );
  overflow: hidden;
}

.wall::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 12px;
  background: linear-gradient(180deg, #cbb892, #b49a6e 55%, #9d855c);
  box-shadow: 0 2px 0 rgba(70, 50, 20, 0.18);
  z-index: 1;
}

.chains {
  width: min(22rem, 82vw);
  height: auto;
  margin-bottom: -6px;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 0 rgba(255, 230, 180, 0.35));
}

.sign {
  position: relative;
  z-index: 2;
  margin: 0 0 1.4rem;
  width: min(22rem, 82vw);
  padding: 1rem 1.25rem 1.15rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--cream);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(180deg, var(--red) 0%, #8e1a2a 100%);
  border: 3px solid var(--gold);
  box-shadow:
    0 0 0 3px var(--red-deep),
    0 0 0 6px var(--gold-deep),
    0 10px 0 var(--red-shadow),
    0 18px 28px rgba(40, 10, 12, 0.28);
  text-wrap: balance;
}

.sign::before,
.sign::after {
  content: "";
  position: absolute;
  top: 0.55rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--brass) 55%, #6e5420);
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.35);
}

.sign::before { left: 0.55rem; }
.sign::after { right: 0.55rem; }

.sign-ornament {
  color: var(--gold-light);
  margin-bottom: 0.15rem;
  opacity: 0.9;
}

.sign-kicker,
.sign-name,
.sign-role {
  display: block;
}

.sign-kicker {
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--gold-light);
  margin-bottom: 0.1rem;
}

.sign-name {
  font-weight: 700;
  font-size: clamp(1.65rem, 6vw, 2.15rem);
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-transform: lowercase;
  color: #f6ead4;
}

.sign-role {
  margin-top: 0.35rem;
  font-weight: 400;
  font-size: 0.8rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #f0e4ce;
}

/* --- counter --- */

.counter {
  flex: 0 0 auto;
  position: relative;
  z-index: 3;
}

.counter-top {
  position: relative;
  padding: 1.1rem 1rem 0.85rem;
  background-color: var(--wood);
  background-image:
    linear-gradient(180deg, rgba(255, 220, 170, 0.16), transparent 28%),
    linear-gradient(180deg, transparent 70%, rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(
      90deg,
      #6a3c24 0 2px,
      #7d4a2c 3px,
      #8b5534 6px,
      #734428 9px,
      #5e351f 12px,
      #7a492c 16px
    );
  box-shadow: inset 0 1px 0 rgba(255, 220, 180, 0.25);
}

.baize {
  margin: 0 auto;
  width: min(58rem, 100%);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.06), transparent 50%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.04) 2px,
      rgba(0, 0, 0, 0.04) 3px
    ),
    linear-gradient(180deg, var(--baize-lit), var(--baize) 40%, var(--baize-dark));
  border-radius: 6px;
  padding: 1.1rem 1rem 1.3rem;
  box-shadow:
    inset 0 0 0 2px rgba(10, 40, 28, 0.45),
    inset 0 1px 0 rgba(180, 220, 190, 0.18),
    inset 0 -8px 16px rgba(0, 0, 0, 0.18),
    0 1px 0 rgba(255, 210, 150, 0.15);
}

.workspace {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.mail-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(22rem, 100%);
}

.mail {
  position: relative;
  width: 100%;
  aspect-ratio: 1.55 / 1;
  margin-bottom: 2.15rem;
}

.envelope {
  position: absolute;
  inset: 0 6% 10% 6%;
  transform-origin: 50% 55%;
  transform: translate(var(--stack-x, 0px), var(--stack-y, 0px)) rotate(var(--stack-rot, 0deg));
  transition: transform 0.45s ease, opacity 0.35s ease;
  will-change: transform, opacity;
}

.envelope.is-flying {
  transition: none;
  animation: fly-off 0.78s cubic-bezier(0.5, 0, 0.25, 1) forwards;
  z-index: 40 !important;
  pointer-events: none;
}

.envelope.is-fading {
  opacity: 0;
  transition: opacity 0.22s ease;
}

.envelope.is-incoming {
  opacity: 0;
}

.envelope .face {
  position: relative;
  height: 100%;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 30%),
    var(--paper);
  border: 1px solid var(--paper-edge);
  box-shadow:
    0 1px 0 #fff8ea,
    0 10px 18px rgba(20, 10, 0, 0.2);
}

.envelope::before {
  content: "";
  position: absolute;
  inset: 4px -3px -5px 4px;
  background: #e4d5b6;
  border: 1px solid #d3c4a6;
  z-index: -1;
  box-shadow: 0 6px 12px rgba(20, 10, 0, 0.12);
}

.envelope[data-layer="1"] .face { background-color: #f4ecdb; background-image: linear-gradient(180deg, rgba(255,255,255,0.3), transparent 30%); }
.envelope[data-layer="2"] .face { background-color: #f0e6d3; background-image: linear-gradient(180deg, rgba(255,255,255,0.22), transparent 30%); }
.envelope[data-layer="3"] .face { background-color: #eadfc8; background-image: none; }
.envelope[data-layer="4"] .face { background-color: #e5d7bd; background-image: none; }

.letter-corner {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 3.4rem;
  height: 3.9rem;
  border: 1px dashed rgba(155, 29, 46, 0.35);
  border-radius: 1px;
}

.letter-corner::after {
  content: "stamp here";
  position: absolute;
  inset: auto 0 0.15rem;
  text-align: center;
  font-size: 0.45rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(155, 29, 46, 0.45);
}

.letter-lines {
  position: absolute;
  left: 1.1rem;
  right: 5rem;
  top: 42%;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.letter-lines span {
  display: block;
  height: 1px;
  background: rgba(28, 36, 56, 0.16);
}

.letter-lines span:first-child { width: 78%; }
.letter-lines span:nth-child(2) { width: 92%; }
.letter-lines span:last-child { width: 64%; }

.marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.postmark {
  position: absolute;
  transform-origin: center;
  opacity: 0.88;
}

.postmark svg {
  width: 4.7rem;
  height: 4.7rem;
  overflow: visible;
}

.remark {
  margin: 0;
  width: 100%;
  text-align: center;
  min-height: 2.2rem;
}

.remark-text {
  display: inline-block;
  max-width: 100%;
  background: var(--paper);
  color: var(--stamp-ink);
  border: 1.5px solid var(--stamp-ink);
  padding: 0.28rem 0.75rem 0.32rem;
  font-size: 0.92rem;
  line-height: 1.3;
  text-wrap: balance;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.remark.is-empty .remark-text {
  border-style: dashed;
  color: var(--ink-soft);
  opacity: 0.85;
}

.postmark.is-appearing {
  animation: ink-in 0.28s ease both;
}

.remark-text.is-appearing {
  animation: remark-in 0.28s ease both;
}

/* --- stamp --- */

.stamp-station {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 8.5rem;
}

.stamp {
  appearance: none;
  background: none;
  border: 0;
  padding: 0.25rem 0.5rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  position: relative;
  z-index: 2;
  border-radius: 6px;
  min-width: 6.5rem;
  min-height: 8.5rem;
  transition: transform 0.2s ease;
}

.stamp:hover:not(:disabled) .stamp-graphic,
.stamp:focus-visible:not(:disabled) .stamp-graphic {
  transform: translateY(-6px) rotate(-4deg);
}

.stamp:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.stamp:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.stamp.is-stamping .stamp-graphic {
  animation: thunk 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.stamp-graphic {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.28));
  transition: transform 0.2s ease;
}

.stamp-knob {
  width: 2.15rem;
  height: 1.35rem;
  border-radius: 50% 50% 40% 40%;
  background:
    radial-gradient(circle at 30% 30%, #c48455, #7a3f20 55%, #4a2412);
  box-shadow: inset 0 2px 2px rgba(255, 220, 180, 0.35);
}

.stamp-shaft {
  width: 1.15rem;
  height: 2.6rem;
  margin-top: -0.3rem;
  background:
    linear-gradient(90deg, #4a2412, #a05a32 35%, #6b351c 70%, #3d1c0e);
  border-radius: 2px;
}

.stamp-ferrule {
  width: 2.4rem;
  height: 0.55rem;
  margin-top: -1px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brass-light), var(--brass) 50%, #7a5e22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 220, 0.4);
}

.stamp-rubber {
  width: 3.3rem;
  height: 1.35rem;
  margin-top: 1px;
  border-radius: 2px 2px 3px 3px;
  background: linear-gradient(180deg, #5a2028, #3a1218 60%, #2a0c10);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 2px rgba(255, 180, 180, 0.12);
}

.stamp-rubber-type {
  font-size: 0.42rem;
  letter-spacing: 0.02em;
  color: rgba(255, 214, 200, 0.38);
  transform: scaleX(-1);
  user-select: none;
}

.stamp-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: #f3e6c6;
  background: var(--red);
  border: 1px solid var(--gold-deep);
  padding: 0.18rem 0.55rem 0.22rem;
  border-radius: 2px;
  box-shadow: 0 1px 0 var(--red-shadow);
}

.stamp:disabled .stamp-label {
  background: var(--wood-dark);
  border-color: #6a5030;
  color: #d9c8a6;
}

.ink-pad {
  width: 4.4rem;
  height: 0.7rem;
  margin-top: -0.55rem;
  border-radius: 40%;
  background:
    radial-gradient(ellipse at 50% 40%, #6b1d28, #2a0c10 70%);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 210, 160, 0.15);
  position: relative;
  z-index: 1;
}

.nosing {
  height: 0.55rem;
  background: linear-gradient(180deg, var(--brass-light), var(--brass) 45%, #6e5420);
  box-shadow: 0 2px 0 rgba(60, 40, 10, 0.35);
}

.counter-front {
  position: relative;
  min-height: 5.2rem;
  padding: 0.9rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  color: #f3e6c6;
  background-color: var(--wood-dark);
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent 30%),
    repeating-linear-gradient(
      90deg,
      #4a2818 0 3px,
      #5a321e 6px,
      #3e2014 10px,
      #55301c 14px
    );
}

.panels {
  position: absolute;
  inset: 0.55rem 8% 0.55rem;
  display: none;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  pointer-events: none;
}

.panels span {
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 210, 150, 0.1),
    inset 3px 3px 0 rgba(0, 0, 0, 0.18),
    inset -2px -2px 0 rgba(255, 200, 140, 0.06);
}

.tally {
  margin: 0;
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: #f3e6c6;
}

#tally {
  font-variant-numeric: tabular-nums;
  color: var(--gold-light);
}

.fresh {
  position: relative;
  z-index: 1;
  appearance: none;
  display: inline-block;
  background: var(--red);
  color: #f6ead4;
  border: 1px solid var(--gold);
  padding: 0.4rem 0.85rem 0.45rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 0 var(--red-shadow);
  border-radius: 2px;
}

.fresh:hover,
.fresh:focus-visible {
  background: var(--red-bright, #b12336);
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
}

.fresh[hidden] {
  display: none;
}

/* --- 404 --- */

.missing-desk {
  min-height: 12rem;
  justify-content: center;
  position: relative;
}

.missing-outline {
  width: min(22rem, 100%);
  aspect-ratio: 1.55 / 1;
  border: 2px dashed rgba(243, 230, 198, 0.35);
  border-radius: 2px;
  transform: rotate(-1.5deg);
  background: rgba(0, 0, 0, 0.08);
}

.missing-card {
  position: absolute;
  width: min(20rem, 92%);
  background: var(--paper);
  color: var(--ink);
  padding: 1.1rem 1.2rem 1.2rem;
  text-align: center;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
  transform: rotate(1deg);
}

.missing-title {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  font-weight: 700;
  text-wrap: balance;
}

.missing-copy {
  margin: 0 0 0.95rem;
  color: var(--ink-soft);
  font-style: italic;
  text-wrap: balance;
}

/* --- motion --- */

@keyframes thunk {
  0% { transform: translateY(0) rotate(0); }
  28% { transform: translateY(-22px) rotate(-8deg); }
  58% { transform: translateY(7px) rotate(1deg) scaleY(0.88); }
  76% { transform: translateY(-4px) rotate(-2deg) scaleY(1.02); }
  100% { transform: translateY(0) rotate(0) scaleY(1); }
}

@keyframes ink-in {
  from { opacity: 0; transform: scale(1.08) rotate(var(--mark-rot, 0deg)); }
  to { opacity: 0.88; transform: scale(1) rotate(var(--mark-rot, 0deg)); }
}

@keyframes remark-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@keyframes fly-off {
  0% { opacity: 1; }
  60% { opacity: 1; }
  100% {
    transform: translate(var(--fly-x, 80vw), var(--fly-y, -40vh)) rotate(var(--fly-rot, 32deg));
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stamp,
  .stamp-graphic,
  .fresh,
  .envelope {
    transition: none;
  }

  .stamp:hover:not(:disabled) .stamp-graphic,
  .stamp:focus-visible:not(:disabled) .stamp-graphic,
  .stamp.is-stamping .stamp-graphic,
  .postmark.is-appearing,
  .remark-text.is-appearing,
  .envelope.is-flying {
    animation: none;
    transform: none;
  }
}

/* --- breakpoints --- */

@media (min-width: 700px) {
  .wall {
    padding-top: 1.75rem;
    justify-content: center;
  }

  .sign {
    width: min(24rem, 70vw);
    margin-bottom: 0;
    padding: 1.15rem 1.5rem 1.3rem;
  }

  .chains {
    width: min(24rem, 70vw);
  }

  .workspace {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    justify-content: center;
    align-items: end;
    column-gap: 2.5rem;
    row-gap: 0;
    min-height: 15.5rem;
    padding: 0.3rem 1rem 0.2rem;
  }

  .mail-block {
    display: contents;
  }

  .mail {
    grid-column: 1;
    grid-row: 1;
    width: 22.5rem;
  }

  .remark {
    grid-column: 1;
    grid-row: 2;
    width: 22.5rem;
    margin-top: 0;
  }

  .stamp-station {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 0.4rem;
  }

  .panels {
    display: grid;
  }

  .counter-front {
    min-height: 5.8rem;
  }

  .tally {
    background: rgba(40, 18, 12, 0.35);
    border: 1px solid rgba(197, 163, 90, 0.45);
    padding: 0.28rem 0.8rem 0.32rem;
    border-radius: 2px;
  }
}

@media (min-width: 1100px) {
  .sign-name {
    font-size: 2.35rem;
  }

  .mail,
  .remark {
    width: 24rem;
  }
}

@media (max-height: 700px) and (min-width: 700px) {
  .wall {
    justify-content: flex-end;
    padding-top: 0.6rem;
  }

  .sign {
    margin-bottom: 0.8rem;
    padding: 0.75rem 1.2rem 0.9rem;
  }

  .chains {
    height: 40px;
  }
}
