/* =============================================================
   O'qish sozlamalari ("Moslash"): yozuv, mavzu, shrift, o'lcham
   Holat <html> atributlarida: data-reader, data-rfont, data-rfs
   ============================================================= */

/* ----- Mavzular ----- */
html[data-reader="qogoz"] {
  --bg: #FAFAF7; --bg-alt: #EFEFEA; --surface: #FFFFFF;
  --text: #1C1C1A; --text-soft: #55554F; --text-muted: #8B8B84; --border: #E4E4DE;
  --primary: #2C44A0; --primary-dark: #233889;
}
html[data-reader="krem"] {
  --bg: #FFFCF0; --bg-alt: #F2F0E5; --surface: #FFFEF7;
  --text: #100F0F; --text-soft: #6F6E69; --text-muted: #9F9D96; --border: #E6E4D9;
  --primary: #205EA6; --primary-dark: #1A4F8C;
}
html[data-reader="sepia"] {
  --bg: #F4ECD8; --bg-alt: #EADFC4; --surface: #FBF5E6;
  --text: #4A3B2C; --text-soft: #75614B; --text-muted: #9C876C; --border: #E0D2B2;
  --primary: #9A4A22; --primary-dark: #7E3B1A;
  --accent: #C8923C; --accent-bg: #F1E3C2;
}
html[data-reader="dengiz"] {
  --bg: #172033; --bg-alt: #212C43; --surface: #1D273B;
  --text: #DCE3EE; --text-soft: #A3AEC2; --text-muted: #75819A; --border: #2E3A54;
  --primary: #7FA6E8; --primary-dark: #6A92D8;
}
html[data-reader="tun"] {
  --bg: #100F0F; --bg-alt: #1C1B1A; --surface: #171616;
  --text: #CECDC3; --text-soft: #9F9D96; --text-muted: #6F6E69; --border: #343331;
  --primary: #4385BE; --primary-dark: #3171B2;
}
html[data-reader="sham"] {
  --bg: #1E1A16; --bg-alt: #2A241E; --surface: #241F1A;
  --text: #EADCC4; --text-soft: #B5A184; --text-muted: #857460; --border: #3B332A;
  --primary: #E0A45C; --primary-dark: #CF924A;
  --accent: #E0A45C; --accent-bg: #3A2E1E;
}

/* ----- Shrift ----- */
html[data-rfont="spectral"] { --reader-font: 'Spectral', Georgia, serif; }
html[data-rfont="lora"]     { --reader-font: 'Lora', Georgia, serif; }
html[data-rfont="georgia"]  { --reader-font: Georgia, 'Times New Roman', serif; }

html[data-rfont] .post-title,
html[data-rfont] .post-excerpt,
html[data-rfont] .post-content,
html[data-rfont] .post-content h1,
html[data-rfont] .post-content h2,
html[data-rfont] .post-content h3 {
  font-family: var(--reader-font);
}

/* ----- Matn o'lchami ----- */
html[data-rfs] .post-content { font-size: var(--reader-fs); }
html[data-rfs] .post-content h1 { font-size: 1.78em; }
html[data-rfs] .post-content h2 { font-size: 1.45em; }
html[data-rfs] .post-content h3 { font-size: 1.17em; }
html[data-rfs] .post-content blockquote { font-size: 1.05em; }
html[data-rfs] .post-content pre { font-size: 0.84em; }

/* ----- Suzuvchi tugma: "0% | Aa Moslash" ----- */
.reader-pill {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 81;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 34px rgba(20, 30, 60, 0.18);
  font-family: var(--font-body);
}
.reader-progress {
  min-width: 52px;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.reader-open {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.reader-open:hover { background: var(--bg-alt); }
.reader-open .reader-aa { font-family: Georgia, serif; font-size: 18px; font-weight: 600; line-height: 1; }

@media (max-width: 1240px) {
  /* Tor ekranda markaziy reaksiya paneli bilan ustma-ust tushmasin */
  .reader-pill { bottom: 86px; }
}
@media (max-width: 600px) {
  .reader-pill { right: 12px; bottom: 84px; }
  body.listening .reader-pill { bottom: 202px; }
  .reader-open .reader-label { display: none; }
  .reader-open { padding: 8px 12px; }
}

/* ----- Panel ----- */
.reader-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 12, 20, 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.reader-panel {
  position: fixed;
  right: 22px;
  bottom: 84px;
  z-index: 1001;
  width: 380px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 18px 18px 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(10, 15, 30, 0.28);
  font-family: var(--font-body);
}
.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.reader-title { font-size: 15px; font-weight: 700; }
.reader-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 15px;
}
.reader-close:hover { color: var(--text); }
.reader-label-sm {
  display: block;
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.reader-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg-alt);
  border-radius: 999px;
}
.reader-seg button {
  padding: 9px 10px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.reader-seg button.active {
  background: var(--text);
  color: var(--surface);
  box-shadow: 0 2px 8px rgba(20, 30, 60, 0.12);
}
.reader-themes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.reader-theme {
  padding: 13px 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline-offset: 2px;
}
.reader-theme.active { outline: 2px solid var(--primary); }
.reader-theme[data-t="qogoz"]  { background: #FAFAF7; color: #1C1C1A; }
.reader-theme[data-t="krem"]   { background: #FFFCF0; color: #100F0F; }
.reader-theme[data-t="sepia"]  { background: #F4ECD8; color: #4A3B2C; }
.reader-theme[data-t="dengiz"] { background: #172033; color: #DCE3EE; }
.reader-theme[data-t="tun"]    { background: #100F0F; color: #CECDC3; }
.reader-theme[data-t="sham"]   { background: #1E1A16; color: #EADCC4; }
.reader-fonts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.reader-font {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.reader-font .rf-aa { font-size: 20px; line-height: 1.1; }
.reader-font .rf-name { font-size: 11px; color: var(--text-muted); }
.reader-font.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.reader-font.active .rf-name { color: inherit; opacity: 0.75; }
.reader-size {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-alt);
  border-radius: 999px;
}
.reader-size .rs-a { font-family: Georgia, serif; color: var(--text-soft); line-height: 1; }
.reader-size .rs-a.sm { font-size: 13px; }
.reader-size .rs-a.lg { font-size: 20px; }
.reader-size input[type="range"] { flex: 1; accent-color: var(--primary); }
.reader-size .rs-val {
  min-width: 22px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.reader-sample {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  line-height: 1.55;
  font-family: var(--reader-font, var(--font-body));
}
.reader-reset {
  display: block;
  margin: 14px auto 0;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reader-reset:hover { color: var(--text); }

@media (max-width: 600px) {
  .reader-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 40px);
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}
