/* ===================================
   JOURNEY.CSS - Journey strip (W5), credits card (R9) and the journal (P1).
   =================================== */

/* Strip: inside #ui-overlay (hidden during the splash and the opening ride), in the top band
   between the Quick View button (x 14-175) and the audio toggle (46 px, right 14). Five
   equal 24 px cells: node i sits in cell i, the dot runs over the same 120 px. */
.journey-strip {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 24px);
  justify-items: center;
  align-items: center;
  padding: 4px;
  background: rgba(20, 22, 30, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.15);
  pointer-events: auto;
}

.journey-line {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: rgba(244, 228, 193, 0.4);
  pointer-events: none;
}

.journey-dot {
  position: absolute;
  top: -4px;
  left: 0;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: #ff6b6b;
  border: 1px solid #10141e;
  z-index: 1;
}

.journey-node {
  position: relative;
  width: 20px;
  height: 20px;
  padding: 0;
  font: 16px/1 "VT323", monospace;
  color: #f4e4c1;
  background: #3b2414;
  border: 2px solid #f4e4c1;
  cursor: pointer;
}

.journey-node:disabled {
  cursor: default;
}

.journey-node[data-chapter="0"] {
  opacity: 0.6;
}

.journey-node.is-current {
  color: #10141e;
  background: #38b764;
}

.journey-node.is-stamped::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -5px;
  width: 7px;
  height: 7px;
  background: #ffe135;
  border: 1px solid #10141e;
}

.journey-strip.is-busy .journey-node {
  opacity: 0.45;
}

/* A minigame course shares the top band with its HUD: the strip steps aside (R21). */
.journey-strip.is-off {
  visibility: hidden;
}

/* Phones: the top band is too narrow for the strip between the Quick View button and the
   audio toggle (< 377 px wide; the centred strip meets the button below ~494 px), so it
   takes its own row under the Quick View button. */
@media (max-width: 500px) {
  .journey-strip {
    top: 72px;
    left: 14px;
    transform: none;
  }
}

/* Credits card (R9, R23): body-level, above the fade (3000) and the title card (3200), below
   toasts (9999) and the Quick View button (10010). The backdrop takes taps off the canvas. */
.credits {
  position: fixed;
  inset: 0;
  z-index: 3300;
  display: grid;
  place-items: center;
  padding: 72px 16px 16px; /* the top row belongs to the Quick View button */
  background: rgba(10, 12, 20, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s, visibility 0s linear 0.4s;
}

.credits.is-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s;
}

.credits-card {
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 88px);
  overflow-y: auto;
  text-align: center;
  /* .pixel-panel only pads: the panel look comes from here (as .modal-content does). */
  background: var(--panel-bg);
  border: 4px solid var(--panel-border);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
}

.credits-title {
  margin: 0 0 8px;
}

.credits-line {
  margin: 0 0 4px;
  font-size: 20px;
}

.credits-stats {
  margin: 10px 0 14px;
  font-size: 22px;
  color: var(--accent);
}

.credits-contacts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.credits-link {
  display: block;
  padding: 8px;
  font-size: 20px;
  color: #10141e;
  background: #f4e4c1;
  border: 2px solid #3b2414;
  text-decoration: none;
}

/* A link with no source (a contact missing from Quick View) hides, display:block aside. */
.credits-link[hidden] {
  display: none;
}

.credits-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.credits-close {
  padding: 6px 14px;
  font: 18px "VT323", monospace;
  color: #f4e4c1;
  background: transparent;
  border: 2px solid rgba(244, 228, 193, 0.5);
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .credits,
  .credits.is-on {
    transition: none;
  }
}

/* Journal button (P1): the audio toggle's look (class audio-toggle), one slot to its left
   (46 px + 10 px gap). It sits after the minigame HUD in #ui-overlay, so a running course
   hides it, as the journal itself refuses to open then (R28). */
.journal-open {
  right: 70px;
}

.minigame-hud:not(.hidden) ~ .journal-open {
  visibility: hidden;
}

/* Journal (P1): a modal <dialog> (top layer). Like Quick View it is its own scroll container:
   body is position:fixed with touch-action:none, so only this box scrolls on phones. */
.journal {
  width: min(440px, calc(100vw - 24px));
  max-width: none; /* the UA's dialog:modal max-width would clamp 351 px to 337 at 375 */
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 4px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text-light);
  font-family: "VT323", monospace;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.journal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.journal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel-bg);
  border-bottom: 3px solid var(--panel-border);
}

.journal-title {
  min-width: 0;
  font-size: 26px;
  font-weight: normal;
  color: var(--accent);
}

/* Focused on open only so that no button holds the focus (a held key presses nothing). */
.journal-title:focus {
  outline: none;
}

.journal-close {
  flex: none;
  width: 36px;
  height: 36px;
  font: 24px/1 "VT323", monospace;
  color: var(--text-light);
  background: var(--accent);
  border: 3px solid var(--text-light);
  cursor: pointer;
}

.journal-body {
  padding: 0 14px 14px;
}

.journal-sec {
  padding: 10px 0;
  border-bottom: 2px solid var(--panel-border);
}

.journal-sec:last-child {
  border-bottom: 0;
}

.journal-h {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 22px;
  font-weight: normal;
}

.journal-count {
  color: #ffe135;
}

.journal-list {
  display: grid;
  gap: 4px;
  list-style: none;
}

/* A row: its mark (::before) on the left, the name and an optional second line beside it. */
.journal-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  column-gap: 6px;
  font-size: 19px;
  line-height: 1.15;
}

.journal-item::before {
  grid-row: span 2;
}

.journal-name,
.journal-sub {
  grid-column: 2;
}

.journal-item:not(.is-on) .journal-name {
  opacity: 0.6;
}

.journal-sub,
.journal-hint {
  font-size: 17px;
  opacity: 0.8;
}

.journal-hint {
  margin-bottom: 6px;
}

.journal-found {
  font-size: 17px;
  color: var(--primary);
}

/* Row marks: a stamp per station, a cup per kopi (a black silhouette until found), a clock
   per minigame record, a trophy or a lock per achievement. */
.journal-list--stamp .journal-item::before {
  content: "⬜";
}

.journal-list--stamp .is-on::before {
  content: "✅";
}

.journal-list--kopi .journal-item::before {
  content: "☕";
  filter: brightness(0);
  opacity: 0.6;
}

.journal-list--kopi .is-on::before {
  filter: none;
  opacity: 1;
}

.journal-list--best .journal-item::before {
  content: "⏱️";
}

.journal-list--ach .journal-item::before {
  content: "🔒";
}

.journal-list--ach .is-on::before {
  content: "🏆";
}
