/* RFardi UI polish v3 — accessibility, touch, responsive stability */

/* Keyboard focus must remain obvious across homepage, public pages and panels. */
body.rfardi-ui-v2 :where(a,button,input,select,textarea,[tabindex]):focus-visible,
.rf-home-v2 :where(a,button,input,select,textarea,[tabindex]):focus-visible,
.rfardi-panel-shell :where(a,button,input,select,textarea,[tabindex]):focus-visible{
  outline:3px solid #b38b4d!important;
  outline-offset:3px!important;
  box-shadow:0 0 0 5px rgba(179,139,77,.15)!important;
}

/* Keep interactive targets comfortable on touch screens. */
body.rfardi-ui-v2 .entry-content a.rfardi-primary-link,
body.rfardi-ui-v2 .wp-block-button__link,
.rfardi-public-action,
.rfardi-panel-shell .rfardi-btn,
.rfardi-panel-shell button,
.rfardi-panel-shell input[type=submit]{
  min-height:44px;
}

.rfardi-panel-shell input[type=checkbox],
.rfardi-panel-shell input[type=radio]{
  min-width:18px;
  min-height:18px;
}

/* Prevent long Persian/Latin identifiers from breaking cards or forms. */
body.rfardi-ui-v2 .entry-content,
.rfardi-public-card,
.rfardi-panel-shell,
.rfardi-panel-shell .rfardi-list-item,
.rfardi-panel-shell .rfardi-message-body{
  overflow-wrap:anywhere;
  word-break:normal;
}

/* Stable typography and form behavior on mobile Safari/Chrome. */
body.rfardi-ui-v2 input,
body.rfardi-ui-v2 select,
body.rfardi-ui-v2 textarea,
.rfardi-panel-shell input,
.rfardi-panel-shell select,
.rfardi-panel-shell textarea{
  font-size:max(16px,1em);
}

body.rfardi-ui-v2 ::placeholder,
.rfardi-panel-shell ::placeholder{
  color:#7a8782;
  opacity:1;
}

/* Tables produced by legacy admin/client modules should not force horizontal page overflow. */
.rfardi-panel-shell table{
  max-width:100%;
}
.rfardi-panel-shell .widefat,
.rfardi-panel-shell .rfardi-table-wrap{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

/* Section anchors should land below sticky headers. */
body.rfardi-ui-v2 :where(h1,h2,h3,[id]){
  scroll-margin-top:110px;
}

/* Better visual hierarchy for notices without relying on color alone. */
.rfardi-notice-success::before{
  content:"✓";
  display:inline-block;
  margin-left:8px;
  font-weight:900;
}
.rfardi-notice-error::before{
  content:"!";
  display:inline-grid;
  place-items:center;
  width:20px;
  height:20px;
  margin-left:8px;
  border:1px solid currentColor;
  border-radius:50%;
  font-weight:900;
  line-height:1;
}

/* Avoid decorative hover motion on devices without a hover pointer. */
@media (hover:none){
  .rfardi-public-card:hover,
  .rfardi-feature:hover,
  .rfardi-growth-card:hover,
  .rfardi-appointment-card:hover,
  .rfv2-btn:hover,
  .rfardi-btn:hover{
    transform:none!important;
  }
}

/* Respect operating-system reduced-motion preferences. */
@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto!important}
  *,*::before,*::after{
    animation-duration:.01ms!important;
    animation-iteration-count:1!important;
    transition-duration:.01ms!important;
    scroll-behavior:auto!important;
  }
}

/* Stronger borders/focus for users requesting additional contrast. */
@media (prefers-contrast:more){
  :root{
    --rf2-line:rgba(23,59,51,.35);
  }
  .rfardi-public-card,
  .rfardi-panel-shell,
  .rfardi-section,
  .rfardi-list-item{
    border-color:rgba(23,59,51,.38)!important;
  }
  body.rfardi-ui-v2 :where(a,button,input,select,textarea,[tabindex]):focus-visible{
    outline-width:4px!important;
  }
}

@media(max-width:760px){
  /* Remove accidental double gutters from theme + bespoke layouts. */
  body.rfardi-ui-v2:not(.wp-admin) .site-content{
    overflow-x:clip;
  }

  .rfardi-public-head{
    margin-bottom:22px;
    padding-bottom:21px;
  }
  .rfardi-public-head h2{
    font-size:clamp(28px,9vw,38px);
  }
  .rfardi-public-card{
    padding:21px 18px;
    border-radius:18px;
  }
  .rfardi-public-card-top{
    gap:10px;
  }
  .rfardi-public-action{
    width:100%;
  }

  .rfardi-panel-page .site-content>.ast-container{
    width:min(100% - 18px,1220px)!important;
  }
  .rfardi-panel-shell{
    box-shadow:0 12px 34px rgba(33,63,54,.065);
  }
  .rfardi-panel-shell .rfardi-btn,
  .rfardi-panel-shell input[type=submit]{
    max-width:100%;
  }
  .rfardi-list-item>div:last-child{
    max-width:100%;
  }
}

@media(max-width:480px){
  body.rfardi-ui-v2:not(.wp-admin):not(.home):not(.rfardi-panel-page) .site-content>.ast-container{
    width:calc(100% - 16px);
  }
  body.rfardi-ui-v2:not(.wp-admin):not(.home):not(.rfardi-panel-page) article.page{
    padding:21px 16px;
    border-radius:17px;
  }
  .rfardi-public-card-top{
    display:block;
  }
  .rfardi-public-count{
    display:inline-flex;
    margin-top:10px;
  }
  .rfardi-panel-shell{
    padding:15px!important;
  }
  .rfardi-panel-head{
    margin:-15px -15px 19px!important;
    padding:21px 15px!important;
  }
  .rfardi-section{
    padding:16px 13px!important;
  }
}
