/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #e9ecef;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --radius: 10px;
  --max-width: 720px;
  --header-height: 60px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg: #1a1b26;
  --surface: #24283b;
  --text: #c0caf5;
  --text-muted: #9aa5ce;
  --border: #414868;
  --accent: #7aa2f7;
  --accent-hover: #bb9af7;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.6);
}

html {
  font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

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

/* ===== Header / Nav ===== */
.site-header {
  background: var(--surface);
  border-block-end: 1px solid var(--border);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

[data-theme="dark"] .site-header {
  background: rgba(36, 40, 59, 0.95);
  border-block-end: 1px solid rgba(65, 72, 104, 0.8);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  white-space: nowrap;
}

.nav-logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}

.lang-toggle {
  font-weight: 600;
  margin-inline-start: 0.25rem;
  padding-inline-start: 0.75rem;
  border-inline-start: 1px solid var(--border);
}

/* ===== RSS Link ===== */
.rss-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  margin-inline-start: 0.25rem;
}

.rss-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(122, 162, 247, 0.1);
  text-decoration: none;
}

[data-theme="dark"] .rss-link:hover {
  background: rgba(122, 162, 247, 0.15);
}

.rss-icon {
  width: 18px;
  height: 18px;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s, border-color 0.2s;
  margin-inline-start: 0.25rem;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-icon {
  width: 18px;
  height: 18px;
}

.theme-moon {
  display: none;
}

.theme-sun {
  display: block;
}

[data-theme="dark"] .theme-sun {
  display: none;
}

[data-theme="dark"] .theme-moon {
  display: block;
}

/* ===== Main Layout ===== */
.main {
  max-width: 100%;
  margin: 0;
  padding: 0;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 0.5rem 1rem 0.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-block-end: 0.25rem;
  line-height: 1.1;
}

.hero p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-block-end: 0;
  max-width: 520px;
  margin-inline: auto;
}

.discovery-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-block-end: 1rem;
  box-shadow: var(--shadow-md);
}

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

.stats {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.stats span {
  margin: 0 0.3rem;
}

/* ===== Discovery Container ===== */
.discovery-container {
  max-width: 100%;
  margin: 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--header-height) - 30px);
  overflow: hidden;
}

.discovery-post {
  flex: 1;
  margin: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  height: 100%;
}

.discovery-post .post {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  padding: 0;
  height: 100%;
}

.discovery-navigation-top {
  display: flex;
  justify-content: flex-start;
  padding: 0.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.nav-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.nav-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.nav-icon {
  font-size: 1rem;
  font-weight: bold;
}


/* ===== Post Header (combined meta + title) ===== */
.post-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  min-height: 44px;
}

.post-header .post-site {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.75rem;
  white-space: nowrap;
}

.post-header .post-site:hover {
  color: var(--accent);
}

.post-header .post-date {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  background: var(--bg);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.post-header .external-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.25rem;
  border-radius: 4px;
  transition: background 0.2s;
  flex-shrink: 0;
  margin-inline-start: auto;
}

.post-header .external-link:hover {
  background: var(--accent);
  color: white;
}

.post-header .discovery-indicator {
  background: var(--accent);
  color: white;
  padding: 0.15rem 0.3rem;
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: help;
  flex-shrink: 0;
}

.post-title-inline {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
  flex: 1 1 0;
  min-width: 0;
  margin-inline-end: auto;
}

.post-title-inline a {
  color: var(--text);
  text-decoration: none;
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-title-inline a:hover {
  color: var(--accent);
}

/* ===== Iframe + Actions ===== */
.iframe-container {
  position: relative;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: white;
}

[data-theme="dark"] .iframe-container {
  background: var(--surface);
}

.iframe-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.notice-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

.notice-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.post-actions .read-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--accent);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.75rem;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.post-actions .read-more-btn:hover {
  background: var(--accent-hover);
  color: white;
  transform: translateY(-1px);
}

.close-actions {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  margin-inline-start: auto;
}

.close-actions:hover {
  color: var(--text);
  background: var(--bg);
}

.posts {
  margin-block: 1.5rem;
}

.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-block-end: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.15s;
}

.post:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.post-meta {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 1rem;
  margin-block-end: 0;
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.post-site {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.75rem;
}

.post-site:hover {
  color: var(--accent);
}

.post-date {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  background: var(--bg);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
}

.post-title {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.4;
  margin-block-end: 0.5rem;
}

.post-title a {
  color: var(--text);
}

.post-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-summary {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
  flex: 1;
  margin-block-end: 1rem;
}

.discovery-post .post-summary {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
  max-height: none;
}

/* ===== Discovery Posts ===== */
.post-discovery {
  border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(37, 99, 235, 0.02) 100%);
}

.discovery-indicator {
  background: var(--accent);
  color: white;
  padding: 0.15rem 0.3rem;
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  margin-inline-start: 0.5rem;
  cursor: help;
}

[data-theme="dark"] .post-discovery {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(88, 166, 255, 0.05) 100%);
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 1rem;
}


/* ===== About ===== */
.about {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.about h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-block-end: 1.25rem;
}

.about h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-block: 1.5rem 0.5rem;
}

.about p {
  margin-block-end: 1rem;
  line-height: 1.8;
  color: var(--text-muted);
}

.about p strong {
  color: var(--text);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-block-start: 1.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ===== Footer ===== */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.25rem 1rem;
  border-block-start: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0;
}

[data-theme="dark"] .site-footer {
  background: rgba(36, 40, 59, 0.95);
  border-block-start: 1px solid rgba(65, 72, 104, 0.8);
}

.site-footer p {
  margin-block-end: 0;
}

.github-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  transition: color 0.2s;
}

.github-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.github-icon {
  width: 16px;
  height: 16px;
  color: currentColor;
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 768px) {
  :root {
    --max-width: 100%;
  }

  .main {
    padding: 0;
  }

  .hero {
    padding: 1.5rem 0;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .post {
    padding: 1.25rem;
  }

  .discovery-navigation-top {
    padding: 0.5rem;
  }

  .nav-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .discovery-container {
    height: calc(100dvh - var(--header-height) - 28px);
  }

  .post-actions {
    padding: 0.3rem 0.5rem;
    gap: 0.35rem;
  }

  .notice-text {
    font-size: 0.7rem;
  }

  .post-actions .read-more-btn {
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
  }

  .post-title-inline {
    font-size: 0.9rem;
    min-width: 0;
  }

  .post-title-inline a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .close-actions {
    font-size: 0.8rem;
    padding: 0.1rem 0.3rem;
  }
}

/* ===== Responsive: Phone ===== */
@media (max-width: 480px) {
  .nav {
    flex-wrap: wrap;
    height: auto;
    padding: 0.5rem 0.75rem;
    gap: 0.35rem;
  }

  .nav-logo {
    font-size: 1rem;
  }

  .logo-icon {
    width: 24px;
    height: 24px;
  }

  .nav-links {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding-block-start: 0.35rem;
    border-block-start: 1px solid var(--border);
  }

  .nav-links a {
    font-size: 0.75rem;
    padding: 0.25rem 0.4rem;
  }

  .lang-toggle {
    border-inline-start: none;
    padding-inline-start: 0;
    margin-inline-start: 0;
  }

  .theme-toggle {
    margin-inline-start: 0;
    width: 30px;
    height: 30px;
  }

  .site-header {
    height: auto;
  }

  .hero h1 {
    font-size: 1.35rem;
  }

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

  .post {
    padding: 1rem;
  }

  .post-title {
    font-size: 1.05rem;
  }

  .post-header {
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
  }

  .post-header .post-date {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
  }

  .post-title-inline {
    font-size: 0.85rem;
    min-width: 0;
  }

  .post-title-inline a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50vw;
  }

  .discovery-container {
    padding: 0;
    height: calc(100dvh - 110px);
  }

  .discovery-navigation-top {
    padding: 0.25rem;
  }

  .nav-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }

  .nav-text {
    display: none;
  }

  .post-actions {
    padding: 0.2rem 0.35rem;
    gap: 0.25rem;
  }

  .notice-text {
    display: none;
  }

  .post-actions .read-more-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
  }

  .close-actions {
    font-size: 0.75rem;
    padding: 0.1rem 0.25rem;
  }

  .about {
    padding: 1.25rem;
  }

  .about h1 {
    font-size: 1.3rem;
  }

  .about h2 {
    font-size: 1rem;
  }

  .site-footer {
    padding: 0.35rem 0.5rem;
    font-size: 0.7rem;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
}
