/* MST Video Library - Phase 1 Styles - Updated */
:root{
  --bg1:#0b0f1a;
  --bg2:#070a12;
  --panel: rgba(10,14,26,.92);
  --panel-darker: rgba(10,14,26,.96);
  --panel2: rgba(0,0,0,.25);
  --border: rgba(255,255,255,.10);
  --border2: rgba(255,255,255,.14);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.70);
  --muted2: rgba(255,255,255,.55);
  --shadow: 0 20px 60px rgba(0,0,0,.45);
  --radius: 22px;
  --navy:#0A3161;
  --red:#fb3c59;
  --blue:#03a9f4;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 900px at 15% 15%, rgba(251,60,89,.22), transparent 60%),
    radial-gradient(1200px 900px at 85% 10%, rgba(10,49,97,.30), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
}

.mst-wrap{
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 16px 28px;
}

/* Sticky Header with Auto-Hide */
.mst-header{
  background: var(--panel-darker);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible;
  position: sticky;
  top: 18px;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mst-header.header-hidden{
  transform: translateY(-120%);
  opacity: 0;
  pointer-events: none;
}

.mst-header__top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding: 14px 16px 12px;
}

.mst-brand{
  display:flex;
  gap:12px;
  align-items:center;
  min-width: 0;
}

.mst-logo{
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.35));
}

.mst-brand__text{ min-width: 0; }

.mst-title{
  margin:0;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: .1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mst-subtitle{
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mst-header__actions{
  display:flex;
  align-items:center;
  justify-content: flex-end;
  gap:10px;
  flex: 0 0 auto;
}

.mst-viewtoggle{ 
  display:flex; 
  gap:4px;
  background: rgba(0,0,0,.2);
  border-radius: 999px;
  padding: 4px;
}

.mst-view-icon{
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.mst-view-icon:hover{
  background: rgba(255,255,255,.1);
  color: var(--text);
}

.mst-view-icon.is-active{
  background: rgba(255,255,255,.15);
  color: var(--text);
}

.mst-view-icon svg{
  width: 20px;
  height: 20px;
}

/* Buttons */
.btn{
  appearance:none;
  border: 1px solid var(--border2);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:hover{ 
  transform: translateY(-1px); 
  background: rgba(255,255,255,.11);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.btn-pill{
  border-radius: 999px;
}

/* Blue buttons when inactive */
.btn-pill:not(.active){
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn-pill:not(.active):hover{
  background: #0288d1;
  border-color: #0288d1;
}

.btn-pill.active{
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.25);
}

.btn-ghost{
  background: rgba(0,0,0,.18);
  padding: 8px 12px;
  font-size: 13px;
}

/* Controls Section */
.mst-controls{
  padding: 0 16px 14px;
}

.mst-controls__row{
  display:flex;
  gap: 10px;
  align-items:center;
  padding: 6px 0 10px;
}

/* Search - NO extra X button, just the clear button outside */
.mst-search{
  flex: 1;
  display:flex;
  gap: 10px;
  align-items:center;
  min-width: 0;
  position: relative;
}

.mst-search input{
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.20);
  color: var(--text);
  outline: none;
  transition: all 0.2s ease;
  /* Hide browser default clear button */
  -webkit-appearance: none;
}

.mst-search input::-webkit-search-cancel-button{
  -webkit-appearance: none;
  display: none;
}

.mst-search input::-ms-clear{
  display: none;
}

.mst-search input::placeholder{ 
  color: rgba(255,255,255,.45); 
}

.mst-search input:focus{
  border-color: rgba(251,60,89,.5);
  background: rgba(0,0,0,.32);
  box-shadow: 0 0 0 3px rgba(251,60,89,.1);
}

/* Hide the X button inside search - user wants only the Clear button outside */
.mst-search-clear{
  display: none !important;
}

/* Advanced Filters */
.mst-advanced{
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 12px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              padding-top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mst-advanced.is-open{
  max-height: 500px;
  opacity: 1;
}

.mst-filters{
  display:grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.filter label{
  display:block;
  font-size: 12px;
  color: var(--muted2);
  margin: 0 0 6px 2px;
}

.filter select{
  width:100%;
  height: 44px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.22);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter select:focus{
  border-color: rgba(251,60,89,.5);
  box-shadow: 0 0 0 3px rgba(251,60,89,.1);
}

select option{
  background: #0f1424;
  color: #ffffff;
}

/* Tags Section */
.mst-tags-section{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 12px 0;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mst-tags-section.is-open{
  max-height: 220px;
  opacity: 1;
  margin: 12px 0 16px;
}

.mst-tags-section.is-open.expanded{
  max-height: 2000px;
}

.mst-tags-inner{
  padding: 14px 16px;
}

.mst-tags-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.mst-tags-title{
  font-weight: 900;
  font-size: 14px;
  letter-spacing:.2px;
}

.mst-tags-expand{
  appearance: none;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mst-tags-expand:hover{
  background: rgba(255,255,255,.14);
  transform: translateY(-1px);
}

.mst-tags-chips{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 180px;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.mst-tags-section.expanded .mst-tags-chips{
  max-height: 2000px;
}

/* Tag Chips */
.chip{
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.95);
  border-radius: 999px;
  padding: 9px 13px;
  font-weight: 800;
  font-size: 13px;
  display:inline-flex;
  align-items:center;
  gap: 8px;
  cursor:pointer;
  user-select:none;
  transition: all 0.2s ease;
}

.chip:hover{
  transform: translateY(-2px);
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.28);
}

.chip em{
  font-style: normal;
  font-weight: 900;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.88);
}

.chip.active{
  border-color: rgba(251,60,89,.55);
  background: rgba(251,60,89,.18);
  color: #fff;
}

.chip.active em{
  background: rgba(0,0,0,.35);
  border-color: rgba(251,60,89,.35);
}

/* Stats */
.mst-stats{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 12px;
}

.mst-stats__count{
  font-weight: 900;
  font-size: 14px;
  color: rgba(255,255,255,.85);
}

/* Grid */
.grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.grid.view-cards{
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.view-grid{
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

/* Cards */
.card{
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.20);
  border-radius: 18px;
  overflow:hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  transition: all 0.2s ease;
}

.card:hover{
  transform: translateY(-4px);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  border-color: rgba(255,255,255,.18);
}

.card__media{
  position:relative;
  height: 170px;
  background: rgba(255,255,255,.05);
  background-size: cover;
  background-position: center;
  cursor: pointer;
}

.grid.view-grid .card__media{
  height: 110px;
}

.overlay{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  padding: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.75) 100%);
  transition: background 0.2s ease;
}

.card__media:hover .overlay{
  background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.85) 100%);
}

.overlay__title{
  font-weight: 900;
  font-size: 14px;
  line-height: 1.15;
  text-shadow: 0 2px 12px rgba(0,0,0,.8);
}

.overlay__sub{
  margin-top: 5px;
  font-size: 12px;
  color: rgba(255,255,255,.78);
  text-shadow: 0 1px 8px rgba(0,0,0,.8);
}

.card__body{
  padding: 12px;
}

.grid.view-grid .card__body{
  padding: 10px;
}

.card__meta{
  display:flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.pill{
  font-size: 11px;
  font-weight: 900;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.90);
}

.pill--hot{
  border-color: rgba(251,60,89,.50);
  background: rgba(251,60,89,.14);
}

.card__sub{
  margin-top: 0;
  display:flex;
  align-items:center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.dot{
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
}

.card__notes{
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.grid.view-grid .card__notes{
  display:none;
}

.card__tags{
  margin-top: 10px;
  display:flex;
  flex-wrap:wrap;
  gap: 6px;
}

.grid.view-grid .card__tags{
  display:none;
}

.tag{
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.22);
  color: rgba(255,255,255,.78);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tag:hover{
  transform: translateY(-2px);
  background: rgba(251,60,89,.14);
  border-color: rgba(251,60,89,.45);
  color: #fff;
}

/* Empty */
.empty{
  margin-top: 16px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
}

.hidden{ 
  display:none !important; 
}

/* Footer */
.mst-footer{
  margin-top: 14px;
}

.mst-footer__box{
  color: var(--muted);
  font-size: 13px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
}

/* ========================================
   FULLSCREEN MODAL - FIXED LAYOUT
   Video info now BELOW video, not overlapping
======================================== */
.modal-fullscreen{
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: flex;
  flex-direction: column;
}

.modal-fullscreen.hidden{ 
  display: none; 
}

.modal-header{
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(env(safe-area-inset-top), 16px) 20px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,.95), rgba(0,0,0,.6) 60%, transparent);
  pointer-events: none;
}

.modal-counter{
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  text-shadow: 0 2px 12px rgba(0,0,0,.9);
  pointer-events: auto;
}

.modal-close{
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  pointer-events: auto;
}

.modal-close:hover{
  background: rgba(255,255,255,.3);
  transform: scale(1.08);
}

.modal-body{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding-top: 60px; /* space for header */
}

/* Content wrapper - column layout with video on top, info below */
.modal-content-wrapper{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
}

/* Video Container - takes up most space but leaves room for info */
.modal-video-container{
  flex: 1 1 auto;
  position: relative;
  background: #000;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-video-container iframe{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Placeholder for non-YouTube */
.modal-placeholder{
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background-size: cover;
  background-position: center;
  min-height: 300px;
}

.modal-placeholder::before{
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(20px);
}

.modal-cta{
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 32px;
  background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  font-weight: 900;
  font-size: 17px;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.modal-cta:hover{
  transform: scale(1.05);
  background: rgba(255,255,255,.28);
  border-color: rgba(255,255,255,.5);
}

/* Info Panel - BELOW video, not overlapping */
.modal-info-panel{
  flex: 0 0 auto;
  background: rgba(10,14,26,.98);
  border-top: 1px solid rgba(255,255,255,.12);
  padding: 16px 20px max(env(safe-area-inset-bottom), 16px);
  color: #fff;
  max-height: 200px;
  overflow-y: auto;
}

.modal-info-panel::-webkit-scrollbar{
  width: 6px;
}

.modal-info-panel::-webkit-scrollbar-track{
  background: rgba(255,255,255,.05);
}

.modal-info-panel::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.2);
  border-radius: 3px;
}

.modal-title{
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
}

.modal-meta{
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,.80);
  margin-bottom: 10px;
}

.modal-notes{
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255,255,255,.75);
}

.modal-tags{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-tag{
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-tag:hover{
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.35);
  transform: translateY(-1px);
}

.modal-hint{
  position: absolute;
  bottom: max(env(safe-area-inset-bottom), 8px);
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255,255,255,.4);
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,.9);
  pointer-events: none;
  z-index: 20;
}

/* Mobile */
@media (max-width: 860px){
  .mst-wrap{ 
    padding: 8px 12px 24px;
  }

  .mst-header{
    top: 8px;
    border-radius: 16px;
  }

  .mst-header__top{
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 14px 10px;
    flex-wrap: wrap;
  }

  .mst-brand{
    flex: 1 1 auto;
    min-width: 0;
  }

  .mst-header__actions{
    flex: 0 0 auto;
  }

  .mst-title{ font-size: 16px; }
  .mst-subtitle{ font-size: 12px; }

  .mst-controls{
    padding: 0 14px 12px;
  }

  .mst-controls__row{
    flex-wrap: wrap;
  }

  .mst-advanced{
    max-height: 0;
  }

  .mst-advanced.is-open{
    max-height: 800px;
  }

  .mst-filters{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mst-tags-section.is-open{
    max-height: 140px;
  }

  .grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.view-cards{
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  .grid.view-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card__media{ 
    height: 160px; 
  }

  .grid.view-grid .card__media{ 
    height: 140px; 
  }

  .modal-body{
    padding-top: 50px;
  }

  .modal-info-panel{
    max-height: 180px;
    padding: 14px 16px max(env(safe-area-inset-bottom), 14px);
  }

  .modal-title{
    font-size: 16px;
  }

  .modal-meta{
    font-size: 12px;
  }
  
  /* Mobile tags - show 3 rows */
  .mst-tags-section.is-open{
    max-height: 170px;
  }
  
  .mst-tags-chips{
    max-height: 135px;
  }
}

/* Tablet */
@media (min-width: 861px) and (max-width: 1100px){
  .mst-filters{ 
    grid-template-columns: repeat(3, minmax(0, 1fr)); 
  }

  .grid{ 
    grid-template-columns: repeat(2, minmax(0, 1fr)); 
  }

  .grid.view-grid{ 
    grid-template-columns: repeat(4, minmax(0, 1fr)); 
  }
}

/* Desktop - Search and filters on one row */
@media (min-width: 1101px){
  .mst-controls__row{
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
  }
}
