/* Component IDs match reader controls. Independent component selectors intentionally follow their UI sections. */
/* stylelint-disable selector-id-pattern, no-descending-specificity */
@font-face {
  font-family: Mast;
  src: url("fonts/dhurjati-mast.woff2") format("woff2");
  font-display: swap;
}

:root {
  --red: #c41320;
  --dark: #161514;
  --paper: #faf7f0;
  --desk: #e7e1d3;
  --rule: #d8d1c2;
  --ink2: #5a554d;
  --wa: #1a7a45;
  --safeb: env(safe-area-inset-bottom, 0px);
  --safet: env(safe-area-inset-top, 0px);
  --ui:
    "Noto Sans Telugu", "Kohinoor Telugu", "Telugu MN", "Telugu Sangam MN",
    gautami, sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--desk);
  color: var(--dark);
  font-family: var(--ui);
}

body {
  position: fixed;
  inset: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

:focus-visible {
  outline: 3px solid #1a5fd0;
  outline-offset: -3px;
}

/* stage: the reading desk. Touch gestures are owned by reader.js here only. */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  background: var(--desk);
  outline: 0;
  user-select: none;
  -webkit-touch-callout: none;
}

#track {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.slot {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.pg {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background: #fff;
  box-shadow:
    0 1px 2px rgb(50 40 20 / 25%),
    0 6px 22px rgb(50 40 20 / 18%);
}

.pg.anim {
  transition:
    left 0.22s ease,
    top 0.22s ease,
    width 0.22s ease,
    height 0.22s ease;
}

.pg img.base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.pg .tl {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pg .tl img {
  position: absolute;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s linear;
}

.pg .tl img.on {
  opacity: 1;
}

.pg .hl {
  position: absolute;
  border: 3px solid var(--red);
  border-radius: 3px;
  background: rgb(196 19 32 / 8%);
  box-shadow: 0 0 0 2000px rgb(22 21 20 / 26%);
  pointer-events: none;
  display: none;
}

.pg .hl.on {
  display: block;
  animation: pulse 0.4s ease-out;
}

.pg .load {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--ink2);
  background: #fff;
}

.pg .load::before {
  content: "";
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--rule);
  border-top-color: var(--red);
  animation: spin 1s linear infinite;
}

.pg .load.err::before {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  from {
    opacity: 0;
  }
}

/* top bar */
#top {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: calc(48px + var(--safet));
  padding: var(--safet) 4px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  z-index: 20;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
}

.mast {
  font-family: Mast, var(--ui);
  font-size: 23px;
  line-height: 1;
  white-space: nowrap;
  padding-top: 2px;
}

.mast b {
  font-weight: 400;
  color: var(--red);
}

#edname {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.25;
  color: var(--ink2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

#draft {
  flex: none;
  font:
    700 11px/1 system-ui,
    sans-serif;
  letter-spacing: 0.06em;
  background: var(--red);
  color: #fff;
  padding: 4px 6px;
  border-radius: 3px;
}

#btnEd {
  flex: none;
  min-width: 48px;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  padding: 0 6px;
  color: var(--dark);
}

#btnEd svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

/* bottom bar */
#bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(60px + var(--safeb));
  padding-bottom: var(--safeb);
  background: var(--paper);
  border-top: 1px solid var(--rule);
  z-index: 20;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
}

.mode {
  display: none;
  height: 60px;
  align-items: stretch;
}

#bar[data-mode="page"] .m-page,
#bar[data-mode="zoom"] .m-zoom,
#bar[data-mode="art"] .m-art {
  display: flex;
}

.nav {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dark);
}

.nav svg {
  width: 28px;
  height: 28px;
  stroke-width: 2.4;
}

.nav:disabled {
  color: #c4bdae;
  cursor: default;
}

.pgno {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1.25;
}

.pgno .num {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.pgno .sub {
  font-size: 12.5px;
  color: var(--ink2);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.pgno .sub svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.4;
}

.tool {
  flex: 0 0 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  line-height: 1.25;
  gap: 2px;
}

.tool svg {
  width: 22px;
  height: 22px;
}

.tool.share {
  color: var(--red);
  font-weight: 700;
}

.atitle {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0 6px 0 14px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
}

#aT {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.go {
  flex: none;
  align-self: center;
  height: 48px;
  padding: 0 16px;
  margin-left: 2px;
  background: var(--red);
  color: #fff;
  font-size: 15.5px;
  font-weight: 700;
  border-radius: 8px;
}

#hd {
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 2px;
  background: var(--red);
  transform-origin: 0 50%;
  transform: scaleX(0);
  opacity: 0;
  transition: opacity 0.2s;
}

#hd.on {
  opacity: 1;
  animation: hdp 1.1s ease-in-out infinite;
}

@keyframes hdp {
  0% {
    transform: scaleX(0);
  }

  70% {
    transform: scaleX(1);
  }

  100% {
    transform: scaleX(1);
    opacity: 0.25;
  }
}

/* variant 1: controls fade on tap; only the slim page strip stays */
#strip {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(49px + var(--safeb));
  padding-bottom: var(--safeb);
  align-items: stretch;
  justify-content: space-between;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  z-index: 19;
  font-size: 15px;
  font-weight: 700;
}

#strip > span {
  align-self: center;
}

#strip button {
  flex: 0 0 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#strip button:disabled {
  color: #c4bdae;
}

html[data-v="1"] #strip {
  display: flex;
}

html[data-v="1"] #btnNews {
  display: none;
}

html[data-v="1"].immersive #top {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

html[data-v="1"].immersive #bar {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* sheets */
#layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  animation: slide 0.2s ease-out;
}

@keyframes slide {
  from {
    transform: translateY(24px);
    opacity: 0.3;
  }
}

.sh-h {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(56px + var(--safet));
  padding: var(--safet) 4px 0 16px;
  border-bottom: 1px solid var(--rule);
}

.sh-h h2 {
  margin: 0;
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.x {
  flex: none;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sh-b {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px 14px calc(24px + var(--safeb));
}

/* thumbnails */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 10px;
}

@media (width >= 600px) {
  .grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.th {
  display: block;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.3;
  color: var(--dark);
}

.th .im {
  position: relative;
  display: block;
  background: #fff;
  border: 1px solid var(--rule);
  overflow: hidden;
}

.th img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.th.cur .im {
  outline: 3px solid var(--red);
  outline-offset: 1px;
}

.th b {
  display: block;
  font-size: 15px;
  margin-top: 6px;
}

.th small {
  display: block;
  font-size: 12.5px;
  color: var(--ink2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* editions */
.month {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink2);
  margin: 14px 2px 8px;
}

.month:first-child {
  margin-top: 0;
}

.ed {
  display: flex;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
  color: var(--dark);
  min-height: 132px;
}

.ed.cur {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
}

.ed .cv {
  flex: 0 0 76px;
  height: 114px;
  background: #f2eee4;
  border: 1px solid var(--rule);
}

.ed .cv img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.ed .tx {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.ed .t {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}

.ed .d {
  font-size: 14px;
  color: var(--ink2);
  line-height: 1.35;
}

.tag {
  align-self: flex-start;
  font-size: 13px;
  font-weight: 700;
  background: var(--red);
  color: #fff;
  padding: 2px 8px;
  border-radius: 3px;
}

.ribbon {
  position: absolute;
  left: -30px;
  top: 12px;
  transform: rotate(-45deg);
  width: 104px;
  text-align: center;
  background: var(--red);
  color: #fff;
  font:
    700 11px/19px system-ui,
    sans-serif;
  letter-spacing: 0.08em;
}

.opts {
  margin-top: 18px;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  font-size: 14px;
  color: var(--ink2);
}

.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  flex: none;
}

.seg a,
.seg button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 64px;
  padding: 0 12px;
  font-size: 14.5px;
  color: var(--dark);
  text-decoration: none;
  background: #fff;
}

.seg .on {
  background: var(--dark);
  color: #fff;
  font-weight: 700;
}

/* story list */
.pgh {
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
  margin: 16px 2px 4px;
}

.pgh:first-child {
  margin-top: 0;
}

.st {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 700;
  padding: 12px 4px;
  border-bottom: 1px solid var(--rule);
  min-height: 48px;
}

/* share */
.prev {
  display: block;
  width: 100%;
  background: #eee;
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
}

.prev.sq {
  width: 66%;
  margin: 0 auto;
}

.stitle {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  margin: 12px 2px;
}

.seg.full {
  display: flex;
  margin: 0 0 12px;
}

.seg.full button {
  flex: 1;
}

.big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 700;
  background: var(--wa);
  color: #fff;
  text-decoration: none;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.row2 > * {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 10px;
  background: #efe9db;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--dark);
  text-decoration: none;
  text-align: center;
  line-height: 1.25;
  padding: 4px;
}

/* article */
.art {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.art img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--rule);
}

.art h1 {
  font-size: 25px;
  line-height: 1.4;
  font-weight: 800;
  margin: 14px 0 6px;
}

.art .meta {
  font-size: 14px;
  color: var(--ink2);
}

.art p {
  font-size: 19px;
  line-height: 1.85;
  margin: 14px 0;
}

.art .sub {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.5;
  margin: 18px 0 4px;
}

.art .noimg {
  background: #fff;
  border: 1px dashed var(--rule);
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  line-height: 1.6;
  margin: 14px 0;
}

.sh-f {
  flex: none;
  display: flex;
  align-items: stretch;
  height: calc(60px + var(--safeb));
  padding-bottom: var(--safeb);
  border-top: 1px solid var(--rule);
  background: var(--paper);
}

.sh-f button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 700;
}

.sh-f button:disabled {
  color: #c4bdae;
}

.sh-f .share {
  color: var(--red);
}

.sh-f svg {
  width: 20px;
  height: 20px;
}

.tolink {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin-top: 6px;
  background: #efe9db;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(72px + var(--safeb));
  transform: translate(-50%, 10px);
  max-width: calc(100vw - 32px);
  width: max-content;
  background: var(--dark);
  color: #fff;
  font-size: 15px;
  line-height: 1.4;
  padding: 9px 14px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  z-index: 60;
  text-align: center;
}

#toast.on {
  opacity: 0.96;
  transform: translate(-50%, 0);
}

.nojs {
  position: fixed;
  inset: 40% 16px auto;
  text-align: center;
  font-size: 18px;
  z-index: 99;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

#pageAlways {
  position: fixed;
  top: calc(48px + var(--safet));
  left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  background: var(--paper);
  padding: 2px 10px;
  border-radius: 0 0 6px 6px;
  font: 700 12px/1.5 var(--ui);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

#latest-banner {
  position: fixed;
  top: calc(48px + var(--safet));
  left: 0;
  right: 0;
  text-align: center;
  background: var(--paper);
  display: flex;
  align-items: stretch;
  min-height: 48px;
  font: 700 14px/1.5 var(--ui);
}

#latest-banner a {
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 48px;
}

#dismiss-latest {
  flex: 0 0 48px;
  min-width: 48px;
  min-height: 48px;
  font-size: 24px;
}

html:not([data-reader-ready="true"]) #stage,
html:not([data-reader-ready="true"]) #top button,
html:not([data-reader-ready="true"]) #bar,
html:not([data-reader-ready="true"]) #pageAlways {
  visibility: hidden;
}

#reader-status {
  position: fixed;
  inset: 30% 10%;
  z-index: 22;
  background: var(--paper);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.retry,
#retry-reader {
  padding: 12px;
  background: var(--red);
  color: white;
  min-height: 48px;
}

.pg .load.err {
  gap: 12px;
  flex-wrap: wrap;
  pointer-events: auto;
}

body:has(#latest-banner:not([hidden])) #pageAlways {
  top: calc(96px + var(--safet));
}
