/* MyGrind · layout.css
 * The app shell at three sizes, using CSS grid and media queries only:
 *   < 768px    single column + bottom tab bar
 *   >= 768px   left sidebar navigation
 *   >= 1024px  dashboard: right-hand rail on the Today screen
 * Content is capped at 1200px and centred.
 */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1200px;
  min-height: 100dvh;
  margin: 0 auto;
}

.sidebar,
.rail { display: none; }

.view {
  /* Bottom padding clears the tab bar and the floating add button. */
  padding: calc(env(safe-area-inset-top) + 20px) var(--gutter) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 104px);
  outline: none;
  min-width: 0;
}

/* ---------- Bottom tab bar (phones) ---------- */

.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  max-width: 520px;
  height: var(--tabbar-h);
  margin: 0 auto;
  padding: 6px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 22px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}

.tab[aria-current="page"] {
  background: var(--selected);
  color: var(--on-selected);
}

/* ---------- Floating add button (phones) ---------- */

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  z-index: 15;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 14px 30px -10px var(--accent);
  transition: transform 0.15s var(--ease);
}
.fab:active { transform: scale(0.94); }
.fab .icon { width: 28px; height: 28px; stroke-width: 2.5; }

/* ---------- Sidebar (>= 768px) ---------- */

@media (min-width: 768px) {
  .shell {
    grid-template-columns: 232px minmax(0, 1fr);
    column-gap: 28px;
    padding: 0 24px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    padding: 28px 0 24px;
  }

  .tabbar { display: none; }

  .view { padding: 32px 0 56px; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 28px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
}
.brand__mark .icon { width: 22px; height: 22px; }

.nav { display: grid; gap: 4px; }

.nav__link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}
.nav__link:hover { background: var(--surface); color: var(--ink); }
.nav__link[aria-current="page"] { background: var(--selected); color: var(--on-selected); }

.sidebar__foot {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

/* ---------- Dashboard rail (>= 1024px, Today only) ---------- */

@media (min-width: 1024px) {
  .shell[data-route="today"] {
    grid-template-columns: 232px minmax(0, 1fr) 340px;
  }

  .shell[data-route="today"] .rail {
    position: sticky;
    top: 0;
    display: grid;
    align-content: start;
    align-self: start;
    gap: 16px;
    max-height: 100dvh;
    padding: 32px 0;
    overflow-y: auto;
    scrollbar-width: thin;
  }
}
