/* ============================================
   LIBRIQ BASE STYLES
   ============================================ */

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-body);
  background-color: var(--bg-base);
  transition: background-color var(--duration-slow) var(--ease-out),
              color var(--duration-slow) var(--ease-out);
}

/* ── App Shell Layout ─────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr;
  min-height: 100dvh;
}

.main-content {
  grid-column: 2;
  min-height: 100dvh;
  overflow-x: hidden;
  background-color: var(--bg-base);
}

/* ── Typography ───────────────────────────── */
.display-serif {
  font-family: var(--font-display);
  font-weight: var(--weight-semi);
  line-height: var(--leading-tight);
}

h1, .h1 {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--text-strong);
  letter-spacing: 0;
}

h2, .h2 {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  color: var(--text-strong);
  letter-spacing: 0;
}

h3, .h3 {
  font-family: var(--font-serif);
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

h4, .h4 {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  color: var(--text-primary);
}

.text-sm    { font-size: var(--text-sm); }
.text-xs    { font-size: var(--text-xs); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.text-accent    { color: var(--text-accent); }
.text-success   { color: var(--color-success); }
.text-danger    { color: var(--color-danger); }
.text-mono      { font-family: var(--font-mono); }

/* ── Page Container ───────────────────────── */
.page {
  padding: var(--space-8) var(--space-8) var(--space-16);
  max-width: var(--content-max);
  animation: pageFadeIn var(--duration-slow) var(--ease-out) both;
}

.page-header {
  margin-bottom: var(--space-8);
}

.page-title {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: 0;
  color: var(--text-strong);
}

.page-subtitle {
  margin-top: var(--space-1);
  font-size: var(--text-base);
  color: var(--text-secondary);
}

/* ── Section Labels ───────────────────────── */
.section-label {
  font-size: var(--t-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Divider ──────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  border: none;
  margin: var(--space-6) 0;
}

/* ── kbd styling ──────────────────────────── */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  line-height: 1.6;
}

/* ── Utility ──────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* ── Mobile topbar (hidden on desktop) ───── */
.mobile-topbar {
  display: none;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
  }

  .main-content {
    grid-column: 1;
    grid-row: 2;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 40;
    grid-column: 1;
    grid-row: 1;
  }

  .mobile-menu-btn,
  .mobile-search-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: background var(--duration-fast);
  }

  .mobile-menu-btn:hover,
  .mobile-search-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }

  .mobile-menu-btn i,
  .mobile-search-btn i {
    font-size: 1.25rem;
  }

  .mobile-logo {
    font-family: var(--font-display);
    font-weight: var(--weight-semi);
    font-size: var(--text-lg);
    color: var(--text-primary);
  }

  .page {
    padding: var(--space-6) var(--space-4) var(--space-16);
  }
}

/* ============================================
   PHASE 7 - GLOBAL MOBILE POLISH
   Responsive shell only; no behavior changes.
   ============================================ */

html, body {
  overflow-x: hidden;
}

.page,
.modal,
.sidebar,
.main-content {
  min-width: 0;
}

@media (max-width: 768px) {
  .page {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    padding-top: var(--space-6);
    padding-bottom: calc(var(--space-16) + env(safe-area-inset-bottom));
  }

  .mobile-topbar {
    padding-left: calc(var(--space-4) + env(safe-area-inset-left));
    padding-right: calc(var(--space-4) + env(safe-area-inset-right));
  }
}

@media (max-width: 430px) {
  .page {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
}
