/* Shared UI hardening for standalone editorial pages. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
  width: 100%;
}

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

body {
  min-width: 0;
}

img,
svg,
video,
canvas {
  height: auto;
  max-width: 100%;
}

.page,
.page-container {
  margin-inline: auto !important;
  max-width: min(960px, calc(100% - 32px)) !important;
  min-width: 0;
  padding-inline: 0 !important;
  width: 100% !important;
}

.page > header,
.page-container > header {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem) !important;
  padding: clamp(0.75rem, 2vw, 1.5rem) 0 0 !important;
}

.page > header:hover,
.page-container > header:hover {
  box-shadow: none !important;
  transform: none !important;
}

.page h1,
.page-container h1 {
  font-size: clamp(2rem, 3vw, 2.5rem) !important;
  line-height: 1.1 !important;
  margin-inline: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.page > header .subtitle,
.page-container > header .subtitle {
  margin-inline: auto;
  max-width: 52ch;
}

.grid,
.example-grid,
.genres-grid,
.decision-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)) !important;
  min-width: 0;
}

.card,
.example-card,
.genre-card,
.book-card,
.decision-card,
.recommendation-card {
  min-width: 0;
  overflow: hidden;
}

.card .title,
.example-card h2,
.example-card h3,
.genre-name,
.book-card h3,
.decision-card h3,
.step-content h2 {
  font-size: clamp(1.12rem, 0.55vw + 1rem, 1.28rem) !important;
  line-height: 1.28 !important;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.page p,
.page li,
.page-container p,
.page-container li,
.step-content {
  min-width: 0;
  overflow-wrap: break-word;
}

.meta {
  align-items: center;
  column-gap: 0.65rem !important;
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  row-gap: 0.4rem !important;
}

.meta > span {
  min-width: 0;
}

.meta > span:not(.pill) {
  white-space: nowrap;
}

.pill,
.scenario-badge,
.tag,
.category,
.badge {
  line-height: 1.1;
  max-width: 100%;
  white-space: normal;
}

.card > .cta {
  align-self: flex-start;
  align-items: center;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: var(--accent) !important;
  display: inline-flex;
  gap: 0.48rem;
  font-weight: 800;
  margin-top: auto;
  padding: 0 !important;
  text-decoration: none;
}

.card > .cta::after {
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
  content: "";
  flex: 0 0 auto;
  height: 0.48rem;
  transform: rotate(45deg);
  transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1);
  width: 0.48rem;
}

.card > .cta:hover {
  color: var(--text) !important;
  text-decoration: underline;
  text-decoration-color: var(--amber-3);
}

.card:hover > .cta::after {
  transform: translateX(3px) rotate(45deg);
}

.callout,
.source-note,
.affiliate-note,
.tip-box,
.affiliate-box,
.book-highlight {
  background: var(--surface-accent) !important;
  border: 1px solid var(--amber-2) !important;
  border-left: 4px solid var(--amber-3) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-card) !important;
  color: var(--text) !important;
}

.source-note,
.affiliate-note {
  color: var(--muted) !important;
}

.source-note a,
.affiliate-note a,
.callout a {
  overflow-wrap: anywhere;
}

.book-card {
  grid-template-columns: minmax(0, 160px) minmax(0, 1fr) !important;
}

.book-cover-wrapper,
.book-content {
  min-width: 0;
}

.book-buy,
.amazon-button,
.amazon-btn,
.btn,
.btn-primary,
.btn-white,
.cta-button {
  max-width: 100%;
  min-width: 0;
  text-align: center;
  white-space: normal;
}

.page a.book-buy,
.page-container a.book-buy,
.book-buy {
  align-items: center;
  background: var(--ink-1) !important;
  border: 1px solid var(--ink-1) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-card) !important;
  color: var(--text-inverse) !important;
  display: inline-flex;
  font-family: var(--font-sans) !important;
  font-weight: 800 !important;
  gap: 0.6rem;
  justify-content: center;
  transition: background-color 140ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 140ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 140ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1);
}

.book-buy::after {
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
  content: "";
  flex: 0 0 auto;
  height: 0.52rem;
  margin-left: 0.05rem;
  transform: rotate(45deg);
  transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1);
  width: 0.52rem;
}

body .page a.book-buy:not(.btn):not(.btn-primary):not(.btn-white):not(.card):not(.genre-card),
body .page-container a.book-buy:not(.btn):not(.btn-primary):not(.btn-white):not(.card):not(.genre-card) {
  color: var(--text-inverse) !important;
}

.page a.book-buy:hover,
.page-container a.book-buy:hover,
.book-buy:hover {
  background: #3a3226 !important;
  border-color: #3a3226 !important;
  box-shadow: var(--shadow-raised) !important;
  color: var(--text-inverse) !important;
  transform: translateY(-1px);
}

.book-buy:hover::after {
  transform: translateX(3px) rotate(45deg);
}

body .page a.book-buy:not(.btn):not(.btn-primary):not(.btn-white):not(.card):not(.genre-card):hover,
body .page-container a.book-buy:not(.btn):not(.btn-primary):not(.btn-white):not(.card):not(.genre-card):hover {
  color: var(--text-inverse) !important;
}

.cta-section,
.cta {
  max-width: 100%;
  overflow: hidden;
}

.cta h2,
.cta h3,
.cta-section h2 {
  overflow-wrap: break-word;
}

.back,
.back-link {
  max-width: 100%;
  overflow-wrap: break-word;
}

.step-number {
  background: linear-gradient(180deg, var(--paper-0), var(--paper-2)) !important;
  border: 1px solid var(--amber-2) !important;
  border-radius: 999px !important;
  box-shadow: 0 1px 2px rgba(90, 70, 30, 0.06),
    0 8px 18px rgba(90, 70, 30, 0.08),
    inset 0 0 0 5px rgba(251, 239, 217, 0.78) !important;
  color: var(--accent) !important;
  font-family: var(--font-sans) !important;
  font-size: 1rem !important;
  font-weight: 800 !important;
  height: 3rem !important;
  letter-spacing: 0 !important;
  line-height: 1 !important;
  position: relative;
  width: 3rem !important;
}

.step-number::after {
  background: var(--amber-3);
  border-radius: 999px;
  bottom: 0.55rem;
  content: "";
  height: 2px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  width: 1rem;
}

@media (max-width: 760px) {
  .page,
  .page-container {
    max-width: calc(100% - 24px) !important;
    width: 100% !important;
  }

  .page h1,
  .page-container h1 {
    font-size: clamp(1.5rem, 5.8vw, 1.85rem) !important;
    line-height: 1.12 !important;
    max-width: 100%;
    text-wrap: balance;
  }

  .card,
  .example-card,
  .genre-card,
  .book-card,
  .decision-card {
    border-radius: var(--radius-md) !important;
    padding: 1.2rem !important;
  }

  .card .title {
    font-size: 1.08rem !important;
    line-height: 1.3 !important;
  }

  .meta {
    font-size: 0.92rem !important;
  }

  .book-card {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .book-cover-wrapper {
    align-items: center;
  }

  .book-cover,
  .book-buy {
    max-width: 210px;
  }

  .step-number {
    height: 2.75rem !important;
    width: 2.75rem !important;
  }

  .genre-card {
    grid-template-columns: auto minmax(0, 1fr) !important;
  }
}

@media (max-width: 420px) {
  .page,
  .page-container {
    max-width: calc(100% - 20px) !important;
    width: 100% !important;
  }

  .page h1,
  .page-container h1 {
    font-size: clamp(1.45rem, 6.2vw, 1.72rem) !important;
    max-width: 100%;
  }

  .page > header .subtitle,
  .page-container > header .subtitle {
    font-size: 1rem !important;
  }

  .meta {
    column-gap: 0.5rem !important;
  }

  .pill {
    font-size: 0.78rem !important;
    padding: 0.28rem 0.58rem !important;
  }
}
