/* NANPA Guide to Responsible Nature Photography, Chapter 1 reader
   NANPA palette: #005598 blue, #72A2CE light blue, #81C241 green, #69973F dark green,
   #231F20 near black, #4F585B / #8D989C / #C1C4C6 grays, #F1F1F1 light gray.
   Type: Fraunces for titles, Montserrat for everything else. */
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/montserrat-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/montserrat-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/montserrat-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/montserrat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/fraunces-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/fraunces-latin-600-normal.woff2") format("woff2"); }
:root {
  --blue: #005598;
  --blue-dark: #00457c;
  --sky: #72A2CE;
  --green: #81C241;
  --green-dark: #69973F;
  --ink: #231F20;
  --slate: #4F585B;
  --gray: #8D989C;
  --line: #C1C4C6;
  --paper: #F1F1F1;
  --white: #fff;
  --bar-h: 64px;
  --font: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --title: "Fraunces", Georgia, serif;
  --text-scale: 1;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--white);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--blue); color: var(--white); padding: 10px 16px; border-radius: 999px;
  font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; }

/* Stage */
#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--white);
}
#book-host { position: relative; width: 100%; height: 100%; }
.book { margin: 0 auto; }
.page { background: var(--white); overflow: hidden; }
.page img {
  display: block; width: 100%; height: 100%; object-fit: contain;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.page.hard { background: var(--white); }
.noscript { max-width: 36em; text-align: center; }

/* Zoom view */
#zoom-view {
  position: absolute; inset: 0; overflow: auto; background: var(--paper);
  padding: 16px; outline: none;
}
#zoom-view:focus-visible { box-shadow: inset 0 0 0 3px var(--sky); }
#zoom-view .spread { display: flex; gap: 0; margin: 0 auto; width: max-content; box-shadow: 0 2px 18px rgba(35,31,32,.18); }
#zoom-view img { display: block; height: auto; background: var(--white); }

/* Bar */
.bar {
  flex: 0 0 auto;
  min-height: var(--bar-h);
  background: var(--blue);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  outline: none;
}
.brand { display: flex; flex-direction: column; line-height: 1.05; flex: 0 0 auto; }
.brand-title { font-family: var(--title); font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.brand-sub { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; justify-content: center; }
.group { display: inline-flex; align-items: center; gap: 6px; }
.lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.where { margin: 0 0 0 auto; font-size: 14px; font-weight: 500; white-space: nowrap; flex: 0 0 auto; min-width: 6.4em; text-align: right; }

.pill {
  appearance: none; border: 1px solid transparent; border-radius: 999px;
  background: var(--white); color: var(--blue);
  font: 500 14px/1 var(--font);
  min-height: 36px; padding: 0 13px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .15s ease, color .15s ease;
}
.pill:hover { background: #e7f0f8; }
.pill:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.pill:disabled { background: var(--line); color: var(--slate); cursor: default; }
.pill.round { width: 36px; padding: 0; font-size: 18px; }
.pill.green { background: var(--green); color: var(--ink); }
.pill.green:hover { background: #95cf5c; }
.pill.select {
  padding-right: 34px; color: var(--blue);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23005598' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  width: 10em; text-overflow: ellipsis;
}
#sel-view { width: 8.6em; }
.pill.small { min-height: 32px; padding: 0 12px; font-size: 13px; }

/* Panels */
dialog.panel {
  border: 0; padding: 0; color: var(--ink); background: var(--white);
  width: min(560px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  margin: 0 0 0 auto; box-shadow: -8px 0 32px rgba(35,31,32,.22);
  display: none; flex-direction: column;
}
dialog.panel[open] { display: flex; }
dialog.panel.narrow { width: min(420px, 100vw); }
dialog::backdrop { background: rgba(35,31,32,.35); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--paper);
}
.panel-head h2 { font-family: var(--title); font-weight: 600; font-size: 22px; color: var(--blue); margin: 0; }
.panel-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.panel-tools .pill { border-color: var(--line); }
.panel-body { flex: 1 1 auto; overflow: auto; padding: 20px 24px 40px; outline: none; }
.panel-body:focus-visible { box-shadow: inset 0 0 0 3px var(--sky); }

/* Read Text */
#text-body { font-size: calc(16px * var(--text-scale)); line-height: 1.6; }
#text-body section + section { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 20px; }
#text-body .pagelabel { font-size: .75em; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--slate); margin: 0 0 8px; }
#text-body h3 { font-family: var(--title); font-weight: 600; color: var(--blue); font-size: 1.45em; line-height: 1.2; margin: .6em 0 .4em; }
#text-body h4 { font-family: var(--title); font-weight: 600; color: var(--blue); font-size: 1.15em; line-height: 1.25; margin: 1.1em 0 .3em; }
#text-body h5 { font-size: 1em; font-weight: 600; color: var(--blue); margin: 1em 0 .2em; }
#text-body p { margin: 0 0 .85em; }
#text-body p.small { font-size: .82em; color: var(--slate); }
#text-body blockquote { margin: 1em 0; padding: 14px 18px; background: var(--paper); border-left: 4px solid var(--green-dark); font-family: var(--title); font-weight: 500; }
#text-body blockquote p:last-child { margin-bottom: 0; }
#text-body ul { padding-left: 1.2em; margin: 0 0 1em; }
#text-body li { margin-bottom: .4em; }
#text-body .alt { font-style: italic; color: var(--slate); }
#text-body ul.toc, #text-body ul.names { list-style: none; padding: 0; }
#text-body ul.toc li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted var(--line); padding: 4px 0; margin: 0; }
#text-body a { color: var(--blue); }

/* Contents and About */
ol.toc { list-style: none; margin: 0; padding: 0; }
ol.toc li { border-bottom: 1px solid var(--line); }
ol.toc button {
  all: unset; box-sizing: border-box; cursor: pointer; width: 100%;
  display: flex; justify-content: space-between; gap: 16px; padding: 12px 4px;
  font: 500 15px/1.35 var(--font); color: var(--ink);
}
ol.toc button:hover { color: var(--blue); }
ol.toc button:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
ol.toc .pg { color: var(--slate); font-variant-numeric: tabular-nums; }
.prose h3 { font-family: var(--title); font-weight: 600; color: var(--blue); font-size: 18px; margin: 1.4em 0 .4em; }
.prose p { margin: 0 0 1em; }
.prose .small { font-size: 13px; color: var(--slate); }
.prose a { color: var(--blue); font-weight: 500; }
.links { padding-left: 1.1em; }

/* Narrow screens */
@media (max-width: 1360px) {
  .brand { display: none; }
}
@media (max-width: 1040px) {
  .bar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .brand { display: none; }
  .tools { order: 2; flex-basis: 100%; }
  .where { order: 1; margin: 0 auto; text-align: center; min-width: 0; }
  .view-group .lbl { display: none; }
}
@media (max-width: 700px) {
  #stage { padding: 8px; }
  .view-group, #btn-full, #sel-page { display: none; }
  .zoom-group .pill.round, #btn-fit { width: 40px; padding: 0; }
  .tools { gap: 6px; }
  .pill { padding: 0 12px; font-size: 13px; min-height: 40px; }
}
@media (max-width: 360px) {
  .pill { padding: 0 9px; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
