/* layout.css — app shell, header, sidebar, bottom nav */

/* ─── LAYOUT ─── */
#app {
  position: relative; z-index: 1;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w, 280px) 1fr;
  grid-template-rows: 64px 1fr;
  transition: grid-template-columns 0.35s cubic-bezier(0.4,0,0.2,1);
}

#app.sidebar-collapsed {
  --sidebar-w: 0px;
  grid-template-columns: 0px 1fr;
}

/* ─── HEADER ─── */
header {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border-bright);
  background: var(--bg2);
  position: relative;
  z-index: 101;
}

.logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 0.4em;
  color: var(--gold);
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.logo:hover { opacity: 0.8; }
.logo-symbol { font-size: 18px; }

.date-display {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.streak-badge {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--gold);
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--glow);
}

/* Time of Day Slider */
.time-slider-container {
  flex: 1;
  max-width: 500px;
  margin: 0 32px;
  padding: 0 16px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.time-slider {
  position: relative;
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: visible;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.time-indicator {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  left: 0;
  transition: left 1s ease-out;
  z-index: 10;
  pointer-events: none;
}

.time-indicator-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(217, 119, 87, 0.8), 0 0 4px rgba(217, 119, 87, 1);
}

.time-indicator-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg2);
  box-shadow: 0 0 16px rgba(217, 119, 87, 0.9), 0 0 4px rgba(217, 119, 87, 1);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    box-shadow: 0 0 16px rgba(217, 119, 87, 0.9), 0 0 4px rgba(217, 119, 87, 1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 0.9;
    box-shadow: 0 0 20px rgba(217, 119, 87, 1), 0 0 8px rgba(217, 119, 87, 1);
  }
}

.time-indicator-time {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
  background: var(--bg2);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--border-bright);
  transition: all 0.2s;
  overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar:hover { background: var(--gold2); border-color: var(--gold); }

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg2);
  border: 1px solid var(--border-bright);
  min-width: 200px;
  display: none;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 100;
}

.user-dropdown.open { display: flex; }

.user-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.user-email {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-dim);
}

.user-dropdown-item {
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}

.user-dropdown-item:hover { background: var(--glow); }
.user-dropdown-item.active { color: var(--gold); background: rgba(217,119,87,0.1); }

.auth-btn {
  padding: 8px 20px;
  border: 1px solid var(--border-bright);
  background: none;
  color: var(--gold);
  font-family: var(--font-ui);
  font-size: 14px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn:hover { background: var(--glow); border-color: var(--gold); }

/* ─── SIDEBAR ─── */
sidebar {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg2);
  overflow: hidden;
  padding: 24px 0;
  width: 280px;
  transition: width 0.35s cubic-bezier(0.4,0,0.2,1),
              opacity 0.25s ease,
              padding 0.35s ease;
  position: relative;
}

#app.sidebar-collapsed sidebar {
  width: 0;
  padding: 0;
  opacity: 0;
  border-right-color: transparent;
}

.sidebar-inner {
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 0 0 16px;
}

/* ─── SIDEBAR TOGGLE BUTTON ─── */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -14px;
  transform: translateY(-50%);
  width: 28px; height: 48px;
  background: var(--bg2);
  border: 1px solid var(--border-bright);
  border-left: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s, right 0.35s cubic-bezier(0.4,0,0.2,1);
  clip-path: polygon(0 8px, 100% 0, 100% 100%, 0 calc(100% - 8px));
}

.sidebar-toggle:hover { background: var(--bg3); }

#app.sidebar-collapsed .sidebar-toggle {
  right: -28px;
  border-left: 1px solid var(--border-bright);
}

.sidebar-toggle-icon {
  font-size: 11px;
  color: var(--gold);
  transition: transform 0.35s ease;
  user-select: none;
}

#app.sidebar-collapsed .sidebar-toggle-icon { transform: rotate(180deg); }

/* ─── BREADCRUMBS ─── */
.breadcrumb-bar {
  padding: 10px 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.breadcrumb-label {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.breadcrumbs {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.sidebar-nav {
  padding: 10px 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-nav-btn {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav-icon {
  width: 22px;
  display: inline-flex;
  justify-content: center;
  font-size: 16px;
}

.sidebar-nav-btn:hover { background: var(--glow); border-color: var(--border-bright); }
.sidebar-nav-btn.active { color: var(--gold); background: rgba(217,119,87,0.1); border-color: var(--gold); }

.breadcrumb-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  cursor: pointer;
  transition: opacity 0.15s;
}

.breadcrumb-step:hover { opacity: 0.8; }

.bc-dot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 16px;
  flex-shrink: 0;
}

.bc-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--border-bright);
  background: transparent;
  transition: all 0.2s;
  flex-shrink: 0;
}

.bc-dot.done { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 5px rgba(217,119,87,0.5); }
.bc-dot.current { border-color: var(--amber); box-shadow: 0 0 6px rgba(203,77,46,0.5); animation: bc-pulse 1.5s ease-in-out infinite; }

@keyframes bc-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(203,77,46,0.4); }
  50% { box-shadow: 0 0 10px rgba(203,77,46,0.8); }
}

.bc-line {
  width: 1.5px;
  height: 16px;
  background: var(--border);
  transition: background 0.3s;
  margin: 2px 0;
}

.bc-line.done { background: var(--gold); }

.bc-text {
  font-size: 11px;
  color: var(--text-dim);
  transition: color 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.bc-text.done { color: var(--text-dim); }
.bc-text.current { color: var(--text); font-style: italic; }
.bc-icon { font-size: 12px; }

.sidebar-section { padding: 0 20px 20px; }

.sidebar-label {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--text-muted);
  margin-bottom: 12px;
}

.ritual-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  margin-bottom: 4px;
  position: relative;
}

.ritual-item:hover { border-color: var(--border); background: var(--glow); }
.ritual-item.active { border-color: var(--border-bright); background: rgba(217,119,87,0.06); }
.ritual-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--gold);
}

.ritual-item.done .ritual-name { color: var(--text-dim); text-decoration: line-through; }
.ritual-icon { font-size: 16px; flex-shrink: 0; }
.ritual-name { font-size: 14px; font-weight: 400; flex: 1; color: var(--text); }

.ritual-check {
  width: 18px; height: 18px;
  border: 1px solid var(--border-bright);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--gold);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.ritual-check.checked { background: var(--gold); color: var(--bg); }

.ritual-actions { position: relative; }

.ritual-menu-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ritual-menu-btn:hover { color: var(--gold); }

.ritual-context-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg2);
  border: 1px solid var(--border-bright);
  min-width: 120px;
  display: none;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 100;
}

.ritual-context-menu.open { display: flex; }

.ritual-context-item {
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ritual-context-item:hover { background: var(--glow); }
.ritual-context-item.delete { color: var(--amber); }
.ritual-context-item.delete:hover { background: rgba(203,77,46,0.1); }

.add-ritual-btn {
  margin: 8px 20px 0;
  padding: 10px;
  border: 1px dashed var(--border);
  background: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.1em;
  cursor: pointer;
  width: calc(280px - 40px);
  text-align: center;
  transition: all 0.2s;
}

.add-ritual-btn:hover { border-color: var(--gold); color: var(--gold); background: var(--glow); }

/* ─── MAIN CONTENT ─── */
main {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.view { display: none; flex-direction: column; height: 100%; }

/* ─── BOTTOM NAV ─── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: linear-gradient(to top, var(--bg), var(--bg2));
  border-top: 1px solid var(--border-bright);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  z-index: 100;
  backdrop-filter: blur(10px);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  max-width: 120px;
}

.nav-tab::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--gold);
  border-radius: 0 0 3px 3px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px var(--gold);
}

.nav-tab:hover { background: var(--glow); }

.nav-tab.active::before {
  width: 60%;
  animation: navIndicatorPulse 2.5s ease-in-out infinite;
}

@keyframes navIndicatorPulse {
  0%, 100% { box-shadow: 0 0 8px var(--gold); opacity: 1; }
  50%       { box-shadow: 0 0 20px var(--gold), 0 0 40px rgba(217,119,87,0.25); opacity: 0.75; }
}

.nav-tab.active { background: rgba(217,119,87,0.1); transition: background 4s ease; }
.nav-tab[data-period="dawn"].active    { background: rgba(100,38,12,0.32); }
.nav-tab[data-period="morning"].active { background: rgba(120,82,20,0.26); }
.nav-tab[data-period="day"].active     { background: rgba(45,72,90,0.26); }
.nav-tab[data-period="dusk"].active    { background: rgba(100,26,14,0.34); }
.nav-tab[data-period="night"].active   { background: rgba(5,7,18,0.48); }

.nav-tab .nav-icon,
.nav-tab .nav-label { position: relative; z-index: 1; }

.nav-mote {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  animation: navMoteFloat var(--dur,4s) ease-in-out infinite var(--delay,0s);
}

@keyframes navMoteFloat {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  20%  { opacity: var(--peak,0.55); }
  80%  { opacity: var(--peak,0.55); }
  100% { transform: translateY(-24px) translateX(var(--drift,0px)); opacity: 0; }
}

.nav-icon {
  font-size: 24px;
  transition: filter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  filter: grayscale(1) opacity(0.5);
}

.nav-tab:hover .nav-icon { filter: grayscale(0.5) opacity(0.7); transform: translateY(-2px); }

.nav-tab.active .nav-icon {
  filter: grayscale(0) opacity(1);
  animation: navIconPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
             navIconFloat 3s ease-in-out 0.45s infinite;
}

@keyframes navIconPop {
  0%   { transform: scale(1)    translateY(0); }
  60%  { transform: scale(1.35) translateY(-6px); }
  100% { transform: scale(1.12) translateY(-3px); }
}

@keyframes navIconFloat {
  0%, 100% { transform: scale(1.12) translateY(-3px); }
  50%      { transform: scale(1.12) translateY(-6px); }
}

.nav-label {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 400;
}

.nav-tab:hover .nav-label { color: var(--text-dim); }

.nav-tab.active .nav-label {
  color: var(--gold);
  font-weight: 600;
  animation: navLabelGlow 2.5s ease-in-out infinite;
}

@keyframes navLabelGlow {
  0%, 100% { text-shadow: none; opacity: 1; }
  50%      { text-shadow: 0 0 10px rgba(217,119,87,0.5); opacity: 0.85; }
}

.main-views {
  flex: 1;
  overflow: hidden;
  position: relative;
  padding-bottom: 64px;
}

.main-view { display: none; height: 100%; overflow-y: auto; }
.main-view.active { display: flex; flex-direction: column; }

sidebar::-webkit-scrollbar, main::-webkit-scrollbar, .main-view::-webkit-scrollbar, .sidebar-inner::-webkit-scrollbar { width: 4px; }
sidebar::-webkit-scrollbar-track, main::-webkit-scrollbar-track, .main-view::-webkit-scrollbar-track, .sidebar-inner::-webkit-scrollbar-track { background: var(--bg); }
sidebar::-webkit-scrollbar-thumb, main::-webkit-scrollbar-thumb, .main-view::-webkit-scrollbar-thumb, .sidebar-inner::-webkit-scrollbar-thumb { background: var(--border); }

.empty-state { color: var(--text-muted); font-style: italic; font-size: 16px; text-align: center; padding: 40px; }
