/* ============================================
   ARKIVE.SU — Knowledge Ark Initiative
   Dark cosmic theme
   ============================================ */

/* --- Reset & Base --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #090A0F;
  --bg-secondary: #0c0e14;
  --bg-card: #12151C;
  --bg-card-hover: #1a1e29;
  --text-primary: #F0F2F8;
  --text-secondary: #8B94A7;
  --text-muted: #5e6678;
  --accent-gold: #E5A93D;
  --accent-gold-dim: #b5832b;
  --accent-blue: #60a5fa;
  --accent-ice: #93c5fd;
  --border-color: #2A2E3D;
  --border-light: #363b4e;
  --font-serif: 'Space Grotesk', sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 1200px;
  --transition: 0.3s ease;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  padding-top: 80px; /* Crucial: Prevents fixed header from overlapping content */
}

a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-ice);
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

h1 { font-size: 3.5rem; font-weight: 700; }
h2 { font-size: 2.5rem; font-weight: 600; margin-bottom: 1.25rem; }
h3 { font-size: 1.5rem; font-weight: 500; margin-bottom: 0.75rem; }
h4 { font-size: 1.125rem; font-weight: 600; }

p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
  font-size: 1.125rem;
}

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.section {
  padding: 5rem 0;
}

.section-title {
  text-align: center;
  margin-bottom: 3rem;
}

.section-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: var(--accent-gold);
  margin: 1rem auto 0;
}

/* --- Starfield Background --- */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 80% 50%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1.5px 1.5px at 10% 80%, rgba(255,255,255,0.25), transparent),
    radial-gradient(1px 1px at 70% 90%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1.5px 1.5px at 90% 10%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 85% 35%, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

#site-header {
  position: relative;
  z-index: 1000;
}

/* --- Header / Navigation --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 1rem 0;
  background: rgba(9, 10, 15, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(42, 46, 61, 0.5);
  transition: all var(--transition);
}

.header.scrolled {
  padding: 0.6rem 0;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Bring links closer to logo naturally */
  gap: 3rem; /* Elegant spacing without being huge */
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-logo img {
  height: 56px; /* Reduced fixed height to avoid overlap with centered text */
  width: auto;
  max-width: 220px;
  display: block;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color var(--transition);
  position: relative;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent-gold);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent-gold);
  transition: width var(--transition);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

/* --- Language Switcher --- */
.lang-switcher {
  margin-left: auto;
  margin-right: 1.5rem;
}

.lang-select {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.4rem 1.5rem 0.4rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23f0f2f8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  transition: all var(--transition);
}

.lang-select:hover, .lang-select:focus {
  border-color: var(--accent-gold);
  outline: none;
}

.lang-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  margin-left: auto; /* Always push toggle to far right on mobile */
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: all var(--transition);
}

/* --- Hero Section --- */
.hero {
  min-height: calc(100vh - 80px); /* Adjust for body padding */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(96, 165, 250, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(212, 168, 83, 0.05) 0%, transparent 50%);
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.hero h1 .gold {
  color: var(--accent-gold);
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto 2.5rem;
  line-height: 1.8;
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 0.85rem 2rem;
  border-radius: 6px;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-align: center;
}

.btn-primary {
  background: var(--accent-gold);
  color: #090A0F;
  box-shadow: 0 4px 14px rgba(229, 169, 61, 0.15);
}

.btn-primary:hover {
  background: #f0b54d;
  color: #090A0F;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(229, 169, 61, 0.3);
}

.btn-outline {
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  background: transparent;
}

.btn-outline:hover {
  background: rgba(212, 168, 83, 0.1);
  color: var(--accent-gold);
}

.btn-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2.5rem;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card:hover {
  border-color: var(--accent-gold);
  background: var(--bg-card-hover);
  transform: translateY(-6px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

/* --- Grid Layouts --- */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

/* --- Stats Bar --- */
.stats {
  display: flex;
  justify-content: center;
  gap: 4rem;
  padding: 3rem 0;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-gold);
  display: block;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.25rem;
}

/* --- Pillars Section --- */
.pillars .card {
  text-align: center;
}

.pillars .card h3 {
  color: var(--accent-gold);
}

/* --- Steps / How It Works --- */
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  counter-reset: step;
}

.step {
  text-align: center;
  counter-increment: step;
  position: relative;
  padding: 1.5rem 1rem;
}

.step::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--accent-gold);
  color: var(--accent-gold);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 auto 1rem;
}

.step h4 {
  margin-bottom: 0.5rem;
}

.step p {
  font-size: 0.9rem;
}

/* --- Technology Cards --- */
.tech-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2.5rem;
  transition: all var(--transition);
}

.tech-card:hover {
  border-color: var(--accent-gold-dim);
  transform: translateY(-2px);
}

.tech-card h3 {
  color: var(--accent-gold);
  margin-bottom: 0.5rem;
}

.tech-card .tech-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.tech-specs {
  list-style: none;
  padding: 0;
}

.tech-specs li {
  padding: 0.4rem 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.tech-specs li::before {
  content: '\2022';
  color: var(--accent-gold);
  font-weight: bold;
  flex-shrink: 0;
}

/* --- FAQ --- */
.faq-item {
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 0;
}

.faq-question {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--text-primary);
  user-select: none;
}

.faq-question::after {
  content: '+';
  font-size: 1.5rem;
  color: var(--accent-gold);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.faq-item.open .faq-question::after {
  content: '\2212';
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
}

.faq-item.open .faq-answer {
  max-height: 500px;
  padding-top: 1rem;
}

.faq-answer p {
  font-size: 0.95rem;
  line-height: 1.8;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.form-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* --- Newsletter --- */
.newsletter-form {
  display: flex;
  gap: 0.75rem;
  max-width: 480px;
  margin: 0 auto;
}

.newsletter-form .form-input {
  flex: 1;
}

/* --- Footer --- */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 3rem 0 2rem;
  margin-top: 4rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 2rem;
}

.footer-about p {
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.footer h4 {
  color: var(--accent-gold);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-links a:hover {
  color: var(--accent-gold);
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Page Header (inner pages) --- */
.page-header {
  padding: 4rem 0 3rem; /* Adjusted for body top padding */
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(96, 165, 250, 0.06) 0%, transparent 60%);
}

.page-header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 1rem;
}

.page-header p {
  max-width: 600px;
  margin: 0 auto;
  font-size: 1.1rem;
}

/* --- Articles List --- */
.article-list {
  list-style: none;
}

.article-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.article-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 100px;
  font-variant-numeric: tabular-nums;
}

.article-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--text-primary);
}

.article-title:hover {
  color: var(--accent-gold);
}

.article-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* --- Article Page --- */
.article-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.article-content h1 {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

.article-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.article-content h2 {
  margin-top: 2.5rem;
}

.article-content h3 {
  margin-top: 2rem;
}

.article-content ul,
.article-content ol {
  margin: 1rem 0 1rem 1.5rem;
  color: var(--text-secondary);
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-content blockquote {
  border-left: 3px solid var(--accent-gold);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: rgba(212, 168, 83, 0.05);
  font-style: italic;
}

.article-content blockquote p {
  color: var(--text-primary);
}

/* --- Network Members --- */
.member-filters {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.filter-btn {
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(212, 168, 83, 0.08);
}

.member-card {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.member-card .card-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

.badge-knowledge { background: rgba(96, 165, 250, 0.15); color: var(--accent-blue); }
.badge-storage { background: rgba(212, 168, 83, 0.15); color: var(--accent-gold); }
.badge-space { background: rgba(147, 197, 253, 0.15); color: var(--accent-ice); }
.badge-digital { background: rgba(74, 222, 128, 0.15); color: #4ade80; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  h1 { font-size: 2.2rem; }
  h2 { font-size: 1.6rem; }
  .section { padding: 3.5rem 0; }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(9, 10, 15, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 1.5rem 2rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 999;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-toggle {
    display: flex;
  }

  .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }

  .steps {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 0 auto;
  }

  .stats {
    gap: 2rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero {
    padding: 7rem 1.5rem 3rem;
  }

  .newsletter-form {
    flex-direction: column;
  }

  .article-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .card, .tech-card {
    padding: 1.5rem 1.25rem;
  }

  .nav {
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.25rem;
  }

  .nav-logo img {
    height: 40px; /* Mini logo for mobile screens */
    max-width: 180px;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 1.25rem; }
  .nav { padding: 0 1.25rem; }
  .btn { padding: 0.75rem 1.5rem; font-size: 0.9rem; }
}

/* --- Right-to-Left (RTL) Support for Arabic --- */
html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .nav-links {
  flex-direction: row-reverse;
}

html[dir="rtl"] .lang-switcher {
  margin-left: 1.5rem;
  margin-right: auto;
}

html[dir="rtl"] .nav-toggle {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] .lang-select {
  padding: 0.4rem 0.8rem 0.4rem 1.5rem;
  background-position: left 0.5rem center;
}

html[dir="rtl"] .btn-primary {
  box-shadow: 0 4px 14px rgba(229, 169, 61, 0.15); /* Keep shadow same */
}

html[dir="rtl"] .article-content ul,
html[dir="rtl"] .article-content ol {
  margin: 1rem 1.5rem 1rem 0;
}

html[dir="rtl"] .article-content blockquote {
  border-left: none;
  border-right: 3px solid var(--accent-gold);
}
