/* ============================================================
   MAGAZINE — Layout v2.2
   Asymmetric grids, editorial topbar, page transitions
   ============================================================ */

.app-shell {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}

/* ── Topbar — editorial masthead ── */
.topbar {
  display: flex; align-items: center;
  padding: 0 var(--main-px);
  height: var(--topbar-h); min-height: var(--topbar-h);
  background: var(--ivory);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  gap: 32px;
}
.topbar-brand {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.03em;
  cursor: pointer;
  flex-shrink: 0;
}
.topbar-brand em { font-style: italic; color: var(--rust); }
.topbar-by {
  font-family: var(--font-body);
  font-size: 0.66rem; font-weight: 600;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  border-left: 1px solid var(--border);
  padding-left: 12px;
  flex-shrink: 0;
  align-self: center;
}
.topbar-nav {
  display: flex; gap: 6px;
  margin-left: auto;
}
.topbar-tab {
  padding: 6px 14px; margin: 0;
  font-size: 0.75rem; font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer; border: none; background: none;
  font-family: var(--font-body);
  letter-spacing: 0.06em;
  transition: color var(--dur-fast);
  position: relative;
}
.topbar-tab::after {
  content: '';
  position: absolute; bottom: -2px; left: 14px; right: 14px;
  height: 2px; background: var(--rust);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur) var(--ease-out);
}
.topbar-tab:hover { color: var(--ink); }
.topbar-tab.active { color: var(--rust); }
.topbar-tab.active::after { transform: scaleX(1); }

.topbar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.78rem; color: var(--ink-soft);
  white-space: nowrap;
  margin-left: 16px;
}
.topbar-user .logout-btn {
  background: none; border: 1px solid var(--border);
  color: var(--ink-muted); padding: 3px 12px;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer; font-family: var(--font-body);
  transition: all var(--dur-fast);
}
.topbar-user .logout-btn:hover { color: var(--rust); border-color: var(--rust); }

/* ── Main content — each page controls its own grid ── */
.main-content {
  flex: 1; overflow-y: auto;
  padding: var(--main-py) var(--main-px);
  max-width: var(--content-max);
  width: 100%; margin: 0 auto;
  animation: pageEnter var(--dur-page) var(--ease-out-expo) both;
}
/* Chat page steals the full viewport */
.main-content.chat-active {
  padding: 0;
  max-width: none;
  overflow: hidden;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(20px); }
}
/* Subtle scale-up for important cards */
@keyframes cardRise {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
}
/* Staggered reveal for content sections */
@keyframes sectionReveal {
  from { opacity: 0; transform: translateY(24px); }
}
.section-reveal {
  animation: sectionReveal 0.55s var(--ease-out-expo) both;
}
.section-reveal:nth-child(1) { animation-delay: 0.05s; }
.section-reveal:nth-child(2) { animation-delay: 0.1s; }
.section-reveal:nth-child(3) { animation-delay: 0.15s; }
.section-reveal:nth-child(4) { animation-delay: 0.2s; }
.section-reveal:nth-child(5) { animation-delay: 0.25s; }
.section-reveal:nth-child(6) { animation-delay: 0.3s; }

/* Page header staggered entrance */
@keyframes headerReveal {
  from { opacity: 0; transform: translateY(18px); }
}

/* ── Page header — dramatic, left-aligned ── */
.page-header {
  margin-bottom: 36px;
  position: relative;
  animation: headerReveal 0.6s var(--ease-out-expo) both;
}
.page-header p {
  animation: headerReveal 0.55s 0.12s var(--ease-out-expo) both;
}
.page-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.page-header p {
  color: var(--ink-soft);
  font-size: 0.78rem; margin-top: 8px;
  max-width: 420px;
  line-height: 1.75;
  position: relative;
  padding-left: 24px;
  border-left: 3px solid var(--rust);
  font-style: italic;
  font-family: var(--font-display);
}

/* ── Section title ── */
.section-title {
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 700;
  margin-bottom: 24px; color: var(--ink);
  letter-spacing: -0.01em;
  position: relative;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-heavy);
  font-style: italic;
}

/* ── Auth shell — cover layout ── */
.auth-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  background: var(--ivory);
  position: relative;
  overflow: hidden;
}
.auth-hero {
  display: flex; flex-direction: column; justify-content: center;
  padding: 80px 64px;
  position: relative;
  z-index: 1;
}
.auth-hero::after {
  content: '';
  position: absolute; top: -20%; right: -60%; width: 120%; height: 140%;
  background: var(--rust);
  clip-path: polygon(65% 0, 100% 0, 100% 100%, 35% 100%);
  z-index: -1;
  opacity: 0.06;
  pointer-events: none;
}
.auth-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.auth-hero h1 em { font-style: italic; color: var(--rust); }
.auth-hero .hero-sub {
  color: var(--ink-muted);
  font-size: 1rem;
  margin-top: 16px;
  letter-spacing: 0.12em; font-weight: 600;
  text-transform: uppercase;
}
.auth-hero .hero-copy {
  color: var(--rust-deep);
  font-size: 0.95rem;
  margin-top: 16px;
  letter-spacing: 0.14em; font-weight: 700;
}
.auth-hero .hero-foot {
  position: absolute;
  left: 64px; bottom: 32px;
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}
.auth-hero .hero-line {
  width: 72px; height: 4px;
  background: var(--rust);
  margin: 32px 0;
}
.auth-hero .hero-tagline {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-style: italic;
  color: var(--ink-soft);
  max-width: 340px;
  line-height: 1.6;
}

.auth-form-col {
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--ivory);
  border: 1px solid var(--border-heavy);
  padding: 48px 40px;
  position: relative;
  animation: cardEnter 0.5s var(--ease-out-expo) both;
}
.auth-card::before {
  content: '';
  position: absolute; top: -1px; left: 0; right: 0;
  height: 4px; background: var(--rust);
}
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(24px); }
}
.auth-card .card-label {
  font-size: 0.65rem; font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 32px;
}
.auth-card .form-footer {
  margin-top: 32px; text-align: center;
  font-size: 0.82rem; color: var(--ink-muted);
}
.auth-card .form-footer a {
  color: var(--rust); cursor: pointer; text-decoration: none;
  font-weight: 700;
  border-bottom: 2px solid var(--rust-dim);
  transition: border-color var(--dur-fast);
}
.auth-card .form-footer a:hover { border-bottom-color: var(--rust); }

/* ── Error banner ── */
.error-banner {
  background: var(--error-dim);
  border-left: 3px solid var(--error);
  color: #8B1A1A;
  padding: 10px 14px;
  margin-bottom: 20px; font-size: 0.82rem;
  animation: shake 0.45s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ── Loading / Spinner ── */
.loading-state {
  display: flex; align-items: center; justify-content: center;
  padding: 64px 20px; flex-direction: column; gap: 12px;
}
.loading-state .spinner { width: 20px; height: 20px; }
.loading-state p { color: var(--ink-muted); font-size: 0.85rem; }
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--rust);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --main-px: 20px; --main-py: 36px; }
  .main-content { padding: var(--main-py) var(--main-px); }
  .topbar {
    padding: 0 var(--main-px); flex-wrap: wrap;
    height: auto; min-height: 48px; gap: 8px;
  }
  .topbar-nav { order: 3; width: 100%; overflow-x: auto; margin: 4px 0; gap: 0; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-tab { margin: 0 8px; font-size: 0.7rem; padding: 4px 8px; white-space: nowrap; flex-shrink: 0; }
  .topbar-by { display: none; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { padding: 40px 24px; min-height: 40vh; }
  .auth-hero::after { display: none; }
  .auth-hero .hero-foot { left: 24px; bottom: 20px; }
  .auth-form-col { padding: 24px; }
  .page-header h2 { font-size: clamp(1.8rem, 8vw, 3rem); }
}
