/* Мир «Игры престолов» — палитра «лёд и пламя»: тёмный камень, золото, кровь, лёд. */
:root {
  --bg: #0e1116;
  --bg-2: #151a22;
  --panel: #1b212b;
  --panel-2: #222a36;
  --border: #2c3644;
  --text: #e8eaed;
  --text-dim: #9aa4b2;
  --gold: #d4af37;
  --gold-soft: #b9962e;
  --blood: #8c2f2f;
  --ice: #6fb7d6;
  --fire: #e0712f;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(224, 113, 47, .08), transparent 60%),
    radial-gradient(1000px 500px at 0% 0%, rgba(111, 183, 214, .07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  line-height: 1.55;
  min-height: 100vh;
}

/* ---------- Шапка ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 18px 28px;
  background: linear-gradient(180deg, #11161d, #0d1116);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { font-size: 34px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.brand-text h1 {
  margin: 0; font-size: 22px; letter-spacing: .5px; color: var(--gold);
  font-weight: 700;
}
.brand-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); letter-spacing: .3px; }
.search-wrap { flex: 1; min-width: 220px; display: flex; justify-content: flex-end; }
#search {
  width: min(440px, 100%);
  padding: 11px 16px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 15px; font-family: inherit;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
#search:focus { border-color: var(--gold-soft); box-shadow: 0 0 0 3px rgba(212,175,55,.15); }
#search::placeholder { color: #6b7480; }

/* ---------- Вкладки ---------- */
.tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: var(--bg-2); position: sticky; top: 75px; z-index: 20;
}
.tab {
  padding: 8px 16px; border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--text-dim);
  font-family: inherit; font-size: 14.5px; cursor: pointer;
  transition: all .15s;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: #15110a; background: var(--gold); border-color: var(--gold); font-weight: 600; }
.tab .count { opacity: .65; font-size: 12px; margin-left: 5px; }

/* ---------- Main ---------- */
#main { padding: 28px; max-width: 1280px; margin: 0 auto; }
.view-title {
  margin: 0 0 6px; font-size: 26px; color: var(--gold); letter-spacing: .4px;
}
.view-sub { margin: 0 0 22px; color: var(--text-dim); font-size: 14.5px; }

/* Сетка карточек */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  transition: transform .14s, border-color .14s, box-shadow .14s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); border-color: var(--gold-soft); box-shadow: var(--shadow); }
.card-img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
}
.card-body { padding: 13px 15px 16px; }
.card-title { font-size: 17px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.card-meta { font-size: 12.5px; color: var(--gold-soft); margin: 0 0 7px; letter-spacing: .3px; }
.card-text { font-size: 13.5px; color: var(--text-dim); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Чипы (перелинковка) ---------- */
.chip {
  display: inline-block; padding: 3px 10px; margin: 3px 5px 3px 0;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  color: var(--ice); font-size: 13px; cursor: pointer; transition: all .13s;
}
.chip:hover { border-color: var(--ice); background: #243441; }
.chip.house { color: var(--gold); }
.chip.house:hover { border-color: var(--gold); background: #2d2716; }

/* ---------- Главная ---------- */
.hero {
  background: linear-gradient(135deg, #161d27, #0f141b);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 30px; margin-bottom: 26px;
}
.hero h2 { margin: 0 0 10px; color: var(--gold); font-size: 24px; }
.hero p { margin: 0 0 12px; color: var(--text-dim); max-width: 70ch; }
.hero .rating-note {
  display: inline-block; margin-top: 6px; padding: 6px 12px;
  background: rgba(140,47,47,.18); border: 1px solid var(--blood); border-radius: 8px;
  color: #e7a3a3; font-size: 13px;
}
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.stat {
  flex: 1; min-width: 120px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 10px; cursor: pointer; transition: all .14s;
}
.stat:hover { border-color: var(--gold-soft); transform: translateY(-2px); }
.stat .num { font-size: 30px; font-weight: 700; color: var(--gold); display: block; }
.stat .lbl { font-size: 13px; color: var(--text-dim); }
.section-h { margin: 30px 0 14px; font-size: 19px; color: var(--text); border-left: 3px solid var(--gold); padding-left: 12px; }

#main ul { margin: 4px 0 0; padding-left: 22px; }
#main ul li { margin: 6px 0; color: var(--text); }
#main > p { color: var(--text); max-width: 78ch; }

.themes { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-pill { background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 13px; font-size: 13.5px; color: var(--text-dim); }

/* ---------- Книги ---------- */
.book-row {
  display: flex; gap: 14px; align-items: baseline;
  padding: 13px 16px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px;
}
.book-year { color: var(--gold); font-weight: 700; min-width: 52px; }
.book-title { font-weight: 600; }
.book-one { color: var(--text-dim); font-size: 13.5px; }

/* ---------- Хронология ---------- */
.timeline { position: relative; margin-left: 10px; padding-left: 26px;
  border-left: 2px solid var(--border); }
.tl-item { position: relative; padding: 0 0 22px; }
.tl-item::before {
  content: ""; position: absolute; left: -33px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--bg);
}
.tl-era { font-size: 12.5px; color: var(--fire); letter-spacing: .4px; text-transform: uppercase; }
.tl-event { margin: 3px 0 0; color: var(--text); }
.tl-note { font-size: 12.5px; color: var(--text-dim); font-style: italic; margin-top: 4px; }

/* ---------- Drawer ---------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40;
  backdrop-filter: blur(2px);
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%);
  background: var(--bg-2); border-left: 1px solid var(--border);
  z-index: 50; box-shadow: -10px 0 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  transform: translateX(0); transition: transform .22s ease;
}
.drawer.hidden { transform: translateX(100%); }
.drawer-overlay.hidden { display: none; }
.drawer-head {
  display: flex; justify-content: space-between; padding: 14px 18px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.drawer-back, .drawer-close {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  width: 38px; height: 38px; border-radius: 8px; cursor: pointer; font-size: 17px;
  transition: all .13s;
}
.drawer-back:hover, .drawer-close:hover { border-color: var(--gold-soft); color: var(--gold); }
.drawer-body { padding: 22px 26px; overflow-y: auto; }
.detail-img {
  width: 150px; height: 150px; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--border); float: right; margin: 0 0 14px 18px; cursor: zoom-in;
}
.detail-title { font-size: 25px; margin: 0 0 2px; color: var(--gold); }
.detail-title-en { font-size: 13px; color: var(--text-dim); margin: 0 0 6px; font-style: italic; }
.detail-kicker { color: var(--fire); font-size: 13px; letter-spacing: .4px; margin: 0 0 14px; }
.detail-section { margin: 16px 0 0; }
.detail-section h4 {
  margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-dim);
}
.detail-section p { margin: 0; color: var(--text); }
.rel-item { padding: 9px 0; border-bottom: 1px solid var(--border); }
.rel-item:last-child { border-bottom: none; }
.rel-type { font-size: 12px; color: var(--fire); text-transform: lowercase; }
.words { font-style: italic; color: var(--ice); font-size: 16px; }

/* ---------- Лайтбокс ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 60;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 10px; box-shadow: var(--shadow); }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 20px 28px; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px; margin-top: 30px;
}
.footer .rating { color: var(--blood); }

.hidden { display: none !important; }
.empty { color: var(--text-dim); padding: 40px 0; text-align: center; }

@media (max-width: 640px) {
  .topbar { padding: 14px 16px; }
  #main { padding: 18px 16px; }
  .tabs { top: 70px; padding: 12px 16px; }
  .detail-img { float: none; display: block; margin: 0 0 14px; }
}
