/* Mobile UX layer — desktop (lg / 1024px+) unchanged; loaded after custom.css */

@media (max-width: 1023px) {
  html {
    scroll-padding-top: 4.35rem;
  }

  #site-header .font-display {
    font-size: 0.95rem;
  }

  #nav-menu {
    max-height: min(78dvh, calc(100dvh - 4.25rem));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #nav-menu a {
    min-height: 3rem;
    border-radius: 0.85rem;
  }

  .cred-intro h2,
  #journey-heading,
  #impact-heading,
  #research-heading,
  #portfolio-heading,
  #experience-heading,
  #about-heading {
    font-size: clamp(1.65rem, 6.5vw, 2rem);
  }

  .journey-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .journey-panels {
    min-height: 11rem;
  }

  .research-feature-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .impact-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .impact-badges {
    justify-content: flex-start;
  }

  .scroll-top-fab {
    right: max(0.85rem, env(safe-area-inset-right));
    bottom: max(0.85rem, env(safe-area-inset-bottom));
    width: 3rem;
    height: 3rem;
  }

  /* Hero: force single column on tablet + phone (overrides Tailwind lg grid) */
  .hero-section {
    min-height: 0;
    min-height: auto;
    padding-top: 4.85rem;
    padding-bottom: 1.75rem;
  }

  #hero-inner {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    gap: 1.1rem;
  }

  #hero-portrait {
    order: 1;
    width: 100%;
    max-width: 13rem;
    margin-inline: auto;
    margin-bottom: 0.15rem;
  }

  #hero-copy {
    order: 2;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .hero-portrait-stage {
    width: min(58vw, 12.75rem);
  }

  /* Education — horizontal qualification cards (tablet + phone) */
  .edu-ladder.mob-hscroll {
    --mob-hscroll-pad: 1rem;
    display: flex !important;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.85rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--mob-hscroll-pad);
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-x;
    margin-inline: calc(-1 * var(--mob-hscroll-pad));
    padding-inline: var(--mob-hscroll-pad);
    padding-left: var(--mob-hscroll-pad) !important;
    padding-bottom: 0.45rem;
    grid-template-columns: unset !important;
  }

  @media (min-width: 640px) {
    .edu-ladder.mob-hscroll {
      --mob-hscroll-pad: 1.5rem;
    }
  }

  .edu-ladder.mob-hscroll::-webkit-scrollbar {
    display: none;
  }

  .edu-ladder.mob-hscroll > .edu-ladder-line {
    display: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }

  .edu-ladder.mob-hscroll > .edu-entry {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: min(88vw, 19rem);
    max-width: min(88vw, 19rem);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    align-self: stretch;
    grid-template-columns: unset;
  }

  .edu-ladder.mob-hscroll .edu-level {
    width: 2.45rem;
    height: 2.45rem;
    font-size: 0.68rem;
    margin-top: 0;
  }

  .edu-ladder.mob-hscroll .edu-panel {
    flex: 1 1 auto;
    min-height: 13.5rem;
    padding: 0.95rem 1rem;
  }

  .edu-ladder.mob-hscroll .edu-panel-top {
    flex-direction: column;
    gap: 0.6rem;
  }

  .edu-ladder.mob-hscroll .edu-degree {
    -webkit-line-clamp: 3;
    min-height: auto;
    font-size: 0.98rem;
  }

  .edu-ladder.mob-hscroll .edu-institution {
    -webkit-line-clamp: 2;
    min-height: auto;
    font-size: 0.82rem;
  }

  .edu-ladder.mob-hscroll .edu-result-box {
    align-self: flex-start;
    min-width: 4.75rem;
  }

  .edu-summary.mob-hscroll,
  .exp-summary.mob-hscroll {
    --mob-hscroll-pad: 1rem;
    display: flex !important;
    flex-wrap: nowrap;
    gap: 0.65rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--mob-hscroll-pad);
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-x;
    margin-inline: calc(-1 * var(--mob-hscroll-pad));
    padding-inline: var(--mob-hscroll-pad);
    padding-bottom: 0.25rem;
    grid-template-columns: unset !important;
  }

  @media (min-width: 640px) {
    .edu-summary.mob-hscroll,
    .exp-summary.mob-hscroll {
      --mob-hscroll-pad: 1.5rem;
    }
  }

  .edu-summary.mob-hscroll::-webkit-scrollbar,
  .exp-summary.mob-hscroll::-webkit-scrollbar {
    display: none;
  }

  .edu-summary.mob-hscroll > *,
  .exp-summary.mob-hscroll > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: min(42vw, 9.5rem);
    max-width: min(42vw, 9.5rem);
  }

  /* Experience — horizontal role cards (tablet + phone) */
  .exp-timeline.mob-hscroll {
    --mob-hscroll-pad: 1rem;
    display: flex !important;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.85rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--mob-hscroll-pad);
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-x;
    margin-inline: calc(-1 * var(--mob-hscroll-pad));
    padding-inline: var(--mob-hscroll-pad);
    padding-left: var(--mob-hscroll-pad) !important;
    padding-bottom: 0.45rem;
    grid-template-columns: unset !important;
  }

  @media (min-width: 640px) {
    .exp-timeline.mob-hscroll {
      --mob-hscroll-pad: 1.5rem;
    }
  }

  .exp-timeline.mob-hscroll::-webkit-scrollbar {
    display: none;
  }

  .exp-timeline.mob-hscroll > .exp-timeline-line {
    display: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }

  .exp-timeline.mob-hscroll > .exp-entry {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: min(90vw, 20.5rem);
    max-width: min(90vw, 20.5rem);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-self: stretch;
    grid-template-columns: unset;
  }

  .exp-timeline.mob-hscroll > .exp-entry::before {
    display: none !important;
  }

  .exp-timeline.mob-hscroll .exp-date {
    position: static;
    left: auto;
    top: auto;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    text-align: left;
    gap: 0.35rem 0.45rem;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .exp-timeline.mob-hscroll .exp-date-sep {
    display: inline;
  }

  .exp-timeline.mob-hscroll .exp-panel {
    flex: 1 1 auto;
    min-height: 15.5rem;
    padding: 0.95rem 1rem;
    display: flex;
    flex-direction: column;
  }

  .exp-timeline.mob-hscroll .exp-panel-top {
    gap: 0.65rem;
  }

  .exp-timeline.mob-hscroll .exp-org-mark {
    width: 2.35rem;
    height: 2.35rem;
    font-size: 0.72rem;
  }

  .exp-timeline.mob-hscroll .exp-role {
    font-size: 1rem;
    line-height: 1.3;
  }

  .exp-timeline.mob-hscroll .exp-company {
    font-size: 0.84rem;
  }

  .exp-timeline.mob-hscroll .exp-duties {
    margin-top: auto;
    padding-top: 0.35rem;
    font-size: 0.82rem;
    line-height: 1.55;
    gap: 0.45rem;
  }

  .exp-timeline.mob-hscroll .exp-duties li {
    font-size: 0.82rem;
  }

  /* About — single column, full width, logical read order */
  .about-layout {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    width: 100%;
  }

  .about-intro,
  .about-identity,
  .about-story {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .about-intro {
    order: 1;
  }

  .about-story {
    order: 2;
  }

  .about-identity {
    order: 3;
    position: static;
    margin-inline: auto;
    width: 100%;
    max-width: 20rem;
    margin-top: 0.25rem;
  }

  .about-profile-visual {
    min-height: 9rem;
    padding-top: 1.5rem;
  }

  .about-profile-photo {
    width: 68%;
    max-width: 11rem;
  }

  .about-profile-card > .space-y-5 {
    padding: 1.15rem 1.2rem 1.25rem;
  }

  .about-facts {
    font-size: 0.88rem;
  }

  .about-quote {
    padding: 1.15rem 1.15rem 1.15rem 1.35rem;
    margin-top: 1.75rem;
  }

  .about-quote::before {
    font-size: 2.25rem;
    left: 0.65rem;
  }

  .about-pillars {
    margin-top: 1.75rem;
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .about-pillar {
    padding: 1rem 1.05rem;
  }
}

@media (max-width: 767px) {
  /* Opt-in horizontal scroll — only elements with .mob-hscroll */
  .mob-hscroll {
    --mob-hscroll-pad: 1rem;
    display: flex !important;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.85rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--mob-hscroll-pad);
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-x;
    margin-inline: calc(-1 * var(--mob-hscroll-pad));
    padding-inline: var(--mob-hscroll-pad);
    padding-bottom: 0.4rem;
  }

  @media (min-width: 640px) {
    .mob-hscroll {
      --mob-hscroll-pad: 1.5rem;
    }
  }

  .mob-hscroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .mob-hscroll > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .mob-hscroll--cards > * {
    min-width: min(82vw, 17.5rem);
    max-width: min(82vw, 17.5rem);
  }

  .mob-hscroll--wide > * {
    min-width: min(86vw, 18.5rem);
    max-width: min(86vw, 18.5rem);
  }

  .mob-hscroll--portfolio > * {
    min-width: min(76vw, 16.5rem);
    max-width: min(76vw, 16.5rem);
  }

  .mob-hscroll--kpi > * {
    min-width: min(72vw, 11.5rem);
    max-width: min(72vw, 11.5rem);
  }

  .research-pillars-row {
    margin-bottom: 0.25rem;
  }

  /* Chip / badge strips — internal scroll only */
  .skills-legend,
  .impact-badges,
  #philosophy .flex-wrap.gap-6,
  .exp-chips,
  .edu-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-x;
    padding-bottom: 0.15rem;
  }

  .skills-legend::-webkit-scrollbar,
  .impact-badges::-webkit-scrollbar,
  #philosophy .flex-wrap.gap-6::-webkit-scrollbar,
  .exp-chips::-webkit-scrollbar,
  .edu-chips::-webkit-scrollbar {
    display: none;
  }

  .skills-legend > *,
  .impact-badges > *,
  #philosophy .flex-wrap.gap-6 > *,
  .exp-chips > *,
  .edu-chips > * {
    flex: 0 0 auto;
  }

  #philosophy .flex-wrap.gap-6 {
    justify-content: flex-start;
  }

  .impact-badges {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .about-profile-card ul[aria-label="Core domains"] {
    flex-wrap: wrap;
    overflow: visible;
    gap: 0.4rem;
  }

  .about-tag {
    font-size: 0.68rem;
    padding: 0.3rem 0.62rem;
  }

  .about-story .space-y-6 {
    font-size: 0.94rem;
    line-height: 1.75;
  }

  .hero-portrait-stage {
    width: min(58vw, 12.75rem);
  }

  .hero-portrait-ring,
  .hero-portrait-arch {
    opacity: 0.9;
  }

  .hero-title-fluid {
    font-size: clamp(1.75rem, 8.5vw, 2.35rem);
  }

  #hero-copy .font-accent.text-lg {
    font-size: 1.05rem;
    line-height: 1.45;
  }

  #hero-copy > p.font-accent:first-child {
    gap: 0.5rem;
    letter-spacing: 0.18em;
    font-size: 0.62rem;
  }

  #hero-copy > p.font-accent:first-child span:last-child {
    display: none;
  }

  #hero-copy .max-w-xl.text-base {
    font-size: 0.92rem;
    line-height: 1.65;
  }

  #hero-copy dl {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Section rhythm — tighter vertical spacing on phones */
  .about-section,
  .skills-section,
  .edu-section,
  .cred-section,
  .exp-section,
  .journey-section,
  .research-section,
  .impact-section,
  .portfolio-section,
  #profiles,
  #philosophy,
  #contact {
    padding-top: 3.25rem !important;
    padding-bottom: 3.25rem !important;
  }

  /* Portfolio controls stack */
  .portfolio-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .portfolio-controls .portfolio-view-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .portfolio-controls .portfolio-view-toggle .portfolio-view-btn {
    flex: 1 1 0;
    text-align: center;
  }

  /* Experience cards */
  .exp-panel {
    padding: 0.95rem 1rem;
  }

  .exp-org-mark {
    width: 2.35rem;
    height: 2.35rem;
    font-size: 0.72rem;
  }

  .exp-role {
    font-size: 1rem;
  }

  .exp-chips {
    gap: 0.35rem;
  }

  /* Education panels */
  .edu-panel {
    padding: 0.95rem 1rem;
  }

  .edu-degree {
    font-size: 1rem;
  }

  .edu-result-box {
    min-height: auto;
    padding: 0.55rem 0.65rem;
  }

  /* Impact events */
  .impact-event-item {
    grid-template-columns: auto 1fr;
    align-items: start;
    padding: 0.7rem 0.75rem;
  }

  .impact-event-item .exp-chip {
    grid-column: 1 / -1;
    margin-left: 2.55rem;
    justify-self: start;
  }

  .impact-kpi-value {
    font-size: 1.75rem;
  }

  /* Research pillars */
  .research-pillar {
    padding: 0.95rem 1rem;
  }

  /* Journey rail horizontal scroll */
  .journey-rail-nav {
    margin: 0 -0.15rem;
    padding: 0 0.15rem 0.35rem;
  }

  .journey-rail-item {
    min-width: 10.5rem;
    padding: 0.65rem 0.7rem;
  }

  .journey-stage-wrap {
    border-radius: 1.35rem;
  }

  /* Contact */
  #contact h2 {
    font-size: clamp(1.65rem, 7vw, 2.15rem);
    margin-top: 1.25rem;
  }

  #contact .grid.max-w-7xl {
    gap: 1.75rem;
  }

  #contact-form input,
  #contact-form select,
  #contact-form textarea {
    font-size: 16px;
  }

  #contact dl.rounded-\[1\.85rem\] dd a,
  #contact dl.rounded-\[1\.85rem\] dd.font-display {
    font-size: 1rem;
    word-break: break-word;
  }

  /* Philosophy quote */
  #philosophy {
    padding-top: 2.75rem;
    padding-bottom: 2.75rem;
  }

  #philosophy blockquote {
    font-size: clamp(1.2rem, 5.5vw, 1.65rem);
    line-height: 1.45;
    margin-top: 1.75rem;
  }

  #philosophy .flex-wrap.gap-6 {
    gap: 0.55rem;
  }

  #philosophy .flex-wrap.gap-6 span {
    font-size: 0.62rem;
    padding: 0.65rem 0.85rem;
    letter-spacing: 0.14em;
  }

  /* Footer */
  .site-footer-grid {
    gap: 1.35rem;
  }

  .site-footer-brand {
    padding: 1rem;
  }

  .site-footer-links {
    grid-template-columns: 1fr 1fr;
    gap-y: 0.65rem;
  }

  .site-footer-bar {
    text-align: center;
  }

  .site-footer-resume {
    width: 100%;
    text-align: center;
  }

  /* Profiles cards */
  #profiles .mob-hscroll {
    gap: 0.85rem;
  }
}

@media (max-width: 479px) {
  #particle-canvas {
    display: none;
  }

  #hero-portrait {
    max-width: 11.5rem;
  }

  .hero-portrait-stage {
    width: min(52vw, 11.25rem);
  }

  #site-header .font-display {
    font-size: 0.88rem;
    max-width: 11.5rem;
    line-height: 1.25;
  }

  #site-header .h-10.w-10 {
    height: 2.35rem;
    width: 2.35rem;
    font-size: 0.95rem;
  }

  .impact-kpi-grid,
  .journey-stats,
  .research-stats,
  .exp-summary {
    gap: 0.65rem;
  }

  .impact-kpi,
  .journey-stat,
  .research-stat,
  .exp-stat {
    padding: 0.65rem 0.55rem;
  }

  .impact-kpi-label {
    font-size: 0.56rem;
    gap: 0.4rem;
  }

  .impact-kpi-icon {
    width: 1.65rem;
    height: 1.65rem;
  }

  .impact-feature-metrics {
    grid-template-columns: 1fr;
  }

  .research-feature-metrics {
    grid-template-columns: 1fr;
  }

  .journey-cta {
    align-items: stretch;
    text-align: left;
  }

  .journey-cta .inline-flex,
  .journey-cta > div a {
    width: 100%;
    justify-content: center;
  }

  .impact-head .impact-badges {
    justify-content: flex-start;
  }

  .platform-grid {
    gap: 0.85rem;
  }

  .cred-card {
    padding: 1rem 1.05rem;
  }

}

/* Portfolio modal — full bleed on small screens */
@media (max-width: 767px) {
  .portfolio-modal-backdrop {
    padding: 0.65rem;
    padding-top: max(0.65rem, env(safe-area-inset-top));
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
  }

  .portfolio-modal-backdrop > div {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 1rem;
    border-radius: 1.35rem;
  }
}

/* Touch devices: remove hover lift, keep taps crisp */
@media (hover: none) and (pointer: coarse) {
  .exp-panel:hover,
  .portfolio-card:hover,
  .cred-card:hover,
  .edu-panel:hover,
  .research-pillar:hover,
  .impact-kpi:hover {
    transform: none;
  }

  a,
  button,
  [role="button"],
  .portfolio-filter,
  .journey-rail-item,
  .journey-nav-btn {
    touch-action: manipulation;
  }
}

/* Prevent iOS zoom on focus — mobile only */
@media (max-width: 767px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }
}
