/* Base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; background:#f5f5f5; color:#111; }
h1, h2 { margin: 16px 0; }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center;
  background: transparent; color:#111; padding: 8px 12px;
  border: none;
}
#menu-toggle { display: none; } /* default hidden, shown on mobile */

/* Layout containers */
.layout { display: block; margin: 0 auto; padding: 0 12px 16px; max-width: 1400px; }
.sidebar { background: #f5f5f5; color: #333; border: 0; }
.sidebar-menu { /* nav element */ }

/* Content cards */
#video-section, #ai-section {
  background:#fff; border-radius:8px; padding:16px; margin-bottom:16px;
}
#video-frame { width:100%; aspect-ratio:16/9; height:auto; border:0; display:block; }

/* Ask bar */
.ask-row { display:flex; gap:12px; width:100%; }
#ai-section #user-input {
  flex:1; width:100%; font-size:16px; padding:12px 14px; min-height:48px;
  border:1px solid #ccc; border-radius:6px; background:#fff; color:#111;
}
#ask-btn { padding:12px 18px; font-size:16px; border:0; border-radius:6px; cursor:pointer; white-space:nowrap; }
#ai-response { margin-bottom:16px; line-height:1.5; }

/* ===== Mobile first ===== */
@media (max-width: 899px){
  /* Full width main content */
  .layout { padding-left: 12px; padding-right: 12px; }
  main { width:100%; margin:0; }

  /* Sidebar does not reserve space */
  .sidebar { position: static; width: 100%; height: auto; max-height: none; padding:0; background:transparent; }

  /* Hamburger visible on mobile */
  #menu-toggle {
    display: inline-block;
    background:#fff; color:#111;
    border:1px solid #ccc; border-radius:6px; padding:8px 12px; font-size:16px;
  }

  /* Hide menu by default, show as overlay when .open */
  .sidebar-menu { display: none; }
  .sidebar-menu.open {
    display:block;
    position: fixed; left:0; top:0; bottom:0;
    width: 80vw; max-width: 320px;
    background:#f5f5f5; color:#333;
    padding:16px; overflow-y:auto; z-index:1000;
    box-shadow: 2px 0 8px rgba(0,0,0,.15);
  }
}

/* ===== Desktop and larger ===== */
@media (min-width: 900px){
  /* Two columns: left nav + right content */
  .layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    padding: 0 16px 24px;
  }
  /* Permanent sidebar */
  .sidebar { position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); overflow: auto; background:#f5f5f5; border-radius:8px; padding:12px; }
  .sidebar-menu { display: block; }
  /* Hide hamburger on desktop */
  #menu-toggle { display: none; }
}

/* Nav tree niceties */
#category-list, #category-list ul { list-style:none; margin:0; padding-left:0; }
#category-list > li { margin-bottom:10px; }
#category-list li > ul { padding-left:12px; }
#category-list li[data-topic] { cursor:pointer; padding:6px 8px; border-radius:6px; color:#333; }
#category-list li[data-topic]:hover { background:#e0e0e0; }

/* Optional: footer hidden if you don’t want the buttons */
footer { display:none; }



/* === MOBILE FORCE-FIX (put at very end) === */
@media (max-width: 899px){
  /* Make header visible and hamburger obvious */
  header{ position: sticky; top:0; z-index:2000; background:#fff; }
  #menu-toggle{
    display:inline-block !important;
    background:#fff; color:#111;
    border:1px solid #ccc; border-radius:6px;
    padding:8px 12px; font-size:16px;
  }

  /* Main content should be full width */
  .layout{
    display:block !important;
    max-width:100% !important;
    margin:0 !important;
    padding:12px !important;
  }
  main{ width:100% !important; margin:0 !important; }

  /* Sidebar must NOT reserve space */
  .sidebar{
    position: static !important;
    height:0 !important;             /* collapse the wrapper */
    padding:0 !important;
    background:transparent !important;
    overflow:visible !important;
  }

  /* Nav is hidden by default, becomes an overlay when opened */
  .sidebar-menu{ display:none !important; }
  .sidebar-menu.open{
    display:block !important;
    position:fixed; left:0; top:0; bottom:0;
    width:80vw; max-width:320px;
    background:#f5f5f5; color:#333;
    padding:16px; overflow-y:auto; z-index:3000;
    box-shadow:2px 0 8px rgba(0,0,0,.15);
  }
}

/* Desktop: keep video smaller */
@media (min-width: 900px){
  #video-section{
    max-width: 800px;   /* limit the section width */
  }
  #video-frame{
    max-width: 800px;   /* limit the iframe width */
    width: 100%;
    margin: 0 auto;     /* center it */
    display: block;
  }
}

/* Desktop styling for video section */
@media (min-width: 900px){
  #video-section{
    background:#fff;      /* white card background */
    padding:20px;
    border-radius:8px;
    max-width: 800px;     /* keeps it from being too wide */
    margin: 0 auto 20px;  /* center the card horizontally */
  }
  #video-frame{
    display:block;
    margin:0 auto;
    width:100%;
    max-width:700px;      /* smaller, more balanced size */
    height:400px;         /* fixed height to keep proportion */
  }
}

/* Desktop styling for video section */
@media (min-width: 900px){
  #video-section{
    background:#fff;      /* white card background */
    padding:20px;
    border-radius:8px;
    max-width: 800px;     /* keeps the card neat */
    margin: 0 auto 20px;  /* center it horizontally */
  }
  #video-frame{
    display:block;
    margin:0 auto;
    width:100%;
    max-width:700px;      /* makes video smaller */
    height:400px;         /* balanced height */
  }
}

/* Shared card style for video + AI sections */
#video-section, 
#ai-section {
  background:#fff;
  padding:20px;
  border-radius:8px;
  max-width: 100%;   /* both use same width */
  margin: 20px auto;  /* center and add spacing */
}

/* Make the video fill the card width (but not too tall) */
#video-frame {
  width:100%;
  height:270px;  /* adjust height as you prefer */
  display:block;
  border:none;
  border-radius:6px;
}

/* === DESKTOP: match the screenshot === */
@media (min-width: 900px){
  /* Two-column layout */
  .layout{
    display: grid !important;
    grid-template-columns: 280px 1fr !important;
    gap: 24px !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 0 16px 24px !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  /* Sidebar with its own scroll */
  .sidebar{
    position: sticky !important;
    top: 12px !important;
    align-self: start !important;
    max-height: calc(100vh - 24px) !important;
    overflow: auto !important;     /* keeps the left-column scrollbar */
    background: #f5f5f5 !important;
    border-radius: 8px !important;
    padding: 12px !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  /* Clean page, no outer border */
  body, main{
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    background: #f5f5f5;
  }

  /* White cards, same width for both sections */
  #video-section, #ai-section{
    background: #fff;
    border: 0;
    box-shadow: none;
    border-radius: 8px;
    padding: 16px 20px;
    max-width: 100%;
    margin: 16px auto;
  }

  /* Video centered and sized to card */
  #video-frame{
    display: block;
    width: 100%;
    max-width: 900px;
    height: 280px;            /* adjust if you want shorter */
    margin: 0 auto;
    border: 0;
    border-radius: 6px;
  }
}

/* Center the site title */
header h1 {
  margin-left: 12px;
}

/* Sidebar column should always match screen height */
.sidebar {
  height: 100vh;         /* exactly the height of the viewport */
  overflow-y: auto;      /* scroll inside if content is taller */
  position: sticky;      /* stays fixed while scrolling the main content */
  top: 0;                /* stick to top */

}


/* === DESKTOP: ChatGPT-style fixed sidebar, no extra top space === */
@media (min-width: 900px){

  /* Hide the top header on desktop (keeps it on mobile) */
  header { display: none !important; }

  /* Fixed left column that exactly matches the viewport height */
  .sidebar{
    position: fixed !important;
    top: 0; left: 0;
    width: 280px;
    height: 100vh;              /* exactly the screen height */
    overflow-y: auto;           /* scroll INSIDE the sidebar if needed */
    background: #f5f5f5;
    border: 0; box-shadow: none;
    padding: 12px;
  }

  /* Shift the main content to the right of the fixed sidebar */
  .layout{
    display: block !important;
    margin-left: 280px !important;   /* same as .sidebar width */
    max-width: none;                 /* let it breathe */
    padding: 0 16px 24px !important;
  }

  /* Cards look the same, centered within the main column */
  #video-section, #ai-section{
    background: #fff;
    border: 0; box-shadow: none;
    border-radius: 8px;
    padding: 16px 20px;
    max-width: 100%;
    margin: 16px auto;
  }

  /* Video sized to match the card width (adjust height if you like) */
  #video-frame{
    display: block;
    width: 100%;
    max-width: 900px;
    height: 380px;      /* change to ~420px if you want shorter */
    margin: 0 auto;
    border: 0; border-radius: 6px;
  }
}


/* === Desktop sidebar title === */
@media (min-width: 900px){
  .sidebar-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
    color: #222;
  }
}


/* === Desktop sidebar title === */
@media (min-width: 900px){
  .sidebar-title {
    font-size: 22px;
    font-weight: 700;
    text-align: left;
    margin-bottom: 16px;
    color: #222;
    margin-left: 18px;
  }
}

/* HARD HIDE the sidebar title on mobile */
@media (max-width: 899px){
  .sidebar-title{
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
}


/* Add some breathing room on the left side of the nav items */
.sidebar-menu ul {
  padding-left: 12px;
  margin-left: 0; /* make sure margin isn't pushing more */
}



/* Shift the whole nav in by 12px */
.sidebar .sidebar-menu,
.sidebar .sidebar-menu #category-list {
  padding-left: 8px !important;
  margin-left: 0 !important;
}

/* Keep sub-lists indented cleanly */
.sidebar .sidebar-menu #category-list li > ul {
  padding-left: 8px !important;
  margin-left: 0 !important;
}

/* Mobile drawer too (so it matches) */
@media (max-width: 899px){
  .sidebar-menu.open {
    padding-left: 12px !important;
  }
}

/* Sidebar menu styling */
.sidebar-menu li {
  font-weight: bold;       /* default: categories look bold */
  margin: 4px 0;
}

/* Items with data-topic (the actual links) should be normal */
.sidebar-menu li[data-topic] {
  font-weight: normal;
  cursor: pointer;
}

.sidebar-menu li[data-topic]:hover {
  text-decoration: underline;
}

/* Answer formatting */
#ai-response p { margin: 0 0 10px; }
#ai-response .ai-spacer { margin: 8px 0; }
#ai-response ul, #ai-response ol { margin: 0 0 12px 0; padding-left: 1.2rem; }
#ai-response li { margin: 4px 0; }
#ai-response { line-height: 1.6; word-wrap: break-word; }


/* Answer formatting */
#ai-response h1, #ai-response h2, #ai-response h3 { margin: 0 0 8px; line-height: 1.25; }
#ai-response p { margin: 0 0 10px; }
#ai-response .ai-spacer { margin: 8px 0; }
#ai-response ul, #ai-response ol { margin: 0 0 12px; padding-left: 1.2rem; }
#ai-response li { margin: 4px 0; }
#ai-response { line-height: 1.6; word-wrap: break-word; }



/* Desktop defaults */
#menu-toggle { display: none; }

/* Mobile sidebar */
@media (max-width: 900px) {
  /* Show hamburger */
  #menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 22px;
    border: 0;
    background: #111;
    color: #fff;
    border-radius: 8px;
    margin-left: auto;
    cursor: pointer;
  }

  /* Layout becomes single column */
  .layout {
    grid-template-columns: 1fr !important;
  }

  /* Sidebar off-canvas by default */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;            /* fills viewport height, even on mobile */
    width: min(80vw, 320px);
    background: #f3f3f3;
    box-shadow: 2px 0 10px rgba(0,0,0,.15);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .28s ease;
    z-index: 1000;             /* above page content */
    padding: 16px 12px;
  }

  /* The nav element inside */
  .sidebar-menu {
    margin: 0;
  }

  /* When JS toggles .open on #menu, slide it in */
  #menu.open {
    transform: translateX(0);
  }

  /* Optional backdrop so taps outside close it if you add logic later */
  body.menu-open::before {
    content: "";
    position: fixed; inset: 0;
    background: rgba(0,0,0,.25);
    z-index: 999;
  }
}

/* === FINAL MOBILE DRAWER FIX (overrides) === */
@media (max-width: 900px){
  /* The container should NOT slide; keep it static */
  .sidebar{
    position: static !important;
    transform: none !important;
    height: auto !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Slide the NAV itself (#menu = .sidebar-menu) */
  .sidebar-menu{
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    width: 80vw; max-width: 320px;
    background: #f5f5f5;
    overflow-y: auto;
    z-index: 3000;
    padding: 16px 12px;
    box-shadow: 2px 0 10px rgba(0,0,0,.15);
    transform: translateX(-100%);         /* hidden by default */
    transition: transform .28s ease;
    display: block !important;            /* ensure it exists to slide */
  }
  .sidebar-menu.open{
    transform: translateX(0);             /* slide in when JS adds .open */
  }

  /* Make the hamburger visible on mobile */
  #menu-toggle{
    display: inline-flex !important;
    align-items: center; justify-content: center;
    width: 44px; height: 44px;
    font-size: 22px; color:#fff; background:#111;
    border: 0; border-radius: 8px; margin-left: auto;
  }
}











/* === FINAL OVERRIDE: mobile drawer === */
@media (max-width: 900px){
  /* The wrapper should NOT slide */
  .sidebar{
    position: static !important;
    transform: none !important;
    height: auto !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Slide the NAV itself */
  nav#menu.sidebar-menu{
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: 80vw; max-width: 320px;
    background: #f5f5f5;
    padding: 16px 12px;
    overflow-y: auto;
    z-index: 4000;
    box-shadow: 2px 0 10px rgba(0,0,0,.15);
    transform: translateX(-100%) !important;   /* hidden by default */
    transition: transform .28s ease;
    display: block !important;                 /* ensure it can slide */
  }
  nav#menu.sidebar-menu.open{
    transform: translateX(0) !important;       /* slide in */
  }

  /* Hamburger visible on mobile */
  #menu-toggle{
    display: inline-flex !important;
    align-items: center; justify-content: center;
    width: 44px; height: 44px; font-size: 22px;
    background: #111; color: #fff; border: 0; border-radius: 8px;
    margin-left: auto;
  }

  /* Optional dim backdrop */
  body.menu-open::before{
    content:""; position:fixed; inset:0;
    background:rgba(0,0,0,.25); z-index: 3999;
  }
}

/* Make sure the hamburger stays clickable when the drawer is open */
@media (max-width: 899px){
  /* Let clicks pass through the backdrop */
  body.menu-open::before { pointer-events: none; }

  /* Put the header and hamburger above the drawer */
  header { position: relative; z-index: 5000; }
  #menu-toggle { position: relative; z-index: 5001; }

  /* Drawer can stay below header */
  nav#menu.sidebar-menu { z-index: 4000; }
}

@media (max-width: 899px){
  /* Push the slide-out menu down so it clears the header */
  nav#menu.sidebar-menu {
    top: 84px;   /* adjust if your header is taller/shorter */
  }
}