@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  color-scheme: dark;
  --void: #080607;
  --ink: #eee8e5;
  --muted: #8b7d7e;
  --blood: #bd1c2c;
  --blood-bright: #f13a47;
  --line: rgba(203, 177, 174, .17);
  --mono: "DM Mono", "Courier New", monospace;
  --serif: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--void);
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  width: 100%;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 36%, rgba(69, 10, 17, .24), transparent 48%),
    var(--void);
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

body::after {
  position: fixed;
  z-index: 10;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: .12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
}

button, textarea { font: inherit; }
button { color: inherit; }

.realm {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.masthead {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 6vw;
  border-bottom: 1px solid rgba(255,255,255,.055);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #e7dedd;
  font-size: 10px;
  letter-spacing: .19em;
  text-decoration: none;
}

.wordmark-mark {
  width: 7px;
  height: 7px;
  border: 1px solid var(--blood-bright);
  transform: rotate(45deg);
  box-shadow: 0 0 9px rgba(241,58,71,.38);
}

.fiction-note, .site-footer, .eyebrow, .summons, .reset-button, .message-speaker, .send-button, .conversation-footnote {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .14em;
}

.fiction-note { color: #796c6e; }

.encounter {
  position: relative;
  display: flex;
  min-height: min(820px, calc(100svh - 64px));
  flex-direction: column;
  align-items: center;
  isolation: isolate;
  padding: 35px 20px 15px;
}

.encounter::before,
.encounter::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
}

.encounter::before {
  z-index: 0;
  background-image: var(--hero-image);
  background-position: center 46%;
  background-repeat: no-repeat;
  background-size: cover;
  filter: blur(8px) brightness(.62) saturate(.9);
  transform: scale(1.035);
}

.encounter::after {
  z-index: 0;
  background: linear-gradient(
    180deg,
    rgba(8, 6, 7, .68) 0%,
    rgba(8, 6, 7, .1) 36%,
    rgba(8, 6, 7, .16) 66%,
    #080607 100%
  );
}

.intro {
  position: relative;
  z-index: 2;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: #bd999b;
  font-size: 9px;
  letter-spacing: .2em;
}

.eyebrow-rule {
  display: inline-block;
  width: 19px;
  height: 1px;
  margin: 0 8px 3px 0;
  background: var(--blood);
}

h1 {
  margin: 8px 0 0;
  color: #f1e9e7;
  font-family: var(--serif);
  font-size: clamp(39px, 6vw, 68px);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: .97;
}

.title-period { color: var(--blood-bright); }

.intro-line {
  margin: 9px 0 0;
  color: #97898a;
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  letter-spacing: .025em;
}

.entity-stage {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(72vw, 620px);
  aspect-ratio: 1;
  place-items: center;
  margin: -4px 0 -37px;
}

.entity-image {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(.83) contrast(1.08);
  -webkit-mask-image: radial-gradient(ellipse 69% 68% at 50% 49%, #000 64%, transparent 100%);
  mask-image: radial-gradient(ellipse 69% 68% at 50% 49%, #000 64%, transparent 100%);
}

.entity-halo {
  position: absolute;
  inset: 10% 5%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(151, 11, 24, .25), rgba(84, 8, 14, .1) 42%, transparent 70%);
  filter: blur(23px);
}

.eye-glow {
  position: absolute;
  z-index: 2;
  top: 41.9%;
  width: 3.1%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 16, 34, .84);
  box-shadow: 0 0 7px 2px rgba(255, 12, 31, .72), 0 0 19px 7px rgba(215, 4, 23, .42), 0 0 37px 12px rgba(160, 0, 16, .2);
  animation: gaze 4.8s ease-in-out infinite;
}

.eye-left { left: 42.9%; }
.eye-right { left: 55.2%; animation-delay: .24s; }

.realm.is-responding .eye-glow {
  animation: gaze-response .48s ease-in-out infinite alternate;
  box-shadow: 0 0 9px 3px rgba(255, 16, 34, .88), 0 0 24px 9px rgba(215, 4, 23, .58), 0 0 43px 15px rgba(160, 0, 16, .32);
}

.stage-vignette {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 53%, rgba(8,6,7,.55) 100%);
}

.summons {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #aa8e90;
  font-size: 8px;
  letter-spacing: .22em;
}

.summons-line {
  width: clamp(22px, 5vw, 52px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(189,28,44,.65));
}

.summons-line:last-child { transform: rotate(180deg); }

.atmosphere { position: absolute; z-index: 0; inset: 0; overflow: hidden; pointer-events: none; }

.mist {
  position: absolute;
  left: -15%;
  width: 130%;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(123, 57, 62, .08), rgba(106, 36, 43, .025) 45%, transparent 72%);
  filter: blur(26px);
  animation: drift 19s ease-in-out infinite alternate;
}
.mist-one { top: 52%; }
.mist-two { top: 65%; animation-duration: 26s; animation-direction: alternate-reverse; opacity: .65; }

.ember {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #e15055;
  box-shadow: 0 0 8px 2px rgba(204,30,42,.38);
  opacity: .48;
  animation: ash 8s ease-in-out infinite;
}
.ember-one { left: 17%; top: 59%; animation-delay: -2s; }
.ember-two { left: 81%; top: 48%; animation-delay: -5s; }
.ember-three { left: 26%; top: 34%; animation-delay: -1s; }
.ember-four { left: 72%; top: 69%; animation-delay: -6s; }
.ember-five { left: 12%; top: 75%; animation-delay: -4s; }
.ember-six { left: 89%; top: 29%; animation-delay: -3s; }
.ember-seven { left: 64%; top: 27%; animation-delay: -7s; }

.conversation {
  position: relative;
  z-index: 2;
  width: min(100% - 40px, 620px);
  margin: 0 auto;
  padding: 49px 0 47px;
  border-top: 1px solid var(--line);
}

.conversation-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.conversation-heading .eyebrow { color: #a54b53; font-size: 8px; }
.conversation h2 {
  margin: 7px 0 0;
  color: #e9dedd;
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 39px);
  font-weight: 400;
  letter-spacing: -.02em;
}

.reset-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: #9a898a;
  cursor: pointer;
  transition: color .2s ease;
}
.reset-button:hover { color: #f0c5c6; }
.reset-button:focus-visible, .send-button:focus-visible, .composer textarea:focus-visible {
  outline: 1px solid #c44851;
  outline-offset: 4px;
}
.reset-icon { font-family: sans-serif; font-size: 14px; line-height: 1; }

.message-window {
  max-height: 310px;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 20px 0 16px;
  scroll-padding-block: 14px;
  scrollbar-color: rgba(160, 38, 48, .5) transparent;
  scrollbar-width: thin;
}
.message-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.message {
  position: relative;
  min-width: 0;
  max-width: 88%;
  padding: 2px 0 3px 11px;
  border-left: 1px solid rgba(166, 53, 62, .36);
  animation: arrive .35s ease both;
}
.message-entity { align-self: flex-start; }
.message-user {
  align-self: flex-end;
  padding: 2px 11px 3px 0;
  border-right: 1px solid rgba(214, 193, 191, .2);
  border-left: 0;
  text-align: right;
}
.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.message-speaker { color: #a64c54; font-size: 8px; letter-spacing: .2em; }
.message-user .message-speaker { color: #8f8584; }
.message p {
  max-width: 100%;
  margin: 3px 0 0;
  color: #c7bcbc;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message-user p { color: #dfd6d4; }
.message-actions { position: relative; flex: 0 0 auto; }
.message-menu-trigger {
  display: inline-grid;
  width: 30px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #a39495;
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: .62;
}
.message-menu-trigger:hover,
.message-menu-trigger:focus-visible,
.message-actions.is-open .message-menu-trigger {
  color: #e2c5c6;
  opacity: 1;
}
.message-menu-trigger:focus-visible,
.message-menu-item:focus-visible {
  outline: 1px solid rgba(206, 63, 73, .8);
  outline-offset: 2px;
}
.message-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% - 1px);
  right: 0;
  min-width: 104px;
  padding: 4px;
  border: 1px solid rgba(189, 131, 134, .28);
  background: #120d0e;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .45);
  text-align: left;
}
.message-menu[hidden] { display: none; }
.message:last-child .message-menu { top: auto; bottom: calc(100% - 1px); }
.message-menu-item {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: #c9babb;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-align: left;
  cursor: pointer;
}
.message-menu-item:hover { background: rgba(189, 28, 44, .18); color: #f0d7d8; }
.message-menu-item:disabled { cursor: wait; opacity: .5; }

.chat-status {
  min-height: 15px;
  margin: 10px 0 0;
  color: #c87077;
  font-size: 10px;
  line-height: 1.6;
}
.chat-status:empty { display: none; }
.chat-status.is-loading { color: #a68d8f; }
.chat-status.is-loading::after {
  display: inline-block;
  width: 17px;
  overflow: hidden;
  vertical-align: bottom;
  content: "...";
  animation: ellipsis 1.2s steps(4, end) infinite;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 60px;
  scroll-margin-bottom: max(20px, env(safe-area-inset-bottom));
  padding: 14px 2px 11px 17px;
  border: 1px solid rgba(189, 131, 134, .28);
  background: rgba(20, 13, 15, .76);
  transition: border-color .2s ease, background .2s ease;
}
.composer:focus-within { border-color: rgba(206, 63, 73, .74); background: rgba(27, 14, 17, .88); }
.composer textarea {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  min-height: 22px;
  max-height: 130px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #e6dcda;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.4;
}
.composer textarea::placeholder { color: #a39495; opacity: 1; }
.send-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: #c64b54;
  cursor: pointer;
  letter-spacing: .17em;
  transition: color .2s ease, transform .2s ease;
}
.send-button:hover { color: #f17a80; transform: translateX(2px); }
.send-button:disabled { cursor: wait; opacity: .55; }
.send-button svg { width: 17px; height: 17px; }
.conversation-footnote { margin: 11px 1px 0; color: #716466; font-size: 8px; letter-spacing: .055em; }

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 17px 6vw 22px;
  border-top: 1px solid rgba(255,255,255,.055);
  color: #63595a;
  font-size: 8px;
  letter-spacing: .13em;
}
.site-footer-heading {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}
.site-footer-credit {
  display: grid;
  gap: 5px;
  width: 100%;
  color: #8b7d7e;
  font-size: 9px;
  letter-spacing: .07em;
  line-height: 1.65;
  text-align: center;
  overflow-wrap: anywhere;
}
.site-footer-credit p { margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes gaze {
  0%, 100% { opacity: .68; transform: scale(.92); }
  48% { opacity: 1; transform: scale(1.12); }
  53% { opacity: .58; transform: scale(.87); }
  57% { opacity: .96; transform: scale(1.05); }
}
@keyframes gaze-response {
  from { opacity: .62; transform: scale(.85); filter: brightness(.9); }
  to { opacity: 1; transform: scale(1.34); filter: brightness(1.5); }
}
@keyframes drift {
  from { transform: translate3d(-3%, 0, 0); }
  to { transform: translate3d(3%, -10px, 0); }
}
@keyframes ash {
  0%, 100% { opacity: .2; transform: translateY(9px); }
  50% { opacity: .58; transform: translateY(-13px); }
}
@keyframes arrive {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ellipsis {
  0% { width: 0; }
  100% { width: 17px; }
}

@media (min-width: 900px) {
  .masthead { min-height: 72px; }
  .encounter {
    min-height: min(900px, calc(100svh - 72px));
    padding-top: 34px;
  }
  .entity-stage {
    width: min(63vw, 690px);
    margin-top: -9px;
    margin-bottom: -46px;
  }
  .conversation { padding-top: 57px; }
}

@media (max-width: 520px) {
  .masthead { min-height: 55px; padding-inline: 20px; }
  .wordmark { font-size: 8px; letter-spacing: .15em; }
  .fiction-note { max-width: 105px; font-size: 7px; text-align: right; line-height: 1.5; }
  .encounter { min-height: min(730px, calc(100svh - 55px)); padding: 39px 13px 18px; }
  h1 { margin-top: 11px; font-size: clamp(39px, 12vw, 55px); }
  .intro-line { font-size: 16px; }
  .entity-stage { width: min(105vw, 520px); margin-top: 12px; margin-bottom: -27px; }
  .summons { gap: 8px; font-size: 7px; letter-spacing: .15em; }
  .conversation { width: calc(100% - 40px); padding: 39px 0 36px; }
  .conversation-heading { align-items: center; }
  .reset-button { gap: 5px; font-size: 8px; }
  .message-window { max-height: min(42dvh, 360px); }
  .message-list { gap: 14px; }
  .message { max-width: 100%; }
  .message p { font-size: 16px; line-height: 1.62; }
  .message-menu-trigger { width: 34px; height: 34px; opacity: 1; }
  .site-footer { padding-inline: 20px; font-size: 7px; }
  .site-footer-credit { font-size: 8px; line-height: 1.75; }
  .composer { padding-bottom: max(11px, env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
