/* Game of Thrones Cinematic Design System - Fully Scrollable & Highly Responsive Layout */

/* @font-face definition for NRT Kurdish Font */
@font-face {
    font-family: 'NRT';
    src: url('fonts/NRT-Regular.woff2') format('woff2'),
         url('fonts/NRT-Regular.woff') format('woff'),
         url('fonts/NRT-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'NRT';
    src: url('fonts/NRT-Bold.woff2') format('woff2'),
         url('fonts/NRT-Bold.woff') format('woff'),
         url('fonts/NRT-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

:root {
    --bg-dark: #050407; /* Deep obsidian */
    --card-bg: rgba(10, 8, 13, 0.94); /* Iron-stone plate */
    --border-gold: rgba(197, 168, 128, 0.35); /* Antique gold */
    --border-gold-hover: rgba(229, 193, 127, 0.95); /* Valyrian gold leaf */
    
    --text-primary: #f5f0e6; /* Parchment white */
    --text-secondary: #e2ded6; /* Brighter off-white grey for readability */
    
    --accent-gold: #c5a880; /* Burned brass gold */
    --bright-gold: #e5b33d; /* Bright gold leaf */
    --house-crimson: #841010; /* Lannister crimson */
    --house-crimson-glow: rgba(132, 16, 16, 0.55);
    --wall-ice-blue: #38bdf8; /* Frozen Wall ice blue */
    --wall-ice-glow: rgba(56, 189, 248, 0.3);
    
    --font-heading: 'Cinzel', 'NRT', 'Noto Naskh Arabic', serif;
    --font-kurdish: 'NRT', 'Noto Naskh Arabic', 'Noto Kufi Arabic', 'Tahoma', sans-serif;
    --transition-cinematic: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Enable natural scrolling and prevent any horizontal overflow cut-off */
html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-kurdish);
    display: block; /* Standard block layout to fix RTL flexbox overflow bug */
    direction: rtl; /* RTL Layout */
    padding: 40px 16px; /* standard body padding to prevent clipping on mobile borders */
}

/* Fullscreen Visual Effects Wrapper to lock in size and avoid horizontal overflows */
.visual-effects-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

/* Fullscreen Parallax Background Image with slow drift */
.parallax-bg {
    position: absolute; /* Relative to wrapper */
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    background-image: url('got_background.jpg');
    background-size: cover;
    background-position: center;
    z-index: -3;
    pointer-events: none;
    animation: panBg 50s ease-in-out infinite alternate;
    will-change: transform; /* Promotes layer to GPU for 120FPS animation */
}

@keyframes panBg {
    0% {
        transform: scale(1) translate(0, 0);
    }
    100% {
        transform: scale(1.06) translate(-1%, -1%);
    }
}

/* Dark Vignette Overlay */
.overlay-dark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(4, 3, 6, 0.45) 0%, rgba(4, 3, 6, 0.72) 100%); /* Brighter background to show art */
    z-index: -2;
    pointer-events: none;
}

/* Background Snow Canvas */
/* Frosty Snow Caps covering container tops */
.header-banner::before, .portal-card::before {
    content: '';
    position: absolute;
    top: -3px; /* sits right on top of the border */
    left: 8px;
    right: 8px;
    height: 4px;
    background: linear-gradient(to bottom, #ffffff 0%, #dbeafe 100%);
    border-radius: 3px;
    box-shadow: 0 0 6px #ffffff, 0 1px 3px rgba(56, 189, 248, 0.45);
    z-index: 3;
    pointer-events: none;
}

/* Ambient glow nodes */
.background-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(150px);
    z-index: -1;
    opacity: 0.22;
    pointer-events: none;
}

.bg-glow-fire {
    background: radial-gradient(circle, var(--house-crimson) 0%, transparent 70%);
    top: -200px;
    left: -100px;
}

.bg-glow-ice {
    background: radial-gradient(circle, var(--wall-ice-blue) 0%, transparent 70%);
    bottom: -200px;
    right: -100px;
}

/* Parallax drifting mist layers for wind movement */
.mist-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.015) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    opacity: 0.55;
    will-change: transform; /* Smooth GPU-accelerated drift */
}

.mist-1 {
    animation: driftMist 45s linear infinite;
}

.mist-2 {
    animation: driftMist 80s linear infinite reverse;
    opacity: 0.35;
}

@keyframes driftMist {
    0% {
        transform: translateX(0%);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Container (Centering safely with margin auto to prevent RTL browser overflow) */
.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto; /* Horizontally center dynamically in RTL/LTR */
    display: flex;
    flex-direction: column;
    gap: 28px;
    z-index: 1;
}

/* Top Banner scroll theme (Weathered Parchment Slate) */
.header-banner {
    background: rgba(12, 10, 15, 0.42); /* High transparency */
    border: 2px solid var(--border-gold);
    border-top: 4px solid var(--accent-gold);
    border-bottom: 4px solid var(--accent-gold);
    padding: 24px 28px;
    text-align: center;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.8);
    position: relative;
    border-radius: 1px;
}

/* Ornate Crest Shield */
.banner-crest {
    display: inline-flex;
    margin-bottom: 12px;
    justify-content: center;
    align-items: center;
}

.crest-frame {
    border: 2px solid var(--accent-gold);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 3, 6, 0.85);
    box-shadow: 0 0 10px rgba(197, 168, 128, 0.35);
    transform: rotate(45deg);
}

.crest-icon {
    font-size: 1.25rem;
    color: var(--accent-gold);
    transform: rotate(-45deg);
    filter: drop-shadow(0 0 4px var(--accent-gold));
}

.greet-title {
    font-family: var(--font-heading);
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.15);
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Gold crest divider */
.crest-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 12px 0;
}

.crest-divider .line {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
    flex-grow: 1;
    max-width: 120px;
}

.divider-crown {
    color: var(--accent-gold);
    font-size: 0.95rem;
    filter: drop-shadow(0 0 4px var(--accent-gold));
}

.greet-subtitle {
    font-size: clamp(0.88rem, 2.5vw, 1rem);
    line-height: 1.8;
    color: var(--text-secondary);
    font-weight: normal;
    text-align: justify;
    text-justify: inter-word;
}

/* Main Cinematic Card */
.portal-card {
    background: rgba(10, 8, 13, 0.45); /* High transparency */
    border: 2px solid var(--border-gold);
    border-radius: 1px;
    padding: 36px 30px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.9);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Medieval corners */
.corner-accent {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid var(--accent-gold);
    pointer-events: none;
}

.top-left {
    top: 10px;
    left: 10px;
    border-right: none;
    border-bottom: none;
}

.top-right {
    top: 10px;
    right: 10px;
    border-left: none;
    border-bottom: none;
}

.bottom-left {
    bottom: 10px;
    left: 10px;
    border-right: none;
    border-top: none;
}

.bottom-right {
    bottom: 10px;
    right: 10px;
    border-left: none;
    border-top: none;
}

/* Logo Area / Instruction */
.logo-area {
    text-align: center;
}

.sword-icon-container {
    margin-bottom: 12px;
}

.swords-icon {
    font-size: 1.8rem;
    color: var(--text-secondary);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.1));
}

.episodes-instruction-title {
    font-family: var(--font-kurdish);
    font-size: clamp(1.1rem, 3.5vw, 1.35rem);
    font-weight: 700;
    color: var(--accent-gold);
    line-height: 1.5;
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--accent-gold) 50%, transparent 100%);
    margin-top: 16px;
    opacity: 0.5;
}

/* Episode List Container */
.episodes-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Episode Row cards */
.episode-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(6, 4, 8, 0.22); /* High transparency */
    border: 1px solid var(--border-gold);
    padding: 16px 22px;
    transition: var(--transition-cinematic);
    position: relative;
    border-radius: 1px;
    min-height: 80px; /* Standardize height to make containers same size */
}

/* Slide in accent bar on hover */
.episode-row::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 0;
    background: var(--accent-gold);
    transition: var(--transition-cinematic);
}

.episode-row:hover::after {
    width: 4px;
}

.episode-row:hover {
    background: rgba(197, 168, 128, 0.05);
    border-color: var(--border-gold-hover);
    transform: translateX(-4px); /* Shift left in RTL */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.episode-row.fire-theme-row:hover::after {
    background: var(--house-crimson);
}

.episode-row.fire-theme-row:hover {
    background: rgba(132, 16, 16, 0.12);
    border-color: var(--house-crimson);
    box-shadow: 0 10px 30px var(--house-crimson-glow);
}

.episode-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.season-badge {
    background: rgba(10, 8, 12, 0.6);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.82rem;
    padding: 5px 0;
    letter-spacing: 0.05em;
    border-radius: 1px;
    width: 72px; /* Fixed width to make containers same size */
    text-align: center;
    display: inline-block;
    flex-shrink: 0; /* Prevents warping */
}

/* Ice & Fire Badges */
.season-badge.ice-theme {
    background: rgba(56, 189, 248, 0.06);
    border: 1px solid var(--wall-ice-blue);
    color: var(--wall-ice-blue);
    box-shadow: 0 0 10px var(--wall-ice-glow);
}

.season-badge.fire-theme {
    background: rgba(132, 16, 16, 0.18);
    border: 1px solid var(--house-crimson);
    color: #ffa3a3;
    box-shadow: 0 0 10px var(--house-crimson-glow);
}

.episode-text-details h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

.episode-text-details p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.badge-icon {
    font-size: 0.8rem;
    color: var(--accent-gold);
}

.red-wedding-blood {
    color: #ef4444;
    animation: pulseBlood 2.5s ease-in-out infinite;
}

@keyframes pulseBlood {
    0%, 100% {
        opacity: 0.65;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.12);
    }
}

/* Valyrian Steel Download Buttons */
.btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(20, 18, 23, 0.22) 0%, rgba(41, 38, 47, 0.3) 50%, rgba(20, 18, 23, 0.22) 100%); /* High transparency */
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    font-family: var(--font-heading);
    font-weight: bold;
    font-size: 0.85rem;
    padding: 12px 0;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-cinematic);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.55);
    min-height: 48px;
    border-radius: 1px;
    width: 120px; /* Fixed width to make containers same size */
    flex-shrink: 0; /* Prevents warping */
}

.btn-download:hover {
    color: #07060a;
    background: var(--accent-gold);
    border-color: var(--bright-gold);
    box-shadow: 0 0 20px rgba(197, 168, 128, 0.45);
    transform: scale(1.02);
}

.btn-download.btn-fire {
    border-color: var(--house-crimson);
    color: #ffa3a3;
    background: linear-gradient(135deg, rgba(132, 16, 16, 0.12) 0%, rgba(132, 16, 16, 0.22) 100%); /* High transparency crimson */
}

.btn-download.btn-fire:hover {
    background: var(--house-crimson);
    border-color: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 22px rgba(132, 16, 16, 0.75);
}

.btn-download:active {
    transform: scale(0.97);
}

.download-icon {
    font-size: 1rem;
}

/* Help Trigger Button */
.help-section {
    border-top: 1px solid var(--border-gold);
    padding-top: 22px;
}

.help-modal-trigger-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border-gold);
    color: var(--text-secondary);
    font-family: var(--font-kurdish);
    font-size: 0.85rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px;
    cursor: pointer;
    transition: var(--transition-cinematic);
}

.help-modal-trigger-btn:hover {
    background: rgba(197, 168, 128, 0.08);
    color: var(--accent-gold);
    border-color: var(--accent-gold);
}

.icon-right {
    font-size: 1rem;
    color: var(--accent-gold);
}

/* Floating Scroll Modal pop-up */
.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.help-modal.active {
    display: flex;
}

.help-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 3, 6, 0.85);
    backdrop-filter: blur(8px);
}

.help-modal-content {
    position: relative;
    background: rgba(14, 12, 18, 0.97);
    border: 2px solid var(--border-gold);
    width: 100%;
    max-width: 500px;
    max-height: 85dvh;
    padding: 36px 30px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 101;
    border-radius: 1px;
}

.close-modal-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: none;
    border: none;
    color: var(--accent-gold);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-cinematic);
}

.close-modal-btn:hover {
    color: #ffffff;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(197, 168, 128, 0.25);
    text-align: center;
    margin-top: 10px;
}

.help-modal-scrollable {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-left: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-gold) rgba(0, 0, 0, 0.2);
}

.help-platform {
    background: rgba(8, 6, 10, 0.55);
    border: 1px solid var(--border-gold);
    padding: 20px;
    border-radius: 1px;
}

.help-platform h4 {
    font-family: var(--font-heading);
    font-size: 0.92rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    color: #ffffff;
    border-bottom: 1px solid rgba(197, 168, 128, 0.2);
    padding-bottom: 8px;
}

.platform-icon {
    margin-left: 10px;
    font-size: 1.05rem;
    color: var(--accent-gold);
}

.help-platform ol {
    margin-right: 20px;
    font-size: 0.82rem;
    line-height: 1.85;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-platform ol li strong {
    color: var(--text-primary);
}

/* Footer note */
.footer-note {
    text-align: center;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: rgba(197, 168, 128, 0.28);
}

/* Fade-in Animations */
.fade-in {
    opacity: 0;
    transform: translateY(22px);
    animation: fadeInUp 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-1 {
    animation-delay: 0.25s;
}

.delay-2 {
    animation-delay: 0.5s;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN & MOBILE OPTIMIZATIONS (Fixed Edge issues and overflows)
   ========================================================================== */

/* 1. Tablets, iPads (Portrait & Landscape) (Max-width: 768px) */
@media (max-width: 768px) {
    body {
        padding: 30px 16px;
    }
    .container {
        gap: 20px;
    }
    .header-banner {
        padding: 20px 24px;
    }
    .portal-card {
        padding: 28px 22px;
        gap: 24px;
    }
}

/* 2. Mobile Phones (Max-width: 580px) */
@media (max-width: 580px) {
    body {
        padding: 20px 12px;
    }
    .portal-card {
        padding: 24px 16px;
        gap: 18px;
    }
    /* Keep row horizontal but compact on mobile */
    .episode-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 14px;
        gap: 10px;
        min-height: 68px; /* Standardize mobile height to keep containers same size */
    }
    .episode-info {
        flex-direction: row;
        gap: 12px;
        align-items: center;
        flex-grow: 1;
    }
    .season-badge {
        font-size: 0.75rem;
        padding: 4px 0;
        width: 58px; /* Fixed width on mobile */
        text-align: center;
    }
    .episode-text-details {
        flex-grow: 1;
        text-align: right;
    }
    .episode-text-details h3 {
        font-size: 0.98rem;
    }
    .episode-text-details p {
        font-size: 0.72rem;
    }
    .btn-download {
        width: 95px; /* Fixed width on mobile to make containers same size */
        padding: 8px 0;
        min-height: 38px;
        font-size: 0.78rem;
        gap: 6px;
        justify-content: center;
    }
}

/* 3. Small Mobile Screens (Max-width: 360px) */
@media (max-width: 360px) {
    body {
        padding: 16px 8px;
    }
    .portal-card {
        padding: 16px 10px;
        gap: 14px;
    }
    .episode-row {
        padding: 10px 8px;
        gap: 6px;
    }
    .episode-info {
        gap: 8px;
    }
    .season-badge {
        font-size: 0.7rem;
        padding: 2px 5px;
    }
    .episode-text-details h3 {
        font-size: 0.88rem;
    }
    .episode-text-details p {
        font-size: 0.68rem;
    }
    .btn-download {
        padding: 6px 12px;
        min-height: 34px;
        font-size: 0.72rem;
        gap: 6px;
    }
    .help-modal-trigger-btn {
        padding: 10px;
        font-size: 0.8rem;
    }
}
