/* --------------------------------------------------------------------------
   Psychometrics book — reading-first visual system
   -------------------------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@500;600;700&family=Literata:opsz,wght@7..72,400;7..72,500;7..72,600&display=swap');

:root {
  --book-bg: #fbfaf7;
  --book-surface: #ffffff;
  --book-surface-soft: #f3f5f2;
  --book-text: #27343d;
  --book-text-soft: #66727a;
  --book-heading: #0b2d3b;
  --book-accent: #176b65;
  --book-accent-soft: #dcebe6;
  --book-secondary: #7a7897;
  --book-coral: #c9665f;
  --book-gold: #a88a49;
  --book-border: #dce2df;
  --book-code-bg: #f4f5f2;
  --book-shadow: 0 12px 32px rgba(11, 45, 59, 0.08);
  --book-shadow-soft: 0 5px 18px rgba(11, 45, 59, 0.06);
}

body.quarto-dark {
  --book-bg: #071823;
  --book-surface: #0c2230;
  --book-surface-soft: #102a39;
  --book-text: #dfe7e8;
  --book-text-soft: #aab9be;
  --book-heading: #f0f5f4;
  --book-accent: #8fc8bd;
  --book-accent-soft: #173f43;
  --book-secondary: #b0aacb;
  --book-coral: #ef8f87;
  --book-gold: #d6bd7f;
  --book-border: #29414b;
  --book-code-bg: #091e2a;
  --book-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
  --book-shadow-soft: 0 5px 18px rgba(0, 0, 0, 0.18);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.25rem;
}

body {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  color: var(--book-text);
  background: var(--book-bg);
  font-size: 1.02rem;
  line-height: 1.74;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--book-accent-soft);
  color: var(--book-heading);
}

/* Reading column ---------------------------------------------------------- */

main.content {
  padding-bottom: 3.5rem;
}

#quarto-document-content {
  max-width: 820px;
}

#quarto-document-content p,
#quarto-document-content li {
  max-width: 74ch;
}

#quarto-document-content p {
  margin-bottom: 1.12rem;
}

#quarto-document-content li + li {
  margin-top: 0.34rem;
}

/* Type hierarchy ---------------------------------------------------------- */

h1, h2, h3, h4, h5, h6,
.sidebar-title,
.quarto-page-breadcrumbs,
.nav-page-text,
.quarto-title-meta,
.book-kicker,
.chapter-card,
.route-card,
.reading-meta,
.book-button {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--book-heading);
  letter-spacing: -0.025em;
  line-height: 1.2;
  font-weight: 650;
}

h2 {
  font-size: clamp(1.55rem, 2.1vw, 1.92rem);
  margin-top: 3.2rem;
  margin-bottom: 1.05rem;
  padding-top: 0.2rem;
}

h2::after {
  content: "";
  display: block;
  width: 2.65rem;
  height: 3px;
  margin-top: 0.6rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--book-accent), var(--book-secondary));
}

h3 {
  font-size: clamp(1.22rem, 1.7vw, 1.45rem);
  margin-top: 2.35rem;
  margin-bottom: 0.8rem;
}

h4 {
  font-size: 1.08rem;
  margin-top: 1.8rem;
}

/* Title block ------------------------------------------------------------- */

#title-block-header {
  position: relative;
  margin: 0 0 2.6rem;
  padding: 0.65rem 0 1.8rem;
  border-bottom: 1px solid var(--book-border);
}

#title-block-header::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: min(170px, 28%);
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--book-accent), var(--book-secondary), var(--book-coral));
}

#title-block-header .title {
  max-width: 19ch;
  margin-bottom: 0.6rem;
  color: var(--book-heading);
  font-family: "Inter", system-ui, sans-serif;
  font-size: clamp(2.15rem, 4.3vw, 3.55rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.045em;
}

#title-block-header .subtitle {
  color: var(--book-accent);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1.04rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

#title-block-header .description {
  max-width: 68ch;
  margin-top: 1rem;
  color: var(--book-text-soft);
  font-size: 1.03rem;
  line-height: 1.65;
}

.quarto-title-meta {
  margin-top: 1.5rem;
  color: var(--book-text-soft);
  font-size: 0.83rem;
}

.quarto-title-meta-heading {
  color: var(--book-text-soft);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chapter-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  height: 2.1rem;
  margin-right: 0.5rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  background: var(--book-accent-soft);
  color: var(--book-accent);
  font-family: "Inter", sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0;
  vertical-align: 0.3rem;
}

.chapter-reading-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin: -1.35rem 0 2.25rem;
  color: var(--book-text-soft);
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
}

.chapter-reading-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chapter-reading-meta span + span::before {
  content: "";
  width: 4px;
  height: 4px;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--book-gold);
}

.chapter-lead {
  max-width: 66ch !important;
  margin-bottom: 2rem !important;
  color: var(--book-heading);
  font-size: 1.16rem;
  line-height: 1.68;
}

/* Links ------------------------------------------------------------------- */

a,
a:link,
a:visited {
  color: var(--book-accent);
  text-decoration-color: color-mix(in srgb, var(--book-accent) 45%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover,
a:focus-visible {
  color: var(--book-coral);
  text-decoration-color: currentColor;
}

/* Figures and tables ------------------------------------------------------ */

.quarto-figure {
  margin: 2.15rem auto;
}

.quarto-figure img,
.figure-img {
  border-radius: 10px;
}

.quarto-figure-center > figure,
figure.quarto-float-fig {
  max-width: 100%;
}

figcaption,
.figure-caption,
.table-caption {
  margin-top: 0.65rem;
  color: var(--book-text-soft);
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  line-height: 1.48;
}

.table-responsive,
.quarto-float-tbl {
  margin: 1.8rem 0;
}

table {
  border-color: var(--book-border) !important;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.88rem;
}

thead {
  color: var(--book-heading);
}

thead th {
  border-bottom: 2px solid var(--book-accent) !important;
}

tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--book-surface-soft) 72%, transparent);
}

/* Code -------------------------------------------------------------------- */

code,
kbd,
pre,
.sourceCode {
  font-family: "Fira Code", "SFMono-Regular", Consolas, monospace;
}

code:not(.sourceCode) {
  padding: 0.14em 0.34em;
  border: 1px solid var(--book-border);
  border-radius: 5px;
  background: var(--book-code-bg);
  color: var(--book-coral);
  font-size: 0.88em;
}

div.sourceCode {
  overflow: hidden;
  margin: 1.55rem 0 1.85rem;
  border: 1px solid var(--book-border);
  border-radius: 12px;
  background: var(--book-code-bg);
  box-shadow: var(--book-shadow-soft);
}

pre.sourceCode {
  margin: 0;
  padding-top: 1rem;
  padding-bottom: 1rem;
  background: transparent !important;
  font-size: 0.82rem;
  line-height: 1.62;
}

.code-copy-button {
  margin: 0.45rem;
  border: 1px solid var(--book-border);
  border-radius: 7px;
  background: var(--book-surface) !important;
  color: var(--book-text-soft) !important;
}

.cell-output {
  margin: -0.75rem 0 1.8rem;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 3px solid var(--book-accent-soft);
}

.cell-output code {
  white-space: pre-wrap;
  border: 0;
  padding: 0;
}

/* Quotations, notes, lists ------------------------------------------------ */

blockquote {
  position: relative;
  margin: 1.8rem 0;
  padding: 1rem 1.25rem 1rem 1.45rem;
  border: 0;
  border-left: 4px solid var(--book-secondary);
  border-radius: 0 10px 10px 0;
  background: var(--book-surface-soft);
  color: var(--book-text);
  font-size: 1rem;
}

blockquote p:last-child {
  margin-bottom: 0;
}

hr {
  height: 1px;
  margin: 2.3rem 0;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--book-border) 12%, var(--book-border) 88%, transparent);
}

.callout {
  overflow: hidden;
  margin: 1.7rem 0;
  border: 1px solid var(--book-border) !important;
  border-radius: 12px !important;
  background: var(--book-surface) !important;
  box-shadow: var(--book-shadow-soft);
}

.callout-header {
  font-family: "Inter", sans-serif;
  font-weight: 700;
}

/* Sidebar and top chrome -------------------------------------------------- */

#quarto-sidebar {
  background: color-mix(in srgb, var(--book-bg) 94%, var(--book-surface));
  border-right: 1px solid var(--book-border);
}

.sidebar-title {
  color: var(--book-heading);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.32;
}

.sidebar-navigation .sidebar-item a,
.sidebar-navigation .sidebar-item .sidebar-item-text {
  color: var(--book-text-soft);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.83rem;
  line-height: 1.36;
}

.sidebar-navigation .sidebar-item a:hover {
  color: var(--book-heading);
}

.sidebar-navigation .sidebar-item a.active,
.sidebar-navigation .sidebar-item .active {
  color: var(--book-accent) !important;
  font-weight: 700;
}

.sidebar-navigation .sidebar-item-section > .sidebar-item-container {
  margin-top: 0.72rem;
}

.sidebar-navigation .sidebar-item-section > .sidebar-item-container .menu-text {
  color: var(--book-heading);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.quarto-secondary-nav {
  background: color-mix(in srgb, var(--book-bg) 92%, transparent);
  border-bottom: 1px solid var(--book-border);
  backdrop-filter: blur(12px);
}

.quarto-page-breadcrumbs {
  color: var(--book-text-soft);
  font-size: 0.76rem;
}

#quarto-margin-sidebar .nav-link {
  padding-top: 0.33rem;
  padding-bottom: 0.33rem;
  color: var(--book-text-soft);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.77rem;
  line-height: 1.32;
}

#quarto-margin-sidebar .nav-link.active {
  color: var(--book-accent);
  font-weight: 650;
  border-left-color: var(--book-accent);
}

/* Previous / next navigation --------------------------------------------- */

.page-navigation {
  gap: 0.8rem;
  margin-top: 3.4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--book-border);
}

.page-navigation .nav-page {
  min-height: 92px;
  padding: 1rem 1.15rem;
  border: 1px solid var(--book-border);
  border-radius: 13px;
  background: var(--book-surface);
  box-shadow: var(--book-shadow-soft);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.page-navigation .nav-page:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--book-accent) 55%, var(--book-border));
  box-shadow: var(--book-shadow);
}

.nav-page-text {
  color: var(--book-heading);
  font-size: 0.87rem;
  font-weight: 650;
}

.nav-page-previous .nav-page-text::before,
.nav-page-next .nav-page-text::before {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--book-text-soft);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-page-previous .nav-page-text::before { content: "Previous"; }
.nav-page-next .nav-page-text::before { content: "Next"; }

/* Home page --------------------------------------------------------------- */

.quarto-cover-image {
  display: none;
}

#overview > h1 {
  display: none;
}

.book-intro {
  display: grid;
  grid-template-columns: minmax(180px, 0.72fr) minmax(0, 1.55fr);
  gap: clamp(1.7rem, 4vw, 3.2rem);
  align-items: center;
  margin: 0.5rem 0 3.3rem;
}

.book-intro-cover img {
  display: block;
  width: 100%;
  max-width: 290px;
  margin: 0 auto;
  border: 1px solid var(--book-border);
  border-radius: 3px;
  box-shadow: 0 18px 44px rgba(6, 28, 43, 0.17);
}

.book-kicker {
  margin-bottom: 0.75rem;
  color: var(--book-accent);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.book-intro-copy .book-deck {
  max-width: 53ch !important;
  margin-bottom: 1rem;
  color: var(--book-heading);
  font-family: "Inter", system-ui, sans-serif;
  font-size: clamp(1.25rem, 2.15vw, 1.62rem);
  font-weight: 550;
  line-height: 1.45;
  letter-spacing: -0.022em;
}

.book-intro-copy p {
  max-width: 60ch !important;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.3rem;
}

.book-button,
a.book-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0.6rem 0.92rem;
  border: 1px solid var(--book-border);
  border-radius: 9px;
  background: var(--book-surface);
  color: var(--book-heading) !important;
  font-size: 0.79rem;
  font-weight: 700;
  text-decoration: none !important;
  box-shadow: var(--book-shadow-soft);
  transition: transform 160ms ease, border-color 160ms ease;
}

.book-button.primary,
a.book-button.primary {
  border-color: var(--book-accent);
  background: var(--book-accent);
  color: #fff !important;
}

.book-button:hover {
  transform: translateY(-1px);
  border-color: var(--book-accent);
}

.chapter-grid,
.route-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1.2rem 0 2.6rem;
}

.chapter-card,
.route-card {
  position: relative;
  overflow: hidden;
  min-height: 145px;
  padding: 1rem 1.05rem 1.05rem;
  border: 1px solid var(--book-border);
  border-radius: 12px;
  background: var(--book-surface);
  box-shadow: var(--book-shadow-soft);
}

.chapter-card::before,
.route-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--book-accent), var(--book-secondary), var(--book-coral));
}

.chapter-card .card-number,
.route-card .card-number {
  display: block;
  margin-bottom: 0.52rem;
  color: var(--book-accent);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.chapter-card strong,
.route-card strong {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--book-heading);
  font-size: 0.98rem;
  line-height: 1.35;
}

.chapter-card p,
.route-card p {
  margin: 0 !important;
  color: var(--book-text-soft);
  font-family: "Literata", serif;
  font-size: 0.88rem;
  line-height: 1.54;
}

.chapter-card a {
  color: inherit !important;
  text-decoration: none;
}

.chapter-card:hover {
  border-color: color-mix(in srgb, var(--book-accent) 55%, var(--book-border));
  transform: translateY(-2px);
  transition: transform 160ms ease, border-color 160ms ease;
}

.author-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 1.35rem;
  align-items: center;
  margin: 1.4rem 0 2.5rem;
  padding: 1.25rem;
  border: 1px solid var(--book-border);
  border-radius: 14px;
  background: var(--book-surface);
  box-shadow: var(--book-shadow-soft);
}

.author-card .quarto-figure {
  margin: 0;
}

.author-card img,
.author-photo {
  width: 140px !important;
  height: 140px;
  object-fit: cover;
  border-radius: 50% !important;
}

.author-card p:last-child {
  margin-bottom: 0;
}

.soft-note {
  margin: 1.4rem 0 2rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--book-border);
  border-radius: 10px;
  background: var(--book-surface-soft);
}

.soft-note p:last-child {
  margin-bottom: 0;
}

/* Reading progress and back-to-top --------------------------------------- */

#book-reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1100;
  width: 100%;
  height: 3px;
  pointer-events: none;
  background: transparent;
}

#book-reading-progress-bar {
  width: 0;
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, var(--book-accent), var(--book-secondary), var(--book-coral));
  transition: width 90ms linear;
}

/* Utilities --------------------------------------------------------------- */

.inline-figure {
  border: none;
}

div.hanging-indent {
  margin-left: -1.5em !important;
}

.csl-entry {
  padding-left: 2em;
  text-indent: -2em;
}

img {
  max-width: 100%;
}

.terminal {
  margin-bottom: 0.75em;
  padding: 0.8em 1em;
  border: 1px solid var(--book-border);
  border-left-width: 4px;
  border-radius: 9px;
  background: var(--book-surface-soft);
}

if {
  display: inline;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  background: var(--book-accent-soft);
  font-size: 90%;
  font-weight: 700;
}

pkg {
  color: inherit;
  font-weight: 600;
}

pkg::before { content: "{"; }
pkg::after { content: "}"; }

mac,
pc {
  display: inline;
  padding: 0.125rem 0.25rem 0;
  border: 1px solid var(--book-border);
  border-radius: 0.25rem;
  font-family: "Fira Code", monospace;
  font-size: 90%;
  white-space: nowrap;
}

/* External-link icon retained from the original book template. */
a[target="_blank"]::after {
  margin: 0 3px 0 5px;
  font-family: "bootstrap-icons";
  font-weight: 900;
  content: "\F1C5";
}

a.glossary::after,
code a::after,
.book-button::after,
.chapter-card a::after {
  content: none !important;
  margin: 0 !important;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 767.98px) {
  body {
    font-size: 1rem;
    line-height: 1.68;
  }

  #title-block-header .title {
    font-size: clamp(2rem, 9vw, 2.8rem);
  }

  .book-intro,
  .author-card {
    grid-template-columns: 1fr;
  }

  .book-intro-cover img {
    max-width: 230px;
  }

  .chapter-grid,
  .route-grid {
    grid-template-columns: 1fr;
  }

  .author-card {
    text-align: left;
  }

  .author-card img,
  .author-photo {
    width: 120px !important;
    height: 120px;
  }

  .page-navigation {
    gap: 0.55rem;
  }

  .page-navigation .nav-page {
    min-height: 80px;
    padding: 0.8rem;
  }

}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* The original template put the mobile TOC beside the chapter list. Keeping
   them stacked is easier to scan and prevents cramped two-column navigation. */
@media screen and (max-width: 767.98px) {
  #TOC,
  #quarto-sidebar .sidebar-menu-container ul.mt-1 {
    width: 100% !important;
    float: none !important;
    display: block !important;
  }
}

div.hanging-indent {
  margin-left: -0.75em !important;
}

.csl-entry {
  padding-left: 2em;
  text-indent: -2em;
}
