/* =====================================================================
   The hub, and the memory box.

   The hub is a desk with the chapters laid out on it as scrapbook cards —
   photo, caption, progress, keepsakes — including the ones still sealed.
   Loaded last so it can quietly override the generic .screen padding.
   ===================================================================== */

.screen.hub-screen,
.screen.mem-screen {
  padding: 0;
  align-items: stretch;
  overflow-y: auto;
}

/* ------------------------------------------------------------- the desk */

.hub-page {
  position: relative;
  width: 100%;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-content: center;
  gap: clamp(6px, 2vh, 18px);
  padding: calc(var(--safe-top, 0px) + 20px) 0 calc(var(--safe-bottom, 0px) + 16px);
}

/* faint pencil ruling, so it reads as a working surface not a menu */
.hub-page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .5;
  background:
    repeating-linear-gradient(0deg, transparent 0 33px, rgba(69,48,38,.045) 33px 34px),
    radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,.5), transparent 62%);
}

.hub-head {
  position: relative;
  text-align: center;
  padding: 0 20px;
}

.hub-eyebrow {
  margin: 0;
  color: var(--rose-deep);
  font-size: 1.35rem;
  transform: rotate(-1.5deg);
}

.hub-title {
  font-size: clamp(2rem, 7vw, 3.1rem);
  color: var(--ink);
}

.hub-lede {
  margin: .4em auto 0;
  max-width: 32ch;
  color: var(--ink-soft);
  font-size: .98rem;
  line-height: 1.5;
}

/* ------------------------------------------------------------- the rail */

.hub-rail {
  position: relative;
  display: flex;
  /* cards take their content's height and sit centred on the desk — stretched
     to the full rail they were mostly empty space under the button */
  align-items: center;
  gap: 18px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* the side padding is what lets the first and last card sit centred */
  padding: 16px max(18px, calc(50% - 172px)) 24px;
}

.hub-rail::-webkit-scrollbar { display: none; }

.hub-card {
  position: relative;
  flex: 0 0 min(78vw, 330px);
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 16px 17px 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fffaf0, #f4e6ca);
  box-shadow: var(--shadow-card);
  transform: rotate(-.55deg);
  transition: transform .25s ease, box-shadow .25s ease;
}

.hub-card:nth-child(even) { transform: rotate(.6deg); }
.hub-card:hover { transform: rotate(0deg) translateY(-3px); }

/* the chapter's own colour, as a spine down the left edge */
.hub-card::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--chapter-tint, var(--amber));
  opacity: .8;
}

.hub-card.is-locked,
.hub-card.is-soon { background: linear-gradient(180deg, #f6efdf, #ece0c6); }
.hub-card.is-soon { border-style: dashed; }
.hub-card.is-soon::before { opacity: .3; }

/* ----- the little map, taped down like a photograph ----- */

.hub-card-photo {
  position: relative;
  margin: 4px 2px 2px;
  border-radius: 11px;
  border: 1px solid rgba(69,48,38,.14);
  background: #fdf6e6;
  box-shadow: inset 0 2px 12px rgba(69,48,38,.09);
}

.hub-card-photo .mini-map { display: block; width: 100%; height: auto; border-radius: 11px; }

.hub-card.is-locked .mini-map,
.hub-card.is-soon .mini-map { filter: grayscale(1); opacity: .42; }

.hub-tape {
  position: absolute;
  width: 54px; height: 17px;
  background: rgba(240,225,183,.8);
  border: 1px solid rgba(160,128,70,.22);
  box-shadow: 0 1px 3px rgba(69,48,38,.16);
}
.hub-tape-a { left: -11px; top: -7px; transform: rotate(-14deg); }
.hub-tape-b { right: -11px; bottom: -7px; transform: rotate(-9deg); }

.hub-seal {
  position: absolute;
  left: 50%; top: 50%;
  width: 62px; height: 62px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%) rotate(-8deg);
  border-radius: 50%;
  color: #ffe3d2;
  background: radial-gradient(circle at 34% 30%, #d3624a, var(--seal));
  font-family: var(--serif);
  font-size: 1.8rem;
  box-shadow: 0 9px 18px rgba(80,22,12,.36), inset 0 0 0 2px rgba(255,220,200,.28);
}

/* the seal breaking, once, on the visit after the chapter unlocks */
.hub-card.just-unlocked .hub-seal { animation: hubSealBreak 1.5s ease-in .35s both; }
.hub-card.just-unlocked .mini-map { animation: hubMapWake 1.2s ease-out .9s both; }
.hub-card.just-unlocked { animation: hubCardWake 1.4s ease-out .8s both; }

@keyframes hubSealBreak {
  0%   { transform: translate(-50%,-50%) rotate(-8deg) scale(1); opacity: 1; }
  22%  { transform: translate(-50%,-50%) rotate(-13deg) scale(1.06); }
  32%  { transform: translate(-50%,-50%) rotate(-3deg) scale(1.06); }
  46%  { transform: translate(-50%,-50%) rotate(-11deg) scale(1.08); }
  100% { transform: translate(-50%,-58%) rotate(16deg) scale(1.5); opacity: 0; }
}
@keyframes hubMapWake { from { filter: grayscale(1); opacity: .42; } to { filter: none; opacity: 1; } }
@keyframes hubCardWake {
  0%, 40% { box-shadow: var(--shadow-card); }
  60%     { box-shadow: var(--shadow-card), 0 0 0 3px rgba(217,142,59,.55), 0 0 34px rgba(217,142,59,.5); }
  100%    { box-shadow: var(--shadow-card); }
}

.hub-stamp {
  position: absolute;
  right: 7px; top: 7px;
  padding: 1px 10px 2px;
  border: 2px solid var(--sage-deep);
  border-radius: 6px;
  color: var(--sage-deep);
  background: rgba(255,250,236,.72);
  font-size: 1.1rem;
  line-height: 1.25;
  transform: rotate(-8deg);
  opacity: .88;
}

/* ----- caption ----- */

.hub-card-body { display: flex; flex-direction: column; gap: 7px; min-height: 0; }
.hub-kicker { margin: 0; color: var(--rose-deep); font-size: 1.15rem; line-height: 1.1; }
.hub-card-title { font-size: clamp(1.3rem, 4.6vw, 1.6rem); }
.hub-card-sub { margin: 0; color: var(--ink-soft); font-size: .92rem; line-height: 1.45; }

.hub-meter { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.hub-dots { display: flex; flex-wrap: wrap; gap: 5px; }
.hub-dots i {
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1.5px solid rgba(69,48,38,.28);
}
.hub-dots i.on { background: var(--chapter-tint, var(--amber)); border-color: transparent; }
.hub-count { margin: 0; color: var(--ink-soft); font-size: .82rem; letter-spacing: .01em; }

.hub-keepsakes { display: flex; flex-wrap: wrap; gap: 4px; }
.hub-keepsake {
  width: 25px; height: 25px;
  display: grid;
  place-items: center;
  border: 1.4px dashed rgba(69,48,38,.24);
  border-radius: 7px;
}
.hub-keepsake.found { border-style: solid; border-color: rgba(69,48,38,.2); background: #fff7e6; }
.hub-keepsake .pot-icon-inline { width: 1.05em; height: 1.05em; margin: 0; }

.hub-card-foot { margin-top: auto; padding-top: 4px; }
.hub-go { width: 100%; }
.hub-lock-note {
  margin: 0;
  padding: 9px 12px;
  border: 1.5px dashed rgba(69,48,38,.26);
  border-radius: 12px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.25;
}

/* ------------------------------------------------------------- the foot */

.hub-foot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 max(16px, var(--safe-left, 0px)) 0 max(16px, var(--safe-right, 0px));
}

.hub-memory {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 18px 9px 11px;
  border: 1.5px solid rgba(69,48,38,.2);
  border-radius: 999px;
  background: linear-gradient(180deg, #fffaf0, #f3e4c6);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform .18s ease, box-shadow .18s ease;
}
.hub-memory:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.hub-memory-icon { width: 34px; height: 34px; flex: none; }
.hub-memory strong { display: block; font-size: .98rem; }
.hub-memory small { display: block; color: var(--ink-soft); font-size: .74rem; }

.hub-restart {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  padding: 9px 15px;
  border: 1.5px solid rgba(69,48,38,.18);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--hand);
  font-size: 1.05rem;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.hub-restart:hover { color: var(--seal); border-color: rgba(176,68,47,.45); background: rgba(255,247,233,.7); }
.hub-restart .pot-icon-inline { width: 1.05em; height: 1.05em; margin: 0; }

/* -------------------------------------------------------- the miniatures */

.mini-map { overflow: visible; }
.mini-trail {
  fill: none;
  stroke: rgba(105,80,50,.45);
  stroke-width: 2.2;
  stroke-dasharray: 5 5;
  stroke-linecap: round;
}
.mini-stop { fill: #fff8e8; stroke: var(--amber); stroke-width: 2; }
.mini-stop.is-done { fill: var(--amber); stroke: var(--amber-deep); }

.mini-river { fill: none; stroke: #a9cbd9; stroke-width: 5.5; opacity: .6; stroke-linecap: round; }
.mini-line { fill: none; stroke: #55636e; stroke-width: 3.6; stroke-linejoin: round; stroke-linecap: round; }
.mini-branch { stroke: #9dabb5; stroke-width: 2.6; stroke-linecap: round; }
.mini-london .mini-stop { fill: #fffdf8; stroke: #38444e; }
.mini-london .mini-stop.is-done { fill: #c71f45; stroke: #7d1028; }

.mini-soon { opacity: .9; }
.mini-soon .mini-arc { fill: none; stroke: rgba(105,80,50,.4); stroke-width: 2; stroke-dasharray: 4 5; }
.mini-soon .mini-city { fill: rgba(69,48,38,.3); }
.mini-soon .mini-plane { fill: rgba(69,48,38,.42); }

/* ------------------------------------------------------- the memory box */

.mem-page {
  width: 100%;
  min-height: 100%;
  padding: calc(var(--safe-top, 0px) + 18px) max(16px, var(--safe-right, 0px))
           calc(var(--safe-bottom, 0px) + 26px) max(16px, var(--safe-left, 0px));
}

.mem-head { max-width: 900px; margin: 0 auto 18px; text-align: center; }
.mem-head .nav-back { position: absolute; left: max(16px, var(--safe-left, 0px)); }
.mem-head > p { margin: 30px 0 0; color: var(--rose-deep); font-size: 1.3rem; }
.mem-head h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); }

.mem-body { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

.mem-section-title {
  margin: 0 0 9px;
  font-size: 1.15rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-family: var(--body);
  font-weight: 700;
}

.mem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 11px; }

.mem-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fffaf0, #f5e8ce);
  box-shadow: var(--shadow-soft);
}
.mem-card.is-locked { background: rgba(240,231,211,.6); box-shadow: none; }
.mem-card.is-locked .mem-icon { filter: grayscale(1); opacity: .45; }
.mem-icon { width: 34px; height: 34px; flex: none; }
.mem-text { min-width: 0; flex: 1 1 auto; }
.mem-text h3 { font-size: 1.02rem; line-height: 1.2; }
.mem-text p { margin: 2px 0 0; color: var(--ink-soft); font-size: .78rem; line-height: 1.35; }

.mem-open {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .3em;
  padding: 6px 12px;
  border: 1.5px solid rgba(69,48,38,.22);
  border-radius: 999px;
  background: #fff8ea;
  color: var(--ink-soft);
  font-family: var(--hand);
  font-size: 1.02rem;
  cursor: pointer;
}
.mem-open:hover { color: var(--ink); border-color: rgba(69,48,38,.45); }
.mem-open .pot-icon-inline { width: .95em; height: .95em; margin: 0; }

.mem-keepsakes { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.mem-keepsake { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }
.mem-keepsake > span { width: 46px; height: 46px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: #fff8ea; }
.mem-keepsake figcaption { color: var(--ink-soft); font-size: .72rem; line-height: 1.3; }
.mem-keepsake.is-locked > span { border-style: dashed; background: transparent; }
.mem-keepsake.is-locked figcaption { opacity: .65; }
.mem-keepsake.is-locked .pot-icon { filter: grayscale(1); opacity: .4; }

.mem-hearts { display: flex; flex-wrap: wrap; gap: 6px; font-size: 1.5rem; color: #d9a326; }
.mem-heart { opacity: .35; }
.mem-heart.found { opacity: 1; color: #e8b432; }
.mem-note { margin: 8px 0 0; color: var(--ink-soft); font-size: 1.05rem; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 560px) {
  .hub-lede { display: none; }
  .hub-card { flex-basis: min(84vw, 320px); }
  .hub-rail { gap: 14px; padding: 12px max(14px, calc(50% - 160px)) 18px; }
  .hub-foot { gap: 8px; }
  .hub-memory { padding: 8px 15px 8px 9px; }
  .hub-memory-icon { width: 30px; height: 30px; }
  .mem-head .nav-back { position: static; }
  .mem-head > p { margin: 12px 0 0; }
}

@media (max-height: 680px) {
  .hub-title { font-size: clamp(1.6rem, 6vw, 2.2rem); }
  .hub-lede { display: none; }
  .hub-card-sub { display: none; }
  .hub-rail { padding-top: 10px; padding-bottom: 14px; }
}

/* A phone on its side is barely taller than the card is tall, so the card
   turns on its side too: the photo beside the caption instead of above it. */
@media (max-height: 560px) {
  .hub-page { gap: 4px; padding-top: calc(var(--safe-top, 0px) + 8px); }
  .hub-eyebrow { display: none; }
  .hub-card {
    flex-basis: min(88vw, 460px);
    display: grid;
    grid-template-columns: 40% 1fr;
    grid-template-areas: "photo body" "photo foot";
    align-content: center;
    gap: 8px 14px;
    padding: 12px 14px;
  }
  .hub-card-photo { grid-area: photo; align-self: center; margin: 0; }
  .hub-card-body { grid-area: body; gap: 5px; }
  .hub-card-foot { grid-area: foot; padding-top: 0; }
  .hub-card-sub { display: block; font-size: .82rem; }
  .hub-seal { width: 48px; height: 48px; font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hub-card, .hub-memory { transition: none; }
  .hub-card:hover { transform: none; }
  /* the seal still goes — it just goes at once, with no shaking */
  .hub-card.just-unlocked,
  .hub-card.just-unlocked .mini-map { animation: none; }
  .hub-card.just-unlocked .hub-seal { animation: hubSealFade .6s ease-out .3s both; }
}
@keyframes hubSealFade { to { opacity: 0; } }
