/*
Theme Name: Thutasone Reader
Theme URI: https://example.com/
Author: Khaing Htoo Aung
Author URI: https://example.com/
Description: Lightweight Ebooks/Audiobooks theme with responsive grid, modal preview, PDF reader and audio player.
Version: 1.1.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: thutasone-reader
Tags: custom-background, custom-logo, custom-menu, featured-images, theme-options
*/

:root{
  --bg: #0b1220;
  --panel: #0f172a; /* slate-900 */
  --panel2:#111c33;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --brand:#22c55e;
  --border:rgba(148,163,184,.18);
  --shadow: 0 14px 50px rgba(0,0,0,.45);
  --radius:16px;
}

html{scroll-behavior:smooth}
body{
  margin:0;
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif;
  background: var(--bg);
  color: var(--text);
}
body.light{
  --bg:#f3f4f6;
  --panel:#ffffff;
  --panel2:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --border:rgba(15,23,42,.12);
  --shadow: 0 10px 30px rgba(2,6,23,.12);
}

a{color:inherit;text-decoration:none}
.container{max-width:1200px;margin:0 auto;padding:18px}
.header{
  position:sticky;top:0;z-index:50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner{display:flex;align-items:center;gap:12px;justify-content:space-between}
.brand{display:flex;align-items:center;gap:10px;font-weight:800;letter-spacing:.3px}
.brand .logo{
  width:34px;height:34px;border-radius:10px;
  background:linear-gradient(135deg,var(--brand),#60a5fa);
  box-shadow:0 10px 30px rgba(34,197,94,.25);
}
.nav{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.nav a{padding:9px 10px;border-radius:12px;color:var(--muted)}
.nav a:hover{background:rgba(148,163,184,.08);color:var(--text)}
.actions{display:flex;align-items:center;gap:10px}
.btn-icon{
  width:40px;height:40px;border-radius:14px;
  border:1px solid var(--border);
  background: var(--panel);
  display:grid;place-items:center;
  cursor:pointer;
}
.btn-icon:hover{filter:brightness(1.05)}
.search{
  display:flex;align-items:center;gap:10px;
  border:1px solid var(--border); background: var(--panel);
  padding:10px 12px;border-radius:14px;min-width:240px;
}
.search input{
  border:0; outline:0; background:transparent; color:var(--text);
  width:100%;
}
.badge{
  display:inline-flex;align-items:center;gap:6px;
  color:var(--muted);font-size:12px;
  border:1px solid var(--border);
  padding:6px 10px;border-radius:999px;
}

.hero{
  border:1px solid var(--border);
  background:linear-gradient(135deg, color-mix(in srgb, var(--panel) 85%, transparent), color-mix(in srgb, var(--panel2) 75%, transparent));
  border-radius: var(--radius);
  padding:18px;
  box-shadow: var(--shadow);
}
.hero h1{margin:0 0 8px;font-size:22px}
.hero p{margin:0;color:var(--muted)}

.grid{
  margin-top:16px;
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr)); /* mobile default */
  gap:12px;
}
@media (min-width: 720px){
  .grid{grid-template-columns: repeat(4, minmax(0,1fr));}
}
@media (min-width: 1024px){
  .grid{grid-template-columns: repeat(6, minmax(0,1fr));}
}

.card{
  border:1px solid var(--border);
  background: var(--panel);
  border-radius: 16px;
  overflow:hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  cursor:pointer;
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}
.card:hover{
  transform: translateY(-2px);
  box-shadow: 0 16px 45px rgba(0,0,0,.22);
}
.cover{
  position:relative;
  aspect-ratio: 2 / 3; /* cover ratio like manga/ebook */
  background: rgba(148,163,184,.10);
}
.cover img{
  width:100%;height:100%;object-fit:cover;display:block;
}
.cover::after{
  content:"";
  position:absolute;inset:0;
  box-shadow: inset 0 -40px 70px rgba(0,0,0,.35);
  pointer-events:none;
}
.card-meta{padding:10px 10px 12px}
.title{font-weight:700;font-size:13px;line-height:1.25;margin:0 0 6px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.meta-row{display:flex;align-items:center;justify-content:space-between;gap:8px;color:var(--muted);font-size:12px}

.pill{
  border:1px solid var(--border);
  padding:4px 8px;border-radius:999px;
  font-size:11px;color:var(--muted);
  background: color-mix(in srgb, var(--panel) 75%, transparent);
}

.footer{margin:28px 0 18px;color:var(--muted);font-size:12px;text-align:center}

.modal-backdrop{
  position:fixed;inset:0;z-index:999;
  background: rgba(2,6,23,.72);
  display:none;
}
.modal{
  position:fixed;inset:0;z-index:1000;
  display:none;
  place-items:center;
  padding:18px;
}
.modal.open, .modal-backdrop.open{display:grid}
.modal-card{
  width:min(980px, 100%);
  border-radius: 18px;
  border:1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.modal-top{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:12px 12px;
  border-bottom:1px solid var(--border);
}
.modal-top .left{display:flex;align-items:center;gap:10px}
.modal-top .left strong{font-size:14px}
.modal-body{
  display:grid;
  grid-template-columns: 280px 1fr;
  gap:14px;
  padding:14px;
}
@media (max-width: 820px){
  .modal-body{grid-template-columns:1fr}
}
.modal-cover{border-radius:16px;overflow:hidden;border:1px solid var(--border)}
.modal-cover img{width:100%;height:auto;display:block}
.modal-content{min-width:0}
.modal-content .excerpt{color:var(--muted);line-height:1.6;font-size:14px}
.modal-actions{
  display:flex;flex-wrap:wrap;gap:10px;margin-top:12px
}
.btn{
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 75%, transparent);
  color: var(--text);
  padding:10px 12px;border-radius:14px;
  cursor:pointer;
  display:inline-flex;align-items:center;gap:8px;
  font-weight:700;font-size:13px;
}
.btn.primary{
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  border:0;
  color:#071019;
}
.btn:active{transform:translateY(1px)}
.btn.small{padding:8px 10px;border-radius:12px;font-weight:700}

.reader{
  margin-top:14px;
  border:1px solid var(--border);
  border-radius: 16px;
  overflow:hidden;
}
.reader iframe{
  width:100%; height: 72vh; border:0; background:#0b1220;
}
.audio{
  margin-top:14px;
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px;
}
.audio audio{width:100%}

.loadmore-wrap{display:flex;justify-content:center;margin:18px 0}
.loadmore{min-width:220px}

.notice{
  border:1px dashed var(--border);
  border-radius: 16px;
  padding:12px;
  color:var(--muted);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}

/* ===== Reader Mode (Single Book) ===== */
.tr-reader-wrap{margin-top:16px}
.tr-reader-card{
  border-radius:28px;
  border:1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 92%, transparent), color-mix(in srgb, var(--panel2) 85%, transparent));
  box-shadow: var(--shadow);
  overflow:hidden;
}
.tr-reader-top{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 18px;
  border-bottom:1px solid var(--border);
}
.tr-reader-label{font-weight:900;letter-spacing:.6px;font-size:13px;opacity:.9}
.tr-reader-close{
  width:34px;height:34px;border-radius:999px;
  display:grid;place-items:center;
  background:#ef4444;color:white;
  text-decoration:none;font-weight:900;
}
.tr-reader-hero{
  display:grid;
  grid-template-columns: 280px 1fr;
  gap:18px;
  padding:18px;
}
@media (max-width: 860px){
  .tr-reader-hero{grid-template-columns:1fr}
}
.tr-reader-cover{
  border-radius:22px;
  overflow:hidden;
  border:1px solid var(--border);
  background: rgba(148,163,184,.08);
  max-width:320px;
}
.tr-reader-cover img{width:100%;height:auto;display:block}
.tr-reader-title{margin:0 0 8px;font-size:24px;line-height:1.2}
.tr-reader-author{font-weight:800;color:#60a5fa;margin-bottom:10px}
.tr-reader-author span{color:color-mix(in srgb, var(--text) 86%, transparent)}
.tr-reader-actions{display:flex;flex-wrap:wrap;gap:10px;margin:10px 0 12px}
.tr-pillbtn{
  border-radius:999px;
  border:1px solid color-mix(in srgb, #ef4444 55%, transparent);
  background: color-mix(in srgb, #ef4444 20%, transparent);
  color:white;
  padding:10px 14px;
  font-weight:900;
  cursor:pointer;
}
.tr-pillbtn:hover{filter:brightness(1.05)}
.tr-readnow{
  margin-left:auto;
  border-radius:999px;
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color:#071019;
  padding:10px 18px;
  font-weight:1000;
  text-decoration:none;
}
.tr-reader-desc{
  color:var(--muted);
  line-height:1.7;
  max-width: 72ch;
}
.tr-reader-stats{margin-top:12px;display:flex;gap:8px;flex-wrap:wrap}
.tr-badge{
  display:inline-flex;align-items:center;gap:6px;
  border:1px solid var(--border);
  padding:6px 10px;border-radius:999px;
  font-size:12px;color:var(--muted);
}
.tr-inline-reader{border-top:1px solid var(--border)}
.tr-inline-reader iframe{width:100%;height:80vh;border:0;background:#0b1220}
.tr-inline-audio{border-top:1px solid var(--border);padding:14px}
.tr-inline-audio audio{width:100%}
.tr-related-title{margin:22px 0 10px;font-size:26px}

/* ===== Audiobook/Ebook Info Box (Reader Mode) ===== */
.tr-mid-box{
  margin-top:12px;
  border:1px dashed var(--border);
  border-radius:22px;
  padding:16px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  text-align:center;
}
.tr-mid-icon{
  width:56px;height:56px;border-radius:16px;
  display:grid;place-items:center;
  margin:0 auto 10px;
  background: rgba(239,68,68,.14);
  border:1px solid rgba(239,68,68,.35);
  font-weight:1000;
}
.tr-mid-icon span{font-size:18px;letter-spacing:.6px}
