/* ==========================================================================
   Looking Sharp — brand components
   Client-only additions the shared components can't express. Tokens only.
   Load after components.css. See brand-id.md, Sections 5 and 6.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. The tape measure
   Markup:
   .tape[data-from][data-to]
     .tape__case            the case the blade pulls out of (decorative)
     .tape__track
       .tape__blade         yellow blade; ticks are background stripes
         .tape__num         decade numbers (site.js adds them)
         .tape__gap         shaded span on the blade (optional)
       .tape__hook          steel hook at the end of the blade
       .tape__marker        a labelled pin (style="--at: 0.4"), .tape__marker--row2 / --row3 to stack labels
   --tape-span is the number of years on the blade (set by script, default 70).
   --tape-p is how far the blade is pulled out, 0 to 1. Without script it stays at 1.
   -------------------------------------------------------------------------- */

@property --tape-p {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

.tape {
  --tape-span: 70;
  --tape-tick: var(--color-primary-dark);
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.tape.is-pending {
  --tape-p: 0;
}

.tape.is-out {
  --tape-p: 1;
  transition: --tape-p var(--tape-motion);
}

.tape__case {
  --case: var(--tape-height);
  flex: none;
  display: grid;
  place-items: center;
  width: var(--case);
  height: var(--case);
  margin-top: 0;
  border: var(--rule-accent-weight) solid var(--color-secondary);
  border-radius: var(--radius);
  color: var(--color-secondary);
  font-family: var(--font-heading);
  font-size: var(--text-h3);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-wordmark);
  position: relative;
  z-index: 1;
  background-color: var(--ctx-bg);
}

@media (min-width: 48rem) {
  .tape__case {
    --case: calc(var(--tape-height) * 1.5);
    margin-top: calc(var(--tape-height) * -0.25);
  }
}

.tape__track {
  position: relative;
  flex: 1;
  min-width: 0;
}

.tape__blade {
  position: relative;
  height: var(--tape-height);
  overflow: hidden;
  background-color: var(--color-accent);
  /* Hard-edged ticks: one per year, longer every 5 and 10. Not a colour gradient (brand-id.md). */
  background-image:
    linear-gradient(to right, var(--tape-tick) var(--rule-accent-weight), transparent 0),
    linear-gradient(to right, var(--tape-tick) var(--rule-accent-weight), transparent 0),
    linear-gradient(to right, var(--tape-tick) var(--rule-accent-weight), transparent 0);
  background-size:
    calc(100% / var(--tape-span)) 22%,
    calc(500% / var(--tape-span)) 38%,
    calc(1000% / var(--tape-span)) 58%;
  background-repeat: repeat-x;
  background-position: 0 0;
  clip-path: inset(0 calc(100% - var(--tape-p) * 100%) 0 0);
}

.tape__num {
  position: absolute;
  bottom: 8%;
  left: calc(var(--at) * 100%);
  padding-left: var(--space-xs);
  color: var(--tape-tick);
  font-family: var(--font-heading);
  font-size: calc(var(--tape-height) * 0.36);
  font-weight: var(--weight-light);
  line-height: var(--line-height-hero);
}

.tape__gap {
  position: absolute;
  inset-block: 0;
  left: calc(var(--from) * 100%);
  width: calc((var(--to) - var(--from)) * 100%);
  background-color: color-mix(in srgb, var(--color-primary-dark) 22%, transparent);
  transition: left var(--transition), width var(--transition);
}

.tape__hook {
  position: absolute;
  top: calc(var(--tape-height) * -0.12);
  left: calc(var(--tape-p) * 100%);
  width: calc(var(--tape-height) * 0.14);
  height: calc(var(--tape-height) * 1.24);
  border-radius: var(--radius-sm);
  background-color: var(--color-secondary);
}

/* Markers: a thin line down from the blade to a label. Rows keep close years from overlapping. */
.tape__marker {
  --row: 0;
  position: absolute;
  top: 0;
  left: calc(var(--at) * 100%);
  height: calc(var(--tape-height) + var(--space-md) + var(--row) * var(--space-xl));
  border-left: var(--rule-accent-weight) solid currentColor;
  opacity: var(--tape-p);
  transition: left var(--transition);
}

/* Where the line crosses the yellow blade it is drawn in Carbon, heavier */
.tape__marker::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc(var(--rule-accent-weight) * -1.5);
  height: var(--tape-height);
  border-left: calc(var(--rule-accent-weight) * 2) solid var(--tape-tick);
}

.tape__marker--row2 { --row: 1; }
.tape__marker--row3 { --row: 2; }

.tape__marker[hidden] {
  display: none;
}

/* Labels sit above other markers' lines, on the section background */
.tape__label {
  position: absolute;
  z-index: 1;
  top: 100%;
  left: calc(var(--rule-accent-weight) * -1);
  padding: var(--space-xs) var(--space-xs) 0 0;
  background-color: var(--ctx-bg);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: var(--weight-body);
  line-height: var(--line-height-ui);
  letter-spacing: var(--tracking-nav);
  text-transform: var(--label-text-transform);
  white-space: nowrap;
}

/* Labels past the middle of the tape hang to the left of their line */
.tape__marker.is-right .tape__label {
  left: auto;
  right: 0;
  text-align: right;
}

.tape__label b {
  display: block;
  font-family: var(--font-heading);
  font-size: var(--text-h4);
  font-weight: var(--weight-light);
  letter-spacing: normal;
}

/* Room under the tape for three rows of labels */
.tape-wrap {
  padding-bottom: calc(var(--space-xl) * 3);
}

@media (prefers-reduced-motion: reduce) {
  .tape.is-out,
  .tape__gap,
  .tape__marker {
    transition: none;
  }
}


/* --------------------------------------------------------------------------
   2. Docket: price lines set like a quote docket
   Markup: ul.docket > li > span.docket__item + span.docket__price
   -------------------------------------------------------------------------- */

.docket {
  max-width: none;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: var(--weight-body);
}

.docket li {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin: 0;
  padding-block: var(--space-sm);
}

.docket__item {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: var(--space-sm);
}

/* Dotted leader between the item and its price */
.docket__item::after {
  content: "";
  flex: 1;
  border-bottom: var(--rule-accent-weight) dotted var(--color-text-muted);
}

.docket__price {
  font-weight: var(--weight-bold);
  white-space: nowrap;
}


/* --------------------------------------------------------------------------
   3. FAQ: native <details>, one per question
   Markup: details.faq > summary.faq__q + .faq__a
   -------------------------------------------------------------------------- */

.faq {
  border-top: var(--border-weight) solid var(--ctx-rule);
}

.faq:last-of-type {
  border-bottom: var(--border-weight) solid var(--ctx-rule);
}

.faq__q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: var(--target-size);
  padding-block: var(--space-md);
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: var(--text-h4);
  font-weight: var(--weight-heading);
  line-height: var(--line-height-heading);
  list-style: none;
}

.faq__q::-webkit-details-marker {
  display: none;
}

/* Plus that turns into a minus */
.faq__q::after {
  content: "+";
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-h3);
  font-weight: var(--weight-body);
}

.faq[open] .faq__q::after {
  content: "\2212";
}

.faq__a {
  padding-bottom: var(--space-md);
}

.faq__a > :last-child {
  margin-bottom: 0;
}
