
/* --- ASAS --- */
body {
    margin: 0;
    padding: 0;
    background-color: #121212;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: white;
    overflow-x: hidden; /* Elak scroll kiri-kanan */
}

/* Had lebar supaya tak pecah di PC */
.webtoon-container {
    max-width: 800px; /* Lebar optimum yang lebih selesa untuk pelbagai saiz media */
    margin: 0 auto;   /* Centerkan di tengah skrin PC */
    background-color: #000; /* Background hitam jika media tak load */
}

/* Optimasi Prestasi */
.page-wrapper {
    content-visibility: auto; 
    contain-intrinsic-size: 1200px; /* Anggaran tinggi satu page, sesuaikan jika perlu */
    min-height: 200px; /* Elak page 'collapse' sebelum load */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: #000;
}

.webtoon-container img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0;
    background-color: #1a1a1a; /* Warna placeholder jika media lambat load */
    border: none;
    object-fit: contain !important; /* FIX: Paksa imej kekalkan nisbah aspek untuk elak 'stretch' */
}

.webtoon-container video,
.webtoon-container iframe {
    width: 100%;
    height: auto;
    display: block;
    margin: 0;
    background-color: #1a1a1a; /* Warna placeholder jika media lambat load */
    border: none;
}

/* --- GAYA SAIZ IMEJ KHAS --- */
/* A4 Portrait (21 x 29.7) - aspect-ratio: 210/297 */
.size-a4-portrait img { aspect-ratio: 210 / 297; }

/* A4 Landscape (29.7 x 21) - aspect-ratio: 297/210 */
.size-a4-landscape img { aspect-ratio: 297 / 210; }

/* 1024 x 768px - aspect-ratio: 1024/768 */
.size-1024x768 img { aspect-ratio: 1024 / 768; }

/* 851 x 351px - aspect-ratio: 851/351 */
.size-851x351 img { aspect-ratio: 851 / 351; }


/* --- GAYA VIDEO --- */
.video-wrapper {
    width: 100%;
    position: relative; /* Penting untuk kedudukan overlay */
    background-color: #000;
    z-index: 60; /* FIX: Naikkan video di atas tap-zone (z-index: 50) */
}

.video-wrapper.orientation-portrait video,
.video-wrapper.orientation-portrait iframe {
    max-width: 70%; /* Elak video potret jadi terlalu lebar di desktop */
    margin: 0 auto;
    aspect-ratio: 9 / 16;
}

.video-wrapper.orientation-landscape video,
.video-wrapper.orientation-landscape iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
}

/* Overlay Butang Main Video (Untuk Video Tempatan SAHAJA) */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.25s ease-in-out;
    pointer-events: auto;
    z-index: 10;
}

.play-icon {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 25px 0 25px 45px;
    border-color: transparent transparent transparent rgba(255, 255, 255, 0.9);
    transition: transform 0.2s ease;
}

.video-overlay:hover .play-icon {
    transform: scale(1.1);
}


/* Zone Tap Halimunan */
#tap-zone {
    position: fixed;
    top: 15%;
    left: 0;
    width: 100%;
    height: 70%; 
    z-index: 50; 
    cursor: pointer; 
}

/* --- UI BARS --- */
.ui-bar {
    position: fixed;
    left: 0;
    width: 100%;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;
    transition: transform 0.3s ease-in-out;
    box-sizing: border-box;
    max-width: 800px; 
    left: 50%;
    transform: translateX(-50%);
}

.ui-bar[style*="translateY(-100%)"] { transform: translate(-50%, -100%) !important; }
.ui-bar[style*="translateY(100%)"] { transform: translate(-50%, 100%) !important; }
.ui-bar[style*="translateY(0)"] { transform: translate(-50%, 0) !important; }

#top-bar {
    top: 0;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}
#top-bar h1 { margin: 0; font-size: 1.1rem; font-weight: 600; letter-spacing: 1px; }

.icon-btn {
    background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; padding: 5px;
}

#bottom-bar {
    bottom: 0;
    padding: 20px 20px 30px 20px;
    border-top: 1px solid #333;
}

/* Slider & Progress */
.slider-container { display: flex; align-items: center; gap: 15px; }
.page-slider { 
    -webkit-appearance: none;
    appearance: none;
    flex-grow: 1; 
    height: 4px; 
    background: #555; 
    border-radius: 2px; 
    cursor: pointer; 
    outline: none;
}
.page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #ff4500;
  border-radius: 50%;
  cursor: pointer;
}
.page-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #ff4500;
  border-radius: 50%;
  cursor: pointer;
}

#progress-bar {
    position: fixed; top: 0; left: 0; height: 3px; background: #ff4500; width: 0%; z-index: 200;
}

/* --- MODAL ISI KANDUNGAN --- */
.toc-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 300;
    justify-content: center;
    align-items: flex-end;
}
.toc-content {
    background: #1e1e1e;
    width: 100%;
    max-width: 800px; 
    max-height: 70vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.3s ease-out;
    box-sizing: border-box;
}
.toc-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #333; padding-bottom: 10px; margin-bottom: 10px;
}
.close-btn { font-size: 2rem; padding: 0 10px; cursor: pointer; }
#toc-list { list-style: none; padding: 0; margin: 0; }
#toc-list li { padding: 15px 10px; border-bottom: 1px solid #2a2a2a; font-size: 1rem; cursor: pointer; transition: background-color 0.2s; }
#toc-list li:hover { background-color: #333; }
#toc-list li:active { background-color: #ff4500; color: white; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
