/* ===================================================================
   INSTANCE MODAL — For my old pc style pop-ups!
   =================================================================== */

/* ----------------------------------------------------------------
   Backdrop (dimmed overlay behind modal)
   ---------------------------------------------------------------- */

.instance-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  animation: instance-modal-fade-in 0.15s ease-out;
}

@keyframes instance-modal-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ----------------------------------------------------------------
   Modal Window (Win95/98 style dialog box)
   ---------------------------------------------------------------- */

.instance-modal-window {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  box-shadow:
    1px 1px 0 #000,
    2px 2px 8px rgba(0, 0, 0, 0.4);
  font-family: "Trebuchet MS", "Lucida Grande", Arial, sans-serif;
  font-size: 14px;
  color: #000;
  animation: instance-modal-slide-in 0.2s ease-out;
  margin: auto;
}

@keyframes instance-modal-slide-in {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------------------------------------------------------
   Title Bar (Win95 blue gradient bar)
   ---------------------------------------------------------------- */

.instance-modal-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 2px 2px;
  background: linear-gradient(to right, #000080, #1084d0);
  border-bottom: 1px solid #000;
  user-select: none;
}

.instance-modal-title-content {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.instance-modal-title-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.instance-modal-title-text {
  font-family: "Trebuchet MS", "Lucida Grande", Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------------------------------
   Theme Overrides (Title Bar Themes)
   ---------------------------------------------------------------- */

/* Backrooms Theme - Warm yellow gradient */
.instance-modal-title-bar.theme-backrooms {
  background: linear-gradient(to right, #8b7d6b, #bfb084, #e6d7a3);
  border-bottom: 1px solid #6b5f52;
}

.instance-modal-title-bar.theme-backrooms .instance-modal-title-text {
  color: #2a2419;
  text-shadow: 1px 1px 0 rgba(244, 234, 213, 0.6);
}

/* Add more theme overrides for future pages here
   .instance-modal-title-bar.theme-yourtheme { ... }
*/

/* ----------------------------------------------------------------
   Close Button (Win95 X button)
   ---------------------------------------------------------------- */

.instance-modal-close {
  width: 16px;
  height: 14px;
  padding: 0;
  margin: 0;
  background: #c0c0c0;
  border: 1px solid;
  border-color: #fff #000 #000 #fff;
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: #000;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.instance-modal-close:hover {
  background: #c8c8c8;
}

.instance-modal-close:active {
  border-color: #000 #fff #fff #000;
  padding-top: 1px;
  padding-left: 1px;
}

/* ----------------------------------------------------------------
   Modal Body (content area)
   ---------------------------------------------------------------- */

.instance-modal-body {
  padding: 12px;
  background: #c0c0c0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* ---------------------------------------------------------------
   Content Layout (image + fields side-by-side)
   --------------------------------------------------------------- */

.instance-modal-image-container {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  border: 1px solid;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.instance-modal-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.instance-modal-fields {
  flex: 1;
  min-width: 0;
}

.instance-modal-field {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}

.instance-modal-field:last-child {
  margin-bottom: 0;
}

.instance-modal-field-label {
  font-weight: 700;
  color: #000;
}

.instance-modal-field-value {
  color: #000;
}

/* -------------------------------------------------------------
   Trigger Button (styled as inline link)
   ---------------------------------------------------------------- */

button.instance-trigger {
  display: inline;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  line-height: inherit;
  transition: background-color 120ms ease, color 120ms ease;
}

button.instance-trigger:hover,
button.instance-trigger:focus {
  background-color: var(--link-hover-bg, rgba(204, 233, 186, 1));
  color: var(--link-color-hover, #31372e);
  text-decoration: none;
  border-radius: 2px;
  outline: none;
}

button.instance-trigger:focus-visible {
  outline: 2px solid var(--link-color, #cce9ba);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------
   AUDIO MODAL LAYOUT (Windows file viewer style)
   --------------------------------------------------------------- */

.instance-modal-body-audio {
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

/* Audio File Header (icon + file info) */
.audio-file-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #808080;
}

.audio-file-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.audio-file-info {
  flex: 1;
  min-width: 0;
}

.audio-file-name {
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #000;
  margin-bottom: 3px;
  word-wrap: break-word;
}

.audio-file-description {
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 11px;
  color: #505050;
  line-height: 1.3;
}

/* Audio Player Container */
.audio-player-container {
  width: 100%;
  padding: 8px;
  background: #fff;
  border: 1px solid;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
}

.audio-player {
  width: 100%;
  height: 32px;
  outline: none;
}

.audio-player:focus {
  outline: 2px solid #000080;
  outline-offset: 2px;
}

/* ----------------------------------------------------------------
   Album Art (optional; only renders on entries that declare albumArt)
   The player stays full width and replaces the audio gif for album art instead.
   ---------------------------------------------------------------- */

/* Square art box — Win95 inset border */
.audio-art-box {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border: 1px solid;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Placeholder shown until album art is added */
.audio-art-placeholder {
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 28px;
  color: #808080;
  user-select: none;
}

/* Actual album art image */
.audio-art-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

/* ------------------------------------------------------------
   Body Lock (prevent scrolling when modal is open)
   ---------------------------------------------------------------- */

body.instance-modal-open {
  overflow: hidden;
}

/* ----------------------------------------------------------------
   Mobile Responsive Adjustments
   ---------------------------------------------------------------- */

@media (max-width: 600px) {
  .instance-modal-window {
    max-width: 100%;
    margin: 0;
  }

  .instance-modal-body {
    flex-direction: column;
    padding: 10px;
  }

  .instance-modal-image-container {
    width: 100%;
    max-width: 200px;
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
  }

  .instance-modal-fields {
    width: 100%;
  }

  .instance-modal-field {
    font-size: 12px;
  }

  .instance-modal-backdrop {
    padding: 10px;
    align-items: flex-start;
  }

  /* Audio modal mobile adjustments */
  .audio-file-icon {
    width: 28px;
    height: 28px;
  }

  .audio-file-name {
    font-size: 12px;
  }

  .audio-file-description {
    font-size: 10px;
  }
}

/* Small screen height adjustments */
@media (max-height: 500px) {
  .instance-modal-backdrop {
    align-items: flex-start;
    padding-top: 10px;
  }

  .instance-modal-image-container {
    width: 80px;
    height: 80px;
  }
}
