/*
 * Uplift group C (docs/design/uplift-c.md): contact, booking, capture,
 * thank-you pages, guides, the white paper page, blog and blog posts.
 * Linked once per page by those templates and snippets (peanut_c_css(),
 * site/snippets/uplift/c/helpers.php), right before the first section that
 * needs it. Looks in the templates layer, movement in the motion layer.
 * Tokens only; no !important.
 */

@layer templates {
  /* ---------- First screens on the brand wash (booking, contact, capture, guide, thank you) ---------- */

  :is(.c-book, .c-contact, .c-capture, .c-guide-hero, .c-thanks) {
    position: relative;
    overflow: hidden;
  }

  :is(.c-book, .c-contact, .c-capture, .c-guide-hero, .c-thanks) > .container {
    position: relative;
    z-index: 1;
  }

  :is(.c-book__intro, .c-contact__intro, .c-capture__intro, .c-guide-hero__body) > * {
    margin: 0;
  }

  :is(.c-book__intro, .c-contact__intro, .c-capture__intro, .c-guide-hero__body) > * + * {
    margin-top: var(--space-3);
  }

  :is(.c-book__title, .c-contact__title, .c-capture__title, .c-thanks__title) {
    font-size: var(--step-6);
    font-weight: var(--weight-display);
    line-height: var(--leading-tight);
  }

  /* White card with the hard shadow: the thing to act on (form, calendar) */
  :is(.c-contact__card, .c-capture__card) {
    padding: var(--space-4) var(--space-3);
    border: var(--border);
    border-radius: var(--radius-lg);
    background: var(--color-white);
    box-shadow: var(--shadow-hard);
  }

  @media (min-width: 48rem) {
    :is(.c-contact__card, .c-capture__card) {
      padding: var(--space-5);
    }
  }

  /* Two half-width fields with a hint under one: keep both inputs on one line */
  :is(.c-contact, .c-capture, .c-guide-form) .field {
    align-content: start;
  }

  /* ---------- Booking pages ---------- */

  .c-book__grid {
    display: grid;
    grid-template-areas: "intro" "frame" "host";
    gap: var(--space-5);
  }

  .c-book__intro {
    grid-area: intro;
  }

  .c-book__frame {
    grid-area: frame;
    min-width: 0;
  }

  .c-book__host {
    grid-area: host;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: var(--border);
  }

  .c-book__avatar {
    flex: none;
    width: 5.5rem;
    height: 5.5rem;
    border: var(--border);
    border-radius: 50%;
    background: var(--color-brand);
    object-fit: cover;
  }

  .c-book__text {
    margin: 0;
  }

  .c-book .embed {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hard);
  }

  @media (min-width: 60rem) {
    .c-book__grid {
      grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
      grid-template-rows: auto 1fr;
      grid-template-areas: "intro frame" "host frame";
      align-items: start;
      gap: var(--space-5) var(--space-6);
    }

    .c-book__title {
      font-size: var(--step-5);
    }
  }

  /* ---------- Contact ---------- */

  .c-contact__grid {
    display: grid;
    grid-template-areas: "intro" "card" "aside";
    gap: var(--space-5);
  }

  .c-contact__intro {
    grid-area: intro;
  }

  .c-contact__aside {
    grid-area: aside;
  }

  .c-contact__card {
    grid-area: card;
    position: relative;
    min-width: 0;
  }

  .c-contact__card--portrait {
    margin-top: 3.75rem;
  }

  .c-contact__label {
    margin: 0 0 var(--space-3);
    font-family: var(--font-body);
    font-size: var(--step--1);
  }

  .c-contact__more {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: var(--border);
  }

  .c-contact__portrait {
    position: absolute;
    top: -3.75rem;
    right: var(--space-4);
    width: 7.5rem;
    height: 7.5rem;
  }

  .c-contact__photo {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    border: var(--border);
    border-radius: 50%;
    background: var(--color-brand);
    object-fit: cover;
  }

  .c-contact__rings {
    position: absolute;
    inset: -1.25rem;
    width: calc(100% + 2.5rem);
    height: auto;
    fill: none;
    stroke-width: 5;
  }

  .c-contact__rings circle:nth-child(1) {
    stroke: var(--color-brand);
  }

  .c-contact__rings circle:nth-child(2) {
    stroke: var(--color-accent-2);
  }

  .c-contact__rings circle:nth-child(3) {
    stroke: var(--color-gold-soft);
  }

  .c-contact__form {
    max-width: none;
  }

  /* The client portal's message form (its starting height is inline; the portal's embed.js sets the real one) */
  .c-contact__frame {
    display: block;
    width: 100%;
    border: 0;
  }

  /* Phones: the portal's message form runs to the card's edges (about 348 px at 390,
     like the call page's frame), so it never scrolls sideways inside its frame */
  @media (max-width: 47.99rem) {
    .c-contact__frame {
      width: calc(100% + 2 * var(--space-3));
      margin-inline: calc(-1 * var(--space-3));
    }
  }

  .c-contact__card--portrait .form-section__title {
    padding-right: 7.5rem;
  }

  @media (min-width: 60rem) {
    .c-contact__grid {
      grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
      grid-template-rows: auto 1fr;
      grid-template-areas: "intro card" "aside card";
      align-items: start;
      gap: var(--space-5) var(--space-7);
    }

    .c-contact__card--portrait {
      margin-top: 0;
    }
  }

  /* Numbered steps on a line (contact, "What happens next") */
  .c-steps {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: c-step;
  }

  .c-steps li {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding-left: 4rem;
    counter-increment: c-step;
  }

  .c-steps li::before {
    content: counter(c-step);
    position: absolute;
    top: 0;
    left: 0;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: var(--border);
    border-radius: 50%;
    background: var(--color-white);
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading-sm);
  }

  .c-steps li + li::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 1.375rem;
    height: var(--space-3);
    border-left: var(--border);
  }

  /* ---------- Capture (templates are moving) ---------- */

  .c-capture__grid {
    display: grid;
    gap: var(--space-5);
  }

  @media (min-width: 60rem) {
    .c-capture__grid {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      align-items: center;
      gap: var(--space-7);
    }
  }

  /* ---------- Thank-you pages ---------- */

  .c-thanks {
    padding-block: var(--space-7);
  }

  .c-thanks__mark {
    display: inline-grid;
    place-items: center;
    width: 4.5rem;
    height: 4.5rem;
    border: var(--border);
    border-radius: 50%;
    background: var(--color-white);
    box-shadow: var(--shadow-hard);
  }

  .c-thanks__mark svg {
    width: 2.5rem;
    height: 2.5rem;
  }

  .c-thanks__text {
    font-family: var(--font-heading);
    font-size: var(--step-1);
    font-weight: var(--weight-heading-sm);
    line-height: 1.4;
  }

  /* One quiet line after a booking with an offer (offer=site-insight) */
  .c-thanks__offer {
    margin: var(--space-4) 0 0;
    font-size: var(--text-body);
  }

  .c-thanks__links .pt-links__cards {
    max-width: 52rem;
    margin-inline: auto;
  }

  /* ---------- The white paper cover (site/snippets/uplift/c/cover.php) ---------- */

  .c-cover {
    --c-cover-w: 18rem;
    position: relative;
    /* the fanned pages reach about 30% of the width past each side */
    width: min(62%, var(--c-cover-w));
    margin-inline: auto;
    aspect-ratio: 8.5 / 11;
    container-type: inline-size;
  }

  @media (min-width: 48rem) {
    .c-cover {
      width: min(100% - 6rem, var(--c-cover-w));
    }
  }

  .c-cover--lg {
    --c-cover-w: 22rem;
  }

  .c-cover--sm {
    --c-cover-w: 12rem;
  }

  .c-cover__sheet,
  .c-cover__page {
    position: absolute;
    inset: 0;
    border: var(--border);
    border-radius: 4px;
  }

  .c-cover__sheet {
    z-index: 2;
    display: flex;
    flex-direction: column;
    padding: 12cqi 10cqi 9cqi;
    background: var(--color-brand);
    box-shadow: var(--shadow-hard);
    color: var(--color-ink);
  }

  .c-cover__eyebrow {
    font-size: 3.4cqi;
    font-weight: var(--weight-strong);
    letter-spacing: var(--tracking-caps);
    line-height: 1.3;
    text-transform: uppercase;
  }

  .c-cover__title {
    margin-top: 6cqi;
    font-family: var(--font-heading);
    font-size: 9.6cqi;
    font-weight: var(--weight-display);
    line-height: 1.1;
    text-wrap: balance;
  }

  .c-cover__foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 3cqi;
    border-top: var(--border);
    font-size: 3.6cqi;
    font-weight: 500;
  }

  .c-cover__brand {
    font-family: var(--font-heading);
    font-size: 6.4cqi;
    font-weight: var(--weight-heading-sm);
    line-height: 1;
  }

  /* Two printed pages behind the cover, fanned out (the motion layer starts them stacked) */
  .c-cover__page {
    display: flex;
    flex-direction: column;
    gap: 4.5cqi;
    padding: 14cqi 10cqi;
    background: var(--color-white);
    transform-origin: 50% 100%;
  }

  .c-cover__page i {
    display: block;
    width: 92%;
    height: 2.4cqi;
    border-radius: var(--radius-pill);
    background: var(--color-muted);
    opacity: 0.35;
  }

  .c-cover__page i:first-child {
    width: 62%;
    height: 4.4cqi;
    margin-bottom: 3cqi;
    background: var(--color-ink);
    opacity: 0.75;
  }

  .c-cover__page i:nth-child(3n) {
    width: 74%;
  }

  .c-cover__page--1 {
    z-index: 1;
    transform: translate(-9%, -2%) rotate(-7deg);
  }

  .c-cover__page--2 {
    transform: translate(11%, -4%) rotate(8deg);
  }

  .c-cover__page--2 i {
    background: var(--color-accent-2);
  }

  /* ---------- Guide page ---------- */

  .c-guide-hero__grid {
    display: grid;
    gap: var(--space-6);
  }

  .c-guide-hero__title {
    max-width: 18ch;
    font-size: var(--step-5);
    font-weight: var(--weight-display);
    line-height: var(--leading-tight);
  }

  .c-guide-hero__lead {
    max-width: var(--measure);
  }

  .c-guide-hero__actions {
    padding-top: var(--space-2);
  }

  .c-guide-hero__media {
    padding-block: var(--space-3);
  }

  @media (min-width: 60rem) {
    .c-guide-hero__grid {
      grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
      align-items: center;
    }
  }

  .c-guide-summary {
    padding-top: 0;
  }

  .c-guide-summary__grid {
    display: grid;
    gap: var(--space-6);
  }

  .c-guide-summary__body {
    max-width: var(--measure);
  }

  .c-guide-summary__study {
    margin-top: var(--space-5);
  }

  .c-guide-inside {
    align-self: start;
    padding: var(--space-4);
    border: var(--border);
    border-radius: var(--radius-lg);
    background: var(--color-white);
  }

  .c-guide-inside__title {
    margin: 0 0 var(--space-3);
    font-size: var(--step-3);
    font-weight: var(--weight-heading);
  }

  .c-guide-inside__list {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: c-inside;
  }

  .c-guide-inside__list li {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr);
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: var(--border);
    counter-increment: c-inside;
  }

  .c-guide-inside__list li::before {
    content: counter(c-inside, decimal-leading-zero);
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: 1;
  }

  @media (min-width: 60rem) {
    .c-guide-summary__grid {
      grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
      gap: var(--space-7);
    }

    .c-guide-inside {
      position: sticky;
      top: calc(var(--header-height) + var(--space-4));
      padding: var(--space-5);
    }
  }

  .c-guide-form__card {
    display: grid;
    gap: var(--space-4);
    max-width: 64rem;
    margin-inline: auto;
    padding: var(--space-4) var(--space-3);
    border: var(--border);
    border-radius: var(--radius-lg);
    background: var(--color-mint-pale);
  }

  .c-guide-form__intro > * {
    margin: 0;
  }

  .c-guide-form__intro > * + * {
    margin-top: var(--space-2);
  }

  .c-guide-form__title {
    font-size: var(--step-4);
    font-weight: var(--weight-display);
  }

  .c-guide-form__form {
    max-width: none;
  }

  @media (min-width: 48rem) {
    .c-guide-form__card {
      padding: var(--space-6);
    }
  }

  @media (min-width: 60rem) {
    .c-guide-form__card {
      grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
      gap: var(--space-6);
    }
  }

  /* ---------- Guides index: the guide as one feature ---------- */

  :is(.c-guides-head, .c-blog-head) {
    background: var(--gradient-wash);
  }

  .c-feature__card {
    display: grid;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-3);
    border: var(--border);
    border-radius: var(--radius-lg);
    background: var(--color-paper);
  }

  .c-feature__body > * {
    margin: 0;
  }

  .c-feature__body > * + * {
    margin-top: var(--space-3);
  }

  .c-feature__title {
    font-size: var(--step-4);
    font-weight: var(--weight-display);
    line-height: var(--leading-heading);
  }

  .c-feature__title a {
    text-decoration: none;
  }

  .c-feature__title a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
  }

  .c-feature__actions {
    padding-top: var(--space-2);
  }

  @media (min-width: 60rem) {
    .c-feature__card {
      grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
      align-items: center;
      gap: var(--space-6);
      padding: var(--space-6);
    }
  }

  /* ---------- Blog: post cards (site/snippets/cards/article.php) ---------- */

  .card--article {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-sm);
  }

  .card--article .card__body {
    gap: var(--space-2);
    padding: var(--space-4) var(--space-3);
  }

  .card--article .card__meta {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .card--article .card__title {
    margin: 0;
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: var(--leading-heading);
  }

  .card--article .card__link::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  .card--article .card__text {
    margin: 0;
  }

  .card--article .card__topics {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .card--article .card__topics li {
    padding: 0.25em 0.8em;
    border: var(--border);
    border-radius: 1em;
    background: var(--color-paper);
    font-size: 0.75rem;
    font-weight: var(--weight-strong);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .card--article .card__more {
    margin: auto 0 0;
    padding-top: var(--space-2);
  }

  .card--article:has(.card__link:focus-visible) {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
  }

  .card--article .card__link:focus-visible {
    outline: 0;
  }

  @media (min-width: 48rem) {
    .card--article-wide {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .card--article-wide .card__media {
      border-right: var(--border);
      border-bottom: 0;
    }

    .card--article-wide .card__media img {
      height: 100%;
      object-fit: cover;
    }

    .card--article-wide .card__body {
      justify-content: center;
      padding: var(--space-5);
    }

    .card--article-wide .card__title {
      font-size: var(--step-3);
    }
  }

  /* ---------- Blog post ---------- */

  .c-article__header {
    padding-block: var(--space-6);
    background: var(--gradient-wash);
  }

  .c-article--cover .c-article__header {
    padding-bottom: calc(var(--space-6) + var(--space-7));
  }

  .c-article--cover .article__cover {
    position: relative;
    margin-top: calc(-1 * var(--space-7));
  }

  .c-article .article__cover img {
    border: var(--border);
    border-radius: var(--radius-sm);
  }

  .c-article .article__title {
    font-size: var(--step-5);
    font-weight: var(--weight-display);
    line-height: var(--leading-tight);
  }

  .c-article__more-title {
    font-size: var(--step-4);
    font-weight: var(--weight-display);
  }
}

@layer motion {
  /* Interface feedback: post cards lift with the hard shadow on hover (fine pointers) */
  @media (hover: hover) {
    .card--article {
      transition: translate var(--motion-fast, 180ms) var(--ease-out, ease-out);
    }

    .card--article:hover {
      translate: 0 -4px;
      box-shadow: var(--shadow-hard);
    }
  }

  @media screen and (prefers-reduced-motion: no-preference) {
    /* fx:enter ---- The H1 of these first screens only lifts (never fades: LCP); the card
       or calendar beside it lifts with it. */
    html[data-fx~="enter"] .hero-enter > :is(.c-book__title, .c-contact__title, .c-capture__title, .c-guide-hero__title, .c-thanks__title, .article__title) {
      animation-name: motion-lift;
    }

    html[data-fx~="enter"] :is(.c-book__frame, .c-contact__card, .c-capture__card, .c-guide-hero__media) {
      animation: motion-lift 800ms var(--ease-out) both;
    }

    /* fx:enter (signature, guide page) ---- The cover's two pages fan out from behind it
       after the hero has risen. Without the key they sit fanned. */
    html[data-fx~="enter"] .c-cover--enter .c-cover__page {
      animation: c-fan 900ms var(--ease-pop) 420ms both;
    }

    html[data-fx~="enter"] .c-cover--enter .c-cover__page--2 {
      animation-delay: 560ms;
    }

    /* fx:reveal ---- On the guides index, the blog and posts the pages fan out when
       their section reveals (the shared observer's is-in). A section in view at load
       is never tagged, so its cover stays fanned. */
    html[data-fx~="reveal"] .c-cover--reveal .c-cover__page {
      transition: transform 900ms var(--ease-pop) 320ms;
    }

    html[data-fx~="reveal"] .c-cover--reveal .c-cover__page--2 {
      transition-delay: 460ms;
    }

    html.js-motion[data-fx~="reveal"] [data-reveal]:not(.is-in) .c-cover--reveal .c-cover__page {
      transform: none;
    }

    /* fx:layers ---- The rings around Christina's portrait on the contact card turn slowly */
    html[data-fx~="layers"] .c-contact__rings {
      animation: c-turn 40s linear infinite;
    }
  }

  @keyframes c-fan {
    from {
      transform: none;
    }
  }

  @keyframes c-turn {
    to {
      transform: rotate(360deg);
    }
  }
}
