/* Message In A Bottle. A shore at night: the sea stays, the sand under it changes.
   Palette and light read off the reference plate — a violet-black room with warm lamp pools. */

:root {
  --ink: #0a0714;
  --deep: #150f2b;
  --water: #221845;
  --violet: #6b56ab;
  --amber: #ffb45c;
  --ember: #ff8b3d;
  --cream: #f6e7c8;
  --paper: #efdcb4;
  --moon: #e6e0f4;
  --dim: rgba(246, 231, 200, 0.62);
  --edge: rgba(246, 231, 200, 0.22);
  --pixel: "Jersey 15", "Courier New", monospace;
  --body: "Newsreader", Georgia, serif;
  --mono: "DM Mono", "Courier New", monospace;
  --seaH: 40vh;
  --ropeH: 124px;
}

* { box-sizing: border-box; }

html { background: var(--ink); scroll-behavior: smooth; }

body {
  margin: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

h1, h2 {
  font-family: var(--pixel);
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
  color: var(--cream);
}
h1 { font-size: 34px; }
h2 { font-size: 26px; }

a { color: var(--amber); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--deep); color: var(--cream); padding: 12px 16px;
  font-family: var(--pixel); font-size: 18px;
}
.skip:focus { left: 8px; top: 8px; }

:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

/* ============================ the sea ============================ */

.sea {
  position: relative; z-index: 1;
  flex: 0 0 var(--seaH);
  overflow: hidden;
  background: var(--water);
}
.sea-film, .sea-still {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 26%;
}
.sea-still { z-index: 0; }
.sea-film { z-index: 1; }
.sea.no-film .sea-film { display: none; }

.sea-water { position: absolute; inset: 0; z-index: 2; }

.sea-water .drift {
  position: absolute;
  width: var(--w, 46px);
  transform: translate(-50%, -50%) rotate(var(--tilt, -8deg));
  image-rendering: pixelated;
  filter: drop-shadow(0 3px 0 rgba(10, 7, 20, 0.45));
  animation: bob var(--dur, 5s) ease-in-out infinite alternate;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.sea-water .drift img { width: 100%; display: block; }

@keyframes bob {
  from { transform: translate(-50%, calc(-50% - 4px)) rotate(var(--tilt, -8deg)); }
  to { transform: translate(-50%, calc(-50% + 4px)) rotate(calc(var(--tilt, -8deg) * -0.6)); }
}

.sea-read {
  position: absolute; left: 50%; bottom: 10px; z-index: 3;
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--pixel); font-size: 18px; letter-spacing: 0.06em;
  color: var(--moon);
  text-shadow: 0 2px 0 rgba(10, 7, 20, 0.8);
}

/* ======================= the rope along the tide ======================= */

.rope {
  position: relative; z-index: 4;
  flex: 0 0 auto;
  padding-bottom: 8px;
  background:
    linear-gradient(180deg, rgba(10, 7, 20, 0.55) 0%, rgba(10, 7, 20, 0.78) 100%),
    url("/art/sand.webp") center top / cover no-repeat;
}
.rope-line {
  position: absolute; left: 0; right: 0; top: 6px; height: 26px;
  background-image: url("/art/rope.webp");
  background-repeat: repeat-x;
  background-size: auto 26px;
  image-rendering: pixelated;
}
.tags {
  position: relative;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px;
  padding-top: 16px;
}
.tag {
  position: relative;
  width: 108px; height: 104px;
  padding: 34px 6px 0;
  border: 0; background: url("/art/tag.webp") center/100% 100% no-repeat;
  image-rendering: pixelated;
  font-family: var(--pixel); font-size: 20px; letter-spacing: 0.02em;
  color: #3a2a17;
  cursor: pointer;
  transform: translateY(0) rotate(var(--sway, 0deg));
  transition: transform 0.12s ease;
}
.tag:nth-child(odd) { --sway: -1.4deg; }
.tag:nth-child(even) { --sway: 1.2deg; }
.tag:hover { transform: translateY(2px) rotate(0deg); }
.tag[aria-selected="true"] {
  color: #1c1208;
  transform: translateY(8px) rotate(0deg);
  filter: drop-shadow(0 0 10px rgba(255, 180, 92, 0.55));
}

/* ============================ the sand ============================ */

.sand {
  position: relative; z-index: 2;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 20px 60px;
  background:
    linear-gradient(180deg, rgba(10, 7, 20, 0.86) 0%, rgba(10, 7, 20, 0.5) 22%, rgba(10, 7, 20, 0.72) 100%),
    url("/art/sand.webp") center top / cover no-repeat fixed,
    var(--deep);
}

.place { max-width: 1180px; margin: 0 auto; }
.place[hidden] { display: none; }

/* paper surfaces lying on the sand */
.sheet {
  position: relative;
  padding: 34px 52px 32px;
  /* the sheet is cut out of the paper: cover crops the torn edges away and keeps the grain */
  background: url("/art/paper.webp") 50% 58% / cover no-repeat, var(--paper);
  box-shadow: inset 0 0 0 3px rgba(58, 42, 23, 0.55);
  color: #2a1d10;
  image-rendering: auto;
  filter: drop-shadow(0 10px 0 rgba(10, 7, 20, 0.35));
}
.sheet h2 { color: #241708; }
.sheet .sub { color: #4a3826; margin: 0 0 14px; }
.sheet.wide { max-width: 900px; margin: 0 auto; }

.works { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 22px; margin-top: 26px; }

.beach-head h1 { text-shadow: 0 3px 0 rgba(10, 7, 20, 0.8); }
.lead { margin: 0 0 16px; color: var(--dim); max-width: 60ch; }

.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.note-card {
  text-align: left;
  padding: 24px 40px 22px;
  background: url("/art/paper.webp") 50% 58% / cover no-repeat, var(--paper);
  box-shadow: inset 0 0 0 3px rgba(58, 42, 23, 0.45);
  color: #2a1d10;
  border: 0; cursor: pointer;
  font-family: var(--body); font-size: 16px;
  filter: drop-shadow(0 8px 0 rgba(10, 7, 20, 0.35));
}
.note-card b { display: block; font-family: var(--pixel); font-size: 19px; color: #241708; margin-bottom: 6px; }
.note-card .meta { display: block; margin-top: 10px; font-family: var(--mono); font-size: 13px; color: #6b533a; }
.note-card.kept { box-shadow: inset 0 0 0 4px rgba(255, 139, 61, 0.75); }

.empty {
  font-family: var(--pixel); font-size: 20px; color: var(--dim);
  margin: 6px 0 0;
}

/* form pieces */
.field { display: block; margin: 0 0 10px; }
.field > span {
  display: block; font-family: var(--pixel); font-size: 18px; color: #3d2c1a; margin-bottom: 4px;
}
.field em { font-style: normal; font-family: var(--mono); font-size: 13px; color: #6b533a; margin-left: 8px; }
textarea, input[type="text"] {
  width: 100%; padding: 12px 12px;
  background: rgba(255, 252, 244, 0.72);
  border: 2px solid rgba(58, 42, 23, 0.45);
  color: #241708;
  font-family: var(--mono); font-size: 16px;
  resize: vertical;
}
.field.short { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.field.short input { width: 140px; }
.counter { margin: 0 0 12px; font-family: var(--mono); font-size: 14px; color: #6b533a; }
.counter .warn { color: #a3331a; margin-left: 10px; }
.public { margin: 0 0 16px; font-size: 15px; color: #6b3a20; }

.do {
  min-height: 52px; padding: 12px 22px;
  background: #2a1d10; color: var(--cream);
  border: 0; cursor: pointer;
  font-family: var(--pixel); font-size: 21px; letter-spacing: 0.03em;
  box-shadow: 0 6px 0 #150c04;
}
.do:hover { background: #3b2915; }
.do:active { transform: translateY(4px); box-shadow: 0 2px 0 #150c04; }
.do[disabled] { opacity: 0.5; cursor: not-allowed; box-shadow: 0 6px 0 #150c04; }
.do.quiet { background: #5a4227; box-shadow: 0 6px 0 #2e1f0e; }

.say { margin: 10px 0 0; font-family: var(--mono); font-size: 14px; color: #6b3a20; min-height: 1.2em; }
.sheet .say { color: #6b3a20; }

.flagbox { position: relative; }
.flagpic { position: absolute; right: 14px; top: -34px; width: 74px; image-rendering: pixelated; }

/* reads and rows */
.reads { display: flex; flex-wrap: wrap; gap: 22px; margin: 6px 0 16px; }
.reads p { margin: 0; display: flex; flex-direction: column; }
.reads b { font-family: var(--pixel); font-size: 32px; color: #241708; line-height: 1.1; }
.reads span { font-family: var(--mono); font-size: 13px; color: #6b533a; }

.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline;
  padding: 12px 14px;
  background: rgba(255, 252, 244, 0.55);
  border-left: 4px solid rgba(58, 42, 23, 0.5);
  font-family: var(--mono); font-size: 14px; color: #3d2c1a;
}
.row .who { font-family: var(--mono); }
.row .when { color: #6b533a; margin-left: auto; }
.row .said { font-family: var(--body); font-size: 16px; color: #241708; width: 100%; }

.how { margin: 0 0 18px; padding-left: 26px; color: #3d2c1a; }
.how li { margin-bottom: 10px; }
.how b { font-family: var(--pixel); font-size: 19px; color: #241708; }

.ashbox { position: relative; }
.firepic { position: absolute; right: 18px; top: -46px; width: 108px; image-rendering: pixelated; }

/* ==================== what lies on the sand ==================== */

.furniture {
  max-width: 1180px; margin: 46px auto 0;
  display: grid; grid-template-columns: 1fr 1.1fr auto; align-items: end; gap: 26px;
}
.plank { width: 100%; max-width: 420px; image-rendering: pixelated; align-self: center; }

.scratch { padding-bottom: 6px; }
.scratch-label { margin: 0 0 6px; font-family: var(--mono); font-size: 13px; color: var(--dim); }
.scratch-ca {
  margin: 0 0 10px;
  font-family: var(--mono); font-size: 17px; line-height: 1.35;
  color: #d9c49a;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 0 rgba(10, 7, 20, 0.9), 0 0 14px rgba(255, 180, 92, 0.18);
}
.scratch-copy {
  min-height: 48px; padding: 10px 20px;
  background: transparent; color: var(--amber);
  border: 2px dashed rgba(255, 180, 92, 0.55);
  font-family: var(--pixel); font-size: 20px; cursor: pointer;
}
.scratch-copy[disabled] { color: var(--dim); border-color: var(--edge); cursor: not-allowed; }
.scratch .say { color: var(--dim); }

.signpost { position: relative; padding-left: 58px; min-height: 250px; display: flex; align-items: center; }
.signpost .post {
  position: absolute; left: 0; bottom: 0; z-index: 0;
  width: 96px; image-rendering: pixelated;
}
.boards { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; }
.board {
  display: flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 10px 16px;
  background: #6d563a;
  color: #f6e7c8; text-decoration: none;
  font-family: var(--pixel); font-size: 20px; letter-spacing: 0.02em;
  box-shadow: 0 5px 0 #33240f;
  transform: rotate(-0.8deg);
}
.board.big { font-size: 22px; }
.board:nth-child(2) { transform: rotate(0.9deg); }
.board:nth-child(3) { transform: rotate(-0.4deg); }
.board:hover { background: #7e653f; }
.board:active { transform: translateY(3px) rotate(0deg); box-shadow: 0 2px 0 #33240f; }
.board img { width: 22px; height: 22px; object-fit: contain; }
.board[aria-disabled="true"] {
  background: #4a3c2b; color: rgba(246, 231, 200, 0.5);
  box-shadow: 0 2px 0 #2b2116;
  transform: rotate(-3.2deg) translateY(4px);
  cursor: not-allowed;
}

/* ==================== the opened note ==================== */

.opened {
  position: relative;
  width: min(560px, 92vw);
  padding: 34px 52px;
  border: 0;
  background: url("/art/paper.webp") 50% 58% / cover no-repeat, var(--paper);
  box-shadow: inset 0 0 0 3px rgba(58, 42, 23, 0.55);
  color: #2a1d10;
}
.opened::backdrop { background: rgba(6, 4, 12, 0.78); }
.open-bottle {
  position: absolute; right: 30px; top: -30px;
  width: 132px; image-rendering: pixelated;
}
.opened h2 { padding-right: 130px; }
.open-meta { margin: 0 0 12px; font-family: var(--mono); font-size: 13px; color: #6b533a; }
.open-text {
  margin: 0 0 18px; padding: 14px;
  background: rgba(255, 252, 244, 0.6);
  font-size: 19px; line-height: 1.5; color: #241708;
  word-break: break-word;
}
.open-acts { display: flex; flex-wrap: wrap; gap: 10px; }

/* ==================== sizes ==================== */

@media (max-width: 1000px) {
  .works { grid-template-columns: 1fr; }
  .furniture { grid-template-columns: 1fr; justify-items: start; gap: 22px; }
  .signpost { align-self: start; }
}

@media (max-width: 640px) {
  :root { --seaH: 30vh; }
  body { font-size: 16px; }
  h1 { font-size: 28px; }
  h2 { font-size: 23px; }
  .sand { padding: 22px 16px 48px; background-attachment: scroll; }
  .sheet { padding: 30px 32px 28px; }
  .note-card { padding: 22px 26px 20px; }
  .opened { padding: 30px 32px; }

  .tags { gap: 2px; padding-top: 10px; }
  .tag { width: 70px; height: 68px; padding-top: 22px; font-size: 16px; letter-spacing: 0; }
  .reads { gap: 16px; }
  .reads b { font-size: 26px; }
  .notes { grid-template-columns: 1fr; }

  .sea-read { font-size: 15px; width: 94%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .plank { max-width: 320px; }
  .boards { padding-bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sea-film { display: none; }
  .sea-water .drift { animation: none; }
  .tag, .do, .board { transition: none; }
}
