
/* ========= Vertex Writers — Responsive Core ========= */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }
img, video, canvas, svg { max-width: 100%; height: auto; display: block; }
iframe { max-width: 100%; }
table { width: 100%; border-collapse: collapse; overflow-x: auto; display: block; }
.container { max-width: 1200px; margin-inline: auto; padding-inline: clamp(12px, 2vw, 24px); }

:root { --gap: clamp(8px, 2vw, 20px); --step0: clamp(14px,1.6vw,16px); --h1: clamp(28px,6vw,48px); --h2: clamp(22px,4.5vw,32px); }
body{ font-size: var(--step0); line-height: 1.6; }
h1{ font-size: var(--h1); line-height: 1.1; }
h2{ font-size: var(--h2); line-height: 1.2; }
.section { padding-block: clamp(32px, 6vw, 96px); }

/* Header/Nav tailored to site's markup */
header .container.nav { display:flex; align-items:center; justify-content:space-between; gap:var(--gap); position:relative; }
header .menu { display:flex; align-items:center; gap:12px; }
header .nav-toggle { display:none; }
@media (max-width: 768px){
  header .nav-toggle{
    display:inline-flex; align-items:center; justify-content:center;
    width:44px; height:44px; border:1px solid rgba(255,255,255,.15);
    border-radius:10px; background:transparent; color:inherit; cursor:pointer;
  }
  header .menu{
    display:none; position:absolute; top:calc(100% + 8px); left:12px; right:12px;
    flex-direction:column; align-items:stretch; background:rgba(15,18,24,.98);
    padding:12px; border-radius:12px; backdrop-filter:blur(6px);
  }
  header.open .menu{ display:flex; }
  header .menu .btn, header .menu .nav-link{ width:100%; text-align:center; }
}

/* Generic helpers */
.grid-auto{ display:grid; gap:var(--gap); grid-template-columns:repeat(auto-fit, minmax(240px,1fr)); }
.hide-mobile{ display:block; } .show-mobile{ display:none; }
@media (max-width:768px){ .hide-mobile{display:none!important} .show-mobile{display:block!important} }

/* Home/Projects hero stack on mobile */
@media (max-width: 768px){
  #hero > .container{ display:block !important; min-height:unset !important; padding-block:24px; }
  #hero .social{ margin-top:12px; display:flex; flex-wrap:wrap; gap:8px; }
  #hero aside.reveal{ margin-top:18px; }
  #hero .cards, #hero [class*="card-grid"], #hero .grid, #hero .grid-auto{
    display:grid !important; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)) !important; gap:10px !important;
  }
  #hero .card{ width:100% !important; margin:0 !important; }
  #hero .card small{ display:block; opacity:.9; margin-top:4px; text-align:center; }
}

/* Services page: sidebar + content stack */
@media (max-width: 992px){
  .section .container[style*="grid-template-columns:300px 1fr"]{ display:block !important; }
  #toc.sidebar{ position:static !important; margin-bottom:14px; }
}

/* Grid/card defaults */
@media (max-width: 768px){
  .why-grid, .grid-auto, .cards, [class*="card-grid"]{
    display:grid !important; grid-template-columns:repeat(auto-fit, minmax(220px,1fr)) !important; gap:12px !important;
  }
}

/* ===== v4: About section + Fast Facts ===== */
@media (max-width: 768px){
  #about .reveal{ display:block !important; }
  #about .card + .card{ margin-top:14px; }
  #about .card h3 + div{
    display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:10px !important;
  }
}
@media (max-width: 420px){
  #about .card h3 + div{ grid-template-columns:1fr !important; }
}
#about .card h3 + div .card + small{ display:block; text-align:center; opacity:.85; margin-top:4px; }

/* ===== v5: Professional Mobile Polish ===== */
/* Wrapping safeguards */
:where(h1,h2,h3,h4,h5,p,li,small,span){ word-wrap:break-word; overflow-wrap:anywhere; hyphens:auto; }
/* Buttons never clip */
@media (max-width: 768px){
  .btn,[class*="btn"]{ width:100%; max-width:100%; white-space:nowrap; }
  .chip{ max-width:100%; }
  .card{ overflow:visible !important; }
}
/* Force any inline multi-column grids to stack */
@media (max-width: 992px){
  [style*="grid-template-columns:1.2fr .8fr"],
  [style*="grid-template-columns:1.1fr .9fr"],
  [style*="grid-template-columns:300px 1fr"],
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns:repeat(5"]{
    display:block !important;
  }
}
/* Pill/metric rows → 2-up on phones, 1-up on very small */
@media (max-width: 768px){
  .pill-row, .metrics, .stats, .result-grid, .steps, .feature-grid, .card-row{
    display:grid !important; grid-template-columns:repeat(2, minmax(0,1fr)) !important; gap:10px !important;
  }
}
@media (max-width: 420px){
  .pill-row, .metrics, .stats, .result-grid, .steps, .feature-grid, .card-row{
    grid-template-columns:1fr !important;
  }
}
/* tighten small-screen padding */
@media (max-width: 576px){
  .card{ padding:12px !important; }
  .cta .btn + .btn{ margin-top:10px; }
}
/* Ensure chips don't overflow */
.chip{ overflow:hidden; text-overflow:ellipsis; }


/* ===== v7 safe fixes (from v6 without quick-nav) ===== */
/* Privacy & Contact: stack hero panels on mobile/tablet */
@media (max-width: 992px){
  body.privacy #hero > .container, #privacy-hero > .container{ display:block !important; }
  body.privacy #hero .card, #privacy-hero .card{ width:100% !important; margin:0 0 12px 0 !important; }
  body.contact #hero > .container, #contact-hero > .container{ display:block !important; }
  body.contact #hero .card, #contact-hero .card{ width:100% !important; margin:0 0 12px 0 !important; }
}
/* Services: tidy spacing */
@media (max-width:1200px){
  #services-hero{ padding-bottom:24px !important; }
  .section + .section{ margin-top:0 !important; }
}
/* Chips wrap */
@media (max-width:768px){
  .chips, .chip-row, .jump, .tags{ display:flex; flex-wrap:wrap; gap:8px; }
  .chip, .tag{ max-width:100%; }
  .bullets, .list, ul{ padding-left:18px; }
}
/* Projects: prevent scroll trap from fixed backgrounds */
#hero[style*="position: fixed"], .bg-fixed, .bg-overlay{ position: static !important; }
.overlay, .bg-overlay{ pointer-events:none; }


/* v7.2: conservative services tidy (no layout changes) */
body.services .section:last-of-type{margin-bottom:0!important;padding-bottom:24px!important}


/* ===== v7.3 Services: bring back first Service ("Book Covers") & kill blank gap ===== */
@media (max-width: 992px){
  /* Ensure core service sections are visible on mobile */
  #book-covers, .book-covers, section[id*="book-covers"]{
    display:block !important; visibility:visible !important; height:auto !important; opacity:1 !important;
  }
  /* Generic service section visibility */
  .services .service, .services .service-section, #services .service, #services .service-section{
    display:block !important; height:auto !important; overflow:visible !important;
  }
  /* If any spacer sits between the Explore block and first service, remove it */
  body.services .spacer, body.services .space, body.services .divider, 
  body.services .after-explore, body.services .after-explore-spacer{
    display:none !important; height:0 !important; min-height:0 !important; padding:0 !important; margin:0 !important;
  }
  /* Sections made of only background art shouldn't create huge scroll on mobile */
  body.services section[style*="position:fixed"],
  body.services section[style*="background-attachment:fixed"],
  body.services .bg-fixed{ position:static !important; background-attachment: scroll !important; }
}
/* Keep last section tight */
body.services .section:last-of-type{ margin-bottom:0 !important; padding-bottom:24px !important; }



/* ===== v7.4 Projects page — mobile responsiveness & smoothness ===== */
body.projects .bg-fixed, body.projects [style*="position:fixed"], 
body.projects [style*="background-attachment:fixed"]{
  position: static !important; background-attachment: scroll !important;
}
/* kill sticky on phones to prevent stutter */
@media (max-width: 992px){
  body.projects [style*="position:sticky"], body.projects .sticky{
    position: static !important; top: auto !important;
  }
  /* stack any inline multi-column grids */
  body.projects [style*="grid-template-columns:"],
  body.projects .grid, body.projects .cards, body.projects .gallery, 
  body.projects .case-grid, body.projects .row{
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* images/videos scale */
  body.projects img, body.projects video, body.projects canvas{
    max-width: 100% !important; height: auto !important;
  }
  /* trim oversized sections */
  body.projects section{ min-height: auto !important; height: auto !important; }
}
/* don't let galleries overflow horizontally */
body.projects .gallery, body.projects .case-grid{ overflow-x: hidden; }



/* ===== v7.5 Projects — HARD mobile fixes (anti-freeze / anti-parallax) ===== */
@media (max-width: 992px){
  body.projects, body.projects html {
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  /* kill fixed/sticky/parallax anywhere inside projects */
  body.projects *[style*="position:fixed"],
  body.projects .fixed, 
  body.projects [style*="position: sticky"],
  body.projects .sticky,
  body.projects [style*="background-attachment:fixed"],
  body.projects .bg-fixed,
  body.projects [data-parallax], body.projects .parallax {
    position: static !important;
    top: auto !important; left: auto !important; right: auto !important; bottom: auto !important;
    background-attachment: scroll !important;
    transform: none !important;
    will-change: auto !important;
  }
  /* neutralize any overflow traps */
  body.projects *, body.projects section, body.projects .gallery, body.projects .case-grid {
    overflow: visible !important;
  }
  /* force single-column flow for any multi-col layouts */
  body.projects [style*="grid-template-columns"], 
  body.projects .grid, body.projects .cards, body.projects .gallery, body.projects .case-grid, body.projects .row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* media scaling */
  body.projects img, body.projects video, body.projects canvas, body.projects iframe {
    max-width: 100% !important; height: auto !important; display: block;
  }
}



/* ===== v7.6 Projects — ultra hardening (mobile) ===== */
@media (max-width: 992px){
  html, body { overflow: auto !important; height: auto !important; }
  body.projects * { will-change: auto !important; }
  body.projects .overlay, body.projects .bg-overlay { pointer-events: none !important; }
  /* Force hero + its parents to be static */
  body.projects #hero, body.projects #hero * {
    position: static !important;
    transform: none !important;
    background-attachment: scroll !important;
  }
  /* Any element trying to fix itself */
  body.projects [style*="fixed"], body.projects .fixed { position: static !important; }
  body.projects [style*="sticky"], body.projects .sticky { position: static !important; top: auto !important; }
  /* Neutralize full-viewport sections */
  body.projects [style*="100vh"], body.projects [style*="min-height:100vh"] {
    min-height: auto !important; height: auto !important;
  }
  /* Avoid accidental horizontal scroll */
  body.projects { overflow-x: hidden !important; }
}



/* ===== v7.7 Contact page — mobile responsiveness only (scoped) ===== */
@media (max-width: 992px){
  /* Stack the hero/content on mobile */
  body.contact #hero > .container,
  body.contact #contact-hero > .container{
    display: block !important;
    padding-block: 20px;
  }
  /* Any two-column grids inside contact should stack */
  body.contact .grid, 
  body.contact .row, 
  body.contact .cards, 
  body.contact [style*="grid-template-columns"]{
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* Form usability */
  body.contact form{
    display: grid;
    gap: 12px;
  }
  body.contact input, 
  body.contact select, 
  body.contact textarea, 
  body.contact button{
    width: 100% !important;
    max-width: 100% !important;
  }
  body.contact .btn, 
  body.contact [class*="btn"]{ 
    width: 100% !important;
  }
  /* Media scaling */
  body.contact img, 
  body.contact iframe{
    max-width: 100% !important;
    height: auto !important;
    display: block;
  }
  /* Kill sticky/fixed that can break mobile layout */
  body.contact [style*="position:sticky"], 
  body.contact .sticky,
  body.contact [style*="position:fixed"], 
  body.contact .fixed{
    position: static !important;
    top: auto !important;
  }
  /* Trim oversized sections */
  body.contact section{ min-height: auto !important; height: auto !important; }
  /* Comfortable side padding for narrow phones */
  body.contact .section, 
  body.contact .container{ padding-inline: 16px; }
}


/* v7.8: FAQs minimal polish */
body.faqs details.faq{border-bottom:1px solid rgba(255,255,255,.08); padding:8px 0}
body.faqs details.faq summary{cursor:pointer}


/* ===== v7.9 Privacy page — mobile responsiveness (scoped) ===== */
@media (max-width: 992px){
  /* stack hero left/right columns */
  body.privacy #hero > .container,
  body.privacy #privacy-hero > .container{
    display: block !important;
    padding-block: 20px;
  }
  /* force any grid/row into single column */
  body.privacy .grid, 
  body.privacy .row,
  body.privacy .cards,
  body.privacy [style*="grid-template-columns"]{
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* text blocks and cards spacing */
  body.privacy .section, 
  body.privacy .container{ padding-inline: 16px; }
  /* prevent nav overlap on small screens */
  body.privacy header, body.privacy nav{ position: relative; z-index: 20; }
  /* disable sticky/fixed on privacy page to avoid layout break */
  body.privacy [style*="position:sticky"], 
  body.privacy .sticky,
  body.privacy [style*="position:fixed"], 
  body.privacy .fixed{
    position: static !important; top: auto !important;
  }
  /* trim any 100vh/min-height locks */
  body.privacy [style*="100vh"], body.privacy [style*="min-height:100vh"]{
    min-height: auto !important; height: auto !important;
  }
  /* scale media cleanly */
  body.privacy img, body.privacy iframe{ max-width:100% !important; height:auto !important; display:block; }
}



/* ===== v8: Footer brand-logos mobile improvements (all pages) ===== */
footer .brand-logos, .footer-logos {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: center; align-items: center;
  overflow: hidden;
}
footer .brand-logos img, .footer-logos img {
  max-width: 70px; height: auto; object-fit: contain; flex: 0 0 auto;
  filter: none;
}
@media (max-width: 480px){
  footer .brand-logos img, .footer-logos img { max-width: 60px; }
}
/* guard: no horizontal scroll on narrow screens */
html, body { overflow-x: hidden; }



/* ===== v8.1: Footer logos — prevent side cutting & keep inside viewport ===== */
footer{ padding-inline: 16px; }
footer .brand-logos, .footer-logos{
  justify-content: center; flex-wrap: wrap; gap: 14px;
  margin-inline: auto;
}
footer .brand-logos img, .footer-logos img{
  max-width: 56px; height: auto; object-fit: contain;
}
@media (min-width: 480px){
  footer .brand-logos img, .footer-logos img{ max-width: 64px; }
}
/* make sure nothing overflows horizontally */
html, body, footer{ overflow-x: hidden; }



/* FINAL: Footer & overflow guards */
footer { padding-inline: 16px; }
footer .brand-logos, .footer-logos {
  display: flex; flex-wrap: wrap; gap: 14px;
  justify-content: center; align-items: center;
}
footer .brand-logos img, .footer-logos img {
  max-width: 56px; height: auto; object-fit: contain;
}
@media (min-width: 480px){
  footer .brand-logos img, .footer-logos img { max-width: 64px; }
}
html, body, footer { overflow-x: hidden; }



/* ==== PATCH: Mobile nav fix (Oct 2025) ==== */
@media (max-width: 768px){
  header { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; }
  body.nav-open { overflow: hidden; } /* lock background scroll */
  header .container.nav { min-height: 64px; }
  header .nav-toggle{
    position: relative;
    z-index: 10001;
    display: inline-flex; align-items:center; justify-content:center;
    width: 42px; height: 42px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,.18); background: rgba(14,18,26,.5);
    backdrop-filter: blur(6px);
    color:#fff; font-size: 24px; line-height: 1;
  }
  header .menu{
    position: fixed;
    top: 64px; left: 12px; right: 12px;
    display: none;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border-radius: 18px;
    background: rgba(10,12,18,.96);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 10px 30px rgba(0,0,0,.4);
    z-index: 10000;
    pointer-events: auto;
  }
  header.open .menu{ display: flex; }
  header .menu a, header .menu button, header .menu .nav-link{
    pointer-events: auto !important;
    position: relative;
    z-index: 10002;
  }
  /* prevent any hero/slider overlay from blocking clicks */
  .hero, .hero * { pointer-events: auto; }
}


/* PATCH: Hide intro overlay remnants */
.title, .desc, .cta, .hint { display: none !important; }

/* ==== MOBILE FIX FOR 3D BOOK CAROUSEL ==== */
@media (max-width: 768px) {
  .carousel, .book-carousel, .book-container {
    transform: scale(0.8) translateY(40px) !important;
    transform-origin: center center !important;
    perspective: 800px !important;
    width: 100% !important;
    margin: 0 auto !important;
    overflow: visible !important;
  }

  .book {
    transform: scale(0.9) !important;
    margin: 0 10px !important;
  }

  canvas, .background-stars {
    transform: scale(1) !important;
  }

  .logo-section img {
    width: 130px !important;
    margin-bottom: 8px !important;
  }

  .carousel-title, .hero-text {
    font-size: 14px !important;
    text-align: center !important;
    padding: 10px 20px !important;
  }
}
/* ==== FIX v2: Proper Mobile Responsive for Book Carousel ==== */
@media (max-width: 768px) {
  #covers .book-covers {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 14px !important;
    transform: scale(0.8) translateY(20px) !important;
    transform-origin: center center !important;
    perspective: 900px !important;
  }

  #covers .book-covers .cover {
    flex: 0 1 calc(50% - 10px) !important;
    max-width: calc(50% - 10px) !important;
    text-align: center !important;
    transform: translateZ(-60px) scale(0.95) !important;
    transition: transform 0.3s ease-in-out;
  }

  #covers .book-covers .cover img {
    width: 100% !important;
    height: auto !important;
    border-radius: 10px !important;
    object-fit: cover !important;
  }

  /* spacing fix below */
  #covers .reveal {
    margin-bottom: 10px !important;
  }
}
