/* ============================================================
   Karify — Layout
   App shell, top bar, category tabs, module pills, drawer,
   bottom nav, responsive breakpoints.
   ============================================================ */

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-12);
  min-height: 100vh;
}

/* ---- Top bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, var(--navy) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-mark {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
}

.brand-tag {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.1;
}

.top-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---- FY + Language segmented toggles ---- */
.fy-toggle,
.lang-toggle {
  display: inline-flex;
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.fy-btn,
.lang-btn {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.fy-btn.active,
.lang-btn.active {
  background: var(--accent);
  color: var(--navy);
  font-weight: 500;
}

.fy-btn:not(.active):hover,
.lang-btn:not(.active):hover {
  color: var(--text);
}

/* ---- Category tabs (primary nav) ---- */
.category-tabs {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
  flex-wrap: wrap;
}

/* ---- Module pills (secondary, scrollable) ---- */
.module-pills {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-5);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-2);
  scrollbar-width: none;
}

.module-pills::-webkit-scrollbar {
  display: none;
}

.module-pill {
  scroll-snap-align: start;
  flex-shrink: 0;
}

/* ---- Module container ---- */
.module-container {
  padding: var(--space-8) 0 var(--space-6);
  min-height: 60vh;
  position: relative;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--text-dim);
  gap: var(--space-3);
}

.placeholder-icon {
  font-size: 56px;
  color: var(--accent);
  opacity: 0.35;
  line-height: 1;
  margin-bottom: var(--space-4);
}

.placeholder-title {
  font-size: var(--text-2xl);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

.placeholder-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 360px;
  font-family: var(--font-mono);
}

/* ---- Profile drawer ---- */
.profile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 90vw;
  height: 100vh;
  background: var(--navy-mid);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-out);
  z-index: 200;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.profile-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--navy-mid);
  z-index: 1;
}

.drawer-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.drawer-body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.drawer-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out);
  z-index: 150;
}

.drawer-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ---- Bottom nav (mobile only) ---- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--navy-mid);
  border-top: 1px solid var(--border);
  grid-template-columns: repeat(4, 1fr);
  padding: var(--space-2) 0 calc(var(--space-2) + env(safe-area-inset-bottom, 0));
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.bn-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--space-2) var(--space-1);
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease-out);
  border-radius: var(--radius-md);
}

.bn-icon {
  font-size: 20px;
  line-height: 1;
  font-weight: 500;
}

.bn-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bn-btn.active {
  color: var(--accent);
}

.bn-btn:not(.active):hover {
  color: var(--text);
}

/* ---- Responsive breakpoints ---- */

/* Tablet */
@media (max-width: 1023px) {
  .app-shell {
    padding: var(--space-5) var(--space-5) var(--space-10);
  }

  .brand-tag {
    font-size: var(--text-base);
  }
}

/* Mobile */
@media (max-width: 767px) {
  .app-shell {
    padding: var(--space-4) var(--space-4) var(--space-8);
  }

  .top-bar {
    padding-bottom: var(--space-3);
    gap: var(--space-2);
  }

  .top-controls {
    gap: var(--space-2);
    width: 100%;
    justify-content: space-between;
  }

  .fy-toggle .fy-btn,
  .lang-toggle .lang-btn {
    padding: 5px 10px;
  }

  .category-tabs {
    display: none;
  }

  .bottom-nav {
    display: grid;
  }

  .module-container {
    padding: var(--space-5) 0 calc(var(--space-16) + var(--space-4));
  }

  .profile-drawer {
    width: 100vw;
    max-width: 100vw;
  }
}

/* Small phone */
@media (max-width: 420px) {
  .top-controls #btn-auth .auth-label {
    display: none;
  }

  .top-controls #btn-auth::before {
    content: '→';
    font-family: var(--font-mono);
    font-size: var(--text-base);
  }
}
