/* Chill Domains — jacks-nap.css
   The /jacks-nap page ("Jack's Nap", a rhythm game): the stage, its HUD, the
   card that holds the title / pause / results screens, and the page below.
   Pairs with /assets/js/jacks-nap.js. Layout follows renewal-run.css. */

/* the game sits straight under the breadcrumb; heading and intro follow it */
.jn-top { padding-block: clamp(1rem, 2.5vw, 1.75rem) clamp(2rem, 4vw, 3.5rem); }
.jn-top .crumb { max-width: 1100px; margin: 0 auto var(--space-3); }
.jn-intro { max-width: 760px; margin: var(--space-7) auto 0; text-align: center; }
.jn-intro h1 { margin-bottom: var(--space-4); }
.jn-lede { color: var(--text-muted); font-size: var(--fs-xl); }
@media (max-width: 640px) { .jn-lede { font-size: var(--fs-lg); } }
.jn-wrap { max-width: 1100px; margin-inline: auto; position: relative; }
.jn-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; isolation: isolate;
  background: #EFE0C8; border-radius: var(--radius-lg); color: var(--color-ink);
  box-shadow: 0 24px 60px -24px rgba(31, 41, 55, 0.5);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
@media (max-width: 640px) { .jn-stage { aspect-ratio: 4 / 5; } }
.jn-stage:focus { outline: none; }
.jn-stage:focus-visible { outline: 3px solid var(--color-coral); outline-offset: 3px; }
.jn-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.jn-wrap:fullscreen { max-width: none; background: #1f2937; display: flex; align-items: center; }
.jn-wrap:fullscreen .jn-stage { aspect-ratio: auto; height: 100%; border-radius: 0; box-shadow: none; }
.jn-wrap.is-pseudo-fs { position: fixed; inset: 0; z-index: 9999; max-width: none; background: #1f2937; }
.jn-wrap.is-pseudo-fs .jn-stage { aspect-ratio: auto; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none; }
html.jn-lock, html.jn-lock body { overflow: hidden; }

/* HUD */
.jn-hud {
  position: absolute; z-index: 5; inset: 0 0 auto 0; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; pointer-events: none; font: 700 0.8rem/1.2 var(--font-sans);
}
.jn-hud__stats { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; flex: 1; min-width: 0; }
.jn-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px;
  background: rgba(251, 247, 238, 0.88); border: 1px solid rgba(44, 56, 72, 0.15); white-space: nowrap;
}
.jn-chip b { font-variant-numeric: tabular-nums; }
/* the nap meter: how deeply Jack is asleep */
.jn-meter { position: relative; display: inline-block; width: 110px; height: 9px; border-radius: 99px; background: rgba(44, 56, 72, 0.16); overflow: hidden; }
.jn-meter span { position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--color-sage-2); border-radius: 99px; transition: width 0.15s ease, background-color 0.3s ease; }
.jn-meter.is-mid span { background: #D9A441; }
.jn-meter.is-low span { background: var(--color-danger); }
.jn-hud__btns { display: flex; gap: 6px; margin-left: auto; pointer-events: auto; }
/* over a card, only the Pause / Sound / Full screen buttons stay on top */
.jn-stage.has-panel .jn-hud__stats { visibility: hidden; }
.jn-icon {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 1px solid rgba(44, 56, 72, 0.15); border-radius: 50%; background: rgba(251, 247, 238, 0.88);
  color: var(--color-ink); cursor: pointer;
}
.jn-icon:hover { background: #fff; }
.jn-icon:focus-visible { outline: 3px solid var(--color-coral); outline-offset: 1px; }
.jn-icon:disabled { opacity: 0.45; cursor: default; }
@media (pointer: coarse) { .jn-icon { width: 44px; height: 44px; } }
.jn-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.jn-icon .jn-i-play, .jn-icon.is-paused .jn-i-pause { display: none; }
.jn-icon.is-paused .jn-i-play { display: block; }
.jn-icon .jn-slash { display: none; }
.jn-icon[aria-pressed="false"] .jn-slash { display: block; }
.jn-icon .jn-i-shrink, .jn-icon.is-fs .jn-i-grow { display: none; }
.jn-icon.is-fs .jn-i-shrink { display: block; }
@media (max-width: 640px) {
  .jn-hud { align-items: flex-start; font-size: 0.74rem; }
  .jn-meter { width: 56px; }
  .jn-chip { padding: 4px 8px; }
  .jn-hide-sm { display: none; }
}

/* the card: title, pause, stage clear, game over, win */
.jn-panel {
  position: absolute; z-index: 4; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 56px 12px 12px; background: rgba(44, 56, 72, 0.3);
}
.jn-panel[hidden] { display: none; }
.jn-card {
  width: 100%; max-width: 560px; max-height: 100%; overflow: auto; overscroll-behavior: contain;
  background: var(--color-cream-3); border: 1px solid var(--color-line); border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px -20px rgba(31, 41, 55, 0.55); padding: clamp(16px, 3.5cqw, 28px);
  touch-action: pan-y; user-select: text; -webkit-user-select: text;
}
.jn-stage { container-type: inline-size; }
.jn-card h2 { font-family: var(--font-display); font-size: clamp(1.4rem, 4.2cqw, 2.1rem); line-height: 1.1; margin: 0 0 0.5rem; }
.jn-card p { margin: 0 0 0.7rem; font-size: 0.95rem; }
.jn-kicker { font: 700 0.72rem/1.2 var(--font-sans) !important; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-sage-2); margin-bottom: 0.35rem !important; }
.jn-small, .jn-tally__fine { color: var(--color-ink-2); font-size: 0.82rem !important; }
.jn-stats, .jn-best { font-size: 0.9rem !important; }
.jn-controls { margin: 0 0 0.8rem; padding-left: 1.1rem; font-size: 0.9rem; }
.jn-controls li { margin-bottom: 0.25rem; }
.jn-controls kbd, .jn-keys kbd {
  display: inline-block; min-width: 1.6em; padding: 0.05em 0.4em; border: 1px solid var(--color-line); border-bottom-width: 2px;
  border-radius: 5px; background: #fff; font: 700 0.8em/1.4 var(--font-sans); text-align: center;
}
/* the buttons stay in view at the bottom of the card when the results scroll */
.jn-btns {
  position: sticky; bottom: calc(-1 * clamp(16px, 3.5cqw, 28px)); z-index: 1;
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0.9rem calc(-1 * clamp(16px, 3.5cqw, 28px)) calc(-1 * clamp(16px, 3.5cqw, 28px));
  padding: 10px clamp(16px, 3.5cqw, 28px) clamp(12px, 3cqw, 22px); background: var(--color-cream-3);
  border-top: 1px solid var(--color-line-2);
}
.jn-btns .btn { min-height: 44px; }

/* timing offset, in the title and pause cards */
.jn-offset { display: flex; align-items: center; gap: 8px; margin: 0.4rem 0 0.4rem; font-size: 0.9rem; }
.jn-offset span { margin-right: 4px; }
.jn-offset b { min-width: 4.2em; text-align: center; font-variant-numeric: tabular-nums; }
.jn-off-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--color-line); background: #fff; color: var(--color-ink);
  font: 800 1.1rem/1 var(--font-sans); cursor: pointer;
}
.jn-off-btn:hover { background: var(--color-cream-2); }
.jn-off-btn:focus-visible { outline: 3px solid var(--color-coral); outline-offset: 1px; }

/* the win card: YourRegistrar's notifications next to ours */
.jn-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0.6rem 0 0.8rem; }
@container (max-width: 520px) { .jn-compare { grid-template-columns: 1fr; } }
.jn-tally, .jn-chill { border-radius: var(--radius); padding: 12px 12px 6px; font-size: 0.84rem; }
.jn-tally { background: #fff; border: 1px dashed rgba(44, 56, 72, 0.35); }
.jn-chill { background: rgba(143, 179, 154, 0.2); border: 1px solid var(--color-sage); }
.jn-tally__h { font: 800 0.72rem/1.3 var(--font-sans) !important; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.4rem !important; }
.jn-tally table, .jn-chill table { width: 100%; border-collapse: collapse; }
.jn-tally td, .jn-chill td { padding: 3px 0; vertical-align: top; border-bottom: 1px dotted rgba(44, 56, 72, 0.2); }
.jn-tally td:last-child, .jn-chill td:last-child { text-align: right; padding-left: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.jn-tally tfoot td, .jn-chill tfoot td { font-weight: 800; border-bottom: 0; padding-top: 6px; }
.jn-tally tfoot td:last-child { color: var(--color-danger); }
.jn-chill tfoot td:last-child { color: var(--color-success); }

/* below the stage */
.jn-points { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--space-4); margin: var(--space-5) 0 0; padding: 0; list-style: none; }
.jn-points li { background: var(--bg-card); border: 1px solid var(--color-line); border-radius: var(--radius); padding: var(--space-4) var(--space-5); }
.jn-points h3 { font-size: var(--fs-md, 1.05rem); margin: 0 0 var(--space-2); }
.jn-points p { margin: 0 0 var(--space-2); font-size: var(--fs-sm); }
.jn-points p:last-child { margin-bottom: 0; }
.jn-points .jn-us { color: #4F7563; font-weight: 700; }   /* darker than sage-2 for 4.5:1 on the cards */
.jn-under { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-top: var(--space-4); }
.jn-keys { margin: 0; font-size: var(--fs-sm); color: var(--color-ink-2); }
.jn-note { max-width: 760px; margin: var(--space-5) auto 0; text-align: center; font-size: var(--fs-sm); color: var(--color-muted); }
.jn-related { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); margin-top: var(--space-8); }
.jn-related a {
  display: block; padding: var(--space-5); text-decoration: none; color: var(--color-ink);
  background: var(--bg-card); border: 1px solid var(--color-line); border-radius: var(--radius);
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.jn-related a:hover { box-shadow: var(--shadow); transform: translateY(-1px); color: var(--color-ink); }
.jn-related strong { display: block; font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--space-1); }
.jn-related span { font-size: var(--fs-sm); color: var(--color-ink-2); }
