/* Mobile corrections only. The approved desktop stylesheet remains unchanged. */
@media (max-width: 760px) {
  /* Keep the decorative card mark visible, underneath the card content. */
  .project-card {
    isolation: isolate;
  }
  .project-card::after {
    right: 12px;
    bottom: 12px;
    z-index: 0;
    color: rgba(238, 233, 223, .07);
    font-size: clamp(5rem, 10.8vw, 12.4rem);
    white-space: nowrap;
  }
  .project-card > * {
    position: relative;
    z-index: 1;
  }

  .start-copy h1 {
    column-gap: .24em;
    row-gap: .08em;
    font-size: clamp(2rem, 11vw, 4.65rem);
    line-height: 1.05;
    word-break: normal;
    overflow-wrap: normal;
  }
  .flap-word {
    display: inline-flex;
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .start-copy h1 > .flap-space {
    display: none;
  }

  /* No intrinsic child width can stretch the page beyond the viewport. */
  .profile-view,
  .profile-tab-panel,
  .skills-view,
  .skills-panel,
  .roadmap-section,
  .roadmap-quote,
  .roadmap-track,
  .tools-section,
  .learning-grid {
    min-width: 0;
    max-width: 100%;
  }
  .profile-view,
  .skills-view {
    height: auto;
    grid-template-rows: auto auto;
  }
  .profile-tab-panel {
    overflow: visible;
  }
  .profile-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-self: center;
    align-items: center;
    gap: 6px;
    width: min(100%, 432px);
    margin: 0 auto 16px;
    overflow: visible;
  }
  .profile-tab-slot {
    width: auto;
    min-width: 0;
    height: auto;
    place-items: center;
  }
  .profile-tabs button,
  .profile-tabs button.is-active {
    min-height: 44px;
    padding: 8px 2px 12px;
    font-size: clamp(.875rem, 4.4vw, 1.08rem);
    text-align: center;
    white-space: nowrap;
  }

  .section-switch {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-self: stretch;
    width: 100%;
    min-width: 0;
    gap: 4px;
    margin: 0 0 20px;
    padding: 4px;
    overflow: visible;
  }
  .section-switch button {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 12px 14px;
    white-space: normal;
    line-height: 1.4;
    text-align: center;
  }
  .section-switch button.is-active {
    background: linear-gradient(145deg, rgba(238, 233, 223, .105), rgba(44, 59, 77, .22));
    box-shadow: inset 0 1px rgba(238, 233, 223, .12), 0 7px 18px rgba(2, 7, 12, .2);
  }
  .section-switch-indicator {
    display: none;
  }
  .skills-panel {
    height: auto;
    overflow: visible;
  }
  .roadmap-section {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 24px;
    padding: 4px 0 16px;
  }
  .roadmap-avatar {
    grid-column: 1;
    grid-row: 1;
    place-self: center;
    width: min(216px, 72%);
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
  }
  .roadmap-quote {
    width: 100%;
    grid-column: 1;
    grid-row: 2;
  }
  .roadmap-quote blockquote {
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 22px 20px 22px 42px;
    font-size: 1rem;
    line-height: 1.55;
    overflow-wrap: break-word;
  }
  .roadmap-quote blockquote::before {
    top: 14px;
    left: 14px;
  }
  .roadmap-track {
    grid-column: 1;
    grid-row: 3;
    grid-template-columns: 24px minmax(0, 1fr);
    grid-template-rows: repeat(6, auto);
    gap: 16px 0;
    width: 100%;
    margin: 0;
    padding: 4px 0;
  }
  .roadmap-line {
    left: 10px;
    top: 18px;
    bottom: 18px;
  }
  .roadmap-card,
  .roadmap-card--left,
  .roadmap-card--right {
    grid-column: 2;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 8px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 18px;
    transform: none;
  }
  .roadmap-card small {
    grid-row: auto;
  }
  .roadmap-card:hover {
    transform: none;
  }
  .roadmap-card h2 {
    min-width: 0;
    font-size: 1rem;
    line-height: 1.4;
  }
  .roadmap-card p {
    min-width: 0;
    margin: 4px 0 0;
    font-size: .9375rem;
    line-height: 1.5;
    overflow-wrap: break-word;
  }
  .roadmap-card--left .roadmap-dot,
  .roadmap-card--right .roadmap-dot {
    left: -19px;
    right: auto;
  }
  .learning-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    height: auto;
  }

  /* Native horizontal scrolling: the first image starts at the content edge. */
  .case-view {
    min-width: 0;
    grid-template-rows: auto auto auto;
  }
  .case-story {
    min-width: 0;
    max-width: 100%;
    height: auto;
    scrollbar-gutter: auto;
    touch-action: auto;
  }
  .case-gallery {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    gap: 12px;
    padding: 0 0 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    touch-action: pan-x pan-y pinch-zoom;
  }
  .case-gallery::before,
  .case-gallery::after {
    display: none;
  }
  .case-gallery-slide,
  .case-gallery-slide.is-active {
    flex: 0 0 calc(100% - 24px);
    width: calc(100% - 24px);
    height: auto;
    grid-template-rows: clamp(230px, 70vw, 390px) auto;
    scroll-snap-align: start;
    scroll-margin: 0;
  }
  .case-gallery-slide .gallery-media .portfolio-media,
  .case-gallery-slide.is-active .gallery-media .portfolio-media {
    width: 100%;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
    filter: none;
  }
  .case-gallery-slide .gallery-copy {
    padding: 16px;
    opacity: 1;
    overflow: visible;
  }
  .case-gallery-slide .gallery-copy p,
  .case-gallery-slide:not(.is-active) .gallery-copy p {
    visibility: visible;
    overflow-wrap: break-word;
  }

  /* The desktop diagram becomes six readable cards; no hover is required. */
  .ai-workflow-view {
    min-width: 0;
    min-height: 0;
    height: auto;
    grid-template-rows: auto auto;
    gap: 24px;
  }
  .ai-header {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .ai-header > div {
    min-width: 0;
  }
  .ai-mode-switch {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-self: stretch;
    width: 100%;
    min-width: 0;
    gap: 4px;
    white-space: normal;
  }
  .ai-mode-switch button {
    min-width: 0;
    min-height: 44px;
    padding: 12px;
    font-size: .875rem;
    line-height: 1.4;
  }
  .workflow-workspace {
    min-width: 0;
    min-height: 0;
    height: auto;
    overflow: visible;
    background: none;
    box-shadow: none;
  }
  .workflow-nodes {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    min-width: 0;
    padding: 0;
  }
  .workflow-node {
    position: relative;
    inset: auto;
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
    gap: 18px 12px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    padding: 20px;
    white-space: normal;
    transform: none;
    animation: none;
  }
  .workflow-node small {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    font-size: .875rem;
  }
  .workflow-node strong {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    font-size: 1.125rem;
    line-height: 1.4;
  }
  .workflow-node-dot {
    display: none;
  }
  .workflow-node .workflow-popover {
    position: static;
    inset: auto;
    display: grid;
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 16px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    opacity: 1;
    background: none;
    box-shadow: none;
    pointer-events: auto;
    transform: none !important;
    transition: none;
  }
  .workflow-popover b {
    display: none;
  }
  .workflow-popover > span {
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    gap: 6px;
    font-size: 1rem;
    line-height: 1.5;
    letter-spacing: .01em;
    overflow-wrap: break-word;
  }
  .workflow-popover em {
    font-size: .875rem;
  }
  .ai-distribution,
  .ai-game-board,
  .ai-game-lane {
    min-width: 0;
    height: auto;
  }
  .ai-distribution > header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .ai-check-actions {
    flex-wrap: wrap;
  }
  .ai-check-actions > button {
    flex: 1;
    min-height: 44px;
  }
  .ai-game-board {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .ai-game-lane > div {
    overflow: visible;
  }
}
