/*
Theme Name: ITALFABER Interface
Theme URI: https://italfaber.com/
Author: ITALFABER
Description: Tema WordPress minimale con menu laterale, sottomenu a scorrimento e integrazione nativa di app HTML esterne.
Version: 0.0.5
Text Domain: italfaber-interface
License: MIT
*/

:root{
  --bg:#f3f4f5;
  --panel:#fff;
  --ink:#0b1016;
  --line:#b9bec4;
  --soft:#eceff1;
  --bar:54px;
  --open:292px;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:var(--bg);color:var(--ink)}
body{font-family:Arial,Helvetica,sans-serif;font-size:14px;line-height:1.5}
button,a{font:inherit;color:inherit}
a{text-decoration:none}
img{max-width:100%;height:auto}

/* SIDEBAR - base identica alla 0.0.1 */
.sidebar{
  position:fixed;
  inset:0 auto 0 0;
  width:var(--bar);
  background:var(--panel);
  border-right:1px solid var(--line);
  overflow:hidden;
  transition:width .16s ease;
  z-index:1000;
}
.sidebar.open{width:var(--open)}

.sidebar-inner{
  width:var(--open);
  height:100%;
  display:flex;
  flex-direction:column;
}

.brand{
  height:54px;
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 9px;
  border-bottom:4px solid var(--ink);
}

.toggle{
  width:34px;
  height:34px;
  flex:0 0 34px;
  border:1px solid var(--line);
  background:#fff;
  display:grid;
  place-items:center;
  padding:0;
  cursor:pointer;
}
.toggle:hover{background:var(--soft)}

.hamburger,
.hamburger::before,
.hamburger::after{
  width:14px;
  height:1px;
  background:var(--ink);
  display:block;
  position:relative;
}
.hamburger::before,
.hamburger::after{
  content:"";
  position:absolute;
  left:0;
}
.hamburger::before{top:-5px}
.hamburger::after{top:5px}

.logo{
  font-weight:900;
  font-size:18px;
  letter-spacing:.08em;
  white-space:nowrap;
}
.logo img{display:block;max-height:28px;width:auto}

/* VIEWPORT MENU */
.menu-viewport{
  position:relative;
  flex:1;
  overflow:hidden;
}

/* ogni livello occupa lo stesso pannello */
.menu-panel{
  position:absolute;
  inset:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:10px 7px;
  scrollbar-width:thin;
  background:#fff;
  transition:transform .18s ease;
}
.menu-panel[data-level="root"]{transform:translateX(0)}
.menu-panel.is-right{transform:translateX(100%)}
.menu-panel.is-left{transform:translateX(-100%)}
.menu-panel.is-active{transform:translateX(0);z-index:2}

.menu-panel ul{list-style:none;margin:0;padding:0}
.menu-panel li{margin:0 0 7px}

.menu-row{
  display:flex;
  align-items:stretch;
  border:1px solid var(--line);
  background:#fff;
}
.menu-row:hover{
  border-color:var(--ink);
  background:var(--soft);
}
.menu-row > a{
  min-height:46px;
  flex:1;
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 11px;
  white-space:nowrap;
  font-weight:700;
  min-width:0;
}
.menu-row > a .label{
  overflow:hidden;
  text-overflow:ellipsis;
}
.menu-next{
  width:42px;
  flex:0 0 42px;
  border:0;
  border-left:1px solid var(--line);
  background:transparent;
  font-size:20px;
  line-height:1;
}
.menu-next:hover{background:#fff}

.icon{
  width:20px;
  flex:0 0 20px;
  text-align:center;
  font-size:15px;
}

.sub-head{
  height:46px;
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:7px;
  border-bottom:1px solid var(--line);
}
.sub-back{
  width:34px;
  height:34px;
  border:1px solid var(--line);
  background:#fff;
  font-size:20px;
  line-height:1;
}
.sub-back:hover{background:var(--soft)}
.sub-title{
  font-weight:800;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* stato chiuso identico alla prima versione */
.sidebar:not(.open) .label,
.sidebar:not(.open) .logo,
.sidebar:not(.open) .menu-next,
.sidebar:not(.open) .sub-head{
  opacity:0;
  pointer-events:none;
}

.sidebar:not(.open) .menu-row{
  width:40px;
  border:1px solid var(--line);
}

.sidebar:not(.open) .menu-row > a{
  width:40px;
  min-width:40px;
  padding:0 9px;
  gap:0;
}

.sidebar:not(.open) .menu-panel:not(.is-active){
  display:none;
}

/* PAGINA - identica alla 0.0.1 */
.if-page{
  position:fixed;
  top:0;
  right:0;
  bottom:0;
  left:var(--bar);
  margin:0!important;
  min-width:0;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  transition:left .16s ease;
}
body.menu-open .if-page{left:var(--open)}

.topbar{
  min-height:54px;
  background:#fff;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:8px 18px;
}
.topbar-title{
  font-size:11px;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
}
.top-menu ul{
  display:flex;
  gap:6px;
  list-style:none;
  margin:0;
  padding:0;
  flex-wrap:wrap;
}
.top-menu a{
  display:block;
  border:1px solid var(--line);
  background:#fff;
  padding:6px 10px;
}
.top-menu a:hover{background:var(--soft);border-color:var(--ink)}

main{
  width:min(1400px,calc(100% - 32px));
  margin:auto;
  padding:20px 0 36px;
}
.content{
  background:#fff;
  border:1px solid var(--line);
  padding:clamp(20px,3vw,42px);
}
.hero{
  min-height:360px;
  background:var(--ink);
  color:#fff;
  display:flex;
  align-items:flex-end;
  padding:38px;
  margin-bottom:14px;
}
.hero small{
  display:block;
  margin-bottom:10px;
  letter-spacing:.18em;
  font-weight:700;
}
.hero h1{
  margin:0;
  max-width:900px;
  font-size:clamp(44px,8vw,110px);
  line-height:.86;
  letter-spacing:-.055em;
}
.entry-title,.page-title{
  margin:0 0 18px;
  font-size:clamp(34px,6vw,72px);
  line-height:.92;
  letter-spacing:-.04em;
}
.entry-content a{text-decoration:underline;text-underline-offset:3px}
.entry-content table{width:100%;border-collapse:collapse}
.entry-content th,.entry-content td{border:1px solid var(--line);padding:8px 10px;text-align:left}
.entry-content blockquote{border-left:4px solid var(--ink);margin:1.5em 0;padding-left:18px}

.posts{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:12px;
}
.card{
  min-height:180px;
  background:#fff;
  border:1px solid var(--line);
  padding:20px;
  display:flex;
  flex-direction:column;
}
.card:hover{border-color:var(--ink)}
.card h2{margin:8px 0 10px;font-size:26px;line-height:1}
.card p{margin:0 0 16px}
.card .more{margin-top:auto;font-weight:800}

.pagination{margin-top:18px;display:flex;gap:6px;flex-wrap:wrap}
.pagination .page-numbers{padding:6px 10px;border:1px solid var(--line);background:#fff}
.pagination .current{background:var(--ink);color:#fff;border-color:var(--ink)}

footer{
  border-top:1px solid var(--line);
  margin-top:14px;
  padding:16px 0;
  font-size:11px;
  letter-spacing:.08em;
}

.screen-reader-text{
  position:absolute!important;
  width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0
}

body.admin-bar .sidebar{top:32px;height:calc(100vh - 32px)}

body.admin-bar .if-page{top:32px}
@media(max-width:782px){
  body.admin-bar .if-page{top:46px}
}

@media(max-width:782px){
  body.admin-bar .sidebar{top:46px;height:calc(100vh - 46px)}
}

@media(max-width:900px){
  .posts{grid-template-columns:1fr 1fr}
}

@media(max-width:700px){
  :root{--bar:46px}
  .sidebar{width:46px}
  .sidebar.open{width:min(292px,calc(100vw - 20px));box-shadow:12px 0 30px rgba(0,0,0,.12)}
  .if-page,body.menu-open .if-page{left:46px;margin:0!important}
  .brand,.topbar{min-height:48px}
  .topbar{align-items:flex-start;flex-direction:column}
  .top-menu{display:none}
  main{width:calc(100% - 18px);padding-top:10px}
  .hero{min-height:300px;padding:22px}
  .posts{grid-template-columns:1fr}
}


/* APP BRIDGE -------------------------------------------------- */
body.italfaber-app-page{
  overflow:hidden;
}
body.italfaber-app-page .topbar{
  flex:0 0 54px;
}
body.italfaber-app-page .if-page{
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.italfaber-app-main{
  width:100%;
  max-width:none;
  margin:0;
  padding:0;
  flex:1 1 auto;
  min-height:0;
  overflow:hidden;
}
.italfaber-app-frame{
  display:block;
  width:100%;
  height:100%;
  border:0;
  background:#fff;
}
.italfaber-app-empty{
  height:100%;
  display:grid;
  place-items:center;
  padding:24px;
  background:#fff;
}
.italfaber-app-empty-box{
  max-width:620px;
  border:1px solid var(--line);
  padding:24px;
}
.italfaber-app-empty-box h1{
  margin:0 0 8px;
  font-size:28px;
}
.italfaber-app-empty-box p{
  margin:0;
}
body.italfaber-app-page footer{
  display:none;
}

@media(max-width:700px){
  body.italfaber-app-page .topbar{
    display:none;
  }
}
