/* ========================================
   RANKS PAGES - COMPLETE STYLES
   (world-rank.html, ranks.html, asia.html, arab.html, ...)
   ======================================== */

/* ========================================
   1. ROOT VARIABLES & RESET
   ======================================== */

:root {
  --maroon: #5C0A1E;
  --maroon-dark: #420715;
  --maroon-light: #8A1230;
  --ink: #1A1414;
  --paper: #FFFFFF;
  --paper-soft: #FAF7F6;
  --line: #E7DEDC;
  --grey: #6B6260;
  --grey-light: #948B89;
  --gold: #B08A3E;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

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

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

.bg-soft {
  background: var(--paper-soft);
}

/* ========================================
   2. HEADER (منقول من indexcss.css)
   ======================================== */

header {
  position: sticky;
  top: 0;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  width: 100%;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  z-index: 10002;
}

.brand img {
  height: 38px;
  width: 38px;
  object-fit: contain;
}

.brand-name {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 21px;
  color: var(--maroon);
  letter-spacing: -0.01em;
}

/* Desktop Nav */
nav.primary-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

nav.primary-nav a {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 5px;
  position: relative;
  transition: color .15s ease;
}

nav.primary-nav a::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 6px;
  height: 2px;
  background: var(--maroon);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .18s ease;
}

nav.primary-nav a:hover {
  color: var(--maroon);
}

nav.primary-nav a:hover::after {
  transform: scaleX(1);
}

nav.primary-nav a.active {
  color: var(--maroon);
}

nav.primary-nav a.active::after {
  transform: scaleX(1);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 10002;
}

.btn-outline {
  border: 1.5px solid var(--maroon);
  color: var(--maroon);
  padding: 8px 18px;
  border-radius: 5px;
  font-size: 13.5px;
  font-weight: 700;
  transition: background .15s ease, color .15s ease;
}

.btn-outline:hover {
  background: var(--maroon);
  color: #fff;
}

/* Mobile burger button */
.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 10003;
}

.burger span {
  display: block;
  height: 2.5px;
  width: 24px;
  background: var(--maroon);
  border-radius: 2px;
  transition: .2s;
}

.burger.open span:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}

.burger.open span:nth-child(2) {
  opacity: 0;
}

.burger.open span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* Mobile Menu */
@media (max-width: 900px) {
  .burger {
    display: flex;
  }

  .header-right .btn-outline {
    display: none;
  }

  nav.primary-nav {
    visibility: hidden;
    opacity: 0;
    position: fixed;
    top: 76px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 76px);
    background: #ffffff;
    flex-direction: column;
    align-items: stretch;
    padding: 30px 24px;
    gap: 12px;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    overflow-y: auto;
    z-index: 10001;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  }

  nav.primary-nav.open {
    visibility: visible;
    opacity: 1;
  }

  nav.primary-nav a {
    padding: 16px 14px;
    font-size: 17px;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper-soft);
    color: var(--ink);
  }

  nav.primary-nav a:hover {
    color: var(--maroon);
    background: #f4ecea;
  }

  nav.primary-nav a::after {
    display: none;
  }
}

/* ========================================
   3. FOOTER (منقول من indexcss.css)
   ======================================== */

footer {
  background: var(--maroon-dark);
  color: #EFE3E0;
  padding: 56px 0 0;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 36px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  flex-wrap: wrap;
  gap: 28px;
}

.footer-links {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 13.5px;
  font-weight: 600;
  color: #EFE3E0;
  opacity: .85;
  transition: opacity .15s ease;
}

.footer-links a:hover {
  opacity: 1;
}

.footer-social {
  display: flex;
  gap: 12px;
}

.footer-social a {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, border-color .15s ease;
}

.footer-social a:hover {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .5);
}

.footer-social svg {
  width: 16px;
  height: 16px;
  fill: #EFE3E0;
}

.footer-bottom {
  padding: 22px 0 26px;
  text-align: center;
  font-size: 12.5px;
  color: rgba(239, 227, 224, .65);
}

@media (max-width: 600px) {
  .footer-top {
    flex-direction: column;
  }
}

/* ========================================
   4. SECTION HEADERS
   ======================================== */

section {
  padding: 72px 0;
}

.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 36px;
  gap: 24px;
  flex-wrap: wrap;
}

.sec-head h2 {
  font-size: clamp(24px, 2.6vw, 32px);
  color: var(--ink);
}

.sec-head .sub {
  color: var(--grey);
  font-size: 14.5px;
  margin-top: 8px;
  max-width: 520px;
}

.see-all {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--maroon);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
  padding-bottom: 4px;
  border-bottom: 1.5px solid transparent;
  transition: border-color .15s ease;
}

.see-all:hover {
  border-color: var(--maroon);
}

/* ========================================
   5. SUB-NAVIGATION
   ======================================== */

.sub-nav-wrap {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 76px;
  z-index: 9998;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
}

.sub-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

.sub-nav::-webkit-scrollbar {
  display: none;
}

.sub-nav a {
  flex: 0 0 auto;
  scroll-snap-align: start;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--grey);
  background: var(--paper-soft);
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sub-nav a:hover {
  color: var(--maroon);
  border-color: var(--maroon);
  background: #fff;
}

.sub-nav a.active {
  color: #fff;
  background: var(--maroon);
  border-color: var(--maroon);
}

/* ========================================
   6. REGION CARDS
   ======================================== */

.region-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
}

.region-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.region-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 36px -20px rgba(92, 10, 30, 0.2);
  border-color: var(--maroon-light);
}

.region-card .thumb {
  height: 100px;
  background: linear-gradient(135deg, var(--maroon-light), var(--maroon-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: relative;
}

.region-card .thumb .badge {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--maroon);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: 'Inter', sans-serif;
}

.region-card.world-card .thumb {
  background: linear-gradient(135deg, var(--gold), #c9a84c);
  font-size: 16px;
}

.region-card.world-card .thumb .badge {
  background: var(--maroon);
  color: #fff;
}

.region-card .body {
  padding: 16px 20px 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.region-card .body h3 {
  font-size: 15.5px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  margin-bottom: 3px;
  line-height: 1.3;
}

.region-card .body .sub-info {
  font-size: 12.5px;
  color: var(--grey-light);
  margin-bottom: 12px;
}

.region-card .body .btn-card {
  margin-top: auto;
  padding: 10px 0 0;
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--maroon);
  border-top: 1px solid var(--line);
  transition: color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.region-card .body .btn-card:hover {
  color: var(--maroon-dark);
}

.region-card .body .btn-card span {
  display: inline-block;
  transition: transform 0.15s ease;
}

.region-card:hover .body .btn-card span {
  transform: translateX(4px);
}

@media (max-width: 1024px) {
  .region-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .region-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .sub-nav a {
    font-size: 12px;
    padding: 6px 16px;
  }
}

@media (max-width: 480px) {
  .region-grid {
    grid-template-columns: 1fr;
  }
  .hero-ranks {
    padding: 40px 0 30px;
  }
}

/* ========================================
   7. HERO (RANKS PAGE)
   ======================================== */

.hero-ranks {
  background: linear-gradient(180deg, var(--paper-soft) 0%, #fff 100%);
  border-bottom: 1px solid var(--line);
  padding: 60px 0 50px;
}

.hero-ranks .hero-index {
  font-family: 'Source Serif 4', serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: .08em;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-ranks .hero-index .rule {
  width: 34px;
  height: 1px;
  background: var(--gold);
}

.hero-ranks h1 {
  font-size: clamp(28px, 3.8vw, 46px);
  line-height: 1.08;
  color: var(--ink);
  margin-bottom: 16px;
}

.hero-ranks h1 em {
  font-style: normal;
  color: var(--maroon);
}

.hero-ranks p.lede {
  font-size: 17px;
  color: var(--grey);
  max-width: 620px;
  line-height: 1.65;
}

/* ========================================
   8. HERO (RANK DETAIL - world-rank.html)
   ======================================== */

.rank-detail-hero {
  background: linear-gradient(180deg, var(--paper-soft) 0%, #fff 100%);
  border-bottom: 1px solid var(--line);
  padding: 50px 0 40px;
}

.rank-detail-hero .hero-index {
  font-family: 'Source Serif 4', serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: .08em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-detail-hero .hero-index .rule {
  width: 34px;
  height: 1px;
  background: var(--gold);
}

.rank-detail-hero h1 {
  font-size: clamp(28px, 3.6vw, 44px);
  line-height: 1.08;
  color: var(--ink);
  margin-bottom: 8px;
}

.rank-detail-hero h1 em {
  font-style: normal;
  color: var(--maroon);
}

.rank-detail-hero p.lede {
  font-size: 16px;
  color: var(--grey);
  max-width: 620px;
  line-height: 1.65;
}

.rank-detail-hero .stats {
  display: flex;
  gap: 32px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.rank-detail-hero .stats .stat-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.rank-detail-hero .stats .stat-item .num {
  font-family: 'Source Serif 4', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--maroon);
}

.rank-detail-hero .stats .stat-item .label {
  font-size: 14px;
  color: var(--grey-light);
}

/* ========================================
   9. BACK LINK
   ======================================== */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--maroon);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 20px;
  transition: gap 0.15s ease;
}

.back-link:hover {
  gap: 12px;
}

/* ========================================
   10. NEWS GRID (2 columns - )
   ======================================== */

/* ============================================================
   10. NEWS GRID (2 columns - )
   ============================================================ */
.news-grid-ranks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

@media (max-width: 768px) {
  .news-grid-ranks {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   11. NEWS GRID
   ============================================================ */
.news-grid-rank-detail {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 22px;
}

@media (max-width: 768px) {
  .news-grid-rank-detail {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   12. TABLE CONTROLS
   ============================================================ */
.table-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.table-controls .search-box {
  flex: 1;
  min-width: 200px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s ease;
}

.table-controls .search-box:focus {
  outline: none;
  border-color: var(--maroon);
}

.table-controls .select-box {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.table-controls .select-box:focus {
  outline: none;
  border-color: var(--maroon);
}

.table-controls .btn-reset {
  padding: 10px 20px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--grey);
  cursor: pointer;
  transition: all 0.15s ease;
}

.table-controls .btn-reset:hover {
  border-color: var(--maroon);
  color: var(--maroon);
}

/* ============================================================
   13. TABLE SUMMARY
   ============================================================ */
.table-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 12px 0;
  font-size: 13px;
  color: var(--grey);
}

.table-summary strong {
  color: var(--ink);
}

/* ============================================================
   14. RANKING TABLE
   ============================================================ */


.rank-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.rank-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  min-width: 900px;
}

.rank-table thead {
  background: var(--maroon);
  color: #fff;
}

.rank-table thead th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
  background: var(--maroon);
}

.rank-table thead th:hover {
  background: var(--maroon-dark);
}

.rank-table thead th .sort-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.6;
}

.rank-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}

.rank-table tbody tr:hover {
  background: var(--paper-soft);
}

.rank-table tbody td {
  padding: 14px 6px;
  vertical-align: middle;
  background: #fff;
}

.rank-table .rank-num {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--maroon);
  text-align: center;
}

.rank-table .univ-name a {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.15s ease;
  border-bottom: 1px solid transparent;
}

.rank-table .univ-name a:hover {
  color: var(--maroon);
  border-bottom-color: var(--maroon);
}

.rank-table .univ-loc {
  color: var(--grey-light);
  font-size: 13px;
}

.rank-table .metric-cell {
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

.rank-table .loading-row td {
  text-align: center;
  padding: 40px;
  color: var(--grey);
}





/* ============================================================
   STICKY COLUMNS - FIXED WIDTH
   ============================================================ */

.rank-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.rank-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  min-width: 900px;
}


.rank-table td:first-child,
.rank-table th:first-child {
  position: sticky !important;
  left: 0 !important;
  z-index: 10 !important;
  background: #fff !important;
  min-width: 120px !important;
  max-width: 120px !important;
  border-right: 2px solid var(--line);
}

.rank-table td:nth-child(2),
.rank-table th:nth-child(2) {
  position: sticky !important;
  left: 120px !important;
  z-index: 10 !important;
  background: #fff !important;
  min-width: 220px !important;
  max-width: 220px !important;
  border-right: 2px solid var(--line);
}


.rank-table thead th:first-child,
.rank-table thead th:nth-child(2) {
  z-index: 20 !important;
  background: var(--maroon) !important;
}


.rank-table tbody tr:hover td:first-child,
.rank-table tbody tr:hover td:nth-child(2) {
  background: var(--paper-soft) !important;
}


.rank-table td:not(:first-child):not(:nth-child(2)),
.rank-table th:not(:first-child):not(:nth-child(2)) {
  background: #fff;
}

.rank-table thead th:not(:first-child):not(:nth-child(2)) {
  background: var(--maroon);
}



/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--maroon);
  color: var(--maroon);
}

.pagination button.active {
  background: var(--maroon);
  border-color: var(--maroon);
  color: #fff;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}




/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .rank-table td:first-child,
  .rank-table th:first-child {
    min-width: 80px !important;
    max-width: 80px !important;
  }

  .rank-table td:nth-child(2),
  .rank-table th:nth-child(2) {
    left: 80px !important;
    min-width: 160px !important;
    max-width: 160px !important;
  }
}

@media (max-width: 480px) {
  .rank-table td:first-child,
  .rank-table th:first-child {
    min-width: 70px !important;
    max-width: 70px !important;
  }

  .rank-table td:nth-child(2),
  .rank-table th:nth-child(2) {
    left: 70px !important;
    min-width: 140px !important;
    max-width: 140px !important;
  }
}





 ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .select-wrapper {
    min-width: 160px;
    max-width: 100%;
  }

  .select-wrapper .select-box {
    padding: 8px 14px;
    padding-right: 36px;
    font-size: 12.5px;
  }

  .select-wrapper .select-search {
    font-size: 12px;
    padding: 8px 12px;
  }
}

@media (max-width: 480px) {
  .select-wrapper {
    min-width: 130px;
  }

  .select-wrapper .select-box {
    padding: 6px 12px;
    padding-right: 32px;
    font-size: 12px;
  }

  .select-wrapper .select-search {
    font-size: 11px;
    padding: 6px 10px;
  }
}

/* ============================================================
   TABLE TEXT - PREVENT SELECTION ============================================================ */
.rank-table-wrap {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.rank-table-wrap .univ-name a {
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}


.sub-nav {
  display: flex;
  overflow-x: auto;          
  white-space: nowrap;       
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;   
  gap: 8px;
  padding: 8px 16px;
}

.sub-nav a {
  flex-shrink: 0;         
  padding: 8px 16px;
  text-decoration: none;
  color: #333;
  border-radius: 20px;
  transition: background 0.3s;
}

.sub-nav a.active {
  background: #5C0A1E;
  color: #fff;
}

