/*
 * TODAY / RECOVERY / MENTAL homepage card-system lock.
 *
 * TODAY remains the structural reference. All three homepages share one warm
 * stone foundation; Recovery and Mental retain their approved artwork and
 * section accents inside TODAY's 15:7 manufactured card system.
 */

:is(#today.page, #recovery.page, #mental.page) {
  --rebuild-home-foundation: #e5dad1;
  --rebuild-home-foundation-light: #eee6de;
  --rebuild-home-foundation-mid: #e8ddd3;
  --rebuild-home-foundation-deep: #ddd0c5;
  --rebuild-home-card-parent-gutter: 15px;
  --rebuild-home-card-width: 94%;
  --rebuild-home-card-ratio: 15 / 7;
  --rebuild-home-card-gap: 24px;
  --rebuild-home-card-radius: 20px;
  --rebuild-home-card-surface: #eee2d4;
  --rebuild-home-card-highlight: #fffaf4;
  --rebuild-home-card-bevel: #d6c4b3;
  --rebuild-home-card-plane: linear-gradient(145deg, #f1e7dc 0%, #eee2d4 54%, #ded0c3 100%);
  --rebuild-home-card-frame:
    0 0 0 2px #eee2d4,
    -1px -1px 0 4px #fffaf4,
    1px 2px 0 4px #d6c4b3,
    0 7px 7px 4px rgba(59, 48, 40, 0.22),
    0 14px 22px 5px rgba(50, 42, 35, 0.15);
}

/* One neutral canvas: Recovery's approved richer stone treatment. */
html body :is(#today.page, #recovery.page, #mental.page) {
  background-color: var(--rebuild-home-foundation) !important;
  background-image:
    radial-gradient(at 14% 7%, rgba(255, 255, 255, 0.46) 0, rgba(255, 255, 255, 0.16) 28%, transparent 52%),
    radial-gradient(at 86% 31%, rgba(151, 128, 110, 0.12) 0, transparent 38%),
    repeating-radial-gradient(circle at 25% 35%, rgba(77, 62, 51, 0.02) 0 0.7px, transparent 0.9px 5px),
    linear-gradient(164deg, var(--rebuild-home-foundation-light) 0%, var(--rebuild-home-foundation-mid) 47%, var(--rebuild-home-foundation-deep) 100%) !important;
}

html body main.app:has(> :is(#today.page, #recovery.page, #mental.page).on) {
  background: var(--rebuild-home-foundation) !important;
}

#mental.page .mental-approved-home {
  background-color: transparent !important;
  background-image: none !important;
}

/* Recovery uses the same content track as TODAY's 15px-inset body. */
#recovery.page :is(.recovery-urgent-grid, .recovery-hub) {
  width: calc(100% - (var(--rebuild-home-card-parent-gutter) * 2)) !important;
  margin-inline: auto !important;
  gap: var(--rebuild-home-card-gap) !important;
}

#recovery.page .recovery-hub {
  margin-top: var(--rebuild-home-card-gap) !important;
}

#recovery.page :is(.recovery-support-card, .recovery-hub-card),
#mental.page :is(.mental-quiet-reset, .mental-quiet-card),
#mental.page .mental-needs-grid > .mental-photo-card {
  width: var(--rebuild-home-card-width) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: var(--rebuild-home-card-ratio) !important;
  margin-inline: auto !important;
  border: 0 !important;
  border-radius: var(--rebuild-home-card-radius) !important;
  box-sizing: border-box !important;
  background-color: var(--rebuild-home-card-surface) !important;
  box-shadow: var(--rebuild-home-card-frame) !important;
}

#recovery.page :is(.recovery-support-card, .recovery-hub-card) {
  padding: 0 !important;
  overflow: visible !important;
}

#recovery.page .recovery-card-visual {
  border-radius: inherit !important;
}

#recovery.page .recovery-premium-card-plate,
#recovery.page .recovery-premium-card-plate > img {
  border-radius: inherit !important;
}

/* TODAY's icon/copy rhythm, adapted only to the existing Recovery content. */
#recovery.page :is(.recovery-support-icon, .recovery-hub-icon) {
  top: 12px !important;
  left: 13px !important;
  width: 43px !important;
  height: 43px !important;
}

#recovery.page .recovery-support-card .k,
#recovery.page .recovery-hub-copy small {
  top: 20px !important;
  right: auto !important;
  left: 64px !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 2px 3px 1px !important;
  box-sizing: border-box;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(238, 226, 212, 0.94), rgba(238, 226, 212, 0.58) 82%, transparent);
  line-height: 1.16 !important;
  white-space: normal !important;
}

#recovery.page .recovery-support-card .k {
  width: calc(59% - 72px) !important;
}

#recovery.page .recovery-hub-copy small,
#recovery.page .recovery-hub-card.fellowship .recovery-hub-copy small {
  width: calc(100% - 72px) !important;
}

#recovery.page :is(.recovery-support-card.craving-now, .recovery-support-card.struggling-now) {
  display: flex !important;
  padding: 55px 44% 7px 14px !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: center !important;
}

#recovery.page .recovery-support-card h2 {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  font-size: 22px !important;
  line-height: 0.96 !important;
}

#recovery.page .recovery-support-card.struggling-now h2 {
  font-size: 21px !important;
}

#recovery.page .recovery-support-card p,
#recovery.page .recovery-support-card.struggling-now p {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 7px 0 0 !important;
  padding: 0 !important;
  font-size: 12px !important;
  line-height: 1.18 !important;
  letter-spacing: -0.01em;
}

#recovery.page .recovery-hub-copy,
#recovery.page .recovery-hub-card.tools .recovery-hub-copy,
#recovery.page .recovery-hub-card.journey .recovery-hub-copy,
#recovery.page .recovery-hub-card.fellowship .recovery-hub-copy {
  inset: 0 41% 0 0 !important;
  width: auto !important;
  padding: 55px 6px 9px 14px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: stretch !important;
}

#recovery.page .recovery-hub-copy b,
#recovery.page .recovery-hub-card.journey .recovery-hub-copy b,
#recovery.page .recovery-hub-card.fellowship .recovery-hub-copy b {
  margin: 0 !important;
  font-size: 20px !important;
  line-height: 0.98 !important;
  text-wrap: balance;
}

#recovery.page .recovery-hub-copy em,
#recovery.page .recovery-hub-card.fellowship .recovery-hub-copy em {
  margin-top: 5px !important;
  font-size: 12px !important;
  line-height: 1.18 !important;
  text-wrap: pretty;
}

/* Mental's two card stacks use one TODAY-sized track and one 24px rhythm. */
#mental.page .mental-quiet-top {
  width: 100% !important;
  gap: var(--rebuild-home-card-gap) !important;
}

#mental.page .mental-needs-grid {
  width: 100% !important;
  gap: var(--rebuild-home-card-gap) !important;
  padding: 7px 0 20px !important;
}

#mental.page :is(.mental-quiet-reset, .mental-quiet-card) {
  justify-self: center;
}

#mental.page .mental-quiet-reset {
  padding: 10px 16px 10px 10px !important;
  background: var(--rebuild-home-card-plane) !important;
}

#mental.page .mental-quiet-reset::before {
  background: linear-gradient(145deg, #f1e7dc 0%, #e4d6c8 100%) !important;
}

/* The Mental photography remains unchanged; only its pale paper plane is
   calibrated to the shared warm-stone card surface. */
#mental.page .mental-quiet-card {
  padding: 0 !important;
  background: var(--rebuild-home-card-plane) !important;
}

#mental.page .mental-quiet-card::after {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: 2;
  border-radius: 16px;
  background: linear-gradient(
    90deg,
    rgba(238, 226, 212, 0.88) 0%,
    rgba(238, 226, 212, 0.82) 34%,
    rgba(238, 226, 212, 0.52) 43%,
    rgba(238, 226, 212, 0) 57%
  );
  pointer-events: none;
}

#mental.page .mental-quiet-card > .mental-quiet-icon {
  position: absolute !important;
  top: 12px !important;
  left: 13px !important;
  width: 43px !important;
  height: 43px !important;
  min-width: 43px !important;
  min-height: 43px !important;
}

#mental.page .mental-quiet-card > .mental-quiet-card-copy {
  position: absolute !important;
  inset: 60px auto 12px 14px !important;
  display: grid !important;
  width: 46% !important;
  margin: 0 !important;
  gap: 6px !important;
  align-content: center !important;
}

#mental.page .mental-quiet-card .mental-quiet-title {
  font-size: 20px !important;
  line-height: 1 !important;
}

#mental.page .mental-quiet-card .mental-quiet-detail {
  font-size: 12.5px !important;
  line-height: 1.24 !important;
}

/* Preserve the approved visible artwork crop while the outer frame can cast. */
#mental.page .mental-quiet-card > .mental-primary-art-v3,
#mental.page .mental-needs-grid > .mental-photo-card > .mental-lower-relief-art {
  overflow: hidden !important;
}

#mental.page .mental-needs-grid > .mental-photo-card {
  justify-self: center;
  overflow: visible !important;
}

#mental.page .mental-needs-grid > .mental-photo-card::after {
  border-radius: 16px !important;
  background: linear-gradient(
    90deg,
    rgba(238, 226, 212, 0.98) 0%,
    rgba(238, 226, 212, 0.95) 34%,
    rgba(238, 226, 212, 0.78) 43%,
    rgba(238, 226, 212, 0.34) 52%,
    rgba(238, 226, 212, 0) 62%
  ) !important;
}

#mental.page .mental-needs-grid > .mental-photo-card > .mental-lower-relief-art {
  border-radius: 16px !important;
}

#mental.page .mental-needs-grid > .mental-photo-card > .mental-card-icon {
  top: 12px !important;
  left: 13px !important;
}

#mental.page .mental-needs-grid > .mental-photo-card > .mental-card-copy {
  inset: 60px auto 12px 14px !important;
  display: grid !important;
  width: 46% !important;
  max-width: 46% !important;
  gap: 6px !important;
  align-content: center !important;
}

#mental.page .mental-needs-grid > .mental-photo-card > .mental-card-copy > b {
  margin: 0 !important;
  font-size: 20px !important;
  line-height: 1 !important;
}

#mental.page .mental-needs-grid > .mental-photo-card > .mental-card-copy > small {
  margin: 0 !important;
  font-size: 12.5px !important;
  line-height: 1.24 !important;
}

#mental.page .mental-needs-grid > .mental-photo-card.sleep > .mental-card-copy {
  width: 43% !important;
  max-width: 43% !important;
}

#mental.page .mental-needs-grid > .mental-photo-card.confidence > .mental-card-copy {
  width: 45% !important;
  max-width: 45% !important;
}

@media (max-width: 360px) {
  :is(#today.page, #recovery.page, #mental.page) {
    --rebuild-home-card-parent-gutter: 12px;
    --rebuild-home-card-width: 95%;
  }

  #mental.page :is(.mental-quiet-top, .mental-needs-grid) {
    width: calc(100% + 6px) !important;
    margin-left: -3px !important;
  }

  #recovery.page .recovery-support-card p,
  #recovery.page .recovery-support-card.struggling-now p {
    font-size: 11.5px !important;
    line-height: 1.16 !important;
  }

  #mental.page .mental-quiet-card .mental-quiet-title,
  #mental.page .mental-needs-grid > .mental-photo-card > .mental-card-copy > b {
    font-size: 18px !important;
  }
}

@media (min-width: 411px) and (max-width: 799px) {
  #mental.page :is(.mental-quiet-top, .mental-needs-grid) {
    width: calc(100% + 6px) !important;
    margin-left: -3px !important;
  }
}

@media (min-width: 800px) {
  #recovery.page :is(.recovery-urgent-grid, .recovery-hub),
  #mental.page :is(.mental-quiet-top, .mental-needs-grid) {
    width: 100% !important;
  }

  #recovery.page :is(.recovery-support-card, .recovery-hub-card),
  #mental.page :is(.mental-quiet-reset, .mental-quiet-card),
  #mental.page .mental-needs-grid > .mental-photo-card {
    width: min(72%, 620px) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #recovery.page :is(.recovery-support-card, .recovery-hub-card),
  #mental.page :is(.mental-quiet-reset, .mental-quiet-card),
  #mental.page .mental-needs-grid > .mental-photo-card {
    transition: none !important;
  }
}

@media (forced-colors: active) {
  #recovery.page :is(.recovery-support-card, .recovery-hub-card),
  #mental.page :is(.mental-quiet-reset, .mental-quiet-card),
  #mental.page .mental-needs-grid > .mental-photo-card {
    border: 2px solid ButtonText !important;
    background: Canvas !important;
    box-shadow: none !important;
  }
}
