/* --- 1. DESIGN VARIABLES --- */
:root {
    --bg: #0F172A;
    --card-bg: #1E293B; /* Slate 800 */
    --accent: #FFB800;
    --text: #F8FAFC;
    --text-muted: #94A3B8;
    --border: #334155;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --easing: cubic-bezier(0.16, 1, 0.3, 1); /* "Apple" style easing */
}

/* --- 2. GLOBAL RESET & "PRO" DEFAULTS --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased; /* Makes fonts look sharper on Mac */
}

/* Custom "Hacker" Selection Color */
::selection {
    background: var(--accent);
    color: #000;
}

/* Custom Scrollbar (Webkit only) */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* --- 3. TYPOGRAPHY (Responsive) --- */
h1 {
    font-size: clamp(3rem, 8vw, 6rem); /* Auto-scales with screen size */
    line-height: 0.95;
    font-weight: 800;
    letter-spacing: -0.04em; /* Tight tracking looks modern */
    margin-bottom: 30px;
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    letter-spacing: -0.03em;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.mono-text { font-family: var(--font-mono); color: var(--accent); font-size: 0.85rem; letter-spacing: 0.05em; text-transform: uppercase;}
.highlight { color: var(--accent); }
.dot { color: var(--accent); }

/* --- 4. NAVIGATION (Glassmorphism) --- */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 5%;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px); /* The "Frosted Glass" effect */
    border-bottom: 1px solid rgba(51, 65, 85, 0.6);
}

.logo { font-weight: 800; font-size: 1.5rem; letter-spacing: -1px; }

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover { color: var(--text); }
.nav-links .btn-small { color: var(--accent); }

/* --- 5. HERO SECTION --- */
#hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 0 5%;
    position: relative;
    /* Subtle Grid Background Pattern */
    background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

.hero-sub {
    color: var(--text-muted);
    max-width: 500px;
    margin-bottom: 40px;
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Modern Buttons */
.hero-btns { display: flex; gap: 20px; }

.btn-primary {
    background-color: var(--accent);
    color: #000;
    padding: 16px 32px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid var(--accent);
    transition: transform 0.2s var(--easing), box-shadow 0.2s var(--easing);
    display: inline-block;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(255, 184, 0, 0.15);
}

.btn-outline {
    border: 1px solid var(--border);
    color: var(--text);
    padding: 16px 32px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: 0.3s;
    background: transparent;
}

.btn-outline:hover { border-color: var(--text); background: rgba(255,255,255,0.05); }

/* --- 6. WORKSHOPS GRID --- */
#trainings { padding: 120px 5%; }

.section-header { margin-bottom: 80px; }
.pixel-divider { width: 60px; height: 6px; background: var(--accent); margin-top: 20px; }

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 40px;
}

.card {
    background: var(--card-bg);
    padding: 40px;
    border: 1px solid var(--border);
    transition: all 0.4s var(--easing);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card:hover {
    transform: translateY(-10px);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
}

.card-status {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 20px;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.card h3 { margin-bottom: 12px; font-size: 1.5rem; }
.card-desc { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 30px; line-height: 1.6; }

.card-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
}

.btn-card {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 14px 20px;
    width: 100%;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
}

.btn-card:hover { background: var(--text); color: #0F172A; border-color: var(--text); }

/* --- 7. LOADING SCREEN --- */
#loader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #0B1224;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.loader-content { width: 300px; text-align: center; }
.pixel-bar {
    height: 2px;
    background: var(--accent);
    width: 0%;
    margin-bottom: 15px;
    box-shadow: 0 0 15px rgba(255, 184, 0, 0.5);
    transition: width 1.2s cubic-bezier(0.83, 0, 0.17, 1);
}

/* --- 8. ANIMATION UTILITIES (The "Next.js" Feel) --- */
.hidden-element {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s var(--easing), transform 0.8s var(--easing);
}

.show-element {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger delays for grid items */
.delay-100 { transition-delay: 100ms; }
.delay-200 { transition-delay: 200ms; }
.delay-300 { transition-delay: 300ms; }

/* --- 9. MODAL --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 200;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: #111827;
    padding: 50px;
    width: 90%;
    max-width: 480px;
    border: 1px solid var(--border);
    position: relative;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.close-btn { position: absolute; top: 20px; right: 25px; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); transition: 0.2s;}
.close-btn:hover { color: white; }

input {
    width: 100%;
    padding: 16px;
    background: #0F172A;
    border: 1px solid var(--border);
    color: var(--text);
    margin-bottom: 15px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    transition: 0.3s;
}
input:focus { outline: none; border-color: var(--accent); background: #0B1224; }
.full-width { width: 100%; }

/* Mobile Tweaks */
@media (max-width: 768px) {
    h1 { font-size: 2.4rem; }
    #hero { flex-direction: column; justify-content: center; text-align: center; padding-top: 60px;}
    .hero-btns { flex-direction: column; width: 100%; }
    .btn-outline { margin-left: 0; }
    nav { flex-direction: column; align-items: flex-start; gap: 12px; padding: 15px 5%; }
    .nav-links { flex-wrap: wrap; gap: 12px; justify-content: flex-start; }
    .nav-links a { margin-left: 0; }
    .nav-links .btn-small { padding: 10px 14px; }
}

/* --- ARABIC MODE (RTL Support) --- */
body.rtl {
    direction: rtl;
    text-align: right;
    font-family: 'Tajawal', sans-serif;
}

/* Flip Navigation */
body.rtl nav {
    flex-direction: row-reverse; /* Logo moves right, Links move left */
}

body.rtl .nav-links {
    flex-direction: row-reverse; /* Reorders links */
}

body.rtl .nav-links a {
    margin-left: 0;
    margin-right: 30px;
}

body.rtl #lang-toggle {
    margin-left: 0;
    margin-right: 20px;
    font-family: 'Inter', sans-serif; /* Keep English font for button */
}

/* Flip Hero Section alignment */
body.rtl .hero-content {
    align-items: flex-start; /* Ensures content stays aligned correctly */
}

/* Flip Workshop Cards */
body.rtl .card {
    text-align: right;
}

body.rtl .card-status {
    float: right; /* Moves status tag to right */
}

body.rtl .btn-card {
    text-align: left; /* Button arrow points correct way */
}

/* Flip Lists or Flex containers */
body.rtl .hero-btns {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/* --- 10. GALLERY GRID (About Page) --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    padding: 80px 5%;
}

.gallery-item {
    position: relative;
    min-height: 260px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--card-bg);
    border: 1px solid var(--border);
    transition: transform 0.4s var(--easing), box-shadow 0.4s var(--easing), border-color 0.4s var(--easing);
    isolation: isolate;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(0.9);
    transition: transform 0.6s var(--easing), filter 0.4s ease;
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.85) 100%);
    opacity: 0;
    transition: opacity 0.35s var(--easing);
}

.gallery-overlay h3 {
    margin: 0;
    font-size: 1.1rem;
}

.gallery-item:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.45);
}

.gallery-item:hover img {
    transform: scale(1.05);
    filter: saturate(1.05);
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

@media (max-width: 768px) {
    .gallery-overlay { opacity: 1; }
    .gallery-grid { grid-template-columns: 1fr; padding: 60px 5%; }
    .article-grid { grid-template-columns: 1fr; padding: 40px 5%; }
}

/* --- ARTICLES PAGE STYLES --- */

.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 40px;
    padding: 50px 5%;
}

.article-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    transition: 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    min-height: 400px; /* Ensures consistent height */
}

.article-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
}

.article-img {
    height: 200px;
    width: 100%;
    object-fit: cover;
    filter: grayscale(100%);
    transition: 0.3s;
}

.article-card:hover .article-img { filter: grayscale(0%); }

.article-content {
    padding: 30px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.author-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.author-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--border);
    background-position: center;
    background-size: cover;
}

/* --- READING MODAL (The Popup Reader) --- */
#article-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 500;
    overflow-y: auto; /* Allows scrolling inside the modal */
    animation: fadeIn 0.3s ease;
}

.reader-container {
    max-width: 800px;
    margin: 80px auto;
    background: #0F172A;
    padding: 60px;
    border: 1px solid var(--border);
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

/* Typography for the article text */
.article-body {
    font-family: 'Merriweather', serif; /* Easier to read */
    line-height: 1.8;
    color: #ccc;
    font-size: 1.1rem;
    white-space: pre-wrap; /* Preserves paragraphs from Google Sheet */
}

/* Mobile Tweaks */
@media (max-width: 768px) {
    .reader-container { margin: 0; min-height: 100vh; border: none; padding: 30px; }
    .article-grid { grid-template-columns: 1fr; }
}
