/* =========================================================
   PEPPYS — CHECKOUT TERMS
   ---------------------------------------------------------
   Loaded ONLY on the checkout and on the Terms of Service page. Every selector
   is scoped under body.peppys-terms-checkout or body.peppys-terms-page, so
   nothing here can reach the shop, a product, the cart or My Account.

   Self-contained tokens: this runs alongside Divi, which does not define the
   PEPPYS theme's CSS variables. Values match peppys-account and
   peppys-cart-style so the pages read as one system.
   ========================================================= */

body.peppys-terms-checkout,
body.peppys-terms-page {
  --pt-bg: #070D24;
  --pt-card: #101A3A;
  --pt-card-hi: #14204a;
  --pt-sunk: rgba(6, 11, 31, .55);
  --pt-line: rgba(255, 255, 255, .10);
  --pt-line-soft: rgba(255, 255, 255, .06);

  --pt-text: #F4F7FF;
  --pt-dim: #AEB8D6;
  --pt-mut: #7C88AC;          /* 4.5:1+ on --pt-card */

  --pt-gold: #F6C915;
  --pt-gold-600: #E0B200;
  --pt-ink: #0A0F22;

  --pt-radius: 16px;
  --pt-radius-sm: 11px;
  --pt-ease: cubic-bezier(.16, 1, .3, 1);
}

/* =========================================================
   THE AGREEMENT ROW AT CHECKOUT
   ---------------------------------------------------------
   Restrained on purpose. This is the last thing between the customer and the
   Place Order button; it needs to be impossible to miss but must not look like
   an error state, or it reads as "something went wrong" rather than
   "one thing to confirm".
   ========================================================= */

body.peppys-terms-checkout .peppys-terms-row {
  margin-block: 4px 0;
  padding: 14px 16px;
  border: 1px solid var(--pt-line);
  border-left: 3px solid var(--pt-gold);
  border-radius: var(--pt-radius-sm);
  background: var(--pt-sunk);
}

body.peppys-terms-checkout .peppys-terms-label {
  line-height: 1.55;
}

/* The link itself. Underlined rather than colour-only, so it still reads as a
   link to anyone who cannot pick the gold out of the surrounding text. */
body.peppys-terms-checkout a.peppys-terms-open,
body.peppys-terms-page a.peppys-terms-open {
  color: var(--pt-gold);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

body.peppys-terms-checkout a.peppys-terms-open:hover,
body.peppys-terms-checkout a.peppys-terms-open:focus-visible {
  color: var(--pt-gold-600);
}

/* =========================================================
   THE READER
   ========================================================= */

/* Scroll lock while the dialog is open. Set on <html> rather than <body>
   because Divi already manages overflow on body in a few of its own modes. */
html.peppys-terms-open-lock {
  overflow: hidden;
}

.peppys-terms-modal[hidden] {
  display: none;
}

.peppys-terms-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;          /* above Divi's fixed header and its mobile menu */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 4vw, 48px);
}

.peppys-terms-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 18, .78);
  backdrop-filter: blur(3px);
}

.peppys-terms-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: min(84vh, 900px);
  overflow: hidden;
  border: 1px solid var(--pt-line);
  border-radius: var(--pt-radius);
  background: var(--pt-card);
  color: var(--pt-text);
  box-shadow: 0 32px 80px rgba(0, 0, 0, .55);
  animation: peppys-terms-in .28s var(--pt-ease) both;
}

@keyframes peppys-terms-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .peppys-terms-modal__panel { animation: none; }
}

/* ---------- Head ---------- */

.peppys-terms-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--pt-line);
  background: var(--pt-card-hi);
}

.peppys-terms-modal__title {
  margin: 0;
  font-size: clamp(18px, 2.4vw, 22px);
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--pt-text);
}

.peppys-terms-modal__close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--pt-line);
  border-radius: 50%;
  background: transparent;
  color: var(--pt-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color .18s var(--pt-ease), border-color .18s var(--pt-ease);
}

.peppys-terms-modal__close:hover,
.peppys-terms-modal__close:focus-visible {
  color: var(--pt-text);
  border-color: var(--pt-gold);
}

/* ---------- Body ---------- */

.peppys-terms-modal__body {
  flex: 1 1 auto;
  min-height: 0;             /* without this a flex child refuses to scroll */
  overflow-y: auto;
  padding: 22px;
  overscroll-behavior: contain;
}

.peppys-terms-modal__body:focus-visible {
  outline: 2px solid var(--pt-gold);
  outline-offset: -4px;
}

/* ---------- The document ---------- */

.peppys-terms-doc {
  font-size: 15px;
  line-height: 1.7;
  color: var(--pt-dim);
}

.peppys-terms-doc p {
  margin: 0 0 1.1em;
}

.peppys-terms-doc p:last-child,
.peppys-terms-doc ul:last-child,
.peppys-terms-doc ol:last-child {
  margin-bottom: 0;
}

.peppys-terms-doc h3 {
  margin: 1.8em 0 .7em;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--pt-gold);
}

.peppys-terms-doc h3:first-child {
  margin-top: 0;
}

.peppys-terms-doc ul,
.peppys-terms-doc ol {
  margin: 0 0 1.1em;
  padding-left: 1.4em;
}

.peppys-terms-doc li {
  margin-bottom: .5em;
}

.peppys-terms-doc li::marker {
  color: var(--pt-mut);
}

/* ---------- Foot ---------- */

.peppys-terms-modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-top: 1px solid var(--pt-line);
  background: var(--pt-card-hi);
}

.peppys-terms-modal__link {
  color: var(--pt-mut);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.peppys-terms-modal__link:hover,
.peppys-terms-modal__link:focus-visible {
  color: var(--pt-dim);
}

/* Matches the specificity WooCommerce reaches its own buttons with
   (.woocommerce button.button) — a plainer selector loses and the button
   silently renders in Woo's grey. Same trap as peppys-account. */
.peppys-terms-modal__foot .peppys-terms-modal__done,
.woocommerce .peppys-terms-modal__foot button.peppys-terms-modal__done {
  padding: 11px 26px;
  border: 0;
  border-radius: 999px;
  background: var(--pt-gold);
  color: var(--pt-ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition: background .18s var(--pt-ease), transform .18s var(--pt-ease);
}

.peppys-terms-modal__foot .peppys-terms-modal__done:hover,
.woocommerce .peppys-terms-modal__foot button.peppys-terms-modal__done:hover {
  background: var(--pt-gold-600);
  transform: translateY(-1px);
}

/* Small screens: the panel takes the whole viewport, and the footer stops
   trying to sit two items on one line. */
@media (max-width: 480px) {
  .peppys-terms-modal {
    padding: 0;
  }

  .peppys-terms-modal__panel {
    width: 100%;
    max-height: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
}

/* =========================================================
   THE TERMS PAGE
   ---------------------------------------------------------
   Styles the document only. The page canvas is left to the theme so this page
   keeps whatever header, footer and width the rest of the site has.
   ========================================================= */

body.peppys-terms-page .peppys-terms-doc {
  max-width: 78ch;
  color: inherit;
}

body.peppys-terms-page .peppys-terms-doc h3 {
  color: inherit;
  opacity: .95;
}
