/* ============================================================
   uk.css – Uncle Kassey ESOL Textbook
   Mobile-first, optimized for phones
   ============================================================ */

/* ----- 1. RESET & BASE ----- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #d5dce0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* ----- 2. NAVIGATION (Mobile-first) ----- */
.topnav {
  background-color: #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 50px;
}

.topnav a {
  color: white;
  text-decoration: none;
  font-size: 18px;
  padding: 8px 12px;
}

.icon {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 4px 8px;
  -webkit-tap-highlight-color: transparent;
}

#myLinks {
  display: none;
  flex-direction: column;
  background-color: #04AA6D;
  position: absolute;
  top: 50px;
  left: 0;
  width: 100%;
  z-index: 100;
}

#myLinks a {
  color: white;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

#myLinks a:active {
  background-color: #038f5a;
}

/* Desktop adjustments */
@media (min-width: 768px) {
  .topnav {
    padding: 10px 20px;
    justify-content: flex-start;
  }
  #myLinks {
    display: flex !important;
    position: static;
    background: none;
    flex-direction: row;
    width: auto;
  }
  #myLinks a {
    border-bottom: none;
  }
  .icon {
    display: none;
  }
}

/* ----- 3. MAIN LAYOUT ----- */
.center {
  background: #d5dce0;
  padding: 8px 0;
  text-align: center;
  flex: 1;
}

/* ----- 4. UNIT CARDS (Mobile-optimized) ----- */
.unit-card {
  background: #ffffff;
  border-radius: 10px;
  padding: 0.5rem 0.5rem 0.8rem;
  margin: 0.5rem 0.6rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.unit-card:nth-child(odd) {
  background: #f8faff;
}
.unit-card:nth-child(even) {
  background: #f2f7f2;
}

/* ----- 5. RESPONSIVE IMAGES ----- */
.responsive {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.unit-card img.responsive {
  width: 100%;
  border-radius: 6px 6px 0 0;
}

/* ----- 6. AUDIO CONTROLS (Mobile-friendly) ----- */
.audio-controls {
  width: 100%;
  height: 44px;
  display: block;
  margin: 0;
  background: #ffffff;
  border-radius: 0;
  border: none;
  outline: none;
}

.audio-controls::-webkit-media-controls-panel {
  background-color: #ffffff !important;
  border-radius: 0;
  padding: 0 4px;
}

/* ----- 7. VIDEO THUMBNAIL (Touch-optimized) ----- */
.clickable-thumb {
  border-radius: 0 0 6px 6px;
  border: none;
  transition: opacity 0.15s;
  margin: 0;
  width: 100%;
  display: block;
  cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
}

.clickable-thumb:active {
  opacity: 0.7;
}

/* ----- 8. FULLSCREEN VIDEO OVERLAY (Mobile-optimized) ----- */
.video-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.97);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.video-overlay.active {
  display: flex;
}

.video-overlay-content {
  position: relative;
  width: 98%;
  max-width: 900px;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
}

.video-overlay-content video {
  width: 100%;
  height: auto;
  display: block;
  max-height: 80vh;
}

/* Close button - always visible, top left */
.video-close-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 26px;
  height: 26px;
  background: rgba(0, 0, 0, 0.6);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  color: white;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.video-close-btn:active {
  transform: scale(0.9);
  background: rgba(255, 0, 0, 0.7);
}

/* Video credit - very small, centered */
.video-credit {
  text-align: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 8px;
  padding: 3px 12px;
  letter-spacing: 0.3px;
}

.video-credit a {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
  transition: color 0.2s;
}

.video-credit a:active {
  color: rgba(255, 255, 255, 0.7);
}

/* ----- 9. FOOTER (Mobile-optimized) ----- */
.site-footer {
  background-color: #222;
  color: #ccc;
  text-align: center;
  padding: 1.2rem 1rem;
  margin-top: 0.5rem;
  border-top: 3px solid #04AA6D;
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
}

.footer-name {
  font-size: 1.2rem;
  font-weight: bold;
  color: #fff;
  margin: 0 0 0.2rem 0;
}

.footer-class {
  font-size: 0.95rem;
  color: #ddd;
  margin: 0 0 0.2rem 0;
}

.footer-copy {
  font-size: 0.8rem;
  color: #999;
  margin: 0;
  letter-spacing: 0.3px;
}

/* ----- 10. LANDSCAPE ORIENTATION FIX ----- */
@media (orientation: landscape) {
  .video-close-btn {
    top: 12px;
    left: 12px;
    width: 30px;
    height: 30px;
    font-size: 18px;
    border-width: 2px;
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.9);
  }
  
  .video-overlay-content video {
    max-height: 75vh;
  }
  
  .video-credit {
    font-size: 9px;
    margin-top: 6px;
  }
}

/* ----- 11. MOBILE OPTIMIZATIONS ----- */
@media (max-width: 767px) {
  .unit-card {
    padding: 0.4rem 0.4rem 0.6rem;
    margin: 0.4rem 0.5rem;
  }
  
  .audio-controls {
    height: 48px;
  }
  
  .video-close-btn {
    top: 12px;
    left: 12px;
    width: 26px;
    height: 26px;
    font-size: 16px;
    border-width: 1.5px;
  }
  
  .video-overlay-content {
    width: 98%;
  }
  
  .video-credit {
    font-size: 9px;
    margin-top: 6px;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .topnav a {
    font-size: 16px;
    padding: 6px 10px;
  }
  
  .video-close-btn {
    top: 10px;
    left: 10px;
    width: 22px;
    height: 22px;
    font-size: 14px;
    border-width: 1px;
  }
}