/* Public site: the doctor's teal-ink notebook. Admin keeps style.css. */
:root {
  --paper: #eef3f4;
  --desk: #dbe5e8;
  --rule-c: #c9dbe0;
  --margin-c: #e3a9a0;
  --ink: #17262c;
  --teal: #1f5f73;
  --teal-deep: #174a5a;
  --mut: #46616a;
  --pen: #5aa3b5;
  --hl: #cfe4ea;
  --rule: 2rem;
  --margin: 3rem;
  --gutter: 1.25rem;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: #9db8c0 var(--paper); }
body.nb {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/var(--rule) "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", serif;
  caret-color: var(--teal);
}
.nb ::selection { background: var(--hl); color: var(--ink); }
.nb a { color: var(--teal); text-decoration-color: var(--pen); text-underline-offset: .25em; }
.nb a:hover { color: var(--teal-deep); }
.nb :focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 2px; }
.nb h1, .nb h2, .nb h3, .nb p, .nb ol { margin: 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* The page: ruled lines every --rule, one margin rule. All vertical
   spacing is a multiple of --rule so text stays on the lines. */
.nb-page {
  position: relative;
  min-height: 100vh;
  padding: var(--rule) var(--gutter) calc(var(--rule) * 2) calc(var(--margin) + .75rem);
  background:
    linear-gradient(to right, transparent calc(var(--margin) - 1px), var(--margin-c) calc(var(--margin) - 1px), var(--margin-c) var(--margin), transparent var(--margin)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--rule) - 1px), var(--rule-c) calc(var(--rule) - 1px), var(--rule-c) var(--rule)),
    var(--paper);
}
.nb-dateline, .nb-meta, .nb-crumb { font-size: .875rem; color: var(--mut); font-variant-numeric: tabular-nums; }
.nb-crumb a { color: var(--mut); }

/* Header: title in ink, taped show cover top right. */
.nb-top { position: relative; padding-right: 5.25rem; min-height: calc(var(--rule) * 4); }
.nb-title { font-size: clamp(1.5rem, 7vw, 2.5rem); line-height: calc(var(--rule) * 2); font-weight: 700; color: var(--teal); letter-spacing: .02em; text-wrap: balance; }
.nb-title a { color: inherit; text-decoration: none; }
.nb-byline { color: var(--ink); }
.nb-photo { position: absolute; top: .25rem; right: 0; width: 4.5rem; margin: 0; transform: rotate(2deg); }
.nb-photo img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border: 4px solid #fff; box-shadow: 0 6px 16px rgba(23, 38, 44, .18); }

.nb-hook { margin-top: var(--rule); font-size: 1.125rem; white-space: pre-line; max-width: 34em; }

/* Primary action: a solid ink block on the rules; platforms as one written line. */
.nb-act { margin-top: var(--rule); }
.nb-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 24rem; height: 3rem; margin: .5rem 0;
  padding: 0 1.25rem; border-radius: 4px;
  background: var(--teal); color: var(--paper) !important; font-weight: 700; font-size: 1.125rem; text-decoration: none;
  box-shadow: 0 4px 12px rgba(31, 95, 115, .25);
  transition: background-color .2s var(--ease), transform .2s var(--ease);
}
.nb-cta:hover { background: var(--teal-deep); transform: translateY(-1px); }
.nb-cta:active { transform: translateY(0); }
.nb-cta svg { flex: none; }
.nb-elsewhere { display: flex; flex-wrap: wrap; column-gap: 1.25rem; color: var(--mut); }
.nb-elsewhere a { display: inline-flex; align-items: center; gap: .35em; white-space: nowrap; }
.nb-elsewhere svg { flex: none; width: 1.15em; height: 1.15em; }

/* Entries: episode number in the margin, title in ink, one play control. */
.nb-section { margin-top: var(--rule); }
.nb-h2 { font-size: 1.25rem; line-height: calc(var(--rule) * 2); color: var(--teal); font-weight: 700; }
.nb-entries { list-style: none; padding: 0; }
.nb-entry { position: relative; display: grid; grid-template-columns: 1fr 2.75rem; column-gap: .75rem; }
.nb-entry[hidden] { display: none; }
.nb-entries.is-spaced .nb-entry + .nb-entry { margin-top: var(--rule); }
.nb-num {
  position: absolute; top: 0; right: calc(100% + .75rem + .5rem);
  width: calc(var(--margin) - .5rem); text-align: right;
  font-size: .8125rem; color: var(--teal); font-variant-numeric: tabular-nums;
}
.nb-entry h2, .nb-entry h3 { font-size: 1.0625rem; font-weight: 700; line-height: var(--rule); }
.nb-entry h2 a, .nb-entry h3 a { color: var(--ink); text-decoration: none; }
.nb-entry h2 a:hover, .nb-entry h3 a:hover { color: var(--teal); }
.nb-entry .nb-play { grid-column: 2; grid-row: 1 / span 2; align-self: start; }

/* Pen underline: a wobbly hand-drawn stroke, drawn under the bio on load
   and under whatever is playing. */
.nb-ink {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 8' preserveAspectRatio='none'%3E%3Cpath d='M1 5.2C24 3.1 47 6.4 78 4.6S140 2.9 163 4.8 190 5.6 199 3.4' fill='none' stroke='%235aa3b5' stroke-width='2.2' stroke-linecap='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 0 100%; background-size: 0 .5rem;
  transition: background-size .9s var(--ease);
}
.is-new .nb-ink { animation: nb-pen 1.1s var(--ease) .35s forwards; }
.is-playing .nb-ink { background-size: 100% .5rem; }
@keyframes nb-pen { to { background-size: 100% .5rem; } }

.nb-play {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  width: 2.75rem; height: 2.75rem; border-radius: 50%;
  background: var(--teal); color: var(--paper) !important; text-decoration: none;
  transition: background-color .2s var(--ease), transform .15s var(--ease);
}
.nb-play:hover { background: var(--teal-deep); }
.nb-play:active { transform: scale(.94); }
.nb-play .i-pause, .is-playing .nb-play .i-play, .nb-play.is-playing .i-play { display: none; }
.is-playing .nb-play .i-pause, .nb-play.is-playing .i-pause { display: block; }
.nb-more { margin-top: var(--rule); }

/* Archive search */
.nb-search { display: block; margin: var(--rule) 0 0; max-width: 24rem; }
.nb-search input {
  width: 100%; height: var(--rule); margin: 0; padding: 0 .25rem;
  border: 0; border-bottom: 2px solid var(--teal); border-radius: 0; background: transparent;
  font: inherit; color: var(--ink);
}
.nb-search input::placeholder { color: var(--mut); }
.nb-search input:focus-visible { outline: none; border-bottom-color: var(--pen); background: rgba(207, 228, 234, .45); }
.nb-count { margin-bottom: var(--rule); }
.nb-empty { color: var(--mut); }

/* Episode page */
.nb-chapter-head { position: relative; margin-top: var(--rule); }
.nb-chapter-head.has-photo { padding-right: 5.25rem; min-height: calc(var(--rule) * 4); }
.nb-chapter h1 { font-size: clamp(1.375rem, 5.6vw, 1.5rem); line-height: var(--rule); font-weight: 700; color: var(--teal); text-wrap: balance; }
.nb-listen { display: flex; flex-wrap: wrap; align-items: center; column-gap: 1rem; margin-top: var(--rule); }
.nb-play.is-wide { width: auto; height: 3rem; margin: .5rem 0; padding: 0 1.25rem 0 1rem; border-radius: 4px; font-weight: 700; }
.nb-listen .nb-elsewhere { flex: 1 1 12rem; }

.nb-prose { margin-top: calc(var(--rule) * 2); max-width: 36em; overflow-wrap: anywhere; }
.nb-prose > * { margin: 0 0 var(--rule); }
.nb-prose h1, .nb-prose h2, .nb-prose h3, .nb-prose h4 { font-size: 1.125rem; line-height: var(--rule); color: var(--teal); margin-top: var(--rule); }
.nb-prose ul, .nb-prose ol { padding-left: 1.25em; }
.nb-prose li::marker { color: var(--teal); }
.nb-prose img { display: block; max-width: 100%; height: auto; }
.nb-prose hr { border: 0; height: var(--rule); margin: 0; }
.nb-prose blockquote { margin-left: 0; padding-left: 1em; color: var(--mut); }
.nb-prose strong { color: var(--teal-deep); }

.nb-ask { margin-top: calc(var(--rule) * 2); }
.nb-ask p { font-weight: 700; }
.nb-pager { display: grid; gap: var(--rule); margin-top: calc(var(--rule) * 2); }
.nb-pager a { display: block; text-decoration: none; }
.nb-pager span { display: block; font-size: .875rem; color: var(--mut); }
.nb-pager b { display: block; color: var(--ink); }
.nb-pager a:hover b { color: var(--teal); }

.nb-foot { margin-top: calc(var(--rule) * 2); font-size: .875rem; color: var(--mut); }
.nb-foot a { color: var(--mut); }

/* Shared player: one audio element, docked at the bottom. */
body.has-player .nb-page { padding-bottom: calc(var(--rule) * 5); }
.nb-player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: 2.75rem 1fr auto; align-items: center; gap: .25rem .75rem;
  padding: .625rem var(--gutter) calc(.625rem + env(safe-area-inset-bottom));
  background: rgba(238, 243, 244, .97); border-top: 1px solid var(--rule-c);
  box-shadow: 0 -8px 24px rgba(23, 38, 44, .1);
  font-size: .875rem; line-height: 1.4;
  transform: translateY(0); transition: transform .35s var(--ease);
}
.nb-player[hidden] { display: grid; transform: translateY(110%); visibility: hidden; }
.nb-player .nb-play { grid-row: 1 / span 2; }
.nb-pl-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink) !important; font-weight: 700; text-decoration: none; }
.nb-pl-seek { grid-column: 2; width: 100%; height: 1.5rem; margin: 0; accent-color: var(--teal); }
.nb-pl-ctl { grid-column: 3; grid-row: 1 / span 2; display: flex; align-items: center; gap: .25rem; }
.nb-pl-ctl button {
  min-width: 2.75rem; height: 2.75rem; padding: 0 .375rem; border: 0; border-radius: 4px;
  background: transparent; color: var(--teal); font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer;
}
.nb-pl-ctl button:hover { background: var(--hl); }
.nb-pl-time { color: var(--mut); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 479px) { .nb-pl-total { display: none; } }
.nb-pl-meta { grid-column: 2; display: flex; justify-content: space-between; gap: .75rem; min-width: 0; }

/* Desktop: the notebook lies on a desk. */
@media (min-width: 720px) {
  :root { --margin: 5rem; --gutter: 3rem; }
  body.nb { background: var(--desk); }
  .nb-page { max-width: 46rem; margin: var(--rule) auto; min-height: calc(100vh - var(--rule) * 2); box-shadow: 0 1px 2px rgba(23, 38, 44, .08), 0 18px 48px rgba(23, 38, 44, .14); border-radius: 2px; }
  .nb-top, .nb-chapter-head.has-photo { padding-right: 11rem; min-height: calc(var(--rule) * 5); }
  .nb-top + .nb-hook { margin-top: 0; }
  .nb-photo { width: 9rem; }
  .nb-photo img { border-width: 6px; }
  .nb-pager { grid-template-columns: 1fr 1fr; }
  .nb-pager .is-older { text-align: right; grid-column: 2; }
  .nb-player { left: 50%; right: auto; width: min(46rem, 100%); transform: translateX(-50%); border: 1px solid var(--rule-c); border-bottom: 0; border-radius: 6px 6px 0 0; }
  .nb-player[hidden] { transform: translate(-50%, 110%); }
}

@media (prefers-reduced-motion: reduce) {
  .nb *, .nb *::before { animation: none !important; transition: none !important; }
  .is-new .nb-ink { background-size: 100% .5rem; }
}
