/* ========================================
   MEMBER HOME on / (html.ah-member, set by js/member-gate.js before
   paint). v2: the approved activity-first sketch
   (.impeccable/mocks/member-home-v2/). Hides the marketing sections,
   keeps the ASCII hero as a band carrying the member's next event, then
   one column: the week's activity grouped by day, "Further out", and a
   bezel. No boxes: structure is hairline rules and space. Radii stay at
   5px (controls) or 6px (logo tile). Mono only measures (figures, dates,
   times, group labels). Teal only for action and "you".
   Filled by js/member-home.js; the skeleton holds the layout until then.
   Tokens come from style.css.
   ======================================== */

/* ---------- Gate ---------- */
html:not(.ah-member) .mh-only { display: none; }

/* .mk-only marks marketing pieces outside main's sections (skip link, hero text) */
html.ah-member .mk-only,
html.ah-member main > :not(#hero):not(.mh-only) {
  display: none;
}

/* ---------- Page ---------- */
html.ah-member main {
  padding-bottom: 2rem;
}

.mh-stream,
.mh-agenda,
.mh-bezel {
  padding-left: var(--frame-pad);
  padding-right: var(--frame-pad);
}

/* ---------- Hero band ---------- */
html.ah-member .hero {
  height: auto;
  min-height: 0;
  padding: 0;
  align-items: stretch;
  overflow: hidden; /* the canvas is viewport-sized; clip it to the band */
  border-bottom: 1px solid var(--line);
}

/* The snake (html.ah-snake) plays on the full viewport-tall canvas */
html.ah-member.ah-snake .hero {
  height: 100vh;
  height: 100dvh;
  overflow: visible;
}

html.ah-member .hero__content {
  max-width: none;
  padding: clamp(2.5rem, 6vh, 3.75rem) var(--frame-pad) 3rem;
}

html.ah-member .hero__content::before {
  left: 0;
  right: 30%;
  top: 0;
  bottom: 0;
}

.mh-hero {
  max-width: 48rem;
  min-height: 21.5rem; /* the common case, so the stream doesn't move when it fills */
}

.mh-hero__title {
  font-family: "Darker Grotesque", var(--font-display);
  font-weight: 800;
  font-size: clamp(3.25rem, 7vw, 6.5rem);
  line-height: 0.9;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--ink);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  padding-bottom: 0.06em;
}

.mh-hero__title a {
  color: inherit;
  text-decoration: none;
}

.mh-hero__title a:hover { color: var(--teal); }

.mh-hero__meta {
  margin-top: 1.1rem;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink-dim);
}

.mh-you {
  color: var(--teal);
  font-weight: 600;
}

.mh-live {
  color: var(--teal);
  font-weight: 600;
}

.mh-hero__line {
  margin-top: 0.6rem;
  max-width: 62ch;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink-dim);
  text-wrap: pretty;
}

.mh-hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.75rem;
  margin-top: 1.75rem;
}

.mh-hero__hint {
  margin-top: 0.75rem;
  font-size: 0.9375rem;
  color: var(--ink-dim);
}

.mh-hero__standing {
  margin-top: 1.4rem;
  font-size: 0.875rem;
  color: var(--ink-faint);
}

.mh-hero__standing .mh-fig { color: var(--ink-dim); }

/* The one filled button on the page */
.mh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.4rem;
  border: 0;
  border-radius: 5px;
  background: var(--teal);
  color: var(--bg-0);
  font: 600 0.9375rem var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: filter 140ms ease;
}

.mh-btn:hover { filter: brightness(0.92); }
.mh-btn:disabled { opacity: 0.6; cursor: default; }

.mh-link,
.mh-more {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  color: var(--ink);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--control-line);
  text-underline-offset: 4px;
  transition: text-decoration-color 140ms ease;
}

.mh-link:hover,
.mh-more:hover { text-decoration-color: var(--ink); }

/* Names inside sentences */
.mh-who {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--control-line);
  text-underline-offset: 3px;
}

a.mh-who:hover { text-decoration-color: var(--ink); }
span.mh-who { text-decoration: none; }
.mh-who--you { color: var(--teal); }

.mh-check {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--control-line);
  text-underline-offset: 3px;
}

/* Figures: the mono "measure" voice */
.mh-fig {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.9em;
  color: var(--ink);
}

.mh-sep { color: var(--ink-faint); }

/* Squad seats */
.mh-squad {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  align-items: end;
  gap: 0.6rem 1.25rem;
  margin-top: 1.25rem;
}

.mh-squad__name {
  grid-column: 1 / -1;
  font-size: 0.9375rem;
  color: var(--ink-dim);
}

.mh-squad__name b { color: var(--ink); font-weight: 600; }

.mh-seats {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mh-seat {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 4rem;
  padding: 0.5rem 0 0.4rem;
  background: var(--bg-2);
  font-size: 0.75rem;
  color: var(--ink-dim);
  overflow: hidden;
  white-space: nowrap;
}

.mh-seat > span:last-child {
  max-width: 3.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mh-seat--you {
  color: var(--teal);
  box-shadow: inset 0 -2px 0 var(--teal);
}

.mh-seat--open {
  background: #1E2020; /* unlit cell */
  outline: 1px dashed var(--control-line);
  outline-offset: -1px;
  color: var(--ink-faint);
}

.mh-seat__cell {
  width: 26px;
  height: 26px;
  background: var(--bg-0);
}

.mh-squad__note {
  font-size: 0.9375rem;
  color: var(--ink);
}

/* Avatars */
.mh-avatar {
  display: inline-flex;
  flex: none;
}

.mh-avatar svg { width: 100%; height: 100%; display: block; }
.mh-avatar--26 { width: 26px; height: 26px; }
.mh-avatar--28 { width: 28px; height: 28px; }

.mh-bots {
  display: flex;
  gap: 2px;
}

/* Entrance: the title rises out of its line like the marketing headline,
   the rest settles after it. Default state is fully visible. */
@media (prefers-reduced-motion: no-preference) {
  .mh-hero--in .mh-hero__title {
    animation: mh-rise 0.75s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .mh-hero--in > :not(.mh-hero__title) {
    animation: mh-settle 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.18s both;
  }
}

@keyframes mh-rise {
  from { clip-path: inset(0 0 100% 0); transform: translateY(0.35em); }
  to { clip-path: inset(0 0 -0.2em 0); transform: none; }
}

@keyframes mh-settle {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Stream ---------- */
.mh-stream { padding-top: 3rem; }

/* While loading, hold the footer below the fold: a real week of activity
   is taller than the skeleton, and pushing a visible footer away is the
   biggest layout shift the page could make. */
.mh-stream[aria-busy="true"] { min-height: 100vh; }

.mh-stream__h {
  max-width: 36ch;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.4rem, 2.2vw, 1.7rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: balance;
}

.mh-stream__h .mh-fig { font-size: 0.92em; }

.mh-group {
  display: flex;
  justify-content: space-between;
  margin-top: 2.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mh-group .mh-fig { color: var(--ink-dim); font-size: 0.8125rem; }

.mh-rows { list-style: none; }

/* lead | body | figure | action. DOM order = visual order. */
.mh-row {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) 7.5rem 12rem;
  align-items: center;
  gap: 0.35rem 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--bg-2);
}

.mh-row--event { padding: 1.25rem 0; }

.mh-row--people .mh-row__body { grid-column: 2 / 4; }

.mh-row__lead {
  align-self: start;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 2px;
}

.mh-row__lead .mh-row__date { padding-top: 0.35rem; }

.mh-badge {
  flex: none;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.mh-shot {
  flex: none;
  width: 48px;
  height: 28px;
  object-fit: cover;
  background: var(--bg-2);
}

.mh-row__event {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.85rem;
}

.mh-row__event a {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3125rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.mh-row__event a:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }

.mh-row__date {
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}

.mh-row__text {
  margin-top: 0.15rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink-dim);
  text-wrap: pretty;
}

.mh-row--people .mh-row__text { margin-top: 0; }
.mh-row__text b { color: var(--ink); font-weight: 600; }

.mh-row__proof {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: var(--ink-faint);
}

.mh-row__proof .mh-fig { color: var(--ink); font-size: 0.8125rem; }

.mh-row__figs {
  justify-self: end;
  display: grid;
  justify-items: end;
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

.mh-fig--big {
  font-size: 1.5rem;
  line-height: 1.1;
}

.mh-row__time {
  grid-column: 4;
  justify-self: end;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mh-row__mine,
.mh-row__note {
  justify-self: end;
  font-size: 0.875rem;
  font-weight: 600;
}

.mh-row__mine { color: var(--teal); }
.mh-row__note { color: var(--ink-dim); font-weight: 500; }

/* Unlit / new cells (DESIGN.md: unlit-cell empty states) */
.mh-cell {
  display: inline-block;
  width: 28px;
  height: 28px;
  background: #1E2020;
  outline: 1px dashed var(--control-line);
  outline-offset: -1px;
}

.mh-cell--new {
  background: #23534D;
  outline: 0;
}

.mh-unlit {
  list-style: none;
  display: flex;
  gap: 6px;
  margin-top: 2rem;
}

.mh-unlit__day {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.mh-unlit__day .mh-cell { width: 36px; height: 36px; }

.mh-unlit__tick {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mh-empty {
  margin-top: 0.75rem;
  font-size: 1rem;
  color: var(--ink-dim);
}

/* ---------- The one action per event: a row toggle ---------- */
.mh-act {
  justify-self: end;
  display: grid;
  justify-items: end;
  gap: 0.25rem;
}

.mh-tog {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  min-width: 11rem;
  padding: 0 1rem 0 0.9rem;
  border: 1px solid var(--control-line);
  border-radius: 5px;
  background: var(--bg-1);
  color: var(--ink);
  font: 600 0.875rem var(--font-body);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.mh-tog:hover:not(:disabled) { background: var(--bg-2); border-color: var(--line-hover); }
.mh-tog:disabled { cursor: progress; opacity: 0.75; }

.mh-tog__box {
  flex: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--teal);
  border-radius: 2px;
  background-repeat: no-repeat;
  background-position: center;
}

.mh-tog.is-on { border-color: var(--teal-line); }

.mh-tog.is-on .mh-tog__box {
  background-color: var(--teal);
  /* tick drawn in the box: an SVG data URI is allowed by the page CSP (img-src data:) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3.5 8.5 3 3 6-6.5' fill='none' stroke='%23131414' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.mh-tog.is-wait .mh-tog__box {
  background-color: transparent;
  background-image: none;
  border-style: dashed;
}

/* The hero's top-pick toggle takes the filled primary look */
.mh-tog--primary {
  min-width: 0;
  padding: 0 1.4rem 0 1.1rem;
  border-color: var(--teal);
  background: var(--teal);
  color: var(--bg-0);
  font-size: 0.9375rem;
}

.mh-tog--primary .mh-tog__box { border-color: var(--bg-0); }
.mh-tog--primary:hover:not(:disabled) { background: var(--teal); border-color: var(--teal); filter: brightness(0.92); }

.mh-tog--primary.is-on {
  background: transparent;
  color: var(--ink);
  border-color: var(--teal-line);
}

.mh-tog--primary.is-on .mh-tog__box { border-color: var(--teal); }

.mh-hero .mh-act { justify-self: start; justify-items: start; }

.mh-act__msg { font-size: 0.8125rem; }
.mh-act__msg--error { color: var(--danger); }

/* ---------- Further out ---------- */
.mh-agenda { padding-top: 3.5rem; }

.mh-agenda__h {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3125rem;
  color: var(--ink);
}

.mh-row--agenda .mh-row__date {
  align-self: start;
  padding-top: 0.4rem;
}

/* ---------- Bezel ---------- */
.mh-bezel { padding-top: 0.5rem; }

.mh-bezel__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 2.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--ink);
}

.mh-bezel__brand img { border-radius: 6px; }

.mh-bezel__note {
  max-width: 90ch;
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* ---------- Skeleton ---------- */
.mh-skel,
.mh-row--skel,
.mh-group--skel { background-color: var(--bg-1); }

@media (prefers-reduced-motion: no-preference) {
  .mh-skel,
  .mh-row--skel,
  .mh-group--skel { animation: mh-loading 1.6s ease-in-out infinite alternate; }
}

/* Opacity only, so the loading pulse stays off the main thread */
@keyframes mh-loading {
  from { opacity: 1; }
  to { opacity: 0.55; }
}

.mh-skel { border-radius: 5px; }
.mh-skel--title { width: min(30rem, 80%); height: clamp(3rem, 6.3vw, 5.9rem); }
.mh-skel--meta { width: min(28rem, 85%); height: 1.6rem; margin-top: 1.1rem; }
.mh-skel--line { width: min(22rem, 70%); height: 1.6rem; margin-top: 0.6rem; }
.mh-skel--actions { width: min(19rem, 75%); height: 48px; margin-top: 1.75rem; }
.mh-group--skel { height: 1.75rem; margin-top: 2.25rem; max-width: 12rem; }
.mh-row--skel { display: block; height: 5.5rem; margin-top: 0.5rem; border: 0; }

/* ---------- Narrow screens ---------- */
/* Below 1024px the four-column board leaves too little room for the
   sentence, so rows stack in DOM order: lead, body, then figure + action
   on one line under the text. */
@media (max-width: 1023px) {
  .mh-row,
  .mh-row--agenda {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem 1rem;
  }
  .mh-row__lead,
  .mh-row__body,
  .mh-row--agenda .mh-row__date { grid-column: 1 / -1; }
  .mh-row__figs {
    justify-self: start;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
  }
  .mh-fig--big { font-size: 1.125rem; }
  .mh-tog { min-width: 0; }

  .mh-row--people { grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 0.25rem 0.75rem; }
  .mh-row--people .mh-row__lead,
  .mh-row--people .mh-row__body { grid-column: auto; }
  .mh-row--people .mh-row__time { grid-column: auto; padding-top: 0.2rem; }
}

/* Phones: after the 1023px rules so these win */
@media (max-width: 760px) {
  html.ah-member .hero__content { padding-top: 2rem; padding-bottom: 2.25rem; }
  .mh-hero { min-height: 21rem; }
  .mh-hero__title { font-size: clamp(2.75rem, 13vw, 3.75rem); }
  .mh-hero__meta,
  .mh-hero__line { font-size: 1rem; }
  .mh-hero__actions { flex-direction: column; align-items: stretch; gap: 0.25rem; }
  .mh-hero .mh-act,
  .mh-hero .mh-tog { width: 100%; justify-self: stretch; justify-content: center; }
  .mh-squad { grid-template-columns: auto; }
  .mh-stream { padding-top: 2.25rem; }
  .mh-row__event a { font-size: 1.1875rem; }
  /* People rows stack like event rows (gutter, text, time), so every
     row's text starts at the same left edge whatever leads it. */
  .mh-row--people { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .mh-row--people .mh-row__lead,
  .mh-row--people .mh-row__body,
  .mh-row--people .mh-row__time { grid-column: 1; justify-self: start; padding-top: 0; }
  .mh-unlit { gap: 4px; }
  .mh-unlit__day .mh-cell { width: 32px; height: 32px; }
}
