/* ==========================================================================
   SocialLouder Mobile — Research Detail View (Integrated Version)
   Base + Results + Buttons + Layout Fixes
   ========================================================================== */

/* --- Google Fonts --- */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&family=Roboto:wght@400;500;600;700;800&family=Roboto+Condensed:ital,wght@0,400;0,700&display=swap");
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

/* --- Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  padding: 0;
  font-family: "Roboto", "Noto Sans KR", "Pretendard", sans-serif;
  -webkit-font-smoothing: antialiased;
}
img {
  display: block;
  max-width: 100%;
}
button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}

/* ==========================================================================
   1. LAYOUT & CONTAINER (Width 100% Fixes)
   ========================================================================== */
.screen {
  position: relative;
  width: 100%;
  max-width: 393px;
  margin: 0 auto;
  min-height: 100vh;
  background: #ffffff;
  overflow-x: hidden;
  overflow-y: auto;
}

form#research_f {
  width: 100%;
  display: block;
}

/* ==========================================================================
   2. HEADER (Fixed)
   ========================================================================== */
.write-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 393px;
  height: 60px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #ffffff;
  z-index: 100;
  border-bottom: 1px solid #f5f5f5;
}

.write-header__left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.write-header__back,
.write-header__home,
.write-header__search {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
}
.write-header__title {
  font-weight: 700;
  font-size: 16px;
  color: #000000;
}

/* ==========================================================================
   3. RESEARCH HERO SECTION
   ========================================================================== */
.research-hero {
  position: relative;
  margin-top: 80px;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 300px;
  background: #000;
  overflow: hidden;
}

.research-hero__video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.research-hero__badge {
  position: absolute;
  left: 0;
  top: 0;
  width: 55px;
  height: 55px;
  z-index: 2;
}
.research-hero__decoration {
  position: absolute;
  right: 0;
  bottom: -17px;
  width: 150px;
  z-index: 1;
}

.research-hero__content {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 30px;
  gap: 20px;
  width: 100%;
  box-sizing: border-box; /* 패딩이 너비에 포함되도록 설정 */
  z-index: 2;
}

.research-hero__tags {
  display: flex;
  gap: 5px;
}
.research-hero__tag {
  display: flex;
  align-items: center;
  padding: 6px;
  height: 19px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.4);
}
.research-hero__tag--category {
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.research-hero__tag-text {
  font-family: "Pretendard";
  font-weight: 700;
  font-size: 10px;
  color: #fff;
}
.research-hero__tag-text--yellow {
  color: #fff34d;
}
.research-hero__title-wrap {
  display: block; /* flex 대신 block으로 설정하여 자연스러운 흐름 유도 */
  width: 100%;    /* 부모 너비를 꽉 채움 */
  min-width: 0;   /* flex 컨텍스트 내에서 수축 가능하도록 설정 */
}

.research-hero__title {
  font-family: 'Pretendard', sans-serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 140%; /* 줄간격을 살짝 넓혀 가독성 향상 */
  color: #FFFFFF;
  
  /* [핵심] 줄바꿈 및 너비 초과 방지 속성 */
  display: block;
  width: 100%;
  word-break: keep-all;     /* 한글 단어 단위 줄바꿈 (가독성 좋음) */
  overflow-wrap: break-word; /* 아주 긴 단어는 강제 줄바꿈 */
  white-space: normal;      /* 줄바꿈 허용 */
}
.research-hero__info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #fff;
  font-size: 12px;
}
.research-hero__info-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.research-hero__info-label {
  width: 60px;
  opacity: 0.8;
}
.research-hero__info-value--points {
  font-weight: 700;
  color: #fff34d;
}

/* Countdown */
.research-hero__countdown {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 5px;
}
.research-hero__countdown-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.research-hero__countdown-digit {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 18px;
  height: 22px;
  background: #f44336;
  color: #fff;
  border-radius: 3px;
  font-weight: 700;
}

/* ==========================================================================
   4. QUESTION SECTION (Stretch Fix)
   ========================================================================== */
.question-section {
  width: 100%;
  background: #ffffff;
}

.question-section__container {
  display: flex;
  flex-direction: column;
  align-items: stretch !important; /* 오른쪽 마진 남는 현상 해결 */
  padding: 20px 15px;
  gap: 15px;
  width: 100%;
  box-sizing: border-box;
}

.section-divider {
  width: 100%;
  height: 8px;
  background: #f5f5f5;
  border: none;
}

.question-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  width: 100%;
}
.question-header__badge {
  padding: 4px 12px;
  background: #f5f5f5;
  border-radius: 20px;
  font-size: 12px;
}
.question-header__title {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  color: #333;
  line-height: 1.4;
}

/* Voting Options */
.question-option {
  display: flex;
  flex-direction: row; /* 좌우 배치 */
  align-items: center;
  min-height: 54px;
  height: auto; /* [추가] 텍스트가 여러 줄이 되면 높이가 유연하게 늘어나도록 설정 */
  background: #f5f5f5;
  border-radius: 5px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  padding: 10px 0; /* [추가] 상하 여백을 주어 텍스트가 위아래로 붙지 않게 함 */
  margin: 0 !important; /* gap을 사용하므로 별도의 마진은 제거하여 꼬임 방지 */
  width: 100% !important;
}

.question-option__input {
  display: none;
} /* 실제 인풋 숨김 */

/* Selected State */
.question-option:has(.question-option__input:checked) {
  background: #e5b22e;
  border-color: #e5b22e;
}
.question-option:has(.question-option__input:checked) .question-option__text {
  color: #ffffff;
}

.question-option__radio-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 50px;
}
.question-option__radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #ddd;
  position: relative;
}
.question-option__input:checked + .question-option__radio {
  border: 1px solid #000;
}
.question-option__input:checked + .question-option__radio::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: #000;
  border-radius: 50%;
}

/* --- 투표 모드 옵션 간격 수정 --- */
.question-options {
  display: flex;
  flex-direction: column;
  /* flex-start 대신 stretch를 사용해야 아이템들이 가로로 꽉 차면서 간격이 생깁니다 */
  align-items: stretch !important; 
  gap: 12px !important; /* 아이템 사이의 수직 간격을 12px로 확대 */
  width: 100%;
}

.question-option__text-wrap {
  flex: 1;
  padding-right: 20px;
  min-width: 0; /* [핵심] Flex 자식 요소가 부모 너비를 초과하지 못하도록 강제함 */
  display: block; /* [수정] 기존 display: flex를 block으로 변경하여 일반적인 텍스트 흐름 유도 */
}

.question-option__text {
  font-family: 'Roboto', 'Noto Sans KR', sans-serif;
  font-size: 13px;
  line-height: 140%; /* [수정] 줄 간격을 살짝 넓혀 가독성 향상 */
  color: #333333;
  
  /* [핵심] 줄바꿈 관련 속성 추가 */
  white-space: normal;      /* 줄바꿈 허용 */
  word-break: break-all;    /* 긴 영문/숫자 단어도 강제 줄바꿈 */
  overflow-wrap: break-word; /* 단어 단위 줄바꿈 보완 */
  display: inline-block;    /* 너비 인식을 위해 인라인 블록으로 설정 */
}

.question-section__hint {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #999;
}

/* ==========================================================================
   5. POLL RESULTS (Result Mode)
   ========================================================================== */
/* --- 결과 보기 모드 아이템 간격 수정 --- */
/* ==========================================================================
   결과 보기 모드(Poll Results) 텍스트 줄바꿈 수정
   ========================================================================== */

   
.poll-result {
  display: flex;
  flex-direction: column;
  width: 100%;
  /* [수정] 고정 높이를 해제하여 텍스트 길이에 따라 늘어나게 함 */
  height: auto !important; 
  min-height: 74px; 
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 1px 2px 2px rgba(0, 0, 0, 0.07);
  margin-bottom: 8px; /* 아이템 간 간격 확보 */
  border: 2px solid #f5f5f5;
}

.poll-result__content {
  display: flex;
  flex-direction: row;
  align-items: center; /* 세로 중앙 정렬 */
  flex: 1;
  padding: 12px 0; /* 상하 여백 추가 */
  background: #FFFFFF;
}

.poll-result__rank {
  width: 50px; /* 고정 너비 확보 */
  flex-shrink: 0; /* 랭킹 숫자가 찌그러지지 않게 함 */
  text-align: center;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 24px;
  font-style: italic;
  line-height: 100%;
}

.poll-result__text {
  flex: 1; /* 남은 공간 모두 차지 */
  min-width: 0; /* [핵심] Flex 자식 요소가 부모 너비를 넘지 못하게 제한 */
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  line-height: 140%; /* 가독성을 위해 줄간격 확보 */
  color: #333333;
  padding: 0 10px; /* 양옆 여백 */
  
  /* [핵심] 줄바꿈 속성 추가 */
  white-space: normal;      /* 줄바꿈 허용 */
  word-break: break-all;    /* 긴 단어 강제 줄바꿈 */
  overflow-wrap: break-word; /* 단어 단위 줄바꿈 */
}

.poll-result__stats {
  display: flex;
  flex-direction: column; /* 퍼센트와 숫자를 세로로 배치하여 공간 확보 */
  align-items: flex-end;
  justify-content: center;
  padding: 0 15px;
  flex-shrink: 0; /* 통계 영역 너비 보존 */
  min-width: 70px;
}

.poll-result__percentage {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 100%;
}

.poll-result__count {
  font-family: 'Roboto', sans-serif;
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* 프로그레스 바 영역 고정 */
.poll-result__progress {
  width: 100%;
  height: 5px;
  background: #F5F5F5;
  flex-shrink: 0;
}
.poll-results {
  display: flex;
  flex-direction: column;
  align-items: stretch !important;
  gap: 12px !important; /* 결과 바 사이의 간격도 12px로 통일 */
  width: 100%;
}


.poll-result--winner {
  border: 1px solid #e5b22e;
}
.poll-result--winner .poll-result__rank,
.poll-result--winner .poll-result__text,
.poll-result--winner .poll-result__percentage {
  color: #cc9504;
  font-weight: 700;
}

.poll-result__progress-bar {
  height: 100%;
  background: #898989;
  transition: width 0.8s ease-out;
}
.poll-result--winner .poll-result__progress-bar {
  background: #cc9504;
}

/* ==========================================================================
   6. BOTTOM BUTTONS (Scroll-flow)
   ========================================================================== */
.bottom-buttons {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: row;
  padding: 20px 10px 120px; /* 푸터 가림 방지 여백 */
  gap: 0;
  background: #fff;
}

.bottom-buttons__btn {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 60px;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.2s;
  flex: 1;
}

.bottom-buttons__btn--secondary {
  max-width: 120px;
  background: #898989;
  color: #fff;
  border-radius: 10px 0 0 0;
}
.bottom-buttons__btn--primary {
  background: #333;
  color: #e5b22e;
  border-radius: 0 10px 0 0;
}

/* ==========================================================================
   7. RESPONSIVE
   ========================================================================== */
@media (max-width: 359px) {
  .bottom-buttons {
    padding: 20px 6px 100px;
  }
  .research-hero__content {
    padding: 20px;
  }
}
