/*
 * TERMS & CONDITIONS.
 *
 * SCOPE. Every selector is under `.lf-legal--terms-and-conditions` or a `.lf-tc`
 * / `.lf-tcnav` / `.lf-tcdoc` / `.lf-tcbody` / `.lf-clause` / `.lf-tldr` /
 * `.lf-callout` / `.lf-tcstamp` class used on no other page. The template,
 * `parts-legal-layouts.php` and delivery.css are shared with every other policy
 * page, so nothing here may be written unscoped.
 *
 * SHARED WITH ANY PAGE BUILT FROM THE SAME LAYOUTS. The `.lf-tc*`, `.lf-clause`,
 * `.lf-tldr` and `.lf-callout` rules are deliberately NOT page-scoped, because
 * they were never page-specific: they describe a long reference document laid
 * out as a contents rail beside numbered sections. The Privacy Policy loads
 * this file for exactly that (see `inc/privacy-ui.php`) and adds only its
 * differences. Anything genuinely specific to the Terms goes under
 * `.lf-legal--terms-and-conditions`, and anything added here that is not must
 * be safe on any page using those layouts.
 *
 * WHAT THIS PAGE IS. A contract somebody may need to read carefully when
 * something has gone wrong, and skim when it has not. So it is built as a
 * document rather than as a landing page: a contents rail that stays with you,
 * numbered clauses at a real reading measure, and four quiet callouts across
 * twenty-six sections — not one box per paragraph.
 *
 * The measure is the whole design. Legal copy fails by being unreadable far
 * more often than by being ugly.
 */

.lf-legal--terms-and-conditions,
.lf-tc {
  --tc-r-sm: 10px;
  --tc-r-md: 13px;
  --tc-r-lg: 16px;
  --tc-r-xl: 20px;

  --tc-shell:  #FBF9F6;
  --tc-panel:  #F4F0EA;
  --tc-white:  #FFFFFF;
  --tc-hair:   #EAE4DC;
  --tc-hair-2: #DDD4C9;

  --tc-ease: cubic-bezier(.22, .61, .36, 1);
}

/* ============================================================ the canvas */

.lf-legal--terms-and-conditions .lf-dhero2 {
  padding-block: clamp(.5rem, 1.4vw, 1.35rem) clamp(1.5rem, 2.6vw, 2.25rem);
  align-items: end;
}
.lf-legal--terms-and-conditions .lf-dhero2__h {
  font-size: clamp(2.4rem, 4.6vw, 3.6rem);
  max-width: 12ch;
}
.lf-legal--terms-and-conditions .lf-dhero2__lede {
  font-size: clamp(1rem, 1.1vw, 1.1rem);
  max-width: 38rem;
  padding-bottom: .35rem;
}
.lf-legal--terms-and-conditions { padding-bottom: 0; }

/* The date the document was last written, not the date it is being read. */
.lf-tcstamp {
  grid-column: 1 / -1;
  margin: clamp(1rem, 2vw, 1.5rem) 0 0; padding-top: 1rem;
  border-top: 1px solid var(--tc-hair);
  font-size: .8rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--lf-taupe-mid);
}
.lf-tcstamp time { color: var(--lf-navy); }

.lf-tc { margin-top: clamp(2.25rem, 4.4vw, 3.75rem); }

/* ======================================================== the summary === */

.lf-tldr {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--tc-shell);
  border: 1px solid var(--tc-hair);
  border-radius: var(--tc-r-xl);
  overflow: hidden;
}
.lf-tldr__item {
  padding: clamp(1.15rem, 2vw, 1.6rem);
  border-left: 1px solid var(--tc-hair);
}
.lf-tldr__item:first-child { border-left: 0; }
.lf-tldr__k {
  margin: 0 0 .5rem; font-size: .76rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--lf-gold);
}
.lf-tldr__v { margin: 0; font-size: .92rem; line-height: 1.6; color: var(--lf-taupe-deep); }
/* Not optional, and not decorative: a summary read alone can look like the
   agreement, so the sentence saying it is not sits with it. */
.lf-tldr__note {
  margin: .9rem 0 0; font-size: .82rem; line-height: 1.6; color: var(--lf-taupe-mid);
}

/* ========================================================= the document = */

.lf-tcdoc {
  display: grid;
  /* The rail is a fixed width because it is furniture, not content: at a
     proportion it grew past 320px on a wide screen and squeezed the measure. */
  grid-template-columns: 232px minmax(0, 1fr);
  gap: clamp(2rem, 4.5vw, 4.5rem);
  align-items: start;
}

/* ---- the contents rail ---- */

.lf-tcnav {
  position: sticky; top: 9.5rem;          /* clear of the 134px sticky header */
  max-height: calc(100vh - 12rem);
  overflow-y: auto;
  /* A rail that scrolls needs a little room so the last entry is not flush
     against the viewport edge. */
  padding-right: .5rem;
  scrollbar-width: thin;
}
.lf-tcnav__title {
  margin: 0 0 1rem; font-size: .76rem; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--lf-taupe-mid);
}
/*
 * THE DISCLOSURE SHIPS CLOSED, AND IS OPENED FOR DESKTOP BY SCRIPT.
 *
 * It used to carry `open` in the markup, which is right for the desktop rail
 * and wrong for a phone: twenty-six links above the document is the document
 * pushed off the screen. The attribute cannot be set per viewport in PHP, and a
 * closed `<details>` cannot be forced open reliably from CSS, so the enhancement
 * sets it — see `inc/terms-ui.php`. Without JavaScript the rail is a collapsed
 * "Jump to a section" control at every width, which still works.
 */
.lf-tcnav__wrap { display: block; }
.lf-tcnav__toggle { display: none; }
.lf-tcnav__list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .1rem;
  counter-reset: none;
}
.lf-tcnav__list a {
  display: grid; grid-template-columns: 1.6rem minmax(0, 1fr);
  gap: .6rem; align-items: baseline;
  padding: .42rem .5rem .42rem 0;
  border-radius: var(--tc-r-sm);
  text-decoration: none;
  transition: color .18s var(--tc-ease), background .18s var(--tc-ease);
}
/* 12.16px. The rail is utility type and wants to be small; it does not want
   to be under 12px, which is where "refined" becomes "unreadable". */
.lf-tcnav__n { font-size: .76rem; color: var(--lf-taupe-mid); letter-spacing: .02em; }
.lf-tcnav__t { font-size: .87rem; line-height: 1.4; color: var(--lf-taupe); }
.lf-tcnav__list a:hover .lf-tcnav__t { color: var(--lf-navy); }
.lf-tcnav__list a:focus-visible { outline: 2px solid var(--lf-gold); outline-offset: 2px; }
/* The reader's position, added by the observer and by nothing else. */
.lf-tcnav__list a.is-here .lf-tcnav__t { color: var(--lf-navy); }
.lf-tcnav__list a.is-here .lf-tcnav__n { color: var(--lf-gold); }
.lf-tcnav__list a.is-here { background: var(--tc-shell); }

/* ---- the clauses ---- */

.lf-tcbody { min-width: 0; }
.lf-clause {
  /* 68ch at 17px is roughly 720px — inside the 680-780px the brief asks for,
     and the number the rest of this page is composed around. */
  max-width: 68ch;
  padding-bottom: clamp(2rem, 3.4vw, 2.75rem);
  margin-bottom: clamp(2rem, 3.4vw, 2.75rem);
  border-bottom: 1px solid var(--tc-hair);
  /* Clear of the sticky header when an anchor is followed. */
  scroll-margin-top: 9rem;
}
.lf-clause:last-child { border-bottom: 0; margin-bottom: 0; }
.lf-clause__n {
  margin: 0 0 .35rem;
  font-family: var(--lf-serif); font-size: 1rem; line-height: 1;
  color: var(--lf-gold); letter-spacing: .04em;
}
.lf-clause__h {
  margin: 0 0 1rem;
  font-family: var(--lf-serif); font-weight: 400;
  font-size: clamp(1.45rem, 2.2vw, 1.9rem); line-height: 1.18;
  letter-spacing: -0.012em; color: var(--lf-navy);
}
.lf-clause__p {
  margin: 0 0 1rem;
  /* 17px, 1.7 — legal copy is read, not glanced at. */
  font-size: 1.06rem; line-height: 1.72; color: var(--lf-taupe-deep);
}
.lf-clause__p:last-of-type { margin-bottom: 0; }
.lf-clause__link { margin: 1.15rem 0 0; }
.lf-clause__link a {
  display: inline-flex; align-items: center; gap: .45rem;
  min-height: 2.75rem;
  font-size: .95rem; color: var(--lf-navy); text-decoration: none;
  box-shadow: inset 0 -1px 0 var(--lf-gold-line);
  transition: box-shadow .25s var(--tc-ease);
}
.lf-clause__link a:hover { box-shadow: inset 0 -1px 0 var(--lf-gold); }
.lf-clause__link a span { transition: transform .25s var(--tc-ease); }
.lf-clause__link a:hover span { transform: translateX(3px); }
.lf-clause__link a:focus-visible { outline: 2px solid var(--lf-gold); outline-offset: 3px; }

/* ---- the callouts: four of them across twenty-six clauses ---- */

.lf-callout {
  margin: 1.35rem 0 0; padding: 1.15rem 1.3rem;
  background: var(--tc-panel);
  border: 1px solid var(--tc-hair);
  border-left: 2px solid var(--lf-gold-rule);
  border-radius: var(--tc-r-md);
}
.lf-callout__t {
  margin: 0 0 .4rem; font-size: .76rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--lf-gold);
}
.lf-callout__b { margin: 0; font-size: .97rem; line-height: 1.65; color: var(--lf-taupe-deep); }

/* ==================================================== useful information */

.lf-legal--terms-and-conditions .lf-dsec--pathways {
  margin-top: clamp(2.75rem, 5vw, 4.5rem);
}

/* =========================================================== responsive */

@media (max-width: 1080px) {
  /*
   * The rail stops being a rail and becomes a disclosure above the document.
   * `<details>` is used rather than a custom accordion because the browser
   * already knows how to open it, announce it and operate it from a keyboard.
   */
  .lf-tcdoc { grid-template-columns: minmax(0, 1fr); gap: clamp(1.5rem, 3vw, 2rem); }
  .lf-tcnav {
    position: static; max-height: none; overflow: visible; padding-right: 0;
    background: var(--tc-shell);
    border: 1px solid var(--tc-hair);
    border-radius: var(--tc-r-lg);
  }
  .lf-tcnav__title { display: none; }
  .lf-tcnav__toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    min-height: 3.25rem; padding: .85rem 1.15rem; cursor: pointer;
    font-size: .78rem; font-weight: 500; letter-spacing: .13em;
    text-transform: uppercase; color: var(--lf-navy);
    list-style: none;
  }
  .lf-tcnav__toggle::-webkit-details-marker { display: none; }
  .lf-tcnav__toggle::after {
    content: ""; width: .55rem; height: .55rem; flex: none;
    border-right: 1.5px solid var(--lf-taupe); border-bottom: 1.5px solid var(--lf-taupe);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform .22s var(--tc-ease);
  }
  .lf-tcnav__wrap[open] .lf-tcnav__toggle::after { transform: rotate(-135deg) translate(-2px, -2px); }
  .lf-tcnav__toggle:focus-visible { outline: 2px solid var(--lf-gold); outline-offset: -2px; }
  .lf-tcnav__list {
    padding: 0 .6rem .8rem; gap: 0;
    border-top: 1px solid var(--tc-hair); margin-top: 0; padding-top: .5rem;
  }
  .lf-tcnav__list a { padding: .6rem .55rem; min-height: 2.75rem; align-items: center; }
  /* Closed by default on a small screen: 26 links above the document is the
     document pushed off the page. */
  .lf-tcnav__wrap:not([open]) .lf-tcnav__list { display: none; }
  .lf-clause { max-width: none; }
}

@media (max-width: 900px) {
  .lf-tldr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lf-tldr__item { border-left: 0; border-top: 1px solid var(--tc-hair); }
  .lf-tldr__item:nth-child(odd) { border-right: 1px solid var(--tc-hair); }
  .lf-tldr__item:nth-child(-n+2) { border-top: 0; }
}

@media (max-width: 640px) {
  .lf-legal--terms-and-conditions .lf-dhero2 { padding-block: .5rem 1.25rem; }
  .lf-tc { margin-top: 1.75rem; }
  .lf-tldr { grid-template-columns: minmax(0, 1fr); border-radius: var(--tc-r-lg); }
  .lf-tldr__item { border-right: 0 !important; border-top: 1px solid var(--tc-hair); }
  .lf-tldr__item:first-child { border-top: 0; }
  .lf-clause { padding-bottom: 1.75rem; margin-bottom: 1.75rem; }
  .lf-clause__p { font-size: 1.02rem; line-height: 1.7; }
  .lf-callout { padding: 1rem 1.1rem; }
}

/* ====================================================== reduced motion */

@media (prefers-reduced-motion: reduce) {
  .lf-tc *, .lf-tcnav * { transition: none !important; }
}
