/* ============================================================================
   Grimoire: A Field Guide to Monsters
   1rem == 1 sprite pixel (html font-size is set to the integer scale by JS).
   ========================================================================== */

:root {
  --ink: #4a3724;
  --ink-soft: #7a6248;
  --ink-faint: #a08a6c;
  --paper-line: #d9b98c;
  --bad: #8c3b2e;
  --good: #4d7a3a;
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }

html { font-size: 6px; }

body {
  background: #211712;
  background-image:
    radial-gradient(ellipse at 50% 38%, #3a2a20 0%, #211712 62%, #140d09 100%);
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  overflow: hidden;
  height: 100vh;
}

img, .px {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------ HUD -- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: linear-gradient(#33231a, #271a12);
  border-bottom: 2px solid #150e09;
  color: #e8d5ae;
  font-size: 15px;
  z-index: 40;
  box-shadow: 0 3px 12px rgba(0,0,0,.55);
}
#hud .h-item { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
#hud img { width: 22px; height: auto; }
#hud .h-sub { color: #a98f63; font-size: 12px; }
#hud .h-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.h-btn {
  background: #4a3322; border: 1px solid #6b4d31; color: #e8d5ae;
  font-family: inherit; font-size: 12px; padding: 4px 10px; cursor: pointer;
  border-radius: 3px;
}
.h-btn:hover { background: #5d4029; }
#hudScouts { display: flex; gap: 6px; }
.scout-chip {
  font-size: 11px; padding: 3px 8px; border-radius: 3px;
  background: #1d4a27; border: 1px solid #2f6b3a; color: #cfe8b8;
}
.scout-chip.busy { background: #4a2a1d; border-color: #6b432f; color: #e8c9b8; }

/* ------------------------------------------------------------ title screen */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}
#title { z-index: 30; }
.title-book {
  position: relative;
  width: 224rem; height: 160rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  filter: drop-shadow(0 14px 30px rgba(0,0,0,.6));
}
.title-book > img.cover-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.title-inner { position: relative; text-align: center; color: #f3dcae; padding: 0 20rem; }
.title-kicker {
  font-size: 4.4rem; letter-spacing: .8rem; text-transform: uppercase;
  color: #d9b173; margin-bottom: 2rem;
}
h1.title-main {
  font-size: 17rem; letter-spacing: .6rem; line-height: 1;
  text-shadow: 0 2px 0 #5d1f24, 0 5px 12px rgba(0,0,0,.5);
  margin-bottom: 3rem;
}
.title-sub { font-size: 5.4rem; font-style: italic; color: #ecd3a3; margin-bottom: 10rem; }
.title-belt {
  display: flex; gap: 4rem; justify-content: center; margin-bottom: 8rem;
}
.title-belt img { width: 9rem; height: auto; }
.title-menu { display: flex; flex-direction: column; gap: 3.4rem; align-items: center; }
.title-foot {
  margin-top: 16px; color: #8d7350; font-size: 12px; text-align: center; line-height: 1.6;
}

/* Sprite-framed button */
.pbtn {
  border: 4rem solid transparent;
  border-image: url('../assets/ui/UI_TravelBook_Frame01a.png') 5 fill;
  border-image-repeat: stretch;
  image-rendering: pixelated;
  font-family: inherit;
  font-size: 4.6rem;
  color: #4a3724;
  padding: .6rem 4rem .9rem;
  min-width: 58rem;
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
}
.pbtn:hover:not(:disabled) {
  border-image-source: url('../assets/ui/UI_TravelBook_FrameSelect01a.png');
}
.pbtn:active:not(:disabled) { transform: translateY(1px); }
.pbtn:disabled { opacity: .55; cursor: default; }
.pbtn.danger { color: #7c2920; }
.pbtn small { display: block; font-size: 3.4rem; color: var(--ink-soft); }

/* ------------------------------------------------------------------- book */
#bookwrap { z-index: 10; padding-top: 44px; }
#book {
  position: relative;
  width: 224rem; height: 160rem;
  filter: drop-shadow(0 16px 34px rgba(0,0,0,.65));
}
#book > img.cover-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.page {
  position: absolute;
  top: 6.5rem;
  width: 104rem; height: 147rem;
  background-size: 100% 100%;
}
#pageL { left: 8rem;  background-image: url('../assets/ui/UI_TravelBook_BookPageLeft01a.png'); }
#pageR { left: 112rem; background-image: url('../assets/ui/UI_TravelBook_BookPageRight01a.png'); }
.page-content {
  position: absolute; inset: 8rem 8rem 9rem 9rem;
  overflow: hidden;
  font-size: 4.1rem;
  line-height: 1.45;
}
#pageR .page-content { inset: 8rem 9rem 9rem 8rem; }

/* page flip */
@keyframes flipOutR { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes flipInR  { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.page.flip-out { animation: flipOutR .14s ease-in both; }
.page.flip-in  { animation: flipInR .14s ease-out both; }
#pageL { transform-origin: right center; }
#pageR { transform-origin: left center; }

/* corner navigation */
.pagenav {
  position: absolute;
  bottom: 2.2rem;
  width: 11rem; height: 9rem;
  background: url('../assets/ui/UI_TravelBook_IconArrow01a.png') center / contain no-repeat;
  image-rendering: pixelated;
  cursor: pointer;
  opacity: .8;
  z-index: 5;
}
.pagenav:hover { opacity: 1; transform: scale(1.08); }
#navL { left: 14rem; transform: scaleX(-1); }
#navL:hover { transform: scaleX(-1.08) scaleY(1.08); }
#navR { right: 14rem; }
.pagenav.off { display: none; }
.folio {
  position: absolute; bottom: 8.2rem; width: 100%;
  text-align: center; font-size: 3.4rem; color: var(--ink-faint);
  font-style: italic; pointer-events: none; z-index: 4;
}

/* ------------------------------------------------------------------- tabs */
#tabs {
  position: absolute;
  top: -11.5rem; left: 14rem;
  display: flex; gap: 1.6rem;
  z-index: 6;
}
.tab {
  position: relative;
  width: 20rem; height: 15rem;
  background: url('../assets/ui/UI_TravelBook_Marker01a.png') center / 100% 100% no-repeat;
  image-rendering: pixelated;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 5.2rem; font-weight: bold; color: #5d4126;
  padding-bottom: 2rem;
  transition: transform .08s;
}
.tab:hover { transform: translateY(-1.4rem); }
.tab.active { transform: translateY(-2rem); filter: brightness(1.12); }
.tab.locked { filter: saturate(.25) brightness(.78); color: #7c6c58; }
.tab .tab-dot {
  position: absolute; top: 1.2rem; right: 2rem;
  width: 3rem; height: 3rem; border-radius: 50%;
  background: #57a05c; border: .6rem solid #2e5c33;
}
.tab .tab-alert {
  position: absolute; top: -4rem; right: -1rem;
  width: 5rem; height: auto;
  animation: bob .7s ease-in-out infinite alternate;
}
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-1.6rem); } }

/* ------------------------------------------------------------ page pieces */
.h-region {
  font-size: 7rem; line-height: 1.1; letter-spacing: .2rem;
  border-bottom: .5rem solid var(--paper-line);
  padding-bottom: 1.6rem; margin-bottom: 2rem;
}
.h-small {
  font-size: 4.6rem; text-transform: uppercase; letter-spacing: .5rem;
  color: var(--ink-soft); margin: 2.5rem 0 1.5rem;
  border-bottom: .5rem solid var(--paper-line); padding-bottom: 1rem;
}
.region-desc { font-style: italic; color: var(--ink-soft); font-size: 3.9rem; margin-bottom: 2.6rem; }

.bar {
  position: relative;
  height: 4rem;
  border: 1.2rem solid transparent;
  border-image: url('../assets/ui/UI_TravelBook_Bar01a.png') 2 fill stretch;
  image-rendering: pixelated;
  margin: 1rem 0;
}
.bar .fill {
  position: absolute; inset: 0;
  background: url('../assets/ui/UI_TravelBook_Fill01a.png');
  background-size: 100% 100%;
  image-rendering: pixelated;
  transition: width .25s linear;
}
.bar .fill.alt { background-image: url('../assets/ui/UI_TravelBook_Fill01b.png'); }

.kv { display: flex; justify-content: space-between; font-size: 3.9rem; margin: .6rem 0; }
.kv b { color: var(--ink); }
.muted { color: var(--ink-faint); }
.tiny { font-size: 3.3rem; }
.center { text-align: center; }

.exp-row { margin: 1.6rem 0 2rem; }
.exp-row .exp-label { display: flex; justify-content: space-between; font-size: 3.7rem; }

.btn-row { display: flex; gap: 2rem; margin-top: 2.4rem; flex-wrap: wrap; justify-content: center; }

.stamp {
  display: inline-block;
  border: 1rem double #9c3b2a;
  color: #9c3b2a;
  font-size: 4.4rem; letter-spacing: .6rem; text-transform: uppercase;
  padding: 1rem 2.4rem;
  transform: rotate(-7deg);
  opacity: .85;
  margin-top: 2.4rem;
}

.lock-art { text-align: center; margin: 8rem 0 4rem; font-size: 22rem; line-height: 1; opacity: .25; }

/* recent finds log */
.log { font-size: 3.6rem; }
.log li { list-style: none; padding: .7rem 0; border-bottom: .4rem dotted var(--paper-line); display:flex; justify-content: space-between; gap: 1rem;}
.log .r-common { color: var(--ink-soft); }
.log .when { color: var(--ink-faint); font-style: italic; white-space: nowrap; }

/* ---------------------------------------------------------- creature page */
.entry { height: 100%; display: flex; flex-direction: column; }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  border-bottom: .5rem solid var(--paper-line); padding-bottom: 1.2rem; }
.entry-name { font-size: 6rem; line-height: 1.05; }
.entry-no { font-size: 3.4rem; color: var(--ink-faint); white-space: nowrap; }
.plate {
  align-self: center;
  margin: 2.6rem 0 1.6rem;
  width: 72rem; height: 56rem;
  border: 4rem solid transparent;
  border-image: url('../assets/ui/UI_TravelBook_Slot01b.png') 5 fill stretch;
  image-rendering: pixelated;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.plate img.creature { width: 44rem; height: 44rem; object-fit: contain; }
.plate .qmark {
  position: absolute; font-size: 9rem; color: #d9c49a;
  bottom: 1rem; right: 2.4rem; font-style: italic;
}
img.sil { filter: brightness(0) opacity(.82); }

.stars { display: flex; gap: 1rem; justify-content: center; margin-bottom: 1.4rem; }
.stars img { width: 6rem; height: auto; }
.stars img.off { filter: grayscale(1) brightness(1.25) opacity(.45); }
.rarity-tag { text-align: center; font-size: 3.8rem; letter-spacing: .5rem; text-transform: uppercase; margin-bottom: 1.8rem; }
.flavor { font-style: italic; font-size: 3.9rem; flex: 1; }
.entry-stats { border-top: .5rem solid var(--paper-line); padding-top: 1.2rem; display: flex; justify-content: space-between; font-size: 3.4rem; color: var(--ink-soft); }
.entry.undisc .entry-name { color: var(--ink-faint); letter-spacing: 1rem; }

.leaf-blank { height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); font-style: italic; font-size: 4rem; }

/* --------------------------------------------------------------- upgrades */
.shop-item { border-bottom: .5rem solid var(--paper-line); padding: 1.8rem 0; }
.shop-item .si-top { display: flex; justify-content: space-between; align-items: baseline; }
.shop-item .si-name { font-size: 4.6rem; }
.shop-item .si-blurb { font-style: italic; color: var(--ink-soft); font-size: 3.5rem; margin: .5rem 0 1rem; }
.pips { display: inline-flex; gap: .8rem; margin-right: 1.6rem; vertical-align: middle; }
.pip { width: 2.6rem; height: 2.6rem; border-radius: 50%; background: #cdb088; }
.pip.on { background: #57a05c; box-shadow: 0 0 0 .5rem #2e5c3344; }
.buy-line { display: flex; align-items: center; justify-content: space-between; }
.buy-btn {
  border: 3rem solid transparent;
  border-image: url('../assets/ui/UI_TravelBook_Frame01a.png') 5 fill stretch;
  image-rendering: pixelated;
  font-family: inherit; font-size: 3.8rem; color: var(--ink);
  padding: .3rem 2.4rem .5rem; cursor: pointer;
}
.buy-btn:hover:not(:disabled) { border-image-source: url('../assets/ui/UI_TravelBook_FrameSelect01a.png'); }
.buy-btn:disabled { opacity: .5; cursor: default; }

/* --------------------------------------------------------------- overlays */
#overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12, 7, 4, .72);
  display: flex; align-items: center; justify-content: center;
}
.popup {
  position: relative;
  width: 130rem; max-width: 92vw;
  max-height: 88vh;
  border: 8rem solid transparent;
  border-image: url('../assets/ui/UI_TravelBook_Popup01a.png') 10 fill stretch;
  image-rendering: pixelated;
  padding: 2rem 4rem 3rem;
  font-size: 4.1rem;
  color: var(--ink);
  filter: drop-shadow(0 10px 26px rgba(0,0,0,.6));
  animation: popIn .18s ease-out both;
  overflow-y: auto;
}
.popup.wide { width: 168rem; }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.popup h2 { font-size: 6.4rem; text-align: center; margin-bottom: .6rem; }
.popup .pop-sub { text-align: center; font-style: italic; color: var(--ink-soft); margin-bottom: 2.4rem; }

.report-scout {
  display: flex; align-items: center; gap: 2.4rem; justify-content: center; margin: 1rem 0 2rem;
}
.report-scout img { width: 12rem; height: 12rem; }
.report-remark { font-style: italic; }

.find-list { max-height: 56rem; overflow-y: auto; margin-bottom: 1rem; }
.find-row {
  display: flex; align-items: center; gap: 2.6rem;
  padding: 1rem .6rem; border-bottom: .4rem dotted var(--paper-line);
}
.find-row img.creature { width: 14rem; height: 14rem; object-fit: contain; }
.find-row .fr-name { flex: 1; }
.find-row .fr-name small { display: block; font-size: 3.2rem; color: var(--ink-soft); }
.badge-new {
  background: #b3851f; color: #fff7e0; font-size: 3.2rem;
  padding: .4rem 1.6rem; letter-spacing: .4rem; border-radius: .8rem;
  animation: pulse .8s ease-in-out infinite alternate;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
.fr-rp { color: var(--good); white-space: nowrap; }

/* reveal ceremony */
#revealStage { text-align: center; padding: 2rem 0; }
#revealStage .plate { width: 96rem; height: 76rem; margin: 2rem auto; }
#revealStage .plate img.creature { width: 60rem; height: 60rem; }
.reveal-name { font-size: 7.6rem; margin-top: 1rem; min-height: 9rem; }
.reveal-flavor { font-style: italic; min-height: 16rem; margin: 1.6rem 4rem; }
@keyframes flashIn {
  0%   { filter: brightness(0) opacity(.85); }
  45%  { filter: brightness(0) opacity(.9); }
  60%  { filter: brightness(3.2) saturate(0); }
  100% { filter: brightness(1); }
}
img.revealing { animation: flashIn 1.05s ease-out both; }
.spark {
  position: absolute; width: 7rem; height: auto; left: 50%; top: 50%;
  pointer-events: none;
  animation: spark .9s ease-out both;
}
@keyframes spark {
  from { transform: translate(-50%, -50%) scale(.4); opacity: 1; }
  to   { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.15) rotate(40deg); opacity: 0; }
}
@keyframes ringPop {
  from { box-shadow: 0 0 0 0 var(--glow); }
  to   { box-shadow: 0 0 9rem 4rem transparent; }
}
.plate.glow { animation: ringPop 1s ease-out .55s both; }

/* legendary parade for the grand reward */
.parade { display: flex; gap: 3rem; justify-content: center; flex-wrap: wrap; margin: 2.4rem 0; }
.parade img { width: 18rem; height: 18rem; object-fit: contain; animation: bob 1s ease-in-out infinite alternate; }
.parade img:nth-child(2n) { animation-delay: .3s; }
.parade img:nth-child(3n) { animation-delay: .6s; }

/* report bell */
#reportBell {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 50;
  display: flex; align-items: center; gap: 10px;
  background: #3d2a1c; color: #f3dcae; border: 2px solid #6b4d31;
  font-family: inherit; font-size: 15px;
  padding: 9px 20px; border-radius: 6px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  animation: bellNudge 1.2s ease-in-out infinite alternate;
}
@keyframes bellNudge { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(-5px); } }
#reportBell img { width: 14px; height: auto; }

/* credits list */
.credits p { margin: 1.4rem 0; }
.credits .who { color: var(--ink-soft); font-style: italic; }

/* scrollbars (webkit) */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,.08); }
::-webkit-scrollbar-thumb { background: #b08c5e; border-radius: 4px; }
