/*
*
* Copyright (c) 2008 Simulation Lab Software. All rights reserved.
* www.simlab-soft.com
*
* Licensees holding a valid SimLab License Agreement may use this file
* in accordance with the rights, responsibilities and obligations
* contained therein.
*
* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
* ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
* MERCHANTABILITY ARE HEREBY DISCLAIMED.
*
*/

/* The public page behind a shared link (/content/share/<guid>), dressed in the
   SimLab web portal's design: the same tokens (WebVRViewerPortal
   src/styles/tokens.css), the same two faces, the same gold. The fonts are
   served from here because PAGE_CSP allows no font host but 'self'. */

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/manrope-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('../fonts/space-grotesk-latin.woff2') format('woff2');
}

:root {
  color-scheme: dark;
  --app-bg: radial-gradient(120% 90% at 50% -10%, #14161c 0%, #0a0b0e 45%, #070809 100%);
  --bg-deep: #070809;
  --surface: #0b0c10;
  --surface-2: #101217;
  --surface-hover: #15171c;
  --card: #121419;
  --card-inset: #0d0e12;
  --avatar-bg: #1c1f26;
  --on-scrim: #eef0f3;

  --text: #f4f5f7;
  --text-2: #dfe2e7;
  --text-3: #c7ccd4;
  --text-4: #aeb4bf;
  --text-5: #9aa1ad;
  --text-6: #7b818d;
  --text-7: #6b7280;

  --b06: rgba(255, 255, 255, 0.06);
  --b07: rgba(255, 255, 255, 0.07);
  --b08: rgba(255, 255, 255, 0.08);
  --b10: rgba(255, 255, 255, 0.1);
  --b14: rgba(255, 255, 255, 0.14);

  --accent: #f3c24e;
  --accent-strong: #f6c95a;
  --accent-deep: #e3a92c;
  --accent-rgb: 243, 194, 78;
  --on-accent: #1a1407;
  --accent-text: #f3c24e;
  --success: #46c98a;
  --success-rgb: 70, 201, 138;

  --thumb-top: #2b2e36;
  --thumb-bottom: #111318;

  --btn: #15171c;
  --btn-hover: #22252d;

  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);

  --font-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', 'Manrope', system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --app-bg: radial-gradient(120% 90% at 50% -10%, #f8f9fc 0%, #eef0f4 45%, #e7e9ef 100%);
    --bg-deep: #e2e6ec;
    --surface: #ffffff;
    --surface-2: #f4f6f9;
    --surface-hover: #e9edf2;
    --card: #ffffff;
    --card-inset: #f1f3f6;
    --avatar-bg: #e6e9ee;

    --text: #14181f;
    --text-2: #2c333d;
    --text-3: #3d4550;
    --text-4: #55606e;
    --text-5: #667080;
    --text-6: #7a8390;
    --text-7: #8b939f;

    --b06: rgba(17, 24, 36, 0.07);
    --b07: rgba(17, 24, 36, 0.08);
    --b08: rgba(17, 24, 36, 0.1);
    --b10: rgba(17, 24, 36, 0.12);
    --b14: rgba(17, 24, 36, 0.16);

    --accent-text: #8a5d00;
    --success: #1f9d66;
    --success-rgb: 31, 157, 102;

    --btn: #f1f3f6;
    --btn-hover: #e4e8ee;

    --shadow: 0 24px 60px -28px rgba(17, 24, 36, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-deep);
  background-image: var(--app-bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a {
  color: inherit;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The page is the window: the stage takes every pixel - the media grows with
   the window instead of sitting in a fixed column with empty margins either
   side. No top bar: the mark there was dropped (2026-10-11, asked for). */
.page {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 600px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(380px, 27vw, 460px);
  gap: 24px;
}

/* ---------- media ---------- */

.media {
  position: relative;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--thumb-top), var(--thumb-bottom));
  border: 1px solid var(--b08);
  box-shadow: var(--shadow);
}

/* The interactive frame FILLS THE WINDOW when the viewer inside asks for it -
   its fullscreen button, where the device has no real fullscreen (an iPhone,
   an iPad). The viewer posts { simlab: 'viewer-expand' } and this page answers
   (the script below). The notch and the home bar stay outside the frame.
   `body` lifts it over the phone layout's 4:3 aspect-ratio rule. */
body .media.expanded {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  aspect-ratio: auto;
  background: #000;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* In flow inside the padding: insets alone do not stretch an iframe - it
   keeps its 300x150 default size. */
body .media.expanded .media-frame {
  position: static;
  width: 100%;
  height: 100%;
}

html.frame-expanded,
html.frame-expanded body {
  overflow: hidden;
}

.media-cover,
.media-frame,
.media-image,
.media-pano {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* A cover is a thumbnail of whatever shape its author made, shown far larger
   than it was captured: it is drawn WHOLE, over a blurred copy of itself that
   fills the rest of the frame, rather than cropped to the frame's shape. */
.media-cover {
  object-fit: contain;
}

.media-backdrop {
  position: absolute;
  inset: -40px;
  background-position: center;
  background-size: cover;
  filter: blur(40px) brightness(0.7);
}

.media-image {
  object-fit: cover;
}

.type-image .media-image {
  object-fit: contain;
  background: #000;
}

.media-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

.media-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--text-5);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

.media-empty .icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.5;
  color: var(--text-6);
}

/* ---------- details ---------- */

/* The text scrolls in its own body and the buttons are docked under it, so a
   long description never moves Open down the card. */
.details {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--b07);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.details-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 24px 20px;
  display: flex;
  flex-direction: column;
}

.details-dock {
  flex: 0 0 auto;
  padding: 18px 24px 22px;
  border-top: 1px solid var(--b06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.details-dock:empty {
  display: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border-radius: 8px;
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  color: var(--accent-text);
}

.chip .icon {
  width: 14px;
  height: 14px;
}

/* The date sits beside the type as its neutral twin (the portal's meta chip). */
.chip-date {
  background: var(--surface-hover);
  border-color: var(--b07);
  color: var(--text-5);
  font-weight: 600;
  letter-spacing: 0;
}

.chip-date .icon {
  color: var(--text-6);
}

.title {
  margin: 14px 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.publisher {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 12px;
  border-radius: 14px;
  background: var(--card-inset);
  border: 1px solid var(--b06);
}

.publisher img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--avatar-bg);
  flex: 0 0 auto;
}

.publisher-text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.publisher-label {
  font-size: 11.5px;
  color: var(--text-6);
  font-weight: 600;
}

.publisher-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.desc {
  margin: 18px 0 0;
  font-size: 14.5px;
  color: var(--text-4);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.desc.muted {
  color: var(--text-7);
  font-style: italic;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 16px;
  border-radius: 12px;
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid var(--b10);
  background: var(--btn);
  color: var(--text-2);
  transition: background 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--btn-hover);
}

.btn:focus-visible,
.link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  border: none;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent-deep));
  color: var(--on-accent);
  font-weight: 800;
  font-size: 15px;
  padding: 15px 16px;
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent-deep));
  filter: brightness(1.06);
}

.icon.fill {
  fill: currentColor;
  stroke-width: 1.5;
}

.launch-row {
  display: flex;
  gap: 10px;
}

.launch-row .btn-primary {
  flex: 1 1 auto;
  min-width: 0;
}

.btn-icon {
  flex: 0 0 auto;
  width: 52px;
  padding: 0;
}

.btn-icon span {
  display: inline-flex;
}

.btn-icon .when-done,
.btn-icon.done .when-idle {
  display: none;
}

.btn-icon.done .when-done {
  display: inline-flex;
}

.btn.done {
  border-color: rgba(var(--success-rgb), 0.5);
  color: var(--success);
}

.status {
  min-height: 0;
  font-size: 12.5px;
  color: var(--text-5);
  text-align: center;
}

.status:empty {
  display: none;
}

/* ---------- get the viewer ---------- */

.get-viewer {
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed var(--b14);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.get-viewer.nudge {
  border-style: solid;
  border-color: rgba(var(--accent-rgb), 0.55);
  background: rgba(var(--accent-rgb), 0.07);
}

.get-viewer-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

.get-viewer-text {
  font-size: 13px;
  color: var(--text-5);
  min-width: 0;
}

.get-viewer-text strong {
  display: block;
  color: var(--text-2);
  font-size: 13.5px;
  margin-bottom: 2px;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 8px;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  border-radius: 4px;
}

.link:hover {
  text-decoration: underline;
}

.link .icon {
  width: 15px;
  height: 15px;
}

/* ---------- the web viewer, second ---------- */
/* "Play in web viewer" under the get-the-viewer card: an "or" rule and a small outlined
   gold button — the web invite page's "Continue in web browser" (WebVRViewerPortal
   public/invite.html), so the desktop viewer stays the page's one primary action. */

.web-alt {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-7);
  font-size: 11.5px;
}

.rule::before,
.rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--b08);
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  color: var(--accent-text);
}

.btn-ghost:hover {
  background: rgba(var(--accent-rgb), 0.12);
}

.btn-sm {
  padding: 10px 18px;
  font-size: 13.5px;
}

/* small, not a second full-width call to action */
.web-alt .btn {
  align-self: center;
}

@media (prefers-color-scheme: light) {
  .btn-ghost {
    border-color: rgba(var(--accent-rgb), 0.7);
  }
}

.btn-sm .icon {
  width: 16px;
  height: 16px;
}

.shared-with {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-5);
}

.shared-with h2 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-6);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- not found ---------- */

.missing {
  flex: 1 0 auto;
  display: grid;
  place-items: center;
}

.missing-card {
  width: min(460px, 100%);
  text-align: center;
  background: var(--card);
  border: 1px solid var(--b07);
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
}

.missing-card .icon {
  width: 44px;
  height: 44px;
  stroke-width: 1.5;
  color: var(--text-6);
}

.missing-card h1 {
  margin: 14px 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
}

.missing-card p {
  margin: 0 0 22px;
  color: var(--text-5);
  font-size: 14px;
}

/* ---------- smaller screens ---------- */

@media (max-width: 980px) {
  .page {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 16px 16px 22px;
    gap: 14px;
  }

  .stage {
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 16px;
  }

  .media {
    aspect-ratio: 16 / 9;
    border-radius: 16px;
  }

  .details,
  .details-body {
    overflow: visible;
  }

  .details {
    border-radius: 16px;
  }

  .details-body {
    padding: 20px 18px 16px;
  }

  .details-dock {
    padding: 16px 18px 18px;
  }

  .title {
    font-size: 25px;
  }

  .type-360image .media,
  .type-webgl .media,
  .type-360grid .media {
    aspect-ratio: 4 / 3;
  }
}

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