@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500&display=swap");

@font-face {
  font-family: "Kremlin Grand Duke";
  src: url("fonts/kremlin-grand-duke.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #082d70;
  --paper: #f4f0e7;
  --gold: #aa7b28;
}

* {
  box-sizing: border-box;
}

html {
  background: #fff;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: "DM Sans", Arial, sans-serif;
}

main {
  min-height: 100vh;
  overflow-x: clip;
}

.masthead {
  display: grid;
  grid-template-columns: 1fr 2.1fr 1fr;
  align-items: end;
  width: min(1500px, 92vw);
  margin: 0 auto;
  padding: 54px 0 20px;
}

.eyebrow,
.instruction,
.tray-caption,
.note-number,
.note-label {
  font-size: 10px;
  line-height: 1.6;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow {
  align-self: start;
  margin: 12px 0 0;
}

h1 {
  margin: 0;
  text-align: center;
  font-family: "Kremlin Grand Duke", Georgia, serif;
  font-size: clamp(62px, 7.8vw, 122px);
  font-weight: 400;
  line-height: 0.78;
  letter-spacing: 0.015em;
}

.intro {
  max-width: 260px;
  justify-self: end;
  font-family: Georgia, serif;
  font-size: 14px;
  font-style: italic;
  line-height: 1.55;
}

.instruction {
  margin-top: 16px;
  opacity: 0.65;
  font-family: "DM Sans", Arial, sans-serif;
  font-style: normal;
}

.table {
  padding: 58px 4vw 20px;
}

.tray {
  position: relative;
  isolation: isolate;
  width: min(1320px, 90vw);
  aspect-ratio: 1.636;
  margin: 0 auto;
}

.tray-image {
  position: absolute;
  top: 15%;
  left: 15%;
  z-index: 0;
  width: 70%;
  height: 70%;
  object-fit: contain;
  filter: drop-shadow(0 24px 30px rgba(35, 30, 20, 0.2));
  pointer-events: none;
}

.trinket {
  position: absolute;
  display: block;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: scale 0.25s ease;
}

.trinket:hover,
.trinket:focus-visible {
  outline: none;
  scale: 1.035;
}

.trinket:hover img,
.trinket:focus-visible img {
  filter:
    drop-shadow(0 20px 14px rgba(8, 32, 65, 0.4))
    drop-shadow(0 5px 5px rgba(8, 32, 65, 0.2))
    drop-shadow(0 0 8px rgba(255, 255, 255, 0.75));
}

.trinket:active {
  cursor: grabbing;
  scale: 1.06;
}

.trinket.returning {
  transition:
    left 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    top 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    scale 0.25s ease;
}

.trinket img {
  display: block;
  width: 100%;
  pointer-events: none;
  filter:
    drop-shadow(0 16px 12px rgba(8, 32, 65, 0.34))
    drop-shadow(0 4px 4px rgba(8, 32, 65, 0.18));
  transition: filter 0.25s ease;
}

.tray-caption {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: min(1230px, 83vw);
  margin: 5px auto 0;
  padding-top: 12px;
  border-top: 1px solid rgba(8, 45, 112, 0.26);
}

.tray-caption > span:last-child {
  text-align: right;
}

/* Scroll chapter: a Gzhel wall that gives way */
.porcelain-story {
  position: relative;
  height: 300vh;
  margin-top: 70px;
  background: #082d70;
}

.porcelain-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 42%, #174995 0, #082d70 62%, #041a43 100%);
}

.porcelain-message {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 8vh 8vw;
  color: #f7f2e7;
  text-align: center;
}

.porcelain-kicker {
  margin: 0 0 28px;
  color: #d8b66b;
  font: 500 10px/1.4 "DM Sans", Arial, sans-serif;
  letter-spacing: 0.23em;
  text-transform: uppercase;
}

.porcelain-message h2 {
  margin: 0;
  font: 400 clamp(56px, 8vw, 128px)/0.8 "Kremlin Grand Duke", Georgia, serif;
  letter-spacing: 0.015em;
}

.porcelain-message > p:last-child {
  width: min(440px, 78vw);
  margin: 34px 0 0;
  font: italic 16px/1.65 Georgia, serif;
  opacity: 0.78;
}

.tile-wall {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: grid;
  width: 100vw;
  grid-template-columns: repeat(8, calc(100vw / 8));
  grid-template-rows: repeat(5, calc(100vw / 8));
  gap: 2px;
  padding: 2px;
  background: transparent;
  perspective: 900px;
  transform: translate(-50%, -50%);
}

.porcelain-tile {
  --fall: 0;
  position: relative;
  min-width: 0;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid rgba(7, 37, 93, 0.22);
  border-radius: 3px;
  background: #f7f3e9;
  box-shadow:
    inset 0 0 22px rgba(8, 45, 112, 0.08),
    0 8px 18px rgba(2, 18, 48, 0.25);
  transform:
    translate3d(calc(var(--drift) * var(--fall)), calc(var(--drop) * var(--fall)), calc(var(--depth) * var(--fall)))
    rotate(calc(var(--spin) * var(--fall)));
  transform-origin: 50% 100%;
  opacity: calc(1 - var(--fall) * 0.16);
  will-change: transform;
}

.porcelain-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.porcelain-cue {
  position: absolute;
  right: 28px;
  bottom: 25px;
  z-index: 3;
  margin: 0;
  color: var(--ink);
  font: 500 9px/1 "DM Sans", Arial, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: opacity 0.25s ease;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1230px, 83vw);
  margin: 0 auto;
  padding: 22px 0 50px;
  font-family: Georgia, serif;
  font-size: 13px;
  font-style: italic;
}

.reset {
  border: 0;
  border-bottom: 1px solid var(--ink);
  padding: 5px 0;
  background: none;
  color: inherit;
  font: 500 10px/1 "DM Sans", Arial, sans-serif;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 28px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  color: inherit;
  font: 500 10px/1 "DM Sans", Arial, sans-serif;
  letter-spacing: 0.13em;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease;
}

.back-link:hover,
.back-link:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 25, 60, 0.32);
  backdrop-filter: blur(6px);
  animation: fade 0.25s ease both;
}

.modal-wrap[hidden] {
  display: none;
}

.note-card {
  position: relative;
  width: min(430px, 92vw);
  min-height: 560px;
  padding: 32px 44px 46px;
  border: 1px solid rgba(170, 123, 40, 0.65);
  background:
    linear-gradient(rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.1)),
    #f6f0e2;
  box-shadow: 0 30px 80px rgba(0, 20, 55, 0.3);
  text-align: center;
  transform: rotate(-0.5deg);
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.note-card::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(8, 45, 112, 0.18);
  pointer-events: none;
}

.note-image {
  width: 130px;
  height: 180px;
  margin: 18px auto 5px;
  object-fit: contain;
  filter: drop-shadow(0 10px 8px rgba(8, 32, 65, 0.18));
}

.note-number {
  margin: 0;
  color: var(--gold);
}

.note-label {
  margin: 12px 0 7px;
  color: var(--gold);
}

.note-card h2 {
  margin: 0;
  font: 400 32px/1.1 Georgia, serif;
}

.note-text {
  max-width: 300px;
  margin: 24px auto 0;
  font: italic 17px/1.65 Georgia, serif;
}

.close {
  position: absolute;
  top: 17px;
  right: 20px;
  z-index: 2;
  border: 0;
  background: none;
  color: var(--ink);
  font: 300 27px/1 sans-serif;
  cursor: pointer;
}

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

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px) rotate(-1.5deg);
  }
}

@media (max-width: 760px) {
  .masthead {
    display: block;
    padding-top: 32px;
    text-align: center;
  }

  .eyebrow {
    margin-bottom: 38px;
  }

  .porcelain-story {
    height: 260vh;
    margin-top: 30px;
  }

  .tile-wall {
    grid-template-columns: repeat(5, 20vw);
    grid-template-rows: repeat(11, 20vw);
  }

  .porcelain-message h2 {
    font-size: clamp(48px, 16vw, 82px);
  }

  .porcelain-cue {
    right: 16px;
    bottom: 18px;
  }

  h1 {
    font-size: clamp(50px, 15vw, 78px);
    line-height: 0.86;
  }

  .intro {
    margin: 34px auto 0;
  }

  .table {
    padding: 20px 0 8px;
  }

  .tray {
    width: 118vw;
    margin-left: -9vw;
  }

  .tray-caption,
  footer {
    width: 88vw;
  }

  footer {
    padding-bottom: 32px;
    flex-direction: column;
    gap: 22px;
    text-align: center;
  }

  .footer-actions {
    flex-wrap: wrap;
    justify-content: center;
  }

  .tray-caption {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .tray-caption .reset {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
