.hero.topic-hero {
  --topic-ink: #594178;
  --topic-paper: #eee6f3;
  --rail-edge: clamp(20px, 2.8vw, 64px);
  display: block;
  width: 100%;
  padding: clamp(15px, 1.5vw, 26px) 0 clamp(38px, 4vw, 64px);
}

.topic-hero [data-topic="mindfulness"] { --topic-ink: #215e50; --topic-paper: #e3eee6; }
.topic-hero [data-topic="focus"] { --topic-ink: #393e83; --topic-paper: #e8e9f5; }
.topic-hero [data-topic="confidence"] { --topic-ink: #904738; --topic-paper: #f7e6df; }
.topic-hero [data-topic="stoicism"] { --topic-ink: #245c76; --topic-paper: #e3edf2; }
.topic-hero [data-topic="gratitude"] { --topic-ink: #76521c; --topic-paper: #f4ecd8; }

.topic-story {
  display: grid;
  width: min(var(--section-width), calc(100% - 48px));
  margin: clamp(28px, 3vw, 48px) auto 0;
  grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr);
  align-items: center;
  gap: clamp(24px, 4.2vw, 68px);
}
.topic-preview-slot { min-width: 0; container: preview-slot / inline-size; }

.topic-gallery-head, .topic-navigation, .topic-download-note,
.topic-preview-footer, .topic-formats {
  display: flex;
  align-items: center;
}

.topic-gallery-head {
  min-height: 44px;
  justify-content: space-between;
  gap: 18px;
  margin: 0 var(--rail-edge) 5px;
}

.topic-gallery-head p {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.025em;
}

.topic-navigation { gap: 2px; }
.topic-position { color: var(--ink-soft); font-size: .8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.topic-position [data-topic-position] { color: var(--ink); font-weight: 700; }

.topic-step {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.topic-step::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-inline-end: 3px;
  border: solid currentColor;
  border-width: 1.6px 1.6px 0 0;
  transform: rotate(45deg);
}

.topic-step[data-topic-step="-1"]::before { margin-inline: 3px 0; transform: rotate(-135deg); }
.topic-step:hover { background: var(--purple-pale); border-color: #b6a9ef; }
.topic-gallery-head .topic-step { border-color: transparent; }

.topic-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(10.75rem, 1fr);
  gap: clamp(10px, 1vw, 20px);
  margin: 0;
  padding: 7px var(--rail-edge) 5px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--rail-edge);
  scrollbar-width: thin;
}

.topic-hero[data-ready] .topic-rail { scrollbar-width: none; }
.topic-hero[data-ready] .topic-rail::-webkit-scrollbar { display: none; }
.topic-rail:focus-visible { outline: 2px solid var(--purple-dark); }

.topic-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  scroll-snap-align: start;
  cursor: pointer;
}

.topic-card:disabled { opacity: 1; cursor: default; }
.topic-cover {
  position: relative;
  display: block;
  overflow: hidden;
  isolation: isolate;
  height: clamp(116px, 10.1vw, 184px);
  border-radius: 13px;
  background: #454051;
  box-shadow: 0 1px 2px #2417281a;
}

.topic-cover > img, .topic-wallpaper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topic-cover::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(0deg, #17111cdb, #17111c91 34%, transparent 76%);
}

.topic-excerpt {
  position: absolute;
  z-index: 1;
  inset: auto 14px 13px;
  max-width: 13ch;
  color: white;
  font: normal clamp(1.28rem, 1.62vw, 1.7rem)/1.04 Georgia, "Times New Roman", serif;
  letter-spacing: -.035em;
  text-wrap: balance;
}

/* A single vector keeps the outlines and their optical alignment at both scales. */
.topic-card[data-format="widget"] .topic-cover::before,
.topic-preview[data-format="widget"] .topic-message-footer::after {
  content: "";
  aspect-ratio: 68 / 20;
  background: currentColor;
  mask: url("/icons/widget-actions.svg") center / contain no-repeat;
  pointer-events: none;
}

.topic-card[data-format="widget"] .topic-cover::before {
  position: absolute;
  z-index: 1;
  right: 12px;
  bottom: 10px;
  width: 48px;
  color: #fff;
}
.topic-card[data-format="widget"] .topic-excerpt { bottom: 29px; }

.topic-card[data-format="notification"] .topic-cover::after { background: linear-gradient(0deg, #17111c42, transparent 55%); }
.topic-card[data-format="notification"] .topic-excerpt {
  inset: auto 8px 9px;
  max-width: none;
  padding: 8px 10px 9px;
  border-radius: 12px;
  background: #faf8fcf0;
  color: #242127;
  font: 500 .875rem/1.25 system-ui, sans-serif;
  letter-spacing: -.015em;
  text-wrap: pretty;
}
.topic-mini-sender { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; font-size: .75rem; font-weight: 650; }
.topic-mini-sender img { border-radius: 4px; }
.topic-mini-sender small { margin-left: auto; font-size: .75rem; font-weight: 400; color: #59545e; }

.topic-name {
  font-size: .875rem;
  font-weight: 600;
}

.topic-card[aria-pressed="true"] .topic-cover {
  outline: 3px solid var(--topic-ink);
  outline-offset: 2px;
}
.topic-card[aria-pressed="true"] .topic-name {
  color: var(--topic-ink);
  font-weight: 800;
}
@media (hover: hover) and (pointer: fine) {
  .topic-card:enabled:hover .topic-name { color: var(--topic-ink); }
}

.topic-card:focus-visible { outline-offset: 3px; }
.topic-pitch h1 { font-size: clamp(3.1rem, 5vw, 4.75rem); line-height: 1.025; }
.topic-pitch h1 em { letter-spacing: -.055em; }
.topic-pitch .hero-lead { max-width: 40ch; margin-top: 16px; font-size: clamp(1rem, 1.3vw, 1.1875rem); }
.topic-pitch .store-actions { margin-top: 24px; }
.topic-pitch .store-link, .topic-pitch .store-link img { height: 48px; min-height: 48px; }
.topic-download-note { flex-wrap: wrap; gap: 0 14px; margin-top: 7px; }
.topic-download-note .availability { margin: 0; }
.topic-download-note .text-link { font-size: .8125rem; }

.topic-preview {
  --status-ink: #271b30;
  display: grid;
  grid-template: "caption device" auto / minmax(0, .79fr) minmax(0, 1.21fr);
  align-items: stretch;
  gap: clamp(12px, 2vw, 30px);
  overflow: clip;
  isolation: isolate;
  margin: 0;
  padding: clamp(16px, 1.9vw, 28px) clamp(16px, 1.9vw, 28px) 0;
  border: 1px solid color-mix(in srgb, var(--topic-ink) 15%, var(--topic-paper));
  border-radius: 24px;
  background-color: var(--topic-paper);
}

.topic-preview:is([data-topic="mindfulness"], [data-topic="focus"], [data-format="notification"]) { --status-ink: #fff; }
.topic-device {
  --rim: 6px;
  --corner: 40px;
  grid-area: device;
  min-width: 0;
  container-type: inline-size;
  padding: var(--rim) var(--rim) 0;
  border: 1px solid #514e54;
  border-bottom: 0;
  border-radius: var(--corner) var(--corner) 0 0;
  background: linear-gradient(110deg, #79767c, #d5d1d2 14%, #8d898e 42%, #c1bdc0 78%, #706c71);
  box-shadow: inset 0 1px 0 #f7f5f4b3, 0 8px 18px -5px #31243638;
}
.topic-screen {
  position: relative;
  isolation: isolate;
  overflow: clip;
  /* Reserve the taller notification layout. Larger text can still expand the screen. */
  min-height: max(19.5rem, 106cqw);
  padding-bottom: 16px;
  --glass-corner: calc(var(--corner) - var(--rim) - 1px);
  border-radius: var(--glass-corner) var(--glass-corner) 0 0;
  box-shadow: 0 0 0 3px #151416;
  background: #c3a9dc;
  background-size: cover;
  background-position: center;
  color: var(--status-ink);
  container-type: inline-size;
}

.topic-wallpaper { z-index: -3; }
.topic-wallpaper-fade { position: absolute; z-index: -2; inset: 0; background-position: center; background-size: cover; opacity: 0; pointer-events: none; }
.topic-preview[data-format="notification"] .topic-screen::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, #17111b99, #17111b55 44%, transparent 75%);
}

.topic-status-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: clamp(38px, 13cqw, 52px);
  padding-inline: 7.5%;
  font: 650 clamp(.75rem, 4.2cqw, .9375rem)/1 system-ui, sans-serif;
  font-variant-numeric: lining-nums;
}
.topic-status-icons { display: block; justify-self: end; width: clamp(42px, 16cqw, 57px); }
.topic-camera {
  position: relative;
  width: clamp(48px, 24cqw, 90px);
  height: clamp(15px, 6.4cqw, 24px);
  border-radius: 99px;
  background: #111013;
  box-shadow: inset 0 0 0 1px #08080a;
}
.topic-camera::after {
  content: "";
  position: absolute;
  right: 9%;
  top: 50%;
  width: 7%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translateY(-50%);
  background: radial-gradient(circle at 38% 30%, #484659, #232233 40%, #17171e 75%);
}

.topic-message {
  position: relative;
  width: 86%;
  margin: 5% auto 0;
  padding: clamp(14px, 4.4cqw, 21px);
  border-radius: 17px;
  background: #fff;
  color: #201d24;
  box-shadow: 0 3px 18px #24192f14;
}

.topic-quote { margin: 0; font: normal clamp(1.2rem, 6.4cqw, 1.7rem)/1.15 Georgia, "Times New Roman", serif; letter-spacing: -.025em; }
.topic-author { margin: 10px 0 0; color: #59545e; font: 500 .8125rem/1.35 system-ui, sans-serif; }
.topic-preview[data-format="widget"] .topic-message {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 40cqw;
}
.topic-preview[data-format="widget"] .topic-message-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4%;
}
.topic-preview[data-format="widget"] .topic-message-footer::after {
  flex: 0 0 22%;
  margin-inline: auto 4%;
  color: #6853cf;
}
.topic-preview[data-format="widget"] .topic-author { margin: 0; }

.topic-widget-label { display: block; margin-top: 5px; font: 600 .8125rem/1.4 system-ui, sans-serif; text-align: center; color: #fff; text-shadow: 0 1px 3px #201428, 0 0 5px #201428; }

.topic-clock { text-align: center; font-family: system-ui, sans-serif; }
.topic-clock > span { display: block; font-size: .9375rem; font-weight: 550; line-height: 1.35; }
.topic-clock strong { display: block; font-size: clamp(3.25rem, 20cqw, 4.75rem); line-height: 1; letter-spacing: -.045em; font-weight: 650; font-variant-numeric: lining-nums proportional-nums; }
/* Center the two dots over the height of the numerals, measured from their baseline. */
.topic-time-separator {
  position: relative;
  display: inline-block;
  vertical-align: .01em;
  overflow: hidden;
  width: max(1.5px, .118em);
  height: .72em;
  height: 1cap;
  margin-inline: .04em;
  text-indent: 1em;
  font-style: normal;
  letter-spacing: normal;
}
.topic-time-separator::before, .topic-time-separator::after {
  content: "";
  position: absolute;
  left: 0;
  top: 25%;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
}
.topic-time-separator::after { top: 75%; }
@media (forced-colors: active) {
  .topic-time-separator { forced-color-adjust: none; color: CanvasText; }
  .topic-card[aria-pressed="true"] .topic-cover { outline-color: Highlight; }
}
.topic-preview[data-format="notification"] .topic-status-bar > span:first-child { visibility: hidden; }
.topic-preview[data-format="notification"] .topic-message {
  width: 89%;
  margin-top: 8%;
  border: 1px solid #ffffff96;
  border-radius: 17px;
  background: #f9f6fcf5;
  padding: clamp(14px, 3.8cqw, 18px);
}

.topic-sender { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; font: 600 .9375rem/1.25 system-ui, sans-serif; }
.topic-sender img { border-radius: 7px; }
.topic-sender small { margin-left: auto; color: #5b5562; font-size: .8125rem; font-weight: 400; }
.topic-preview[data-format="notification"] .topic-quote { font: 500 clamp(1rem, 4.4cqw, 1.1875rem)/1.35 system-ui, sans-serif; letter-spacing: -.018em; }
.topic-preview[data-format="notification"] .topic-author { margin-top: 5px; }

.topic-preview-footer { grid-area: caption; flex-direction: column; align-items: start; justify-content: space-between; gap: 16px; padding-block: 4px clamp(16px, 1.9vw, 28px); }
.topic-preview-title { display: grid; gap: 9px; }
.topic-preview-title span { color: var(--topic-ink); font-size: .875rem; font-weight: 750; line-height: 1.3; }
.topic-preview-title strong { color: #29212c; font: normal clamp(1.75rem, 2.7vw, 2.6rem)/1.04 Georgia, "Times New Roman", serif; letter-spacing: -.045em; text-wrap: balance; }
.topic-formats {
  position: relative;
  isolation: isolate;
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  max-width: 100%;
  padding: 3px;
  border: 1px solid #29212c1c;
  border-radius: 30px;
  background: #fffc;
}
.topic-formats::before {
  position: absolute;
  z-index: -1;
  inset: 3px auto 3px 3px;
  width: calc(50% - 3px);
  border-radius: inherit;
  background: var(--topic-ink);
  content: "";
}
.topic-preview[data-format="notification"] .topic-formats::before { transform: translateX(100%); }
.topic-formats button { min-height: 44px; padding-inline: 9px; border: 0; border-radius: 30px; background: transparent; color: #473f4a; font-size: .8125rem; font-weight: 700; cursor: pointer; }
.topic-formats button[aria-pressed="true"] { color: #fff; }
.topic-formats button:hover:not([aria-pressed="true"]) { color: var(--topic-ink); }

.topic-announcement { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; }

@container preview-slot (max-width: 31rem) {
  .topic-preview { grid-template: "caption" auto "device" auto / minmax(0, 1fr); gap: 12px; padding: 14px 16px 0; }
  .topic-preview-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 0; }
  .topic-preview-title { gap: 3px; align-content: center; }
  .topic-preview-title strong { font-size: 1.375rem; }
  .topic-device { width: min(88%, 18.5rem); justify-self: center; }
}
@container preview-slot (min-width: 21.5rem) and (max-width: 26.5rem) {
  .topic-preview-title { min-height: 4.25rem; }
}
@container preview-slot (width < 21.5rem) {
  .topic-preview-footer { grid-template-columns: minmax(0, 1fr); }
  .topic-preview-title { gap: 2px; }
}
@media screen and (prefers-reduced-motion: no-preference) {
  .topic-hero[data-ready] .topic-card { animation: topic-arrive .42s cubic-bezier(.2,.7,.25,1) backwards; animation-delay: var(--arrival, 0s); }
  .topic-card:nth-child(2) { --arrival: .035s; }
  .topic-card:nth-child(3) { --arrival: .07s; }
  .topic-card:nth-child(4) { --arrival: .105s; }
  .topic-card:nth-child(5) { --arrival: .14s; }
  .topic-card:nth-child(6) { --arrival: .175s; }

  .topic-hero[data-ready] :is(.topic-gallery-head > *, .topic-pitch > *, .topic-preview-slot) {
    animation: hero-arrive .48s cubic-bezier(.2,.7,.25,1) var(--arrival, 0s) backwards;
  }
  .topic-pitch h1 { --arrival: .105s; }
  .topic-pitch .hero-lead { --arrival: .14s; }
  .topic-gallery-head .topic-navigation,
  .topic-pitch .store-actions, .topic-download-note { --arrival: .175s; }
  .topic-preview-slot { --arrival: .24s; }

  .topic-preview { transition: background-color .28s ease-out, border-color .28s ease-out; }
  .topic-formats::before { transition: transform .25s cubic-bezier(.25,.78,.26,1), background-color .2s ease-out; }
  @keyframes topic-arrive { from { opacity: .8; transform: translateY(7px); } to { opacity: 1; transform: none; } }
  @keyframes hero-arrive {
    from { opacity: .8; transform: translateX(clamp(-14px, -1vw, -6px)); }
    to { opacity: 1; transform: none; }
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .topic-cover, .topic-cover > img { transition: transform .22s ease-out, box-shadow .22s ease-out; }
  .topic-card:enabled:hover .topic-cover { transform: translateY(-2px); box-shadow: 0 5px 10px -5px #2417284d; }
  .topic-card:enabled:hover .topic-cover > img { transform: scale(1.035); }
}

/* Leave the gallery, preview controls and store badges reachable on a first visit. */
@media (min-width: 801px) {
  #analytics-consent:has(.consent-close[hidden]):not([hidden]) {
    inset: auto max(20px, (100% - var(--section-width)) / 2) 12px;
    width: auto;
    display: grid;
    grid-template: "title privacy choices" auto "description privacy choices" auto "hint privacy choices" auto / minmax(0, 1fr) auto minmax(230px, .34fr);
    column-gap: 22px;
    padding: 14px 20px;
    align-items: center;
  }
  #analytics-consent:has(.consent-close[hidden]) h2 { grid-area: title; margin: 0 0 2px; font-size: 1rem; }
  #analytics-consent:has(.consent-close[hidden]) #consent-description { grid-area: description; }
  #analytics-consent:has(.consent-close[hidden]) .consent-hint { grid-area: hint; margin-top: 2px; }
  #analytics-consent:has(.consent-close[hidden]) .consent-privacy { grid-area: privacy; }
  #analytics-consent:has(.consent-close[hidden]) .consent-actions { grid-area: choices; margin: 0; }
}

@media (min-width: 801px) and (max-height: 800px) {
  .hero.topic-hero { padding-block-start: 10px; }
  .topic-story { align-items: start; margin-top: 21px; }
  .topic-preview-slot .topic-preview-footer { max-height: 16.25rem; }
  .topic-cover { height: clamp(110px, 8.6vw, 143px); }
  .topic-excerpt { font-size: 1.375rem; }
  .topic-pitch h1 { font-size: clamp(2.6rem, 4.7vw, 4.125rem); }
  .topic-pitch .hero-lead { margin-top: 12px; }
  .topic-pitch .store-actions { margin-top: 16px; }
}

@media (max-width: 800px) {
  .hero.topic-hero { --rail-edge: 20px; display: flex; flex-direction: column; gap: 24px; padding-block: 28px; }
  .topic-gallery-head { gap: 12px; margin-bottom: 2px; }
  .topic-rail { grid-auto-columns: clamp(8.875rem, 42%, 11.875rem); gap: 10px; }
  .topic-cover { height: auto; aspect-ratio: 1.21; }
  .topic-excerpt { inset: auto 11px 12px; font-size: 1.3125rem; max-width: 10ch; }
  .topic-story { display: contents; }
  .topic-pitch, .topic-preview-slot { width: min(100% - 40px, 620px); margin-inline: auto; }
  .topic-pitch { order: -1; }
  .topic-preview-slot { order: 1; }
  .topic-pitch h1 { font-size: clamp(2.7rem, 10.35vw, 4rem); }
  .topic-pitch .hero-lead { margin-top: 13px; line-height: 1.48; }
  .topic-pitch .store-actions { margin-top: 19px; }
  .topic-pitch .store-link, .topic-pitch .store-link img { height: 44px; min-height: 44px; }
}

@media (max-width: 380px) {
  .topic-download-note { margin-top: 12px; }
  .topic-formats button { padding-inline: 7px; }
}
