/* Armando Betancourt — responsive + performance hardening
   Loaded last so this file is the single place for viewport-specific corrections. */

html,body{max-width:100%;overflow-x:hidden}
main,.tab-panel,.section,.hero-grid>*,
.surname-keyboard-section>*,
.portfolio-section-heading>*,
.armando-system-heading>*{min-width:0}
img,svg,video,canvas{max-width:100%}

/* HERO / signature lockup
   The previous 60vw cap made the name feel like a narrow box floating on the left
   of ultrawide screens. Let the lockup use the composition instead of a fixed island. */
#view-home .hero-nameplate{
  left:var(--pad);
  right:var(--pad);
  width:auto;
  max-width:none;
  bottom:clamp(24px,3.8vh,54px);
  font-size:clamp(64px,10.2vw,190px);
  line-height:.76;
  letter-spacing:-.07em;
}
#view-home .hero-nameplate .surname{
  margin-left:clamp(22px,5.4vw,108px);
}

/* Standalone campaign band: it belongs below the hero, but must be truly
   full-bleed. Do not relatively offset the whole block by --pad; only pad
   the lettering inside it. */
#view-home > .hero-nameplate{
  position:relative;
  inset:auto;
  width:100%;
  max-width:none;
  margin:0;
  box-sizing:border-box;
  padding:26px var(--pad) 42px;
  font-size:clamp(76px,10.8vw,185px);
  line-height:.74;
  letter-spacing:-.07em;
}
#view-home > .hero-nameplate .surname{
  margin-left:clamp(0px,5vw,85px);
}

/* BETANCOURT keyboard
   Give the Spanish headline enough real width, and let every key column shrink
   fluidly before we stack the composition. */
.surname-keyboard-section{
  grid-template-columns:minmax(0,.82fr) minmax(580px,1.18fr);
  gap:clamp(30px,4vw,68px);
}
.surname-keyboard-copy{max-width:none;min-width:0}
.surname-keyboard-copy h2{
  max-width:100%;
  font-size:clamp(54px,5.55vw,102px);
  line-height:.82;
}
html[lang="es"] .surname-keyboard-copy h2{
  font-size:clamp(52px,5vw,92px);
  letter-spacing:-.06em;
}
.surname-keyboard-shell{min-width:0;width:100%}
.surname-keyboard-keys{
  grid-template-columns:repeat(5,minmax(0,1fr)) minmax(106px,1.28fr);
}
.surname-key strong{font-size:clamp(40px,3.8vw,70px)}
.surname-key small{max-width:100%;overflow:hidden;text-overflow:ellipsis}

/* Wide laptops: stack before either column starts crushing the other. */
@media(max-width:1280px){
  .surname-keyboard-section{
    grid-template-columns:1fr;
    min-height:auto;
    gap:46px;
  }
  .surname-keyboard-copy{max-width:850px}
  .surname-keyboard-copy h2{font-size:clamp(58px,8.6vw,104px)}
  html[lang="es"] .surname-keyboard-copy h2{font-size:clamp(56px,7.8vw,96px)}
  .surname-keyboard-shell{transform:none}
  .surname-keyboard-shell:hover{transform:translateY(-3px)}
}

/* Tablets */
@media(max-width:900px){
  :root{--pad:clamp(18px,4.5vw,34px)}
  .section{padding-left:var(--pad);padding-right:var(--pad)}
  #view-home .hero{
    min-height:max(760px,100svh);
    padding-top:108px;
  }
  #view-home .hero-grid{
    grid-template-columns:1fr;
    min-height:58vh;
    padding-top:0;
  }
  #view-home .hero-main{max-width:680px}
  #view-home .hero h1{
    max-width:760px;
    font-size:clamp(52px,9.5vw,88px);
  }
  #view-home .hero-deck{max-width:min(620px,92vw)}
  #view-home .hero-nameplate{
    font-size:clamp(52px,11.7vw,98px);
    bottom:clamp(22px,3vh,36px);
  }
  #view-home .hero-nameplate .surname{margin-left:clamp(0px,4vw,38px)}
  #view-home > .hero-nameplate{
    inset:auto;
    width:100%;
    padding:24px var(--pad) 38px;
    font-size:clamp(70px,12vw,118px);
  }
  .portfolio-section-heading{grid-template-columns:1fr!important;gap:24px}
}

/* Phones / coarse pointers:
   keep the art direction, remove the expensive layers that do not add meaning
   on a small screen, and make the keyboard genuinely thumb-size. */
@media(max-width:760px),(pointer:coarse){
  body::after{display:none}
  #scene{display:none!important}
  .aurora-ribbon,
  #view-home .hero .hero-beam,
  #view-home .hero .hero-prism,
  #view-home .hero .hero-flare{display:none!important}
  .space::before,.space::after{animation:none!important;transform:none!important}
  .space::before{opacity:.22}
  .nav{
    -webkit-backdrop-filter:blur(12px) saturate(120%);
    backdrop-filter:blur(12px) saturate(120%);
  }
  .tilt,.tilt:hover{transform:none!important}
}

@media(max-width:760px){
  :root{--pad:20px}
  #view-home .hero{
    min-height:max(710px,100svh);
    padding-top:98px;
  }
  #view-home .hero-grid{
    min-height:500px;
    align-items:start;
  }
  #view-home .hero h1{
    font-size:clamp(46px,12.8vw,72px);
    line-height:.88;
    max-width:100%;
  }
  #view-home .hero-deck{
    width:100%;
    max-width:560px;
    margin-top:22px;
  }
  #view-home .hero-deck .copy{font-size:14px;line-height:1.65}
  #view-home .hero-portrait{
    right:-28%;
    width:92vw;
    opacity:.34;
  }
  #view-home .hero-nameplate{
    left:20px;
    right:20px;
    width:auto;
    font-size:clamp(43px,12.5vw,72px);
    line-height:.8;
    bottom:24px;
  }
  #view-home .hero-nameplate .surname{margin-left:0}
  #view-home > .hero-nameplate{
    inset:auto;
    width:100%;
    padding:26px 20px 34px;
    font-size:clamp(58px,17vw,78px);
    line-height:.77;
  }

  .surname-keyboard-section{
    padding:88px 20px 96px;
    gap:34px;
  }
  .surname-keyboard-copy{max-width:100%}
  .surname-keyboard-copy h2,
  html[lang="es"] .surname-keyboard-copy h2{
    font-size:clamp(48px,14vw,78px);
    line-height:.84;
    letter-spacing:-.065em;
  }
  .surname-keyboard-copy>p{margin-top:22px;font-size:15px;line-height:1.5}
  .surname-keyboard-hint{margin-top:25px;gap:10px}
  .surname-keyboard-hint kbd{
    max-width:100%;
    white-space:normal;
    line-height:1.35;
  }
  .surname-keyboard-shell{
    padding:12px;
    border-radius:24px;
    box-shadow:0 25px 65px rgba(43,34,61,.15),inset 0 1px 0 #fff;
  }
  .surname-keyboard-topbar{
    margin:0 2px 12px;
    gap:10px;
    font-size:7px;
  }
  .surname-keyboard-keys{
    grid-template-columns:repeat(5,minmax(0,1fr));
    grid-template-rows:repeat(2,94px) 68px;
    gap:7px;
  }
  .surname-key{
    min-width:0;
    padding:11px 7px 9px;
    border-radius:15px;
  }
  .surname-key::before{inset:5px;border-radius:11px}
  .surname-key strong{font-size:clamp(30px,9vw,45px)}
  .surname-key small{font-size:5.3px;letter-spacing:.04em}
  .surname-enter-key{
    grid-column:1/-1;
    grid-row:3;
    min-width:0;
    padding:12px 14px;
    border-radius:16px;
    flex-direction:row;
    align-items:center;
  }
  .surname-enter-key>span{font-size:42px}
  .surname-enter-key small{writing-mode:horizontal-tb;transform:none}
  .surname-keyboard-meta{
    gap:10px;
    margin-top:15px;
    padding-top:13px;
    font-size:6.5px;
    line-height:1.45;
  }
}

@media(max-width:430px){
  :root{--pad:16px}
  #view-home .hero{padding-top:92px}
  #view-home .hero h1{font-size:clamp(44px,13.4vw,61px)}
  #view-home .hero-portrait{display:none}
  #view-home .hero-nameplate{
    left:16px;
    right:16px;
    font-size:clamp(39px,12.4vw,54px);
  }
  #view-home > .hero-nameplate{
    inset:auto;
    width:100%;
    padding-left:16px;
    padding-right:16px;
    font-size:clamp(52px,16vw,68px);
  }
  .surname-keyboard-section{padding-left:16px;padding-right:16px}
  .surname-keyboard-copy h2,
  html[lang="es"] .surname-keyboard-copy h2{font-size:clamp(45px,13.7vw,62px)}
  .surname-keyboard-keys{grid-template-rows:repeat(2,84px) 64px;gap:6px}
  .surname-key small{display:none}
  .surname-key strong{font-size:31px}
  .surname-keyboard-topbar span:first-child{display:none}
  .surname-keyboard-meta{display:grid;grid-template-columns:1fr}
  .surname-keyboard-meta span:last-child{text-align:left}
}

/* Off-screen work should not compete with the first viewport for layout/paint. */
.portfolio-billboard,
.portfolio-home-projects,
.portfolio-studio-preview,
.portfolio-contact-tease,
.ab-work-bento{
  content-visibility:auto;
  contain-intrinsic-size:800px;
}
@media(max-width:760px){
  .portfolio-billboard,
  .portfolio-home-projects,
  .portfolio-studio-preview,
  .portfolio-contact-tease,
  .ab-work-bento{contain-intrinsic-size:640px}
}

@media(prefers-reduced-motion:reduce){
  #view-home .hero-nameplate,
  .surname-keyboard-shell,
  .surname-key,
  .surname-enter-key{transition:none!important;transform:none!important}
}


/* FINAL MOBILE HARDENING — prevent visual clipping/overlap on narrow viewports.
   These rules intentionally affect only responsive layouts; desktop stays untouched. */
@media(max-width:760px){
  /* Typography: no oversized editorial line may extend beyond the viewport. */
  .section .display,
  .portfolio-contact-tease h2,
  .portfolio-studio-preview h2,
  .portfolio-about-bio h2,
  .tab-head h1{
    max-width:100%;
    min-width:0;
    overflow-wrap:break-word;
    word-break:normal;
  }
  .section .display{
    font-size:clamp(42px,12.4vw,58px);
    line-height:.88;
    letter-spacing:-.055em;
  }
  .portfolio-contact-tease{
    overflow:hidden;
    padding-left:20px;
    padding-right:20px;
  }
  .portfolio-contact-tease h2{
    font-size:clamp(44px,13.2vw,62px);
    line-height:.88;
    letter-spacing:-.065em;
  }
  .portfolio-contact-tease p,
  .work-head .copy,
  .resume-head .copy{
    width:100%;
    max-width:100%;
    font-size:clamp(15px,4.5vw,19px);
    line-height:1.5;
  }

  /* Resume snapshot: two narrow columns clipped long labels such as Monterrey. */
  .resume-snapshot{
    grid-template-columns:1fr;
  }
  .resume-snapshot>div{
    min-width:0;
    min-height:130px;
  }
  .resume-snapshot strong{
    max-width:100%;
    font-size:clamp(30px,10vw,44px);
    line-height:.94;
    overflow-wrap:anywhere;
  }

  /* KAISEI manifesto: let the intro participate in document flow before the cards. */
  #view-kaisei .crystal-stage{
    padding:0 0 30px;
    align-items:start;
  }
  #view-kaisei .crystal-intro{
    position:relative;
    grid-column:1/-1;
    left:auto;
    right:auto;
    top:auto;
    max-width:100%;
    padding:28px 0 22px;
  }
  #view-kaisei .crystal-intro strong{
    max-width:100%;
    font-size:clamp(31px,9.7vw,43px);
    line-height:.92;
    letter-spacing:-.045em;
    overflow-wrap:break-word;
  }

  /* Selected-work intro: stack cleanly and keep Spanish copy inside the viewport. */
  .work-head{
    display:block;
    margin-bottom:36px;
  }
  .work-head .copy{
    margin-top:26px;
  }

  /* Project cards: stop using desktop absolute positioning on phones.
     Scene, logo and copy now flow vertically, so ETERNAL/RADISOL cannot collide. */
  .work .project,
  .work .project.large,
  .work .project.small,
  .work .project.full{
    display:flex;
    flex-direction:column;
    min-height:0!important;
    height:auto;
    padding:20px!important;
  }
  .work .project-top{
    order:1;
    flex-direction:column;
    align-items:flex-start;
    gap:12px;
  }
  .work .project-tags{
    justify-content:flex-start;
  }
  .work .project-scene,
  .work .project.full .project-scene{
    order:2;
    position:relative;
    inset:auto;
    left:auto;
    right:auto;
    top:auto;
    bottom:auto;
    width:100%;
    height:170px;
    margin:18px 0 0;
    transform:none!important;
  }
  .work .project-logo,
  .work .p-eternal .project-logo,
  .work .p-kaisei .project-logo,
  .work .p-radisol .project-logo{
    order:3;
    position:relative;
    inset:auto!important;
    left:auto!important;
    right:auto!important;
    top:auto!important;
    bottom:auto!important;
    width:min(78%,320px)!important;
    max-width:78%;
    height:82px!important;
    margin:16px 0 0;
  }
  .work .project-bottom,
  .work .project.full .project-bottom{
    order:4;
    position:relative;
    inset:auto;
    left:auto;
    right:auto;
    bottom:auto;
    display:block;
    margin-top:18px;
    transform:none;
  }
  .work .project-bottom h3,
  .work .project.full h3{
    max-width:100%;
    margin:0 0 14px;
    font-size:clamp(40px,13vw,58px);
    line-height:.9;
    letter-spacing:-.055em;
    overflow-wrap:anywhere;
  }
  .work .project-bottom p{
    max-width:100%;
    margin-bottom:20px;
    font-size:15px;
    line-height:1.5;
  }
  .work .project .link-arrow{
    max-width:100%;
    white-space:normal;
  }
}

@media(max-width:430px){
  .section .display{font-size:clamp(40px,12vw,52px)}
  .portfolio-contact-tease h2{font-size:clamp(42px,12.8vw,56px)}
  #view-kaisei .crystal-intro strong{font-size:clamp(29px,9.2vw,38px)}
  .work .project-scene,.work .project.full .project-scene{height:155px}
  .work .project-logo,
  .work .p-eternal .project-logo,
  .work .p-kaisei .project-logo,
  .work .p-radisol .project-logo{height:72px!important}
  .work .project-bottom h3,
  .work .project.full h3{font-size:clamp(38px,12.5vw,52px)}
}
