/* ============================================================
   shared.css  –  Somnovia Design Tokens & Shared Components
   Single source of truth for all pages.
   ============================================================ */

/* ---- TOKENS ---- */
:root{
  /* Brand palette — Somnovia blue-violet (logo: #362B62) */
  --brand-purple:#6558A6;
  --brand-purple-light:#9088C0;
  --brand-purple-dark:#362B62;
  --brand-purple-deep:#2A2150;
  --brand-pink:#5892B5;
  --brand-pink-light:#8ABBD4;

  /* Semantic roles */
  --accent:#544A8A;
  --accent-light:#9088C0;
  --accent-dark:#362B62;

  /* Text */
  --text-dark:#2A2150;
  --text-muted-dark:#6B6088;
  --text-light-page:#505050;
  --text-muted-light:#767676;

  /* Surfaces — glass hierarchy (light → strong → dark) */
  --glass-white:rgba(255,255,255,.48);
  --glass-white-strong:rgba(255,255,255,.62);
  --glass-subtle:rgba(255,255,255,.20);
  --glass-dark:rgba(42,33,80,.62);
  --glass-quote:rgba(60,50,100,.38);

  /* Shared geometry */
  --radius:16px;
  --radius-lg:20px;
  --radius-sm:12px;
  --bottom-nav-h:64px;

  /* Typography — families */
  --font:'IBM Plex Sans',-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,Roboto,Helvetica,Arial,sans-serif;
  --font-serif:'IBM Plex Serif',Georgia,'Times New Roman',serif;

  /* Typography — scale (5 steps) */
  --text-display:1.2rem;
  --text-heading:1.1rem;
  --text-body:.9rem;
  --text-small:.78rem;
  --text-caption:.65rem;

  /* Gradients */
  --gradient-bg:linear-gradient(155deg,#9088C0 0%,#6558A6 30%,#4E4290 70%,#362B62 100%);
  --gradient-progress:linear-gradient(90deg,#8ABBD4,#5892B5);
  --gradient-outline:linear-gradient(170deg,rgba(255,255,255,.3),rgba(255,255,255,.05));
  --gradient-outline-purple:linear-gradient(170deg,rgba(160,150,200,.3),rgba(80,60,140,.06));

  /* Transitions */
  --ease-out:cubic-bezier(.16,1,.3,1);
  --ease-smooth:cubic-bezier(.4,0,.2,1);
}

/* ---- RESET ---- */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}

/* ---- SCROLL REVEAL ---- */
.reveal{
  opacity:0;
  transform:translateY(18px) scale(.995);
  filter:blur(2px);
  transition:opacity .7s var(--ease-out),
             transform .7s var(--ease-out),
             filter .5s var(--ease-out);
}
.reveal.visible{opacity:1;transform:none;filter:none}

/* ---- REDUCED MOTION ---- */
@media(prefers-reduced-motion:reduce){
  .reveal{transition:none;opacity:1;transform:none;filter:none}
  *{animation-duration:.01ms !important;transition-duration:.01ms !important}
}

/* ---- GLASS OUTLINE (reusable mixin via class) ---- */
.glass-outline{position:relative;overflow:hidden}
.glass-outline::before{display:none}

/* ---- BOTTOM NAV ---- */
.bottom-nav{
  position:fixed;bottom:0;left:0;right:0;
  height:var(--bottom-nav-h);
  backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);
  border-top:1px solid rgba(255,255,255,.08);
  display:flex;align-items:center;justify-content:space-around;
  z-index:200;
  padding-bottom:env(safe-area-inset-bottom,0);
}
.bottom-nav--dark{
  background:rgba(60,40,68,.65);
}
.bottom-nav--light{
  background:#fff;
  border-top:1px solid rgba(0,0,0,.06);
}
.nav-item{
  display:flex;flex-direction:column;align-items:center;gap:2px;
  font-size:var(--text-caption);letter-spacing:.02em;
  color:rgba(255,255,255,.5);
  text-decoration:none;
  padding:.4rem .5rem;
  position:relative;
  transition:color .2s;
}
.bottom-nav--light .nav-item{color:rgba(60,40,68,.4)}
.nav-item svg{width:22px;height:22px;transition:color .2s,transform .15s}
.nav-item:hover svg{transform:translateY(-1px)}

/* Active states — blue-violet for Home/Dashboard, blue for sub-pages */
.nav-item.active{color:var(--brand-pink)}
.nav-item.active svg{color:var(--brand-pink)}
.nav-item.active::before{
  content:"";position:absolute;top:-1px;left:25%;right:25%;
  height:2px;background:var(--brand-pink);border-radius:0 0 2px 2px;
}
.bottom-nav--light .nav-item.active{color:var(--brand-pink)}

.sidebar-logo{display:none}

@media(min-width:600px) and (max-width:899px){
  .bottom-nav{
    max-width:760px;left:50%;transform:translateX(-50%);
    border-radius:20px 20px 0 0;
    box-shadow:0 -4px 24px rgba(0,0,0,.08);
  }
}

/* ---- DESKTOP SIDEBAR NAV ---- */
@media(min-width:900px){
  body{background:#d4d2de}

  .bottom-nav{
    position:fixed;top:0;bottom:0;right:auto;
    left:max(0px, calc(50vw - 480px));
    width:160px;height:100vh;
    flex-direction:column;
    justify-content:flex-start;
    padding:1.25rem 0 1.5rem;gap:.15rem;
    border-top:none;
    border-right:1px solid rgba(0,0,0,.06);
    z-index:200;
  }
  .bottom-nav--light{
    background:#fff;
    border-top:none;
    border-right:1px solid rgba(0,0,0,.06);
  }
  .nav-item{
    flex-direction:row;gap:.55rem;justify-content:flex-start;
    padding:.65rem 1.2rem;
    width:100%;
    font-size:var(--text-small);
  }
  .nav-item svg{width:20px;height:20px}
  .nav-item.active::before{
    top:25%;bottom:25%;left:-1px;right:auto;
    width:2px;height:auto;
    border-radius:0 2px 2px 0;
  }
  .nav-item:hover svg{transform:translateY(0) scale(1.08)}

  .sidebar-logo{
    display:flex !important;align-items:center;justify-content:center;
    padding:.75rem 1rem 1.2rem;
    margin-bottom:.5rem;
    border-bottom:1px solid rgba(0,0,0,.06);
  }
  .sidebar-logo svg{width:110px;height:auto}

  /* content centered as compact unit with sidebar */
  .page{
    margin-left:max(160px, calc(50vw - 320px));
    max-width:760px;
    padding:0 2rem 2rem;
  }

  /* top-bar follows the same centering */
  .top-bar{
    margin-left:max(160px, calc(50vw - 320px));
    max-width:760px;
    width:auto;
  }
}

/* ---- TOAST ---- */
.toast{
  position:fixed;bottom:calc(var(--bottom-nav-h) + 12px);
  left:50%;transform:translateX(-50%) translateY(20px);
  background:rgba(40,25,48,.9);color:#fff;
  padding:.65rem 1.3rem;border-radius:12px;
  font-size:var(--text-small);font-family:var(--font);
  opacity:0;pointer-events:none;
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
  transition:opacity .25s,transform .25s;
  z-index:300;
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0);pointer-events:auto}

/* ---- LOADING SPINNER ---- */
.loading-screen{
  display:flex;flex-direction:column;align-items:center;
  justify-content:center;min-height:50vh;
}
.loading-screen .spinner{
  width:36px;height:36px;
  border:3px solid rgba(255,255,255,.2);border-top-color:#fff;
  border-radius:50%;animation:spin .7s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---- FADEUP (was missing on login) ---- */
@keyframes fadeUp{
  from{opacity:0;transform:translateY(12px)}
  to{opacity:1;transform:none}
}

/* ---- PAGE CONTAINER ---- */
.page{max-width:760px;margin:0 auto;padding:0 1rem 2rem}

/* ---- VIEW TRANSITIONS (progressive enhancement) ---- */
@view-transition{navigation:auto}
::view-transition-old(root){animation:.2s ease-out both fade-out}
::view-transition-new(root){animation:.3s ease-out both fade-in}
@keyframes fade-out{from{opacity:1}to{opacity:0}}
@keyframes fade-in{from{opacity:0}to{opacity:1}}
