/* One product, many properties (#homes): the nine products on the left (each with its line icon),
   one building in the middle on one foundation line, the standard, and the four property types on
   the right. The building wears the chosen product in the current property type (fit.js draws and
   moves it; markup in components/fit.html, generated by tools/fit-gen.py). Without the script and
   under reduced motion the middle holds the four shapes as a quiet row instead. Tokens from
   styles.css only: navy lines on the vellum ground, gold only for light (lit windows, lamps, the
   string lights, the moon and the sun). Labels and numbers in Libre Franklin. */
.fit {
  --fit-light: var(--gold);
  --fit-fill: .46;   /* a lit window */
  --fit-dim: .2;     /* a window lit only by a desk lamp */
  --fit-cone: .62;   /* a lamp's light */
  --fit-gl: var(--ink);      /* lines drawn over the light */
  --fit-iof: var(--ground);  /* things in a lit window: curtains, a jersey */
  --fit-halo: rgba(168, 137, 78, .16);
  --fit-in: .8s;
  --fit-out: .6s;
  margin-top: clamp(88px, 11vw, 144px);
}
@media (prefers-color-scheme: dark) {
  .fit { --fit-light: var(--on-band-accent); --fit-fill: .8; --fit-dim: .34; --fit-cone: .9; --fit-gl: var(--ground); --fit-iof: var(--sunk); --fit-halo: rgba(214, 185, 138, .14); }
}

/* Head: a sub-head under the section head */
.fit-head { text-align: center; max-width: 820px; margin: 0 auto; }
.fit-head h3 { font-family: var(--display); font-weight: 600; font-size: clamp(32px, 3.6vw, 46px); line-height: 1.05; letter-spacing: -.005em; }
.fit-head p { margin: 18px auto 0; max-width: 64ch; font-size: 17px; line-height: 1.65; color: var(--muted); text-wrap: pretty; }

/* The figure. Stacked by default (the still, and phones): the nine products as three rows of
   three, the drawing, the four property types. On a wide screen the one building stands in the
   middle with the products on its left and the property types on its right; on a tablet the
   products stand on its left and the property types run below. A tap anywhere in it stops the
   cycle, so it has no tap highlight (phones would flash all of it). */
.fit-fig { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 26px; margin-top: clamp(40px, 5.5vw, 72px); -webkit-tap-highlight-color: transparent; }
.fit-col ul { list-style: none; margin: 0; padding: 0; }
.fit-cap { font-size: 12px; font-weight: 600; line-height: 1.3; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); text-align: center; margin-bottom: 10px; }

.fit-col button {
  -webkit-appearance: none; appearance: none; border: 0; border-radius: 0; margin: 0; background: none;
  font: inherit; color: var(--muted); text-align: inherit; cursor: pointer; position: relative;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
/* the names fade to ink; the icons change at once (a colour fading through a whole button, icon
   included, costs a style pass of every line of the icon in each frame of a move) */
.fit-pn, .fit-tn, .fit-tc { transition: color .45s ease; }
.fit-col button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* Products: icon and name. The one shown has ink and a lit icon; the one chosen a gold ring. */
.fit-prods ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 18px; max-width: 690px; margin: 0 auto; }
.fit-prods button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 3px 0; text-align: left; }
.fit-pn { font-size: 15px; font-weight: 500; line-height: 1.3; white-space: nowrap; }
.fit-ic {
  flex: none; display: block; width: 38px; height: 38px; padding: 5px; border-radius: 50%;
  fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round;
  transition: background-color .45s ease, box-shadow .45s ease;
}
.fit-ic .d { stroke-width: .85; }
.fit-prods li.is-on button { color: var(--ink); }
.fit-prods li.is-on .fit-ic { background: var(--fit-halo); }
.fit-prods button[aria-pressed="true"] { color: var(--ink); }
.fit-prods button[aria-pressed="true"] .fit-ic { box-shadow: inset 0 0 0 1px var(--fit-light); }

/* Property types: a mark, the name and the count. The one shown has its mark lit; the one chosen is ringed. */
.fit-types ul { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 14px; max-width: 760px; margin: 0 auto; }
.fit-types button { display: flex; flex-direction: column; width: 100%; padding: 6px 0 6px 18px; }
.fit-tn { font-size: 15px; font-weight: 600; line-height: 1.35; text-wrap: balance; }
.fit-tc { font-size: 14px; line-height: 1.4; font-variant-numeric: tabular-nums; white-space: nowrap; opacity: .85; }
.fit-types button::after {
  content: ""; position: absolute; left: 0; top: 15px; width: 7px; height: 7px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--muted); opacity: .55;
  transition: background-color .45s ease, box-shadow .45s ease, opacity .45s ease;
}
.fit-types li.is-on button { color: var(--ink); }
.fit-types li.is-on button::after { background: var(--fit-light); box-shadow: 0 0 0 4px var(--fit-halo); opacity: 1; }
.fit-types li button[aria-pressed="true"]::after { box-shadow: 0 0 0 2px var(--ground), 0 0 0 3px var(--fit-light); }
@media (hover: hover) {
  .fit-col button:hover { color: var(--ink); }
}

.fit-stage { position: relative; min-width: 0; width: 100%; max-width: 580px; justify-self: center; container-type: inline-size; }
/* the still row is wider, with each name under its own building */
.fit:not(.fit--one) .fit-stage { max-width: 1100px; }
.fit:not(.fit--one) .fit-types ul { grid-template-columns: 332fr 344fr 460fr 408fr; max-width: 1100px; column-gap: 0; }
.fit:not(.fit--one) .fit-types button { align-items: center; text-align: center; padding: 16px 6px 4px; }
.fit:not(.fit--one) .fit-types button::after { left: 50%; top: 2px; margin-left: -3.5px; }

@media (min-width: 1000px) {
  .fit--one .fit-fig { grid-template-columns: minmax(196px, 1fr) minmax(0, 600px) minmax(196px, 1fr); column-gap: clamp(24px, 3vw, 44px); align-items: end; }
  .fit--one .fit-fig { margin-top: 24px; }
  .fit--one .fit-col { padding-bottom: 44px; }
  .fit--one .fit-prods { justify-self: end; }
  .fit--one .fit-types { justify-self: start; }
  .fit--one .fit-prods .fit-cap { text-align: right; }
  .fit--one .fit-types .fit-cap { text-align: left; padding-left: 22px; }
  .fit--one .fit-prods ul, .fit--one .fit-types ul { display: block; max-width: none; }
  .fit--one .fit-prods button { flex-direction: row-reverse; justify-content: flex-start; text-align: right; padding: 2px 0; }
  .fit--one .fit-types li + li { margin-top: 8px; }
  .fit--one .fit-types button { padding: 6px 0 6px 22px; }
  .fit--one .fit-types button::after { top: 18px; }
  .fit--one .fit-stage { max-width: none; }
}
/* Tablets: the products down the left beside the building, the property types in a row below */
@media (min-width: 700px) and (max-width: 999.98px) {
  .fit--one .fit-fig { grid-template-columns: auto minmax(0, 1fr); column-gap: clamp(20px, 3vw, 36px); align-items: end; }
  .fit--one .fit-prods { grid-column: 1; grid-row: 1; padding-bottom: 36px; }
  .fit--one .fit-stage { grid-column: 2; grid-row: 1; max-width: 600px; }
  .fit--one .fit-types { grid-column: 1 / -1; }
  .fit--one .fit-prods .fit-cap { text-align: right; }
  .fit--one .fit-prods ul { display: block; max-width: none; }
  .fit--one .fit-prods button { flex-direction: row-reverse; justify-content: flex-start; text-align: right; padding: 2px 0; }
}

/* The drawing */
.fit-art { display: block; color: var(--ink); overflow: visible; }
.fit-art path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.fit-art circle { stroke: none; }
.fit-art .s { stroke-width: 1.4; }
.fit-art .d { stroke-width: .8; }
.fit-art .o { fill: var(--ground); stroke-width: 1.2; }
.fit-art .od { fill: var(--ground); stroke-width: .8; }
.fit-art .lt { fill: var(--fit-light); stroke: none; }
.fit-art .ls { stroke: var(--fit-light); stroke-width: 1.4; }
.fit-art .lw { fill: var(--fit-light); fill-opacity: var(--fit-fill); stroke: none; }
.fit-art .lw-dim { fill-opacity: var(--fit-dim); }
.fit-art .lc { fill: var(--fit-light); fill-opacity: var(--fit-cone); stroke: none; }
.fit-art .i { stroke: var(--fit-gl); stroke-width: .9; }
.fit-art .ib { stroke-width: 1.3; }
.fit-art .io { fill: var(--fit-iof); stroke: var(--fit-gl); stroke-width: .8; }
.fit-art .fit-mass { fill: var(--ground); stroke: none; }
.fit-art .fit-core { fill: var(--fit-light); stroke: none; }
.fit-art .gs { stop-color: currentColor; }
.fit-art .gl { stop-color: var(--fit-light); }
.fit-one { width: 100%; height: auto; }
.fit-std { margin-top: 10px; text-align: center; font-size: 12px; font-weight: 600; line-height: 1.3; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }

/* Layers of the one building fade in and out as a whole; its windows light ground floor first */
.fit-L { transition: opacity var(--fit-in) ease; }
.fit-L.is-off, .fit-L.is-out { opacity: 0; }
.fit-L.is-out { transition-duration: var(--fit-out); }
.fit-art .fit-pen { opacity: 0; }
.fit-L .lw { transition: opacity .7s ease; }
.fit-L .lw[data-g="1"] { transition-delay: .16s; }
.fit-L .lw[data-g="2"] { transition-delay: .32s; }
.fit-L.is-off .lw { opacity: 0; transition: none; }

/* The still: the four shapes in a row on one foundation, at one scale */
.fit-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; }
.fit-row .fit-still { flex: none; width: calc(var(--u) * var(--w)); height: auto; transition: opacity .4s ease; }
.fit-row .fit-still.is-dim { opacity: .28; }
/* fit-gen:widths (written by tools/fit-gen.py): each drawing's width in units */
.fit-row { --u: calc(100cqw / 1546); }
.fit-still[data-t="houses"] { --w: 332; }
.fit-still[data-t="multifamilies"] { --w: 344; }
.fit-still[data-t="apartments"] { --w: 460; }
.fit-still[data-t="larger"] { --w: 408; }
@media (max-width: 600px) { .fit-row { --u: calc(100cqw / 870); row-gap: 12px; } }
/* fit-gen:end */
.fit--one .fit-row { display: none; }

/* Words for screen readers only */
.fit-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Phones: icon above name, three by three; the types two by two; stronger lines */
@media (max-width: 600px) {
  .fit-head p { font-size: 16.5px; }
  .fit-fig { row-gap: 18px; margin-top: 36px; }
  .fit-prods ul { gap: 4px 6px; }
  .fit-prods button { flex-direction: column; gap: 2px; text-align: center; padding: 2px 0 4px; }
  .fit-pn { font-size: 12.5px; line-height: 1.25; white-space: normal; text-wrap: balance; }
  .fit-ic { width: 34px; height: 34px; padding: 4.5px; }
  .fit-types ul, .fit:not(.fit--one) .fit-types ul { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; }
  .fit:not(.fit--one) .fit-types button { padding: 14px 4px 2px; }
  .fit-tn { font-size: 14px; }
  .fit-tc { font-size: 13px; }
  .fit-types button { padding: 4px 0 4px 16px; }
  .fit-types button::after { top: 12px; width: 6px; height: 6px; }
  .fit-art .s { stroke-width: 1.9; }
  .fit-art .d { stroke-width: 1.1; }
  .fit-art .o { stroke-width: 1.6; }
  .fit-art .od, .fit-art .io { stroke-width: 1; }
  .fit-art .i { stroke-width: 1.05; }
  .fit-art .ls { stroke-width: 1.8; }
}

/* No motion and still frames: every change is instant */
@media (prefers-reduced-motion: reduce) {
  .fit *, .fit *::before, .fit *::after { transition: none !important; }
}
.fit.fit--still *, .fit.fit--still *::before, .fit.fit--still *::after { transition: none !important; }
