/* =====================================================================
   The Hidden Wild: A Spotter's Journal — AnimalSake
   Resource page + Canvas 2D spotting game. Matches AnimalSake theme.
   (Page-chrome block mirrors the other 17 game pages — each game's own
   styles.css carries it; the site /styles.css does NOT.)
   ===================================================================== */

:root {
  --as-bg:     #fdf6e9;
  --as-card:   #fff8ec;
  --as-brown:  #4b2f20;
  --as-orange: #ff5a00;
  --as-green:  #5aa545;
  --as-yellow: #f8e7c2;
  --as-blue:   #2e9fe6;
  --as-purple: #8b5cf6;
  --as-shadow: 0 12px 30px rgba(75, 47, 32, 0.14);

  --as-brown-soft:  #6f5b4a;
  --as-orange-deep: #e54f00;
  --as-green-deep:  #468539;
  --as-line:        #efe0c8;
  --as-card-soft:   #fffdf8;
  --radius:    22px;
  --radius-sm: 14px;
  --maxw: 980px;
  --font: "Baloo 2", "Quicksand", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--as-brown);
  background:
    radial-gradient(1200px 520px at 50% -160px, #ffe9c9 0%, rgba(255,233,201,0) 70%),
    var(--as-bg);
  line-height: 1.55;
  font-size: 17px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.12; margin: 0; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
strong { color: var(--as-orange-deep); }
a { color: var(--as-orange-deep); text-decoration: none; }

/* The [hidden] attribute must beat every class display rule (joey's-big-hop
   lesson: `.overlay{display:flex}` etc. silently override [hidden]). */
.game-shell [hidden] { display: none !important; }

/* ---------- Buttons (canonical site set) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  touch-action: manipulation;   /* no iOS double-tap zoom on rapid Hint/Journal taps */
  border: 0; border-radius: 999px; padding: 13px 24px;
  font-family: var(--font); font-weight: 700; font-size: 16px; color: #fff;
  cursor: pointer; text-decoration: none;
  transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn--lg { padding: 16px 32px; font-size: 18px; }
.btn--sm { padding: 9px 14px; font-size: 14px; }
.btn--primary { background: var(--as-green); box-shadow: 0 8px 18px rgba(90,165,69,.32); }
.btn--primary:hover { background: var(--as-green-deep); }
.btn--ghost { background: var(--as-card-soft); color: var(--as-brown); border: 2px solid var(--as-line); }
.btn--ghost:hover { background: #fff; border-color: #e3cfa8; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn--pulse { animation: hint-pulse 1.6s ease-in-out infinite; }
@keyframes hint-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 181, 46, 0); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 7px rgba(255, 181, 46, 0.28); }
}

:focus-visible { outline: 3px solid var(--as-blue); outline-offset: 3px; border-radius: 6px; }

/* ---------- Page chrome ---------- */
.site-nav a { font-weight: 700; color: var(--as-brown); }
.site-nav a:hover { color: var(--as-orange-deep); }

.page { max-width: var(--maxw); margin: 0 auto; padding: 8px 20px 48px; }
.resource { display: flex; flex-direction: column; gap: 26px; }

/* ---------- Intro ---------- */
.eyebrow {
  display: inline-block; font-weight: 700; font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--as-orange); background: #fff; border: 2px solid var(--as-line); border-radius: 999px;
  padding: 5px 14px; margin-bottom: 12px;
}
.intro h1 { font-size: 40px; color: var(--as-brown); margin-bottom: 12px; }
.lede { font-size: 20px; color: var(--as-brown); max-width: 62ch; margin-bottom: 18px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.meta-pill { display: inline-flex; align-items: center; gap: 7px; background: var(--as-card); border: 2px solid var(--as-line); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; color: var(--as-brown); }
.learn { background: var(--as-yellow); border-radius: var(--radius); padding: 20px 22px; }
.learn__title { font-size: 18px; color: var(--as-brown); margin-bottom: 14px; }
.learn__list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.learn__list li { display: flex; align-items: center; gap: 9px; background: #fffdf8; border-radius: var(--radius-sm); padding: 12px 12px; font-weight: 700; font-size: 14px; box-shadow: 0 3px 8px rgba(75,47,32,.07); }
.learn__list li span { font-size: 22px; }

/* =====================================================================
   Game shell
   ===================================================================== */
.game-shell {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(180deg, #2c2417, #1d1810);
  box-shadow: var(--as-shadow);
}

/* ---------- HUD (dark bar — buttons get a translucent variant) ---------- */
.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #4b3a1e, #3a2d16);
  color: #fff3da;
}
.hud__title {
  font-weight: 800;
  font-size: 1.06rem;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.hud__stats { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.hud__actions { display: flex; align-items: center; gap: 7px; }
.hud .btn--ghost {
  background: rgba(255, 240, 200, 0.14);
  border: 1px solid rgba(255, 240, 200, 0.26);
  color: #fff3da;
}
.hud .btn--ghost:hover { background: rgba(255, 240, 200, 0.24); border-color: rgba(255, 240, 200, 0.4); }
.hud .btn--sm { font-size: 0.88rem; padding: 5px 12px; }
.chip {
  font-family: "Quicksand", var(--font);
  font-weight: 700;
  font-size: 0.86rem;
  background: rgba(255, 240, 200, 0.14);
  border: 1px solid rgba(255, 240, 200, 0.22);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.chip--dim { opacity: 0.55; }
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 2px;
  background: #ffb52e;
  color: #4a3208;
  border-radius: 999px;
  font-size: 0.78rem;
  text-align: center;
}
.dial-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  animation: dial-in 0.6s ease-out;
}
@keyframes dial-in { from { opacity: 0; transform: translateY(-6px); } }
#sun-dial {
  width: 110px;
  accent-color: #ffb52e;
  cursor: pointer;
}

/* ---------- canvas ---------- */
.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #15110a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* ---------- fullscreen (native via :fullscreen; CSS takeover on iOS) ---------- */
.game-shell--fs {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  margin: 0;
  border-radius: 0;
}
.game-shell--fs, .game-shell:fullscreen {
  display: flex;
  flex-direction: column;
  border-radius: 0;
  width: 100%;
  height: 100%;
}
.game-shell--fs .canvas-wrap, .game-shell:fullscreen .canvas-wrap {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
}
.game-shell--fs .game-canvas, .game-shell:fullscreen .game-canvas {
  width: auto;
  height: auto;
}
.hw-noscroll, .hw-noscroll body { overflow: hidden; }

/* ---------- coach ---------- */
.coach {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(38, 28, 12, 0.88);
  color: #fff3da;
  font-weight: 700;
  font-size: clamp(0.9rem, 2.4vw, 1.08rem);
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 220, 140, 0.5);
  pointer-events: none;
  animation: coach-bob 2.2s ease-in-out infinite;
  max-width: 86%;
  text-align: center;
}
@keyframes coach-bob { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-5px); } }

/* ---------- polaroid ---------- */
.polaroid {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 188px;
  padding: 9px 9px 26px;
  background: #fdfbf4;
  border-radius: 4px;
  box-shadow: 0 10px 26px rgba(10, 8, 2, 0.45);
  transform: translate(-50%, -50%) rotate(-3deg);
  pointer-events: none;
}
.polaroid img { display: block; width: 100%; border-radius: 2px; }
.polaroid__label {
  position: absolute;
  left: 0; right: 0; bottom: 5px;
  text-align: center;
  font-size: 0.82rem;
  color: #6b5a36;
}
.polaroid--dev { animation: pol-develop 1.05s ease-out forwards; }
.polaroid--dev::after {
  content: "";
  position: absolute;
  inset: 9px 9px 26px;
  background: #fff;
  animation: pol-fade 0.85s ease-in 0.1s forwards;
}
@keyframes pol-develop {
  0% { transform: translate(-50%, -46%) rotate(-7deg) scale(0.7); opacity: 0; }
  18% { opacity: 1; }
  72% { transform: translate(-50%, -50%) rotate(-3deg) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -52%) rotate(-2.4deg) scale(0.98); opacity: 0.96; }
}
@keyframes pol-fade { to { opacity: 0; } }

/* ---------- find card ---------- */
.find-card {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 13px;
  align-items: center;
  width: min(440px, 92%);
  background: linear-gradient(180deg, #fff8e6, #ffeec7);
  border: 2px solid #e3c277;
  border-radius: 16px;
  padding: 13px 38px 13px 14px;
  box-shadow: 0 12px 30px rgba(30, 20, 4, 0.4);
}
.find-card--in { animation: card-up 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
@keyframes card-up { from { transform: translateX(-50%) translateY(26px); opacity: 0; } }
.find-card__emoji { font-size: 2.3rem; line-height: 1; }
.find-card__body h3 { font-size: 1.04rem; color: #5a4313; margin-bottom: 2px; }
.find-card__stars { margin: 0 0 4px; font-size: 0.92rem; letter-spacing: 1.5px; }
.find-card__fact {
  margin: 0 0 7px;
  font-family: "Quicksand", var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  color: #4f3d15;
}
.find-card .btn--ghost { padding: 5px 12px; font-size: 0.85rem; background: rgba(90, 67, 19, 0.08); border-color: rgba(90, 67, 19, 0.3); color: #5a4313; }
.find-card__close {
  position: absolute;
  top: 7px; right: 9px;
  background: none;
  border: 0;
  font-size: 1rem;
  color: #8a6d2f;
  cursor: pointer;
  padding: 3px 6px;
}

/* ---------- dusk banner ---------- */
.dusk-banner {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  background: rgba(16, 18, 48, 0.86);
  border: 1.5px solid rgba(160, 180, 255, 0.45);
  color: #e8ecff;
  font-weight: 700;
  font-size: clamp(1rem, 3vw, 1.35rem);
  padding: 12px 26px;
  border-radius: 999px;
  pointer-events: none;
}
.dusk-banner--in { animation: dusk-in 6.2s ease forwards; }
@keyframes dusk-in {
  0% { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  10%, 78% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ---------- toasts ---------- */
.toast-wrap {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  pointer-events: none;
  max-width: min(330px, 70%);
}
.toast {
  background: rgba(38, 28, 12, 0.9);
  color: #fff3da;
  font-family: "Quicksand", var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 220, 140, 0.35);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast--in { opacity: 1; transform: translateY(0); }

/* ---------- journal ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 14, 4, 0.6);
  z-index: 30;
}
.overlay--journal { overflow-y: auto; padding: 18px 10px; align-items: flex-start; }
.overlay__card--journal {
  position: relative;
  width: min(680px, 96%);
  margin: 0 auto;
  background:
    radial-gradient(circle at 12% 8%, rgba(150, 110, 40, 0.12), transparent 40%),
    linear-gradient(180deg, #fbf3dc, #f3e6c4);
  border: 2px solid #d7b873;
  border-radius: 16px;
  padding: 18px 20px 22px;
  box-shadow: 0 16px 44px rgba(15, 10, 2, 0.5);
}
.overlay__title { color: #57411a; font-size: 1.35rem; margin-bottom: 2px; }
.journal-sub {
  margin: 0 0 9px;
  font-family: "Quicksand", var(--font);
  font-weight: 600;
  color: #7a6234;
  font-size: 0.92rem;
}
.journal-h {
  margin: 15px 0 8px;
  color: #5a4313;
  font-size: 1.02rem;
  border-bottom: 1.5px dashed #d7b873;
  padding-bottom: 4px;
}
.stamps { display: flex; gap: 9px; margin: 4px 0 2px; flex-wrap: wrap; }
.stamp {
  font-weight: 800;
  font-size: 0.82rem;
  color: #2c6e3a;
  border: 2.5px solid #2c6e3a;
  border-radius: 8px;
  padding: 3px 10px;
  transform: rotate(-4deg);
  letter-spacing: 1px;
  opacity: 0.88;
}
.stamp--night { color: #3a3f8f; border-color: #3a3f8f; transform: rotate(3deg); }
.jgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(186px, 1fr));
  gap: 10px;
}
.jcard {
  background: #fffdf4;
  border: 1.5px solid #e2cfa0;
  border-radius: 12px;
  padding: 9px;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.jcard--found { border-color: #cfa84e; box-shadow: 0 3px 10px rgba(120, 90, 20, 0.14); }
.jcard__photo {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid #e2cfa0;
  background: #efe6cb;
}
.jcard__photo--none {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
}
.jcard__sil {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.7rem;
  border-radius: 7px;
  background: #e7dcbd;
  filter: grayscale(1) contrast(0.25) brightness(0.72);
}
.jcard__body h4 { font-size: 0.94rem; color: #57411a; }
.jcard__stars { margin: 0; font-size: 0.8rem; letter-spacing: 1px; }
.jcard__fact {
  margin: 0;
  font-family: "Quicksand", var(--font);
  font-weight: 600;
  font-size: 0.82rem;
  color: #6b5631;
}
.jcard__links { margin: auto 0 0; display: flex; align-items: center; gap: 8px; font-size: 0.84rem; }
.jcard__links a { font-weight: 700; color: #1d6e3f; }
.jspeak {
  background: none;
  border: 1px solid #d7b873;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.82rem;
  padding: 2px 7px;
}
.overlay__card--options { width: min(520px, 96%); }
.ranger-code__row { display: flex; gap: 8px; margin: 8px 0; align-items: center; }
.overlay__card--options .btn--ghost { padding: 6px 12px; font-size: 0.85rem; background: rgba(90, 67, 19, 0.08); border-color: rgba(90, 67, 19, 0.3); color: #5a4313; flex: 0 0 auto; }
#j-reset { margin-top: 8px; padding: 6px 12px; font-size: 0.85rem; background: rgba(90, 67, 19, 0.08); border-color: rgba(90, 67, 19, 0.3); color: #8a3a2a; }
.ranger-code__box {
  flex: 1;
  min-width: 0;
  border: 1.5px solid #d7b873;
  border-radius: 8px;
  padding: 6px 9px;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  background: #fffdf4;
  color: #57411a;
}
.find-card__close:hover, .jspeak:hover { color: var(--as-orange-deep); border-color: #c9a85e; }

/* ---------- expedition map (postcard menu) ---------- */
.overlay--menu { overflow-y: auto; padding: 18px 10px; align-items: flex-start; }
.overlay__card--menu {
  position: relative;
  width: min(720px, 96%);
  margin: 0 auto;
  background:
    radial-gradient(circle at 88% 6%, rgba(150, 110, 40, 0.14), transparent 40%),
    linear-gradient(180deg, #fbf3dc, #f0e2bd);
  border: 2px solid #d7b873;
  border-radius: 16px;
  padding: 18px 20px 22px;
  box-shadow: 0 16px 44px rgba(15, 10, 2, 0.5);
}
.postcards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 13px;
  margin-top: 10px;
}
.postcard {
  background: #fffdf4;
  border: 1.5px solid #e2cfa0;
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(120, 90, 20, 0.12);
  transition: transform 0.14s ease, border-color 0.15s ease;
}
.postcard--open { cursor: pointer; }
.postcard--open:hover, .postcard--open:focus-visible { transform: translateY(-3px) rotate(-0.5deg); border-color: var(--as-orange); }
.postcard--here { border-color: #cfa84e; box-shadow: 0 0 0 3px rgba(207, 168, 78, 0.35); }
.postcard--soon { opacity: 0.72; }
.postcard:not(.postcard--open):not(.postcard--soon) .postcard__art { filter: saturate(0.35) brightness(0.85); }
.postcard__art {
  position: relative;
  height: 104px;
  background-size: cover;
  background-position: center;
  background-color: #cfc3a0;
  border-bottom: 1.5px solid #e2cfa0;
}
.postcard__emoji {
  position: absolute;
  right: 7px; bottom: 5px;
  font-size: 1.5rem;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
.postcard__body { padding: 9px 11px 11px; }
.postcard__body h3 {
  font-size: 1rem;
  color: #57411a;
  margin-bottom: 1px;
}
.postcard__tag {
  font-family: "Quicksand", var(--font);
  font-weight: 600;
  font-size: 0.78rem;
  color: #8a7344;
  margin-bottom: 7px;
}
.postcard__state {
  font-family: "Quicksand", var(--font);
  font-weight: 700;
  font-size: 0.82rem;
  color: #5a4313;
  margin: 0;
}
.postcard__bar {
  height: 8px;
  border-radius: 999px;
  background: #e7dcbd;
  overflow: hidden;
  margin-bottom: 5px;
}
.postcard__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb52e, #ff8a2e);
  transition: width 0.4s ease;
}
.menu-complete {
  margin-top: 14px;
  padding: 13px 16px;
  text-align: center;
  background: linear-gradient(180deg, #fff6da, #ffeebb);
  border: 2px solid #e3b94e;
  border-radius: 13px;
}
.menu-complete__line {
  font-family: "Baloo 2", var(--font);
  font-weight: 700;
  color: #6b4d10;
  margin-bottom: 9px;
}
.menu-reset-row { margin: 14px 0 0; text-align: center; }
.linklike {
  background: none;
  border: 0;
  cursor: pointer;
  font-family: "Quicksand", var(--font);
  font-weight: 700;
  font-size: 0.85rem;
  color: #8a7344;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 8px;
}
.linklike:hover { color: var(--as-orange-deep); }

/* ---------- how-to prose ---------- */
.howto-prose h2 { font-size: 24px; color: var(--as-brown); margin-bottom: 10px; }
.howto-list {
  font-family: "Quicksand", var(--font);
  font-weight: 600;
  line-height: 1.55;
  padding-left: 20px;
  list-style: disc;
}
.howto-list li { margin: 5px 0; }

/* =====================================================================
   Related links
   ===================================================================== */
.related__title { font-size: 24px; color: var(--as-brown); margin-bottom: 16px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.related-card { display: flex; align-items: center; gap: 12px; background: var(--as-card); border: 2px solid var(--as-line); border-radius: var(--radius-sm); padding: 16px 18px; font-weight: 700; font-size: 16px; color: var(--as-brown); box-shadow: 0 4px 10px rgba(75,47,32,.07); transition: transform .12s ease, border-color .15s ease; }
.related-card:hover { transform: translateY(-2px); border-color: var(--as-orange); color: var(--as-orange-deep); }
.related-card__emoji { font-size: 26px; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .page { padding: 4px 14px 36px; }
  .resource { gap: 20px; }
  .intro h1 { font-size: 30px; }
  .lede { font-size: 17px; }
  .learn__list { grid-template-columns: repeat(2, 1fr); }

  .hud { padding: 8px 10px; gap: 6px 8px; }
  .hud__title { font-size: 0.95rem; }
  .chip { font-size: 0.78rem; padding: 3px 9px; }
  .hud .btn--sm { font-size: 0.8rem; padding: 4px 9px; }
  #sun-dial { width: 84px; }
  .find-card { padding: 10px 32px 10px 11px; gap: 9px; }
  .find-card__emoji { font-size: 1.8rem; }
  .polaroid { width: 150px; }
}

@media (max-width: 380px) {
  .intro h1 { font-size: 26px; }
}

/* =====================================================================
   Reduced motion
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  .coach { animation: none; }
  .polaroid--dev { animation-duration: 0.3s; }
  .dusk-banner--in { animation-duration: 3s; }
  .btn--pulse { animation: none; box-shadow: 0 0 0 4px rgba(255, 181, 46, 0.3); }
}
