/* =========================================================
   HEX / Video Styles – refactored (same behavior, cleaner)
   Goals:
   - less repetition
   - !important only where it protects against framework defaults
   - consistent 16:9 handling via aspect-ratio with safe fallback
   ========================================================= */

/* ---------- Small tokens (optional, but helps consistency) ---------- */
:root{
  --hex-maxw: 950px;
  --hex-font: Calibri, Arial, Helvetica, sans-serif;

  --overlay-dark: rgba(0,0,0,.45);
  --overlay-dark-soft: rgba(0,0,0,.35);

  --btn-bg: rgba(25, 83, 101, .95);
  --btn-radius: 22px;
}

/* =========================================================
   1) HEX VIDEO COMPONENT
   Markup expectation (roughly):
   .hex-video
     figure
       .figure-wrapper
         .video-container
           iframe OR img.thumbnail
         .cover (optional)
         .info (logo/headline/play)
       .figcaption (optional)
   ========================================================= */

/* A) Containment + reset (centralized)
   Use :where() so it stays low specificity (easy to override later). */
.hex-video :where(figure, .figure-wrapper, .video-container, iframe, img, .thumbnail){
  border: 0 !important;         /* often needed vs bootstrap/img defaults */
  box-shadow: none !important;  /* same */
  background: none !important;
  outline: none !important;
}

.hex-video{
  position: relative;
}

/* Remove default figure margin safely */
.hex-video :where(figure){
  margin: 0;
}

/* B) Media frame */
.hex-video .figure-wrapper{
  position: relative;
  overflow: hidden;
}

/* Prefer modern aspect-ratio; keep a fallback for older browsers */
.hex-video .video-container{
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

/* Fallback: only kicks in if aspect-ratio not supported */
@supports not (aspect-ratio: 16 / 9){
  .hex-video .video-container{
    height: 0;
    padding-top: 56.25%;
  }
}

/* Embedded video fills container */
.hex-video .video-container iframe{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Thumbnail image fills container */
.hex-video .thumbnail{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* C) Overlay layer (optional) */
.hex-video .cover{
  position: absolute;
  inset: 0;
  background: var(--overlay-dark-soft);
  pointer-events: none;
}

/* D) Center info / CTA */
.hex-video .info{
  position: absolute;
  inset: 0;                     /* makes centering simpler */
  display: grid;
  place-items: center;
  padding: 8px 12px;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  pointer-events: none;         /* prevents overlay blocking clicks */
}

/* Inner stack */
.hex-video .info > *{
  pointer-events: auto;         /* allow buttons/links inside */
}

.hex-video .info .stack{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* If you don't have a .stack wrapper in markup, this still works:
   the below targets existing children similarly */
.hex-video .info:not(:has(.stack)){
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

/* Logo circle */
.hex-video .info .logo{
  width: 72px;
  height: 72px;
  border: 4px solid rgba(255,255,255,.95);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

/* Headline */
.hex-video .info .headline{
  margin: 0;
  font-weight: 800;
  font-size: 22px;
  line-height: 1.3;
}

/* Play button/link */
.hex-video .play{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--btn-bg);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--btn-radius);
  text-decoration: none;
  font-weight: 700;
}

.hex-video .play:focus{
  outline: 2px solid #fff !important;
  outline-offset: 2px;
}

/* Caption */
.hex-video .figcaption{
  margin-top: 8px;
  color: #333;
  font-size: 14px;
}

/* =========================================================
   2) SIMPLE VIDEO WRAPPER (your second pattern)
   Keeps your behavior: thumbnail + overlay + play overlay
   with class toggle .is-playing to hide overlay.
   ========================================================= */

.video-wrapper{
  position: relative;
  width: 100%;
  max-width: var(--hex-maxw);
  aspect-ratio: 16 / 9;
  margin: 20px auto;
}

/* Overlay tint */
.video-wrapper::after{
  content: "";
  position: absolute;
  inset: 0;
  background: var(--overlay-dark);
  pointer-events: none;
}

/* Thumbnail */
.video-wrapper .thumbnail{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Play overlay content */
.video-wrapper .play-overlay{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,.8);
  z-index: 2;
  padding: 12px;
}

.video-wrapper .play-button{
  color: #fff;
  font-size: 20px;
  padding: 10px 18px;
  border-radius: 30px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--hex-font);
  text-shadow: none !important;
}

/* Icons / logos */
.video-wrapper .play-icon{
  width: 40px;
  height: 40px;
}

.video-wrapper .logo-overlay{
  width: 60px;
  height: 60px;
  margin: 0 auto 20px auto;
  display: block;
}

.video-wrapper .play-overlay h2{
  margin: 0 0 15px 0;
  color: #fff;
  font-family: var(--hex-font);
  text-shadow: none !important;
}

/* Video element (initially hidden like before) */
.video-wrapper iframe{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: none;
}

/* When playing: hide overlay tint (same as before) */
.video-wrapper.is-playing::after{ display: none; }

/* =========================================================
   3) PAGE / TYPO / LAYOUT (rest of your styles)
   Mostly unchanged, just normalized (max-width token etc.)
   ========================================================= */

/* Video Caption */
.video-caption{
  max-width: 600px;
  margin: 15px auto 0 auto;
  text-align: center;
  font-size: 14px;
  color: #666;
  line-height: 1.4;
  font-family: var(--hex-font);
}

/* Section Headings */
.section-heading{
  text-align: left;
  font-family: var(--hex-font);
  font-weight: bold;
  margin: 30px 0 15px 0;
}

/* Content Container */
.content-container{
  width: 100%;
  max-width: var(--hex-maxw);
  margin: 0 auto;
}

/* Analysis Text */
.analysis-text{
  text-align: justify;
  font-family: var(--hex-font);
  max-width: var(--hex-maxw);
  margin: 0 auto;
  line-height: 1.6;
}

/* Logo Positioning */
.logo-positioned{
  position: absolute;
  top: 0px;
  right: 0px;
  width: 260px;
  height: auto;
}

/* Video Overlay Heading */
.video-overlay-heading{
  font-family: var(--hex-font);
  font-size: 28px;
  font-weight: bold;
  margin: 0 0 15px 0;
  text-align: center;
}

/* Plot Slider - Responsive */
.plot-container-responsive{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px auto 0 auto;
  width: 100%;
  max-width: var(--hex-maxw);
  border: none;
  padding: 0;
}

.plot-container-responsive > div{
  flex-grow: 1;
  margin: 0 20px;
  min-width: 0;
}

.plot-container-responsive .shiny-plot-output{
  width: 100% !important;
  max-width: 100%;
  height: auto;
  min-height: 300px;
}

/* Arrows */
.arrow-btn-clean{
  font-size: 32px;
  background: none;
  border: none;
  cursor: pointer;
  color: #495057;
  padding: 10px 15px;
  border-radius: 50%;
  transition: transform 0.3s ease, background-color 0.3s ease, color 0.3s ease;
  flex-shrink: 0;
}

.arrow-btn-clean:hover{
  background-color: #e9ecef;
  color: #212529;
  transform: scale(1.1);
}

.arrow-btn-clean:active{ transform: scale(0.95); }

.arrow-btn-clean:disabled{
  color: #adb5bd;
  cursor: not-allowed;
}

.arrow-btn-clean:disabled:hover{
  background: none;
  transform: none;
}

/* Spacing helpers */
h3.section-title{
  margin-top: 44px;
  margin-bottom: 28px;
}
.section-block{ margin-bottom: 44px; }

/* Text rhythm */
.content-container p{
  margin: 0 0 14px 0;
  line-height: 1.65;
}
.analysis-text{ margin-bottom: 0; }

/* FAQ formatting */
.faq-wrap{ margin: 0 auto; }
.faq-item{ margin: 0 0 22px 0; }
.faq-item strong{
  display: block;
  margin: 0 0 6px 0;
}

/* Methods / Expertise blocks */
.narrow-wrap{ margin: 0 auto; }

/* Headline + logo positioning container */
.hero-wrap{ position: relative; }

.plot-stage{
  flex-grow: 1;
  margin: 0 20px;
  min-width: 0;
}

/* Caption + Counter */
.plot-caption{
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(0,0,0,0.75);
}

.plot-counter{
  margin-top: 6px;
  font-size: 12px;
  color: rgba(0,0,0,0.55);
}

/* Switch */
.switch{
  background-color: #fff;
  border: 1px solid #4a4a4a;
  color: #4a4a4a;
  padding: 5px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 10px;
  margin: 4px 2px;
  cursor: pointer;
  border-radius: 40px;
  width: 150px;
  height: 40px;
  box-shadow: none;
  outline: none;
}
.switch:active{ transform: translateY(2px); }
.switch:hover{ background-color: #f9f9f9; }

/* Layout helper */
.row-flex{
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
}
.text-content{ padding-left: 24px; }

/* Hex page alignment */
.hex-page .content-container,
.hex-page .faq-wrap,
.hex-page .narrow-wrap,
.hex-page .plot-container-responsive{
  max-width: var(--hex-maxw);
  margin-left: 0;
  margin-right: auto;
}

.hex-page .plot-container-responsive{
  margin-top: 18px;
  margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 768px){
  .plot-container-responsive{
    max-width: 100vw;
    margin: 20px 10px;
  }
  .plot-container-responsive > div{ margin: 0 10px; }

  .arrow-btn-clean{ padding: 5px !important; }
  .arrow-btn-clean img{ width: 30px !important; height: 30px !important; }

  .plot-container-responsive .shiny-plot-output{ min-height: 250px; }

  .row-flex{ flex-direction: column-reverse; }
  .text-content{ padding-left: 0; }

  .section-title{ margin-top: 34px; }
  .section-block{ margin-bottom: 34px; }
  .plot-stage{ margin: 0 12px; }
}

@media (max-width: 480px){
  .plot-container-responsive{ margin: 20px 5px; }
  .plot-container-responsive > div{ margin: 0 5px; }

  .arrow-btn-clean{ padding: 3px !important; }
  .arrow-btn-clean img{ width: 25px !important; height: 25px !important; }
}
