/* ============================================================
   ScribeNex — Responsive hardening layer (public website)
   Loaded LAST, after global.css + components.css, on every
   public page. Purpose: guarantee a flawless layout on every
   device (360 → 1920+) with zero button overlap and zero
   horizontal overflow.
   Breakpoints: 1100 / 1024 / 900 / 768 / 640 / 520 / 400 / 340
   ============================================================ */

/* ------------------------------------------------------------
   1) GLOBAL SAFETY
   ------------------------------------------------------------ */
html {
  /* fallback, then clip (not hidden) so position:sticky headers keep working */
  overflow-x: hidden;
  overflow-x: clip;
  scroll-padding-top: calc(var(--header-h) + 10px);
}
body { overflow-x: hidden; overflow-x: clip; }

/* never let media or long strings punch through the viewport */
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }
h1, h2, h3, h4, h5, h6 { overflow-wrap: anywhere; }
.id-row strong, .track-id-display, .cred-box .cb-v, .spec-table td, .legal-body, .article-body p, .track-ids span { overflow-wrap: anywhere; }

/* the page scale: small devices get a touch more density */
@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .container-narrow { padding: 0 16px; }
}

/* ------------------------------------------------------------
   2) HEADER  (fixes the sitewide 19px overflow)
   ------------------------------------------------------------ */
.site-header .container { gap: 14px; min-width: 0; }
.brand { min-width: 0; }
.brand > span, .brand { white-space: nowrap; }
.brand img { flex: none; }

@media (max-width: 640px) {
  .site-header .container { gap: 8px; padding-left: 14px; padding-right: 14px; }
  .brand { font-size: 1.06rem; gap: 8px; }
  .brand small { display: none; }
  .brand img { width: 38px !important; height: 38px !important; }
  .header-actions { gap: 6px; }
  .header-actions .btn.keep-mobile { padding: 8px 12px; font-size: 0.82rem; gap: 6px; }
  .nav-toggle { padding: 6px; font-size: 1.3rem; }
}
@media (max-width: 520px) {
  /* keep the bell/icon actions but drop the text CTA into the drawer */
  .header-actions .btn.keep-mobile { display: none; }
}
@media (max-width: 400px) {
  .brand { font-size: 1rem; }
  .brand img { width: 34px !important; height: 34px !important; }
}

/* ------------------------------------------------------------
   3) ANNOUNCEMENT BAR
   ------------------------------------------------------------ */
@media (max-width: 640px) {
  .announce-bar { font-size: 0.78rem; padding: 8px 12px; line-height: 1.5; }
  .announce-bar a { display: inline-block; margin-left: 4px; }
}

/* ------------------------------------------------------------
   4) HERO  (fixes the 34px grid blowout)
   ------------------------------------------------------------ */
/* grid/flex children must be allowed to shrink below min-content */
.hero .container { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); }
.hero .container > * { min-width: 0; }
.hero-copy { min-width: 0; }
.hero h1 { overflow-wrap: anywhere; }
.hero-sub { max-width: 100%; }
.hero-spotlight { padding: clamp(20px, 4.5vw, 30px); min-width: 0; }
.hero-spotlight h3 { overflow-wrap: anywhere; }

@media (max-width: 1024px) {
  .hero .container { grid-template-columns: minmax(0, 1fr); gap: 40px; }
}
@media (max-width: 640px) {
  .hero { padding: 56px 0 68px; }
  .hero-kicker { font-size: 0.72rem; padding: 6px 12px; margin-bottom: 18px; }
  .hero-sub { font-size: 1.02rem; margin-bottom: 26px; }
  .hero-ctas { margin-bottom: 30px; gap: 10px; }
  .hero-stats { gap: 22px; }
  .hero-stat .num { font-size: 1.55rem; }
}
@media (max-width: 480px) {
  .hero-ctas { flex-direction: column; align-items: stretch; }
  .hero-ctas .btn { width: 100%; }
}

/* ------------------------------------------------------------
   5) COUNTDOWN  (was forcing a 370px track)
   ------------------------------------------------------------ */
.countdown { flex-wrap: wrap; }
@media (max-width: 640px) {
  .countdown { gap: 8px; justify-content: flex-start; }
  .countdown .cd-box { min-width: 0; flex: 1 1 calc(25% - 8px); padding: 10px 4px; }
  .countdown .cd-num { font-size: 1.35rem; }
  .countdown .cd-label { font-size: 0.6rem; letter-spacing: 0.06em; }
  .hero-spotlight .countdown { justify-content: center; }
}
@media (max-width: 380px) {
  .countdown .cd-box { flex-basis: calc(50% - 8px); }
}

/* ------------------------------------------------------------
   6) BUTTONS  (never overlap; stack & stretch when tight)
   ------------------------------------------------------------ */
.btn { max-width: 100%; }
.btn-row, .cta-actions, .hero-ctas, .success-actions, .share-row, .socials-row,
.input-btn-row, .drawer-foot, .modal-actions, .pay-actions { flex-wrap: wrap; }

@media (max-width: 560px) {
  .btn { white-space: normal; }
  .btn-lg { padding: 14px 22px; font-size: 1rem; }
  .btn-row > .btn, .cta-actions > .btn, .success-actions > .btn, .pay-actions > .btn { flex: 1 1 auto; }
}
@media (max-width: 480px) {
  .btn-row > .btn, .cta-actions > .btn, .success-actions > .btn,
  .input-btn-row > .btn, .drawer-foot > .btn, .modal-actions > .btn { width: 100%; }
  .sticky-cta-inner .btn { flex: 1 1 100%; }
}

/* ------------------------------------------------------------
   7) GRIDS
   ------------------------------------------------------------ */
.grid-2, .grid-3, .grid-4 { min-width: 0; }
.grid > *, .grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 22px; }
}

/* ------------------------------------------------------------
   8) TWO-COLUMN PAGE SPLITS / DETAIL LAYOUTS
   ------------------------------------------------------------ */
.detail-layout, .contact-layout, .founder-layout, .reg-layout, .vol-layout,
.split, .unspoken-feature, .founder-hero, .detail-hero .container,
.vol-hero-grid, .reg-layout { min-width: 0; }
.detail-layout > *, .contact-layout > *, .founder-layout > *,
.reg-layout > *, .vol-layout > *, .split > *, .detail-hero .container > * { min-width: 0; }

@media (max-width: 900px) {
  .detail-layout, .contact-layout, .founder-layout, .reg-layout, .vol-layout,
  .split, .unspoken-feature, .founder-hero, .detail-hero .container, .vol-hero-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }
  .detail-cover, .founder-card, .vol-side, .reg-summary, .sticky-side { position: static; top: auto; }
  .detail-cover .book-cover { max-width: 260px; margin: 0 auto; }
  .founder-photo { max-width: 300px; }
}

/* ------------------------------------------------------------
   9) STORE TOOLBAR / FILTERS / BOOK CARDS
   ------------------------------------------------------------ */
@media (max-width: 640px) {
  .store-toolbar { gap: 12px; }
  .store-toolbar .search-box, .search-inline { width: 100%; min-width: 0; }
  .store-filters { width: 100%; }
  .store-filters select, .store-filters .form-control { flex: 1 1 calc(50% - 5px); min-width: 0; width: auto; }
  .store-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
  .book-card-body { padding: 12px 14px; }
  .book-card-actions { flex-wrap: wrap; }
  .book-card-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 420px) {
  .store-grid { grid-template-columns: minmax(0, 1fr); }
  .store-filters select, .store-filters .form-control { flex-basis: 100%; }
}

/* ------------------------------------------------------------
   10) TABLES  (scroll instead of overflow)
   ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 640px) {
  .table-wrap { border-radius: var(--radius-sm); }
  table.data-table, table.table { min-width: 560px; }
}

/* ------------------------------------------------------------
   11) FORMS
   ------------------------------------------------------------ */
.form-grid-2, .form-grid-3 { min-width: 0; }
@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-section { padding: 22px 18px; }
  .contact-form-wrap, .reg-section { padding: 22px 18px; }
  .id-row { flex-wrap: wrap; }
  .id-row span { min-width: 100%; color: var(--gray-400); }
}

/* ------------------------------------------------------------
   12) CONTENT BLOCKS, CTA BANDS, QUOTES
   ------------------------------------------------------------ */
.cta-band { padding: clamp(28px, 5vw, 56px); }
.cta-band::after { font-size: clamp(6rem, 18vw, 12rem); }
@media (max-width: 640px) {
  .cta-band { flex-direction: column; align-items: flex-start; gap: 22px; }
  .cta-band .cta-actions { width: 100%; }
  .cta-band .cta-actions .btn { flex: 1 1 100%; }
  .quote-block, .founder-quote, .post-body blockquote { padding: 20px 20px; font-size: 1.1rem; }
  .author-box { flex-direction: column; align-items: flex-start; }
  .article-body, .post-body { font-size: 1rem; }
  .section-head { margin-bottom: 34px; }
}
@media (max-width: 480px) {
  .section { padding: 52px 0; }
  .section--tight { padding: 40px 0; }
  .page-hero { padding: 48px 0 40px; }
  .page-hero::after { font-size: 9rem; right: -4%; }
}

/* ------------------------------------------------------------
   13) FOOTER
   ------------------------------------------------------------ */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px; }
}
@media (max-width: 640px) {
  .site-footer { padding-top: 50px; }
  .footer-grid { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .footer-brand p { max-width: 100%; }
  .footer-social { flex-wrap: wrap; }
  .footer-bottom { flex-direction: column; text-align: center; gap: 12px; }
  .footer-bottom > div { justify-content: center; }
  .footer-contact-line { overflow-wrap: anywhere; }
}

/* ------------------------------------------------------------
   14) STICKY CTA + FLOATING ELEMENTS
   ------------------------------------------------------------ */
.sticky-cta { padding: 10px 16px; }
.sticky-cta-inner { gap: 10px; }
@media (max-width: 640px) {
  .sticky-cta { flex-wrap: wrap; }
  .sticky-cta .sc-info { font-size: 0.82rem; width: 100%; }
  .sticky-cta-inner .btn { flex: 1 1 auto; }
}

/* ------------------------------------------------------------
   15) MODALS / DRAWERS / POPUPS
   ------------------------------------------------------------ */
.drawer, .modal-card, .unspoken-modal { max-width: 100%; }
@media (max-width: 640px) {
  .unspoken-modal-body { padding: 32px 16px 22px; }
  .unspoken-modal-actions .btn { flex: 1 1 100%; }
  .unspoken-feature-aside { padding: 18px 10px; }
  .modal-card, .unspoken-popup .unspoken-modal { width: calc(100vw - 24px); }
}

/* ------------------------------------------------------------
   16) TYPOGRAPHY SCALE ON SMALL SCREENS
   ------------------------------------------------------------ */
@media (max-width: 400px) {
  h1 { font-size: clamp(1.75rem, 8vw, 2.2rem); }
  h2 { font-size: clamp(1.45rem, 6.4vw, 1.9rem); }
  .hero h1 { font-size: clamp(1.85rem, 8.5vw, 2.3rem); }
  .price-big { font-size: 1.9rem; }
}

/* ------------------------------------------------------------
   17) KILL ACCIDENTAL HORIZONTAL OVERFLOW FROM SECTIONS
   ------------------------------------------------------------ */
section, .section, main, header, footer { max-width: 100%; }
[style*="width:100vw"], [style*="100vw"] { max-width: 100%; }
