/* Responsive refinements: portrait-first hero, 3-up stat strip, small phones,
   safe areas and print. The old header/drawer rules were removed with the header. */

@media (max-width: 900px) {
  :root { --space-9: 4.5rem; --space-10: 6rem; }
  .hero__grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-items: start; }

  /* One shared text source on every viewport. Keep the desktop construction —
     portrait + absolutely positioned methodology card — so the card only
     shrinks and sits ON the image, never becomes a second grid column. */
  .hero__grid > .hero__visual { grid-row: 1; grid-column: 1; }
  .hero__grid > .hero__content { grid-row: 2; grid-column: 1; }
  .hero__grid > .stat-strip { grid-row: 3; grid-column: 1; }
  .hero__visual {
    width: min(86%, 300px); margin-inline: auto;
    padding: 0 0 2.4rem; /* reserve room for the overlapping card */
  }
  .portrait { width: 100%; max-width: none; margin: 0; }
  .hero__content { text-align: center; }
  .hero__summary { margin-inline: auto; }
  .hero__meta { justify-content: center; margin-top: var(--space-4); gap: var(--space-3) var(--space-5); }
  .flow-card {
    position: absolute; z-index: 4;
    inset-block-start: auto; inset-inline-start: auto;
    inset-inline-end: -0.6rem; inset-block-end: 0.2rem;
    width: min(80%, 220px); max-width: none;
    margin: 0; padding: 0.7rem 0.8rem;
  }
  .flow-card__title { font-size: 0.6rem; letter-spacing: 0.06em; text-align: center; margin-bottom: 0.5rem; }
  .flow__node { font-size: 0.58rem; padding: 0.35rem 0.1rem; }
  .flow__link { flex-basis: 12px; }

  .about__grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
}

@media (max-width: 700px) {
  .section-head { gap: var(--space-3); margin-bottom: var(--space-5); }
  .section-head h2 { font-size: var(--step-2); }
  .section-rule { display: none; }
  .timeline__item { grid-template-columns: minmax(0, 1fr); gap: 0.35rem; padding-inline-start: var(--space-5); }
  .timeline::before { inset-inline-start: 5px; }
  .timeline__item::before { inset-inline-start: 0; }
  .writeup-list a { grid-template-columns: 58px minmax(0, 1fr) 18px; gap: var(--space-3); padding: var(--space-3) var(--space-2); }
  .writeup-list .chip { display: none; }
  .ctf-list a { grid-template-columns: 38px minmax(0, 1fr); gap: var(--space-3); padding: var(--space-3) var(--space-2); }
  .contact__links { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  :root { --space-8: 3rem; --space-9: 3.75rem; }
  .container { width: min(100% - 2rem, var(--container)); }
  /* Tighter first-screen rhythm: keeps the centred stat strip above the
     bottom-left floating + on short phones without reserving a side lane. */
  .hero { padding-block: var(--space-6) 5rem; }
  .hero__grid { gap: var(--space-4); }
  .hero__visual { width: min(84%, 288px); padding-bottom: 1.9rem; }
  .flow-card { width: min(82%, 200px); inset-inline-end: -0.4rem; }
  .hero__meta { margin-top: var(--space-3); }

  /* Full-width, perfectly centred strip — no reserved lane, no left shift. */
  .hero .stat-strip { margin-inline: 0; margin-top: var(--space-5); }
  .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-strip li { padding: 0.75rem 0.4rem; text-align: center; }
  .stat-strip li:first-child { border-inline-start: 0; }
  .stat-strip strong { font-size: var(--step-1); text-align: center; }
  .stat-strip span { font-size: 0.68rem; line-height: 1.5; margin-top: 0.35rem; }

  .section-lead { font-size: var(--step-0); }
  .case > div { grid-template-columns: 58px minmax(0, 1fr); gap: var(--space-2); }
  .contact__lead { font-size: var(--step-1); }
  .signoff { padding: var(--space-3) var(--space-4); }
}

@media (max-width: 380px) {
  .hero h1 { font-size: var(--step-3); }
  .flow__node { font-size: 0.54rem; }
  .flow__link { flex-basis: 10px; }
  .flow-card { padding: 0.6rem 0.55rem; }
  .stat-strip li { padding: 0.8rem 0.3rem; }
  .stat-strip span { font-size: 0.64rem; }
  .fact-chips { gap: 0.35rem; }
  .fact-chip { padding-inline: 0.45rem; font-size: var(--step--2); }
  .contact-link { gap: var(--space-2); padding: var(--space-3); }
  /* Tighten the sign-off plate on phones: less dead space under the text. */
  .signoff { padding: var(--space-3) var(--space-4) var(--space-2); }
}

/* Keep the sign-off plate clear of the floating + button on narrow viewports
   where the card spans near full width. Wide desktops keep the balanced
   padding-block from sections.css because the card is centred well clear. */
@media (max-width: 1240px) {
  .site-footer { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)); }
}

/* Three compact certification cards stay aligned in one row on tablets too;
   below 641px the shared grid rules stack them in a single column. */
@media (min-width: 641px) and (max-width: 980px) {
  #certifications .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media print {
  .dock, .hero__visual, .flow-card { display: none !important; }
  body { background: #fff; color: #000; }
  .section { padding-block: 1.5rem; break-inside: avoid; }
  .signoff { box-shadow: none; }
}
