@import url('https://fonts.googleapis.com/css2?family=Aref+Ruqaa:wght@400;700&family=Tajawal:wght@400;500;700;900&display=swap');

:root {
  --paper: #FFFFFF;
  --paper-raised: #FFFFFF;
  --ink: #0B0F14;
  --ink-soft: #55606B;
  --line: #DCE4EC;
  --gold: #0EA5E9;
  --gold-deep: #0284C7;
  --teal: #0EA5E9;
  --teal-soft: #E6F5FD;
  --science: #0EA5E9;
  --science-soft: #E6F5FD;
  --literary: #0B0F14;
  --literary-soft: #EEF1F4;
  --danger: #B3261E;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .display {
  font-family: 'Aref Ruqaa', serif;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; }

/* ============ Texture: subtle paper grain via layered gradient ============ */
body {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(14,165,233,0.06), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(11,15,20,0.04), transparent 45%);
}

/* ============ Nav ============ */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 2px solid var(--line);
  background: var(--paper-raised);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Aref Ruqaa', serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

.brand-mark {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-weight: 500;
  color: var(--ink-soft);
}

.nav-links a:hover { color: var(--ink); }

.nav-auth-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-cta {
  background: var(--gold);
  color: var(--paper-raised) !important;
  padding: 9px 20px;
  border-radius: 999px;
  font-weight: 700;
}

.nav-profile-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink) !important;
}

.mini-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

/* ============ Layout ============ */
main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ============ Hero ============ */
.hero {
  text-align: center;
  padding: 28px 10px 40px;
}

.hero .display {
  font-size: 38px;
  margin-bottom: 14px;
}

.hero p {
  color: var(--ink-soft);
  font-size: 17px;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.9;
}

/* ============ Section headers ============ */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 44px 0 18px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--ink);
}

.section-head h2 {
  font-size: 24px;
}

.section-head .count {
  color: var(--ink-soft);
  font-size: 14px;
  font-family: 'Tajawal', sans-serif;
}

/* ============ Bulletin board (Announcements) ============ */
.board {
  background: #EAF6FD;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pin-note {
  background: var(--paper-raised);
  border-radius: 4px;
  padding: 18px 20px;
  box-shadow: 0 3px 8px rgba(30, 36, 48, 0.08);
  position: relative;
}

.pin-note::before {
  content: "📌";
  position: absolute;
  top: -12px;
  right: 18px;
  font-size: 20px;
}

.pin-note h3 {
  font-size: 19px;
  margin-bottom: 8px;
  color: var(--teal);
}

.pin-note .content {
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink);
}

.pin-note .meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 30px 10px;
  font-size: 15px;
}

/* ============ Composer ============ */
.composer {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 22px;
}

.composer textarea {
  width: 100%;
  border: none;
  resize: none;
  font-family: 'Tajawal', sans-serif;
  font-size: 15px;
  min-height: 60px;
  outline: none;
  background: transparent;
  color: var(--ink);
}

.composer input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: 'Tajawal', sans-serif;
  font-size: 15px;
  outline: none;
  background: transparent;
  color: var(--ink);
  margin-bottom: 10px;
}

.composer input[type="file"] {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.announcement-image {
  width: 100%;
  border-radius: 6px;
  margin: 10px 0;
  display: block;
}

.admin-badge {
  display: inline-block;
  background: var(--teal, #0EA5E9);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-right: 6px;
  vertical-align: middle;
}

.delete-btn {
  background: none;
  border: none;
  color: #d33;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  margin-right: 8px;
}

.delete-btn:hover {
  text-decoration: underline;
}

.report-btn {
  background: none;
  border: none;
  color: #b8860b;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  margin-right: 8px;
}

.report-btn:hover {
  text-decoration: underline;
}

.avatar-upload-wrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.avatar-edit-btn {
  position: absolute;
  bottom: -2px;
  left: -2px;
  background: var(--teal, #0EA5E9);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  border: 2px solid #fff;
}

.composer-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.composer-locked {
  text-align: center;
  padding: 18px;
  background: var(--science-soft);
  border-radius: var(--radius);
  margin-bottom: 22px;
  color: var(--science);
  font-weight: 500;
}

.composer-locked a { text-decoration: underline; font-weight: 700; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-family: 'Tajawal', sans-serif;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

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

.btn-primary { background: var(--gold); color: white; }
.btn-primary:hover { background: var(--gold-deep); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--ink);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  padding: 6px 10px;
  font-size: 13px;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  padding: 6px 10px;
  font-size: 13px;
}

.btn-block { width: 100%; justify-content: center; }

/* ============ Post feed ============ */
.post {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.post:last-child { border-bottom: none; }

.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  flex-shrink: 0;
}

.post-author {
  display: flex;
  flex-direction: column;
}

.post-author .name {
  font-weight: 700;
  font-size: 15px;
}

.post-author .name a:hover, .comment-bubble .cname a:hover {
  text-decoration: underline;
}

.post-author .sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}

.track-badge {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 700;
}

.badge-science { background: var(--science-soft); color: var(--science); }
.badge-literary { background: var(--literary-soft); color: var(--literary); }

.post-body {
  font-size: 15.5px;
  line-height: 1.85;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.post-actions button {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: 'Tajawal', sans-serif;
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.post-actions button:hover { color: var(--teal); }

/* ============ Comments ============ */
.comments {
  margin-top: 14px;
  padding-right: 20px;
  border-right: 2px solid var(--line);
  display: none;
}

.comments.open { display: block; }

.comment {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.comment .avatar {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

.comment-bubble {
  background: var(--paper);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  flex: 1;
}

.comment-bubble .cname {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--teal);
  display: block;
  margin-bottom: 2px;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.comment-form input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: 'Tajawal', sans-serif;
  font-size: 13.5px;
  background: var(--paper-raised);
  outline: none;
}

.comment-form input:focus { border-color: var(--gold); }

/* ============ Forms (register / profile) ============ */
.form-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 26px;
  max-width: 440px;
  margin: 20px auto;
}

.form-card h1 {
  text-align: center;
  font-size: 28px;
  margin-bottom: 6px;
}

.form-sub {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 26px;
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-family: 'Tajawal', sans-serif;
  font-size: 15px;
  background: var(--paper);
  outline: none;
  color: var(--ink);
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold);
}

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.form-error {
  background: #FBEAE9;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: none;
}

.form-error.show { display: block; }

/* ============ Profile page ============ */
.profile-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 26px 0;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 8px;
}

.profile-header .avatar {
  width: 76px;
  height: 76px;
  font-size: 30px;
}

.profile-header .name { font-size: 24px; font-weight: 700; }

.profile-header .sub {
  color: var(--ink-soft);
  font-size: 13.5px;
  margin-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.profile-actions { margin-right: auto; }

.bio-box {
  background: var(--teal-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14.5px;
  color: var(--ink);
  margin: 16px 0 30px;
  line-height: 1.8;
}

.bio-box.empty { color: var(--ink-soft); font-style: normal; }

/* ============ Footer ============ */
footer {
  text-align: center;
  padding: 26px;
  color: var(--ink-soft);
  font-size: 13px;
  border-top: 1px solid var(--line);
}

/* ============ Responsive ============ */
@media (max-width: 560px) {
  .hero .display { font-size: 30px; }
  .nav-links { gap: 12px; }
  .site-nav { padding: 14px 16px; }
  .field-row { flex-direction: column; gap: 0; }
}

/* ============ Accessibility ============ */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
