/* Phase 7 — shared mobile entity page structure (not identical layouts).
   hero → identity → CTAs → info → entity-specific content → updates */

:root {
  --mv-entity-gutter: var(--mv-shell-gutter, 1rem);
  --mv-entity-radius: var(--mv-shell-radius-card, 0.875rem);
  --mv-entity-gap: var(--mv-shell-section-gap, 1rem);
}

@media (max-width: 1279px) {
  body.mv-mobile-shell-on .mv-entity-page,
  body.mv-mobile-shell-on .mv-listing-detail.mv-entity-page {
    background: var(--mv-shell-bg, #fff);
  }

  body.mv-mobile-shell-on .mv-entity-page__section {
    padding-left: var(--mv-entity-gutter);
    padding-right: var(--mv-entity-gutter);
    margin-bottom: var(--mv-entity-gap);
  }

  body.mv-mobile-shell-on .mv-entity-page__identity {
    padding: 0.85rem var(--mv-entity-gutter) 0.5rem;
  }

  body.mv-mobile-shell-on .mv-entity-page__name {
    font-size: 1.35rem;
    font-weight: 750;
    line-height: 1.2;
    color: var(--mv-shell-fg, #1f2a24);
    letter-spacing: -0.02em;
  }

  body.mv-mobile-shell-on .mv-entity-page__meta {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--mv-shell-muted, #5b6b62);
  }

  body.mv-mobile-shell-on .mv-entity-page__ctas {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.35rem var(--mv-entity-gutter) 0.85rem;
  }

  body.mv-mobile-shell-on .mv-entity-page__ctas a,
  body.mv-mobile-shell-on .mv-entity-page__ctas button {
    min-height: 2.75rem;
    border-radius: 9999px;
    font-weight: 650;
  }

  /* Listing already uses sticky CTA bar — keep entity CTAs clear of bottom nav */
  body.mv-mobile-shell-on .mv-listing-detail__cta {
    bottom: calc(var(--mv-shell-bottom-h, 4.25rem) + env(safe-area-inset-bottom, 0px));
  }

  /*
   * Shared listing primary/secondary actions — high contrast in light + dark.
   * Avoid Tailwind green-600/text-white pairs that collapse under dark theme remaps.
   */
  .mv-listing-detail__cta-primary {
    background: #166534;
    color: #ffffff;
    border: 1px solid #14532d;
  }
  .mv-listing-detail__cta-primary:hover {
    filter: brightness(1.05);
  }
  .mv-listing-detail__cta-primary:focus-visible {
    outline: 2px solid #166534;
    outline-offset: 2px;
  }
  .mv-listing-detail__cta-secondary {
    background: var(--color-base-100, #ffffff);
    color: var(--color-base-content, #1f2a24);
    border: 1px solid var(--color-base-300, rgba(31, 42, 36, 0.18));
  }
  .mv-listing-detail__cta-secondary:hover {
    background: var(--color-base-200, #f3f4f3);
  }
  .mv-listing-detail__cta-secondary:focus-visible {
    outline: 2px solid #166534;
    outline-offset: 2px;
  }
  [data-theme="myvillage-dark"] .mv-listing-detail__cta-primary,
  html[data-mv-resolved="dark"] .mv-listing-detail__cta-primary {
    background: #4ade80;
    color: #052e16;
    border-color: #22c55e;
  }
  [data-theme="myvillage-dark"] .mv-listing-detail__cta-secondary,
  html[data-mv-resolved="dark"] .mv-listing-detail__cta-secondary {
    background: color-mix(in oklab, var(--color-base-200, #1a1f1c) 92%, white);
    color: var(--color-base-content, #f4eee2);
    border-color: color-mix(in oklab, var(--color-base-content, #f4eee2) 28%, transparent);
  }

  /* Club: entity identity card — never legacy purple/green full-bleed hero */
  body.mv-mobile-shell-on .mv-entity-page--club {
    background: var(--mv-shell-bg-soft, #f7f9f7);
    min-height: 100%;
  }

  body.mv-mobile-shell-on .mv-entity-page--club .mv-club-hero,
  body.mv-mobile-shell-on .mv-entity-page--club .hero.bg-gradient-to-br {
    display: none !important;
  }

  body.mv-mobile-shell-on .mv-club-identity {
    background: var(--mv-shell-bg, #fff);
    border-bottom: 1px solid var(--mv-shell-border);
    padding: 0.85rem var(--mv-entity-gutter) 1rem;
  }

  body.mv-mobile-shell-on .mv-club-identity__back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--mv-shell-muted);
    margin-bottom: 0.75rem;
  }

  body.mv-mobile-shell-on .mv-club-identity__row {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
  }

  body.mv-mobile-shell-on .mv-club-identity__crest {
    width: 4.25rem;
    height: 4.25rem;
    border-radius: var(--mv-entity-radius);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--mv-shell-bg-soft);
    border: 1px solid var(--mv-shell-border);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body.mv-mobile-shell-on .mv-club-identity__crest-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  body.mv-mobile-shell-on .mv-club-identity__crest-mark {
    display: block;
  }

  body.mv-mobile-shell-on .mv-club-identity__name,
  body.mv-mobile-shell-on .mv-entity-page--club .mv-entity-page__name {
    font-family: ui-serif, Georgia, "Times New Roman", serif;
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--mv-shell-fg);
    margin: 0.15rem 0 0.35rem;
  }

  body.mv-mobile-shell-on .mv-club-identity__summary {
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--mv-shell-muted);
    margin: 0;
  }

  body.mv-mobile-shell-on .mv-club-identity__ctas {
    padding-left: 0;
    padding-right: 0;
    margin-top: 0.75rem;
  }

  body.mv-mobile-shell-on .mv-club-identity__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0.45rem 0.9rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 650;
    border: 1px solid var(--mv-shell-border);
    background: var(--mv-shell-bg);
    color: var(--mv-shell-fg);
  }

  body.mv-mobile-shell-on .mv-club-identity__btn--primary {
    background: var(--mv-shell-green);
    border-color: var(--mv-shell-green);
    color: #fff;
  }

  body.mv-mobile-shell-on .mv-club-identity__btn--owner {
    font-size: 0.75rem;
    min-height: 2.15rem;
    opacity: 0.85;
    color: var(--mv-shell-muted);
  }

  body.mv-mobile-shell-on .mv-club-sponsors {
    padding-top: 0.85rem;
    padding-bottom: 0.35rem;
    background: var(--mv-shell-bg);
    border-bottom: 1px solid var(--mv-shell-border);
  }

  body.mv-mobile-shell-on .mv-club-panel__title {
    font-family: ui-serif, Georgia, "Times New Roman", serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--mv-shell-fg);
    margin: 0 0 0.35rem;
  }

  body.mv-mobile-shell-on .mv-club-sponsors-section__lead {
    font-size: 0.85rem;
    color: var(--mv-shell-muted);
    margin: 0 0 0.85rem;
  }

  body.mv-mobile-shell-on .mv-sponsor-carousel {
    margin: 0 calc(-1 * var(--mv-entity-gutter));
    padding: 0 var(--mv-entity-gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.mv-mobile-shell-on .mv-sponsor-carousel::-webkit-scrollbar {
    display: none;
  }

  body.mv-mobile-shell-on .mv-sponsor-carousel__track {
    display: flex;
    gap: 0.75rem;
    padding-bottom: 0.35rem;
  }

  body.mv-mobile-shell-on .mv-sponsor-carousel__item {
    flex: 0 0 78%;
    max-width: 17.5rem;
    scroll-snap-align: start;
  }

  body.mv-mobile-shell-on .mv-sponsor-card {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 8.5rem;
    height: 100%;
    padding: 0.95rem;
    border-radius: var(--mv-entity-radius);
    border: 1px solid var(--mv-shell-border);
    background: var(--mv-shell-bg);
    box-shadow: var(--mv-shell-shadow);
    color: inherit;
    text-decoration: none;
  }

  body.mv-mobile-shell-on .mv-sponsor-card__logo,
  body.mv-mobile-shell-on .mv-sponsor-card__monogram {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.65rem;
    object-fit: contain;
    background: var(--mv-shell-bg-soft);
    border: 1px solid var(--mv-shell-border);
  }

  body.mv-mobile-shell-on .mv-sponsor-card__monogram {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 750;
    color: var(--mv-shell-green);
  }

  body.mv-mobile-shell-on .mv-sponsor-card__name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--mv-shell-fg);
    margin: 0;
    line-height: 1.25;
  }

  body.mv-mobile-shell-on .mv-sponsor-card__team,
  body.mv-mobile-shell-on .mv-sponsor-card__kicker {
    font-size: 0.75rem;
    font-weight: 650;
    color: var(--mv-shell-green);
    margin: 0.2rem 0 0;
  }

  body.mv-mobile-shell-on .mv-sponsor-card__note {
    font-size: 0.78rem;
    color: var(--mv-shell-muted);
    margin: 0.35rem 0 0;
    line-height: 1.35;
  }

  body.mv-mobile-shell-on .mv-sponsor-card__cta {
    margin-top: auto;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--mv-shell-green);
  }

  body.mv-mobile-shell-on .mv-sponsor-card--opportunity {
    background: linear-gradient(180deg, #fff 0%, #f3f8f4 100%);
  }

  body.mv-mobile-shell-on .mv-club-sponsors-section__cta {
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--mv-shell-border);
  }

  body.mv-mobile-shell-on .mv-club-section-tabs {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding-top: 0.65rem;
    padding-bottom: 0.35rem;
    scrollbar-width: none;
    background: var(--mv-shell-bg-soft);
  }

  body.mv-mobile-shell-on .mv-club-section-tab {
    flex-shrink: 0;
    padding: 0.45rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 650;
    color: var(--mv-shell-muted);
    background: var(--mv-shell-bg);
    border: 1px solid var(--mv-shell-border);
  }

  body.mv-mobile-shell-on .mv-club-section-tab.is-active {
    color: #fff;
    background: var(--mv-shell-green);
    border-color: var(--mv-shell-green);
  }

  body.mv-mobile-shell-on .mv-club-body {
    background: var(--mv-shell-bg-soft);
    min-height: 40vh;
  }

  body.mv-mobile-shell-on .mv-club-body__inner {
    padding: 0.85rem var(--mv-entity-gutter) 1.5rem;
  }

  body.mv-mobile-shell-on .mv-club-panel {
    background: transparent;
  }

  body.mv-mobile-shell-on .mv-club-highlight,
  body.mv-mobile-shell-on .mv-club-feed-card {
    background: var(--mv-shell-bg);
    border: 1px solid var(--mv-shell-border);
    border-radius: var(--mv-entity-radius);
    box-shadow: var(--mv-shell-shadow);
  }

  body.mv-mobile-shell-on .mv-club-highlight {
    padding: 0.95rem;
  }

  body.mv-mobile-shell-on .mv-club-highlight__heading,
  body.mv-mobile-shell-on .mv-club-feed-card__title {
    font-family: ui-serif, Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--mv-shell-fg);
    margin: 0.15rem 0;
  }

  body.mv-mobile-shell-on .mv-club-highlight__meta,
  body.mv-mobile-shell-on .mv-club-highlight__sub {
    font-size: 0.82rem;
    color: var(--mv-shell-muted);
    margin: 0;
  }

  body.mv-mobile-shell-on .mv-club-highlight__score {
    font-size: 1.45rem;
    font-weight: 750;
    color: var(--mv-shell-green);
    margin: 0 0 0.25rem;
  }

  body.mv-mobile-shell-on .mv-club-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 650;
    border: 1px solid var(--mv-shell-border);
    background: var(--mv-shell-bg);
    color: var(--mv-shell-muted);
  }

  body.mv-mobile-shell-on .mv-club-chip.is-active {
    background: var(--mv-shell-green);
    border-color: var(--mv-shell-green);
    color: #fff;
  }

  body.mv-mobile-shell-on .mv-club-feed-card__avatar,
  body.mv-mobile-shell-on .mv-club-feed-card__avatar-img {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    flex-shrink: 0;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mv-shell-green-pale);
    color: var(--mv-shell-green);
    font-weight: 700;
    font-size: 0.85rem;
  }

  body.mv-mobile-shell-on .mv-club-feed-card__badge {
    font-size: 0.68rem;
    font-weight: 650;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    border: 1px solid var(--mv-shell-border);
    color: var(--mv-shell-muted);
  }

  body.mv-mobile-shell-on .mv-club-empty-compact {
    font-size: 0.85rem;
    color: var(--mv-shell-muted);
    padding: 0.35rem 0 0.75rem;
  }

  /* Hobby/legacy club templates under shell: suppress purple heroes */
  body.mv-mobile-shell-on .hero.from-indigo-600,
  body.mv-mobile-shell-on .hero.bg-gradient-to-br.from-indigo-600 {
    background: var(--mv-shell-bg) !important;
    background-image: none !important;
    color: var(--mv-shell-fg) !important;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  body.mv-mobile-shell-on .hero.from-indigo-600 h1,
  body.mv-mobile-shell-on .hero.bg-gradient-to-br.from-indigo-600 h1 {
    color: var(--mv-shell-fg) !important;
    font-family: ui-serif, Georgia, "Times New Roman", serif;
  }

  body.mv-mobile-shell-on .page-surface-wrapper:has([data-testid="formal-sponsors-section"]) {
    background: var(--mv-shell-bg-soft);
  }

  body.mv-mobile-shell-on .page-surface:has([data-testid="formal-sponsors-section"]) {
    background: transparent;
    box-shadow: none;
    border: 0;
    padding-left: 0;
    padding-right: 0;
  }

  /* School front: keep school branding; align gutters with shell */
  body.mv-mobile-shell-on .mv-entity-page--school.school-front-page,
  body.mv-mobile-shell-on .school-front-page.mv-entity-page--school {
    padding-bottom: 0.5rem;
  }

  /* Messages — conversation-first list under shell */
  body.mv-mobile-shell-on .mv-messages-page {
    padding-top: 0.75rem;
    padding-bottom: 1rem;
  }

  body.mv-mobile-shell-on .mv-messages-page__title {
    font-size: 1.35rem;
    color: var(--mv-shell-fg, #1f2a24);
    letter-spacing: -0.02em;
  }

  body.mv-mobile-shell-on .mv-messages-page__row.card {
    border-radius: var(--mv-shell-radius-card, 0.875rem);
    box-shadow: none;
    border-color: var(--mv-shell-border, rgba(31, 42, 36, 0.12));
  }

  body.mv-mobile-shell-on .mv-messages-page__list {
    gap: 0.35rem;
  }
}
