/* ============================================================
   AlterMe — Mobile design system
   Layered on top of brand.css + site.css.
   Desktop ≥1180px is preserved as the canonical view.
   Tablet 720px–1180px is a transitional layout.
   Mobile ≤720px is a real, designed mobile experience.

   IMPORTANT: React renders inline styles as kebab-case CSS in the
   DOM. Attribute selectors below match the rendered HTML strings
   (e.g. `grid-template-columns: 1.5fr 1fr`), not the JSX source.
   ============================================================ */


/* ─── Default-state hidden mobile-only elements ─── */
.mobile-cta-bar { display: none; }
.leaning-ribbon { display: none; }


/* ============================================================
   TABLET — ≤1180px
   Two-column layouts stay possible but tighten significantly.
   ============================================================ */
@media (max-width: 1180px) {

  .site-nav { padding: 16px 28px; }
  .site-nav .links { gap: 22px; font-size: 13px; }

  .section { padding: 80px 36px !important; }

  /* Index portal */
  .portal { padding: 44px 36px 64px; }
  .portal-nav { margin-bottom: 56px; }
  .portal-hero { margin-bottom: 56px; }
  .portal-hero h1 { font-size: clamp(48px, 6.4vw, 72px) !important; }
  .options { gap: 18px; }

  /* Direction 2 — sticky lens rail narrows */
  .lens-stage { grid-template-columns: 280px minmax(0, 1fr); gap: 40px; padding: 48px 36px 80px; }
  .lens-pill { padding: 14px; }
  .lens-pill .lp-name { font-size: 15px; }
  .lens-pill .lp-price { font-size: 12px; }

  /* Direction 3 — scrolly tightens */
  .scrolly { gap: 56px; padding: 0 36px; }
  .chap-card { padding: 52px 32px; min-height: 480px; }

  /* Footer 4-col → 2-col */
  .footer-grid { grid-template-columns: 2fr 1fr 1fr !important; gap: 36px; }
  .site-footer { padding: 60px 36px 36px; }

  /* Display headlines */
  .h-display { font-size: clamp(48px, 7vw, 92px) !important; }
  .h-mid { font-size: clamp(34px, 4.4vw, 52px) !important; }

  /* Inline padding shrinks */
  [style*="padding: 14px 80px"] { padding-left: 28px !important; padding-right: 28px !important; }
}


/* ============================================================
   COMPACT TABLET / LARGE PHONE — ≤980px
   Layout fundamentally restructures.
   ============================================================ */
@media (max-width: 980px) {

  /* ── Two-column inline-styled grids → stack */
  [style*="grid-template-columns: 1.5fr 1fr"],
  [style*="grid-template-columns: 1fr 2fr"],
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1fr 1.5fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 36px !important;
  }

  /* ── Three-column inline grids → two columns */
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 14px !important;
  }
  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 14px !important;
  }

  /* ── "Where to start" sticky card un-stickies (D1 hero right column) */
  [style*="position: sticky"] {
    position: static !important;
    top: auto !important;
  }

  /* ── DIRECTION 2: Lens rail moves from sidebar to sticky horizontal at top.
     Rail container stays sticky; we restructure the inside to a row. */
  .lens-stage {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    padding: 0 0 80px !important;
  }
  .lens-rail-sticky {
    position: sticky !important;
    top: 60px !important;
    z-index: 40;
    background: rgba(255, 252, 244, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    padding: 14px 28px;
    margin-bottom: 32px;
  }
  .lens-rail-sticky .eyebrow { display: none; }
  /* The "Tip" box is the LAST direct child div of .lens-rail-sticky */
  .lens-rail-sticky > div:last-of-type { display: none; }
  .lens-rail {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 4px;
    background: rgba(26, 24, 24, 0.05);
    border-radius: 12px;
    flex-direction: row;
  }
  .lens-pill {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: 10px 12px !important;
    gap: 6px !important;
    border-radius: 9px;
    text-align: left;
    background: transparent;
  }
  .lens-pill .lp-dot { width: 8px !important; height: 8px !important; }
  .lens-pill .lp-name { font-size: 13px !important; line-height: 1; }
  .lens-pill .lp-price { font-size: 10px !important; line-height: 1.3; opacity: 0.7; }
  .lens-pill.on { background: var(--ink) !important; color: var(--cream) !important; }
  /* The right-side stage is the second direct child of .lens-stage */
  .lens-stage > div:not(.lens-rail-sticky) { padding: 0 28px; }

  /* ── DIRECTION 3: Scrolly stacks. Character is sticky at TOP. */
  .scrolly {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    padding: 0 28px !important;
  }
  .character-sticky {
    position: sticky !important;
    top: 60px !important;
    z-index: 30;
    background: var(--cream);
    padding: 16px 0 12px;
    margin: -16px 0 24px;
    border-bottom: 1px solid var(--line);
  }
  .character-sticky > div:first-child {
    height: 40vh !important;
    max-height: 360px;
    min-height: 220px;
  }
  .character-sticky > div:nth-child(2) {
    margin-top: 14px !important;
    gap: 10px !important;
  }

  .chap-card { padding: 40px 28px !important; min-height: auto !important; margin-bottom: 20px; }
  .chap-card h2 { font-size: clamp(28px, 4vw, 40px) !important; }

  /* ── Section padding shrinks */
  .section { padding: 64px 28px !important; }

  /* ── Inline 80px paddings collapse — these are RENDERED forms (no quotes) */
  [style*="padding: 80px 80px"],
  [style*="padding: 90px 80px"],
  [style*="padding: 100px 80px"],
  [style*="padding: 110px 80px"],
  [style*="padding: 120px 80px"],
  [style*="padding: 40px 80px"],
  [style*="padding: 60px 80px"],
  [style*="padding: 80px 0px"] {
    padding-left: 28px !important;
    padding-right: 28px !important;
  }

  /* ── D2 comparison strip — give it horizontal scroll */
  [style*="grid-template-columns: 180px repeat(3, 1fr)"] {
    display: grid !important;
    grid-template-columns: 130px repeat(3, minmax(120px, 1fr)) !important;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  /* ── Display headlines */
  .h-display { font-size: clamp(40px, 6.4vw, 72px) !important; line-height: 1.02 !important; }
  .h-mid { font-size: clamp(28px, 3.8vw, 44px) !important; }

  /* ── Banner strips */
  [style*="padding: 14px 80px"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
    font-size: 12px !important;
  }
}


/* ============================================================
   MOBILE — ≤720px
   Real mobile design.
   ============================================================ */
@media (max-width: 720px) {

  /* ── Site nav: hide desktop link list, condense ── */
  .site-nav { padding: 12px 18px !important; }
  .site-nav .logo img { height: 22px; }
  .site-nav .links { display: none !important; }
  .site-nav .right { gap: 10px; font-size: 13px; }
  .site-nav .right > span { display: none; } /* hide "Sign in" */
  .site-nav .right .btn-pill {
    padding: 9px 14px !important;
    font-size: 12px !important;
    letter-spacing: 0.01em;
  }

  /* ── Portal-back chip: bottom-left, slim, thumb-reach ── */
  .portal-back {
    top: auto !important;
    left: 14px !important;
    bottom: 18px;
    font-size: 11px;
    padding: 7px 12px 7px 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }

  /* ── Index portal ── */
  .portal { padding: 24px 18px 56px; }
  .portal-nav {
    margin-bottom: 36px;
    gap: 14px;
  }
  .portal-nav .meta {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    font-size: 11px;
  }
  .portal-nav .meta span:not(.pill) { font-size: 11px; color: var(--mute); }
  .portal-hero { margin-bottom: 44px; }
  .portal-hero .eyebrow { margin-bottom: 18px !important; }
  .portal-hero h1 {
    font-size: clamp(36px, 11vw, 56px) !important;
    line-height: 1.04 !important;
    letter-spacing: -0.035em;
    margin-bottom: 24px !important;
  }
  .portal-hero h1 br { display: none; }
  .portal-hero h1 .serif {
    display: block;
    margin-top: 0.1em;
  }
  .portal-hero .lede { font-size: 16px; line-height: 1.55; }
  .portal-hero .meta-row {
    flex-direction: column;
    gap: 16px;
    padding-top: 28px;
    margin-top: 32px;
    font-size: 12px;
  }
  .portal-hero .meta-row strong { font-size: 13px; margin-bottom: 2px; }

  .review-aside {
    grid-template-columns: 1fr !important;
    padding: 24px 22px !important;
    border-radius: 16px;
    margin-bottom: 40px;
    gap: 20px;
  }
  .review-aside h3 { font-size: 19px; }
  .review-aside p { font-size: 13px; }
  .review-aside .right ul {
    flex-direction: column !important;
    gap: 10px;
    font-size: 11px;
  }

  .options {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    margin-bottom: 40px;
  }
  .options .option:nth-child(3) { grid-column: span 1; }
  .option { border-radius: 18px; }
  .option:hover { transform: none; box-shadow: none; }
  .option .preview { height: 200px; }
  .option .body { padding: 22px 22px 24px !important; gap: 12px; }
  .option h3 { font-size: 24px !important; }
  .option .sub { font-size: 13px !important; }
  .option .cta { font-size: 13px; padding-top: 14px; }

  .footer-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-size: 11px;
  }


  /* ── DIRECTION 1: Diagnostic on mobile ── */

  /* Live "currently leaning" ribbon — sticky just below nav */
  .leaning-ribbon {
    display: flex;
    position: sticky;
    top: 48px;
    z-index: 45;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--ink);
    color: var(--cream);
    font-size: 12px;
    letter-spacing: 0.01em;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
    pointer-events: none;
  }
  .leaning-ribbon.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .leaning-ribbon .lr-eyebrow {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 252, 244, 0.55);
  }
  .leaning-ribbon .lr-tier {
    font-weight: 500;
    font-size: 13px;
  }
  .leaning-ribbon .lr-conf {
    color: rgba(255, 252, 244, 0.7);
    font-size: 12px;
  }
  .leaning-ribbon .lr-progress {
    margin-left: auto;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    color: rgba(255, 252, 244, 0.55);
    letter-spacing: 0.04em;
  }

  /* Q-chip becomes a full-width row card */
  .q-chip {
    padding: 16px 18px !important;
    border-radius: 12px;
  }
  .q-chip > div:first-child {
    font-size: 16px !important;
  }
  .q-chip-sub {
    font-size: 12px !important;
  }

  /* Recommendation cards stack with the winner first */
  .rec-card {
    padding: 24px !important;
    border-radius: 16px;
  }
  .rec-card.hero {
    transform: none !important;
    box-shadow: 0 18px 36px rgba(26, 24, 24, 0.22) !important;
  }


  /* ── DIRECTION 2: Lens picker (sticky horizontal) refinement ── */
  .lens-rail-sticky {
    top: 48px !important;
    padding: 10px 18px !important;
    margin-bottom: 24px;
  }
  .lens-pill { padding: 10px 8px !important; }
  .lens-pill .lp-name { font-size: 12px !important; letter-spacing: 0.01em; }
  .lens-pill .lp-price { font-size: 9.5px !important; }
  .lens-stage > div:not(.lens-rail-sticky) {
    padding: 0 18px !important;
  }

  /* Sticky bottom CTA bar (D2-only) */
  .mobile-cta-bar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 252, 244, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    align-items: center;
    gap: 12px;
  }
  .mobile-cta-bar .label {
    flex: 1;
    min-width: 0;
    display: flex; flex-direction: column; gap: 2px;
  }
  .mobile-cta-bar .label .lens-name {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--mute);
  }
  .mobile-cta-bar .label .lens-price {
    font-size: 18px;
    font-weight: 200;
    letter-spacing: -0.02em;
    color: var(--ink);
  }
  .mobile-cta-bar button {
    flex-shrink: 0;
    padding: 12px 18px !important;
    font-size: 13px !important;
  }
  body:has(.mobile-cta-bar) { padding-bottom: 70px; }
  /* When the CTA bar is present, raise the portal-back chip above it */
  body:has(.mobile-cta-bar) .portal-back {
    bottom: 84px;
  }

  /* Pillar cards stack on D2 */
  .pillar-card { padding: 24px !important; }


  /* ── DIRECTION 3: Sticky character on mobile ── */
  .character-sticky {
    top: 48px !important;
    padding: 14px 0 10px;
    margin: -14px 0 18px;
    background: var(--cream);
  }
  .character-sticky > div:first-child {
    height: 32vh !important;
    max-height: 280px;
    min-height: 200px;
    border-radius: 16px !important;
  }
  .character-sticky > div:nth-child(2) {
    margin-top: 10px !important;
    gap: 6px !important;
    justify-content: flex-start !important;
    padding: 0 4px;
    font-size: 11px;
    flex-wrap: nowrap;
  }
  .character-sticky > div:nth-child(2) .chap-dot {
    width: 6px !important;
    height: 6px !important;
  }
  .character-sticky > div:nth-child(2) .chap-dot.on {
    width: 14px !important;
    border-radius: 999px;
  }
  .character-sticky > div:nth-child(2) span {
    margin-left: 8px !important;
    font-size: 10px !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mute) !important;
    font-family: ui-monospace, Menlo, monospace;
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .character-sticky > div:first-child > div:last-child {
    left: 16px !important;
    bottom: 12px !important;
  }
  .character-sticky > div:first-child > div:last-child > div:last-child {
    font-size: 15px !important;
  }

  .scrolly { padding: 0 18px !important; }
  .chap-card { padding: 32px 22px !important; margin-bottom: 16px; border-radius: 16px; }
  .chap-card h2 { font-size: 26px !important; line-height: 1.12 !important; }
  .chap-card p { font-size: 15px !important; }


  /* ── Universal mobile elements ── */

  /* Section padding */
  .section { padding: 56px 18px !important; }

  /* Three-col / four-col → single column on mobile */
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Inline padding overrides for content containers */
  [style*="padding: 80px 80px"],
  [style*="padding: 90px 80px"],
  [style*="padding: 100px 80px"],
  [style*="padding: 110px 80px"],
  [style*="padding: 120px 80px"],
  [style*="padding: 40px 80px"],
  [style*="padding: 60px 80px"],
  [style*="padding: 80px 0px"] {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  /* Display headlines on mobile — fluid clamp */
  .h-display {
    font-size: clamp(34px, 9vw, 52px) !important;
    line-height: 1.04 !important;
    letter-spacing: -0.035em !important;
  }
  .h-mid {
    font-size: clamp(24px, 6vw, 36px) !important;
    letter-spacing: -0.02em !important;
  }

  /* Lift-on-hover transforms cause sticky-hover bugs on touch devices */
  .lift:hover, .btn-pill:hover, .option:hover { transform: none !important; box-shadow: none !important; }
  .option .cta .arrow { transform: none !important; }

  /* Comparison strip — let it scroll horizontally on mobile */
  [style*="grid-template-columns: 180px repeat(3, 1fr)"] {
    grid-template-columns: 110px repeat(3, minmax(110px, 1fr)) !important;
    overflow-x: auto;
    font-size: 12px !important;
  }
  [style*="grid-template-columns: 180px repeat(3, 1fr)"] > div {
    padding: 14px 12px !important;
    font-size: 12px !important;
  }

  /* Banner strip */
  [style*="padding: 14px 80px"] {
    padding-left: 14px !important;
    padding-right: 14px !important;
    font-size: 11px !important;
    line-height: 1.4 !important;
  }

  /* Stat tiles */
  .stat-tile { padding: 22px; }
  .stat-tile .big { font-size: 38px; }
  .stat-tile .label { font-size: 12px; }

  /* Cart drawer full-width */
  .cart-drawer { width: 100vw; }

  /* FAQ */
  .faq-item { padding: 20px 0; }
  .faq-item .q { font-size: 16px; }
  .faq-item .a { font-size: 14px; }
  .faq-item .toggle { font-size: 20px; }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px;
    margin-bottom: 32px;
  }
  .site-footer {
    padding: 48px 22px 28px !important;
  }
  .footer-col h4 { font-size: 11px; }
  .footer-col ul { gap: 8px; }
  .footer-col a { font-size: 13px; }
  .footer-bottom {
    flex-direction: column;
    gap: 8px;
    font-size: 11px;
  }

  /* Inline buttons in row */
  .btn-pill, .btn-outline {
    padding: 12px 18px;
    font-size: 13px;
  }

  /* Final dark CTA section padding */
  .section.dark { padding: 64px 22px !important; }
}


/* ============================================================
   SMALL MOBILE — ≤380px
   ============================================================ */
@media (max-width: 380px) {
  .portal { padding: 20px 14px 48px; }
  .portal-nav .pill { display: none; }
  .portal-hero h1 { font-size: 32px !important; }
  .h-display { font-size: 30px !important; }
  .h-mid { font-size: 22px !important; }

  .lens-pill .lp-name { font-size: 11px !important; }
  .lens-pill .lp-price { font-size: 9px !important; }

  .mobile-cta-bar .label .lens-price { font-size: 16px; }
  .mobile-cta-bar button { padding: 10px 14px !important; font-size: 12px !important; }

  .chap-card h2 { font-size: 23px !important; }
}


/* ============================================================
   TOUCH DEVICES — disable hover transforms
   ============================================================ */
@media (hover: none) {
  .option:hover { transform: none; box-shadow: none; }
  .lift:hover { transform: none; }
  .btn-pill:hover { transform: none; }
  .q-chip:hover { transform: none; }
  .lens-pill:hover { background: transparent; }
  .lens-pill.on:hover { background: var(--ink); }
}


/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .wave-anim { animation: none !important; }
  .pulse { animation: none !important; }
}
