* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: #080808; color: #fff; font-family: Arial, sans-serif; }
body { height: 100svh; display: flex; flex-direction: column; }
a { color: #fff; text-decoration: none; font-size: 13px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: wait; }
a:focus-visible, button:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.viewer-header {
  height: 76px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid #2c2c2c;
}
body:has(#welcome:not([hidden])) .viewer-header {
  position: absolute;
  z-index: 1;
  inset: 0 0 auto;
  background: #080808b3;
  border-color: #ffffff35;
}
.viewer-header img { display: block; width: 54px; height: 48px; object-fit: contain; }
.viewer-header > span { font-size: 10px; letter-spacing: .24em; color: #ddd; }
.back-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #aaa;
  background: #151515;
}
.back-button:hover { color: #080808; background: #fff; border-color: #fff; }

#viewer { position: relative; flex: 1; min-height: 0; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
canvas:active { cursor: grabbing; }
canvas:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
#viewer > video { position: absolute; width: 1px; height: 1px; opacity: .001; pointer-events: none; bottom: 0; left: 0; }

.cabin-transition {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #050505;
  animation: curtain-out .65s ease 2.3s both;
}
.reveal-mark { width: clamp(230px, 32vw, 390px); aspect-ratio: 1; position: relative; }
.reveal-mark img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
.layer-frame { animation: mark-reveal 1.1s ease .1s forwards; }
.layer-ribbon { animation: mark-reveal 1.1s ease .8s forwards; }
@keyframes mark-reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes curtain-out {
  from { opacity: 1; visibility: visible; }
  to { opacity: 0; visibility: hidden; }
}

#welcome {
  position: absolute;
  inset: 0;
  isolation: isolate;
  display: grid;
  align-items: end;
  overflow: auto;
  padding: 106px clamp(22px, 6vw, 110px) clamp(36px, 10vh, 120px);
  background: #171717 url("cabin-arrival.webp") center 51% / cover no-repeat;
}
#arrival-film {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 51%;
  pointer-events: none;
}
#welcome::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(90deg, #000d 0%, #000a 40%, #0003 100%),
    linear-gradient(0deg, #000b 0%, transparent 72%);
  pointer-events: none;
}
.intro { max-width: 660px; }
.intro > :is(.eyebrow, h1, .intro-text, #start) { animation: cabin-arrive .65s ease both; }
.intro .eyebrow { animation-delay: 2.46s; }
.intro h1 { animation-delay: 2.54s; }
.intro .intro-text { animation-delay: 2.64s; }
.intro #start { animation-delay: 2.76s; }
@keyframes cabin-arrive {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f1f1f1;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .2em;
  text-transform: uppercase;
  margin: 0 0 20px;
}
.eyebrow span { width: 28px; height: 1px; background: #bfbfbf; }
h1 { margin: 0; font-size: clamp(46px, 7.2vw, 108px); line-height: .96; letter-spacing: -.065em; text-wrap: balance; }
.intro-text { color: #f0f0f0; max-width: 40ch; margin: 24px 0 28px; line-height: 1.6; }
#start {
  min-height: 54px;
  padding: 12px 20px;
  border: 1px solid #fff;
  color: #080808;
  background: #fff;
  font-weight: bold;
}
#start:hover:not(:disabled) { background: #dcdcdc; }
#status { color: #f0f0f0; font-size: 13px; line-height: 1.5; margin: 14px 0 0; }
#status:empty { display: none; }
#fallback { display: inline-block; text-decoration: underline; text-underline-offset: 4px; margin-top: 12px; }

.controls {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}
.controls button, .hint { padding: 12px 14px; font-size: 13px; background: #080808; }
.controls button { border: 1px solid #8f8f8f; pointer-events: auto; }
.controls button:hover { background: #fff; color: #080808; }
.hint { line-height: 1.4; }
.expanded { position: fixed !important; inset: 0 !important; z-index: 1000; height: 100svh !important; }

@media (max-width: 520px) {
  .viewer-header { height: 62px; }
  .viewer-header > span { display: none; }
  #welcome { padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 24px)); }
  #welcome::before { background: linear-gradient(0deg, #000e 0%, #000a 55%, #0002 85%); }
  .eyebrow { margin-bottom: 14px; }
  .intro-text { margin: 16px 0 20px; }
  .hint { width: 100%; text-align: center; }
  .controls { left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .cabin-transition { display: none; }
  .intro > :is(.eyebrow, h1, .intro-text, #start) { animation: none; }
}
