/* ----------------------------------------
   Bluemoon TV Guide — Grid Shortcode Styles
   ---------------------------------------- */

/* Only when our schedule is present */
#wp--skip-link--target > div > div:has(.bmg-grid-wrapper) {
  padding: 5px !important;
}

/* Wrapper: fixed channel column + scrollable grid */
.bmg-grid-wrapper {
  display: flex;
  width: 100%;
  border: 1px solid #ddd;
  font-family: Arial, sans-serif;
  background: #fff;
}

/* Channels column (fixed) */
.bmg-channels-column {
  flex-shrink: 0;
  width: 70px;
  border-right: 1px solid #ccc;
  overflow: hidden;
}

.bmg-channels-column .bmg-channel {
  display: flex;
  align-items: center;
  height: 60px;
  padding: 0 8px;
  border-top: 1px solid #b2ebf2;
  border-bottom: 1px solid #b2ebf2;
  box-sizing: border-box;
}

.bmg-channels-column .bmg-channel img {
  max-width: 50px;
  max-height: 50px;
  margin-right: 8px;
}


.bmg-channels-column .bmg-channel .bmg-channel-name {
  font-size: 14px;
  color: #333;
}

/* Programmes column (scrollable) */
.bmg-programmes-column {
  position: relative;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Sticky header for time labels */
.bmg-programmes-column .bmg-timescale {
  position: sticky;
  top: 0;
  display: flex;
  background: #f9f9f9;
  border-bottom: 1px solid #ccc;
  z-index: 2;
}

.bmg-programmes-column .bmg-timescale .bmg-time-label {
  flex: 0 0 60px;
  text-align: left;
  font-size: 12px;
  color: #666;
  border-right: 1px solid #eee;
}

.bmg-grid-arrow-bar {
  width: 100%;
  text-align: right;
  margin: 6px 0 6px 0;
  position: relative;
  z-index: 2;
  user-select: none;
}

.bmg-grid-scroll-arrow {
  background: #fff;
  border: 1px solid #ddd;
  color: #333;
  font-size: 18px;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 20px;
  margin-left: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.2s, border-color 0.2s;
  touch-action: manipulation;
}

.bmg-grid-scroll-arrow:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #f7f7f7;
}

.bmg-grid-scroll-arrow:active {
  background: #e6e6e6;
}

/* Corner cell for arrows */
.bmg-corner-cell {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-bottom: 1px solid #eee;
  box-sizing: border-box;
  /* Height is set in JS to match header height */
  padding: 0 !important; /* Prevent extra height from padding */
  margin: 0 !important;
}

/* Grid inner container */
.bmg-programmes-column .bmg-grid-inner {
  position: relative;
}

/* Individual programme cells */
.bmg-programme-cell {
  position: absolute;
  top: 0;
  height: 60px;
  background: #e0f7fa;
  border: 1px solid #b2ebf2;
  box-sizing: border-box;
  padding: 4px;
  cursor: pointer;
  overflow: hidden;
}

.bmg-cell-progress {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 2;
}

.bmg-title.past {
  font-weight: normal;
}

/* Title: clamp to 2 lines */
.bmg-programme-cell .bmg-title {
  font-size: 12px;
  line-height: 1.2em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: normal;
}

.bmg-programme-cell .bmg-start-time {
  font-size: 12px;
  line-height: 1.2em;
  margin-top: 2px;
  color: #555;
}

.bmg-programme-cell:hover {
  background: #b2ebf2;
}
.bmg-programme-cell.active {
  background: #4dd0e1;
}

/* -------- Modal Styles -------- */
.bmg-modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.bmg-modal {
  background: #fff;
  max-width: 800px;
  width: 90%;
  display: flex;
  position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  box-sizing: border-box;
  overflow-x: hidden; /* prevent inner overflow */
}

.bmg-modal-close {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 20px;
  cursor: pointer;
}

.bmg-modal-image {
  width: 50%;
  overflow: hidden;
}

.bmg-modal-image img {
  width: 100%;
  height: auto;
  display: block;
}

.bmg-modal-details {
  padding: 16px;
  flex: 1;
  min-width: 0; /* allow this flex child to shrink */
  overflow-wrap: break-word; /* ensure text wraps inside */
}

.bmg-modal-details h2 {
  margin-top: 0;
  font-size: 24px;
  color: #222;
}

.bmg-modal-details .bmg-subtitle {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
}

.bmg-modal-actions {
  margin-bottom: 16px;
}

.bmg-modal-actions .bmg-btn {
  display: inline-block;
  padding: 8px 14px;
  margin-right: 8px;
  text-decoration: none;
  font-size: 14px;
  border-radius: 3px;
  background: #00bcd4;
  color: #fff;
}

.bmg-modal-description {
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  overflow-wrap: break-word; /* ensure long text wraps */
  word-wrap: break-word;     /* legacy fallback */
  white-space: normal;       /* allow wrapping */
  word-break: break-word;    /* break long words if needed */
  padding-right:2em;
}

/* Day-header row */
.bmg-dayscale {
  position: sticky;
  top: 0;
  display: flex;
  height: 30px;
  background: #fafafa;
  border-bottom: 1px solid #ccc;
  z-index: 3;
}

.bmg-day-label {
  display: inline-block;
  text-align: center;
  font-size: 12px;
  padding: 4px 0;
  border-right: 1px solid #eee;
}

.bmg-programmes-column .bmg-timescale {
  position: sticky;
  top: 30px;
  background: #f9f9f9;
  border-bottom: 1px solid #ccc;
  z-index: 2;
}

/* Loader spinner */
.loader {
  width: 300px;
  height: 20px;
  background:
    linear-gradient(90deg,#0001 33%,#0005 50%,#0001 66%)
    #f2f2f2;
  background-size:300% 100%;
  animation: l1 1s infinite linear;
}

@keyframes l1 { 0% {background-position: right} }

/* Modal image container */
.bmg-modal-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 35%;
}

.bmg-modal-image .loader { /* inherits loader */ }

.bmg-modal-image img {
  width: 100%;
  height: auto;
  max-height: 300px;
}

.bmg-modal-image img.fallback {
  opacity: 0.6;
}

.bmg-modal-overlay {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.bmg-modal {
  margin: auto;
  max-width: 600px;
}

@media (max-width: 600px) {
  .bmg-modal { flex-direction: column; }
  .bmg-modal-image,
  .bmg-modal-details { width: 100%; }
  .bmg-modal-image {
    margin: 10px 0;
  }
  .bmg-modal-image img {
    width: 60%;
    margin: 0 auto;
  }
}

/* --- THE "NOW" LINE --- */
.bmg-now-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px !important;
  height: 100% !important;
  background: rgba(0, 0, 255, 0.7);
  z-index: 5;
  pointer-events: none;
}

/* --- LAZY LOAD LOADER --- */
.bmg-grid-lazy-loader {
  position: absolute;
  right: 24px;
  top: 70px; /* Or adjust as needed to appear just below sticky headers */
  z-index: 20;
  width: 72px;
  text-align: center;
  background: #fff7;
  font-size: 13px;
  color: #888;
  border-radius: 6px;
  pointer-events: none;
  padding: 6px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.09);
}

/* (Optional) hide blue overlay if present by bug */
.bmg-grid-inner {
  background: none !important;
}

