/*
 * Shared paper layout for the public pages opted in with .print-page.
 * Printing keeps the current page and selected state; it does not open
 * disclosures, reveal answers, or turn private form fields into an export.
 */
@media print {
  @page {
    size: auto;
    margin: 16mm;
  }

  html {
    font-size: 11pt;
  }

  body.print-page {
    margin: 0 !important;
    background: #fff !important;
    color: #111 !important;
    font-size: 11pt !important;
    line-height: 1.45 !important;
  }

  body.print-page main,
  body.print-page main * {
    color: #111 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    animation: none !important;
    transition: none !important;
  }

  body.print-page main,
  body.print-page .wrap,
  body.print-page .container {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin-inline: 0 !important;
    padding-inline: 0 !important;
  }

  body.print-page main::before {
    content: "The Turn Ahead | Education. Accountability. Action.";
    display: block;
    margin: 0 0 12pt;
    padding-bottom: 6pt;
    border-bottom: 1px solid #999;
    color: #111;
    font: 9pt/1.4 ui-sans-serif, system-ui, sans-serif;
    break-after: avoid;
    page-break-after: avoid;
  }

  body.print-page main :is(h1, h2, h3, h4, h5, h6) {
    line-height: 1.2 !important;
    letter-spacing: normal !important;
    margin: 10pt 0 6pt !important;
    break-after: avoid;
    page-break-after: avoid;
  }

  body.print-page main h1 {
    font-size: 24pt !important;
    margin-top: 0 !important;
  }

  body.print-page main h2 {
    font-size: 17pt !important;
  }

  body.print-page main h3 {
    font-size: 14pt !important;
  }

  body.print-page main :is(h4, h5, h6) {
    font-size: 11pt !important;
  }

  body.print-page main :is(p, li, blockquote) {
    orphans: 3;
    widows: 3;
  }

  body.print-page main p {
    font-size: 11pt !important;
    line-height: 1.45 !important;
    margin-bottom: 6pt !important;
  }

  body.print-page main blockquote {
    font-size: 12pt !important;
    line-height: 1.45 !important;
    margin: 8pt 0 !important;
  }

  body.print-page main img {
    max-width: 100% !important;
    max-height: 60mm !important;
    object-fit: contain;
  }

  body.print-page main :is(.lead, .section-head > p, .description) {
    font-size: 11pt !important;
    line-height: 1.45 !important;
    max-width: none !important;
  }

  body.print-page main :is(
    small, .eyebrow, .pill, .tiny, .notice, .field-note, .stage-label,
    .card-tag, .card-bottom, .board-count, .board-stats-note, .board-disclosure,
    .resource-meta, .resource-related, .ripple-stage-label, .ripple-story-toolbar > span,
    .learning-caption, .kq-footer p, .kq-source, .lp-source, .lp-storage,
    .alcohol-source, .alcohol-caption, .alcohol-small
  ) {
    font-size: 9pt !important;
    line-height: 1.4 !important;
  }

  body.cost-page :is(.prevent-stat .large-number, .cost-hero-total strong, .scenario-amount),
  body.learn-page .learning-metric strong,
  body.alcohol-page .alcohol-spending-total > strong {
    font-size: 20pt !important;
    line-height: 1.15 !important;
    letter-spacing: normal !important;
    margin: 4pt 0 !important;
  }

  body.print-page .hero-aside > strong,
  body.print-page .tool-illustration > strong,
  body.print-page .program > strong,
  body.print-page .resource > strong,
  body.print-page .ripple-story-ending > strong {
    font-size: 14pt !important;
  }

  body.print-page :is(.board-stats-grid strong, .impact-metrics strong, .journey-summary .day) {
    font-size: 20pt !important;
    line-height: 1.15 !important;
  }

  body.print-page .rhythm-days span {
    font-size: 14pt !important;
    padding: 6pt;
  }

  body.learn-page .mini-chart .level strong {
    font-size: 14pt !important;
    line-height: 1.2 !important;
  }

  /* Dark panels must remain readable when background graphics are disabled. */
  body.print-page main :is(
    section, article, aside, .belief-detail, .cost-hero-total, .method,
    .scenario-time, .impact-strip > div, .path-card, .learn-path,
    .learning-block-header, .learning-earned, .guide-progress,
    .knowledge-quiz .kq-shell, .kq-feedback, .kq-result, .kq-message,
    .kq-topic, .lp-shell, .level, .support-band, .takeaway, .safety,
    .alcohol-measures, .alcohol-pattern, .alcohol-reflection-panel,
    .hero-card, .home-next-picker, .home-next-result, .today-return-banner,
    .today-turn-card, .today-turn-question, .choice-panel, .option, .saved,
    .tool-card, .journey-summary, .journey-stage .prompt,
    .turn-next-marker, .turn-daily-summary, .turn-daily-editor,
    .turn-state-options span, .today-journey-idea, .journal-notice,
    .board-hero-art, .support-pills span, .public-empty, .commitment-card,
    .builder-panel, .builder-aside, .board-consent, .card-initial, .card-tag,
    .draft-box, .draft-preview, .guideline, .wall-removal, .removal-area,
    .stories-private-callout, .story-contribute-side, .story-removal,
    .impact-truth-card, .resources-purpose, .resource-controls,
    .resource-card, .resource-empty, .resource-fallback,
    .ride-option, .ride-option-icon, .ride-reset, .ride-next,
    .ripple-story, .ripple-node, .symbol-showcase, .meaning, .program
  ) {
    background: #fff !important;
    border-color: #999 !important;
  }

  /* Navigation and commands only: content-bearing buttons stay printable. */
  body.print-page > header,
  body.print-page > footer,
  body.print-page .site-menu-toggle,
  body.print-page .skip-link,
  body.print-page .home-skip-link,
  body.print-page .resource-skip,
  body.print-page .resources-back,
  body.print-page .tool-actions,
  body.print-page .tool-export-note,
  body.print-page .today-daily-reminder,
  body.print-page .knowledge-quiz .kq-actions,
  body.print-page .knowledge-quiz .kq-footer-actions,
  body.print-page .knowledge-quiz .kq-topic-jump,
  body.print-page .ripple-replay,
  body.print-page #today-share-idea,
  body.print-page #save-commitment,
  body.print-page #download-commitment,
  body.print-page #calendar,
  body.print-page #wallet-commitment,
  body.print-page #share-count,
  body.print-page #share-reset,
  body.print-page #copy-invite,
  body.print-page #clear-device,
  body.print-page #download-checkins,
  body.print-page #daily-guest-save,
  body.print-page .journey-stage [data-save-day],
  body.print-page #clear-reflections,
  body.print-page #board-more,
  body.print-page #board-form > .stack,
  body.print-page #submit-public,
  body.print-page #copy-removal,
  body.print-page #withdraw-submission,
  body.print-page .wall-submit-actions,
  body.print-page #wall-more,
  body.print-page #copy-message-removal,
  body.print-page #withdraw-message,
  body.print-page #stories-load-more,
  body.print-page .story-contribute-actions,
  body.print-page #community-story-copy-removal,
  body.print-page #community-story-withdraw,
  body.print-page #resource-clear,
  body.print-page #resource-empty-clear,
  body.print-page #resource-more,
  body.print-page #turnstile-widget,
  body.print-page #encouragement-turnstile,
  body.print-page #community-story-turnstile,
  body.learn-page .learn-skip-link,
  body.learn-page .learning-choose-again,
  body.learn-page .learning-share-actions,
  body.learn-page #learning-clear-practice,
  body.learn-page #clear-progress,
  body.learn-page .kq-actions,
  body.learn-page .kq-footer-actions,
  body.learn-page .kq-topic-jump,
  body.alcohol-page .alcohol-skip,
  body.alcohol-page .alcohol-back,
  body.alcohol-page .alcohol-on-this-page,
  body.cost-page .tool-actions {
    display: none !important;
  }

  body.print-page main a {
    text-decoration: underline;
    overflow-wrap: anywhere;
  }

  /* Undo older print rules hiding content links along with action buttons. */
  body.print-page main :where(a.btn, a.button) {
    display: inline-block !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    font-size: 10pt !important;
    text-decoration: underline !important;
    transform: none !important;
  }

  body.print-page main :is(button, input, textarea, select) {
    max-width: 100%;
    font-size: 10pt !important;
    line-height: 1.4 !important;
  }

  body.print-page main button {
    background: #fff !important;
    border-color: #777 !important;
    min-height: 0 !important;
    padding: 6pt 8pt !important;
    transform: none !important;
  }

  body.print-page main :where(button[data-checkin]) {
    display: inline-block !important;
  }

  body.print-page main :is(button, .option)[aria-pressed="true"],
  body.print-page .turn-state-options input:checked + span {
    border: 2px solid #111 !important;
    font-weight: 700;
  }

  body.print-page main input:is([type="checkbox"], [type="radio"]) {
    accent-color: #111;
  }

  body.print-page main :focus {
    outline: none !important;
  }

  body.print-page .hero::after,
  body.print-page .hero-card .spark,
  body.print-page .board-brand-emblem,
  body.print-page .closing-mark,
  body.print-page .ride-mark,
  body.print-page .ripple-emblem::before,
  body.print-page .ripple-emblem::after,
  body.print-page .board-hero-art::after,
  body.print-page .journey-stage::before,
  body.print-page .journey-stage::after,
  body.print-page .ripple-story::before,
  body.print-page .ripple-story::after,
  body.print-page .hero-aside .line,
  body.cost-page .path-symbol,
  body.cost-page .belief-arrow,
  body.cost-page .stat-rule,
  body.learn-page .hero-aside .line,
  body.alcohol-page .alcohol-gold-line {
    display: none !important;
  }

  body.print-page main :is(
    .hero, .section, .alcohol-section, .learning-summary-section,
    .learn-path-section, .education-note, .alcohol-review, .cta-band,
    .prevention-bridge, .today-turn-section, .home-next-step-section,
    .home-support-strip, .board-stats-band, .stories-hero, .impact-hero,
    .resources-hero, .resource-directory, .resource-trust,
    .ride-hero, .ride-main, .ripple-lesson-hero, .ripple-section, .ripple-questions
  ) {
    padding: 12pt 0 !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body.print-page main :is(
    .section-head, .learn-path-heading, .learning-summary-head,
    .alcohol-section-intro
  ) {
    max-width: none !important;
    margin-bottom: 10pt !important;
  }

  /* Major layouts become a linear reading flow, rather than paper-sized grids. */
  body.print-page :where(
    .hero-grid, .tool-intro, .split, .home-next-layout, .home-next-choices,
    .home-support-inner, .today-turn-intro, .today-turn-grid, .kq-topics, .kq-choices,
    .hero-card, .today-turn-card, .tool-card, .commitment-card, .encouragement,
    .resource-card, .stories-hero-art, .draft-preview,
    .tool-grid, .option-grid, .resource-grid, .journey-layout,
    .turn-state-options, .board-hero-grid, .board-stats-grid,
    .purpose-grid, .commitment-grid, .builder-grid, .board-identity-grid,
    .closing-grid, .encouragement-grid, .draft-box, .guidelines,
    .stories-hero-grid, .stories-list, .stories-prompt-grid,
    .stories-private-callout, .story-contribute-shell,
    .impact-hero-inner, .impact-metrics, .impact-truth-grid, .impact-actions,
    .resources-hero-grid, .resource-urgent, .resource-directory-head,
    .resource-search-form, .resource-results, .resource-trust-grid,
    .ride-hero-grid, .ride-options, .ripple-intro, .ripple-next,
    .ripple-question-grid, .symbol-grid, .grid3, .programs
  ),
  body.cost-page :where(
    .tool-intro, .cost-layout, .guided-cost-layout, .belief-layout,
    .story-layout, .story-cards, .mission-note, .prevention-bridge-inner,
    .path-grid, .belief-list, .scenario-choices, .scenario-breakdown, .impact-strip
  ),
  body.learn-page :where(
    .hero-grid, .learn-paths, .learn-path-heading, .learning-summary-head,
    .learn-knowledge-layout, .chapter-grid, .learning-block-stack,
    .learning-set-grid, .learning-lesson-grid, .kq-topics,
    .kq-choices, .lp-choices, .lp-reason-list, .optional-ripple-lesson,
    .mini-chart, .support-bands
  ),
  body.alcohol-page :where(
    .hero-grid, .alcohol-section-intro, .alcohol-measures,
    .alcohol-strength-example, .alcohol-everyday-row, .alcohol-spending,
    .alcohol-routines-grid, .alcohol-aud-note, .alcohol-social-grid,
    .alcohol-people-close, .alcohol-reflection-choices, .alcohol-support
  ),
  body.alcohol-page :where(.alcohol-review > .wrap) {
    display: block !important;
    min-width: 0 !important;
    gap: 0 !important;
  }

  body.print-page :is(.sidebar, .sticky-summary, .story-heading, .journey-summary, .story-contribute-side) {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    order: initial !important;
  }

  /* Restore substantive Cost content omitted by the older print styles. */
  body.print-page :where(.cta-band, .wall-filters) {
    display: block !important;
  }

  body.cost-page :where(
    .story-section, .prevention-bridge, .guided-summary, .belief-bottom, .cta-band
  ) {
    display: block !important;
  }

  body.cost-page :where(.path-card, .scenario-choice, .belief-list button) {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 0 !important;
    padding: 9pt !important;
    margin: 8pt 0 !important;
  }

  body.cost-page .scenario-choice > :is(span, strong) {
    display: block;
    margin: 3pt 0;
  }

  body.cost-page .path-card h3 {
    max-width: none !important;
  }

  body.cost-page :is(.scenario-choice, .belief-list button)[aria-pressed="true"],
  body.alcohol-page .alcohol-reflection-choices button[aria-pressed="true"] {
    border: 2px solid #111 !important;
    font-weight: 700;
  }

  body.cost-page :is(.scenario-detail-heading, .scenario-line) {
    gap: 10pt;
  }

  body.cost-page .scenario-line {
    padding: 8pt 0;
  }

  body.cost-page .scenario-line-description {
    min-width: 0;
    max-width: none;
  }

  body.cost-page .scenario-line-amount {
    white-space: nowrap;
  }

  body.cost-page :is(.guided-summary-emphasis, .scenario-takeaway) {
    font-size: 11pt !important;
    line-height: 1.45 !important;
  }

  /* Long panels must be allowed to span pages; avoid only small reading units. */
  body.print-page main :is(
    .cost-panel, .tool-illustration, .sticky-summary, .belief-detail, .method,
    .chapter, .sidebar, .learning-block, .learning-block-body,
    .knowledge-quiz .kq-shell, .lp-shell, .kq-review-list, .lp-reason-list,
    .reveal, .alcohol-hero-note, .alcohol-measures, .alcohol-pattern,
    .alcohol-reflection-panel, .alcohol-next-step, .alcohol-review
  ) {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  body.print-page main :is(
    .scenario-line, .path-card, .scenario-choice, .belief-list button,
    .story-cards article, .impact-strip > div, .learning-item,
    .kq-choice, .lp-choice, .level, .support-band,
    .alcohol-picture li, .alcohol-everyday-row, .alcohol-pattern li,
    .alcohol-reflection-choices button, .alcohol-drink-table tr
  ) {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.print-page main :is(
    .tool-illustration, .hero-aside, .cost-panel, .sticky-summary,
    .belief-detail, .method, .story-cards article, .impact-strip > div,
    .chapter, .sidebar, .learn-path, .learning-item, .kq-shell, .lp-shell,
    .guide-progress, .alcohol-hero-note, .alcohol-drink-table-wrap,
    .alcohol-pour-note, .alcohol-spending, .alcohol-pattern,
    .alcohol-safety, .alcohol-reflection-panel
  ) {
    padding: 10pt !important;
    margin: 10pt 0 !important;
    border-radius: 3pt !important;
  }

  body.print-page main :is(
    .cost-hero-total, .scenario-time, .kq-feedback, .kq-result,
    .level, .support-band, .takeaway, .safety
  ) {
    padding: 8pt !important;
    margin: 8pt 0 !important;
  }

  body.learn-page .learning-block {
    margin: 12pt 0;
  }

  body.learn-page .learning-block-header {
    padding: 8pt 10pt !important;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: avoid;
    page-break-after: avoid;
  }

  body.learn-page .learning-block-body {
    padding: 10pt !important;
  }

  body.learn-page :is(.learning-item, .kq-choice, .lp-choice, .kq-topic) {
    margin-bottom: 8pt !important;
  }

  body.learn-page .learning-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 10pt;
    margin: 10pt 0;
  }

  body.learn-page .learning-metric {
    flex: 1 1 40mm;
    padding: 4pt 8pt;
  }

  body.learn-page :is(.finish-chapter, .optional-ripple-lesson) {
    margin-top: 8pt;
    padding-top: 8pt;
  }

  body.learn-page .kq-choice-body,
  body.learn-page .lp-choice-content {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body.alcohol-page :is(.alcohol-everyday-row, .alcohol-social-grid, .alcohol-aud-note, .alcohol-support) {
    padding: 10pt 0 !important;
  }

  body.alcohol-page :is(.alcohol-routines-grid > *, .alcohol-social-grid > *, .alcohol-support > *) + * {
    margin-top: 10pt;
  }

  body.alcohol-page :is(.alcohol-reflect, .alcohol-pattern-close, .alcohol-social-grid blockquote) {
    font-size: 11pt !important;
    line-height: 1.45 !important;
  }

  body.alcohol-page .alcohol-reflection-choices button {
    display: block;
    width: 100%;
    margin: 6pt 0;
  }

  body.alcohol-page .alcohol-spending-total {
    justify-content: flex-start;
    gap: 14pt;
    flex-wrap: wrap;
  }

  body.alcohol-page .alcohol-drink-table {
    width: 100%;
    font-size: 10pt !important;
  }

  body.alcohol-page .alcohol-drink-table :is(th, td) {
    padding: 6pt;
  }

  body.alcohol-page .alcohol-drink-table thead {
    display: table-header-group;
  }

  /* Public directory, community, commitment and 30-day layouts. */
  body.print-page main :is(
    .hero-card, .home-next-picker, .home-next-result, .today-turn-card,
    .choice-panel, .saved, .tool-card, .journey-summary, .journey-stage,
    .turn-daily-editor, .board-hero-art, .builder-panel, .builder-aside,
    .draft-box, .draft-preview, .stories-hero-art, .story-card,
    .stories-private-callout, .story-contribute-form, .story-contribute-side,
    .impact-truth-card, .resources-purpose, .resource-controls,
    .resource-card, .resource-empty, .resource-fallback,
    .ride-reset, .ride-next, .ripple-story, .meaning, .program
  ) {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 10pt !important;
    margin: 10pt 0 !important;
    border-radius: 3pt !important;
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  body.print-page main :is(
    .commitment-card, .encouragement, .resource, .guideline,
    .purpose-grid article, .impact-metrics article, .impact-actions article,
    .stories-prompt-grid article, .ride-option, .option, .home-next-choice
  ) {
    min-height: 0 !important;
    padding: 9pt !important;
    margin: 8pt 0 !important;
    border-radius: 3pt !important;
    break-inside: avoid;
    page-break-inside: avoid;
    transform: none !important;
  }

  body.print-page main :where(.option, .home-next-choice) {
    display: block !important;
    width: 100% !important;
    text-align: left;
  }

  body.print-page :is(.option > strong, .option > small, .home-next-choice > span, .home-next-choice > strong) {
    display: block;
    margin: 3pt 0;
  }

  body.print-page :is(.story-card, .commitment-card, .encouragement) :is(p, blockquote) {
    overflow-wrap: anywhere;
  }

  body.print-page :is(.story-contribute-form, .builder-panel, .draft-box, .journey-stage) :is(input, textarea, select) {
    box-sizing: border-box;
    max-width: 100% !important;
  }

  body.print-page .board-stats-grid > div {
    padding: 6pt 0;
    border-right: 0;
  }

  body.print-page .resource-filter {
    margin-bottom: 6pt;
  }

  body.print-page .resource-card-actions a[href^="https://"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    font-weight: normal;
    overflow-wrap: anywhere;
  }

  body.print-page :is(.hero-mark, .symbol-showcase) {
    width: 50mm !important;
    max-width: 100% !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    padding: 6pt !important;
    margin: 10pt 0 !important;
  }

  body.print-page :is(.hero-mark, .symbol-showcase) img {
    width: 42mm !important;
    height: auto !important;
    filter: none !important;
  }

  body.print-page :is(.stories-hero-art, .impact-hero-inner) > img {
    width: 25mm !important;
    height: auto !important;
    margin: 6pt 0 !important;
  }

  body.print-page .ripple-map {
    margin: 10pt 0;
    max-width: none;
  }

  body.print-page .ripple-stage {
    gap: 4pt;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.print-page .ripple-nodes {
    gap: 5pt;
  }

  body.print-page .ripple-node {
    min-width: 0;
    min-height: 0;
    padding: 5pt 8pt;
    font-size: 10pt;
  }

  body.print-page .ripple-connector {
    height: 12pt;
    background: #555 !important;
  }

  body.print-page .ripple-branch::after {
    width: 50mm;
    max-width: 100%;
    background: #555 !important;
  }

  body.print-page .ripple-story-ending {
    padding-top: 10pt;
    margin-top: 10pt;
  }

  /* Closed disclosures and hidden tracks retain their actual current state. */
  body.print-page details:not([open]) > :not(summary),
  body.print-page .hidden,
  body.print-page [hidden] {
    display: none !important;
  }

  /*
   * The one intentional exception is an already-synced summary mirror.
   * It contains only the current sharing preview, not generic form values.
   */
  body.learn-page #learning-overview[open] #learning-share-preview {
    display: none !important;
  }

  body.learn-page #learning-overview[open] #learning-print-summary[hidden] {
    display: block !important;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: inherit;
    height: auto;
    max-height: none;
    min-width: 0;
    overflow: visible;
    border: 1px solid #999;
    padding: 8pt;
    margin: 0 0 8pt;
    background: #fff;
    break-inside: auto;
    page-break-inside: auto;
  }
}
