/* Pockets Full of True Things - the collected writings of Solen Verai */

:root {
  --ink: #14161d;
  --ink-raised: #1b1e27;
  --paper: #e9e4d8;
  --paper-dim: #b5af9f;
  --hairline: rgba(233, 228, 216, 0.14);
  --accent: #cfd8e8;
  --measure: 66ch;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "EB Garamond", Georgia, serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 1.1875rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* Page accents */
.page-torch   { --accent: #e08a3c; }
.page-feather { --accent: #8fa1b3; }
.page-shovel  { --accent: #a09484; }
.page-dawn    { --accent: #d4af5e; }
.page-lamp    { --accent: #e8d8a8; }

::selection {
  background: var(--accent);
  color: var(--ink);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Ambient canvas sits behind everything */
#ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Reading progress */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 30;
  background: transparent;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
}

/* Header + nav */
.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding: 1.3rem 1.6rem;
}

.site-mark {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

.site-mark a {
  color: inherit;
}

.site-mark a:hover {
  color: var(--paper);
  text-decoration: none;
}

.nav {
  position: relative;
}

.nav-toggle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
  background: none;
  border: none;
  padding: 0.2rem 0;
  cursor: pointer;
}

.nav-toggle:hover {
  color: var(--accent);
}

.nav-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 15rem;
  margin: 0;
  padding: 0.4rem 0;
  list-style: none;
  background: var(--ink-raised);
  border-radius: 3px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  display: none;
}

.nav-menu li + li {
  border-top: 1px solid var(--hairline);
}

.nav[data-open="true"] .nav-menu {
  display: block;
}

.nav-menu a {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.55rem 1rem;
  color: var(--paper);
}

.nav-menu a:hover,
.nav-menu a[aria-current="page"] {
  background: rgba(233, 228, 216, 0.06);
  text-decoration: none;
}

.nav-menu .num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--paper-dim);
}

.nav-menu .sub {
  display: block;
  font-size: 0.82rem;
  color: var(--paper-dim);
  font-style: italic;
}

/* Letter layout */
.letter {
  position: relative;
  z-index: 1;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 5rem 1.4rem 7rem;
}

.letter-head {
  text-align: center;
  margin-bottom: 4.5rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.2rem;
}

.letter-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 7vw, 4rem);
  line-height: 1.1;
  margin: 0 0 1.4rem;
  color: var(--paper);
}

.letter .epigraph,
.epigraph {
  font-style: italic;
  color: var(--paper-dim);
  font-size: 1.05rem;
  margin: 0 auto;
  max-width: 100%;
  text-align: center;
}

.glyph {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 1.6rem;
  color: var(--accent);
}

.letter p {
  margin: 0 0 1.6rem;
}

.letter h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 3.5rem 0 1.6rem;
}

.letter hr {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 3.5rem auto;
  width: 40%;
}

.signature {
  margin-top: 3rem;
  font-style: italic;
}

.signature .name {
  font-family: var(--font-display);
  font-style: normal;
  font-size: 1.6rem;
}

.signature .tagline {
  color: var(--paper-dim);
  font-size: 0.98rem;
}

/* Index */
.index-head {
  text-align: center;
  padding: 6rem 1.4rem 3rem;
  position: relative;
  z-index: 1;
}

.index-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.8rem, 8vw, 4.6rem);
  line-height: 1.08;
  margin: 0.8rem 0 1.2rem;
}

.index-intro {
  font-style: italic;
  color: var(--paper-dim);
  max-width: 46ch;
  margin: 0 auto;
}

.toc {
  position: relative;
  z-index: 1;
  max-width: 40rem;
  margin: 2.5rem auto 7rem;
  padding: 0 1.4rem;
  list-style: none;
}

.toc li + li {
  border-top: 1px solid var(--hairline);
}

.toc a {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1.5rem 0.5rem;
  color: var(--paper);
}

.toc a:hover {
  text-decoration: none;
  background: rgba(233, 228, 216, 0.04);
}

.toc .glyph {
  width: 26px;
  height: 26px;
  margin: 0;
  flex-shrink: 0;
}

.toc .titles {
  flex: 1;
}

.toc .entry-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.2;
}

.toc .entry-sub {
  color: var(--paper-dim);
  font-style: italic;
  font-size: 0.95rem;
}

.toc .num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--paper-dim);
}

.toc-torch:hover   .glyph, .toc-torch:hover   .entry-title { color: #e08a3c; }
.toc-feather:hover .glyph, .toc-feather:hover .entry-title { color: #8fa1b3; }
.toc-shovel:hover  .glyph, .toc-shovel:hover  .entry-title { color: #a09484; }
.toc-dawn:hover    .glyph, .toc-dawn:hover    .entry-title { color: #d4af5e; }
.toc-lamp:hover    .glyph, .toc-lamp:hover    .entry-title { color: #e8d8a8; }

/* Return to top */
.to-top {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 20;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: rgba(27, 30, 39, 0.9);
  background: color-mix(in srgb, var(--ink-raised) 88%, transparent);
  color: var(--paper-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.to-top.visible {
  opacity: 1;
  visibility: visible;
}

.to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.to-top svg {
  width: 1rem;
  height: 1rem;
}

/* Footer */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2.5rem 1.4rem 3.5rem;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

.footer-nav {
  display: flex;
  justify-content: space-between;
  max-width: var(--measure);
  margin: 0 auto 2rem;
}

.footer-nav a {
  color: var(--paper-dim);
}

.footer-nav a:hover {
  color: var(--accent);
}

@media (max-width: 600px) {
  body {
    font-size: 1.0625rem;
  }

  .letter {
    padding-top: 3.5rem;
  }

  .letter-head {
    margin-bottom: 3rem;
  }

  .footer-nav {
    flex-direction: column;
    gap: 0.8rem;
    align-items: center;
  }
}

/* Read-along player */
.reader {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  max-width: 26rem;
  margin: 2.2rem auto 0;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(27, 30, 39, 0.85);
  background: color-mix(in srgb, var(--ink-raised) 80%, transparent);
}

.reader-play {
  width: 2.2rem;
  height: 2.2rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.reader-play svg {
  width: 1rem;
  height: 1rem;
}

.reader .i-pause { display: none; }
.reader.playing .i-pause { display: block; }
.reader.playing .i-play { display: none; }

.reader-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(233, 228, 216, 0.12);
  cursor: pointer;
  overflow: hidden;
}

.reader-track-fill {
  height: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
}

.reader-time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--paper-dim);
  min-width: 2.6rem;
  text-align: right;
}

.reader-follow {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: none;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.reader-follow.off {
  border-color: var(--hairline);
  color: var(--paper-dim);
}

.reader-dim {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: none;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.reader-dim.off {
  border-color: var(--hairline);
  color: var(--paper-dim);
}

/* Word highlighting: unread text sits dimmed, words warm to full as read */
article.readable [data-w] {
  cursor: pointer;
  transition: color 0.45s ease;
}

article.readable p,
article.readable h2 {
  color: #6f6d66;
  color: color-mix(in srgb, var(--paper) 45%, var(--ink));
}

article.readable [data-w].spoken,
article.readable [data-w].speaking {
  color: var(--paper);
}

article.readable h2 [data-w].spoken,
article.readable h2 [data-w].speaking {
  color: var(--accent);
}

@media (max-width: 600px) {
  .reader {
    max-width: 100%;
  }
}


/* Accessible reading mode: Atkinson Hyperlegible, opened-up spacing */
.type-toggle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-dim);
  background: none;
  border: none;
  padding: 0.2rem 0;
  cursor: pointer;
  line-height: 1;
}

.type-toggle:hover {
  color: var(--accent);
}

.type-toggle[aria-pressed="true"] {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

body.easy-read {
  --font-body: "Atkinson Hyperlegible", "EB Garamond", Georgia, serif;
  font-size: 1.0625rem;
  line-height: 1.85;
}

body.easy-read .letter p {
  letter-spacing: 0.01em;
  margin-bottom: 1.9rem;
}

body.easy-read .epigraph,
body.easy-read .index-intro,
body.easy-read .signature {
  font-style: normal;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.header-controls .hdiv {
  width: 1px;
  height: 0.9rem;
  background: var(--hairline);
}


/* Docked player follows the reader down the page */
.reader-sentinel {
  height: 1px;
}

.reader.docked {
  position: fixed;
  top: 0.9rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 19;
  width: min(26rem, calc(100% - 2rem));
  margin: 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  background: rgba(27, 30, 39, 0.96);
  background: color-mix(in srgb, var(--ink-raised) 94%, transparent);
  backdrop-filter: blur(8px);
}

@media (max-width: 600px) {
  .reader.docked {
    top: 0.7rem;
  }
}
