/* ============================================================
   Mobile — responsive overrides for editorial-personal theme
   All mobile-specific fixes are isolated here.

   Breakpoints:
     768px  — tablet / large phone (landscape)
     480px  — small phone (portrait)
   ============================================================ */

/* ——— Masthead: hide on mobile to reclaim vertical space ——— */
@media (max-width: 768px) {
  .masthead { display: none; }
}

/* ================================================================
   NAV — hamburger menu for mobile
   ================================================================
   Structure:
     .nav
       .wrap.nav-row
         a.nav-brand
         div.nav-links         ← hidden on mobile, revealed when open
         div.nav-tools
           button.nav-hamburger ← new, visible only on mobile
           (existing icon-btns)
   ================================================================ */

/* Hamburger button — hidden on desktop, shown on mobile */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  padding: 7px 8px;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
  transform-origin: center;
}

/* Hamburger "open" state — transforms into × */
.nav-hamburger.open span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.nav-hamburger.open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.nav-hamburger.open span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

@media (max-width: 768px) {
  /* Show hamburger */
  .nav-hamburger { display: flex; }

  /* Hide ⌘K search button — keyboard shortcut is meaningless on touch */
  .kbd-btn { display: none; }

  /* Nav row: allow wrapping so the mobile menu flows below the row */
  .nav-row {
    flex-wrap: wrap;
    height: auto;
    min-height: 60px;
    padding-top: 16px;
    padding-bottom: 16px;
    row-gap: 0;
  }

  /* nav-links: hidden by default on mobile */
  .nav-links {
    display: none;
    order: 10;
    width: 100%;
    flex-direction: column;
    gap: 0;
    padding: 8px 0 4px;
    border-top: 1px solid var(--rule);
    margin-top: 8px;
  }
  /* Show when .open is toggled by JS */
  .nav-links.open { display: flex; }

  .nav-links a {
    font-size: 14px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--rule);
  }
  .nav-links a:last-child { border-bottom: none; }

  /* ---- General layout ---- */
  .wrap { padding: 0 16px; }

  /* ---- Hero section ---- */
  .hero { padding: 36px 0 56px; }

  /* Restack hero-side to single column on small screens */
  .hero-side {
    grid-template-columns: 1fr !important;
    gap: 16px;
    align-items: flex-start;
  }
  .hero-portrait {
    /* Show portrait as a horizontal strip instead of a tall portrait */
    aspect-ratio: 16 / 7;
    max-height: 200px;
  }
  .hero-portrait .pm { font-size: 72px; }

  /* hero meta: keep 2 columns but reduce gap */
  .hero-meta { gap: 14px; }

  /* ---- Sections ---- */
  .sec { padding: calc(72px * var(--rhythm)) 0; }
  .sec-num { font-size: 80px; top: 20px; right: 16px; }

  /* ---- Featured article ---- */
  .featured-art { min-height: 180px; }

  /* ---- Article list (homepage) ---- */
  /* Drop the date column on very narrow screens: idx + content only */
  .article {
    grid-template-columns: 36px 1fr;
    gap: 12px;
  }
  .article .a-date { display: none; }
  /* tag row already hidden at 1000px */

  /* ---- Pull quote ---- */
  .pullquote { padding: 70px 0; }
  .pullquote .mark { font-size: 70px; }

  /* ---- Skills ---- */
  .skills { grid-template-columns: 1fr 1fr; gap: 20px; }

  /* ---- Contact ---- */
  .contact { padding: 72px 0 40px; }
  .contact-links a { font-size: 19px; padding: 12px 0; }

  /* ---- Footer ---- */
  .foot { flex-direction: column; gap: 6px; text-align: center; }

  /* ---- Tweaks panel: anchor to bottom on mobile ---- */
  .tweaks {
    right: 12px;
    top: auto;
    bottom: 16px;
    width: calc(100vw - 24px);
    max-width: 320px;
  }

  /* ================================================================
     SINGLE POST — mobile fixes
     ================================================================ */
  .a-hero { padding: 36px 0 28px; }
  .a-hero-numeral { font-size: 140px; top: 20px; right: 16px; }
  .a-breadcrumb { font-size: 10px; }

  /* Blockquote negative margin causes horizontal overflow — remove it */
  .a-body blockquote { margin-left: 0; margin-right: 0; }

  .a-byline { flex-wrap: wrap; gap: 12px; margin-top: 28px; }

  .a-body-wrap { padding: 48px 0 48px; }

  /* End signature */
  .a-end { margin: 40px 0 0; }

  /* tail share row */
  .a-tail { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* Author grid */
  .a-author { padding: 40px 0; }
  .a-author-grid { gap: 16px; }
  .a-author-cta { display: none; }

  /* Read next */
  .a-readnext { padding: 56px 0; }

  /* ================================================================
     ARCHIVE — mobile fixes
     ================================================================ */
  .arc-head { padding: 48px 0 36px; }
  .arc-head-num { font-size: 140px; right: 16px; }
  .arc-filter { top: 60px; }

  /* Drop date column: idx + content only */
  .arc-item {
    grid-template-columns: 36px 1fr;
    gap: 12px;
  }
  .arc-item-date { display: none; }
  /* meta already hidden at 900px */

  .arc-list { padding: 40px 0 60px; }
  .arc-year { margin: 40px 0 20px; }
  .arc-year-num { font-size: 36px; }

  /* ================================================================
     WORK DETAIL — extra small screen
     ================================================================ */
  .pd-container { padding: 20px 14px 56px; }
}

/* ================================================================
   SMALL PHONE — extra breakpoint for ≤ 480px
   ================================================================ */
@media (max-width: 480px) {
  .wrap { padding: 0 14px; }

  /* ---- Nav brand: hide EN tagline to save space ---- */
  .nav-brand .en { display: none; }
  .nav-brand { font-size: 18px; }

  /* ---- Hero ---- */
  .hero { padding: 28px 0 48px; }
  .hero-title { font-size: clamp(34px, 9vw, 48px) !important; }
  .hero-desc { font-size: 15px; }
  .hero-meta { grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; }
  .hero-meta-item .v { font-size: 13px; }
  .hero-portrait { max-height: 160px; }
  .hero-portrait .pm { font-size: 56px; }

  /* ---- Sections ---- */
  .sec-title { font-size: 30px; }
  .sec { padding: calc(56px * var(--rhythm)) 0; }

  /* ---- Skills: single column on tiny screens ---- */
  .skills { grid-template-columns: 1fr; }

  /* ---- Featured article ---- */
  .featured-art { min-height: 140px; }
  .f-title { font-size: clamp(22px, 6vw, 34px); }
  .f-excerpt { font-size: 14px; }
  .f-excerpt::first-letter { font-size: 2.2em; }

  /* ---- Pull quote ---- */
  .pullquote { padding: 56px 0; }
  .pullquote blockquote { font-size: clamp(22px, 6vw, 34px); }
  .pullquote .mark { font-size: 56px; }

  /* ---- Works ---- */
  .work { padding: 18px 16px; min-height: 220px; }
  .w-name { font-size: 20px; }

  /* ---- Docs ---- */
  .doc { grid-template-columns: 40px 1fr; gap: 14px; padding: 20px 16px; }
  .doc-updated { display: none; }
  .doc-title { font-size: 16px; }
  .doc-num { font-size: 18px; }

  /* ---- Contact ---- */
  .contact h2 { font-size: clamp(36px, 10vw, 56px); }
  .contact-links a { font-size: 17px; }

  /* ---- Marquee ---- */
  .marquee-track span { font-size: 20px; }

  /* ================================================================
     SINGLE POST — small phone
     ================================================================ */
  .a-hero { padding: 24px 0 20px; }
  .a-headline { font-size: clamp(28px, 8vw, 44px) !important; }
  .a-deck { font-size: 16px; }
  .a-body { font-size: 16px; line-height: 1.7; }
  .a-body h1 { font-size: 28px; }
  .a-body h2 { font-size: 22px; }
  .a-body h3 { font-size: 18px; }
  .a-body blockquote {
    font-size: 20px;
    padding: 8px 0 8px 20px;
  }
  .a-body pre { padding: 14px 16px; font-size: 12px; }
  .a-body-wrap { padding: 32px 0 40px; }
  .a-cover { aspect-ratio: 4/3; }
  .rn { padding: 18px; }
  .rn-title { font-size: 18px; }
  .a-author-avatar { width: 70px; height: 70px; font-size: 32px; }
  .a-author-text h3 { font-size: 20px; }

  /* ================================================================
     ARCHIVE — small phone
     ================================================================ */
  .arc-title { font-size: clamp(32px, 9vw, 48px) !important; }
  .arc-desc { font-size: 15px; }
  .arc-item-title { font-size: 19px; }
  .arc-item-excerpt { font-size: 13px; }
  .arc-head { padding: 32px 0 28px; }
  .arc-filter-row { gap: 12px; }
  .arc-controls { display: none; }

  /* ================================================================
     LIBRARY — small phone
     ================================================================ */
  .lib-content-wrap { padding: 24px 14px 56px; }
  .lib-doc-title { font-size: 22px; }
  .lib-body { font-size: 14px; }
}
