/* =========================
   TWL Calendar Shortcode UI
   assets/twl-cal-shortcode.css
   Version 1.1.2
   ========================= */

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

/* ---- Controls row (Tabs + Grade) ---- */
.twl-cal-controls{
  display:flex;
  align-items:center;
  gap:12px;
  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:8px 12px;
  cursor:pointer;
  font-size:14px;
  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:10px;

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

  padding:8px 12px;
  height:34px;
  box-sizing:border-box;

  position:relative; /* caret */
}

.twl-cal-grade-filter label{
  margin:0;
  font-size:14px;
  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;

  /* kill native caret across browsers */
  background-image:none !important;

  border:0 !important;
  outline:none !important;

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

  padding:0 28px 0 6px; /* room for our caret */
  height:18px;
  line-height:18px;
  font-size:14px;
  cursor:pointer;

  /* helps browser keep light UI for this control */
  color-scheme: light;
}

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

/* Keep select white on focus/active/opening (desktop theme override fix) */
.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 (ONLY one caret now) */
.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;
  }
}

/* ---- "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:
   - Keep a consistent baseline height tied to image column (desktop)
   - Prevent long text from making the card taller
*/
.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 */
  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 body height to match the image baseline (desktop)
   - so long excerpts can't make the card taller
*/
.twl-cal-card-body{
  padding:14px 16px 14px 0;
  min-width:0;

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

/* Title: fix line-height clipping */
.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 top/bottom 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.25;
}

/* normalize HTML inside excerpt */
.twl-cal-excerpt p{ margin:0 0 8px 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; }

/* =========================
   Patch: prevent bottom clipping + improve ellipsis reliability
   ========================= */

/* Give the text a tiny cushion and a bit more width */
.twl-cal-card-body{
  padding:14px 12px 16px 0;  /* was 14px 16px 14px 0 */
  max-height:170px;          /* keep baseline */
  overflow:hidden;
  box-sizing:border-box;
}

/* Ensure excerpt clamping isn't losing its last line to nested margins */
.twl-cal-excerpt{
  line-height:1.28; /* tiny bump for readability and less clipping risk */
}

/* Kill bottom margins that can cause “cut off but no …” behavior */
.twl-cal-excerpt p{
  margin:0 0 6px 0;
}
.twl-cal-excerpt p:last-child{
  margin-bottom:0;
}

/* Desktop truncation: clamp a hair earlier so ellipsis has room */
@media (min-width:761px){
  .twl-cal-excerpt{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:6; /* was 7 */
    overflow:hidden;
  }
}

/* Mobile stays as-is, but prevent last-line clipping there too */
@media (max-width:760px){
  .twl-cal-card-body{
    padding:14px 12px 14px 0;
    max-height:140px;
  }
}

/* ---- 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{
  max-height:calc(100vh - 24px);
  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);
  overflow:hidden;
}

.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;
}

.twl-cal-modal-content{
  display:grid;
  grid-template-columns:520px 1fr;
  gap:0;
  height:100%;
}

@media (max-width:760px){
  .twl-cal-modal-content{ grid-template-columns:1fr; }
}

.twl-cal-modal-media{
  height:100%;
  min-height:520px;
  overflow:hidden;
  border-top-left-radius:16px;
  border-bottom-left-radius:16px;
  background:#000;
}

.twl-cal-modal-img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
  object-position:center;
  background:#1f2327;
}

@media (max-width:760px){
  .twl-cal-modal-media{
    min-height:260px;
    border-radius:16px 16px 0 0;
  }
  .twl-cal-modal-img{
    object-fit:cover;
  }
}

@media (min-width:761px){
  .twl-cal-modal-img.is-square{
    object-fit:contain;
    object-position:center;
    background:#1f2327;
  }
}

.twl-cal-modal-body{
  padding:18px;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

.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 card layout + truncation
   ========================= */
@media (max-width:760px){
  /* static image column width on mobile */
  .twl-cal-card-inner{
    grid-template-columns:140px 1fr;
  }

  .twl-cal-card-thumbwrap{
    min-height:140px;
  }

  .twl-cal-card-body{
    max-height:140px;
  }

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

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

/* =========================
   Desktop truncation (no fade, native “…”)
   - fixes "card gets tall" perception for long excerpts
   ========================= */
@media (min-width:761px){
  .twl-cal-excerpt{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:7;
    overflow:hidden;
  }
}
