/* =========================================================
   Academic UI — "Aurora Scholar" (Premium / Light / Calm) v1
   ---------------------------------------------------------
   Goals:
   - Calm, elegant look with light pastel accents
   - No background banding/repeat on long pages (html fixed)
   - Fully responsive (desktop/tablet/mobile)
   - Better typography + spacing + cards + navigation
   - Book covers NOT cropped (contain)
   - Book details layout: cover balanced + info roomy
   - Accessible focus states + reduced motion support
   ========================================================= */

/* -------------------- Design Tokens -------------------- */
:root{
  color-scheme: light;

  /* Base paper */
  --bg0: #f7f7fb;
  --bg1: #ffffff;

  /* Surfaces */
  --surface: #ffffff;
  --surface2: rgba(255,255,255,.78);
  --surface3: rgba(255,255,255,.62);

  /* Ink */
  --ink: #0f172a;
  --muted: #334155;
  --muted2: #64748b;

  /* Accents (soft academic) */
  --accent: #2b5bd7;
  --accent2:#1f4dbb;

  /* Pastel aurora tints */
  --auraBlue:  rgba(43,91,215,.12);
  --auraMint:  rgba(16,185,129,.10);
  --auraViolet:rgba(139,92,246,.10);
  --auraRose:  rgba(244,63,94,.08);

  /* Lines */
  --line:  rgba(15,23,42,.10);
  --line2: rgba(15,23,42,.14);

  /* Shadows */
  --shadow1: 0 18px 42px rgba(15,23,42,.10);
  --shadow2: 0 10px 26px rgba(15,23,42,.08);
  --shadow3: 0 6px 16px rgba(15,23,42,.07);

  /* Radius */
  --r12: 12px;
  --r16: 16px;
  --r22: 22px;

  /* Layout */
  --container: 1140px;

  /* Typography */
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", Times, serif;

  /* Focus ring */
  --focus: 0 0 0 4px rgba(43,91,215,.18);

  /* Smoothness */
  --ease: cubic-bezier(.2,.8,.2,1);
}

/* -------------------- Reset -------------------- */
*{ box-sizing: border-box; }
html, body{ height:100%; min-height:100%; }
html{ color-scheme: light; }
body{
  margin:0;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Form controls (prevent mobile dark UI) */
input, select, textarea, button{
  color: var(--ink);
  background-color: #ffffff;
  border-color: rgba(15,23,42,.12);
  color-scheme: light;
}
select, button{ -webkit-appearance: none; appearance: none; }

img{ max-width:100%; display:block; }
a{ color: var(--accent2); text-decoration: none; }
a:hover{ text-decoration: underline; text-underline-offset: 3px; }

:focus{ outline: none; }
:focus-visible{ box-shadow: var(--focus); border-radius: 14px; }

@media (prefers-reduced-motion: reduce){
  *{ animation:none !important; transition:none !important; scroll-behavior:auto !important; }
}

/* -------------------- Background (no repeat/banding) -------------------- */
html{
  background-color: var(--bg0);
  background-image:
    radial-gradient(1200px 820px at 10% -10%, var(--auraViolet), transparent 60%),
    radial-gradient(980px 720px at 92% 0%,  var(--auraMint),   transparent 58%),
    radial-gradient(900px 620px at 18% 112%, var(--auraBlue),  transparent 60%),
    radial-gradient(760px 520px at 92% 112%, var(--auraRose),  transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 62%, var(--bg0));
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: auto;
}

body{ background: transparent; }

/* -------------------- Layout Shell -------------------- */
.page{
  min-height:100vh;
  display:flex;
  flex-direction:column;
  background: transparent;
}

.main{
  flex:1 0 auto;
  padding: 22px 0 44px;
  background: transparent;
}

.footer{
  flex:0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--surface3);
  backdrop-filter: blur(12px);
}

.container{
  width: min(var(--container), calc(100% - 44px));
  margin: 0 auto;
}

/* Skip link */
.skip{
  position:absolute;
  left:-999px;
  top: 12px;
  background: var(--surface);
  border: 1px solid var(--line2);
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: var(--shadow3);
  z-index: 9999;
}
.skip:focus{ left: 12px; }

/* -------------------- Topbar / Nav -------------------- */
.topbar{
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(15,23,42,.08);
  background: rgba(247,247,251,.72);
  backdrop-filter: blur(14px);
}

.bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
  padding: 14px 0;
  flex-wrap: wrap;
}

.brand{ min-width: 0; }
.brand-link{ color: inherit; text-decoration:none; display:block; }
.brand-title{
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: .15px;
  line-height: 1.18;
}
.brand-sub{
  margin-top: 3px;
  color: var(--muted2);
  font-size: 13px;
  max-width: 68vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav{
  display:flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content:flex-end;
  align-items:center;
}

.nav-link{
  display:inline-flex;
  align-items:center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: .05px;
  text-decoration:none;
  transition: background .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease);
}

.nav-link:hover{
  background: rgba(255,255,255,.62);
  border-color: rgba(15,23,42,.10);
  color: rgba(30,41,59,.96);
  text-decoration:none;
}

.nav-link.active{
  color: var(--accent2);
  background: rgba(43,91,215,.10);
  border-color: rgba(43,91,215,.26);
  position: relative;
}

.nav-link.active::after{
  content:"";
  position:absolute;
  left: 16px;
  right: 16px;
  bottom: 6px;
  height: 2px;
  border-radius: 99px;
  background: rgba(43,91,215,.42);
  opacity: .95;
}

/* -------------------- Cards -------------------- */
.card{
  position: relative;
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border: 1px solid rgba(15,23,42,.10);
  border-radius: var(--r22);
  box-shadow: var(--shadow1);
  overflow:hidden;
}

/* Elegant aurora edge highlight */
.card::before{
  content:"";
  position:absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg,
    rgba(43,91,215,0),
    rgba(43,91,215,.30),
    rgba(16,185,129,.24),
    rgba(139,92,246,.22),
    rgba(43,91,215,0)
  );
  opacity: .95;
}

/* -------------------- Hero -------------------- */
.hero{ padding: 26px 0 14px; }

.hero-grid{
  display:grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
}

.hero-main{ padding: 24px 22px; }
.hero-side{ padding: 18px 18px; display:flex; flex-direction:column; gap: 12px; }

.kicker{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: .22px;
  color: var(--muted2);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(15,23,42,.10);
  padding: 7px 12px;
  border-radius: 999px;
  box-shadow: 0 10px 22px rgba(15,23,42,.04);
}

.hero-top{
  display:flex;
  gap: 16px;
  align-items:flex-start;
  justify-content:space-between;
  flex-wrap:wrap;
  margin-top: 10px;
}
.hero-top-text{ flex: 1 1 360px; min-width: 240px; }
.hero-top-img{ flex: 0 0 180px; width:180px; max-width:100%; }

/* Hero portrait should fill its frame (do not affect book covers) */
.hero-top-img .cover img{
  object-fit: cover;
  object-position: center;
}

.h1{
  margin: 12px 0 10px;
  font-family: var(--serif);
  font-size: 44px;
  line-height: 1.06;
  letter-spacing: .18px;
}

.lede{
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.82;
  max-width: 82ch;
}

.actions{
  margin-top: 18px;
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* -------------------- Buttons -------------------- */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,.12);
  background: rgba(255,255,255,.86);
  color: var(--ink);
  font-weight: 900;
  font-size: 14px;
  text-decoration:none;
  transition: transform .14s var(--ease), box-shadow .14s var(--ease), background .14s var(--ease), border-color .14s var(--ease);
}
.btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(15,23,42,.10);
  background: rgba(255,255,255,.96);
  text-decoration:none;
}

.btn.primary{
  color: var(--accent2);
  border-color: rgba(43,91,215,.26);
  background: linear-gradient(180deg, rgba(43,91,215,.16), rgba(43,91,215,.06));
}
.btn.primary:hover{
  box-shadow: 0 18px 36px rgba(43,91,215,.16);
  border-color: rgba(43,91,215,.38);
}

.btn.ghost{
  background: transparent;
  border-color: rgba(15,23,42,.12);
}
.btn.ghost:hover{ background: rgba(255,255,255,.70); }

/* -------------------- Meta Panel -------------------- */
.meta{ display:grid; gap: 10px; }

.meta-item{
  padding: 12px 12px;
  border-radius: var(--r16);
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.68);
  box-shadow: 0 10px 22px rgba(15,23,42,.04);
}

.meta-label{
  margin:0 0 6px;
  color: var(--muted2);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .2px;
}

.meta-value{
  margin:0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.58;
}

/* -------------------- Page Head -------------------- */
.page-head{ padding: 18px 0 12px; }

.page-title{
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.16;
  letter-spacing: .15px;
}

.page-sub{
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.78;
  max-width: 88ch;
}

/* -------------------- Sections / Features -------------------- */
.section{ padding: 14px 0 22px; }

.section h2{
  margin: 0 0 10px;
  font-size: 18px;
  letter-spacing: .2px;
}

.grid3{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.feature{ padding: 18px 18px; }

.feature h3{
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 950;
  letter-spacing: .15px;
}

.feature p{
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.74;
}

/* -------------------- Lists / Items -------------------- */
.list{
  display:grid;
  gap: 12px;
  margin: 14px 0 22px;
}

.item{ padding: 18px 18px; }

.item-title{
  margin:0 0 6px;
  font-size: 16px;
  font-weight: 950;
  line-height: 1.38;
}

.item-meta{
  margin:0 0 10px;
  color: var(--muted2);
  font-size: 13px;
  font-weight: 800;
}

.item p{
  margin:0;
  color: var(--muted);
  line-height: 1.82;
  font-size: 14px;
}

/* -------------------- Badges -------------------- */
.badges{
  margin-top: 10px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.badge{
  font-size: 12px;
  font-weight: 900;
  color: rgba(15,23,42,.78);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(15,23,42,.10);
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(15,23,42,.03);
}

/* -------------------- Divider -------------------- */
.hr{
  height:1px;
  background: rgba(15,23,42,.10);
  margin: 18px 0;
}

/* -------------------- Cover / Portrait -------------------- */
.cover{
  width: 180px;
  height: 228px;
  border-radius: 18px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.76);
  overflow:hidden;
  display:grid;
  place-items:center;
  box-shadow: 0 12px 26px rgba(15,23,42,.07);
}

/* IMPORTANT: do NOT crop covers */
.cover img{
  width:100%;
  height:100%;
  object-fit: contain;
  object-position: center;
  display:block;
  background: transparent;
}

.cover .ph{
  color: var(--muted2);
  font-size: 13px;
  padding: 10px;
  text-align:center;
}

/* -------------------- Books Grid -------------------- */
.book-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.book-card{
  display:grid;
  grid-template-columns: 132px 1fr;
  gap: 14px;
  padding: 16px 16px;
  align-items:start;
}

.book-card .cover{
  width: 132px;
  height: 176px;
  border-radius: 16px;
}

.book-card .cover img{
  object-fit: contain;
  object-position: center;
  background: transparent;
}

/* -------------------- Book Details (UPDATED) --------------------
   ضع class="book-detail" على الكونتينر الذي يجمع الغلاف + معلومات الكتاب
   وضع معلومات الكتاب داخل عنصر class="book-info" */
.book-detail{
  display:grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items:start;
  padding: 18px 18px;
}

/* أصغر من السابق (كان 220x310) */
.book-detail .cover{
  width: 180px;
  height: 252px;
  border-radius: 18px;
}

/* حزام أمان: إذا صورة الديتيلز ليست داخل .cover أو لها كلاس مختلف */
.book-detail img.book-cover,
.book-detail img.cover,
.book-detail img.book-cover-img,
.book-detail img.book-cover-image,
.book-detail .book-cover img,
.book-detail .book-cover-wrap img{
  width: 100%;
  max-width: 180px;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
  display:block;
}

.book-detail .book-info{
  min-width: 0; /* يسمح للنص أن يلتف بدل ما "ينكبس" */
}

.book-detail .book-info .item-title{
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 8px;
}

.book-detail .book-info .item-meta{
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted2);
  font-weight: 850;
}

.book-detail .book-info .badges{
  margin-top: 8px;
}

.book-detail .rich{
  margin-top: 12px;
}

/* -------------------- Rich content / Prose -------------------- */
.rich{
  color: var(--muted);
  line-height: 1.95;
  font-size: 14px;
  overflow-wrap: anywhere;
  word-break: normal;
}
.rich > *:first-child{ margin-top: 0; }
.rich > *:last-child{ margin-bottom: 0; }
.rich p{ margin: 10px 0; }
.rich ul, .rich ol{ margin: 10px 0 10px 18px; }
.rich li{ margin: 6px 0; }

.rich h2, .rich h3{
  color: var(--ink);
  font-family: var(--serif);
  letter-spacing: .12px;
  margin: 16px 0 10px;
}

.rich blockquote{
  margin: 14px 0;
  padding: 12px 14px;
  background: rgba(255,255,255,.70);
  border: 1px solid rgba(43,91,215,.18);
  border-left: 4px solid rgba(43,91,215,.36);
  border-radius: var(--r16);
  box-shadow: 0 10px 18px rgba(15,23,42,.04);
}

.rich a{ word-break: break-word; }

/* -------------------- Footer -------------------- */
.footer-inner{ padding: 18px 0; }

.footer-line{
  display:flex;
  flex-wrap:wrap;
  gap: 10px 14px;
  align-items:center;
  justify-content:space-between;
}

.footer small{ color: var(--muted2); font-weight: 800; }

/* -------------------- Responsive -------------------- */
@media (max-width: 980px){
  .hero-grid{ grid-template-columns: 1fr; }
  .grid3{ grid-template-columns: 1fr; }
  .book-grid{ grid-template-columns: 1fr; }
  .brand-sub{ max-width: 92vw; }
  .hero-top-img{ width: 100%; flex: 1 1 240px; }

  /* only the hero portrait should become full width */
  .hero-top-img .cover{ width: 100%; height: 280px; }

  /* detail: أصغر */
  .book-detail{
    grid-template-columns: 170px minmax(0, 1fr);
  }
  .book-detail .cover{
    width: 170px;
    height: 238px;
  }
  .book-detail img.book-cover,
  .book-detail img.cover,
  .book-detail img.book-cover-img,
  .book-detail img.book-cover-image,
  .book-detail .book-cover img,
  .book-detail .book-cover-wrap img{
    max-width: 170px;
  }
}

@media (max-width: 720px){
  /* detail stacks */
  .book-detail{
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .book-detail .cover{
    width: 160px;
    height: 224px;
    margin: 0 auto;
  }
  .book-detail img.book-cover,
  .book-detail img.cover,
  .book-detail img.book-cover-img,
  .book-detail img.book-cover-image,
  .book-detail .book-cover img,
  .book-detail .book-cover-wrap img{
    max-width: 160px;
  }
}

@media (max-width: 560px){
  .container{ width: min(var(--container), calc(100% - 32px)); }
  .h1{ font-size: 34px; }
  .hero-main{ padding: 18px 16px; }
  .hero-side{ padding: 16px 14px; }
  .btn{ width: 100%; justify-content:center; }

  .book-card{ grid-template-columns: 1fr; }
  .book-card .cover{
    width: 170px;
    height: 230px;
    margin: 0 auto 10px;
  }

  .book-detail{
    padding: 16px 14px;
  }
  .book-detail .cover{
    width: 150px;
    height: 210px;
  }
  .book-detail img.book-cover,
  .book-detail img.cover,
  .book-detail img.book-cover-img,
  .book-detail img.book-cover-image,
  .book-detail .book-cover img,
  .book-detail .book-cover-wrap img{
    max-width: 150px;
  }
}

/* Improve tap targets */
@media (pointer: coarse){
  .nav-link{ padding: 10px 14px; }
  .btn{ padding: 11px 14px; }
}

/* -------------------- Print (clean academic) -------------------- */
@media print{
  html{ background: #fff !important; background-image: none !important; }
  body{ color:#000 !important; }
  .topbar{ position: static !important; background: #fff !important; backdrop-filter:none !important; }
  .card{ box-shadow:none !important; }
  .btn, .nav{ display:none !important; }
  a{ color:#000 !important; text-decoration: underline !important; }
}
