/* =========================
   TWL Calendar Shortcode UI
   assets/twl-cal-shortcode.css
   Version 1.1.3 (cleaned)
   ========================= */

/* Panels: required for toggles */
.twl-cal-panel[hidden]{ display:none !important; }

.twl-cal-schedule-footer{
  margin-top: 2rem;
  color: rgba(255,255,255,0.92);
  font-size: 1rem;
  line-height: 1.6;
}

.twl-cal-schedule-footer hr{
  margin: 0 0 1.25rem;
  opacity: 0.9;
}

.twl-cal-schedule-footer strong{
  display: block;
  font-weight: 800;
}

/* ---- Controls row (Tabs + Grade) ---- */
.twl-cal-controls{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin:0 0 14px 0;
}

.twl-cal-controls .twl-cal-tabs{
  margin:0;
  padding:0;
  flex:1 1 auto;
}

/* ---- Tabs ---- */
.twl-cal-tabs{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.twl-cal-tab{
  appearance:none;
  border:1px solid rgba(0,0,0,0.15);
  background:#ffffff;
  border-radius:999px;
  padding:7px 11px;
  cursor:pointer;
  font-size:13px;
  line-height:1;
}

.twl-cal-tab.is-active{
  border-color:#1d2327;
  font-weight:700;
}

/* ---- Grade pill (matches tab height) ---- */
.twl-cal-grade-filter{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 1 auto;
  min-width:0;
  max-width:100%;
  overflow:hidden;

  border:1px solid rgba(0,0,0,0.15);
  background:#ffffff;
  border-radius:999px;

  padding:6px 11px;
  height:31px;
  box-sizing:border-box;

  position:relative; /* caret */
}

.twl-cal-grade-filter label{
  margin:0;
  flex:0 0 auto;
  font-size:13px;
  line-height:1;
  white-space:nowrap;
  color:#1d2327;
  font-weight:700;
}

/*
  IMPORTANT:
  - Prevent theme from turning <select> black while open/focused.
  - Remove native arrow so we don't get double-caret.
*/
.twl-cal-shortcode .twl-cal-grade-filter .twl-cal-grade-select{
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;
  flex:1 1 auto;
  min-width:0;
  width:auto !important;
  max-width:100%;

  background-image:none !important; /* kill native caret */
  border:0 !important;
  outline:none !important;

  background-color:#ffffff !important;
  color:#1d2327 !important;

  padding:0 20px 0 4px; /* room for our caret */
  height:16px;
  line-height:16px;
  font-size:13px;
  cursor:pointer;

  color-scheme: light;
}

.twl-cal-shortcode .twl-cal-grade-filter .twl-cal-grade-select::-ms-expand{
  display:none; /* IE/old Edge arrow */
}

.twl-cal-shortcode .twl-cal-grade-filter .twl-cal-grade-select:focus,
.twl-cal-shortcode .twl-cal-grade-filter .twl-cal-grade-select:active,
.twl-cal-shortcode .twl-cal-grade-filter .twl-cal-grade-select:focus-visible{
  background-color:#ffffff !important;
  color:#1d2327 !important;
  box-shadow:none !important;
  filter:none !important;
}

/* Option list: best-effort. (Some browsers/OS ignore option styling.) */
.twl-cal-shortcode .twl-cal-grade-filter .twl-cal-grade-select option{
  background:#ffffff;
  color:#1d2327;
}

/* Our single caret */
.twl-cal-grade-filter::after{
  content:"";
  position:absolute;
  right:12px;
  top:50%;
  width:0;
  height:0;
  transform:translateY(-50%);
  border-left:5px solid transparent;
  border-right:5px solid transparent;
  border-top:6px solid rgba(0,0,0,0.55);
  pointer-events:none;
}

/* Mobile: allow wrap */
@media (max-width:760px){
  .twl-cal-grade-filter{
    margin-left:0;
    width:100%;
  }
}

/* ---- "All" view section headers (event headings) ---- */
.twl-cal-all-section{ margin:0 0 16px 0; }

.twl-cal-section-title{
  margin:0 0 10px 0;
  padding:10px 12px;
  border-radius:12px;
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.08);
  color:#fff;
  font-size:16px;
  font-weight:900;
  line-height:1.2;
}

.twl-cal-section-title em{
  font-weight:700;
  font-style:italic;
  opacity:0.9;
  margin-left:6px;
}

/* ---- Cards ---- */
.twl-cal-cards{
  display:grid;
  grid-template-columns:repeat(1, minmax(0, 1fr));
  gap:14px;
}

@media (min-width:700px){
  .twl-cal-cards{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
}
@media (min-width:1024px){
  .twl-cal-cards{ grid-template-columns:repeat(3, minmax(0, 1fr)); }
}

.twl-cal-card{
  border:1px solid rgba(255,255,255,0.08);
  background:#2b2f33;
  border-radius:14px;
  overflow:hidden;
  width:100%;
  cursor:pointer;
  text-align:left;
  padding:0;
  transition:transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.twl-cal-card:focus{ outline:none; }
.twl-cal-card:focus-visible{ box-shadow:0 0 0 3px rgba(255,255,255,0.18); }

.twl-cal-card:hover{
  transform:translateY(-3px);
  border-color:rgba(255,255,255,0.18);
  box-shadow:0 10px 30px rgba(0,0,0,0.25);
}

/* Card layout */
.twl-cal-card-inner{
  display:grid;
  grid-template-columns:clamp(120px, 22vw, 170px) 1fr;
  gap:12px;
  height:100%;
  align-items:stretch;
}

/* Left image panel */
.twl-cal-card-thumbwrap{
  height:100%;
  min-height:170px; /* baseline card height (desktop) */
  overflow:hidden;
  background:#000;
  border-top-left-radius:14px;
  border-bottom-left-radius:14px;
  display:flex;
  align-items:flex-start;
  justify-content:center;
}

/* Image width never crops */
.twl-cal-card-thumb{
  width:100%;
  height:100%;
  display:block;
  object-fit:contain;
  object-position:top center;
  background:#000;
}

/* Square images still top-aligned and contain */
.twl-cal-card-thumbwrap.is-square{ background:#2a2d31; }
.twl-cal-card-thumb.is-square{
  height:auto;
  object-fit:contain;
  object-position:top center;
  background:transparent;
}

/* Placeholder */
.twl-cal-thumb-placeholder{
  width:100%;
  height:100%;
  background:#000;
}

/* Body: lock height to match baseline, prevent tall cards */
.twl-cal-card-body{
  padding:14px 12px 16px 0; /* bottom cushion helps ellipsis */
  min-width:0;

  max-height:170px; /* matches thumbwrap min-height */
  overflow:hidden;
  box-sizing:border-box;
}

/* Title */
.twl-cal-title{
  font-size:16px;
  font-weight:800;
  color:#ffffff;
  margin:0 0 10px 0;
  min-width:0;
  overflow-wrap:anywhere;
  white-space:normal;
  line-height:1.15; /* prevents clipping */
}

/* Excerpt */
.twl-cal-excerpt{
  font-size:14px;
  color:rgba(255,255,255,0.86);
  margin:0;
  min-width:0;
  overflow-wrap:anywhere;
  white-space:normal;
  line-height:1.28;
}

/* normalize HTML inside excerpt */
.twl-cal-excerpt p{ margin:0 0 6px 0; }
.twl-cal-excerpt p:last-child{ margin-bottom:0; }
.twl-cal-excerpt ul,
.twl-cal-excerpt ol{ margin:6px 0 0 18px; padding:0; }
.twl-cal-excerpt li{ margin:2px 0; }

/* Mobile card layout + truncation */
@media (max-width:760px){
  .twl-cal-card-inner{ grid-template-columns:140px 1fr; }
  .twl-cal-card-thumbwrap{ min-height:140px; }
  .twl-cal-card-body{
    max-height:140px;
    padding:14px 12px 14px 0;
  }

  /* Title: max 2 lines */
  .twl-cal-title{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    overflow:hidden;
  }

  /* Excerpt: allow more lines on mobile */
  .twl-cal-excerpt{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:10;
    overflow:hidden;
  }
}

/* Desktop truncation (native “…” via clamp) */
@media (min-width:761px){
  .twl-cal-excerpt{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:6; /* earlier clamp to guarantee ellipsis room */
    overflow:hidden;
  }
}

/* ---- Modal ---- */
.twl-cal-modal{
  display:none;
  position:fixed;
  inset:0;
  z-index:2147483647;
}
.twl-cal-modal.is-open{ display:block; }

.twl-cal-modal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.55);
}

.twl-cal-modal-dialog{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  width:min(1120px, calc(100% - 24px));
  background:#1f2327;
  border:1px solid rgba(255,255,255,0.10);
  border-radius:16px;
  box-shadow:0 24px 60px rgba(0,0,0,0.45);

  /* fixed shell + inner scrolling */
  max-height:86vh;
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

/* Close button */
.twl-cal-modal-close{
  position:absolute;
  top:12px;
  right:12px;
  width:38px;
  height:38px;
  border:0;
  border-radius:10px;
  background:rgba(255,255,255,0.08);
  color:#fff;
  font-size:22px;
  line-height:38px;
  text-align:center;
  cursor:pointer;
  z-index:5;
  padding:0;
  transition:background 140ms ease, color 140ms ease;
}
.twl-cal-modal-close:hover{
  background: rgba(181, 152, 120, 0.85);
  color: #1f2327;
}
.twl-cal-modal-close:focus-visible{
  background: rgb(181, 152, 120);
  color: #1f2327;
  outline:none;
}

/* Content: ROW by default */
.twl-cal-modal-content{
  display:flex;
  flex-direction:row;
  gap:0;
  width:100%;
  min-width:0;
  min-height:0; /* critical for nested scrolling */
  flex:1 1 auto;
}

/* Media panel */
.twl-cal-modal-media{
  flex:0 0 520px;
  max-width:520px;
  min-width:0;

  overflow:hidden;
  border-top-left-radius:16px;
  border-bottom-left-radius:16px;
  background:#000;
}

/* Image */
.twl-cal-modal-img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
  object-position:center;
  background:#1f2327;
}
@media (min-width:761px){
  .twl-cal-modal-img.is-square{
    object-fit:contain;
    object-position:center;
    background:#1f2327;
  }
}

/* Body scrolls */
.twl-cal-modal-body{
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  padding:18px;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
}

.twl-cal-modal-title{
  font-size:22px;
  font-weight:900;
  color:#fff;
  margin:0 0 12px 0;
  overflow-wrap:anywhere;
}

.twl-cal-modal-content-html{
  font-size:14px;
  color:rgba(255,255,255,0.90);
  line-height:1.35;
}
.twl-cal-modal-content-html p{ margin:0 0 6px 0; }
.twl-cal-modal-content-html p:last-child{ margin-bottom:0; }

.twl-cal-modal-hr{
  border:0;
  border-top:1px solid rgba(255,255,255,0.10);
  margin:14px 0;
}

.twl-cal-modal-actions{
  display:flex;
  gap:10px;
  margin-top:14px;
}

.twl-cal-modal-link{
  display:inline-block;
  padding:10px 12px;
  border-radius:10px;
  background:rgba(255,255,255,0.10);
  color:#fff;
  text-decoration:none;
  border:1px solid rgba(255,255,255,0.10);
}
.twl-cal-modal-link:hover{ background:rgba(255,255,255,0.16); }

body.twl-cal-modal-open{ overflow:hidden; }

/* Mobile: stack media above body */
@media (max-width:760px){
  .twl-cal-modal-content{ flex-direction:column; }

  .twl-cal-modal-media{
    flex:0 0 auto;
    max-width:none;
    min-height:260px;
    border-radius:16px 16px 0 0;
  }
}

/* Smaller screens: a little more usable height */
@media (max-width:900px){
  .twl-cal-modal-dialog{ max-height:92vh; }
}
