/* ============================================================================
   YEMMA — THE SAMPLE CREDIT, HELD
   The card a customer reads their credit on: under the thank-you hero, and at
   the top of the account's orders. Drawn by `templates/swatches/credit/card.php`
   through `Swatches\CreditSurfaces`, and every word on it is `CreditState`'s.

   Loaded on those two contexts only — `is_account_page()` and
   `is_order_received_page()` — at priority 20, after `yemma-style`, so it lands
   after account.css and thankyou.css and wins its ties with them.

   The badge is the account's own `.ostat`, which account.css draws on both of
   those contexts; this sheet adds only the clay tone the account never needed.
   The big figure copies the swatches page's `.swoffer__n` rather than depending
   on a sheet that is not loaded here.

   Every colour is a theme token. One is mixed rather than used neat, and the
   reason is contrast: --muted on --bone is 3.8:1, short of what a 9.5px label
   needs. Mixed a fifth of the way toward --ink it keeps the hue and reaches 5:1.
   A browser without color-mix() keeps the neat token, the theme's own choice —
   which is why the mix is set inside @supports: a custom property accepts any
   value at all, so two declarations of it in a row are not a fallback, and the
   second one would have reached that browser as an invalid colour.

   HANDLE: yemma-credit-page — the `-page` suffix keeps it clear of any name the
   theme might register for a sheet of its own.
   ========================================================================== */

/* ================================================================= CARD === */
.credcard {
  --cc-label: var(--muted);

  position: relative;
  background: var(--bone);
  border: 1px solid var(--line);
  padding: clamp(1.25rem, 2.6vw, 2rem) clamp(1.15rem, 2.8vw, 2.2rem) clamp(1.1rem, 2.2vw, 1.6rem);
  color: var(--ink);
  animation: credcardIn 280ms var(--ease-out) both;
}

/* The brass rule along the top, laid over the border rather than beside it so
   it runs to both corners. Brass is the colour this shop gives to what is
   promised; the card is one. */
.credcard::before {
  content: "";
  position: absolute; top: -1px; left: -1px; right: -1px;
  height: 2px;
  background: var(--brass);
}

@supports (color: color-mix(in srgb, red, blue)) {
  .credcard { --cc-label: color-mix(in srgb, var(--muted) 82%, var(--ink)); }
}

@keyframes credcardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ HEAD -- */
.credcard__head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .7rem 1rem;
}

/* A real heading dressed as an overline: h2 on the thank-you page, h3 inside
   the account's section. Every heading rule the theme sets is undone by name —
   and at two classes, because woo-account.css dresses `.acct__main h3` in serif
   at 1.1rem and one class alone loses to that. */
.credcard .credcard__over {
  margin: 0;
  font-family: var(--sans); font-size: 10px; font-weight: 500;
  line-height: 1.4; letter-spacing: .2em; text-transform: uppercase;
  color: var(--cc-label);
}

.credcard__badge { background: transparent; }
.credcard .ostat--mute { color: var(--cc-label); }

/* The tone `CreditState::badge()` gives an end that is close. Clay rather than
   the account's pulsing `live`: nothing is wrong, and nothing should throb. */
.ostat--clay { border-color: rgba(169, 82, 47, .42); color: var(--clay); }
.ostat--clay i { background: var(--clay); }

/* ------------------------------------------------------------------ BODY -- */
.credcard__body {
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  align-items: center; gap: clamp(1.2rem, 3vw, 2.4rem);
  margin-top: clamp(1rem, 2.2vw, 1.4rem);
}

.credcard__fig { margin: 0; max-width: none; }

/* The figure. `.swoffer__n`'s grammar at its largest: serif at 300, the symbol
   small and raised in clay, the number bare. */
.credcard__n {
  display: block;
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(2.9rem, 5.4vw, 3.4rem); line-height: .95;
  letter-spacing: -.01em;
  font-variant-numeric: lining-nums;
  color: var(--ink); white-space: nowrap;
}
.credcard__n sup {
  font-size: .42em; vertical-align: 1.1em; line-height: 0;
  margin: 0 .06em; color: var(--clay);
}

/* What it was before a refund lowered it — said, not hidden. */
.credcard__was {
  display: block; margin-top: .5rem;
  font-size: 11px; line-height: 1.4; letter-spacing: .04em;
  color: var(--cc-label);
}
.credcard__was s { text-decoration-thickness: 1px; }

/* The headline, beside the figure across a hairline. */
.credcard__say {
  margin: 0; max-width: 36ch;
  padding-left: clamp(1.2rem, 3vw, 2.4rem);
  border-left: 1px solid var(--line);
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(1.2rem, 1.9vw, 1.5rem); line-height: 1.3;
  color: var(--ink-2);
  text-wrap: balance;
}

/* ----------------------------------------------------------------- FACTS -- */
/* The account's promise row (`.wait__promise`) — an ink rule over uppercase
   labels and serif figures — laid out as up to three equal cells divided by
   hairlines. They stack into its own label-left, figure-right rows on a phone. */
.credcard__facts {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  margin: clamp(1.2rem, 2.4vw, 1.6rem) 0 0;
  border-top: 1px solid var(--ink);
}
.credcard__facts > div { min-width: 0; padding: .95rem 1rem .95rem 0; }
.credcard__facts > div + div { padding-left: 1rem; border-left: 1px solid var(--line); }
.credcard__facts dt {
  font-size: 9.5px; line-height: 1.4; letter-spacing: .2em; text-transform: uppercase;
  color: var(--cc-label);
}
/* Lining figures, as on the big number: Cormorant's default old-style digits
   sit at x-height, and "$200" beside "October 5, 2027" read as the smaller of
   the two facts when it is the one that decides whether the credit applies. */
.credcard__facts dd {
  margin: .35rem 0 0;
  font-family: var(--serif); font-size: 1.28rem; line-height: 1.2;
  font-variant-numeric: lining-nums;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.credcard__facts .is-soon dt,
.credcard__facts .is-soon dd { color: var(--clay); }

/* ------------------------------------------------------------------ FOOT -- */
.credcard__foot {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: .8rem 1.6rem;
  margin-top: 1rem; padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.credcard__facts + .credcard__foot { margin-top: 0; }

.credcard__line {
  flex: 1 1 22rem; margin: 0; max-width: 60ch;
  font-size: .9rem; line-height: 1.7; color: var(--ink-3);
}

.credcard__go { flex: none; color: var(--ink); transition: color .35s var(--ease); }
.credcard__go:hover,
.credcard__go:focus-visible { color: var(--clay); }
.credcard__go svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ---------------------------------------------------------------- STATES -- */
/* Over: spent, ran out, cancelled. The card stays legible — it is a record —
   but it stops asking for attention: a quiet rule, a muted figure. The figure
   is large type, where --muted clears the 3:1 that size needs. */
.credcard.is-past::before { background: var(--line-2); }
.credcard.is-past .credcard__n,
.credcard.is-past .credcard__n sup { color: var(--muted); }
.credcard.is-past .credcard__say { color: var(--ink-3); }

/* Not paid for yet: the figure is a promise rather than a balance. */
.credcard--pending .credcard__n { color: var(--ink-3); }

/* =========================================================== PLACEMENTS === */
/* The page after paying: the order card's own column, so the two line up. */
.credwrap--one {
  max-width: 920px;
  margin: 0 auto clamp(1.4rem, 3.4vw, 2.2rem);
}

/* The account: above the order filters. No scroll-margin for the rail's
   "#credit" link — base.css already gives `html` a scroll-padding the height of
   the sticky header, and the two add up: with both, the heading landed some
   two hundred pixels down the screen rather than just under the header. */
.credits {
  margin-bottom: clamp(1.8rem, 3.6vw, 2.6rem);
}
/* Two classes for the reason the card's overline has two: `.acct__main h2`. */
.credits .credits__h {
  margin: 0 0 1rem;
  font-family: var(--sans); font-size: 10px; font-weight: 500;
  line-height: 1.4; letter-spacing: .2em; text-transform: uppercase;
  color: var(--muted);
  color: color-mix(in srgb, var(--muted) 82%, var(--ink));
}
.credits .credcard + .credcard { margin-top: 1rem; }

/* Two or more cards stacked: the figure's column gets a floor, so "$20" and
   "$12.50" do not push their headlines and hairlines to two different places
   down the same column. One card alone keeps its figure tight against the rule;
   a browser without :has() simply keeps that for every card. Above the phone
   breakpoint only: this selector outweighs the one-column rule down there. */
@media (min-width: 561px) {
  .credits:has(.credcard + .credcard) .credcard__body {
    grid-template-columns: minmax(8rem, auto) minmax(0, 1fr);
  }
}

/* The one line about credits that are over. When it is all there is, it sits in
   a `.credits--quiet` box of its own rather than as a bare paragraph, which
   woo-account.css would take for the endpoint's opening sentence. */
.credits__past {
  margin: .9rem 0 0;
  font-size: .84rem; line-height: 1.6; color: var(--ink-3);
}
.credits--quiet { margin-bottom: 1.4rem; }
.credits--quiet .credits__past { margin: 0; }

/* =========================================================== RESPONSIVE === */
@media (max-width: 560px) {
  /* The figure leads, on a line of its own; the headline follows under it. */
  .credcard__body { grid-template-columns: minmax(0, 1fr); gap: .8rem; }
  .credcard__say { max-width: none; padding-left: 0; border-left: 0; }

  .credcard__facts { grid-auto-flow: row; grid-auto-columns: auto; }
  .credcard__facts > div,
  .credcard__facts > div + div {
    display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
    padding: .75rem 0; border-left: 0;
  }
  .credcard__facts > div + div { border-top: 1px solid var(--line); }
  .credcard__facts dt { flex: none; }
  .credcard__facts dd { margin: 0; text-align: right; font-size: 1.12rem; }

  .credcard__foot { flex-direction: column; align-items: flex-start; }
  .credcard__line { flex-basis: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .credcard { animation: none; }
  .credcard__go { transition: none; }
}
