/* ------------------------------------------------------------
   Sidebar (側邊選單) — design-3-elegant
   Self-contained: relies only on CSS variables already defined
   on :root in index.html (--navy, --navy-soft, --gold,
   --gold-soft, --line, --card). Does not alter any existing
   page styles.
------------------------------------------------------------- */

.eg-sidebar{
  position:fixed;
  top:0;
  right:0;
  height:100vh;
  width:min(272px, 82vw);
  background:linear-gradient(180deg, var(--navy) 0%, var(--navy-soft) 100%);
  z-index:1300;
  overflow:hidden;
  box-shadow:-2px 0 20px rgba(19,34,68,0.18);
  transform:translateX(100%);
  transition:transform .4s cubic-bezier(.4,0,.2,1);
  font-family:var(--font-sans);
}
.eg-sidebar.is-expanded{
  transform:translateX(0);
}

@media(max-width:960px){
  .eg-sidebar{
    width:100vw;
    height:100dvh;
  }
}

/* Toggle icon lives in the header (not inside the sidebar), has no
   background of its own, and animates from a hamburger to an X on open.
   It only ever opens the sidebar — it is hidden while the sidebar is
   expanded so only one control (the sidebar's own close button) shows. */
.eg-sb-toggle{
  display:flex;
  align-items:center;
  justify-content:center;
  width:42px;
  height:42px;
  flex-shrink:0;
  flex-direction:column;
  gap:5px;
  background:transparent;
  border:none;
  cursor:pointer;
}
.eg-sb-toggle span{
  display:block;width:20px;height:1px;background:var(--navy);transition:.3s ease;
}
.eg-sb-toggle:hover span{ background:var(--gold); }
.eg-sb-toggle.open span:nth-child(1){transform:translateY(6px) rotate(45deg);background:var(--gold);}
.eg-sb-toggle.open span:nth-child(2){opacity:0;}
.eg-sb-toggle.open span:nth-child(3){transform:translateY(-6px) rotate(-45deg);background:var(--gold);}

/* Dedicated close button fixed to the sidebar's own top-right corner. */
.eg-sb-close{
  position:absolute;
  top:22px;
  right:22px;
  width:40px;
  height:40px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:transparent;
  border:none;
  cursor:pointer;
  z-index:2;
}
.eg-sb-close span{
  position:absolute;
  width:20px;
  height:1px;
  background:var(--gold-soft);
  transition:background .25s ease;
}
.eg-sb-close span:first-child{ transform:rotate(45deg); }
.eg-sb-close span:last-child{ transform:rotate(-45deg); }
.eg-sb-close:hover span{ background:#fff; }

.eg-sb-nav{
  list-style:none;
  margin:0;
  padding:96px 0 24px;
  height:100%;
  overflow-y:auto;
  overflow-x:hidden;
}
.eg-sb-nav::-webkit-scrollbar{ width:4px; }
.eg-sb-nav::-webkit-scrollbar-thumb{ background:rgba(217,192,120,0.3); border-radius:4px; }

.eg-sb-main{
  display:flex;
  align-items:center;
  gap:16px;
  width:100%;
  padding:14px 18px;
  background:transparent;
  border:none;
  cursor:pointer;
  text-align:left;
  color:#EDEFF5;
  font-size:1.04rem;
  letter-spacing:0.04em;
  font-weight:var(--fw-semibold);
  white-space:nowrap;
  font-family:inherit;
}
.eg-sb-icon{
  flex:0 0 auto;
  width:26px;
  height:26px;
  border-radius:50%;
  border:1px solid var(--gold-soft);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:0.78rem;
  color:var(--gold-soft);
  font-family:var(--font-serif);
  transition:background .3s ease, color .3s ease, border-color .3s ease;
}
.eg-sb-item.open > .eg-sb-main{
  background:rgba(184,150,62,0.14);
  color:var(--gold-soft);
}
.eg-sb-item.open > .eg-sb-main .eg-sb-icon{
  background:var(--gold);
  color:var(--navy);
  border-color:var(--gold);
}
.eg-sb-label{
  flex:1;
  opacity:0;
  transition:opacity .25s ease;
}
.eg-sidebar.is-expanded .eg-sb-label{ opacity:1; }

.eg-sb-caret{
  flex:0 0 auto;
  opacity:0;
  width:22px;
  height:22px;
  color:var(--gold-soft);
  transition:opacity .25s ease, transform .3s ease, color .25s ease;
}
.eg-sb-item.open > .eg-sb-main .eg-sb-caret{ color:var(--gold); }
.eg-sidebar.is-expanded .eg-sb-caret{ opacity:1; }
.eg-sb-item.open .eg-sb-caret{ transform:rotate(90deg); }

.eg-sb-sub{
  max-height:0;
  overflow:hidden;
  transition:max-height .4s ease;
}
.eg-sb-item.open .eg-sb-sub{ max-height:400px; }
.eg-sb-sub a{
  display:block;
  padding:10px 18px 10px 60px;
  margin-left:31px;
  font-size:1rem;
  font-weight:var(--fw-medium);
  color:#aab3c9;
  white-space:nowrap;
  border-left:1px solid rgba(217,192,120,0.18);
  transition:color .25s ease;
}
.eg-sb-sub a:hover{ color:var(--gold-soft); }
