/* Summit app navigation — glass header, tabs and profile menu.
   Shared by the journal (apps/web) and the account pages (apps/account);
   page tokens such as --ink, --muted, --page and --blue come from each app. */
:root {
  /* Glass navigation — Summit “Aujourd’hui (glass)” canvas, October 24. */
  --nav-glass: #ffffff8c;
  --nav-glass-hi: #ffffffc7;
  --nav-edge: #ffffffd9;
  --nav-hair: #07102a12;
  --nav-link: #0757de;
  --nav-shadow: 0 30px 70px -34px #14386e57, 0 2px 6px -2px #14386e0f;
  --nav-inset: inset 0 1px 0 #ffffff8c;
  --nav-ease: cubic-bezier(.32,.72,0,1);
}

.app-header {
  position: relative;
  z-index: 4;
  max-width: none;
  padding: 20px var(--shell-gutter, 32px) 0;
  background: transparent;
  border: 0;
}
.app-header-inner {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: var(--shell-width, 1240px);
  min-height: 64px;
  padding: 8px 8px 8px 22px;
  margin-inline: auto;
  border: 1px solid var(--nav-edge);
  border-radius: 999px;
  background: var(--nav-glass);
  box-shadow: var(--nav-inset), var(--nav-shadow);
  backdrop-filter: blur(26px) saturate(170%);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
}
.app-header .brand {
  justify-self: start;
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.6px;
}
.app-header .brand-symbol { display: block; width: 38px; height: auto; }

#nav {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: none;
  margin: 0;
  padding: 4px;
  border: 0;
  border-radius: 999px;
  background: var(--nav-hair);
  overflow: visible;
}
#nav a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background .5s var(--nav-ease), color .3s var(--nav-ease), transform .4s var(--nav-ease);
}
#nav .nav-label { display: block; font-size: inherit; line-height: inherit; }
#nav a:hover { color: var(--ink); background: var(--nav-glass); }
#nav a:active { transform: scale(.97); }
#nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--nav-glass-hi);
  font-weight: 700;
  box-shadow: 0 6px 18px -8px #14386e59, inset 0 1px 0 #ffffff99;
}
#nav a[aria-current="page"] .nav-icon { color: var(--nav-link); }
#nav .nav-icon { display: block; width: 20px; height: 20px; }
#nav a:focus-visible { outline: 2px solid var(--nav-link); outline-offset: 2px; }

.header-account { display: flex; justify-self: end; align-items: center; justify-content: flex-end; gap: 14px; }
.profile-account { position: relative; width: 82px; height: 48px; flex: 0 0 auto; }
.connection-indicator { position: absolute; right: 36px; bottom: 4px; display: block; width: 12px; height: 12px; border: 2px solid #f8fbff; border-radius: 50%; background: #c18427; box-shadow: 0 1px 3px #14263a24; }
.connection-indicator[hidden] { display: none; }
.connection-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.connection-indicator[data-state="syncing"] { background: var(--blue); }
.connection-indicator[data-state="syncing"]::after { content: ""; position: absolute; inset: -4px; border: 1px solid var(--blue); border-radius: 50%; animation: connection-pulse 1.8s ease-out infinite; }
@keyframes connection-pulse { from { opacity: .55; transform: scale(.65); } to { opacity: 0; transform: scale(1.5); } }
.profile-link {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 82px;
  min-height: 48px;
  padding: 4px 14px 4px 4px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--nav-hair);
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  transition: width 320ms cubic-bezier(.22,1,.36,1), background 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}
.profile-link:hover, .profile-link[aria-current="page"] { color: var(--ink); background: var(--nav-glass-hi); }
.profile-name { display: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; opacity: 0; transform: translateX(8px); transition: opacity 200ms ease, transform 320ms cubic-bezier(.22,1,.36,1); }
.profile-account.is-open .profile-link { color: var(--ink); border-color: var(--nav-edge); background: var(--nav-glass-hi); box-shadow: 0 6px 18px -8px #14386e59; }
.profile-chevron { transition: transform 220ms ease; }
.profile-account.is-open .profile-chevron { transform: rotate(180deg); }
.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 248px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border: 1px solid #dce7f4;
  border-radius: 20px;
  background: #fdfefe;
  box-shadow: 0 16px 48px #14263a1c, 0 3px 8px #14263a08;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  transform-origin: top right;
  transition: opacity 180ms ease, transform 240ms cubic-bezier(.22,1,.36,1), visibility 180ms;
}
.profile-dropdown::before { content: ""; position: absolute; inset: -12px 0 auto; height: 12px; }
.profile-account.is-open .profile-dropdown { visibility: visible; opacity: 1; transform: translateY(0) scale(1); }
.profile-menu-heading { padding: 8px 12px 10px; margin: 0 0 4px; border-bottom: 1px solid #e7eef6; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.profile-dropdown a, .profile-dropdown button { display: flex; align-items: center; justify-content: flex-start; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; background: transparent; color: var(--ink); text-decoration: none; font: inherit; font-size: 13px; font-weight: 500; }
.profile-dropdown a:hover, .profile-dropdown button:hover { background: #eaf1ff; color: var(--blue); }
.profile-dropdown .profile-logout { margin-top: 4px; color: #a83c3c; }
.profile-dropdown .profile-logout:hover { background: #fff1ef; color: #a83c3c; }
.profile-dropdown [hidden] { display: none; }
.profile-link:focus-visible, .profile-dropdown :focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
@media (min-width: 761px) {
  .profile-name { display: block; flex: 1 1 auto; }
  .profile-account.is-open .profile-link { width: 230px; padding-left: 18px; }
  .profile-account.is-open .profile-name { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .profile-link, .profile-name, .profile-chevron, .profile-dropdown { transition: none; }
  .connection-indicator[data-state="syncing"]::after { animation: none; opacity: .4; }
}
.profile-avatar, .profile-chevron, #nav .nav-icon {
  flex-shrink: 0;
  background-color: currentColor;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}
.profile-avatar { display: block; width: 40px; height: 40px; mask-image: url("./media/icons/user-circle.svg"); }
/* Without a photo: the canvas's blue avatar disc carrying the white profile glyph. */
.profile-avatar:not(.has-photo) {
  position: relative;
  mask-image: none;
  border-radius: 50%;
  background: linear-gradient(140deg, #4d93ff, #0866ff);
  box-shadow: 0 4px 12px -6px #0866ff99;
}
.profile-avatar:not(.has-photo)::before {
  content: "";
  position: absolute;
  inset: 16%;
  background: #ffffff;
  mask: url("./media/icons/user-circle.svg") center / contain no-repeat;
}
.profile-avatar.has-photo {
  mask-image: none;
  background: transparent;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid #ffffff;
  box-shadow: 0 1px 5px #14263a16;
}
.profile-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.profile-chevron { display: block; width: 14px; height: 14px; mask-image: url("./media/icons/caret-down.svg"); }
[data-icon="house"] .nav-icon { mask-image: url("./media/icons/house.svg"); }
[data-icon="barbell"] .nav-icon { mask-image: url("./media/icons/barbell.svg"); }
[data-icon="fork-knife"] .nav-icon { mask-image: url("./media/icons/fork-knife.svg"); }
[data-icon="chart-bar"] .nav-icon { mask-image: url("./media/icons/chart-bar.svg"); }
[data-icon="chat-circle"] .nav-icon { mask-image: url("./media/icons/chat-circle.svg"); }

@media (min-width: 761px) and (max-width: 1100px) {
  .app-header-inner { grid-template-columns: auto 1fr auto; gap: 12px; padding-left: 18px; }
  #nav { justify-self: center; gap: 2px; }
  #nav a { padding-inline: 12px; font-size: 13px; }
  #nav .nav-icon { display: none; }
  .header-account { gap: 8px; }
  .profile-account.is-open .profile-link { width: 200px; }
}

@media (max-width: 760px) {
  :root { --tabbar-bottom: max(18px, env(safe-area-inset-bottom, 0px)); --bottom-nav-space: calc(84px + var(--tabbar-bottom)); }
  /* The fixed tab bar must paint independently of the header as it scrolls away. */
  .app-header { z-index: auto; padding: 10px var(--shell-gutter, 32px) 0; }
  .app-header-inner { display: flex; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 4px; border: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .app-header .brand { gap: 8px; font-size: 21px; }
  .app-header .brand-symbol { width: 34px; height: auto; }
  .header-account { position: relative; z-index: 4; gap: 8px; }
  .profile-account { width: 48px; }
  .connection-indicator { right: 2px; bottom: 2px; }
  .profile-link { justify-content: center; width: 48px; min-width: 44px; padding: 0; gap: 0; border-color: var(--nav-edge); background: var(--nav-glass); box-shadow: var(--nav-inset), var(--nav-shadow); backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%); }
  .profile-avatar { width: 38px; height: 38px; }
  .profile-chevron { display: none; }
  #nav {
    position: fixed;
    z-index: 6;
    transform: translateZ(0);
    top: auto;
    bottom: var(--tabbar-bottom);
    left: 12px;
    right: 12px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    padding: 6px;
    border: 1px solid var(--nav-edge);
    border-radius: 30px;
    background: var(--nav-glass);
    box-shadow: var(--nav-inset), var(--nav-shadow);
    backdrop-filter: blur(24px) saturate(170%);
    -webkit-backdrop-filter: blur(24px) saturate(170%);
  }
  #nav a {
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    min-height: 54px;
    padding: 0 2px;
    border-radius: 24px;
    font-size: 10.5px;
    font-weight: 600;
  }
  #nav a:active { transform: scale(.94); }
  #nav .nav-icon { width: 22px; height: 22px; }
  #nav a[aria-current="page"] { color: var(--nav-link); box-shadow: 0 6px 16px -8px #14386e59, inset 0 1px 0 #ffffff99; }
}

@media (prefers-reduced-transparency: reduce) {
  .app-header-inner, #nav, .profile-link { --nav-glass: var(--page); --nav-glass-hi: var(--page); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  #nav a { transition: none; }
  #nav a:active { transform: none; }
}
@media (forced-colors: active) {
  #nav a[aria-current="page"], .profile-link[aria-current="page"] { outline: 2px solid Highlight; }
  #nav .nav-icon, .profile-avatar, .profile-chevron { background-color: ButtonText; }
  .profile-avatar:not(.has-photo) { background: Canvas; border: 1px solid ButtonText; }
  .profile-avatar:not(.has-photo)::before { background: ButtonText; }
  .connection-indicator { background: ButtonText; border-color: Canvas; }
  .connection-indicator[data-state="syncing"] { background: Highlight; }
  .connection-indicator[data-state="syncing"]::after { border-color: Highlight; }
}
/* Glass navigation in the dark home theme. */
html[data-today-theme="dark"] body:is([data-view="today"], [data-view="progress"], [data-view="nutrition"], [data-session-home="true"], [data-session-brief="true"]) {
  --nav-glass: #091e2e80;
  --nav-glass-hi: #16344cbf;
  --nav-edge: #ffffff17;
  --nav-hair: #ffffff12;
  --nav-link: #6aa6ff;
  --nav-shadow: 0 30px 80px -30px #00000099;
  --nav-inset: inset 0 1px 0 #ffffff0f;
}
html[data-today-theme="dark"] body:is([data-view="today"], [data-view="progress"], [data-view="nutrition"], [data-session-home="true"], [data-session-brief="true"]) .brand-symbol { filter: brightness(1.5); }
html[data-today-theme="dark"] body:is([data-view="today"], [data-view="progress"], [data-view="nutrition"], [data-session-home="true"], [data-session-brief="true"]) #nav a[aria-current="page"] { box-shadow: 0 6px 18px -8px #00000099, inset 0 1px 0 #ffffff14; }
