:root {
  --bg-color: #dddddd;
  --text-color: 51, 51, 51;
  --link-color: #1a0dab;
  --container-bg: #ffffff;
  --inactive-container-bg: 230, 230, 230;
  --dim-container-bg: #eeeeee;
  --border-color: #ddd;
  --shadow: 0 2px 5px rgba(0,0,0,0.1);
}
[data-theme="dark"] {
  --bg-color: #111111;
  --text-color: 221, 221, 221;
  --link-color: #8ab4f8;
  --container-bg: #333333;
  --inactive-container-bg: 26, 26, 26;
  --dim-container-bg: #222222;
  --border-color: #444;
  --shadow: 0 2px 5px rgba(0,0,0,0.5);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg-color);
  color: rgba(var(--text-color), 1.0);
}
body {
  font-family: 'Poppins', sans-serif;
  font-size: 1.1rem;
  padding: 1em;
  transition: background-color 0.3s, color 0.3s, font-size 0.5s;
}

#content {
  padding-top: 2.5rem;
}

p {
  line-height: inherit;
}

p:first-of-type {
  margin-top: 0;
}

p:last-of-type {
  margin-bottom: 0.4rem;
}

#topmenu {
  position: fixed;
  top: 0;
  right: 0;
  display: flex;
  font-size: 1em;
}

.topmenuitem {
  color: rgba(var(--text-color), 0.8);
}

.topmenuitem::before {
  content: "|";
  padding-left: 0.6em;
  padding-right: 0.6em;
  display: inline-block;
  width: 0px;
  color: rgba(var(--text-color), 0.5);
}

.topmenuitem:first-child::before {
  content: "";
}

.topmenuitem:last-child::after {
  content: "";
  padding-left: 0.6em;
  padding-right: 0.6em;
}

.object-title, .breadcrumb-title, .attribute-name {
  font-weight: 600;
}

.breadcrumb {
  max-width: 67%;
  margin: 0 auto 1em;
  padding: 0.3em 0;
  text-align: center;
  font-size: 0.9em;
}
.breadcrumb a {
  text-decoration: none;
  color: var(--link-color);
  margin-right: 0.5em;
}
.breadcrumb a:hover {
  text-decoration: underline;
}
.breadcrumb span {
  margin-right: 0.5em;
  color: #666;
  font-size: 0.9em;
}

.object-container, .inactive-container {
  padding: 1em 1.5em;
  padding-left: 1.5em;
  padding-right: 1.5em;
  margin-left: auto;
  margin-right: auto;
  border-radius: 5px;
  max-width: 67dvw;
  transition: background-color 0.3s, box-shadow 0.3s;
}
.object-container {
  background-color: var(--container-bg);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}
.inactive-container {
  background: linear-gradient(180deg, rgba(var(--inactive-container-bg), 1) 0%, rgba(var(--inactive-container-bg), 0) 100%);
}

/* Use Flexbox for attributes with keys and values side-by-side */
.attribute {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start; /* keys align to top */
  margin: 0.2em 0;
  background-color: rgba(128, 128, 192, 0.0);
  border: 2px solid rgba(128, 128, 192, 0.0);
  border-radius: 0.5rem;
}
.attribute:hover {
  background-color: rgba(128, 128, 192, 0.1);
  border: 2px solid rgba(128, 128, 192, 0.2);
}
.attribute-name {
  font-weight: bold;
  margin-bottom: 0;
  flex: 1.3 0.8 10%;
  max-width: 42%;
  box-sizing: border-box;
  padding-right: 2rem;
  text-align: right;
  line-height: 1.5;
  cursor: default;
}
.attribute-value {
  flex: 0.2 3 70%;
  box-sizing: border-box;
  line-height: 1.5;
  min-width: 50%;
}

.object-meta, .inactive-meta {
  font-size: 0.8em;
  border: 2px solid rgba(var(--text-color), 0.05);
  border-radius: 0.5rem;
  background-color: rgba(var(--text-color), 0.05);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  width: fit-content;
  float: right;
  margin-left: 0.5rem;
}
.object-meta {
  margin-top: 0.2em;
  color: rgba(var(--text-color), 1);
}
.inactive-meta {
  margin-top: 0.0em;
  color: rgba(var(--text-color), 0.2);
}
.object-title, .inactive-title {
  margin-top: 0;
  margin-bottom: 0;
  font-size: 1.3em;
}
.object-title {
  color: rgba(var(--text-color), 1);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.1em;
  cursor: default;
}
.inactive-title {
  color: rgba(var(--text-color), 0.2);
  padding-bottom: 0;
  line-height: 0.3em;
  padding-top: 0.5em;
}

.title-link {
  color: rgba(var(--text-color), 1);
}

.title-link:hover {
  text-decoration: none;
}

.inactive-title-link {
  color: rgba(var(--text-color), 0.2);
}
.attribute-count {
  color: #999;
}

.value-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2rem;
  list-style-type: none;
  margin: 0;
  line-height: 1;
  padding: 0;
}

li.native {
  list-style-type: none;
  padding: 0.2rem 0.4rem;
  margin: 0;
  border: 2px solid rgba(0, 128, 128, 0);
  border-radius: 0.5rem;
  cursor: default;
}

li.native:hover {
  background: rgba(0, 128, 128, 0.3);
  border: 2px solid rgba(0, 128, 128, 0.4);
}

.thumbnail {
  max-width: 20dvw;
  max-height: 15dvh;
  border: none;
}
.reference {
  position: relative; /* establish positioning context for nested content */
}
.reference a {
  display: inline;
  margin: 0;
  padding: 0;
  vertical-align: middle;
  line-height: 1.5;
}
.toggle {
  cursor: pointer;
  color: var(--link-color);
  font-weight: bold;
  vertical-align: middle;
  line-height: 1.5;
}
.code {
  font-family: monospace;
}
.code-value {
  font-family: monospace;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin: 0;
  line-height: 1.9rem;
  padding: 0.2rem 0.4rem;
  background: rgba(128, 128, 128, 0.1);
  border: 2px solid rgba(0, 128, 128, 0);
  border-radius: 0.5rem;
}
.code-value:hover {
  background: rgba(0, 128, 128, 0.3);
  border: 2px solid rgba(0, 128, 128, 0.4);
}
.array-count {
  border-radius: 50%;
  width: 0.9em;
  height: 0.9em;
  padding: 0.2em;
  background: rgba(var(--text-color), 0.5);
  color: var(--container-bg);
  border: 0;
  text-align: center;
  font-family: monospace;
  font-size: 0.8em;
  display: inline-block;
  line-height: 0.9em;
  font-weight: bold;
  margin-left: 0.2em;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.array-count-hovered {
  opacity: 1;
}

/* Floating nested content as an overlay */
.nested-content {
  position: absolute;
  top: 0; /* align to top of parent reference */
  left: 100%; /* default: to the right */
  margin-left: 0.5em;
  background-color: var(--container-bg);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  padding: 0.5em;
  z-index: 10;
  max-width: 90dvw;
  width: 50dvw;
  overflow: auto;
}

/* Optional: If the nested content would extend off-screen,
   your JavaScript can add a class (for example, .flip) to reposition it.
   For instance, when .flip is present, display it to the left: */
.nested-content.flip {
  left: auto;
  right: 100%;
  margin-left: 0;
  margin-right: 0.5em;
}

/* Dim overlay for page when nested content is open.
(Your JavaScript should toggle the class "dim" on #page-container) */
#page-container.dim::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 5;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease 0.2s;
}

/* Backlinks container as its own white box */
.backlinks-container {
  background-color: var(--dim-container-bg);
  padding: 1em 1.5em;
  margin: 1em auto;
  border-radius: 5px;
  box-shadow: var(--shadow);
  max-width: 67dvw;
  transition: background-color 0.3s, box-shadow 0.3s;
  color: rgba(var(--text-color), 0.5);
}
.backlinks-container h3 {
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5em;
  margin-top: 0;
  margin-bottom: 1.1em;
}
.backlink-group {
  margin-bottom: 0.5em;
}
.top-link {
  margin: 1em auto;
  max-width: 67%;
  text-align: right;
}
a {
  color: var(--link-color);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.newline-arrow {
  color: rgba(var(--text-color), 0.3);
  user-select: none;
}

@media (max-width: 600px) {
  .object-container, .breadcrumb-container, .breadcrumb, .top-link, .backlinks-container {
    max-width: 95%;
  }
  .thumbnail {
    max-width: 100px;
    max-height: 100px;
  }
}

.object-link {
  padding-right: 0.8rem;
}

.object-link-disabled, .object-link-notfound {
  pointer-events: none;
  cursor: default;
  text-decoration: none;
  color: rgba(var(--text-color), 0.5);
  padding-right: 0.8rem;
}

.json-slash {
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  margin-left: 0.2rem;
  margin-right: 0.2rem;
}

/* Page transition animations */
#page-container {
  transform: translateX(0);
  transition: transform 0.3s ease;
}
.slide-out-left {
  transform: translateX(-100%);
}
.slide-out-right {
  transform: translateX(100%);
}
.slide-in-from-right {
  animation: slideInFromRight 0.3s ease forwards;
}
.slide-in-from-left {
  animation: slideInFromLeft 0.3s ease forwards;
}
@keyframes slideInFromRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@keyframes slideInFromLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
