/* Mobile hardening and narrow-screen layout. */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body { overflow-x: clip; }

.site-mark {
  min-width: 0;
  max-width: 100%;
}

.site-mark > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-toggle {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

.post-content,
.email-embed,
.post-list-copy,
.writing-index-root {
  min-width: 0;
}

.post-content a,
.email-embed a {
  overflow-wrap: anywhere;
}

.post-content pre,
.post-content table {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.post-content table { display: block; }
.post-content code,
.post-content pre { font-size: .86em; }

@media (max-width: 760px) {
  .shell,
  .shell-narrow {
    width: min(calc(100% - 28px), var(--shell));
  }

  .header-inner {
    min-height: 55px;
    gap: 12px;
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .site-mark { font-size: 10px; }

  .nav-toggle {
    display: block;
    padding: 10px 0 10px 14px;
  }

  .site-nav {
    position: absolute;
    left: 14px;
    right: 14px;
    top: 54px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-height: calc(100dvh - 70px);
    overflow-y: auto;
    background: #151613;
    border: 1px solid var(--line);
    box-shadow: 0 18px 45px rgba(0,0,0,.3);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .site-nav.is-open { display: flex; }

  .site-nav a {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    -webkit-tap-highlight-color: transparent;
  }

  .site-nav a:last-child { border-bottom: 0; }
  .nav-toggle { -webkit-tap-highlight-color: transparent; }

  body.nav-open {
    overflow: hidden;
    touch-action: none;
  }

  .hero { padding: 43px 0 28px; }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hero h1 {
    max-width: 540px;
    font-size: clamp(34px, 10vw, 42px);
    line-height: 1.02;
  }

  .hero-note {
    max-width: 30rem;
    font-size: 13.5px;
  }

  .section { padding: 6px 0 52px; }

  .writing-controls {
    align-items: stretch;
    flex-direction: column;
    gap: 3px;
    padding: 7px 0 8px;
  }

  .writing-search { width: 100%; }

  .writing-search input {
    width: 100%;
    min-height: 38px;
    font-size: 10px;
  }

  .writing-controls-meta {
    justify-content: space-between;
    min-height: 32px;
  }

  .writing-sort {
    min-height: 32px;
    padding: 6px 0;
  }

  .post-list-link {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 12px;
    padding: 19px 0 20px;
  }

  .post-list-date {
    grid-column: 1;
    padding-top: 0;
    font-size: 9px;
  }

  .post-list-length {
    grid-column: 2;
    grid-row: 1;
    padding-top: 0;
    font-size: 9px;
  }

  .post-list-copy { grid-column: 1 / -1; }

  .post-list-title {
    font-size: clamp(24px, 7.5vw, 29px);
  }

  .post-list-excerpt {
    margin-top: 5px;
    font-size: 13px;
  }

  .archive-intro { padding: 44px 0 18px; }
  .archive-intro h1 { font-size: 36px; }

  .post-header {
    padding-top: 46px;
    padding-bottom: 26px;
  }

  .post-header h1 {
    font-size: clamp(34px, 10.4vw, 42px);
  }

  .post-deck { font-size: 16.5px; }

  .post-content {
    font-size: 18px;
    line-height: 1.72;
  }

  .post-content img {
    margin-left: auto;
    margin-right: auto;
  }

  .post-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  .post-nav a {
    display: block;
    min-height: 44px;
    padding: 12px 0;
  }

  .footer-inner {
    flex-direction: column;
    gap: 5px;
  }

  .email-embed { overflow-wrap: break-word; }
}

@media (max-width: 420px) {
  .shell,
  .shell-narrow {
    width: min(calc(100% - 24px), var(--shell));
  }

  .hero {
    padding-top: 38px;
    padding-bottom: 24px;
  }

  .hero h1 { font-size: clamp(32px, 9.8vw, 38px); }

  .post-header { padding-top: 40px; }
  .post-header h1 { font-size: clamp(32px, 10vw, 38px); }
  .post-content { font-size: 17.5px; }

  .email-embed {
    padding: 18px 14px;
    font-size: 14px;
  }

  .footer-inner {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 340px) {
  .site-mark-dot { display: none; }
  .site-mark { font-size: 9px; }
  .hero h1 { font-size: 31px; }
  .post-header h1 { font-size: 31px; }
  .post-content { font-size: 17px; }
}
