/*
 * The portal page (scripts/templates/portal.html). Colors and type are the Jubilee family tokens from
 * ThePortalMesh.com packages/ui/tokens.css, copied by name so they mean the same thing here; the blue is
 * the portal pad's rim light (spec 4.4).
 */

:root {
  --bg: #000000;
  --text: #f3f2ee;
  --text-dim: #c9cad4;
  --text-muted: #8c8d9c;
  --accent: #e0a24e;
  --accent-hi: #f0b968;
  --accent-soft: rgba(224, 162, 78, 0.55);
  --border-strong: rgba(255, 255, 255, 0.1);
  --pm-destination: #e0a24e;
  --font-sans: "Segoe UI", Tahoma, Geneva, Verdana, -apple-system, BlinkMacSystemFont, sans-serif;
  /* Cascadia Mono, not Cascadia Code: the Code face draws "://" as a ligature. */
  --font-mono: "Cascadia Mono", "Consolas", "SFMono-Regular", Menlo, monospace;

  --pad-glow: #5ab8ff;
  --pad-glow-soft: rgba(90, 184, 255, 0.35);
  --gutter: 16px;
  color-scheme: dark;
}

@media (min-width: 720px) {
  :root {
    --gutter: 32px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.in-portal {
  overflow: hidden;
}

/* ---- the landing: the hero picture with the title over its left third ---- */

.portal {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--gutter);
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
  overflow: hidden;
}

.portal-hero {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 30%, #0b1a2b 0%, #04070c 55%, #000 100%);
  background-position: center;
  background-size: cover;
}

.portal-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.6) 42%, rgba(0, 0, 0, 0.08) 78%);
}

/* No hero yet: the pad itself stands in for the picture. */
.portal:not(.has-hero) .portal-hero::after {
  content: "";
  position: absolute;
  top: 30%;
  left: 50%;
  width: min(64vmin, 460px);
  aspect-ratio: 1;
  border: 2px solid var(--pad-glow);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 238, 246, 0.1) 0%, rgba(232, 238, 246, 0.03) 62%, transparent 70%);
  box-shadow: 0 0 22px var(--pad-glow-soft), inset 0 0 22px var(--pad-glow-soft), 0 0 90px rgba(90, 184, 255, 0.16);
  transform: translate(-50%, -50%) perspective(900px) rotateX(66deg);
  animation: pad-breathe 5s ease-in-out infinite;
}

@keyframes pad-breathe {
  50% {
    box-shadow: 0 0 34px rgba(90, 184, 255, 0.55), inset 0 0 30px rgba(90, 184, 255, 0.45), 0 0 120px rgba(90, 184, 255, 0.24);
  }
}

.portal-panel {
  position: relative;
  width: 100%;
  max-width: 34rem;
}

@media (min-width: 900px) {
  .portal {
    align-items: center;
    padding-left: clamp(32px, 6vw, 96px);
  }

  .portal-hero::before {
    background:
      linear-gradient(to right, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.62) 30%, rgba(0, 0, 0, 0) 62%),
      linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 40%);
  }

  .portal:not(.has-hero) .portal-hero::after {
    top: 50%;
    left: 70%;
  }
}

.portal-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 3px 12px;
  border: 1px solid rgba(224, 162, 78, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--pm-destination);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.portal-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.portal-name {
  margin: 0 0 10px;
  font-size: clamp(2.25rem, 6.5vw, 4.5rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.6);
}

.portal-address {
  margin: 0 0 6px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-variant-ligatures: none;
  overflow-wrap: anywhere;
}

.portal-meta {
  margin: 0 0 28px;
  color: var(--text-dim);
}

.portal-meta span + span::before {
  content: "\00B7";
  margin: 0 0.5em;
  color: var(--text-muted);
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.portal-button {
  min-height: 48px;
  padding: 0 26px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.portal-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.portal-step-in {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 0 1px rgba(240, 185, 104, 0.4), 0 8px 30px rgba(224, 162, 78, 0.28);
}

.portal-step-in:hover:not(:disabled) {
  background: var(--accent-hi);
  transform: translateY(-1px);
}

.portal-step-in:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  box-shadow: none;
  cursor: default;
}

.portal-preview {
  border-color: var(--border-strong);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
}

.portal-preview:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 480px) {
  .portal-actions .portal-button {
    flex: 1 1 100%;
  }
}

.portal-status {
  min-height: 1.6em;
  margin: 16px 0 0;
  color: var(--text-dim);
}

.portal-status:empty {
  margin-top: 8px;
}

.portal-note {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.portal-noscript {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  margin: 0;
  color: var(--text-dim);
}

/* ---- inside the portal: the look-around view in the browser ---- */

.portal-stage {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000;
}

.portal-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.portal-canvas.is-dragging {
  cursor: grabbing;
}

/* The exit control is there from the first paint, whatever is still loading. */
.portal-step-out {
  position: absolute;
  top: max(var(--gutter), env(safe-area-inset-top));
  left: max(var(--gutter), env(safe-area-inset-left));
  border-color: rgba(90, 184, 255, 0.6);
  background: rgba(6, 9, 16, 0.78);
  color: var(--text);
  box-shadow: 0 0 18px rgba(90, 184, 255, 0.25);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.portal-step-out:hover {
  border-color: var(--pad-glow);
}

.portal-loading {
  position: absolute;
  top: calc(50% + 7.5rem);
  right: 0;
  left: 0;
  margin: 0;
  color: var(--text-dim);
  text-align: center;
  pointer-events: none;
}

.portal-hint {
  position: absolute;
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  left: 50%;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-dim);
  font-size: 0.9rem;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.8s;
}

.portal-hint.is-faded {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
