/* ================= Global Reset ================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: #000;
  color: #fff;
  padding-top: 70px; /* header space */
}

/* ================= Header ================= */
.header {
  background-color: #111;
  color: #fff;
  padding: 10px 20px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
}

.title {
  font-size: 24px;
  flex: 0 0 auto;
  margin-right: 20px;
}

/* ================= Compact Header Search (Placed before login/register) ================= */
.search-form-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: none; /* prevent from expanding */
  width: auto;
  margin-right: 10px; /* add a small gap before login/register */
}

.search-form-header input[type="text"] {
  width: 180px; /* compact width */
  min-width: 140px;
  max-width: 220px;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #444;
  background-color: #222;
  color: #fff;
  border-radius: 16px;
  flex: none;
  transition: width 0.25s ease-in-out;
}

.search-form-header input[type="text"]:focus {
  width: 220px;
  border-color: #007BFF;
}

.search-form-header button {
  padding: 6px 12px;
  font-size: 14px;
  border: none;
  background-color: #007BFF;
  color: #fff;
  border-radius: 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.search-form-header button:hover {
  background-color: #0056b3;
}

/* ================= Responsive Behavior ================= */
@media (max-width: 600px) {
  .search-form-header {
    width: 100%;
    justify-content: center;
    margin: 8px 0;
  }

  .search-form-header input[type="text"] {
    width: 100%;
    max-width: none;
  }
}


/* ================= Header Nav Links ================= */
.nav-links {
  display: flex;
  gap: 12px;
  flex: 0 0 auto;
}

.nav-links a {
  color: #e60000;
  font-weight: bold;
  text-decoration: none;
}

.nav-links a:hover {
  text-decoration: underline;
}

/* ================= Main Content (3-column Grid Layout) ================= */
.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 200px 1fr 250px; /* Left:side bar / Center:contents / Right:ads */
  gap: 20px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.sidebar {
  width: auto; /*  */
  background-color: #111;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #333;
}

.content-area {
  background-color: #000;
  border-radius: 8px;
  padding: 10px;
}

.right-sidebar {
  background-color: #111;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  color: #ccc;
}

.ad-box {
  border: 1px solid #333;
  padding: 10px;
  background-color: #000;
  border-radius: 6px;
  margin-bottom: 15px;
}

/* ================= Responsive 3-column collapse ================= */
@media (max-width: 992px) {
  .main-content {
    grid-template-columns: 180px 1fr; /* For tablet: 2colums */
  }

  .right-sidebar {
    grid-column: 1 / -1;
    order: 3; /* to below */
  }
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr; /* For phone: 1colum */
  }

  .sidebar,
  .right-sidebar {
    order: 2;
    width: 100%;
    margin-bottom: 15px;
  }

  .content-area {
    order: 1;
  }
}

/* ================= Search Form (Sidebar) ================= */
.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.search-form input[type="text"] {
  padding: 8px;
  font-size: 16px;
  width: 300px;
  border: 1px solid #333;
  background-color: #111;
  color: #fff;
  border-radius: 4px;
}

.search-form button {
  padding: 8px 16px;
  font-size: 16px;
  background-color: #e60000;
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}

.search-form button:hover {
  background-color: #cc0000;
}

/* ================= Video Grid ================= */
.video-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 30px;
}

.video-item {
  flex: 0 0 calc(33.33% - 10px);
  box-sizing: border-box;
  text-align: center;
  background-color: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.video-item:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.video-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ================= Sidebar ================= */
.sidebar {
  width: 200px;
  margin-right: 20px;
  background-color: #111;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #333;
}

.tag-list {
  list-style: none;
  padding: 0;
}

.tag-list li {
  margin-bottom: 8px;
}

.tag-list a {
  text-decoration: none;
  color: #e60000;
  font-weight: bold;
}

.tag-list a:hover {
  text-decoration: underline;
}

/* ================= Footer ================= */
.footer {
  background-color: #111;
  text-align: center;
  padding: 10px 0;
  font-size: 12px;
  color: #aaa;
}

/* ================= Links & Buttons ================= */
a {
  color: #ff4d4d;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

input, button {
  background-color: #222;
  color: #fff;
  border: 1px solid #555;
  padding: 8px;
  border-radius: 4px;
}

button {
  cursor: pointer;
}

button:hover {
  background-color: #ff4d4d;
}

/* ================= Forms ================= */
.form-container {
  max-width: 400px;
  margin: 50px auto;
  padding: 20px;
  background-color: #111;
  border-radius: 8px;
  box-shadow: 0 0 10px #222;
}

.error {
  color: #ff4d4d;
  margin-bottom: 10px;
}

/* ================= Headings ================= */
h2 {
  border-left: 4px solid #e60000;
  padding-left: 10px;
  margin: 20px 0 10px;
  font-size: 20px;
}

/* ================= Responsive ================= */
@media (max-width: 600px) {
  .main-content {
    flex-direction: column;
    padding: 10px;
  }

  .sidebar {
    width: 100%;
    margin-right: 0;
    margin-bottom: 20px;
  }

  .video-item {
    flex: 0 0 100%;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px;
  }

  .search-form-header {
    width: 100%;
    margin: 8px 0;
  }

  .nav-links {
    width: 100%;
    margin-top: 5px;
    justify-content: flex-start;
  }
}

@media (min-width: 601px) and (max-width: 1024px) {
  .video-item {
    flex: 0 0 calc(50% - 10px);
  }
}

/* ================= Video Titles ================= */
.video-item p {
  font-size: 14px;       
  line-height: 1.2em;    
  margin-top: 6px;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2; 
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word; 
}

/* ================= Responsive Video Titles ================= */
@media (max-width: 600px) {
  .video-item p {
    font-size: 12px;       
    -webkit-line-clamp: 1; 
  }
}

/* ================= 3-Column Layout ================= */
.three-column {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* common setting for columns */
.left-column,
.center-column,
.right-column {
  background-color: #000; /* black background */
  color: #fff;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 10px;
  box-sizing: border-box;
}

/* width of column */
.left-column {
  flex: 0 0 20%; /* Lest sidebar */
}

.center-column {
  flex: 1; /* meincontents */
}

.right-column {
  flex: 0 0 20%; /* adcolumns */
}

/* ================= Responsive ================= */
@media (max-width: 900px) {
  .three-column {
    flex-direction: column;
  }

  .left-column,
  .center-column,
  .right-column {
    flex: 0 0 100%;
    margin-bottom: 20px;
  }
}

.search-form-header input,
.top-search-bar input {
  transition: width 0.2s ease-in-out;
}

.search-form-header input:focus,
.top-search-bar input:focus {
  width: 240px;
  border-color: #007BFF;
}

/* Group the search form and login/register together on the right */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px; /* space between search and login/register */
  margin-left: auto; /* push this group to the right side */
}

.video-container {
  position: relative;
  z-index: 0;
}

.video-ad-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999; /* 🔥 iframeの上に強制的に重ねる */
  cursor: pointer;
}

.ad-content {
  background: #111;
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.ad-content p {
  color: #ccc;
  margin: 5px 0;
}

.click-text {
  font-size: 14px;
  color: #fff;
  margin-top: 8px;
  opacity: 0.8;
}