/* Web editions of Watarrka Waterhole Wildlife (book + species guide) */

:root {
  --paper: #f7f3ec;
  --paper-2: #efe8dc;
  --card: #fffdf9;
  --ink: #2b2620;
  --ink-2: #5d544a;
  --ink-3: #8a7f72;
  --rule: #ddd3c4;
  --accent: #a9522a;
  --accent-ink: #8c4220;
  --shadow: 0 1px 2px rgb(60 40 20 / 8%), 0 6px 20px rgb(60 40 20 / 8%);

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua',
    Georgia, serif;
  --sans: Optima, Candara, 'Segoe UI', 'Noto Sans', 'Gill Sans', system-ui,
    sans-serif;

  --measure: 38rem;
  --wide: 62rem;
  --sidebar: 17rem;
  --bar-h: 3.25rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #1a1714;
    --paper-2: #24201b;
    --card: #221e1a;
    --ink: #ebe4d9;
    --ink-2: #bdb3a5;
    --ink-3: #8f8577;
    --rule: #3a342c;
    --accent: #e0905f;
    --accent-ink: #eba67c;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #1a1714;
  --paper-2: #24201b;
  --card: #221e1a;
  --ink: #ebe4d9;
  --ink-2: #bdb3a5;
  --ink-3: #8f8577;
  --rule: #3a342c;
  --accent: #e0905f;
  --accent-ink: #eba67c;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h) + 1rem);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- top bar ------------------------------------------------------------ */

.sitebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
}
.sitebar-title {
  color: var(--accent);
  text-decoration: none;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.sitebar-links {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}
.sitebar-links a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
}
.sitebar-links a:hover {
  color: var(--ink);
  background: var(--paper-2);
}
.sitebar-links a[aria-current='page'] {
  color: var(--ink);
  background: var(--paper-2);
}

/* ---- book layout -------------------------------------------------------- */

.layout {
  display: block;
}

.toc {
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.35;
}
.toc-heading {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc > ol > li {
  margin-bottom: 0.15rem;
}
.toc ol ol {
  margin: 0.1rem 0 0.4rem 0.75rem;
  border-left: 1px solid var(--rule);
}
.toc a {
  display: block;
  padding: 0.28rem 0.6rem;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: 6px;
}
.toc > ol > li > a {
  color: var(--ink);
}
.toc ol ol a {
  font-size: 0.85rem;
  border-radius: 0 6px 6px 0;
  margin-left: -1px;
  border-left: 2px solid transparent;
}
.toc a:hover {
  background: var(--paper-2);
}
.toc a.active {
  color: var(--accent-ink);
  background: var(--paper-2);
}
.toc ol ol a.active {
  border-left-color: var(--accent);
}

.toc-toggle {
  position: fixed;
  z-index: 30;
  right: 1rem;
  bottom: 1rem;
  font: inherit;
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}

@media (max-width: 1099px) {
  .toc {
    position: fixed;
    z-index: 25;
    top: var(--bar-h);
    bottom: 0;
    left: 0;
    width: min(22rem, 88vw);
    padding: 1.25rem 1rem 5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--card);
    border-right: 1px solid var(--rule);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    visibility: hidden;
  }
  .toc-open .toc {
    transform: none;
    visibility: visible;
  }
}

@media (min-width: 1100px) {
  .toc-toggle {
    display: none;
  }
  .layout {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
  }
  .toc {
    position: sticky;
    top: var(--bar-h);
    height: calc(100vh - var(--bar-h));
    overflow-y: auto;
    padding: 1.5rem 0.75rem 3rem 1rem;
    border-right: 1px solid var(--rule);
    scrollbar-width: thin;
  }
}

.book {
  padding: 0 1rem 4rem;
}
.book > *,
.chapter > * {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
}
.book > .chapter {
  max-width: none;
}

/* title page */
.titlepage {
  text-align: center;
  padding-top: 3rem;
  max-width: var(--wide) !important;
}
.titlepage h1,
.landing-intro h1,
.guide-intro h1 {
  font-family: var(--sans);
  font-weight: 400;
  color: var(--accent);
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.1;
  margin: 0 0 0.4rem;
  letter-spacing: -0.005em;
}
.byline {
  font-family: var(--sans);
  font-size: 1.2rem;
  color: var(--ink-2);
  margin: 0 0 2rem;
}
.cover {
  margin: 0;
}
.cover img {
  margin: 0 auto;
  max-width: 48rem;
  width: 100%;
  border-radius: 4px;
}

.copyright {
  margin-top: 3rem !important;
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.copyright .nla {
  max-width: 300px;
  margin: 0.75rem 0;
  border-radius: 2px;
}

/* headings */
.chapter-title {
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(1.75rem, 4vw, 2.3rem);
  line-height: 1.2;
  color: var(--accent);
  margin-top: 4.5rem;
  margin-bottom: 1.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.section-title {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1.3;
  margin-top: 3rem;
  margin-bottom: 0.75rem;
}
.section-title i,
.chapter-title i {
  font-family: var(--serif);
  font-size: 0.85em;
  color: var(--ink-2);
}

.book p {
  margin-top: 0;
  margin-bottom: 1.1em;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.book p.caption {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink-2);
}

/* photos break out of the text column */
.photo {
  max-width: var(--wide) !important;
  margin: 2.25rem auto;
}
.photo-link {
  display: block;
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper-2);
}
.photo img {
  width: 100%;
}
.photo figcaption {
  max-width: var(--measure);
  margin: 0.75rem auto 0;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.references {
  list-style: none;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}
.references li {
  margin-bottom: 0.7em;
  padding-left: 1.5em;
  text-indent: -1.5em;
}

/* species list + indexes */
.species-list {
  columns: 2 16rem;
  column-gap: 2rem;
}
.species-list-group {
  break-inside: avoid-column;
}
.species-list h3 {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 1.15rem;
  color: var(--accent);
  margin: 1.25rem 0 0.4rem;
}
.species-list ul,
.book-index {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
}
.species-list li {
  margin-bottom: 0.3rem;
}
.book-index {
  columns: 2 16rem;
  column-gap: 2rem;
}
.book-index li {
  break-inside: avoid;
  margin-bottom: 0.45rem;
}
.index-refs {
  display: block;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-3);
}

.book-footer {
  margin-top: 5rem !important;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-3);
  text-align: center;
}

/* ---- species guide ------------------------------------------------------ */

.guide {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 1rem 4rem;
}
.guide-intro {
  padding: 2.5rem 0 1rem;
  max-width: 46rem;
}
.guide-intro p {
  color: var(--ink-2);
  margin: 0.5rem 0 0;
}

.guide-tools {
  position: sticky;
  top: var(--bar-h);
  z-index: 10;
  background: var(--paper);
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  gap: 0.6rem;
}
.search input {
  width: 100%;
  font: inherit;
  font-family: var(--sans);
  font-size: 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
}
.search input::placeholder {
  color: var(--ink-3);
}
.chips {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar {
  display: none;
}
.chips a {
  flex-shrink: 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  text-decoration: none;
  background: var(--card);
}
.chips a:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}
@media (min-width: 800px) {
  .guide-tools {
    grid-template-columns: minmax(16rem, 24rem) 1fr;
    align-items: center;
  }
}

.guide .no-results {
  color: var(--ink-2);
  padding: 2rem 0;
}

.guide-group {
  scroll-margin-top: calc(var(--bar-h) + 7.5rem);
}
.guide-group > h2 {
  font-family: var(--sans);
  font-weight: 400;
  color: var(--accent);
  font-size: 1.8rem;
  margin: 2.75rem 0 1rem;
}
.count {
  font-size: 0.9rem;
  color: var(--ink-3);
  vertical-align: middle;
  margin-left: 0.25rem;
}

.sp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 1.25rem;
}
.sp-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  scroll-margin-top: calc(var(--bar-h) + 7.5rem);
}
.sp-photo {
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--paper-2);
  overflow: hidden;
}
.sp-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.sp-photo:hover img {
  transform: scale(1.03);
}
.sp-body {
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.sp-name {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.25;
  margin: 0;
}
.sp-indigenous {
  font-family: var(--sans);
  color: var(--accent-ink);
  font-size: 0.95rem;
  margin: 0.1rem 0 0;
}
.sp-sci {
  margin: 0.1rem 0 0;
  color: var(--ink-2);
  font-size: 1rem;
}
.sp-aka {
  margin: 0.25rem 0 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-3);
}
.sp-caption {
  margin: 0.7rem 0 0.8rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink-2);
}
.sp-more {
  margin-top: auto;
  font-family: var(--sans);
  font-size: 0.85rem;
  align-self: flex-start;
}

.sp-others {
  margin-top: 1.75rem;
}
.sp-others h3 {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}
.sp-others .note {
  color: var(--ink-3);
  font-size: 0.85rem;
}
.sp-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  column-gap: 2rem;
  border-top: 1px solid var(--rule);
}
.sp-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: calc(var(--bar-h) + 7.5rem);
}
.sp-row-name {
  font-family: var(--sans);
  font-size: 1rem;
}
.sp-row-name .sp-indigenous {
  font-size: 0.88rem;
  margin-left: 0.15rem;
}
.sp-row-sci {
  color: var(--ink-2);
  font-size: 0.95rem;
}
.sp-row-more {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 0.8rem;
}

[hidden] {
  display: none !important;
}

/* ---- landing ------------------------------------------------------------ */

.landing {
  max-width: 64rem;
  margin: 0 auto;
  padding: 3rem 1rem 4rem;
}
.landing-intro {
  text-align: center;
  max-width: 40rem;
  margin: 0 auto 2.5rem;
}
.landing-intro .byline {
  margin-bottom: 1rem;
}
.landing-intro p:last-child {
  color: var(--ink-2);
}
.landing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1.5rem;
}
.landing-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  color: var(--ink-2);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.landing-card:hover {
  transform: translateY(-2px);
  color: var(--ink-2);
}
.landing-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.landing-card-body {
  padding: 1rem 1.25rem 1.35rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.5;
  display: grid;
  gap: 0.3rem;
}
.landing-card-title {
  font-size: 1.35rem;
  color: var(--accent);
}

@media (max-width: 520px) {
  body {
    font-size: 1.0625rem;
  }
  .sitebar-title {
    font-size: 0.95rem;
  }
  .sitebar-links a {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
  }
}

@media print {
  .sitebar,
  .toc,
  .toc-toggle,
  .guide-tools {
    display: none !important;
  }
  .layout {
    display: block;
  }
}
