/* castle.css - "A Benevolent Castle": pixel-art rooms, dark stone and candlelight. Shared by every page. */
:root {
  --ink: #11161f;
  --ink-deep: #0b0f16;
  --slate: #2b3a4a;
  --fog: #8aa0a8;
  --parchment: #e6d8b8;
  --parchment-deep: #c9b48a;
  --candle: #f2b35c;
  --candle-hot: #ffd58f;
  --wax: #b3261e;
  --wax-deep: #5c130f;
  --wood: #6b4a2b;
  --wood-deep: #1a120c;
  --panel: #161d2a;
  --text: #e6d8b8;
  --text-soft: #b9a988;
  --pixel: "Pixelify Sans", ui-monospace, monospace;
  --serif: "EB Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

body.castle {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.castle a { color: var(--candle); }
.castle a:hover { color: var(--candle-hot); }
.castle img.px, .castle .px img { image-rendering: pixelated; }

/* Hidden but read aloud. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Framed boxes ---------- */
.box {
  background: var(--panel);
  border: 4px solid var(--slate);
  box-shadow: 0 0 0 4px var(--ink-deep);
  padding: 20px 22px;
}
.box--wood { background: var(--wood-deep); border-color: var(--wood); }
.box--parchment {
  background: var(--parchment);
  color: #2a1d12;
  border-color: var(--wood);
  box-shadow: 0 0 0 4px var(--ink-deep), inset 0 0 60px var(--parchment-deep);
}
.box--parchment a { color: var(--wax); }
.box--parchment a:hover { color: var(--wax-deep); }

.pixel-h {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 600;
  color: var(--candle);
  line-height: 1.2;
}
.box--parchment .pixel-h { color: var(--wax); }
.kicker { font-family: var(--pixel); font-size: 14px; letter-spacing: 1px; color: var(--fog); }

.btn {
  font-family: var(--pixel);
  font-size: 16px;
  color: #f6e7c4;
  background: var(--wax);
  border: 3px solid var(--wax-deep);
  padding: 10px 16px;
  cursor: pointer;
}
.btn:hover { background: #c8352b; }
.field {
  font: inherit;
  font-size: 18px;
  padding: 10px 12px;
  background: #fffaf0;
  color: #2a1d12;
  border: 3px solid var(--wood);
  min-width: 0;
}

/* ---------- The main room (landing page) ---------- */
.room {
  position: relative;
  max-width: 1600px;
  margin: 0 auto;
  background: var(--ink-deep);
}
.room > img { display: block; width: 100%; height: auto; }
.room { overflow: hidden; }
.scene-layer { position: absolute; background-repeat: no-repeat; pointer-events: none; }
.scene-group { position: absolute; display: block; transition: transform .25s ease-out, filter .25s ease-out; }
.scene-group.is-hover {
  transform: translateY(-1.5%) rotate(-0.6deg);
  filter: drop-shadow(0 0 2px #ffe6a8) drop-shadow(0 0 10px rgba(255, 190, 90, .75));
}
.scene-group.no-glow.is-hover { transform: none; filter: none; }
.scene-group.no-lift.is-hover { transform: none; }
.scene-group-paper.is-hover { filter: brightness(1.3) drop-shadow(0 0 2px #fff0c8) drop-shadow(0 0 7px rgba(255, 200, 110, .95)); }
/* The card catalogue stands against the fire-lit hearth, so it needs a brighter glow than the dark objects to show up. */
.scene-group-catalogue.is-hover { filter: brightness(1.25) drop-shadow(0 0 1px #fff4d0) drop-shadow(0 0 3px #ffe6a8) drop-shadow(0 0 14px rgba(255, 200, 110, .95)); }
.scene-layer.only-on-hover { opacity: 0; transition: opacity .25s ease-out; }
.scene-layer.only-on-hover.lit { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .scene-group.is-hover { transform: none; } }
.room-title {
  position: absolute; left: 0; top: 0;
  padding: clamp(12px, 2vw, 24px) clamp(14px, 2.4vw, 30px);
  text-shadow: 0 2px 0 var(--ink-deep), 0 0 12px var(--ink-deep);
}
.room-title h1 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 600;
  font-size: clamp(22px, 2.6vw, 38px);
  color: #f6e7c4;
  letter-spacing: 1px;
}
.room-title p { margin: 2px 0 0; font-style: italic; font-size: clamp(15px, 1.4vw, 20px); color: var(--parchment); }
.room-title .wip-sign {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  font-family: var(--pixel);
  font-style: normal;
  font-size: clamp(11px, 0.95vw, 14px);
  color: #2a1d12;
  text-shadow: none;
  background: var(--candle);
  border: 3px solid #8a5a1e;
  box-shadow: 0 0 0 3px var(--ink-deep);
  transform: rotate(-2deg);
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--pixel);
  font-size: clamp(12px, 1.05vw, 16px);
  white-space: nowrap;
  text-decoration: none;
  color: #f6e7c4 !important;
  background: var(--wood-deep);
  border: 3px solid var(--wood);
  box-shadow: 0 0 0 3px var(--ink-deep);
  padding: 6px 10px;
  transition: background .12s, border-color .12s;
}
.hotspot:hover, .hotspot:focus-visible, .hotspot.is-lit { background: #3a2412; border-color: var(--candle); outline: none; }
.hotspot::before { content: "▸ "; }

/* A hidden link over the loose page on the desk: invisible itself; hovering it lights the paper (a scene layer) and names it. */
.secret {
  position: absolute;
  transform: translate(-50%, -50%);
}
.secret:hover, .secret:focus-visible { outline: none; }
.secret::after {
  content: "blueprints";
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  font-family: var(--pixel);
  font-size: 13px;
  white-space: nowrap;
  color: #f6e7c4;
  background: var(--wood-deep);
  border: 3px solid var(--candle);
  box-shadow: 0 0 0 3px var(--ink-deep);
  padding: 4px 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.secret:hover::after, .secret:focus-visible::after { opacity: 1; }

.room-nav { display: none; }

.below {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 48px;
}
.welcome {
  position: relative;
  display: flex;
  gap: 22px;
  align-items: center;
  margin-top: clamp(-70px, -5vw, -24px);
}
.welcome img { width: clamp(84px, 9vw, 128px); height: auto; flex: none; }
.welcome-portrait { flex: none; display: block; line-height: 0; transition: transform .15s; }
.welcome-portrait:hover, .welcome-portrait:focus-visible { transform: rotate(-3deg) scale(1.05); outline: none; }
.welcome-portrait img { display: block; }
.welcome-portrait .welcome-full { display: none; } /* the head-to-toe Ben, used on phones */
.welcome p { margin: 0; font-size: clamp(19px, 1.7vw, 23px); line-height: 1.5; }

.subscribe {
  position: relative;
  margin: 40px auto 0;
  max-width: 720px;
}
.subscribe .letter { position: absolute; right: -14px; top: -28px; width: 84px; transform: rotate(8deg); }
.subscribe p { margin: 6px 0 14px; font-size: 18px; }
.subscribe form { display: flex; flex-wrap: wrap; gap: 8px; }
.subscribe .field { flex: 1 1 220px; }
.form-note { margin: 10px 0 0; font-size: 16px; font-style: italic; min-height: 1em; }

.foot {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 3px solid #3a2a1c;
  font-size: 17px;
  font-style: italic;
  color: var(--fog);
  display: flex;
  gap: 14px;
  align-items: center;
}
.foot img { width: 64px; height: auto; flex: none; }

@media (max-width: 760px) {
  /* On a phone: no room painting, just the title, the welcome, then the furniture as tiles to tap. */
  .room > :not(.room-title) { display: none; }
  /* Title on the left, the "site in progress" sign beside it on the right, in one row. */
  .room-title { position: static; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 2px; }
  .room-title h1 { font-size: clamp(15px, 4.6vw, 20px); line-height: 1.15; white-space: nowrap; }
  .room-title p:not(.wip-sign) { display: none; } /* no "essays, notes, and a cat" subtitle on phones */
  .room-title .wip-sign { flex: none; max-width: 122px; margin: 0; padding: 3px 7px; font-size: 10px; line-height: 1.3; text-align: center; }
  /* Walk the room: a dotted path down the middle, the furniture alternating sides, each with a small wooden sign. */
  /* Kept to phone width even on a wider small screen, so the furniture stays a sensible size. */
  .room-nav { position: relative; display: block; max-width: 440px; margin: 8px auto 0; padding: 4px 0 16px; }
  .room-nav::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 3px dotted #5a3d1c; }
  .room-nav a { position: relative; display: flex; align-items: center; gap: 12px; margin: 8px 0; text-decoration: none; }
  .room-nav a:nth-child(even) { flex-direction: row-reverse; text-align: right; }
  .room-nav .thing { position: relative; flex: none; width: var(--w, 50%); aspect-ratio: var(--ar, 1); background: radial-gradient(circle at 50% 60%, #4a2a14, transparent 70%); }
  .room-nav .thing img { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; image-rendering: pixelated; transition: transform .2s; }
  .room-nav a:hover .thing img, .room-nav a:focus-visible .thing img { transform: translateY(-4px) rotate(-1deg); }
  .room-nav a:focus-visible { outline: none; }
  /* The sleeping cat on the armchair's seat, as in the desktop scene. */
  .room-nav .thing-cat { position: absolute; left: 22.2%; top: 33%; width: 43.1%; aspect-ratio: 222 / 141; background: url(castle/cat.png) 0 0 / 1100% 100% no-repeat; image-rendering: pixelated; }
  .room-nav .sign { position: relative; z-index: 1; padding: 6px 10px 8px; background: var(--wood-deep); border: 3px solid var(--wood); box-shadow: 0 4px 0 #0009; }
  .room-nav a:hover .sign, .room-nav a:focus-visible .sign { border-color: var(--candle); }
  .room-nav b { display: block; font-family: var(--pixel); font-weight: 600; font-size: 16px; color: var(--candle); white-space: nowrap; }
  .room-nav small { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--text-soft); }
  .below { padding: 0 16px 40px; }
  /* A compact welcome: the portrait beside the text rather than above it. */
  .welcome { margin-top: 10px; padding: 12px 14px; flex-direction: row; align-items: flex-start; gap: 12px; }
  .welcome-portrait img:not(.welcome-full) { display: none; }
  .welcome-portrait .welcome-full { display: block; width: 50px; }
  .welcome p { font-size: 16.5px; line-height: 1.45; }
  .subscribe .letter { width: 60px; right: -6px; top: -22px; }
}

/* ---------- Room pages: a backdrop with the room's name on it ---------- */
.backdrop {
  position: relative;
  max-width: 1600px;
  margin: 0 auto;
  background: var(--ink-deep);
}
.backdrop > img {
  display: block;
  width: 100%;
  height: clamp(260px, 42vw, 560px);
  object-fit: cover;
  object-position: 50% 50%;
}
.backdrop .back {
  position: absolute; left: clamp(12px, 2vw, 24px); top: clamp(12px, 2vw, 20px);
  font-family: var(--pixel);
  font-size: 15px;
  text-decoration: none;
  color: #f6e7c4 !important;
  background: var(--wood-deep);
  border: 3px solid var(--wood);
  box-shadow: 0 0 0 3px var(--ink-deep);
  padding: 8px 12px;
}
.backdrop .back:hover { border-color: var(--candle); }
.plaque {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
  min-width: min(560px, 90vw);
  text-align: center;
  background: var(--wood-deep);
  border: 4px solid var(--wood);
  box-shadow: 0 0 0 4px var(--ink-deep), 0 14px 30px #00000080;
  padding: 14px 24px;
}
.plaque h1 { margin: 0; font-family: var(--pixel); font-weight: 600; font-size: clamp(24px, 3vw, 36px); color: #f6e7c4; }
.plaque p { margin: 4px 0 0; font-style: italic; font-size: 18px; color: var(--text-soft); }

.room-page {
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(64px, 8vw, 90px) 20px 56px;
}
.room-page--wide { max-width: 1180px; }

/* Essay list on the desk */
.entries { list-style: none; margin: 0; padding: 0; }
.entries a {
  display: flex;
  gap: 18px;
  align-items: baseline;
  padding: 14px 4px;
  border-bottom: 1px solid var(--slate);
  text-decoration: none;
  color: var(--text);
}
.entries a:hover { color: #fff3d6; background: #1a2230; }
.entries .when { flex: none; width: 110px; font-family: var(--pixel); font-size: 14px; color: var(--fog); }
.entries .what { flex: 1; min-width: 0; font-size: 23px; line-height: 1.25; }
@media (max-width: 560px) {
  .entries a { display: block; }
  .entries .when { display: block; width: auto; margin-bottom: 4px; }
}

/* Thirty nights */
/* Each night is a candle standing on a paper slip with its night and title; nights to come get a dark, blank slip. */
.candles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 18px 12px; margin: 22px 0; }
.candles .night { display: flex; flex-direction: column; align-items: center; text-decoration: none; }
.candles img { display: block; width: 62px; height: auto; position: relative; z-index: 1; margin-bottom: -6px; }
.candles .unlit { opacity: .45; }
.candles .lit { filter: drop-shadow(0 0 7px #f2b35caa); }
.candles .slip { width: 100%; min-height: 86px; padding: 9px 9px 10px; background: #efe3c6 url(castle/sketches/parchment.jpg) center/cover; background-blend-mode: multiply; color: #3a2814; text-align: center; box-shadow: 0 6px 12px #00000060; transform: rotate(var(--tilt, -1deg)); transition: transform .2s, box-shadow .2s; }
.candles .night:nth-child(3n) .slip { --tilt: 1.2deg; }
.candles .night:nth-child(3n+1) .slip { --tilt: -0.6deg; }
.candles .slip b { display: block; font-family: var(--pixel); font-weight: 400; font-size: 11px; letter-spacing: 1px; color: #7a6446; }
.candles .slip span { display: block; margin-top: 3px; font-size: 15px; line-height: 1.15; }
.candles a.night:hover .slip, .candles a.night:focus-visible .slip { transform: rotate(0) translateY(-3px); box-shadow: 0 0 22px 4px #f2b35c66, 0 6px 12px #00000060; }
.candles a.night:focus-visible { outline: none; }
.candles .night.dark .slip { min-height: 40px; background: #2a2116; color: #6d6252; box-shadow: none; }
.candles .night.dark .slip b { color: #5d5444; }
@media (max-width: 560px) {
  .candles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 8px; }
  .candles img { width: 48px; }
  .candles .slip { min-height: 74px; padding: 7px 6px 8px; }
  .candles .slip span { font-size: 14px; }
}

/* Friends & guestbook */
.blogroll { display: flex; flex-direction: column; gap: 6px; font-size: 21px; }
.badge-88 {
  display: inline-block; vertical-align: middle;
  width: 88px; height: 31px;
  border: 2px solid var(--wood);
  background: var(--wood-deep);
  color: var(--candle);
  font-family: var(--pixel); font-size: 11px; line-height: 27px; text-align: center;
}
/* Postcards pinned to the door, each a link to a friend's blog. */
.postcards {
  list-style: none;
  margin: 0;
  padding: 8px 4px 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 26px 22px;
}
.postcards li:nth-child(3n+1) a { transform: rotate(-2deg); }
.postcards li:nth-child(3n+2) a { transform: rotate(1.5deg); }
.postcards li:nth-child(3n) a { transform: rotate(-0.8deg); }
.postcards a {
  position: relative;
  display: block;
  background: #f6ecd4;
  padding: 8px 8px 0;
  box-shadow: 0 6px 14px #00000080;
  text-decoration: none;
  transition: transform .15s;
}
.postcards a::before {
  /* the pin */
  content: "";
  position: absolute; z-index: 1; left: 50%; top: -6px;
  width: 12px; height: 12px; margin-left: -6px;
  background: var(--wax);
  border: 2px solid var(--wax-deep);
  border-radius: 50%;
}
.postcards a:hover, .postcards a:focus-visible { transform: rotate(0) scale(1.04); outline: none; }
.postcards a > img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px 8px 4px; }
.pc-name { font-size: 19px; font-style: italic; color: #2a1d12; line-height: 1.2; }
.pc-stamp {
  flex: none;
  width: 34px; height: 34px;
  object-fit: cover;
  background: #fff;
  border: 2px dashed #a88d63;
  padding: 2px;
}
.pc-stamp--emoji { display: grid; place-items: center; font-size: 20px; line-height: 1; }

.guest { padding: 10px 0; border-bottom: 1px dashed #a88d63; }
.guest .who { font-family: var(--pixel); font-size: 13px; color: var(--wood); }
.stack { display: flex; flex-direction: column; gap: 32px; }

/* ---------- Existing pages moved into the castle ---------- */
/* Gifts: the cabinet. The cat greets you alone, then the gifts stand on shelves with hanging signs, and she tells you about whichever you pick up. */
.cat-intro {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background: linear-gradient(#0b0f16bb, #0b0f16ee), url(castle/cabinet.jpg) center / cover;
  image-rendering: pixelated;
  transition: opacity .5s ease-out;
}
.cat-intro .back {
  position: absolute; left: 20px; top: 18px;
  font-family: var(--pixel); font-size: 15px; text-decoration: none; color: #f6e7c4 !important;
  background: var(--wood-deep); border: 3px solid var(--wood); box-shadow: 0 0 0 3px var(--ink-deep); padding: 8px 12px;
}
.cat-stage { width: min(720px, 100%); text-align: center; }
.cat-stage > img {
  width: clamp(150px, 26vw, 230px); height: auto; margin-bottom: -6px;
  border: 5px solid var(--wood); box-shadow: 0 0 0 5px var(--ink-deep), 0 20px 50px #000000aa; background: var(--wood-deep);
}
.cat-box { position: relative; margin-top: 26px; text-align: left; min-height: 150px; }
.cat-box b, .narrator b { display: block; font-family: var(--pixel); font-weight: 600; font-size: 15px; letter-spacing: 1px; color: var(--candle); margin-bottom: 4px; }
.cat-line { margin: 0; font-size: 22px; min-height: 3em; }
.cat-choices { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 14px; }
.cat-choices[hidden] { display: none; }
.cat-choices button, .cat-choices a {
  position: relative; padding: 4px 0 4px 22px; cursor: pointer; text-decoration: none;
  font-family: var(--pixel); font-size: 18px; color: #f6e7c4 !important; background: none; border: 0;
}
.cat-choices button::before, .cat-choices a::before { content: "▸"; position: absolute; left: 0; color: var(--candle); opacity: 0; }
.cat-choices .wares::before, .cat-choices :hover::before, .cat-choices :focus-visible::before { opacity: 1; }
.cat-choices :focus-visible { outline: none; color: var(--candle-hot) !important; }
.cat-intro.gone { opacity: 0; visibility: hidden; pointer-events: none; position: absolute; inset: 0; transition: opacity .5s ease-out, visibility 0s .5s; }
.wares-area { padding-bottom: 260px; opacity: 0; transition: opacity .6s ease-out .2s; }
body.showing-wares .wares-area { opacity: 1; }
body:not(.showing-wares) .wares-area { display: none; }

.cabinet {
  max-width: 1180px; margin: clamp(64px, 8vw, 90px) auto 0; padding: 28px clamp(14px, 3vw, 34px) 34px;
  background: linear-gradient(#1f150d, #160f09); border: 10px solid var(--wood);
  box-shadow: 0 0 0 4px var(--ink-deep), inset 0 0 80px #000000aa, 0 30px 60px #000000aa;
}
.shelf { margin: 0 0 40px; padding-top: 4px; text-align: center; background: radial-gradient(ellipse at 50% 30%, #f2b35c1c, transparent 70%); }
.shelf h2 {
  display: inline-block; margin: 0 0 22px; padding: 4px 16px; white-space: nowrap;
  font-family: var(--pixel); font-weight: 600; font-size: 15px; letter-spacing: 1px; color: #3a2610;
  background: linear-gradient(#f3d28a, #c9963f 55%, #a87a2c); border: 2px solid #5c3f17; box-shadow: 0 2px 0 #00000088;
}
.shelf-row { display: flex; flex-wrap: wrap; gap: 30px 22px; justify-content: center; align-items: flex-start; }
.shelf-row + .shelf-row { margin-top: 30px; }
.shelf-item { position: relative; min-width: 110px; padding: 0; border: 0; background: none; cursor: pointer; color: inherit; font: inherit; }
.shelf-item:focus-visible { outline: none; }
/* The frame hugs the picture: every picture is the same height and as wide as its own shape. */
.shelf-frame { display: block; width: fit-content; margin: 0 auto; border: 4px solid #4a3220; background: #4a3220; transition: transform .15s; }
.shelf-frame img { display: block; height: 122px; width: auto; max-width: 230px; object-fit: cover; }
.shelf-item:hover .shelf-frame, .shelf-item:focus-visible .shelf-frame { transform: translateY(-4px); border-color: var(--candle); }
.shelf-item[aria-pressed="true"] .shelf-frame { transform: translateY(-8px); border-color: var(--candle); box-shadow: 0 0 20px #f2b35c99; }
/* A cut-out (its photo background removed) stands straight on the shelf with no frame, and glows around its outline. */
.shelf-item--cutout .shelf-frame { background: none; border-color: transparent !important; box-shadow: none !important; }
.shelf-item--cutout img { object-fit: contain; object-position: 50% 100%; }
.shelf-item--cutout:hover img, .shelf-item--cutout:focus-visible img, .shelf-item--cutout[aria-pressed="true"] img { filter: drop-shadow(0 0 8px #f2b35caa); }
/* Each item stands on its own length of plank; side by side they make one shelf. */
.shelf-item::after {
  content: ""; position: absolute; left: -12px; right: -12px; top: 130px; height: 16px;
  background: linear-gradient(#8a5f36, #6b4a2b 45%, #3e2a17); border-top: 3px solid #a7764a; box-shadow: 0 8px 12px #000000aa;
}
/* The name and price, painted on a little wooden sign hung from the plank by two strings; picking an item sets it swinging. */
.shelf-sign {
  position: relative; display: block; width: max-content; max-width: 160px; margin: 32px auto 0; padding: 5px 10px 6px; line-height: 1.15;
  background: linear-gradient(#6b4a2b, #4a3220); border: 2px solid #22140a; box-shadow: 0 5px 8px #000000aa;
  transform-origin: 50% -16px; transform: rotate(-1.5deg);
}
.shelf-item:nth-child(even) .shelf-sign { transform: rotate(1.2deg); }
.shelf-sign::before, .shelf-sign::after { content: ""; position: absolute; top: -18px; height: 16px; border-left: 2px solid #c9b48a; }
.shelf-sign::before { left: 16px; }
.shelf-sign::after { right: 16px; }
.shelf-item:hover .shelf-sign, .shelf-item[aria-pressed="true"] .shelf-sign { animation: swing 1.2s ease-in-out; }
@keyframes swing { 0% { transform: rotate(0); } 20% { transform: rotate(6deg); } 45% { transform: rotate(-4deg); } 70% { transform: rotate(2deg); } 100% { transform: rotate(0); } }
.shelf-name { display: block; font-family: var(--pixel); font-size: 13px; color: #f6e7c4; text-shadow: 0 1px 0 #1a0e05; }
.shelf-item[aria-pressed="true"] .shelf-name { color: var(--candle-hot); }
.shelf-cost, .narrator .gold { display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; font-family: var(--pixel); font-size: 14px; color: #f3d28a; }
.coin {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 35%, #fff1b8, #f2b35c 45%, #a8742a); box-shadow: 0 0 0 1px #5c3f17;
}

/* The cat, sitting at the bottom of the screen with her text box. */
.narrator {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 5;
  width: min(860px, calc(100% - 24px)); display: grid; grid-template-columns: 110px 1fr auto; gap: 18px; align-items: start;
  box-shadow: 0 0 0 4px var(--ink-deep), 0 20px 40px #000000cc;
}
.narrator > img { width: 110px; height: 110px; object-fit: cover; image-rendering: pixelated; border: 3px solid var(--wood); background: var(--wood-deep); }
.narrator .cat-line { font-size: 19px; min-height: 0; }
.narrator-picture { width: 220px; height: 120px; padding: 8px; background: var(--parchment); border: 3px solid var(--wood); }
.narrator-picture:empty { display: none; }
.narrator-picture img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.narrator-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 8px; }
.narrator-actions:empty { display: none; }
.narrator-actions a, .narrator-actions button {
  position: relative; padding: 2px 0 2px 18px; cursor: pointer; text-decoration: none;
  font-family: var(--pixel); font-size: 16px; color: #f6e7c4 !important; background: none; border: 0;
}
.narrator-actions a::before, .narrator-actions button::before { content: "▸"; position: absolute; left: 0; color: var(--candle); }
.narrator .gold { font-size: 16px; margin: 0; }
@media (prefers-reduced-motion: reduce) { .shelf-sign { animation: none !important; } }
@media (max-width: 700px) {
  .shelf-frame img { height: 96px; max-width: 150px; }
  .shelf-item::after { top: 104px; }
  .narrator { grid-template-columns: 64px 1fr; gap: 12px; }
  .narrator > img { width: 64px; height: 64px; }
  .narrator .cat-line { font-size: 16px; }
  .narrator-picture { display: none; }
}

/* Rankings: same page, read by candlelight. */
body.castle.rk-page {
  --rk-ink: var(--parchment);
  --rk-muted: var(--text-soft);
  --rk-faint: var(--fog);
  --rk-accent: var(--candle);
  --rk-paper: var(--ink);
  --rk-rule: var(--slate);
  background: var(--ink);
}
body.castle.rk-page .wrap { padding-top: clamp(64px, 8vw, 90px); }
body.castle.rk-page .tabs a { color: var(--text-soft); }
body.castle.rk-page .tabs a.on, body.castle.rk-page .tabs a:hover { color: var(--candle); }

/* ---------- The card catalogue: a cabinet of drawers, one per page. Click a drawer to lift it out and flip through its cards. ---------- */
.ctl-cabinet { position: relative; max-width: 1600px; margin: 0 auto; background: var(--ink-deep); }
/* The painting and the drawers laid over it; drawer positions are percentages of this box. */
.ctl-art { position: relative; container-type: inline-size; }
.ctl-art > img { display: block; width: 100%; height: auto; }
/* On a phone, zoom in on the cabinet itself (cropping the wall either side and a little above and below) and give it
   the whole first screen, with the title above it. */
@media (max-width: 600px) {
  .ctl-page { min-height: 100svh; display: flex; flex-direction: column; justify-content: center; }
  .ctl-cabinet { display: flex; flex-direction: column; overflow: hidden; width: 100%; }
  .ctl-cabinet .room-title { position: relative; z-index: 2; order: -1; padding: 8px 16px 0; text-align: center; }
  .ctl-page .ctl-back { position: fixed; top: 12px; right: 12px; }
  .ctl-page { padding-top: 56px; box-sizing: border-box; }
  .ctl-art { width: 136.2%; margin: -6.4% 0 -4.3% -18.1%; }
  .ctl-page .ctl-intro { margin-top: 18px; padding: 0 18px 24px; }
}
.ctl-cabinet .room-title { pointer-events: none; }
.ctl-back {
  position: absolute; right: clamp(12px, 2vw, 24px); top: clamp(12px, 2vw, 20px); z-index: 3;
  font-family: var(--pixel); font-size: 15px; text-decoration: none; color: #f6e7c4 !important;
  background: var(--wood-deep); border: 3px solid var(--wood); box-shadow: 0 0 0 3px var(--ink-deep); padding: 8px 12px;
}
.ctl-back:hover { border-color: var(--candle); }
.ctl-intro { max-width: 640px; margin: 28px auto 0; text-align: center; font-family: var(--pixel); font-size: 16px; line-height: 1.6; color: var(--text-soft); }

/* Each drawer: an invisible button over the painting, holding a cut-out of that drawer laid exactly over the
   painted one. On hover the cut-out lifts a little and glows; the glow is a drop-shadow, so it follows the drawer's outline. */
.ctl-drawer { position: absolute; padding: 0; border: 0; background: none; cursor: pointer; }
.ctl-drawer:focus-visible { outline: none; }
.ctl-drawer:hover, .ctl-drawer:focus-visible { z-index: 2; }
.ctl-sprite { position: absolute; pointer-events: none; transition: transform .22s ease-out; }
.ctl-sprite img { display: block; width: 100%; height: 100%; image-rendering: pixelated; transition: filter .22s ease-out; }
.ctl-drawer:hover .ctl-sprite, .ctl-drawer:focus-visible .ctl-sprite { transform: translateY(-2.5%) scale(1.025); }
.ctl-drawer:hover .ctl-sprite img, .ctl-drawer:focus-visible .ctl-sprite img { filter: brightness(1.15) drop-shadow(3px 0 0 #f2b35c) drop-shadow(-3px 0 0 #f2b35c) drop-shadow(0 3px 0 #f2b35c) drop-shadow(0 -3px 0 #f2b35c); }
@media (prefers-reduced-motion: reduce) { .ctl-drawer:hover .ctl-sprite, .ctl-drawer:focus-visible .ctl-sprite { transform: none; } }
.ctl-label { position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; font-family: var(--pixel); font-weight: 600; font-size: clamp(8px, 1.25cqi, 19px); line-height: 1; color: #2a1d12; }

/* An index card, as read when taken out of its drawer: white ruled paper, pixel type on a 26px grid.
   The title block is 64px tall, so the rules start there; each rule sits 5px above a line's foot, just under the text. */
.ctl-card { position: relative; display: block; padding: 12px 18px 18px; color: #2f2216; background: #fbf8ef repeating-linear-gradient(transparent 0 20px, #c9d6e8 20px 22px, transparent 22px 26px) 0 64px / 100% calc(100% - 64px) no-repeat; box-shadow: 0 4px 0 #0005, 0 10px 18px #0007; }
.ctl-card h3 { margin: 0; box-sizing: content-box; height: 43px; padding-bottom: 6px; border-bottom: 3px solid #b8352a; font-family: var(--pixel); font-weight: 600; font-size: clamp(19px, 5.4vw, 30px); line-height: 50px; color: #8c1d1d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctl-body { padding-top: 26px; } /* one blank ruled line between the title and the text */
/* Card text is set in Courier Prime, a typewriter face that reads more easily than the pixel font. */
.ctl-body p, .ctl-body ul, .ctl-body blockquote { margin: 0 0 26px; font-family: "Courier Prime", "Courier New", monospace; font-size: 16px; line-height: 26px; }
.ctl-body > :last-child { margin-bottom: 0; }
.ctl-body ul { padding-left: 0; list-style: none; }
.ctl-body li { position: relative; padding-left: 22px; }
.ctl-body li::before { content: "♥"; position: absolute; left: 2px; font-size: 11px; color: #b33a3a; }
.ctl-body blockquote { padding-left: 14px; border-left: 3px solid #d24b3e; font-style: italic; }
.ctl-body a { color: #8c1d1d; }
.ctl-body sup { font-size: 12px; line-height: 0; }
.ctl-body .ctl-foot { font-size: 15px; color: #5d5446; }
.ctl-body h4 { margin: 0; font-family: var(--pixel); font-weight: 600; font-size: 19px; line-height: 26px; color: #8c1d1d; }
.ctl-body .ctl-lead { color: #8c1d1d; }

/* The lifted-out drawer */
.ctl-desk { position: fixed; inset: 0; z-index: 20; display: none; background: #0b0f16e6; }
.ctl-desk.open { display: block; }
.ctl-tray { position: absolute; left: 50%; top: 50%; width: min(1100px, 100%); height: min(88vh, 760px); transform: translate(-50%, -50%); overflow: hidden; background: #2a1a10 url(castle/catalogue/drawer-empty.jpg) no-repeat; border: 6px solid var(--wood); box-shadow: 0 10px 0 #000b; image-rendering: pixelated; animation: ctl-lift .5s cubic-bezier(.2, .8, .2, 1); }
@keyframes ctl-lift { from { transform: translate(-50%, 50vh); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ctl-tray { animation: none; } }
.ctl-head { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; background: #1a120cee; border-bottom: 3px solid var(--wood); }
.ctl-head h2 { margin: 0; font-family: var(--pixel); font-size: 24px; color: #f6e7c4; }
.ctl-head h2 small { margin-left: 10px; font-family: var(--pixel); font-weight: 400; font-size: 13px; color: var(--text-soft); }
.ctl-head button, .ctl-flip button { font-family: var(--pixel); font-size: 14px; color: #f6e7c4; background: var(--wood-deep); border: 3px solid var(--wood); padding: 6px 12px; cursor: pointer; }
.ctl-head button:hover, .ctl-flip button:hover { border-color: var(--candle); }
.ctl-head { z-index: 200; }
.ctl-head button { white-space: nowrap; }
@media (max-width: 600px) {
  /* On a phone the lifted-out drawer takes the whole screen rather than floating as a window. */
  .ctl-tray { width: 100%; height: 100%; height: 100dvh; border-width: 0; box-shadow: none; }
  .ctl-head { padding: 10px 12px; }
  .ctl-head h2 { font-size: 20px; }
  .ctl-head h2 small { font-size: 12px; }
  .ctl-added { display: none; }
  .ctl-edge span { font-size: 16px; }
  .ctl-divtab { font-size: 13px; padding: 0 2px; }
  .ctl-flip { gap: 8px; }
  .ctl-flip button { padding: 6px 8px; }
}

/* The papers standing in the drawer: titled cards, blank papers and tabbed dividers. Their edges are
   Grok-painted pixel art (castle/catalogue/papers/), cut into frames that stretch to any size. */
/* The papers stand in a window that scrolls once there are more than fit; catalogue.js sets its top and height. */
.ctl-file { position: absolute; left: 0; right: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #c9b48f55 transparent; }
.ctl-stack { position: relative; }
.ctl-paper { position: absolute; box-sizing: border-box; transition: transform .25s ease, filter .25s; }
.ctl-edge { padding: 0; text-align: left; cursor: pointer; border: 12px solid transparent; border-image: url(castle/catalogue/papers/card.png) 4 / 12px round; image-rendering: pixelated; background: #f1ce98 padding-box; box-shadow: 0 4px 0 #0007; }
.ctl-edge span { position: absolute; left: 4px; right: 4px; top: -5px; padding-bottom: 4px; border-bottom: 3px solid #b8352a; font-family: var(--pixel); font-weight: 600; font-size: 18px; line-height: 20px; color: #2a1d12; }
.ctl-edge:hover, .ctl-edge:focus-visible { outline: none; transform: translateY(-34px); filter: none !important; }
.ctl-blank { pointer-events: none; border: 12px solid transparent; border-image: url(castle/catalogue/papers/card.png) 4 / 12px round; image-rendering: pixelated; background: #f1ce98 padding-box; box-shadow: 0 4px 0 #0007; }
.ctl-divider { pointer-events: none; border: 12px solid transparent; border-image: url(castle/catalogue/papers/divider-green.png) 4 fill / 12px round; image-rendering: pixelated; box-shadow: 0 4px 0 #0007; }
.ctl-divtab { pointer-events: auto; cursor: pointer; background: none; margin: 0; position: absolute; top: -42px; height: 42px; box-sizing: border-box; padding: 0 4px; border-style: solid; border-color: transparent; border-width: 9px 9px 0; border-image: url(castle/catalogue/papers/divider-tab-green.png) 3 3 0 fill / 9px 9px 0 round; image-rendering: pixelated; font-family: var(--pixel); font-size: 15px; line-height: 20px; color: #fff; white-space: nowrap; }
.ctl-divtab:hover, .ctl-divtab:focus-visible { outline: none; filter: brightness(1.15); }
@media (prefers-reduced-motion: reduce) { .ctl-paper { transition: none; } }

/* A card taken out to read */
.ctl-reader { position: absolute; z-index: 150; inset: 64px 0 0; display: none; flex-direction: column; align-items: center; gap: 14px; padding: 24px 16px 16px; background: #0b0f16b8; }
.ctl-reader.open { display: flex; }
/* The card is read inside an open manila folder (Grok-painted, castle/catalogue/papers/folder.png, 397×495).
   The folder is a stretchable frame: its left edge (tab and crease) and right edge (string tie) keep their painted
   shape, and only the plain manila middle widens. --k is the folder's scale, set by catalogue.js to fit the screen. */
.ctl-folder { --k: 1; position: relative; flex: none; box-sizing: border-box; border-style: solid; border-color: transparent;
  border-width: calc(55px * var(--k)) calc(97px * var(--k)) calc(30px * var(--k)) calc(190px * var(--k));
  border-image: url(castle/catalogue/papers/folder.png) 55 97 30 190 fill / 1 stretch;
  animation: ctl-take .35s cubic-bezier(.2, .8, .2, 1); filter: drop-shadow(0 6px 0 #0009); }
.ctl-folder-tab { position: absolute; left: calc(-161.5px * var(--k)); top: calc(-44.5px * var(--k)); width: calc(100px * var(--k)); height: calc(25.5px * var(--k)); display: flex; align-items: center; justify-content: center; font-family: var(--pixel); font-weight: 600; font-size: calc(12.5px * var(--k)); letter-spacing: 2px; text-transform: uppercase; color: #5a3d1c; }
/* The string tie is its own sprite, so it keeps its shape when the folder stretches taller; it sits 42% of the way down. */
.ctl-folder-string { position: absolute; z-index: 1; right: calc(-97px * var(--k)); top: calc((100% + 85px * var(--k)) * .42 - 55px * var(--k)); width: calc(49px * var(--k)); height: calc(98px * var(--k)); pointer-events: none; }
/* The paper lies on the folder's inner panel, which runs a little into the left and right edges. */
.ctl-reader .ctl-card { position: absolute; left: calc(-170px * var(--k)); right: calc(-49.5px * var(--k)); top: 0; bottom: calc(-7.5px * var(--k)); min-height: 0; overflow-y: auto; background-attachment: local; box-shadow: 0 3px 0 #0004; scrollbar-color: #c9b48f transparent; scrollbar-width: thin; }
@keyframes ctl-take { from { transform: translateY(40%) scale(.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ctl-folder { animation: none; } }
.ctl-flip { display: flex; justify-content: center; align-items: center; gap: 14px; font-family: var(--pixel); color: #f6e7c4; }
.ctl-shut { cursor: default; }
.ctl-shut .ctl-label { opacity: .8; font-size: clamp(6px, .95cqi, 15px); line-height: 1.05; }
/* Drawer labels a little larger on the zoomed-in phone cabinet (kept last so they win over the label rules above). */
@media (max-width: 600px) {
  .ctl-label { font-size: clamp(9px, 1.7cqi, 19px); }
  .ctl-shut .ctl-label { font-size: clamp(8px, 1.35cqi, 15px); }
}
