/**
 * Your Notebook (docs/design/2026-08-11-your-notebook-design.md)
 *
 * Master-detail, v3 (owner: "I think it needs a master detail view"): one
 * elevated surface split into a master rail and a reading pane — the mail-app
 * grammar in the app's own tokens. The rail holds compact rows (previews may
 * ellipsize; that is list grammar); the reading pane shows the selected entry
 * whole, and NEVER truncates the member's words.
 *
 * The typographic contract, kept everywhere on this page:
 *   Frank Ruhl  = the member's voice (their answers, the titles of things)
 *   Barlow      = the system's voice (recaps, coach notes, meta prose)
 *   Barlow Cond = wayfinding (kind markers, ordinals, actions)
 *
 * Layout: two panes from 900px up, each owning its own scroll inside a
 * viewport-fit card. Below 900px it collapses list-first: the rail fills the
 * screen and .is-detail-open (server-set for explicit ?entry= links,
 * client-set on row taps) pushes the reading pane full-screen with a back
 * affordance. No squeezed two-pane, no horizontal scroll.
 */

.notebook-shell {
  display: grid;
  grid-template-columns: minmax(300px, 348px) minmax(0, 1fr);
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  /* The card fits the viewport under the sticky chrome (--chrome-height is
     published live by chrome_height_controller; the fallback covers the
     pre-JS first paint) so both panes scroll internally, app-like. */
  height: calc(100dvh - var(--chrome-height, 140px) - 3.25rem);
  min-height: 32rem;
  overflow: hidden;
  margin-block: 0.25rem 1.5rem;
}

/* ── Entrance: the hub's motion grammar, once per session ─────────────────
   (entrance_controller sets data-entrance="play" on first sighting only;
   base.css collapses this under prefers-reduced-motion.) */
.notebook-shell[data-entrance="play"] > * {
  animation: motion-rise var(--motion-enter) var(--ease-out) backwards;
}

.notebook-shell[data-entrance="play"] > :nth-child(1) { animation-delay: 0ms; }
.notebook-shell[data-entrance="play"] > :nth-child(2) { animation-delay: 60ms; }

/* ── The master rail ─────────────────────────────────────────────────────── */

.notebook-master {
  overflow-y: auto;
  border-right: 1px solid var(--border-light);
  /* A quiet tonal step below the reading pane, so the selected row's lift
     to the card surface reads. */
  background: var(--surface-page);
}

.notebook-masthead {
  padding: 1.35rem 1.25rem 1.05rem;
  border-bottom: 1px solid var(--border-light);
}

.notebook-masthead h1 {
  font-family: var(--font-heading);
  font-weight: var(--weight-heading);
  font-size: calc(21px * var(--text-scale));
  color: var(--text-dark);
  margin: 0;
}

/* ── Search: a quiet box at the top of the rail ──────────────────────────── */

.notebook-search {
  padding: 0.85rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
}

.notebook-search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.65rem;
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  transition: border-color var(--motion-quick) var(--ease-out),
              box-shadow var(--motion-quick) var(--ease-out);
}

/* The input keeps the app's own token ring (base.css :focus-visible); the
   box just firms its border so the control reads as one piece. */
.notebook-search-box:focus-within {
  border-color: var(--teal-accent);
}

.notebook-search-box .fa-magnifying-glass {
  color: var(--text-secondary);
  font-size: calc(13px * var(--text-scale));
}

.notebook-search-input {
  flex: 1;
  min-width: 0;
  min-height: calc(var(--tap) - 2px);
  border: 0;
  background: transparent;
  font-family: var(--font-body);
  /* 16px floor: anything smaller makes iOS zoom the page on focus. */
  font-size: calc(16px * var(--text-scale));
  color: var(--text-dark);
}

.notebook-search-input::placeholder {
  color: var(--text-secondary);
}

/* The form's own clear affordance is the one x; hide WebKit's built-in. */
.notebook-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.notebook-search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: calc(var(--tap) - 10px);
  min-height: calc(var(--tap) - 10px);
  color: var(--text-secondary);
  text-decoration: none;
}

@media (hover: hover) {
  .notebook-search-clear:hover {
    color: var(--teal-ink);
  }
}

.notebook-search-count {
  margin: 0.5rem 0.1rem 0;
  font-family: var(--font-body);
  font-size: calc(12px * var(--text-scale));
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* No results: one flat line and the way out. */
.notebook-search-empty {
  padding: 1.1rem 1.25rem;
}

.notebook-search-empty p {
  font-family: var(--font-body);
  font-size: calc(13.5px * var(--text-scale));
  color: var(--text-secondary);
  overflow-wrap: anywhere;
  margin: 0 0 0.4rem;
}

.notebook-search-empty-clear {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12px * var(--text-scale));
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-ink);
  text-decoration: none;
}

@media (hover: hover) {
  .notebook-search-empty-clear:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

/* The matched region in a preview line — snippet only, never the detail. */
.notebook-mark {
  background: var(--teal-light);
  color: inherit;
  padding: 0 0.08em;
}

/* ── Sections: quiet labels over row groups ──────────────────────────────── */

.notebook-index {
  padding-bottom: 1.25rem;
}

.notebook-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.25rem 0.45rem;
}

.notebook-section-head h2 {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  margin: 0;
}

/* Progress as data, not a meter. */
.notebook-section-count {
  font-family: var(--font-body);
  font-size: calc(12px * var(--text-scale));
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Rows ────────────────────────────────────────────────────────────────── */

.notebook-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notebook-row {
  display: grid;
  grid-template-columns: 1.9rem 1fr;
  column-gap: 0.3rem;
  align-items: start;
  padding: 0.6rem 1.1rem 0.65rem 0.85rem;
  min-height: var(--tap);
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: background var(--motion-quick) var(--ease-out),
              border-color var(--motion-quick) var(--ease-out);
}

@media (hover: hover) {
  a.notebook-row:hover:not([aria-current]) {
    background: color-mix(in srgb, var(--surface-card) 65%, transparent);
  }
}

/* The selected row lifts to the reading pane's surface off a teal edge. */
.notebook-row[aria-current] {
  background: var(--surface-card);
  border-left-color: var(--teal-accent);
}

/* The question's place in the sequence — question_number is a stored fact,
   so the ordinal is information, set in the wayfinding face. */
.notebook-row-ordinal {
  font-family: var(--font-ui);
  font-size: calc(12px * var(--text-scale));
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  line-height: 1.7;
  color: var(--gray-400);
}

.notebook-row.is-answered .notebook-row-ordinal {
  color: var(--slate-blue);
}

.notebook-row-body {
  min-width: 0; /* let previews ellipsize instead of widening the rail */
}

.notebook-row-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

/* Answered state as a mark: a filled teal square when written, hollow while
   waiting — squared like the rest of the brand's corners. */
.notebook-row-mark {
  flex: none;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--slate-blue);
}

.notebook-row.is-answered .notebook-row-mark {
  background: var(--teal-accent);
  border-color: var(--teal-accent);
}

.notebook-row-title {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.35;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notebook-row.is-answered .notebook-row-title {
  color: var(--navy-primary);
}

/* One line, may ellipsize — list grammar; the reading pane never truncates. */
.notebook-row-preview {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-body);
  font-size: calc(12.5px * var(--text-scale));
  line-height: 1.5;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notebook-row-preview.is-awaiting {
  color: var(--gray-400);
}

/* ── Timeline rows: the system's voice, kind-marked and dated ────────────── */

.notebook-row-glyph {
  width: 8px;
  height: 8px;
  margin-top: 0.4rem;
  justify-self: start;
  margin-left: 2px;
  border: 1.5px solid var(--slate-blue);
}

.notebook-row.is-insight .notebook-row-glyph {
  background: var(--teal-accent);
  border-color: var(--teal-accent);
}

.notebook-row-kind {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(11.5px * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.notebook-row.is-insight .notebook-row-kind {
  color: var(--teal-ink);
}

.notebook-row-date {
  margin-left: auto;
  font-family: var(--font-ui);
  font-size: calc(11px * var(--text-scale));
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-400);
  white-space: nowrap;
}

/* The awaiting stream: quiet, non-interactive explainer rows — the promise
   of the layer, not a nag. Their lines may wrap; they are prose, not previews. */
.notebook-rows--awaiting .notebook-row.is-explainer .notebook-row-preview {
  white-space: normal;
  color: var(--gray-400);
}

.notebook-rows--awaiting .notebook-row.is-explainer .notebook-row-kind {
  color: var(--gray-400);
}

.notebook-rows--awaiting .notebook-row.is-explainer.is-insight .notebook-row-kind {
  color: color-mix(in srgb, var(--teal-ink) 65%, transparent);
}

.notebook-rows--awaiting .notebook-row.is-explainer .notebook-row-glyph {
  border-color: var(--gray-400);
  background: none;
}

/* ── The reading pane ────────────────────────────────────────────────────── */

.notebook-detail {
  overflow-y: auto;
  background: var(--surface-card);
}

turbo-frame#notebook_detail {
  display: block;
  min-height: 100%;
}

.notebook-article {
  max-width: 660px;
  margin-inline: auto;
  padding: clamp(2.25rem, 6vh, 3.5rem) clamp(1.75rem, 5vw, 3rem) 4rem;
}

.notebook-detail-head {
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.7rem;
}

.notebook-detail-eyebrow {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12px * var(--text-scale));
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 0.9rem;
}

.notebook-detail-eyebrow-num {
  font-variant-numeric: tabular-nums;
  color: var(--gray-400);
}

.notebook-detail-eyebrow.is-coach {
  color: var(--teal-ink);
}

/* The question (or the welcome line) as the heading, in the member-facing
   serif. */
.notebook-detail-heading {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(26px * var(--text-scale));
  line-height: 1.32;
  color: var(--navy-primary);
  margin: 0 0 0.7rem;
  text-wrap: balance;
}

.notebook-detail-meta {
  font-family: var(--font-body);
  font-size: calc(13px * var(--text-scale));
  color: var(--text-secondary);
  margin: 0;
}

/* The member's words, whole, in their own voice. No clamp, no max-height:
   a long answer flows like a passage. */
.notebook-detail-answer {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: calc(18px * var(--text-scale));
  line-height: 1.75;
  color: var(--text-dark);
  max-width: 58ch;
}

.notebook-detail-answer p {
  margin: 0 0 1rem;
}

.notebook-detail-answer p:last-child {
  margin-bottom: 0;
}

/* An unanswered page: what it becomes, said plainly. */
.notebook-detail-awaiting {
  font-family: var(--font-body);
  font-size: calc(15.5px * var(--text-scale));
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 52ch;
  margin: 0;
}

/* The system's voice: Barlow, never the member's serif. */
.notebook-detail-prose {
  font-family: var(--font-body);
  font-size: calc(16.5px * var(--text-scale));
  line-height: 1.75;
  color: var(--text-dark);
  max-width: 60ch;
  margin: 0;
}

/* A coach's note: annotation off a teal rule with a breath of wash — a
   different voice, visibly. */
.notebook-detail-note {
  border-left: 3px solid var(--teal-accent);
  padding: 1rem 1.25rem 1.05rem;
  background: linear-gradient(to right, rgba(72, 156, 184, 0.08),
              rgba(72, 156, 184, 0.02) 70%, transparent);
}

/* Where the insight looked — a quiet provenance line, list grammar. */
.notebook-detail-sources {
  font-family: var(--font-body);
  font-size: calc(13px * var(--text-scale));
  color: var(--text-secondary);
  margin: 0.6rem 0 0;
}

/* Editing stays in the step: one action, one name, answered or not. */
.notebook-detail-open {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  min-height: var(--tap);
  margin-top: 1.9rem;
  padding: 0.25rem 1rem 0.25rem 1.2rem;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12.5px * var(--text-scale));
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-ink);
  border: 1px solid var(--teal-accent);
  text-decoration: none;
  transition: background var(--motion-quick) var(--ease-out),
              color var(--motion-quick) var(--ease-out);
}

.notebook-detail-open .fa-sharp {
  font-size: 1.3em;
  transition: transform var(--motion-quick) var(--ease-out);
}

@media (hover: hover) {
  .notebook-detail-open:hover {
    background: var(--teal-light);
    color: var(--teal-ink);
  }

  .notebook-detail-open:hover .fa-sharp {
    transform: translateX(2px);
  }
}

/* ── The welcome panel: day one's first impression ───────────────────────── */

.notebook-welcome-body p {
  font-family: var(--font-body);
  font-size: calc(16px * var(--text-scale));
  line-height: 1.7;
  color: var(--text-dark);
  max-width: 54ch;
  margin: 0 0 1rem;
}

.notebook-welcome-subhead {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12px * var(--text-scale));
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 2.3rem 0 1.1rem;
}

.notebook-welcome-item {
  border-left: 3px solid var(--border-light);
  padding: 0.15rem 0 0.2rem 1.1rem;
  margin-bottom: 1.25rem;
}

.notebook-welcome-item.is-insight {
  border-left-color: var(--teal-accent);
}

.notebook-welcome-kind {
  display: block;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(11.5px * var(--text-scale));
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.notebook-welcome-item.is-insight .notebook-welcome-kind {
  color: var(--teal-ink);
}

.notebook-welcome-item p {
  font-family: var(--font-body);
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 50ch;
  margin: 0;
}

/* ── The back affordance: narrow screens only ────────────────────────────── */

.notebook-detail-back {
  display: none;
  align-items: center;
  gap: 0.1rem;
  min-height: var(--tap);
  padding: 0.9rem clamp(1.25rem, 5vw, 2rem) 0;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(12.5px * var(--text-scale));
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal-ink);
  text-decoration: none;
}

.notebook-detail-back .fa-sharp {
  font-size: 1.35em;
}

/* ── Narrow: list-first, detail pushes full-screen ───────────────────────── */

@media (max-width: 899.98px) {
  .notebook-shell {
    display: block;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .notebook-master {
    border-right: 0;
    overflow: visible;
  }

  .notebook-detail {
    display: none;
    overflow: visible;
  }

  .notebook-shell.is-detail-open .notebook-master {
    display: none;
  }

  .notebook-shell.is-detail-open .notebook-detail {
    display: block;
  }

  .notebook-detail-back {
    display: inline-flex;
  }

  .notebook-article {
    padding-top: 1.25rem;
  }
}

/* ── Dark theme ──────────────────────────────────────────────────────────
   Every token above flips with the theme (variables.css); only the fixed
   rgba wash needs its own dark value. */

[data-theme="dark"] .notebook-detail-note {
  background: linear-gradient(to right, rgba(72, 156, 184, 0.14),
              rgba(72, 156, 184, 0.04) 70%, transparent);
}

/* ── Activities shelf artifacts (Library activities, completed) ─────────── */

.notebook-activity-ranked {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: calc(18px * var(--text-scale));
  line-height: 1.6;
  color: var(--text-dark);
  margin: 0;
  padding-left: 1.6em;
}

.notebook-activity-ranked li {
  margin-bottom: 0.4em;
}

.notebook-activity-ranked li::marker {
  font-family: var(--font-heading);
  color: var(--teal-ink);
}

.notebook-activity-scores {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 46ch;
}

.notebook-activity-scores li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-light);
}

.notebook-activity-score-area {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: calc(16.5px * var(--text-scale));
  color: var(--navy-primary);
}

.notebook-activity-score-num {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: calc(13px * var(--text-scale));
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal-ink);
  white-space: nowrap;
}

/* Activity-wave artifacts (2026-08-13): the member's words in brief, one
   fragment per line, before the Open-this-activity link. */
.notebook-activity-fragments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.notebook-activity-fragments li {
  padding: 0.55rem 0.8rem;
  border-left: 3px solid var(--teal-accent);
  background: var(--teal-light);
  color: var(--text-dark);
  border-radius: 0 8px 8px 0;
  font-size: calc(14.5px * var(--text-scale));
  line-height: 1.5;
}

/* ── Writing in the pane: the in-place Trix editor (owner, 2026-08-15) ─────
   The member's words stay in their serif at the same size they read at; the
   editor is a writing surface, not a form control, so it carries no filled
   box — a hairline underline that becomes a teal rule on focus, and nothing
   else. The toolbar only appears once the caret is in. */
.notebook-editor {
  max-width: 58ch;
}

.notebook-editor trix-toolbar {
  visibility: hidden;
  margin-bottom: 0.25rem;
}

.notebook-editor:focus-within trix-toolbar {
  visibility: visible;
}

.notebook-editor .notebook-trix {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: calc(18px * var(--text-scale));
  line-height: 1.75;
  color: var(--text-dark);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-light);
  border-radius: 0;
  padding: 0 0 0.6rem;
  min-height: 7rem;
}

/* Focus keeps the shared ring (.trix-content:focus, --focus-ring); the rule
   under the text just goes teal with it. */
.notebook-editor .notebook-trix:focus {
  border-bottom-color: var(--teal-accent);
}

.notebook-editor .notebook-trix p {
  margin: 0 0 1rem;
}

.notebook-editor .notebook-trix p:last-child {
  margin-bottom: 0;
}

.notebook-editor .field-status {
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
}

/* An entry never saved has no date to show; the slot stays for the autosave
   to replace, but takes no space until there is something in it. */
.notebook-detail-meta:empty {
  display: none;
}

/* The foot of the editor: what the save is doing on the left, when the entry
   was last updated on the right, quiet (owner, 2026-08-15). The recency line
   used to sit under the question, where it read as part of the heading. */
.notebook-editor-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.35rem;
}

.notebook-editor-foot .notebook-detail-meta {
  margin: 0;
  font-family: var(--font-ui);
  font-size: calc(12px * var(--text-scale));
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: right;
}
