:root {
  --bg: #0b0f1a;
  --bg-soft: #12182b;
  --blue: #3b82f6;
  --green: #22c55e;
  --text: #e5e7eb;
  --muted: #9ca3af;
}

/* reset + base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Prevent any accidental horizontal scrolling from tiny rounding errors */
html,
body {
  overflow-x: hidden;
}

html {
  height: 100%;
  background: radial-gradient(circle at top, #101633, var(--bg));
}

body {
  min-height: 100dvh;
  /* fill viewport */
  display: flex;
  /* layout engine */
  flex-direction: column;
  /* stack header / main / footer */
  background: radial-gradient(circle at top, #101633, var(--bg));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== HEADER / NAV ===== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  background: rgba(18, 24, 43, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 5;
  position: relative;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.site-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--blue);
}

.nav-right {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
}

.nav-right a {
  margin-left: 16px;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.18s ease;
  font-size: 0.95rem;
}

.nav-right a:hover {
  color: var(--green);
}

.hidden {
  display: none;
}

/* ===== MAIN (grows) ===== */
/* This is the crucial rule: make main consume remaining vertical space */
main {
  flex: 1;
  /* grow to fill remaining viewport space */
  display: flex;
  /* make main a column flex container */
  flex-direction: column;
  min-width: 0;
  /* prevent overflow in small viewports */
}

/* HERO stays natural height and does not stretch */
.hero {
  flex: 0 0 auto;
  /* don't grow or shrink to fill main */
  text-align: center;
  padding: 80px 20px 60px;
  width: 100%;
}

/* Keep a centered max-width content area inside hero/cards sections without extra wrappers */
.hero>h1 {
  margin: 0 auto;
  max-width: 1200px;
  font-size: clamp(2rem, 5dvw, 3rem);
  background: linear-gradient(90deg, var(--blue), var(--green));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* small hero paragraph */
.hero p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 1.05rem;
}

/* hero buttons */
.hero-buttons {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* buttons */
button {
  padding: 12px 22px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

button:hover {
  transform: translateY(-2px);
}

.primary {
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #fff;
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.18);
}

.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* ===== RESOURCE / CARDS AREA ===== */
/* Use percentage width + max-width instead of dVw to avoid rounding/viewport issues */
#certificates {
  width: 100%;
  max-width: 1200px;
  margin: 20px auto 0;
  padding: 20px;
  box-sizing: border-box;
}

/* container for lists of resources */
.resource-list {
  margin-top: 16px;
}

/* placeholder empty message */
.resource-list .empty {
  color: var(--muted);
  font-style: italic;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), transparent);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

/* Cards grid
   - use a smaller min width for the grid to avoid horizontal overflow
   - width:100% + max-width keeps it centered and safe */
.cards {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 20px;
  padding: 24px 20px 60px;
  margin: 20px auto;
  box-sizing: border-box;
}

/* keep transforms smooth & hint the browser */
.card {
  background: var(--bg-soft);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: transform 0.2s, border 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  will-change: transform;
}

/* If you want hover lift without horizontal bleed, we already hide page overflow-x on html/body */
.card:hover {
  transform: translateY(-6px);
  border-color: var(--blue);
}

.card h3 {
  margin-bottom: 10px;
  color: var(--blue);
}

.card p {
  color: var(--muted);
  line-height: 1.4;
}

/* ===== FOOTER ===== */
/* footer must be the last child inside body for margin-top: auto to work */
.footer {
  margin-top: auto;
  /* this pushes footer to the bottom */
  text-align: center;
  padding: 24px 16px;
  font-size: 0.9rem;
  color: var(--muted);
  background: linear-gradient(180deg, #070913, #0a0e1a);
  /* distinct solid-ish background */
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* ===== ACCOUNT / AUTH AREA ===== */
.nav-account {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 120px;
}

/* loading spinner */
.account-loader {
  font-size: 1.2rem;
  opacity: 0.75;
  animation: pulse 1.4s ease-in-out infinite;
}

/* guest (logged out) */
.account-guest {
  display: flex;
  align-items: center;
}

/* sign in button */
.login-btn {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--green));
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(34, 197, 94, 0.35);
}

/* logged in wrapper */
.account-loggedin {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* avatar */
.nav-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--bg-soft);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.nav-avatar:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* username */
#nav-name {
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  transition: color 0.15s ease;
}

#nav-name:hover {
  color: var(--green);
}

/* account source label (GitHub / Local) */
.account-loggedin span {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.1;
}

/* subtle animation */
@keyframes pulse {
  0%   { opacity: 0.4; }
  50%  { opacity: 1; }
  100% { opacity: 0.4; }
}

/* ===== SMALL SCREENS ===== */
@media (max-width: 768px) {
  .nav-account {
    margin-left: auto;
  }

  #nav-name,
  #nav-account-type {
    display: none; /* avatar-only on mobile */
  }
}

/* ===== Small screens tweaks ===== */
@media (max-width: 768px) {
  iframe {
    height: 400px;
  }

  .navbar {
    padding: 12px 14px;
  }

  .hero {
    padding: 56px 14px 40px;
  }

  /* remove dVw usage and rely on padding inside the container */
  #certificates,
  .cards {
    padding-left: 16px;
    padding-right: 16px;
  }

  .nav-right a {
    margin-left: 10px;
    font-size: 0.92rem;
  }

  /* Hide normal nav-right links on small screens */
  .nav-right {
    display: none;
  }

  /* Show hamburger button */
  .hamburger {
    display: inline-block;
    font-size: 1.8rem;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    z-index: 10;
    /* on top */
  }

  /* Sidebar overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100vh;
    background: var(--bg-soft);
    padding: 60px 20px 20px;
    /* space for navbar */
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.6);
    background-color: rgba(0, 0, 0, 0.767);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 20;
    /* on top of everything */
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  /* Show sidebar when active */
  .sidebar.active {
    transform: translateX(0);
  }

  /* Sidebar links */
  .sidebar a {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 8px 0;
  }

  .sidebar a:hover {
    color: var(--blue);
  }

  /* slightly reduce gaps on small screens for tighter layout */
  .cards {
    gap: 16px;
    padding-top: 18px;
    padding-bottom: 40px;
  }

  .card {
    padding: 18px;
  }
}

/* small visual helper — keep long words from breaking layout badly */
.card p,
.card h3 {
  word-wrap: break-word;
  hyphens: auto;
}

/* ===== SIDE-BY-SIDE LAYOUT ===== */
.main-content-wrapper {
  width: 100%;
  max-width: 1400px;
  margin: 40px auto 0;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* Mobile-first: stacked layout by default */
.content-column {
  width: 100%;
}

.featured-column {
  width: 100%;
  margin-top: 30px;
}

.featured-sticky {
  background: rgba(18, 24, 43, 0.8);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Iframe styling for all devices */
#iframe-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#iframe-container iframe {
  width: 100%;
  border: 0;
  background: transparent;
  color-scheme: dark;
  border-radius: 12px;
}

/* Tablet: 768px - 1023px */
@media (min-width: 768px) and (max-width: 1023px) {
  .main-content-wrapper {
    padding: 0 20px;
  }
  
  /* On tablet, keep stacked but adjust iframe height */
  #chat-or-cta[data-state="chat"] iframe {
    height: 500px; /* Good height for tablets */
    min-height: 500px;
  }
  
  /* Cards layout on tablet */
  #chat-or-cta[data-state="cta"] .cards {
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 20px;
  }
  
  .featured-sticky {
    position: relative;
    top: 0;
  }
}

/* Desktop: side-by-side layout with matched heights */
@media (min-width: 1024px) {
  .main-content-wrapper {
    flex-direction: row;
    align-items: stretch;
    padding: 0 20px;
    min-height: 620px;
  }

  .content-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }

  .featured-column {
    flex: 0 0 350px;
    margin-left: 30px;
    margin-top: 0; /* Reset mobile margin */
    display: flex;
    flex-direction: column;
  }

  .featured-sticky {
    flex: 1;
    position: sticky;
    top: 100px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .featured-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 100%;
  }

  #chat-or-cta {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  #chat-or-cta[data-state="chat"] {
    height: 100%;
  }

  #chat-or-cta[data-state="chat"] > div {
    flex: 1;
    display: flex;
  }

  #chat-or-cta[data-state="chat"] iframe {
    flex: 1;
    height: 100%;
    min-height: 600px;
  }

  #chat-or-cta[data-state="cta"] {
    height: 100%;
  }

  #chat-or-cta[data-state="cta"] .cards {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    grid-auto-rows: 1fr;
    gap: 20px;
    margin-top: 20px;
  }

  #chat-or-cta[data-state="cta"] .card {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
}

/* Mobile: < 768px */
@media (max-width: 767px) {
  .main-content-wrapper {
    padding: 0 16px;
    gap: 20px;
  }
  
  /* Proper iframe height for mobile */
  #chat-or-cta[data-state="chat"] iframe {
    height: 400px;
    min-height: 400px;
  }
  
  /* Cards layout for mobile */
  #chat-or-cta[data-state="cta"] .cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
  }
  
  .featured-sticky {
    position: relative;
    top: 0;
    margin-top: 20px;
  }
}

/* Featured panel styling */
.featured-sticky h2 {
  font-size: 1.4rem;
  margin-bottom: 20px;
  color: var(--blue);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

.featured-item {
  text-decoration: none;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 14px;
  background: rgba(11, 15, 26, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: all 0.25s ease;
}

.featured-item:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
  transform: translateY(-2px);
}

.featured-item h3 {
  text-decoration: none;
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--green);
}

.featured-item p {
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.no-decoration {
  text-decoration: none;
}

.featured-sticky .see-more {
  text-decoration: none;
  display: block;
  margin-top: 20px;
  text-align: center;
  padding: 12px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 10px;
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.featured-sticky .see-more:hover {
  background: rgba(59, 130, 246, 0.2);
  color: var(--text);
}