/**
 * modal_logs.css - Battle Database Logs Modal Stylesheet
 * 
 * Scaled dynamically using container query units (cqw, cqh) relative to the #game-wrapper
 * container query root instead of browser viewport units to maintain constant
 * proportional scaling and prevent layout overflow across variable screen aspect ratios.
 */

/* ==========================================================================
   SECTION 1: OVERLAY & CONTAINER STATE
   ========================================================================== */

/* Outer modal overlay positioning and initial transparent state */
.log-modal-overlay {
  /* Positioning & Layout */
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Box Model & Sizing */
  padding: 3cqw;
  box-sizing: border-box;

  /* Visual Styles & Borders */
  opacity: 1;

  /* Interactivity & Transitions */
  transition: opacity 0.2s ease-in-out;
}

/* Hidden overlay state */
.log-modal-overlay.hidden,
.log-modal-overlay[hidden] {
  /* Positioning & Layout */
  display: none !important;

  /* Visual Styles & Borders */
  opacity: 0;

  /* Interactivity & Transitions */
  pointer-events: none;
}

/* Active overlay state override: `pointer-events: auto !important` explicitly restores user interactions 
   (clicks/taps) within the active modal hierarchy, overriding any pointer-disabled state on parent wrappers */
.log-modal-overlay:not(.hidden):not([hidden]) {
  /* Positioning & Layout */
  z-index: 1000;
  display: flex !important;

  /* Visual Styles & Borders */
  opacity: 1 !important;

  /* Interactivity & Transitions */
  pointer-events: auto !important;
}

/* Background visual feedback: The `[inert]` attribute selector marks background stages as inactive,
   applying a visual blur (filter: blur) while disabling pointer events and text selection to block interaction */
.battle-stage1-container[inert],
.battle-stage2-container[inert] {
  /* Visual Styles & Borders */
  filter: blur(1.5px);

  /* Interactivity & Transitions */
  pointer-events: none !important;
  user-select: none !important;
  transition: filter 0.2s ease-in-out;
}

/* ==========================================================================
   SECTION 2: BACKDROP & MODAL FRAME
   ========================================================================== */

/* Darkened background backdrop element */
.log-modal-backdrop {
  /* Positioning & Layout */
  position: absolute;
  inset: 0;
  z-index: 0;

  /* Visual Styles & Borders */
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

/* Main outer card container with container query relative sizing (cqw, cqh) */
.log-modal-card {
  /* Positioning & Layout */
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5cqh;

  /* Box Model & Sizing */
  width: 90cqw;
  max-width: 92%;
  max-height: 82cqh;
  padding: 3cqh 3cqw 2.5cqh;
  box-sizing: border-box;

  /* Visual Styles & Borders */
  background: linear-gradient(180deg, #140e0a 0%, #0e0a07 100%);
  border: 2px solid #c89d38;
  outline: 1px solid #4a3818;
  outline-offset: -0.8cqw;
  border-radius: 2cqw;
  box-shadow: 0 1.5cqh 4cqw rgba(0, 0, 0, 0.9), 0 0 2cqw rgba(200, 157, 56, 0.15);
}

/* ==========================================================================
   SECTION 3: HEADER & CONTROLS
   ========================================================================== */

/* Modal header flex layout */
.log-modal-header {
  /* Positioning & Layout */
  position: relative;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
}

/* Header title with clamp() boundaries: clamp() sets minimum (0.95rem), fluid container-relative (4.2cqw), 
   and maximum (1.3rem) bounds to maintain consistent typography readability across all display resolutions */
.log-modal-title {
  /* Box Model & Sizing */
  margin: 0;

  /* Typography & Color */
  font-family: 'Cinzel', 'MedievalSharp', serif;
  font-size: clamp(0.95rem, 4.2cqw, 1.3rem);
  font-weight: 700;
  color: #f3d078;
  letter-spacing: 0.05em;
  text-shadow: 0 0.25cqh 0.5cqh rgba(0, 0, 0, 0.8), 0 0 1cqw rgba(243, 208, 120, 0.25);
  text-transform: uppercase;
}

/* Top-right circular close action button using clamp() for responsive physical touch target bounds */
.log-modal-close-btn {
  /* Positioning & Layout */
  position: absolute;
  top: -1.2cqh;
  right: -0.8cqw;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Box Model & Sizing */
  width: clamp(28px, 7.5cqw, 38px);
  height: clamp(28px, 7.5cqw, 38px);

  /* Visual Styles & Borders */
  background-color: #dc2626;
  border: 1.5px solid #c89d38;
  border-radius: 50%;
  box-shadow: 0 0.5cqh 1cqh rgba(0, 0, 0, 0.6);

  /* Typography & Color */
  font-size: clamp(0.85rem, 3.8cqw, 1.15rem);
  font-weight: bold;
  color: #ffffff;
  line-height: 1;

  /* Interactivity & Transitions */
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

/* Close button hover interaction */
.log-modal-close-btn:hover {
  /* Visual Styles & Borders */
  background-color: #b91c1c;

  /* Interactivity & Transitions */
  transform: scale(1.08);
}

/* Close button keyboard focus indicator */
.log-modal-close-btn:focus-visible {
  /* Visual Styles & Borders */
  outline: 2px solid #f3d078;
  outline-offset: 2px;
}

/* ==========================================================================
   SECTION 4: TERMINAL VIEWPORT & SCROLLBAR
   ========================================================================== */

/* Scrollable log message terminal viewport container */
.log-viewport {
  /* Positioning & Layout */
  flex: 1;

  /* Box Model & Sizing */
  min-height: 0;
  max-height: 58cqh;
  overflow-y: auto;

  /* Visual Styles & Borders */
  background-color: #080503;
  border: 1px solid #4a3818;
  border-radius: 1.5cqw;
  box-shadow: inset 0 0.3cqh 1cqh rgba(0, 0, 0, 0.9);
}

/* Custom WebKit scrollbar track sizing */
.log-viewport::-webkit-scrollbar {
  /* Box Model & Sizing */
  width: clamp(4px, 1.8cqw, 8px);
}

/* Custom WebKit scrollbar background track styling */
.log-viewport::-webkit-scrollbar-track {
  /* Visual Styles & Borders */
  background: #0e0a07;
  border-radius: 0 1.5cqw 1.5cqw 0;
}

/* Custom WebKit scrollbar thumb styling */
.log-viewport::-webkit-scrollbar-thumb {
  /* Visual Styles & Borders */
  background: #4a3818;
  border: 1px solid #c89d38;
  border-radius: 1cqw;
}

/* Custom WebKit scrollbar thumb hover state */
.log-viewport::-webkit-scrollbar-thumb:hover {
  /* Visual Styles & Borders */
  background: #c89d38;
}

/* ==========================================================================
   SECTION 5: LOG LIST & TYPOGRAPHY
   ========================================================================== */

/* Unordered log list container */
.log-list {
  /* Positioning & Layout */
  display: flex;
  flex-direction: column;
  gap: 1cqh;

  /* Box Model & Sizing */
  margin: 0;
  padding: 2.5cqw;

  /* Typography & Color */
  list-style: none;
}

/* Monospaced log item row typography with container-relative clamp() bounds */
.log-item {
  /* Box Model & Sizing */
  padding: 0.55cqh 1.2cqw;

  /* Visual Styles & Borders */
  border-radius: 0.6cqw;

  /* Typography & Color */
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: clamp(11px, 3.3cqw, 20px);
  color: #fef08a;
  line-height: 1.48;
  overflow-wrap: anywhere;
  word-break: break-word;

  /* Interactivity & Transitions */
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Individual log entry hover state */
.log-item:hover {
  /* Visual Styles & Borders */
  background-color: rgba(200, 157, 56, 0.15);

  /* Typography & Color */
  color: #ffffff;
}

/* Monospaced inline code tags inside log entries */
.log-item code {
  /* Typography & Color */
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre-wrap;
}

/* ==========================================================================
   SECTION 6: CONTAINER QUERY BREAKPOINTS
   ========================================================================== */

/* Responsive scaling overrides when the #game-wrapper height is constrained */
@container game (max-height: 500px) {
  .log-modal-card {
    /* Box Model & Sizing */
    max-height: 90cqh;
    padding: 2cqh 2.5cqw;
  }

  .log-viewport {
    /* Box Model & Sizing */
    max-height: 66cqh;
  }

  .log-list {
    /* Positioning & Layout */
    gap: 0.9cqh;

    /* Box Model & Sizing */
    padding: 2cqw;
  }

  .log-item {
    /* Box Model & Sizing */
    padding: 0.5cqh 1cqw;

    /* Typography & Color */
    line-height: 1.4;
  }
}