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

/* the game sits straight under the breadcrumb; heading and intro follow it */
.jc-top { padding-block: clamp(1rem, 2.5vw, 1.75rem) clamp(2rem, 4vw, 3.5rem); }
.jc-top .crumb { max-width: 1100px; margin: 0 auto var(--space-3); }
.jc-intro { max-width: 760px; margin: var(--space-7) auto 0; text-align: center; }
.jc-intro h1 { margin-bottom: var(--space-4); }
.jc-lede { color: var(--text-muted); font-size: var(--fs-xl); }
@media (max-width: 640px) { .jc-lede { font-size: var(--fs-lg); } }
.jc-wrap { max-width: 1100px; margin-inline: auto; position: relative; }
.jc-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; isolation: isolate;
  background: #1E3A33; 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) { .jc-stage { aspect-ratio: 4 / 5; } }
/* a tablet held upright: a taller stage gives the piano the tall layout's wide keys
   (16:9 left eleven keys about 38 px wide on a 10" iPad, with half the screen empty below) */
@media (min-width: 641px) and (max-width: 1100px) and (orientation: portrait) {
  .jc-stage { aspect-ratio: 4 / 5; max-height: calc(100vh - 150px); max-height: calc(100svh - 150px); }
}
/* a phone on its side: the whole stage fits under the sticky header (16:9 ran the piano off the bottom) */
@media (max-height: 560px) and (orientation: landscape) {
  .jc-stage { aspect-ratio: auto; height: calc(100vh - 72px); height: calc(100svh - 72px); min-height: 230px; }
}
.jc-stage:focus { outline: none; }
.jc-stage:focus-visible { outline: 3px solid var(--color-coral); outline-offset: 3px; }
.jc-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

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

/* HUD */
.jc-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);
}
.jc-hud__stats { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; flex: 1; min-width: 0; }
.jc-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;
}
.jc-chip b { font-variant-numeric: tabular-nums; }
/* Jack's mood meter: how much he's enjoying the carol */
.jc-meter { position: relative; display: inline-block; width: 110px; height: 9px; border-radius: 99px; background: rgba(44, 56, 72, 0.16); overflow: hidden; }
.jc-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; }
.jc-meter.is-mid span { background: #D9A441; }
.jc-meter.is-low span { background: var(--color-danger); }
.jc-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 */
.jc-stage.has-panel .jc-hud__stats { visibility: hidden; }
.jc-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;
}
.jc-icon:hover { background: #fff; }
.jc-icon:focus-visible { outline: 3px solid var(--color-coral); outline-offset: 1px; }
.jc-icon:disabled { opacity: 0.45; cursor: default; }
@media (pointer: coarse) { .jc-icon { width: 44px; height: 44px; } }
.jc-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.jc-icon .jc-i-play, .jc-icon.is-paused .jc-i-pause { display: none; }
.jc-icon.is-paused .jc-i-play { display: block; }
.jc-icon .jc-slash { display: none; }
.jc-icon[aria-pressed="false"] .jc-slash { display: block; }
.jc-icon .jc-i-shrink, .jc-icon.is-fs .jc-i-grow { display: none; }
.jc-icon.is-fs .jc-i-shrink { display: block; }
@media (max-width: 640px) {
  .jc-hud { align-items: flex-start; font-size: 0.74rem; }
  .jc-meter { width: 56px; }
  .jc-chip { padding: 4px 8px; }
  .jc-hide-sm { display: none; }
}
/* the short sideways-phone stage: a compact HUD, so the far end of the lanes stays clear */
@media (max-height: 560px) and (orientation: landscape) {
  .jc-hud { font-size: 0.74rem; padding: 6px 8px; }
  .jc-meter { width: 56px; }
  .jc-chip { padding: 3px 8px; }
  .jc-hide-sm { display: none; }
}

/* the card: title, pause, stage clear, game over, win */
.jc-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);
}
.jc-panel[hidden] { display: none; }
.jc-card {
  width: 100%; max-width: 640px; 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;
}
.jc-stage { container-type: inline-size; }
.jc-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; }
.jc-card p { margin: 0 0 0.7rem; font-size: 0.95rem; }
.jc-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; }
.jc-small, .jc-tally__fine { color: var(--color-ink-2); font-size: 0.82rem !important; }
.jc-stats, .jc-best { font-size: 0.9rem !important; }
.jc-controls { margin: 0 0 0.8rem; padding-left: 1.1rem; font-size: 0.9rem; }
.jc-controls li { margin-bottom: 0.25rem; }
.jc-card kbd, .jc-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 */
.jc-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);
}
.jc-btns .btn { min-height: 44px; }

/* timing offset, in the title and pause cards */
.jc-offset { display: flex; align-items: center; gap: 8px; margin: 0.4rem 0 0.4rem; font-size: 0.9rem; }
.jc-offset span { margin-right: 4px; }
.jc-offset b { min-width: 4.2em; text-align: center; font-variant-numeric: tabular-nums; }
.jc-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;
}
.jc-off-btn:hover { background: var(--color-cream-2); }
.jc-off-btn:focus-visible { outline: 3px solid var(--color-coral); outline-offset: 1px; }

/* the song list on the title card */
.jc-songs { list-style: none; margin: 0.4rem 0 0.8rem; padding: 0; display: grid; gap: 6px; }
@container (min-width: 760px) { .jc-songs { grid-template-columns: 1fr 1fr; } }
.jc-song {
  width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "t b" "m b"; align-items: center; gap: 2px 12px;
  padding: 9px 12px; text-align: left; cursor: pointer; color: var(--color-ink);
  background: #fff; border: 1px solid var(--color-line); border-radius: var(--radius);
  font: inherit; transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.jc-song:hover { border-color: var(--color-coral); background: #FFFDF8; }
.jc-song:focus-visible { outline: 3px solid var(--color-coral); outline-offset: 1px; }
.jc-song__t { grid-area: t; font-weight: 800; font-size: 0.98rem; }
.jc-song__m { grid-area: m; font-size: 0.8rem; color: var(--color-ink-2); }
.jc-song__b { grid-area: b; font-size: 0.8rem; color: var(--color-ink-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.jc-lvl { display: inline-block; padding: 0 7px; border-radius: 99px; font-weight: 800; font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; }
.jc-lvl--easy { background: rgba(79, 163, 107, 0.18); color: #2F6B45; }
.jc-lvl--medium { background: rgba(232, 196, 90, 0.3); color: #7A5A12; }
.jc-lvl--hard { background: rgba(200, 71, 63, 0.16); color: #9A2F28; }
.jc-stars { color: #C9971E; letter-spacing: 0.06em; }
.jc-big .jc-stars { font-size: 1.9rem; }
.jc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 0.7rem; font-size: 0.9rem; }
.jc-row__l { font-weight: 800; margin-right: 4px; }
.jc-seg, .jc-midi {
  min-height: 36px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--color-line); background: #fff;
  color: var(--color-ink); font: 700 0.86rem/1 var(--font-sans); cursor: pointer;
}
.jc-seg[aria-pressed="true"] { background: var(--color-ink); border-color: var(--color-ink); color: #fff; }
.jc-midi { margin-left: auto; }
.jc-seg:focus-visible, .jc-midi:focus-visible { outline: 3px solid var(--color-coral); outline-offset: 1px; }
.jc-btns[hidden] { display: none; }
/* the results card: Jack's wish */
.jc-wish { margin: 0.6rem 0 0.2rem; padding: 10px 12px; border-radius: var(--radius); background: rgba(143, 179, 154, 0.2); border: 1px solid var(--color-sage); font-size: 0.88rem; }
.jc-wish p { margin: 0 0 0.3rem; font-size: 0.88rem; }
.jc-wish__h { font: 800 0.72rem/1.3 var(--font-sans) !important; letter-spacing: 0.08em; text-transform: uppercase; color: #4F7563; }
/* the streak multiplier chip lights up */
.jc-chip.is-hot { background: #E8C45A; border-color: #C9971E; }

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

/* the cards on a sideways phone: the stage is only about 270 px tall, so the Pause / Sound / Full screen
   buttons stack down the right while a card is up, and the card's buttons scroll with it (kept stuck to
   the bottom they covered the stars and the score) */
@media (max-height: 560px) and (orientation: landscape) {
  .jc-stage.has-panel .jc-hud__btns { flex-direction: column; }
  .jc-panel { padding: 6px 62px 6px 10px; }
  .jc-btns { position: static; }
}
