/* Mobile-first structural refinement for the 2026 portfolio system */

@media (max-width: 62rem) {
  :root {
    --mobile-gutter: clamp(1rem, 4.5vw, 1.35rem);
    --mobile-section: clamp(3.75rem, 12vw, 5.25rem);
  }

  .container,
  .rb-page,
  .hero-content,
  .prose-content {
    width: calc(100% - (2 * var(--mobile-gutter)));
  }

  /* Header becomes a compact app-bar rather than a compressed desktop nav. */
  .nav-wrapper {
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--canvas) 96%, transparent);
    backdrop-filter: blur(18px) saturate(120%);
  }

  .nav-glass {
    position: relative;
    width: calc(100% - (2 * var(--mobile-gutter)));
    min-height: 60px;
    gap: 0.45rem;
  }

  .brand { min-width: 0; gap: 0.55rem; }
  .brand-mark { width: 2rem; height: 2rem; flex-basis: 2rem; border-radius: 0.55rem; }
  .brand-text { min-width: 0; }
  .brand-name { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-sub { display: none; }

  .theme-toggle,
  .menu-toggle {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 0.75rem;
  }

  .nav-links {
    top: calc(100% + 1px);
    padding: 0.55rem var(--mobile-gutter) 0.75rem;
    gap: 0.2rem;
    background: color-mix(in srgb, var(--canvas) 98%, transparent);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
  }

  .nav-links a {
    min-height: 46px;
    padding: 0 0.8rem;
    border-radius: 0.65rem;
    font-size: 0.78rem;
    letter-spacing: 0.035em;
  }

  .nav-links a.active {
    border-left: 0;
    padding-left: 0.8rem;
    background: color-mix(in srgb, var(--accent) 11%, transparent);
    box-shadow: inset 3px 0 0 var(--accent);
  }

  /* Heroes read as one intentional narrative on phones. */
  .rb-hero,
  .page-hero,
  .hero-gradient,
  .case-hero {
    padding: clamp(2.9rem, 9vw, 4rem) 0 clamp(3.2rem, 10vw, 4.5rem);
  }

  .rb-hero-grid,
  .page-hero__grid,
  .case-hero__grid {
    gap: 2.2rem;
    align-items: start;
  }

  .rb-hero h1,
  .page-hero__copy h1,
  .hero-content h1,
  .case-hero__copy h1 {
    max-width: 13ch;
    margin: 0.65rem 0 1rem;
    font-size: clamp(2.45rem, 10.8vw, 3.65rem);
    line-height: 1;
    letter-spacing: -0.042em;
  }

  .rb-hero-copy > p:not(.rb-kicker),
  .page-hero__copy > p:not(.eyebrow),
  .hero-content > p:not(.eyebrow),
  .case-hero__copy > p:not(.eyebrow) {
    max-width: 38rem;
    font-size: 0.98rem;
    line-height: 1.62;
  }

  .rb-intro,
  .summary-panel,
  .case-facts {
    margin-top: 0;
    padding: 0;
    border-left: 0;
  }

  .rb-meta-row,
  .summary-row,
  .case-fact {
    grid-template-columns: minmax(4.8rem, 0.3fr) minmax(0, 0.7fr);
    gap: 0.75rem;
    padding: 0.75rem 0;
  }

  /* Section headings stack tightly and preserve the content hierarchy. */
  .rb-section,
  .section { padding-bottom: var(--mobile-section); }

  .rb-section-head,
  .section-heading {
    gap: 0.65rem;
    margin-bottom: 1.65rem;
  }

  .rb-section-head h2,
  .section-heading h2,
  .rb-close h2,
  .closing-panel h2 {
    max-width: 18ch;
    font-size: clamp(1.85rem, 8vw, 2.55rem);
    line-height: 1.06;
  }

  .rb-section-head p:not(.rb-kicker),
  .section-heading p:not(.eyebrow) {
    margin-top: 0.45rem;
    line-height: 1.58;
  }

  /* Featured projects become compact reading cards rather than tall desktop panels. */
  .rb-work-grid {
    border-radius: 1rem;
  }

  .rb-work-primary,
  .rb-work-secondary {
    min-height: 0;
    padding: 1.25rem;
    gap: 1.4rem;
  }

  .rb-work-primary { min-height: 0; }
  .rb-work-secondary { min-height: 0; }
  .rb-work-title,
  .rb-work-secondary .rb-work-title {
    max-width: 18ch;
    margin: 0.55rem 0 0.55rem;
    font-size: clamp(1.55rem, 7.5vw, 2.15rem);
    line-height: 1.03;
  }
  .rb-work-copy { font-size: 0.92rem; line-height: 1.56; }
  .rb-work-foot { align-items: center; margin-top: 0.8rem; }
  .rb-tags { gap: 0.32rem; }
  .rb-tags span,
  .tag,
  .stat-pill { font-size: 0.66rem; padding: 0.3rem 0.45rem; }

  /* Ledgers stop spending an entire phone column on numbering. */
  .rb-capability,
  .skill-entry,
  .experience-entry,
  .case-study-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 1.2rem 0;
  }

  .rb-capability > span,
  .case-study-row__mark,
  .skill-entry > span,
  .experience-entry__date {
    display: block;
    margin-bottom: 0.05rem;
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .rb-capability p,
  .skill-entry p,
  .experience-entry p,
  .experience-entry ul,
  .case-study-row p {
    grid-column: auto;
  }

  .rb-capability h3,
  .skill-entry h3,
  .experience-entry h3,
  .case-study-row h2,
  .case-study-row h3 {
    font-size: 1.08rem;
    line-height: 1.2;
  }

  .experience-entry ul { margin-top: 0.55rem; padding-left: 1.15rem; }

  /* Side panels enter the reading flow with restrained separation. */
  .profile-aside,
  .credential-stack,
  .case-aside { gap: 0.75rem; }

  .aside-panel,
  .credential-panel,
  .form-panel,
  .card,
  .profile-embed {
    padding: 1.05rem;
    border-radius: 1rem;
  }

  /* Case studies prioritise findings and outcomes over the desktop rail. */
  .case-section { padding: 1.65rem 0 2rem; }
  .case-section h2 { max-width: 22ch; font-size: clamp(1.65rem, 7.5vw, 2.2rem); }
  .finding { grid-template-columns: 32px minmax(0, 1fr); gap: 0.75rem; padding: 1rem 0; }
  .finding h3 { font-size: 1rem; }
  .outcome-list { margin-top: 1rem; border-left: 0; }
  .outcome-item { padding: 0.95rem 0; border-right: 0; }
  .case-actions { display: grid; grid-template-columns: 1fr; }
  .case-actions .btn { width: 100%; }

  /* Supporting pages use a single visual rhythm instead of three detached cards. */
  .grid { gap: 0.75rem; }
  .grid > .card { border-radius: 0.9rem; }
  .stats { gap: 0.35rem; }

  /* Contact is one continuous task on mobile. */
  .contact-shell { gap: 2.25rem; }
  .contact-link-row { grid-template-columns: 4.6rem minmax(0, 1fr); gap: 0.65rem; }
  .form-panel { padding: 1.15rem; }
  .form-panel label { margin-top: 0.8rem; }
  .form-panel input,
  .form-panel textarea { min-height: 48px; padding: 0.75rem 0.8rem; }
  .form-panel textarea { min-height: 9rem; }

  /* Proof points become a readable list rather than three squeezed columns. */
  .rb-proof {
    grid-template-columns: 1fr;
    border-bottom: 0;
  }
  .rb-proof-item,
  .rb-proof-item:nth-child(2),
  .rb-proof-item:nth-child(3) {
    display: grid;
    grid-template-columns: minmax(5.5rem, 0.35fr) minmax(0, 0.65fr);
    align-items: baseline;
    gap: 0.8rem;
    padding: 0.9rem 0;
    border-right: 0;
    border-bottom: 1px solid var(--line) !important;
  }
  .rb-proof-item:nth-child(4) { display: none; }
  .rb-proof-item strong { font-size: clamp(1.35rem, 7vw, 1.8rem); }
  .rb-proof-item span { margin-top: 0; font-size: 0.72rem; }

  .rb-close,
  .closing-panel {
    gap: 1.25rem;
    padding-top: 1.5rem;
  }

  .rb-close .btn,
  .closing-panel .btn { width: 100%; }

  .footer-inner {
    gap: 0.75rem;
    padding: 1.35rem 0 calc(1.35rem + env(safe-area-inset-bottom));
  }
  .footer-links { gap: 0.4rem 0.85rem; }

  /* Accessibility controls become a compact bottom-sheet style panel. */
  .a11y-launcher {
    right: max(0.8rem, env(safe-area-inset-right));
    bottom: max(0.8rem, env(safe-area-inset-bottom));
    width: 3.15rem;
    height: 3.15rem;
  }
  .a11y-panel {
    left: var(--mobile-gutter);
    right: var(--mobile-gutter);
    bottom: calc(4.5rem + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(70vh, 34rem);
    overflow-y: auto;
    padding: 0.95rem;
    border-radius: 1rem;
  }
}

@media (max-width: 35rem) {
  .rb-actions,
  .home-hero__actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .rb-actions .btn,
  .home-hero__actions .btn { width: 100%; }

  .rb-meta-row,
  .summary-row,
  .case-fact,
  .contact-link-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .rb-meta-row span,
  .summary-row span,
  .case-fact span,
  .contact-link-row span { margin-bottom: 0.05rem; }

  .rb-work-foot { align-items: flex-end; }
  .rb-tags { max-width: 88%; }

  .profile-embed__header { align-items: flex-start; }
  .profile-embed__avatar { width: 3.25rem; height: 3.25rem; }
  .profile-embed__stats { grid-template-columns: 1fr; }

  .footer-inner,
  .footer-inner > div { align-items: flex-start; }
}

@media (max-width: 23rem) {
  .brand-name { max-width: 7.5rem; }
  .theme-toggle,
  .menu-toggle { width: 40px; min-width: 40px; height: 40px; min-height: 40px; }
  .rb-hero h1,
  .page-hero__copy h1,
  .hero-content h1,
  .case-hero__copy h1 { font-size: 2.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-links,
  .a11y-panel { scroll-behavior: auto; }
}
