/* Mobile polish — overflow fixes + touch-friendly layout */

html {
  overflow-x: clip;
}

body {
  overflow-x: clip;
  min-width: 0;
}

main,
.container {
  min-width: 0;
  max-width: 100%;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Long log lines — scroll inside the panel, not the page */
.result-card__snippet,
.terminal-frame pre,
.shadow-log {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.result-card__snippet code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Comfortable tap targets */
.btn,
.site-nav a,
.ascii-mascot {
  touch-action: manipulation;
}

@media (max-width: 640px) {
  :root {
    --gutter: clamp(0.85rem, 3.5vw, 1.15rem);
  }

  main {
    padding-block: clamp(1.35rem, 4vw, 2rem) clamp(1.75rem, 5vw, 2.75rem);
  }

  /* Header */
  .site-header__inner {
    align-items: stretch;
    gap: 0.75rem;
  }

  .site-brand {
    margin-right: 0;
    flex: 1 1 auto;
    min-width: 0;
  }

  .site-logo {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-header__inner > nav {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(var(--gutter) * -0.15);
    padding: 0 calc(var(--gutter) * 0.15) 0.15rem;
  }

  .site-nav {
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    gap: 0;
  }

  .site-nav a {
    flex-shrink: 0;
    padding: 0.55rem 0.7rem;
    font-size: 0.82rem;
    min-height: 2.5rem;
    display: inline-flex;
    align-items: center;
  }

  /* Hero + CTAs */
  .hero {
    padding: 1.15rem 1rem 1.25rem;
  }

  .hero__actions .btn,
  .article-cta__actions .btn {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .article-cta {
    flex-direction: column;
    align-items: stretch;
    padding: 1.15rem 1rem;
  }

  .article-cta__actions {
    flex-direction: column;
    width: 100%;
  }

  .article-cta__actions .btn {
    width: 100%;
    text-align: center;
  }

  .manifesto {
    padding: 1rem;
  }

  .manifesto__line {
    padding-left: 0.75rem;
    font-size: 0.85rem;
  }

  /* Project cards — mascots below content on narrow screens */
  .project-card--lucimagi,
  .project-card--pia,
  .project-card--cve {
    padding-bottom: 0.5rem;
  }

  .project-card--lucimagi .project-card__tags,
  .project-card--pia .project-card__tags,
  .project-card--cve .project-card__tags {
    padding-right: 0;
    margin-bottom: 0.35rem;
  }

  .project-card .lucimagi-owl,
  .project-card .pia-terminal,
  .project-card .cve-router {
    position: static;
    display: flex;
    justify-content: flex-end;
    margin: 0.35rem 0 0 auto;
    transform: none;
    max-width: 100%;
    overflow-x: auto;
  }

  /* Project detail header mascots */
  .page-header {
    padding: 1rem 0.95rem 1.1rem;
  }

  .page-header--lucimagi .page-header__summary,
  .page-header--pia .page-header__summary,
  .page-header--cve .page-header__summary {
    padding-right: 0;
  }

  .page-header--lucimagi .lucimagi-owl,
  .page-header--pia .pia-terminal,
  .page-header--cve .cve-router {
    position: static;
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    transform: none;
    max-width: 100%;
    overflow-x: auto;
  }

  .page-header__title {
    font-size: clamp(1.25rem, 5vw, 1.65rem);
  }

  /* Evidence / terminal blocks */
  .result-grid {
    grid-template-columns: 1fr;
  }

  .terminal-frame__bar b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55vw;
  }
}

/* ── About You / shadow dashboard ── */

.shadow-page {
  min-width: 0;
  overflow-x: clip;
}

#recon-root {
  min-width: 0;
  overflow-x: clip;
}

@media (max-width: 900px) {
  .shadow-fingerprint__main,
  .shadow-fingerprint__main--triple {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 640px) {
  .shadow-notice {
    padding: 0.85rem 0.9rem;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .shadow-hero {
    padding: 1rem 0.95rem 1.1rem;
  }

  .shadow-hero__title {
    font-size: clamp(1.35rem, 6vw, 1.85rem);
  }

  .shadow-hero__summary {
    font-size: 0.92rem;
  }

  .shadow-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
    margin-top: 1rem;
  }

  .shadow-meta__item {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .shadow-meta__item b {
    word-break: break-all;
  }

  .shadow-meta__status {
    margin-left: 0;
    align-self: flex-start;
  }

  .shadow-boot {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .shadow-fingerprint {
    padding: 1rem 0.95rem;
  }

  .shadow-fingerprint__hash {
    font-size: clamp(0.72rem, 3.2vw, 0.92rem);
    line-height: 1.45;
  }

  .shadow-fingerprint__unique {
    font-size: clamp(0.95rem, 4vw, 1.1rem);
    overflow-wrap: anywhere;
  }

  .shadow-fingerprint__actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .shadow-fingerprint__actions .btn {
    width: 100%;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .shadow-breakdown__item {
    grid-template-columns: 1fr;
    gap: 0.25rem;
    padding: 0.55rem 0.65rem;
  }

  .shadow-breakdown__weight {
    white-space: normal;
  }

  .shadow-breakdown__detail {
    text-align: left;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .shadow-grid,
  .shadow-active-grid {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .shadow-panel {
    min-height: 6.5rem;
  }

  .shadow-panel__head {
    padding: 0.55rem 0.65rem 0.4rem;
  }

  .shadow-panel__title {
    font-size: 0.78rem;
    overflow-wrap: anywhere;
  }

  .shadow-panel__note {
    font-size: 0.62rem;
    overflow-wrap: anywhere;
  }

  .shadow-log {
    padding: 0.5rem 0.6rem;
  }

  .shadow-log code {
    font-size: clamp(0.62rem, 2.8vw, 0.68rem);
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .shadow-escalate {
    padding-top: 1.15rem;
  }

  .shadow-escalate__controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .shadow-escalate__controls .btn,
  .shadow-go {
    width: 100%;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .shadow-escalate__progress,
  .shadow-escalate__controls .shadow-meta__status {
    align-self: flex-start;
  }

  .shadow-page .article-cta {
    margin-top: 1.75rem;
  }

  .shadow-page .article-cta__actions .btn {
    min-height: 2.75rem;
  }
}

@media (max-width: 380px) {
  .ascii-mascot {
    padding: 0.22rem 0.38rem;
  }

  .ascii-mascot__shell {
    font-size: 0.72rem;
  }

  .site-logo {
    font-size: 0.78rem;
  }

  .shadow-fingerprint__actions .btn {
    font-size: 0.72rem;
    padding-inline: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shadow-scanline::before {
    animation: none;
  }

  #recon-root.is-scanning .shadow-scanline {
    opacity: 0;
  }
}
