/* ══════════════════════════════════════════════
   Assurance Mbula — Library / Books
   Shared design system with main portfolio
   ══════════════════════════════════════════════ */

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

/* ── Theme System (mirrors main portfolio) ──── */
:root,[data-theme="dark"]{
  --bg-primary:#080d1a;
  --bg-secondary:#0f1729;
  --bg-tertiary:#162033;
  --bg-glass:rgba(15,23,41,0.65);
  --bg-glass-strong:rgba(15,23,41,0.85);
  --text-primary:#e2e8f0;
  --text-secondary:#94a3b8;
  --text-dim:#64748b;
  --accent:#64ffda;
  --accent-rgb:100,255,218;
  --accent-secondary:#818cf8;
  --accent-secondary-rgb:129,140,248;
  --heading:#f1f5f9;
  --border:rgba(100,255,218,0.1);
  --border-strong:rgba(100,255,218,0.2);
  --shadow-color:rgba(0,0,0,0.3);
  --nav-bg:rgba(8,13,26,0.82);
  --card-bg:rgba(15,23,41,0.55);
  --card-hover-bg:linear-gradient(135deg,rgba(15,23,41,0.8),rgba(100,255,218,0.04));
  --scrollbar-track:rgba(15,23,41,0.5);
  --scrollbar-thumb:rgba(100,255,218,0.25);
  --scrollbar-thumb-hover:rgba(100,255,218,0.45);
  --grain-opacity:0.035;
  --download-bg:rgba(100,255,218,0.08);
  --download-hover-bg:rgba(100,255,218,0.15);
}

[data-theme="light"]{
  --bg-primary:#f8fafc;
  --bg-secondary:#f1f5f9;
  --bg-tertiary:#e2e8f0;
  --bg-glass:rgba(255,255,255,0.65);
  --bg-glass-strong:rgba(255,255,255,0.85);
  --text-primary:#0f172a;
  --text-secondary:#475569;
  --text-dim:#94a3b8;
  --accent:#0d9488;
  --accent-rgb:13,148,136;
  --accent-secondary:#6366f1;
  --accent-secondary-rgb:99,102,241;
  --heading:#0f172a;
  --border:rgba(15,23,42,0.08);
  --border-strong:rgba(15,23,42,0.15);
  --shadow-color:rgba(0,0,0,0.06);
  --nav-bg:rgba(248,250,252,0.82);
  --card-bg:rgba(255,255,255,0.55);
  --card-hover-bg:linear-gradient(135deg,rgba(255,255,255,0.9),rgba(13,148,136,0.04));
  --scrollbar-track:rgba(241,245,249,0.8);
  --scrollbar-thumb:rgba(13,148,136,0.25);
  --scrollbar-thumb-hover:rgba(13,148,136,0.45);
  --grain-opacity:0.02;
  --download-bg:rgba(13,148,136,0.08);
  --download-hover-bg:rgba(13,148,136,0.15);
}

/* ── Global Transitions for Theme Switch ────── */
body,header,footer,.book-card,.download-btn{
  transition:background .35s ease,color .35s ease,border-color .35s ease;
}

/* ── Typography ─────────────────────────────── */
html{
  scroll-behavior:smooth;
  font-size:16px;
  overflow-x:hidden;
}

body{
  font-family:'Inter','Segoe UI',system-ui,-apple-system,sans-serif;
  background:var(--bg-primary);
  color:var(--text-primary);
  line-height:1.75;
  overflow-x:hidden;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

h1,h2,h3{
  font-family:'Outfit','Segoe UI',system-ui,sans-serif;
}

a{color:var(--accent);text-decoration:none;transition:opacity .2s,color .35s}
a:hover{opacity:.85}

strong{color:var(--heading);font-weight:600}

::selection{
  background:rgba(var(--accent-rgb),0.25);
  color:var(--heading);
}

/* ── Custom Scrollbar ───────────────────────── */
::-webkit-scrollbar{width:8px}
::-webkit-scrollbar-track{background:var(--scrollbar-track)}
::-webkit-scrollbar-thumb{background:var(--scrollbar-thumb);border-radius:4px}
::-webkit-scrollbar-thumb:hover{background:var(--scrollbar-thumb-hover)}
html{scrollbar-color:var(--scrollbar-thumb) var(--scrollbar-track);scrollbar-width:thin}

/* ── Grain Overlay ──────────────────────────── */
.grain-overlay{
  position:fixed;
  inset:0;
  z-index:9998;
  pointer-events:none;
  opacity:var(--grain-opacity);
  mix-blend-mode:overlay;
}

/* ── Header / Nav ──────────────────────────── */
header{
  position:sticky;
  top:0;
  z-index:100;
  backdrop-filter:blur(16px) saturate(1.5);
  -webkit-backdrop-filter:blur(16px) saturate(1.5);
  background:var(--nav-bg);
  border-bottom:1px solid var(--border);
}

nav{
  max-width:960px;
  margin:auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:.9rem 1.5rem;
}

.back-link{
  display:flex;
  align-items:center;
  gap:.5rem;
  color:var(--text-secondary);
  font-size:.85rem;
  font-weight:500;
  transition:color .25s;
}
.back-link:hover{color:var(--accent);opacity:1}

.site-title{
  font-family:'Outfit',sans-serif;
  font-weight:700;
  font-size:1.1rem;
  color:var(--heading);
  letter-spacing:-.01em;
}

.nav-right{
  display:flex;
  align-items:center;
}

/* ── Theme Toggle (same as portfolio) ───────── */
.theme-toggle{
  background:none;
  border:1px solid var(--border);
  cursor:pointer;
  color:var(--text-secondary);
  padding:.45rem;
  border-radius:10px;
  transition:color .3s,background .3s,border-color .3s,transform .3s;
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  width:38px;
  height:38px;
}
.theme-toggle:hover{
  color:var(--accent);
  background:rgba(var(--accent-rgb),0.08);
  border-color:rgba(var(--accent-rgb),0.2);
  transform:scale(1.05);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon{
  position:absolute;
  transition:transform .5s cubic-bezier(.4,0,.2,1),opacity .35s ease;
  width:20px;
  height:20px;
}

[data-theme="dark"] .icon-sun{transform:rotate(90deg) scale(0);opacity:0}
[data-theme="dark"] .icon-moon{transform:rotate(0) scale(1);opacity:1}
[data-theme="light"] .icon-sun{transform:rotate(0) scale(1);opacity:1}
[data-theme="light"] .icon-moon{transform:rotate(-90deg) scale(0);opacity:0}

/* ── Hero Banner ────────────────────────────── */
#hero{
  text-align:center;
  padding:7rem 1.5rem 4rem;
  position:relative;
}
#hero::after{
  content:'';
  position:absolute;
  bottom:0;
  left:10%;
  right:10%;
  height:1px;
  background:linear-gradient(90deg,transparent,var(--border-strong),transparent);
}

#hero h1{
  font-size:clamp(1.8rem,4vw,2.8rem);
  font-weight:800;
  color:var(--heading);
  letter-spacing:-.02em;
  margin-bottom:.75rem;
}

.subtitle{
  font-size:1.05rem;
  color:var(--text-secondary);
  max-width:500px;
  margin:0 auto;
  line-height:1.6;
}

/* ── Books Section ──────────────────────────── */
#books{
  padding:4rem 1.5rem;
  flex:1;
}

.container{
  max-width:960px;
  margin:auto;
}

.books-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(320px,1fr));
  gap:2rem;
}

/* ── Book Card ──────────────────────────────── */
.book-card{
  background:var(--card-bg);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border:1px solid var(--border);
  border-radius:16px;
  overflow:hidden;
  transition:transform .4s ease,border-color .4s,box-shadow .4s;
}
.book-card:hover{
  transform:translateY(-6px);
  border-color:rgba(var(--accent-rgb),0.2);
  box-shadow:
    0 16px 48px rgba(var(--accent-rgb),0.08),
    0 0 1px rgba(var(--accent-rgb),0.15);
}

/* Preview area */
.book-preview{
  position:relative;
  width:100%;
  height:280px;
  background:var(--bg-tertiary);
  border-bottom:1px solid var(--border);
  overflow:hidden;
}
.book-preview object,
.book-preview embed,
.book-preview iframe{
  width:100%;
  height:100%;
  border:none;
}
.preview-fallback{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  height:100%;
  gap:1rem;
  color:var(--text-dim);
  font-size:.9rem;
}
.preview-fallback a{
  padding:.5rem 1.25rem;
  border:1px solid var(--accent);
  border-radius:8px;
  color:var(--accent);
  font-size:.85rem;
  font-weight:500;
  transition:background .25s;
}
.preview-fallback a:hover{
  background:rgba(var(--accent-rgb),0.08);
  opacity:1;
}

/* Book info */
.book-info{
  padding:1.75rem 1.5rem;
}
.book-info h2{
  font-size:1.15rem;
  font-weight:700;
  color:var(--heading);
  margin-bottom:.65rem;
  letter-spacing:-.01em;
  line-height:1.35;
}
.book-description{
  font-size:.88rem;
  color:var(--text-secondary);
  line-height:1.65;
  margin-bottom:1.25rem;
}
.book-meta{
  display:flex;
  gap:1rem;
  margin-bottom:1.25rem;
  flex-wrap:wrap;
}
.book-meta span{
  font-size:.78rem;
  color:var(--text-dim);
  display:flex;
  align-items:center;
  gap:.35rem;
  padding:.3rem .65rem;
  background:rgba(var(--accent-rgb),0.04);
  border-radius:6px;
  border:1px solid var(--border);
}

/* Terminal Download Button */
.book-terminal {
  margin-top: 1.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.book-terminal:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
  box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.12);
  transform: translateY(-2px);
}
.term-header {
  background: var(--bg-secondary);
  padding: 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.term-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s;
}
.book-terminal:hover .term-dot:nth-child(1) { background: #ff5f56; }
.book-terminal:hover .term-dot:nth-child(2) { background: #ffbd2e; }
.book-terminal:hover .term-dot:nth-child(3) { background: #27c93f; }
.term-title {
  margin-left: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.term-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.15rem 1.25rem;
  text-decoration: none;
  font-family: 'Courier New', Courier, monospace;
  background: var(--bg-tertiary);
}
.term-cmd {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.term-prompt {
  color: var(--accent);
  font-weight: bold;
}
.term-typing {
  color: var(--text-primary);
}
.term-file {
  color: var(--accent-secondary);
}
.term-action {
  color: var(--text-dim);
  display: flex;
  align-items: center;
  transition: transform 0.3s ease, color 0.3s ease;
}
.book-terminal:hover .term-action {
  color: var(--accent);
  transform: translateX(6px);
}

/* ── Empty State ────────────────────────────── */
.empty-state{
  text-align:center;
  padding:4rem 2rem;
  color:var(--text-dim);
}
.empty-state svg{
  color:var(--text-dim);
  margin-bottom:1.5rem;
  opacity:.5;
}
.empty-state h3{
  color:var(--text-secondary);
  font-size:1.1rem;
  margin-bottom:.5rem;
}
.empty-state p{
  font-size:.9rem;
}

/* ── How to Add Books Instructions (hidden) ─── */
.instructions{
  display:none;
}

/* ── Footer ────────────────────────────────── */
footer{
  text-align:center;
  padding:2.5rem 1rem;
  color:var(--text-dim);
  font-size:.8rem;
  border-top:1px solid var(--border);
}
.footer-links{
  display:flex;
  justify-content:center;
  gap:1.5rem;
  margin-top:.75rem;
}
.footer-links a{
  color:var(--text-dim);
  font-size:.78rem;
  transition:color .25s;
}
.footer-links a:hover{color:var(--accent)}

/* ── Scroll Reveal ──────────────────────────── */
.reveal-up{
  opacity:0;
  transform:translateY(30px);
  transition:opacity .7s ease,transform .7s ease;
}
.reveal-up.visible{
  opacity:1;
  transform:translateY(0);
}

/* ── Responsive ─────────────────────────────── */
@media(max-width:768px){
  #hero{padding:5rem 1.25rem 3rem}
  #hero h1{font-size:1.6rem}
  .subtitle{font-size:.95rem}
  .books-grid{grid-template-columns:1fr}
  .book-preview{height:240px}
}

@media(max-width:480px){
  nav{padding:.75rem 1rem}
  .back-link{font-size:.8rem}
  .site-title{font-size:.95rem}
  #hero{padding:4rem 1rem 2.5rem}
  #books{padding:2.5rem 1rem}
  .book-info{padding:1.25rem 1rem}
  .book-info h2{font-size:1.05rem}
  .term-cmd {font-size: 0.8rem;}
  .term-body {padding: 1rem;}
}

/* ── Reduced Motion ────────────────────────── */
@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.01ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.01ms !important;
  }
  html{scroll-behavior:auto}
}

/* ── Print ──────────────────────────────────── */
@media print{
  .grain-overlay,.theme-toggle{display:none}
  header{position:static;background:#fff;border:none}
  body{background:#fff;color:#000}
  .book-card{break-inside:avoid}
}
