/*
 * Brand elements for the branded case studies (Hudsonhaus, Westchester Barber
 * Pro). One static file, linked only by a case that names a `brand`, so the
 * studio's other pages do not carry it. The site inlines its own CSS twice into
 * every page and holds each case page under a size budget; see DECISIONS.md.
 *
 *   cm-*  the mark over a chapter heading      (components/Case/ChapterMark.tsx)
 *   in-*  the fixed scroll instrument          (components/Case/Instrument.tsx)
 *   st-*  the room's ceiling, brick and floor  (components/Case/Strata.tsx)
 *   the last block styles pictures inside a chapter, by [data-brand]
 *
 * This file is the source; there is no build step. It is cached for an hour
 * (vercel.json), so a change reaches visitors within the hour.
 */

/* Chapter mark */
/* The mark over a chapter's heading. See ChapterMark.tsx. */
.cm-tide,
.cm-room {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
  min-width: 0;
}

/* ---- Tide: a gauge with one fixed edge ---------------------------------- */
.cm-tide {
  color: var(--ink-soft);
  font:
    400 0.75rem/1 ui-monospace,
    'SF Mono',
    Menlo,
    Consolas,
    monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.cm-tide::before {
  content: 'N° ' attr(data-n);
  color: var(--ink);
  white-space: nowrap;
}
.cm-tide::after {
  content: var(--read);
  white-space: nowrap;
  min-width: 5.5em;
  text-align: right;
}
.cm-tide i {
  position: relative;
  flex: 1;
  height: 26px;
  min-width: 0;
  border-left: 2px solid var(--ink);
  background:
    repeating-linear-gradient(90deg, var(--ink-soft) 0 1px, transparent 1px 60px) left bottom / 100%
      15px no-repeat,
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 12px) left bottom / 100% 8px
      no-repeat,
    /* The water: a line from the fixed edge to this chapter's reading... */
    linear-gradient(var(--ink), var(--ink)) left bottom / var(--level) 2px no-repeat,
    /* ...and a short tick standing at its edge. */ linear-gradient(var(--ink), var(--ink)) left
      var(--level) bottom / 2px 100% no-repeat;
}

/* The water's height at each chapter, 0.3 to 4.7 ft: a wave down the page. */
.cm-tide[data-n='01'] { --level: 100%; --read: '4.7 ft'; }
.cm-tide[data-n='02'] { --level: 71%; --read: '3.4 ft'; }
.cm-tide[data-n='03'] { --level: 17%; --read: '1.1 ft'; }
.cm-tide[data-n='04'] { --level: 2%; --read: '0.4 ft'; }
.cm-tide[data-n='05'] { --level: 43%; --read: '2.2 ft'; }
.cm-tide[data-n='06'] { --level: 93%; --read: '4.4 ft'; }
.cm-tide[data-n='07'] { --level: 91%; --read: '4.3 ft'; }
.cm-tide[data-n='08'] { --level: 41%; --read: '2.1 ft'; }
.cm-tide[data-n='09'] { --level: 2%; --read: '0.4 ft'; }
.cm-tide[data-n='10'] { --level: 19%; --read: '1.1 ft'; }
.cm-tide[data-n='11'] { --level: 73%; --read: '3.5 ft'; }
.cm-tide[data-n='12'] { --level: 100%; --read: '4.7 ft'; }

/* ---- Room: a brass plate and a length of rope --------------------------- */
.cm-room {
  --brass: var(--accent);
}
.cm-room::before {
  content: 'No. ' attr(data-n);
  flex: none;
  padding: 7px 14px 6px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--brass) 78%, white) 0%,
    var(--brass) 55%,
    color-mix(in srgb, var(--brass) 80%, black) 100%
  );
  color: #14181a;
  font-weight: 700;
  font-size: 0.75rem;
  line-height: 1;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  /* The shield's chamfered corners, on a plate the size of a thumb. */
  clip-path: polygon(
    7px 0,
    calc(100% - 7px) 0,
    100% 7px,
    100% calc(100% - 7px),
    calc(100% - 7px) 100%,
    7px 100%,
    0 calc(100% - 7px),
    0 7px
  );
}
.cm-room i {
  flex: 1;
  height: 8px;
  min-width: 0;
  border-radius: 4px;
  background:
    repeating-linear-gradient(115deg, rgba(0, 0, 0, 0.42) 0 1.5px, transparent 1.5px 8px),
    repeating-linear-gradient(
      115deg,
      color-mix(in srgb, var(--brass) 70%, white) 0 4px,
      var(--brass) 4px 8px
    );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 2px rgba(0, 0, 0, 0.4);
}
/* A brass stud at the rope's end. */
.cm-room::after {
  content: '';
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    color-mix(in srgb, var(--brass) 55%, white),
    var(--brass) 55%,
    color-mix(in srgb, var(--brass) 55%, black)
  );
}

/* Scroll instrument */
.in-instrument {
  display: none;
  position: fixed;
  z-index: 5;
  right: clamp(10px, 1.5vw, 26px);
  top: 18vh;
  height: 64vh;
  width: 14px;
  pointer-events: none;
}

@media (min-width: 1100px) {
  @supports (animation-timeline: scroll()) {
    .in-instrument {
      display: block;
      /* Gone by the footer. */
      animation: in-out linear both;
      animation-timeline: scroll(root block);
      animation-range: 90% 99%;
    }
  }
}

@keyframes in-out {
  to {
    opacity: 0;
  }
}

/* ---- Tide: a rail of tick marks, and the lamp riding it ------------------ */
.in-tide::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 3px;
  width: 12px;
  border-left: 1px solid rgba(236, 231, 221, 0.55);
  background:
    repeating-linear-gradient(180deg, rgba(236, 231, 221, 0.75) 0 1px, transparent 1px 64px) left
      top / 12px 100% no-repeat,
    repeating-linear-gradient(180deg, rgba(236, 231, 221, 0.4) 0 1px, transparent 1px 16px) left
      top / 6px 100% no-repeat;
}
.in-tide::after {
  content: '';
  position: absolute;
  left: -1px;
  top: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff3b1f;
  box-shadow:
    0 0 0 3px rgba(255, 59, 31, 0.22),
    0 0 16px 3px rgba(255, 59, 31, 0.45);
  animation: in-rise linear both;
  animation-timeline: scroll(root block);
}
@keyframes in-rise {
  to {
    transform: translateY(calc(64vh - 9px));
  }
}

/* ---- Room: a barber pole with brass caps, turning as the page moves ------ */
.in-room {
  background:
    linear-gradient(90deg, #8a6727, #d2a95b 45%, #8a6727) left top / 100% 7px no-repeat,
    linear-gradient(90deg, #8a6727, #d2a95b 45%, #8a6727) left bottom / 100% 7px no-repeat;
}
.in-room::before {
  content: '';
  position: absolute;
  inset: 8px 1px;
  border-radius: 6px;
  /* A square tile that repeats without a seam: linen at both ends. */
  background: linear-gradient(
      135deg,
      #f2ede3 0 12.5%,
      #9c5540 12.5% 37.5%,
      #f2ede3 37.5% 62.5%,
      #1b3a2f 62.5% 87.5%,
      #f2ede3 87.5% 100%
    )
    0 0 / 24px 24px;
  box-shadow:
    inset 3px 0 3px rgba(255, 255, 255, 0.28),
    inset -3px 0 4px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(185, 141, 62, 0.55);
  animation: in-turn linear both;
  animation-timeline: scroll(root block);
}
@keyframes in-turn {
  to {
    background-position: 0 960px;
  }
}

/* A branded case sets the client's colors on its article; these follow from them. */
[data-brand] {
  --ink-strong: var(--ink);
  --ink-lede: var(--ink);
  --focus: var(--accent);
  --focus-inner: transparent;
}

/* Strata */
.st-strata figcaption {
  margin-top: var(--s-3);
  font-weight: 400;
}
.st-layers {
  display: grid;
  grid-template-rows: clamp(56px, 8vw, 88px) clamp(88px, 13vw, 144px) clamp(56px, 8vw, 88px);
  border: 1px solid var(--line);
  /* The shield's chamfer, on three strips of a room. */
  clip-path: polygon(
    18px 0,
    calc(100% - 18px) 0,
    100% 18px,
    100% calc(100% - 18px),
    calc(100% - 18px) 100%,
    18px 100%,
    0 calc(100% - 18px),
    0 18px
  );
}
.st-layers > div {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: var(--s-2);
}
.st-tag {
  padding: 4px 10px;
  background: #0f221b;
  color: #f2ede3;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Joists and a duct, painted out in matte black. */
.st-ceiling {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px) 0 0 / 100% 100%,
    linear-gradient(180deg, transparent 0 38%, #2a3033 38% 41%, #14181a 41% 52%, transparent 52%),
    repeating-linear-gradient(90deg, #14181a 0 60px, #070909 60px 64px, #1a1f21 64px 66px);
}

/* Running bond: a course of bricks, each row half a brick over from the last. */
.st-brick {
  background:
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.3),
      transparent 22%,
      transparent 78%,
      rgba(0, 0, 0, 0.22)
    ),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='32'%3E%3Crect width='48' height='32' fill='%239C5540'/%3E%3Crect x='2' y='2' width='20' height='12' fill='%23a65f49'/%3E%3Crect x='26' y='18' width='20' height='12' fill='%2392503b'/%3E%3Cpath d='M0 1H48M0 17H48M1 0V16M25 16V32' stroke='%230F221B' stroke-width='2' fill='none'/%3E%3C/svg%3E")
      0 0 / 48px 32px;
}

/* Wide planks laid in rows, the end joints staggered. */
.st-floor {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 30%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='36'%3E%3Crect width='260' height='36' fill='%23C29A63'/%3E%3Crect y='18' width='260' height='18' fill='%23b98f58'/%3E%3Cpath d='M0 18H260M96 0V18M180 18V36' stroke='%237f6238' stroke-width='1.5' fill='none'/%3E%3C/svg%3E")
      0 0 / 260px 36px;
}

/* Pictures inside a chapter. A case names its brand in frontmatter and the article carries `data-brand`. */
/*
 * The brand elements of a branded case study, for what the components cannot
 * reach on their own: the pictures inside a chapter. A case names its brand in
 * frontmatter and the article carries `data-brand`.
 *
 *   tide  Hudsonhaus. Crop marks at a picture's corners, the tailor's tick
 *         marks, and a doorway's arch on a tall picture.
 *   room  Westchester Barber Pro. A picture takes the shield's chamfered
 *         corners, edged in brass.
 *
 * Only pictures that sit in a chapter's column or in a spread are touched.
 * Edge-to-edge plates, device frames and the masthead are left alone.
 */

/* ---- Tide --------------------------------------------------------------- */
[data-brand='tide'] [data-client-surface] .wrap > figure > picture,
[data-brand='tide'] [data-client-surface] [data-block] > figure:not([data-arch]) > picture {
  position: relative;
}
[data-brand='tide'] [data-client-surface] .wrap > figure > picture::after,
[data-brand='tide'] [data-client-surface] [data-block] > figure:not([data-arch]) > picture::after {
  content: '';
  position: absolute;
  inset: -9px;
  pointer-events: none;
  background:
    linear-gradient(var(--ink-soft), var(--ink-soft)) left 0 top 9px / 8px 1px no-repeat,
    linear-gradient(var(--ink-soft), var(--ink-soft)) left 9px top 0 / 1px 8px no-repeat,
    linear-gradient(var(--ink-soft), var(--ink-soft)) right 0 top 9px / 8px 1px no-repeat,
    linear-gradient(var(--ink-soft), var(--ink-soft)) right 9px top 0 / 1px 8px no-repeat,
    linear-gradient(var(--ink-soft), var(--ink-soft)) left 0 bottom 9px / 8px 1px no-repeat,
    linear-gradient(var(--ink-soft), var(--ink-soft)) left 9px bottom 0 / 1px 8px no-repeat,
    linear-gradient(var(--ink-soft), var(--ink-soft)) right 0 bottom 9px / 8px 1px no-repeat,
    linear-gradient(var(--ink-soft), var(--ink-soft)) right 9px bottom 0 / 1px 8px no-repeat;
}
[data-brand='tide'] figure[data-arch] > picture {
  display: block;
  overflow: hidden;
  border-radius: 999px 999px 0 0;
}

/* Captions read like the stamp on a print: small, spaced, in a monospace. */
[data-brand='tide'] [data-client-surface] figcaption {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---- Room --------------------------------------------------------------- */
/* Brass edge: the picture's box is the brass, the picture sits 1px inside it. */
[data-brand='room'] [data-client-surface] .wrap > figure > picture,
[data-brand='room'] [data-client-surface] [data-block] > figure > picture {
  padding: 1px;
  background: linear-gradient(135deg, #d2a95b, #b98d3e 45%, #8a6727);
  clip-path: polygon(
    16px 0,
    calc(100% - 16px) 0,
    100% 16px,
    100% calc(100% - 16px),
    calc(100% - 16px) 100%,
    16px 100%,
    0 calc(100% - 16px),
    0 16px
  );
}
[data-brand='room'] [data-client-surface] .wrap > figure > picture > img,
[data-brand='room'] [data-client-surface] [data-block] > figure > picture > img {
  clip-path: polygon(
    15.4px 0,
    calc(100% - 15.4px) 0,
    100% 15.4px,
    100% calc(100% - 15.4px),
    calc(100% - 15.4px) 100%,
    15.4px 100%,
    0 calc(100% - 15.4px),
    0 15.4px
  );
}
[data-brand='room'] [data-client-surface] figcaption {
  letter-spacing: 0.01em;
}

/* ---- Lantern: a ridgeline with the lantern hung over it (Sleepy Hollow Studio) ---- */
.cm-lantern {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
  min-width: 0;
  color: var(--ink-soft);
  font:
    500 0.875rem/1 var(--body),
    sans-serif;
}
.cm-lantern::before {
  content: 'Mile ' attr(data-n);
  color: var(--ink);
  white-space: nowrap;
}
.cm-lantern::after {
  content: var(--read);
  min-width: 11em;
  text-align: right;
  white-space: nowrap;
}
.cm-lantern i {
  position: relative;
  flex: 1;
  height: 34px;
  min-width: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='16' viewBox='0 0 240 16'%3E%3Cpath d='M0 12L18 8 34 10 52 4 70 9 92 6 110 11 132 3 150 8 172 5 196 10 216 7 240 12' fill='none' stroke='%235c7378' stroke-width='1.3'/%3E%3C/svg%3E")
    left bottom / 240px 16px repeat-x;
  border-bottom: 1px solid var(--line);
}
/* The lantern: the dot, hung where this chapter's hour sits along the ridge. */
.cm-lantern i::after {
  content: '';
  position: absolute;
  left: var(--level);
  bottom: 14px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: #e6a23c;
  box-shadow: 0 0 14px 4px rgba(230, 162, 60, 0.35);
}
@media (max-width: 640px) {
  .cm-lantern::after {
    min-width: 0;
  }
}

.cm-lantern[data-n='01'] { --level: 95%; --read: 'First light'; }
.cm-lantern[data-n='02'] { --level: 69%; --read: 'Fog lifting'; }
.cm-lantern[data-n='03'] { --level: 21%; --read: 'High haze'; }
.cm-lantern[data-n='04'] { --level: 7%; --read: 'Noon on the water'; }
.cm-lantern[data-n='05'] { --level: 44%; --read: 'Long shadows'; }
.cm-lantern[data-n='06'] { --level: 88%; --read: 'Gold on the far shore'; }
.cm-lantern[data-n='07'] { --level: 87%; --read: 'Blue hour'; }
.cm-lantern[data-n='08'] { --level: 42%; --read: 'Lantern hour'; }
.cm-lantern[data-n='09'] { --level: 6%; --read: 'Deep night'; }
.cm-lantern[data-n='10'] { --level: 22%; --read: 'First light'; }
.cm-lantern[data-n='11'] { --level: 71%; --read: 'Fog lifting'; }
.cm-lantern[data-n='12'] { --level: 95%; --read: 'High haze'; }
.cm-lantern[data-n='13'] { --level: 66%; --read: 'Noon on the water'; }
.cm-lantern[data-n='14'] { --level: 18%; --read: 'Long shadows'; }
.cm-lantern[data-n='15'] { --level: 8%; --read: 'Gold on the far shore'; }
.cm-lantern[data-n='16'] { --level: 48%; --read: 'Blue hour'; }
.cm-lantern[data-n='17'] { --level: 90%; --read: 'Lantern hour'; }
.cm-lantern[data-n='18'] { --level: 85%; --read: 'Deep night'; }
.cm-lantern[data-n='19'] { --level: 38%; --read: 'First light'; }
.cm-lantern[data-n='20'] { --level: 6%; --read: 'Fog lifting'; }
.cm-lantern[data-n='21'] { --level: 25%; --read: 'High haze'; }
.cm-lantern[data-n='22'] { --level: 74%; --read: 'Noon on the water'; }
.cm-lantern[data-n='23'] { --level: 95%; --read: 'Long shadows'; }
.cm-lantern[data-n='24'] { --level: 62%; --read: 'Gold on the far shore'; }

/* ---- Lantern: the river line, and the lantern riding it, warming as you go ---- */
.in-lantern::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(#5c7378, #5c7378) left 6px top 0 / 1px 100% no-repeat,
    repeating-linear-gradient(180deg, #5c7378 0 1px, transparent 1px 32px) left 3px top 0 / 7px 100%
      no-repeat;
}
.in-lantern::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5c7378;
  animation:
    in-rise linear both,
    in-warm linear both;
  animation-timeline: scroll(root block);
}
@keyframes in-warm {
  to {
    background: #e6a23c;
    box-shadow: 0 0 16px 4px rgba(230, 162, 60, 0.45);
  }
}
