/* ============================================================
   Shell — sidebar dashboard chrome, SVG icon sizing, density.
   Loaded last so it wins over style.css / dashboard.css.
   ============================================================ */

/* ---------- SVG icons ---------- */

.icon {
  display: inline-block;
  vertical-align: -0.15em;
  flex: none;
}

/* Icons inside a coloured container inherit that colour automatically. */
.stat-icon .icon,
.row-icon .icon,
.brand-mark .icon,
.review-mark .icon,
.nav-link .icon { vertical-align: middle; }

.state-icon {
  font-size: 0;               /* kill the old emoji sizing */
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.state-glyph {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.big-glyph {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold);
}

.badge-icon {
  font-size: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0 auto 6px;
}

.inline-glyph { vertical-align: -0.18em; color: var(--gold); }
.row-glyph { display: inline-grid; place-items: center; color: var(--text-dim); }

.demo-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--surface-hi);
  color: var(--text-muted);
  flex: none;
}

/* ---------- App shell ---------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: 10px 16px;
  background: var(--magenta);
  color: #fff;
  border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px 14px;
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  z-index: 60;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 800;
  font-size: 1.06rem;
  letter-spacing: -0.02em;
  color: var(--text);
}
.sidebar .brand:hover { text-decoration: none; }
.brand-accent { color: var(--magenta-hi); }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--violet), var(--magenta));
  color: #fff;
  box-shadow: none;
  font-size: 0;
}

/* Nav */
.sidebar .main-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  font-size: 0.895rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  transition: background 0.14s, color 0.14s;
}
.sidebar .nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transform: none;
}
.sidebar .nav-link.active {
  background: color-mix(in srgb, var(--magenta) 15%, transparent);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--magenta);
}
.sidebar .nav-label { display: inline; }

/* Sidebar footer */
.sidebar-foot { padding-top: 10px; border-top: 1px solid var(--border); }

.sidebar .user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
}
.sidebar .user-avatar {
  width: 30px;
  height: 30px;
  font-size: 0.8rem;
  flex: none;
}
.sidebar .user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar .user-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .user-role { font-size: 0.71rem; color: var(--text-dim); }
.sidebar .logout {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  flex: none;
}
.sidebar .logout:hover { background: var(--wrong-bg); color: var(--wrong); }

/* Content column */
.content-col {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-title { font-weight: 600; font-size: 0.95rem; }

.nav-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}

/* Inside the shell the content is left-aligned and full-width, not centred. */
.shell main { padding: 26px 0 64px; }
.shell main .wrap { max-width: 1360px; padding: 0 26px; }

/* ---------- Density ---------- */

.card {
  padding: 17px 18px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: none;
}
.card-tight { padding: 13px 14px; }

.section-head { margin: 22px 0 11px; }
.section-label {
  font-size: 0.735rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
}
.section-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.section-action:hover { color: var(--magenta-hi); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
}

.stat-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat-tile::before { display: none; }
.stat-tile:hover { transform: none; }

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent, var(--magenta)) 15%, transparent);
  color: var(--accent, var(--magenta));
  font-size: 0;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 0.755rem;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
}

.row-item { padding: 11px 13px; }
.row-icon { width: 34px; height: 34px; border-radius: 9px; font-size: 0; }
.row-title { font-size: 0.885rem; }
.row-sub { font-size: 0.765rem; }

table.data th {
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 9px 12px;
}
table.data td { padding: 9px 12px; font-size: 0.865rem; }

.pill { font-size: 0.72rem; padding: 2px 9px; }

h1 { font-size: 1.5rem !important; }

/* ---------- Utilities ---------- */

.media { display: flex; align-items: center; gap: 12px; }
.media-body { flex: 1; min-width: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tag.active {
  background: var(--magenta);
  color: #fff;
  border-color: var(--magenta);
}

/* ---------- Accessibility ---------- */

a, button, .nav-link, .tag, .demo-btn, [role="button"] { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--magenta-hi);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .shell main .wrap { padding: 0 18px; }
}

@media (max-width: 768px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease-out);
    width: 260px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .content-col { grid-column: 1; }
  .topbar { display: flex; }
  .shell main { padding: 18px 0 56px; }
  .shell main .wrap { padding: 0 15px; }

  .stat-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 9px; }
  .stat-value { font-size: 1.3rem; }
}

@media (max-width: 480px) {
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 14px 14px; }
}

/* ---------- Study modes (Phase 2) ---------- */

.study-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 20px;
  padding: 15px 17px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  /* The accent edge is an inset shadow in soft.css. A 3px border-left against
     a 1px border and a radius makes the browser taper one into the other,
     leaving a detached-looking sliver at the corner. */
}
.study-head-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: none;
  background: color-mix(in srgb, var(--accent, var(--magenta)) 16%, transparent);
  color: var(--accent, var(--magenta));
}
.study-title { font-size: 1.22rem; margin-bottom: 2px; letter-spacing: -0.02em; }

/* Exam countdown. State is carried by text and weight, not colour alone. */
.exam-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.12rem;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  flex: none;
  white-space: nowrap;
}
.exam-timer.urgent {
  background: var(--wrong-bg);
  border-color: var(--wrong);
  color: var(--wrong);
}

/* Question meta row — chips stay on one line, wrap as a group. */
.q-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.q-topic {
  font-size: 0.755rem;
  color: var(--text-dim);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Study mode cards on the dashboard */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  /* Accent edge is an inset shadow in soft.css -- a 2px border-top against a
     1px border and a radius tapers at the corners. */
  color: var(--text);
  transition: border-color 0.18s, transform 0.18s, background 0.18s;
  /* .mode-card is both a grid item (inside .mode-grid) and a flex container.
     Grid and flex items both default to min-width:auto, which refuses to
     shrink below the unwrapped width of .mode-card-sub's text -- on a phone
     that pushes the card past the viewport instead of wrapping the text.
     min-width:0 here lets the grid track's width win instead. */
  min-width: 0;
}
.mode-card:hover {
  text-decoration: none;
  background: var(--surface-2);
  border-color: var(--border-hi);
  transform: translateY(-2px);
}
.mode-card-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex: none;
  background: color-mix(in srgb, var(--accent, var(--magenta)) 16%, transparent);
  color: var(--accent, var(--magenta));
}
.mode-card-title {
  font-weight: 700;
  font-size: 0.94rem;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.mode-card-sub { font-size: 0.775rem; color: var(--text-dim); line-height: 1.45; }

/* Due-count badge — never colour alone, always a number + label */
.due-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  font-size: 0.7rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--gold) 18%, transparent);
  color: var(--gold);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .mode-card:hover { transform: none; }
}

@media (max-width: 768px) {
  .study-head { flex-wrap: wrap; }
  .mode-grid { grid-template-columns: 1fr; }
}

/* ---------- Weekly activity bars (parent report) ---------- */

.week-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 78px;
  padding-top: 6px;
}
.week-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.week-bar {
  width: 100%;
  max-width: 34px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--magenta), var(--violet));
  transition: height 0.25s var(--ease-out);
}
.week-bar-label {
  font-size: 0.67rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.pill-mute {
  background: var(--surface-hi);
  color: var(--text-dim);
}
