/* ===========================================================
   Facebook story sections (see story-fb.js).
   Scoped to the two section ids and the ew-fb- prefix.
   =========================================================== */

/* ---------- shared ---------- */

#todo-fb-overview,
#todo-fb-easywean { overflow: hidden; }

#todo-fb-overview > *,
#todo-fb-easywean > * { position: relative; z-index: 1; }

#todo-fb-overview > .ew-fb-ghost,
#todo-fb-easywean > .ew-fb-ghost,
#todo-fb-overview > .ew-fb-ov-patch,
#todo-fb-easywean > .ew-fb-ew-strip { position: absolute; z-index: 0; }

.ew-fb-ghost {
  top: 10%;
  right: -2vw;
  margin: 0;
  font-size: clamp(6rem, 22vw, 19rem);
  white-space: nowrap;
}

.ew-fb-hook {
  font-family: var(--font-family-display);
  font-weight: 700;
  font-size: clamp(1.35rem, 2.8vw, 2.2rem);
  line-height: 1.2;
  color: var(--heading-fg);
  max-width: 22ch;
  text-wrap: balance;
}

.ew-fb-takeaway {
  font-weight: 800;
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  line-height: 1.15;
  color: var(--heading-fg);
  max-width: 24ch;
  padding-left: 1rem;
  border-left: 5px solid var(--color-primary);
  text-wrap: balance;
}

.ew-fb-context {
  margin-top: 1rem;
  max-width: 56ch;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-muted-foreground);
}

.ew-fb-source {
  margin-top: 0.9rem;
  font-size: 0.74rem;
  color: var(--color-muted-foreground);
}

.ew-fb-up { width: 0.95em; height: 0.95em; color: var(--color-primary); flex: none; }

/* ---------- odometer ---------- */

.ew-fb-odo { display: inline-block; }

.ew-fb-odo-face {
  display: inline-flex;
  align-items: flex-start;
  font-variant-numeric: tabular-nums;
}

.ew-fb-odo-digit {
  display: inline-block;
  height: 1em;
  overflow: hidden;
}

.ew-fb-odo-reel {
  display: flex;
  flex-direction: column;
  transform: translateY(calc(var(--pos, 0) * -1em));
  will-change: transform;
}

.ew-fb-odo-reel > span,
.ew-fb-odo-char {
  display: block;
  height: 1em;
  line-height: 1;
}

/* ===========================================================
   1. Overview
   =========================================================== */

.ew-fb-ov-patch { top: 16%; left: 3%; width: 26vw; height: 22vh; }

#todo-fb-overview .ew-fb-ghost { top: auto; bottom: 6%; font-size: clamp(5rem, 15vw, 14rem); }

.ew-fb-ov-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas:
    "hook  chart"
    "after chart";
  grid-template-rows: auto 1fr;
  gap: clamp(1.5rem, 4vh, 2.5rem) clamp(2rem, 5vw, 5rem);
  align-items: start;
}

.ew-fb-ov-hook { grid-area: hook; max-width: 18ch; }
.ew-fb-ov-chart { grid-area: chart; min-width: 0; }
.ew-fb-ov-after { grid-area: after; align-self: end; }

.ew-fb-stage {
  --track-h: clamp(220px, 42vh, 400px);
  --label-h: 3.3rem;
  position: relative;
  padding-top: 5.5rem;
}

/* The ceiling the third column breaks through. */
.ew-fb-chart-top {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--label-h) + var(--track-h) * var(--break-frac));
  border-top: 2px dashed color-mix(in srgb, var(--color-secondary) 35%, transparent);
  transform-origin: left center;
  pointer-events: none;
}

.ew-fb-cols {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.6rem, 2vw, 1.6rem);
}

.ew-fb-col-track {
  position: relative;
  height: var(--track-h);
  display: flex;
  align-items: flex-end;
}

.ew-fb-bar {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--color-secondary);
  box-shadow: var(--shadow-sm);
  transition: filter var(--duration-normal), box-shadow var(--duration-normal);
}

.ew-fb-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--color-white-0) 30%, transparent) 1.4px, transparent 1.6px);
  background-size: 14px 14px;
  pointer-events: none;
}

.ew-fb-col-2 .ew-fb-bar { background: var(--color-primary); }
.ew-fb-col-3 .ew-fb-bar { background: var(--color-accent); }
.ew-fb-col-3 .ew-fb-bar::after {
  background-image: radial-gradient(circle, color-mix(in srgb, var(--color-secondary) 22%, transparent) 1.4px, transparent 1.6px);
}

@media (hover: hover) {
  .ew-fb-col:hover .ew-fb-bar { filter: brightness(1.08) saturate(1.1); box-shadow: var(--shadow-md); }
  .ew-fb-col:hover .ew-fb-col-label { color: var(--color-primary); }
}

.ew-fb-figure {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.55rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.ew-fb-num {
  font-family: var(--font-family-display);
  font-weight: 900;
  font-size: clamp(1.25rem, 3.2vw, 3rem);
  color: var(--heading-fg);
  line-height: 1;
}

.ew-fb-col.is-break .ew-fb-num { font-size: clamp(1.35rem, 4vw, 3.6rem); color: var(--color-primary); }

.ew-fb-sub {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.35rem;
  font-family: var(--font-family-display);
  font-weight: 600;
  font-size: 0.76rem;
  color: var(--color-muted-foreground);
}

/* Classic axis break: a band of page colour between two slanted rules. */
.ew-fb-axis-break {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: calc(var(--break-frac) * 100%);
  height: 12px;
  background: var(--section-bg);
  border-top: 3px solid var(--color-secondary);
  border-bottom: 3px solid var(--color-secondary);
  transform: skewY(-9deg);
  z-index: 2;
  pointer-events: none;
}

.ew-fb-col-label {
  height: 2.6rem;
  margin-top: 0.7rem;
  font-family: var(--font-family-display);
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.25;
  text-align: center;
  color: var(--section-fg);
  transition: color var(--duration-normal);
}

.ew-fb-break-note {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin-top: 1.4rem;
  max-width: 52ch;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--section-fg);
}

.ew-fb-break-glyph {
  flex: none;
  width: 26px;
  height: 10px;
  margin-top: 0.45em;
  background: var(--color-accent);
  border-top: 3px solid var(--color-secondary);
  border-bottom: 3px solid var(--color-secondary);
  transform: skewY(-9deg);
}

.ew-fb-caveat {
  margin-top: 1rem;
  max-width: 56ch;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--section-fg);
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--radius-sm);
}

/* ===========================================================
   2. The brand's own page
   =========================================================== */

#todo-fb-easywean {
  background: var(--color-card);
  justify-content: flex-start;
  gap: clamp(2.5rem, 7vh, 4.5rem);
}

#todo-fb-easywean .section-head { margin-bottom: 0; }

.ew-fb-ew-strip { bottom: 3%; height: 10px; opacity: 0.5; transform: rotate(3deg); }

.ew-fb-ew-hook { max-width: 30ch; }

.ew-fb-word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.08em;
}

.ew-fb-word > span { display: inline-block; }

.ew-fb-big {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  font-family: var(--font-family-display);
  font-weight: 900;
  font-size: clamp(3.4rem, 9vw, 7.5rem);
  line-height: 0.9;
  color: var(--heading-fg);
  font-variant-numeric: tabular-nums;
}

.ew-fb-big-unit {
  font-size: clamp(1rem, 2vw, 1.5rem);
  font-weight: 700;
  color: var(--color-primary);
}

.ew-fb-big-sub {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  color: var(--color-muted-foreground);
}

.ew-fb-line {
  margin-top: 1rem;
  max-width: 34ch;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--section-fg);
}

/* ---------- beat 1: tally ---------- */

.ew-fb-tally-beat {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: end;
}

.ew-fb-tally {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(0.25rem, 1vw, 0.8rem);
  align-items: end;
}

.ew-fb-month {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-radius: 6px;
  cursor: default;
  outline: none;
}

.ew-fb-month:focus-visible { box-shadow: 0 0 0 2px var(--color-card), 0 0 0 4px var(--color-accent); }

.ew-fb-month-dots {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: clamp(3px, 0.45vw, 6px);
  padding-bottom: 0.55rem;
  border-bottom: 3px solid var(--color-accent);
}

.ew-fb-dot {
  display: block;
  width: clamp(8px, 1.4vw, 18px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--color-secondary);
  transition: background-color var(--duration-fast);
}

.ew-fb-month:hover .ew-fb-dot,
.ew-fb-month:focus .ew-fb-dot { background: var(--color-primary); }

.ew-fb-month-name {
  margin-top: 0.45rem;
  text-align: center;
  font-family: var(--font-family-display);
  font-weight: 600;
  font-size: clamp(0.62rem, 1.1vw, 0.8rem);
  color: var(--section-fg);
}

.ew-fb-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.4rem);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  background: var(--color-secondary);
  color: var(--color-white-0);
  font-size: 0.74rem;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity var(--duration-fast), transform var(--duration-fast);
  pointer-events: none;
  z-index: 3;
}

.ew-fb-tip strong { font-family: var(--font-family-display); font-weight: 700; }
.ew-fb-tip span { color: color-mix(in srgb, var(--color-white-0) 75%, transparent); }

/* Edge months open their tip inward so it never leaves the page. */
.ew-fb-month:nth-child(-n+2) .ew-fb-tip { left: 0; transform: translate(0, 6px); }
.ew-fb-month:nth-last-child(-n+2) .ew-fb-tip { left: auto; right: 0; transform: translate(0, 6px); }

.ew-fb-month:hover .ew-fb-tip,
.ew-fb-month:focus .ew-fb-tip { opacity: 1; transform: translate(-50%, 0); }
.ew-fb-month:nth-child(-n+2):hover .ew-fb-tip,
.ew-fb-month:nth-child(-n+2):focus .ew-fb-tip,
.ew-fb-month:nth-last-child(-n+2):hover .ew-fb-tip,
.ew-fb-month:nth-last-child(-n+2):focus .ew-fb-tip { transform: translate(0, 0); }

.ew-fb-count { display: inline-block; min-width: 3ch; }

/* ---------- beat 2: drain ---------- */

.ew-fb-drain-ask {
  margin-top: 0;
  max-width: 30ch;
  font-family: var(--font-family-display);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.2vw, 1.6rem);
  line-height: 1.25;
  color: var(--heading-fg);
}

.ew-fb-units {
  display: grid;
  grid-template-columns: repeat(55, minmax(0, 1fr));
  gap: 4px;
  max-width: 1100px;
  margin-top: 1.4rem;
}

.ew-fb-unit {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: 3px;
  border: 1.5px solid color-mix(in srgb, var(--color-secondary) 30%, transparent);
}

.ew-fb-unit b {
  position: absolute;
  inset: 1px;
  display: block;
  border-radius: 2px;
  background: var(--color-secondary);
  transform: scale(0);
}

.ew-fb-unit.is-on { border-color: var(--color-primary); }
.ew-fb-unit.is-on b { background: var(--color-primary); transform: scale(1); }

.ew-fb-drain-big { margin-top: 1.4rem; }
.ew-fb-drain-num { display: inline-block; min-width: 1.2ch; color: var(--color-primary); }
.ew-fb-drain-big .ew-fb-big-unit { color: var(--heading-fg); }

/* ---------- beat 3: the engagement there is ---------- */

.ew-fb-eng-beat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2.2fr);
  gap: clamp(0.8rem, 2vw, 1.4rem);
  align-items: stretch;
}

.ew-fb-eng-stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: clamp(1rem, 2.4vw, 1.6rem);
  background: var(--color-background);
  border: var(--card-border);
  border-radius: var(--radius-md);
  transition: transform var(--duration-normal), box-shadow var(--duration-normal), border-color var(--duration-normal);
}

@media (hover: hover) {
  .ew-fb-eng-stat:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
}

.ew-fb-eng-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white-0);
}

.ew-fb-eng-icon svg { width: 1.05rem; height: 1.05rem; }

.ew-fb-eng-num {
  margin-top: auto;
  font-family: var(--font-family-display);
  font-weight: 900;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1;
  color: var(--heading-fg);
  font-variant-numeric: tabular-nums;
}

.ew-fb-eng-label { font-size: 0.85rem; color: var(--color-muted-foreground); }

.ew-fb-top {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: clamp(1.1rem, 2.6vw, 1.8rem);
  background: var(--color-secondary);
  color: var(--color-white-0);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: transform var(--duration-normal), box-shadow var(--duration-normal);
}

@media (hover: hover) {
  .ew-fb-top:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
}

.ew-fb-top-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-family: var(--font-family-display);
  font-weight: 600;
  font-size: 0.85rem;
}

.ew-fb-top-tag {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-foreground);
  font-weight: 800;
  font-size: 0.74rem;
}

.ew-fb-top-quote {
  margin: 0;
  font-style: italic;
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  line-height: 1.5;
}

.ew-fb-top-pills { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.ew-fb-top .metric-pill {
  background: color-mix(in srgb, var(--color-white-0) 10%, transparent);
  border-color: color-mix(in srgb, var(--color-white-0) 25%, transparent);
  color: var(--color-white-0);
}

.ew-fb-top .metric-pill svg { color: var(--color-accent); }

.ew-fb-top-line {
  font-family: var(--font-family-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-accent);
}

/* ---------- beat 4: split-flap board ---------- */

.ew-fb-vs {
  display: grid;
  gap: 0.35rem;
  padding: clamp(0.8rem, 2.6vw, 1.8rem);
  background: var(--color-navy-900);
  color: var(--color-white-0);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.ew-fb-vs-row {
  display: grid;
  grid-template-columns: minmax(4.6rem, 1fr) minmax(0, 2fr) minmax(0, 2fr);
  gap: clamp(0.6rem, 2vw, 1.6rem);
  align-items: center;
  padding: 0.55rem clamp(0.4rem, 1.2vw, 0.9rem);
  border-radius: var(--radius-sm);
  transition: background-color var(--duration-normal);
}

.ew-fb-vs-row:not(.ew-fb-vs-head):hover { background: color-mix(in srgb, var(--color-white-0) 7%, transparent); }
.ew-fb-vs-row:not(.ew-fb-vs-head):hover .ew-fb-vs-bar { filter: brightness(1.15); }

.ew-fb-vs-head { padding-bottom: 0.2rem; }

.ew-fb-vs-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-family-display);
  font-weight: 700;
  font-size: clamp(0.72rem, 1.3vw, 0.9rem);
  line-height: 1.2;
}

.ew-fb-vs-name i { flex: none; width: 10px; height: 10px; border-radius: 2px; }
.ew-fb-vs-name.ew-fb-vs-a i { background: var(--color-primary); }
.ew-fb-vs-name.ew-fb-vs-b i { background: var(--color-accent); }

.ew-fb-vs-label {
  font-family: var(--font-family-display);
  font-weight: 600;
  font-size: clamp(0.8rem, 1.4vw, 1rem);
  color: color-mix(in srgb, var(--color-white-0) 80%, transparent);
}

.ew-fb-vs-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; min-width: 0; }

.ew-fb-flap { display: inline-block; perspective: 500px; }

.ew-fb-flap > span {
  position: relative;
  display: inline-block;
  min-width: 2.4ch;
  padding: 0.2em 0.35em;
  border-radius: 6px;
  background: var(--color-navy-950);
  font-family: var(--font-family-display);
  font-weight: 900;
  font-size: clamp(1.35rem, 3.4vw, 2.6rem);
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transform-origin: 50% 0;
}

/* The split-flap seam. */
.ew-fb-flap > span::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: color-mix(in srgb, var(--color-white-0) 16%, transparent);
}

.ew-fb-vs-track {
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-white-0) 10%, transparent);
  overflow: hidden;
}

.ew-fb-vs-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  transform-origin: left center;
  transition: filter var(--duration-normal);
}

.ew-fb-vs-a .ew-fb-vs-bar { background: var(--color-primary); }
.ew-fb-vs-b .ew-fb-vs-bar { background: var(--color-accent); }

/* ---------- close ---------- */

.ew-fb-ew-after .ew-fb-takeaway { max-width: 30ch; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .ew-fb-ov-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "hook" "chart" "after";
    grid-template-rows: auto;
  }
  .ew-fb-ov-hook { max-width: 22ch; }
  .ew-fb-stage { --track-h: clamp(200px, 36vh, 300px); padding-top: 4.6rem; }
  .ew-fb-col-label { font-size: 0.74rem; }
  .ew-fb-tally-beat { grid-template-columns: minmax(0, 1fr); }
  .ew-fb-units { grid-template-columns: repeat(22, minmax(0, 1fr)); gap: 3px; }
  .ew-fb-eng-beat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ew-fb-top { grid-column: 1 / -1; }
  .ew-fb-ghost { top: 4%; }
}

@media (max-width: 480px) {
  .ew-fb-vs-row { grid-template-columns: minmax(4rem, 0.8fr) minmax(0, 1fr) minmax(0, 1fr); }
  .ew-fb-tip { font-size: 0.68rem; padding: 0.35rem 0.5rem; }
}
