/* =============================================================================
   COMPONENT: PORTAL (what's behind each door)
   A full-screen <dialog> built by js/components/portal.js. It grows out of the
   door that was opened, then lists that category as calm cards
   (.reel--list in reel.css). Colour comes from data-tone on the dialog.
   ============================================================================= */
html.has-portal { overflow: hidden; }

.portal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--c-ink);
  overflow: hidden;
}

.portal::backdrop { background: rgb(22 19 15 / 0.55); }

/* Grows out of the door's arch (--from is set by JS); centre box otherwise */
.portal[open] { animation: portal-in 560ms var(--e-out) both; }
.portal.is-leaving { animation: portal-out 240ms ease-in both; }

@keyframes portal-in {
  from { clip-path: var(--from, inset(30% 25% 30% 25% round 32px)); }
  to   { clip-path: inset(0 round 0); }
}

@keyframes portal-out { to { opacity: 0; scale: 0.985; } }

/* Reading surface: one typeface (DM Sans), calm paper, hairline borders.
   The comic voice stays on the home page; behind the door it's all business. */
.portal {
  --f-heading: var(--f-body);
  --f-accent:  var(--f-body);
  --f-label:   var(--f-body);
  /* Dark surface, cream cards: the cards are the brightest thing on the page */
  --p-ink:     #faf1dc;
  --p-muted:   #cfc4ae;
  --p-line:    rgb(250 241 220 / 0.18);
  --p-bg:      #1c1712;
  --p-wrap:    820px;     /* bar and cards share one width */
  background: var(--p-bg);
}

/* Scroll lives in here, not on the page behind */
.portal__scroll {
  height: 100%;
  overflow: hidden auto;
  overscroll-behavior: contain;
  padding-bottom: clamp(56px, 8vw, 104px);
  background: var(--p-bg);
}

/* ---- Top bar: back + door switcher, hides while reading down ----------- */
.portal__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 24px);
  min-height: 60px;
  padding: 0 max(var(--gutter), (100% - var(--p-wrap)) / 2);
  background: rgb(28 23 18 / 0.92);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--p-line);
  transition: translate 260ms var(--e-out);
}

.portal__bar.is-hidden { translate: 0 -100%; }

.portal__back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px 0 10px;
  color: var(--p-ink);
  border: 1px solid rgb(250 241 220 / 0.3);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background-color var(--d-fast), border-color var(--d-fast);
}

.portal__back svg { transition: translate var(--d-mid) var(--e-out); }
.portal__back:hover { background: rgb(250 241 220 / 0.1); border-color: var(--p-ink); }
.portal__back:hover svg { translate: -3px 0; }

.portal__tabs {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

.portal__tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--p-muted);
  white-space: nowrap;
  transition: background-color var(--d-fast), color var(--d-fast);
}

.portal__tabs a span { font-variant-numeric: tabular-nums; opacity: 0.6; }
.portal__tabs a:hover { color: var(--p-ink); background: rgb(250 241 220 / 0.08); }

.portal__tabs a[aria-current] {
  color: var(--c-ink);
  background: var(--p-ink);
}

/* ---- Head: category name + one line, centred over the cards ------------ */
.portal__head {
  max-width: calc(640px + 2 * var(--gutter));
  margin: 0 auto clamp(32px, 4vw, 48px);
  padding: clamp(44px, 7vw, 84px) var(--gutter) 0;
  text-align: center;
}

.portal__head .sec-head__title {
  font: 800 clamp(2rem, 1.4rem + 2.4vw, 3.2rem)/1.08 var(--f-body);
  letter-spacing: -0.03em;
  text-transform: none;
  color: var(--p-ink);
}

.portal__head .sec-head__sub {
  margin-top: 12px;
  font: 500 clamp(1rem, 0.95rem + 0.3vw, 1.15rem)/1.55 var(--f-body);
  color: var(--p-muted);
}

/* ---- The list ---------------------------------------------------------- */
.portal__film { width: min(var(--p-wrap), 100% - 2 * var(--gutter)); margin-inline: auto; }

/* Cards rise in gently as they scroll into view */
.portal .frame {
  opacity: 0;
  translate: 0 20px;
  transition: opacity 500ms var(--e-out), translate 500ms var(--e-out);
}

.portal .frame.is-in { opacity: 1; translate: none; }

@media (max-width: 760px) {
  .portal__bar { gap: 10px; padding-inline: 12px; }
  .portal__back { width: 40px; padding: 0; justify-content: center; }
  .portal__back span { display: none; }
  .portal__tabs { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .portal__tabs::-webkit-scrollbar { display: none; }
  .portal__tabs a { padding: 0 12px; }
  .portal__tabs a span { display: none; }
  .portal__head { padding-top: 32px; }
}

/* The closing "more coming" panel, restyled for the dark surface */
.portal .reel--list .frame--leader .frame__inner { border-color: rgb(250 241 220 / 0.3); color: var(--p-ink); }
.portal .reel--list .frame--leader .frame__title { color: var(--p-ink); }
.portal .reel--list .frame--leader .frame__text { color: var(--p-muted); }
.portal .reel--list .frame__actions .btn { background: transparent; border-color: rgb(250 241 220 / 0.35); color: var(--p-ink); }
.portal .reel--list .frame__actions .btn:hover { background: rgb(250 241 220 / 0.1); border-color: var(--p-ink); }
.portal .reel--list .frame__actions .btn--mustard { background: var(--p-ink); color: var(--c-ink); border-color: var(--p-ink); }
.portal .reel--list .frame__actions .btn--mustard:hover { background: #fff; }
