/* =====================================================================
   enisnews — Kindle mode: the paged reader (lib/kindle.js createPager)
   and the "Aa" display settings (openDisplaySheet). Every rule sits under
   html[data-kindle]; css/kindle.css is the e-ink skin of everything else,
   the scrolling reader included.

   The book type: lib/kindle.js (applyReadVars) sets these from the Kindle
   settings on the reader — the paged layer (.kp) and, while the article
   scrolls, the reader's view; both carry the class k-read.
     --k-read-font     font-family of the book text (Book, Classic, Georgia, Sans)
     --k-read-size     its size in px (12 steps, 14–32)
     --k-read-lh       line height, unitless: tight 1.45 · normal 1.62 · wide 1.85
     --k-read-leading  the same value (the name css/kindle.css reads);
                       Word Wise adds .32 to it here, room for its hints
     --k-read-align    justify | left
     --k-read-margin   extra side margin of the text while the article scrolls
     --k-read-indent   first-line indent of a paragraph (1.5em)
     --k-read-weight   font-weight, 400–500 (only variable fonts show the steps)
     --k-read-stroke   the Kindle "Bold" level as ink round every letter: a
                       -webkit-text-stroke width, 0px at level 0
   The paged layer measures and sets, for itself:
     --kp-h            the height of the text on a page (px)
     --kp-m            the side margin inside each page (px)
     --kp-edge         from the screen's edge to the text (px): the status
                       lines and the toolbar line up with it
     --kp-player-h     the Listen strip under the page (0px without it)
   Classes: body.kindle-reader while the paged reader is open (with
   kindle-study while its study pack is on screen); html.kp-lock while the
   pages show — the document never scrolls under them.
   ===================================================================== */

html[data-kindle] { --kp-top: 30px; --kp-foot: 34px; }

/* ---------- the pages take the screen ---------- */
html[data-kindle].kp-lock,
html[data-kindle].kp-lock body { overflow: hidden; overscroll-behavior: none; }
html[data-kindle] body.kindle-reader:not(.kindle-study) #app > .view,
html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-actions { display: none !important; }

html[data-kindle] .kp {
  position: fixed; inset: 0; z-index: 46;
  background: var(--k-paper); color: var(--k-ink);
  font-family: var(--k-sans);
  overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* status lines: the clock at the top, reading progress and percent at the bottom */
html[data-kindle] .kp-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  height: calc(var(--safe-t) + var(--kp-top)); padding: var(--safe-t) 0 0;
  display: flex; align-items: center; justify-content: center;
  font: 600 12px/1 var(--k-sans); letter-spacing: .04em; font-variant-numeric: tabular-nums; color: var(--k-ink-2);
}
html[data-kindle] .kp-foot {
  position: absolute; bottom: 0; z-index: 2;
  left: env(safe-area-inset-left, 0px); right: env(safe-area-inset-right, 0px);
  height: calc(var(--safe-b) + var(--kp-foot)); padding: 0 max(12px, var(--kp-edge, 24px)) var(--safe-b);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  font: 500 12px/1 var(--k-sans); color: var(--k-ink-2); font-variant-numeric: tabular-nums;
}
html[data-kindle] .kp-left { flex: 1; min-width: 0; height: 100%; padding: 0; text-align: left; font: inherit; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-kindle] .kp-pct { flex: none; }

/* the page: one column of the flow (two side by side in a spread), its margins inside it */
html[data-kindle] .kp-page {
  position: absolute;
  top: calc(var(--safe-t) + var(--kp-top));
  bottom: calc(var(--safe-b) + var(--kp-foot) + var(--kp-player-h, 0px));
  left: env(safe-area-inset-left, 0px); right: env(safe-area-inset-right, 0px);
  overflow: hidden; touch-action: none; outline: none;
}
/* a spread: a hairline down the middle, the book's spine */
html[data-kindle] .kp-page.spread::after { content: ""; position: absolute; top: 3%; bottom: 3%; left: 50%; width: 1px; background: var(--k-rule); pointer-events: none; }
html[data-kindle] .kp-flow {
  position: absolute; top: 0; /* left, width, height, padding, column count and width: lib/kindle.js */
  overflow: hidden; column-gap: 0; column-fill: auto;
  font-family: var(--k-read-font); font-size: var(--k-read-size); line-height: var(--k-read-lh);
  font-weight: var(--k-read-weight, 400); -webkit-text-stroke: var(--k-read-stroke, 0px) currentColor;
  color: var(--k-ink); text-align: var(--k-read-align);
  font-kerning: normal; font-variant-ligatures: common-ligatures; text-rendering: optimizeLegibility;
  -webkit-hyphens: auto; hyphens: auto; overflow-wrap: break-word;
  scrollbar-width: none;
}
html[data-kindle] .kp-flow::-webkit-scrollbar { display: none; }
html[data-kindle] .kp-flow > * { margin-left: var(--kp-m); margin-right: var(--kp-m); }
/* a blank page that completes the last spread */
html[data-kindle] .kp-fill { break-before: column; -webkit-column-break-before: always; height: 1px; }

/* ---------- the chapter opener: photo, kicker, centred title, dek, byline ---------- */
html[data-kindle] .kp-opener { text-align: center; -webkit-hyphens: manual; hyphens: manual; }
html[data-kindle] .kp-opener.noimg { padding-top: calc(var(--kp-h) * .14); }
html[data-kindle] .kp-opener .nx-art-img {
  width: auto; max-width: none; height: calc(var(--kp-h) * .4); aspect-ratio: auto;
  margin: 0 0 1.1em; border-radius: 0; box-shadow: none; break-inside: avoid;
}
html[data-kindle] .kp-opener .nx-art-img img { width: 100%; height: 100%; object-fit: cover; }
html[data-kindle] .kp-opener .nx-art-head { max-width: none; margin: 0; padding: 0; text-align: center; }
html[data-kindle] .kp-opener .nx-art-head .k { font: 700 .62em/1.3 var(--k-sans); letter-spacing: .22em; text-transform: uppercase; color: var(--k-ink-2); -webkit-text-stroke: 0; }
html[data-kindle] .kp-opener .nx-art-head h1 { font: 700 1.48em/1.18 var(--k-read-font); letter-spacing: -.005em; margin: .4em 0 .45em; text-wrap: balance; }
html[data-kindle] .kp-opener .nx-art-head .d { font: italic 400 .94em/1.45 var(--k-read-font); color: var(--k-ink-2); text-wrap: balance; }
html[data-kindle] .kp-opener .nx-meta { justify-content: center; margin-top: 1.1em; font: 500 .64em/1.4 var(--k-sans); color: var(--k-ink-2); -webkit-text-stroke: 0; }
html[data-kindle] .kp-opener .nx-meta b { color: var(--k-ink); }
/* a Build story the site would not show: the summary note under the byline, as the scrolling page has it */
html[data-kindle] .kp-opener .banner { margin: 1.1em 0 0; padding: 10px 12px; text-align: left; font-family: var(--k-sans); -webkit-text-stroke: 0; break-inside: avoid; -webkit-column-break-inside: avoid; }
/* a short rule between the opening and the text, as a printed chapter has */
html[data-kindle] .kp-opener::after { content: ""; display: block; width: 2.6em; height: 1px; margin: 1.25em auto 1.45em; background: var(--k-ink-3); }

/* ---------- book typography on the page ---------- */
html[data-kindle] .kp .nx-body { padding-top: 0; font: inherit; line-height: inherit; text-align: var(--k-read-align); color: inherit; }
html[data-kindle] .kp .nx-body .nx-p {
  margin: 0 -6px; padding: 0 6px; border-radius: 0; transition: none;
  text-indent: var(--k-read-indent, 1.5em); widows: 2; orphans: 2; text-wrap: pretty;
  hanging-punctuation: first allow-end last;
}
/* no indent where a gap or a heading already marks the start */
html[data-kindle] .kp .nx-body .nx-p:is(:first-child, .h, .quote, .bio),
html[data-kindle] .kp .nx-body .nx-p:is(.h, .quote) + .nx-p { text-indent: 0; }
/* the chapter's first line in small capitals */
html[data-kindle] .kp .nx-body > .nx-p:first-child:not(.h, .quote)::first-line { font-variant-caps: small-caps; letter-spacing: .03em; }
html[data-kindle] .kp .nx-body .nx-p.h {
  font-weight: 700; font-size: 1.08em; line-height: 1.3; text-align: left; -webkit-hyphens: manual; hyphens: manual;
  margin-top: 1.1em; margin-bottom: .4em; break-after: avoid; -webkit-column-break-after: avoid; break-inside: avoid;
}
html[data-kindle] .kp .nx-body .nx-p.quote { font-style: italic; margin: .6em -6px .6em 1.1em; padding: 0 6px; border: 0; border-radius: 0; text-align: left; }
html[data-kindle] .kp .nx-body .nx-p.bio { font-size: .84em; font-style: italic; text-align: left; margin-top: 1.4em; padding-top: .7em; border-top: 1px solid var(--k-rule-2); border-radius: 0; }

/* the Kindle "Bold" level, on the scrolling page too */
html[data-kindle] .k-read .nx-body { -webkit-text-stroke: var(--k-read-stroke, 0px) currentColor; }

/* ---------- Word Wise: a small hint above each saved word ---------- */
/* a little more leading makes the room; the hint never covers a line and never takes a tap of its own
   (a tap on it is a tap on its word); a word with a hint is not hyphenated, so the hint stays on it */
html[data-kindle] .k-read .nx-body.k-ww { line-height: calc(var(--k-read-lh, 1.62) + .32); }
html[data-kindle] .k-read .nx-body.k-ww .nx-p.h { line-height: 1.62; }
html[data-kindle] .k-read .nx-body.k-ww .wd[data-ww] { position: relative; -webkit-hyphens: manual; hyphens: manual; }
html[data-kindle] .k-read .nx-body.k-ww .wd[data-ww]::before {
  content: attr(data-ww);
  position: absolute; left: 50%; bottom: 100%;
  transform: translate(-50%, .12em);
  max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 .5em/1.15 var(--k-sans); font-style: normal; letter-spacing: .01em;
  text-indent: 0; text-align: center; text-transform: none; text-decoration: none;
  color: var(--k-ink-2); background: none; -webkit-text-stroke: 0;
  -webkit-user-select: none; user-select: none;
}
/* on a page the hint stays on its page: lib/kindle.js (measure) moves one that would reach past the
   page's edge (into the next page's margin, or across the spine) back in by --ww-dx */
html[data-kindle] .kp .nx-body.k-ww .wd[data-ww]::before { transform: translate(calc(-50% + var(--ww-dx, 0px)), .12em); }

/* ---------- the page after the last: "Before you go…" ---------- */
html[data-kindle] .kp-end {
  break-before: column; -webkit-column-break-before: always;
  padding-top: calc(var(--kp-h) * .07);
  font: 400 15px/1.45 var(--k-sans); text-align: left; -webkit-text-stroke: 0; -webkit-hyphens: manual; hyphens: manual;
}
html[data-kindle] .kp-end-k { font: 700 11px/1.2 var(--k-sans); letter-spacing: .2em; text-transform: uppercase; color: var(--k-ink-2); }
html[data-kindle] .kp-end-h { font: 700 26px/1.2 var(--k-book); margin: 8px 0 4px; }
html[data-kindle] .kp-end-t { font: italic 400 15px/1.4 var(--k-book); color: var(--k-ink-2); margin-bottom: 16px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
html[data-kindle] .kp-end-list { border-top: 1px solid var(--k-ink); }
html[data-kindle] .kp-end-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 2px; text-align: left; color: var(--k-ink); border-bottom: 1px solid var(--k-rule-2); }
html[data-kindle] .kp-end-row > svg { width: 22px; height: 22px; flex: none; }
html[data-kindle] .kp-end-row > svg.chev { width: 18px; height: 18px; color: var(--k-ink-2); }
html[data-kindle] .kp-end-row b { display: block; font-size: 15px; font-weight: 700; }
html[data-kindle] .kp-end-row small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--k-ink-2); }
html[data-kindle] .kp-end-src .nx-src { margin-top: 0; }
/* "Original ↗" stays in one piece */
html[data-kindle] .kp-end-src .nx-src a { flex: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
html[data-kindle] .kp-end-back { margin-top: 16px; }

/* ---------- the e-ink redraw of a page turn ---------- */
/* soft: the old page's ghost (a copy of the flow) fading out in steps; flash: ink, then paper */
html[data-kindle] .kp-ghost { position: absolute; inset: 0; pointer-events: none; visibility: hidden; }
html[data-kindle] .kp-flash { position: absolute; inset: 0; z-index: 9; pointer-events: none; background: var(--k-ink); }
html[data-kindle] .kp-flash.paper { background: var(--k-paper); }

/* ---------- the toolbar (a tap at the top of the page) ---------- */
html[data-kindle] .kp-bar { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; }
html[data-kindle] .kp-bar-top {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 2px;
  padding: calc(var(--safe-t) + 4px) max(6px, calc(var(--kp-edge, 24px) - 10px)) 4px;
  background: var(--k-paper); border-bottom: 1px solid var(--k-ink);
}
html[data-kindle] .kp-scrim { flex: 1; }
html[data-kindle] .kp-bar-bot {
  display: grid; gap: 10px;
  padding: 12px max(12px, var(--kp-edge, 24px)) calc(var(--safe-b) + 10px);
  background: var(--k-paper); border-top: 1px solid var(--k-ink);
}
/* the Listen strip stays in view under the toolbar */
html[data-kindle] .kp.has-player .kp-bar-bot { padding-bottom: calc(var(--safe-b) + var(--kp-foot) + var(--kp-player-h, 0px) + 8px); }
html[data-kindle] .kp-tb { height: 44px; min-width: 44px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; border-radius: 8px; color: var(--k-ink); font: 700 14px/1 var(--k-sans); }
html[data-kindle] .kp-tb svg { width: 22px; height: 22px; }
html[data-kindle] .kp-aa { font: 400 22px/1 var(--k-book); letter-spacing: -.02em; }
html[data-kindle] .kp-ttl { min-width: 0; padding: 0 6px; text-align: center; font: 700 14.5px/1.25 var(--k-sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-kindle] .kp-scrub-row { display: grid; gap: 4px; width: 100%; max-width: 640px; margin: 0 auto; }
html[data-kindle] .kp-scrub-l { font: 600 12.5px/1.2 var(--k-sans); color: var(--k-ink-2); text-align: center; font-variant-numeric: tabular-nums; }
html[data-kindle] .kp-scrub { width: 100%; margin: 0; }
html[data-kindle] .kp-acts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; width: 100%; max-width: 560px; margin: 0 auto; }
html[data-kindle] .kp-act { position: relative; min-width: 0; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 8px; font: 700 11px/1 var(--k-sans); color: var(--k-ink); white-space: nowrap; }
html[data-kindle] .kp-act svg { width: 22px; height: 22px; }
html[data-kindle] .kp-act .nx-badge { top: 3px; right: calc(50% - 25px); }
html[data-kindle] .kp-act.on { background: var(--k-shade); box-shadow: inset 0 0 0 1px var(--k-ink); }
/* the Kindle press flash on the reader's own controls */
html[data-kindle] :where(.kp-tb, .kp-act, .kp-end-row, .kd-opt, .kd-font, .kd-step, .kd-tick):active:not(:disabled) { background: var(--k-invert-bg); color: var(--k-invert-fg); box-shadow: none; }
html[data-kindle] :where(.kp-act, .kp-end-row, .kd-opt, .kd-font):active:not(:disabled) :where(small, .chev, .nm) { color: inherit; }
html[data-kindle] .kd-tick:active:not(:disabled) i { background: currentColor; }

/* "Aa" in the reader's action bar, where Text size was */
html[data-kindle] .nx-act .nx-aa { height: 22px; font: 400 21px/22px var(--k-book); letter-spacing: -.02em; }

/* ---------- Listen: a slim strip above the progress line while the pages show ---------- */
html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player {
  left: env(safe-area-inset-left, 0px); right: env(safe-area-inset-right, 0px); bottom: calc(var(--safe-b) + var(--kp-foot)); z-index: 47;
  max-width: none; margin: 0; padding: 5px max(8px, calc(var(--kp-edge, 24px) - 8px));
  border-width: 1px 0; border-style: solid; border-color: var(--k-ink); border-radius: 0;
  column-gap: 8px; row-gap: 2px; animation: none;
}
html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player .nx-play { width: 36px; height: 36px; }
html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player .nx-play svg { width: 18px; height: 18px; }
html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player .nx-pctl .icon-btn,
html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player > .icon-btn { width: 34px; height: 34px; }
html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player .nx-speed button { width: 28px; height: 28px; }
@media (max-width: 699px) {
  html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player .nx-plabel { display: none; }
}
@media (min-width: 700px) {
  /* one row: play · position · controls · close */
  html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player .nx-pctl { grid-column: 3; grid-row: 1; }
  html[data-kindle] body.kindle-reader:not(.kindle-study) .nx-player > .icon-btn { grid-column: 4; grid-row: 1; }
}

/* ---------- "Aa": the display settings sheet ---------- */
/* no wash behind it: the page shows each change as it is made */
html[data-kindle] .backdrop.kd-back.on { opacity: 0; }
html[data-kindle] .kd-head { display: flex; align-items: center; gap: 10px; }
html[data-kindle] .kd-head .sheet-title { margin: 0; }
html[data-kindle] .kd-aa { font: 400 26px/1 var(--k-book); letter-spacing: -.02em; }
html[data-kindle] .kd-body { display: grid; gap: 10px; align-content: start; min-height: 290px; }
html[data-kindle] .kd-lbl { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 4px; font: 700 11.5px/1.2 var(--k-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--k-ink-2); }
html[data-kindle] .kd-lbl .k-val { letter-spacing: 0; }
html[data-kindle] .kd-desc { font-size: 12.5px; line-height: 1.4; color: var(--k-ink-2); }
html[data-kindle] p.kd-desc { margin-top: -4px; }
html[data-kindle] .kd-ttl { font-size: 15px; font-weight: 700; }
html[data-kindle] .kd-row { display: flex; align-items: center; gap: 12px; padding: 10px 0 2px; border-top: 1px solid var(--k-rule); }
html[data-kindle] .kd-fonts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
html[data-kindle] .kd-font { height: 72px; display: grid; place-content: center; justify-items: center; gap: 5px; border: 1px solid var(--k-rule-2); border-radius: 8px; color: var(--k-ink); }
html[data-kindle] .kd-font .aa { font-size: 26px; line-height: 1; }
html[data-kindle] .kd-font .nm { font: 600 11.5px/1 var(--k-sans); }
html[data-kindle] :is(.kd-font, .kd-opt).on { border: 2px solid var(--k-ink); background: var(--k-shade); }
/* the chosen one pressed again flashes like the rest (on its grey the paper label would vanish) */
html[data-kindle] :is(.kd-font, .kd-opt).on:active:not(:disabled) { background: var(--k-invert-bg); }
html[data-kindle] .kd-size { display: flex; align-items: center; gap: 8px; }
html[data-kindle] .kd-step { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 1px solid var(--k-rule-2); border-radius: 8px; color: var(--k-ink); font-family: var(--k-book); }
html[data-kindle] .kd-step .sm { font-size: 14px; }
html[data-kindle] .kd-step .lg { font-size: 24px; }
html[data-kindle] .kd-step:disabled { color: var(--k-ink-3); }
html[data-kindle] .kd-ticks { flex: 1; min-width: 0; height: 40px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); }
html[data-kindle] .kd-tick { height: 100%; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 7px; border-radius: 4px; }
html[data-kindle] .kd-tick i { display: block; width: 2px; height: calc(7px + var(--i) * 2px); background: var(--k-ink-3); }
html[data-kindle] .kd-tick.on i { width: 6px; background: var(--k-ink); }
html[data-kindle] .kd-preview {
  padding: 10px 12px; border: 1px solid var(--k-rule); border-radius: 8px; color: var(--k-ink);
  font-family: var(--k-read-font); font-size: var(--k-read-size); font-weight: var(--k-read-weight, 400); line-height: 1.35;
  -webkit-text-stroke: var(--k-read-stroke, 0px) currentColor; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html[data-kindle] .kd-opts { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 8px; }
html[data-kindle] .kd-opt { min-height: 64px; padding: 8px 4px; display: grid; justify-items: center; align-content: center; gap: 6px; border: 1px solid var(--k-rule-2); border-radius: 8px; font: 600 12px/1 var(--k-sans); color: var(--k-ink); }
html[data-kindle] .kd-bold .kd-opt { min-height: 56px; }
html[data-kindle] .kd-bold .b { font: 400 22px/1 var(--k-book); -webkit-text-stroke: calc(var(--b, 0px) * 2) currentColor; }
/* the little pages that show spacing, margins and alignment */
html[data-kindle] .kd-lines { width: 36px; height: 26px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 3px; }
html[data-kindle] .kd-lines i { display: block; height: 2px; background: currentColor; }
html[data-kindle] .kd-lines.sp-tight { gap: 2px; }
html[data-kindle] .kd-lines.sp-wide { gap: 6px; }
html[data-kindle] .kd-lines:is(.m-narrow, .m-normal, .m-wide) { border-left: 1px solid var(--k-ink-3); border-right: 1px solid var(--k-ink-3); }
html[data-kindle] .kd-lines.m-narrow { padding: 0 2px; }
html[data-kindle] .kd-lines.m-normal { padding: 0 6px; }
html[data-kindle] .kd-lines.m-wide { padding: 0 10px; }
html[data-kindle] .kd-lines.al-left i:nth-child(2) { width: 72%; }
html[data-kindle] .kd-lines.al-left i:nth-child(3) { width: 88%; }
html[data-kindle] .kd-lines:is(.al-left, .al-justify) i:last-child { width: 50%; }
html[data-kindle] .kd-slider { display: grid; gap: 2px; }
html[data-kindle] .kd-exit { margin-top: 4px; }
