/* Desktop-specific navigation, layout, and rendering refinements (>= 961px) */

/* "Find my place" in the Browse panel is offered where there is a keyboard and room for it.
   It stays out of the way everywhere else unless another stylesheet opts in. */
.find-place-btn {
  display: none;
}

/* Screen only: the printed keepsake spread keeps its own rules in styles.css untouched. */
@media screen and (min-width: 961px) {
  /* ------------------------------------------------------------------
     Steady geometry
     Reserve the scrollbar gutter so the book never jumps sideways when a
     short devotion follows a long one or when the Browse panel locks scroll.
     ------------------------------------------------------------------ */
  html {
    scrollbar-gutter: stable;
  }

  /* ------------------------------------------------------------------
     Chrome: one quiet masthead, one page-turning rail
     The book is the only boxed object on the desk. Controls are plain
     words on the cloth; only the two-way switches keep a hairline frame.
     ------------------------------------------------------------------ */
  .site-bar {
    padding: 13px 0 3px;
    gap: 24px;
    flex-wrap: nowrap;
  }

  .brand {
    gap: 11px;
    white-space: nowrap;
  }

  .bar-controls {
    gap: 2px;
    flex-wrap: nowrap;
  }

  .book-stage {
    gap: 9px;
  }

  .bar-controls .tool-btn,
  .quick-nav .tool-btn {
    position: relative;
    border-color: transparent;
    background: transparent;
    color: rgba(250, 248, 243, 0.74);
    padding: 7px 10px;
  }

  .bar-controls .tool-btn:hover,
  .quick-nav .tool-btn:hover {
    border-color: transparent;
    background: rgba(250, 248, 243, 0.08);
    color: #faf8f3;
  }

  .bar-controls .tool-btn--email {
    border: 1px solid rgba(215, 192, 153, 0.34);
    background: rgba(215, 192, 153, 0.09);
    color: #f6ead4;
    padding: 6px 11px;
    margin-left: 4px;
  }

  .bar-controls .tool-btn--email:hover {
    border-color: rgba(215, 192, 153, 0.56);
    background: rgba(215, 192, 153, 0.17);
    color: #faf8f3;
  }

  /* Latest / Today: a brass underline marks the one you are standing on */
  .bar-controls .tool-btn.is-active {
    background: transparent;
    border-color: transparent;
    color: #faf8f3;
  }

  .bar-controls .tool-btn.is-active::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 3px;
    height: 1.5px;
    border-radius: 1px;
    background: #d7c099;
  }

  .segmented {
    border-color: rgba(250, 248, 243, 0.15);
    background: transparent;
  }

  .bar-controls .segmented {
    margin-left: 8px;
  }

  .bar-controls .segmented + .tool-btn {
    margin-left: 6px;
  }

  .segmented .seg-btn {
    color: rgba(250, 248, 243, 0.62);
    padding: 6px 11px;
  }

  .segmented .seg-btn + .seg-btn {
    border-left-color: rgba(250, 248, 243, 0.1);
  }

  .segmented .seg-btn:hover {
    background: rgba(250, 248, 243, 0.06);
    color: #faf8f3;
  }

  .segmented .seg-btn.is-active {
    background: rgba(250, 248, 243, 0.16);
    color: #faf8f3;
  }

  .segmented--quiet .seg-btn {
    font-size: 0.8rem;
    padding: 5px 11px;
  }

  .quick-nav .tool-btn--quiet {
    font-size: 0.8rem;
  }

  /* The rail: previous and next sit on the book's own left and right edges */
  .quick-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 16px;
  }

  .quick-nav-center {
    gap: 6px;
  }

  .quick-turn-btn,
  .turn-btn {
    justify-self: start;
    min-width: 0;
    gap: 5px;
    margin: 0 0 0 -7px;
    padding: 8px 12px 8px 6px;
    border-color: transparent;
    background: transparent;
    border-radius: 6px;
  }

  .quick-turn-btn--right,
  .turn-btn--right {
    justify-self: end;
    margin: 0 -7px 0 0;
    padding: 8px 6px 8px 12px;
  }

  .quick-turn-btn:hover:not(:disabled),
  .turn-btn:hover:not(:disabled) {
    border-color: transparent;
    background: rgba(250, 248, 243, 0.08);
  }

  .quick-turn-btn:disabled,
  .turn-btn:disabled {
    opacity: 0.3;
  }

  .quick-nav .turn-btn-text,
  .turn-bar .turn-btn-text {
    flex-direction: row;
    align-items: baseline;
    gap: 9px;
    white-space: nowrap;
  }

  .quick-nav .turn-dir,
  .turn-bar .turn-dir {
    font-size: 0.88rem;
  }

  .quick-nav .turn-date,
  .turn-bar .turn-date {
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
  }

  /* Same three-column footing as the rail, so the entry count sits centred under the book */
  .turn-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    padding-top: 4px;
  }

  .page-indicator {
    font-size: 0.86rem;
    color: rgba(246, 243, 235, 0.86);
  }

  .keyboard-hint {
    color: rgba(246, 243, 235, 0.6);
  }

  /* ------------------------------------------------------------------
     Page turns: the ink fades, the paper holds still
     app.js adds .is-turning, makes the next devotion and its decoded
     painting ready, swaps them in while nothing is visible, then lets go.
     ------------------------------------------------------------------ */
  .book-spread {
    transition: none;
  }

  .book-spread.is-turning {
    opacity: 1;
  }

  .page-folio > *,
  .art-plate,
  .year-switcher,
  .devotion-header,
  .scripture-callout,
  .devotion-body,
  .devotion-share,
  .devotion-signoff {
    transition: opacity 260ms ease-out;
  }

  .book-spread.is-turning .page-folio > *,
  .book-spread.is-turning .art-plate,
  .book-spread.is-turning .year-switcher,
  .book-spread.is-turning .devotion-header,
  .book-spread.is-turning .scripture-callout,
  .book-spread.is-turning .devotion-body,
  .book-spread.is-turning .devotion-share,
  .book-spread.is-turning .devotion-signoff {
    opacity: 0;
    transition: opacity 150ms ease-in;
  }

  /* While the plate is hidden the painting swaps in at full strength, so plate and text
     come back together instead of the picture trailing behind. */
  .book-spread.is-turning .art-frame img {
    transition: none;
  }

  /* ------------------------------------------------------------------
     Left page: the plate
     The frame runs the full width of the column so its edges meet the
     folio rule, and shrinks on short windows so the painting and its
     caption stay whole while the plate rides alongside a long devotion.
     ------------------------------------------------------------------ */
  .art-plate {
    top: 24px;
    margin-top: 0;
    gap: 14px;
  }

  .art-frame {
    max-width: none;
    width: min(100%, calc((100vh - 24px - 14px - 4.6rem - 22px) * 0.75));
  }

  /* Captions run one to four lines. Holding room for three keeps the foot of the spread at
     one height from page to page. */
  .art-caption {
    max-width: min(100%, 56ch);
    min-height: calc(1.55em * 3);
    text-wrap: balance;
  }

  /* ------------------------------------------------------------------
     Right page: reading typography
     At the old 17px the column ran to about 77 characters a line. A
     slightly larger face brings it to about 70 (63 at the larger size),
     which is easier on older eyes across a wide page.
     ------------------------------------------------------------------ */
  :root {
    --reading-size: 1.14rem;
  }

  body.is-large-text {
    --reading-size: 1.3rem;
  }

  /* Running heads: the two rules must meet across the spine. Each head is held to one line's
     height with its text sitting on the rule, so a long time-of-day note wraps upward into
     the top margin instead of pushing the right-hand rule below the left. */
  .page-folio {
    box-sizing: border-box;
    height: calc(1.2em + 15px);
    line-height: 1.2;
    align-items: flex-end;
  }

  .page-folio time {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .page-folio--right > span {
    text-align: right;
    text-wrap: balance;
  }

  .year-switcher {
    margin: -10px 0 16px;
  }

  .year-pill-part {
    font-weight: 400;
  }

  .devotion-header {
    margin-bottom: 20px;
  }

  .devotion-title {
    text-wrap: balance;
  }

  .scripture-callout {
    margin-bottom: 28px;
    padding: 14px 20px 13px;
  }

  .scripture-quote {
    margin-bottom: 7px;
    font-size: 1.06rem;
    text-wrap: pretty;
  }

  .devotion-body {
    padding-bottom: 34px;
  }

  .devotion-body p {
    text-wrap: pretty;
  }

  .devotion-body p:last-child {
    margin-bottom: 0;
  }

  /* Drop cap: a true two-line initial. Its top meets the capitals of the first line and it
     sits on the baseline of the second, at either text size. The sizes are worked out from
     the reading leading and Newsreader's cap height (0.70em) and ascent (0.74em). */
  .devotion-body p:first-child::first-letter {
    font-size: calc((var(--reading-leading) + 0.7) / 0.7 * 1em);
    line-height: 0.8;
    padding: calc(
        (1.5 * var(--reading-leading) + 0.24) / ((var(--reading-leading) + 0.7) / 0.7) * 1em -
          0.6em
      )
      0.03em 0 0;
  }

  /* Where the browser can set an initial letter itself, let it: the alignment is exact */
  @supports (initial-letter: 2) {
    .devotion-body:not(.is-original):not(.is-loading):not(.has-brief-opening)
      p:first-child::first-letter {
      float: none;
      font-size: inherit;
      line-height: inherit;
      padding: 0;
      initial-letter: 2;
    }
  }

  /* A one-line opening has nothing to wrap around a two-line capital */
  .devotion-body.has-brief-opening p:first-child::first-letter {
    font-size: inherit;
    line-height: inherit;
    float: none;
    padding: 0;
    color: inherit;
    font-weight: inherit;
  }

  /* An opening quotation mark hangs in the margin beside the capital instead of being
     blown up with it */
  .devotion-body:not(.is-original) p:first-child {
    position: relative;
  }

  .devotion-body:not(.is-original) .lead-quote {
    position: absolute;
    right: 100%;
    top: -0.12em;
    margin-right: 0.06em;
    font-size: 1.9em;
    line-height: 1.2;
    color: var(--moss);
    opacity: 0.72;
  }

  .devotion-body.has-brief-opening .lead-quote {
    position: static;
    margin: 0;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    opacity: 1;
  }

  /* ------------------------------------------------------------------
     Browse panel: an index you can drive from the keyboard
     ------------------------------------------------------------------ */
  .index-drawer {
    width: min(480px, 94vw);
    animation: bdp-drawer-in 200ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .drawer-backdrop {
    animation: bdp-backdrop-in 200ms ease-out;
  }

  @keyframes bdp-drawer-in {
    from {
      transform: translateX(28px);
      opacity: 0;
    }
  }

  @keyframes bdp-backdrop-in {
    from {
      opacity: 0;
    }
  }

  /* The pale brass focus ring is drawn for the dark cloth; on paper it needs moss */
  .index-drawer :focus-visible {
    outline-color: var(--moss);
  }

  .search-input {
    font-size: 0.9rem;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .filter-status {
    justify-content: flex-start;
    gap: 14px;
  }

  #filterSummary {
    margin-right: auto;
  }

  .find-place-btn {
    display: inline-block;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--moss);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 4px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .find-place-btn:focus-visible {
    outline: 2px solid var(--moss);
    outline-offset: 2px;
  }

  .drawer-scroll {
    padding: 8px 12px 24px;
    scroll-padding: 12px 0;
  }

  /* Rows read as lines in an index, not a stack of cards */
  .toc-list {
    gap: 1px;
  }

  .toc-btn {
    grid-template-columns: 42px 1fr;
    gap: 13px;
    padding: 9px 10px;
    border-color: transparent;
    background: transparent;
  }

  .toc-btn:hover {
    border-color: transparent;
    background: rgba(59, 91, 69, 0.06);
  }

  .toc-btn:focus-visible {
    outline-offset: -2px;
    background: rgba(59, 91, 69, 0.06);
  }

  .toc-thumb,
  .toc-thumb-placeholder {
    width: 42px;
    height: 56px;
  }

  .toc-title {
    font-size: 1.04rem;
  }

  /* The devotion open in the book: tinted, with the ribbon's ochre down its edge */
  .toc-btn.is-current {
    border-color: transparent;
    background: var(--moss-soft);
    box-shadow: inset 3px 0 0 var(--ochre-ribbon);
  }

  .toc-btn.is-current .toc-date {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
  }

  .toc-btn.is-current .toc-date::after {
    content: "Open in the book";
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--muted-ink);
  }

  .toc-more-wrap {
    padding: 0 10px;
  }
}

@media screen and (min-width: 961px) and (prefers-reduced-motion: reduce) {
  .page-folio > *,
  .art-plate,
  .year-switcher,
  .devotion-header,
  .scripture-callout,
  .devotion-body,
  .devotion-share,
  .devotion-signoff,
  .book-spread.is-turning .page-folio > *,
  .book-spread.is-turning .art-plate,
  .book-spread.is-turning .year-switcher,
  .book-spread.is-turning .devotion-header,
  .book-spread.is-turning .scripture-callout,
  .book-spread.is-turning .devotion-body,
  .book-spread.is-turning .devotion-share,
  .book-spread.is-turning .devotion-signoff {
    transition: none;
  }

  .index-drawer,
  .drawer-backdrop {
    animation: none;
  }
}
