/* ===========================================================================
   Studee — the shell: a light floating rail on the left — the wordmark, the pages,
   settings, and the signed-in school account at its foot — and paper on the
   right. On a phone the rail becomes a floating header band and the ink tab
   bar at the bottom.
   =========================================================================== */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100dvh;
}

.main { min-width: 0; padding: 28px var(--gutter) 48px; }
.view { max-width: 1400px; }

/* ------------------------------------------------------------ the rail */
/* `.yu-rail.yu-rail--sticky` draws the panel; these only place what is in it. */
.rail-brand { display: inline-flex; text-decoration: none; }
.rail-brand yumee-logo { --yu-logo-size: 2rem; }
.rail .yu-nav__item svg { width: 20px; height: 20px; }

/* The school account the app is signed in to, and the way to Nastavenia. */
.rail-account .yu-account__figure { font-size: 1.125rem; }
.rail-account.is-active { border-color: var(--lav-300); }

/* ---------------------------------------------------------- header row */
.head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
  flex-wrap: wrap;
  margin: 6px 0 26px;
}
.head-kicker { margin: 0 0 8px; }
.head-title { margin: 0; }

.head-sync {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .75rem;
  line-height: 1.35;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.sync-label b { color: var(--ink); font-weight: 600; }

@media (max-width: 899px) {
  .desktop-only { display: none !important; }
}

/* ------------------------------------------------------ dashboard grid */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.grid-mid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.grid-stats > .card, .grid-mid > .card { min-width: 0; }
/* The wide panel (the latest grades) takes a whole row, wherever it is placed. */
.grid-mid > .card.wide { grid-column: 1 / -1; }

/* Every summary tile links into the page it summarises. */
a.stat-card { display: flex; color: inherit; text-decoration: none; }

/* ---------------------------------- generic page layout (non-dashboard) */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin: 6px 0 24px;
}
.page-title {
  margin: 0;
  font-size: clamp(1.75rem, 1.3rem + 1.4vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: var(--track-display);
}

/* --------------------------------------------------------- responsive */
.topbar { display: none; }
.tabbar { display: none; }

.topbar-brand { display: inline-flex; text-decoration: none; }
.topbar-brand yumee-logo { --yu-logo-size: 1.6rem; }

/* The way to Nastavenia on a phone: the account's initial and the cog. */
.topbar-profile { gap: 8px; padding: 0 12px 0 4px; min-height: 44px; color: var(--muted); }
.topbar-profile .yu-avatar { width: 34px; height: 34px; font-size: .9375rem; }
.topbar-profile svg { width: 18px; height: 18px; }
.topbar-profile.is-active { border-color: var(--lav-300); color: var(--purple-ink); }

@media (max-width: 1199px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-mid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 899px) {
  :root { --tabbar-space: calc(88px + var(--safe-bottom)); }

  .shell {
    grid-template-columns: minmax(0, 1fr);
    overflow-x: clip;
  }
  .rail { display: none; }
  .main { padding: calc(8px + var(--safe-top)) 14px calc(24px + var(--tabbar-space)); }

  /* The rail's twin as a band across the top: paper, a hairline, the float
     shadow, sticky with paper above it. */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: calc(8px + var(--safe-top));
    z-index: 30;
    margin-bottom: 18px;
    padding: 8px 8px 8px 18px;
    background: var(--card);
    border: var(--hairline);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-float);
  }

  /* The ink pill at the bottom (`.yu-tabbar`); the active icon sits in a
     lavender circle. The one large ink surface the app keeps. */
  .tabbar {
    display: grid;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + var(--safe-bottom));
    z-index: 60;
    gap: 2px;
    padding: 8px 6px;
  }
  .tab-item { gap: 4px; padding: 2px 0; }
  .tab-item .yu-tabbar__icon { width: 38px; height: 38px; transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
  .tab-item .yu-tabbar__icon svg { width: 20px; height: 20px; }
  .tab-label {
    font-size: .6875rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tab-item:active { transform: scale(0.94); }

  .head { flex-direction: column; align-items: stretch; gap: 12px; margin: 4px 0 20px; }
  .head-sync { text-align: left; justify-content: space-between; white-space: normal; }
  .page-head { margin: 4px 0 18px; }
  .grid-stats { gap: 12px; margin-bottom: 16px; }
  .grid-mid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

@media (max-width: 559px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card { padding: 16px; }
  .tab-label { font-size: .625rem; }
  .tab-item .yu-tabbar__icon { width: 36px; height: 36px; }
}

@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}
