@layer reset, base, components, navbar, utilities;

/* ========================================
   RESET LAYER
   ======================================== */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -moz-text-size-adjust: none;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
  }

  body,
  h1,
  h2,
  h3,
  h4,
  p,
  figure,
  blockquote,
  dl,
  dd {
    margin: 0;
    margin-block-end: 0;
  }

  ul[role='list'],
  ol[role='list'] {
    list-style: none;
  }

  body {
    min-height: 100vh;
    line-height: 1.5;
    font-family: var(--font-sans);
  }

  h1,
  h2,
  h3,
  h4,
  button,
  input,
  label {
    line-height: 1.1;
  }

  h1,
  h2,
  h3,
  h4 {
    text-wrap: balance;
  }

  a:not([class]) {
    text-decoration-skip-ink: auto;
    color: currentColor;
  }

  img,
  picture {
    max-width: 100%;
    display: block;
  }

  input,
  button,
  textarea,
  select {
    font-family: inherit;
    font-size: inherit;
  }

  textarea:not([rows]) {
    min-height: 10em;
  }

  :target {
    scroll-margin-block: 5ex;
  }
}

/* ========================================
   BASE LAYER - Fonts & Variables
   ======================================== */
@layer base {
  :root {
    /* Font Families */
    --font-sans: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji',
      'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
      'Liberation Mono', 'Courier New', monospace;

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Line Heights */
    --leading-none: 1;
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    /* Spacing */
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-5: 1.25rem;
    --spacing-6: 1.5rem;
    --spacing-8: 2rem;
    --spacing-10: 2.5rem;
    --spacing-12: 3rem;
    --spacing-16: 4rem;
    --spacing-20: 5rem;
  }
}

@layer components {
  /* Video Background */
  video {
    height: 100%;
    width: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -2;
  }

  /* Hero Section */
  .hero-1 {
    position: relative;
    height: 885px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .hero-2 {
    background-color: black;
    width: 100%;
    min-height: 500px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    margin-top: -3rem;
    padding: 12px 6px;
    color: white;
  }

  .hero-2-section {
    display: flex;
    padding: 1rem;
    justify-content: center;
    text-align: center;
    align-items: center;
    gap: 4rem;
    flex-direction: column;
  }

  .hero-2-section h1 {
    font-size: var(--text-4xl);
    font-weight: var(--font-bold);
  }

  .hero-2-section h2 {
    font-size: var(--text-base);
    text-align: start;
  }

  /* Title Sections */
  .title {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 5rem;
    margin-bottom: 4rem;
    max-width: 70%;
    width: 100%;
  }

  .first-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: white;
    max-width: 50%;
    line-height: var(--leading-tight);
  }

  .second-title {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-6);
    justify-content: space-between;
    color: white;
  }

  .second-title p {
    flex: 1 1 200px;
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
  }

  /* Buttons */
  .btn-primary {
    background-color: #ef5324;
    padding: 0.5rem;
    color: white;
    border-radius: 20px;
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    width: fit-content;
    white-space: nowrap;
  }

  /* Carousel */
  .carosel {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
  }

  .carosel img {
    flex: 0 0 auto;
    width: min(300px, 80vw);
    height: 500px;
    object-fit: cover;
    border-radius: 20px;
    scroll-snap-align: start;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
}

/* ========================================
   NAVBAR LAYER - WITH ANCHOR POSITIONING
   ======================================== */
@layer navbar {
  /* Base Navbar Styles */
  .navbar-container {
    position: fixed;
    top: 0;
    z-index: 1000;
    background-color: transparent;
    width: 100%;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
  }

  .navbar-container.scrolled {
    background-color: rgba(0, 0, 0, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
  }

  .navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
  }

  /* Logo */
  .logo {
    max-width: 180px;
    transition: transform 0.3s ease;
  }

  .logo:hover {
    transform: scale(1.05);
  }

  /* Desktop Navigation */
  .desktop-nav {
    display: flex;
    gap: 2rem;
    align-items: center;
  }

  /* ========================================
     ANCHOR POSITIONING SETUP
     ======================================== */

  /* Volunteer Anchor */
  #volunteer-anchor {
    anchor-name: --volunteer-anchor;
  }

  /* Syle Anchor */
  #syle-anchor {
    anchor-name: --syle-anchor;
  }

  /* Peace School Anchor */
  #peace-school-anchor {
    anchor-name: --peace-school-anchor;
  }

  /* What's News Anchor */
  #what-is-news-anchor {
    anchor-name: --news-anchor;
  }

  /* Nested Opportunities Trigger */
  .nested-trigger {
    anchor-name: --opportunities-trigger;
  }

  /* Nav Button Styles */
  .nav-button {
    background: none;
    border: none;
    color: white;
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
    position: relative;
    text-decoration: none;
    display: inline-block;
  }

  .nav-button::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: white;
    transition: all 0.3s ease;
    transform: translateX(-50%);
  }

  .nav-button:hover::after {
    width: 80%;
  }

  /* ========================================
     DROPDOWN MENUS WITH ANCHOR POSITIONING
     ======================================== */

  /* Base Dropdown Menu */
  .dropdown-menu {
    position: absolute;
    margin-top: 0.5rem;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    padding: 0;
    border: none;
  }

  /* Volunteer Dropdown */
  #volunteer-positioned {
    position: absolute;
    position-anchor: --volunteer-anchor;
    position-area: bottom;
    position-try-fallbacks: bottom, top;
    top: auto;
    left: auto;
    margin-top: 0.5rem;
  }

  /* Syle Dropdown */
  #syle-positioned {
    position: absolute;
    position-anchor: --syle-anchor;
    position-area: bottom;
    position-try-fallbacks: bottom, top;
    top: auto;
    left: auto;
    margin-top: 0.5rem;
  }

  /* Peace School Dropdown */
  #peace-school-positioned {
    position: absolute;
    position-anchor: --peace-school-anchor;
    position-area: bottom;
    position-try-fallbacks: bottom, top;
    top: auto;
    left: auto;
    margin-top: 0.5rem;
  }

  /* What's News Dropdown */
  #what-is-news-positioned {
    position: absolute;
    position-anchor: --news-anchor;
    position-area: bottom;
    position-try-fallbacks: bottom, top;
    top: auto;
    left: auto;
    margin-top: 0.5rem;
  }

  /* Nested Opportunities Dropdown */
  #opportunities-positioned {
    position: absolute;
    position-anchor: --opportunities-trigger;
    position-area: right;
    position-try-fallbacks: right, left, bottom;
    margin-left: 0.5rem;
    border: 2px dashed #ef5324;
  }

  /* Dropdown Card */
  .dropdown-card {
    padding: 1rem;
  }

  .dropdown-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .dropdown-card li {
    margin: 0;
  }

  .dropdown-card a,
  .dropdown-card .nested-trigger {
    display: block;
    padding: 0.75rem 1rem;
    color: #1a1a1a;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--font-normal);
  }

  .dropdown-card a:hover,
  .dropdown-card .nested-trigger:hover {
    background-color: #f5f5f5;
    color: #e5e5e5;
    transform: translateX(4px);
  }

  /* Syle Grid Layout */
  .syle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    min-width: 400px;
  }

  /* Auth Section */
  .auth {
    display: flex;
    gap: 1.5rem;
    align-items: center;
  }

  .auth-link {
    color: white;
    text-decoration: none;
    font-weight: var(--font-medium);
    font-size: var(--text-base);
    transition: color 0.2s ease;
  }

  .auth-link:hover {
    color: #e5e5e5;
  }

  /* Mobile Menu Button */
  .mobile-menu-button {
    display: none;
    background: none;
    border: none;
    color: black;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1002;
  }

  .mobile-menu-button svg {
    width: 28px;
    height: 28px;
  }

  /* Mobile Drawer */
  .nav-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background-color: white;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    overflow-y: auto;
  }

  .nav-drawer.open {
    left: 0;
  }

  .nav-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
  }

  .nav-drawer-header img {
    height: 18px;
  }

  .drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: #1a1a1a;
  }

  .drawer-close svg {
    width: 24px;
    height: 24px;
  }

  /* Drawer Content */
  .nav-drawer-content {
    padding: 1rem 0;
  }

  .drawer-item {
    display: block;
    padding: 1rem 1.5rem;
    color: #1a1a1a;
    text-decoration: none;
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    transition: background-color 0.2s ease;
  }

  .drawer-item:hover {
    background-color: #f5f5f5;
  }

  /* Drawer Accordion */
  .drawer-accordion {
    border-bottom: 1px solid #e5e5e5;
  }

  .drawer-accordion summary {
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-weight: var(--font-semibold);
    font-size: var(--text-base);
    color: #1a1a1a;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
  }

  .drawer-accordion summary::after {
    content: '+';
    font-size: 1.5rem;
    transition: transform 0.3s ease;
  }

  .drawer-accordion[open] summary::after {
    transform: rotate(45deg);
  }

  .drawer-accordion summary:hover {
    background-color: #f5f5f5;
  }

  .drawer-accordion ul {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #fafafa;
  }

  .drawer-accordion ul li {
    margin: 0;
  }

  .drawer-accordion ul a {
    display: block;
    padding: 0.75rem 2rem;
    color: #4a4a4a;
    text-decoration: none;
    font-size: var(--text-sm);
    transition: all 0.2s ease;
  }

  .drawer-accordion ul a:hover {
    background-color: #f0f0f0;
    color: #e5e5e5;
    padding-left: 2.5rem;
  }

  /* Nested Accordion */
  .nested-accordion {
    margin: 0.5rem 0;
  }

  .nested-accordion summary {
    padding: 0.75rem 2rem;
    background-color: #f5f5f5;
    font-weight: var(--font-medium);
    font-size: var(--text-sm);
  }

  .nested-accordion ul a {
    padding-left: 3rem;
    font-size: var(--text-xs);
  }

  .drawer-divider {
    height: 1px;
    background-color: #e5e5e5;
    margin: 1rem 0;
  }

  .mobile-cta {
    margin: 1rem 1.5rem;
    display: block;
    text-align: center;
  }

  /* Backdrop */
  .backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    transition: opacity 0.3s ease;
    opacity: 0;
  }

  .backdrop.show {
    display: block;
    opacity: 1;
  }

  /* ========================================
     FALLBACK FOR BROWSERS WITHOUT ANCHOR SUPPORT
     ======================================== */
  @supports not (anchor-name: --test) {
    /* Fallback positioning for older browsers */
    #volunteer-positioned,
    #syle-positioned,
    #peace-school-positioned,
    #what-is-news-positioned {
      position: absolute;
      top: 100%;
      left: 0;
      margin-top: 0.5rem;
    }

    #opportunities-positioned {
      position: absolute;
      top: 0;
      left: 100%;
      margin-left: 0.5rem;
    }
  }

  /* Mobile Responsive */
  @media (max-width: 1080px) {
    .mobile-menu-button {
      display: block;
      order: -1;
    }

    .desktop-nav,
    .desktop-auth {
      display: none;
    }

    .navbar {
      padding: 1rem 1.5rem;
      justify-content: space-between;
    }

    .logo {
      max-width: 140px;
      order: 2;
    }

    .first-title {
      font-size: var(--text-4xl);
    }

    .title {
      max-width: 100%;
      flex-wrap: wrap;
      gap: 2rem;
      justify-content: center;
      align-items: center;
      text-align: center;
      padding: 0 1rem;
    }
  }

  @media (max-width: 640px) {
    .nav-drawer {
      width: 90%;
    }

    .navbar {
      padding: 1rem;
    }

    .first-title {
      font-size: var(--text-3xl);
    }

    .hero-2-section h1 {
      font-size: var(--text-3xl);
    }

    .syle-grid {
      grid-template-columns: 1fr;
      min-width: auto;
    }

    /* Nested Opportunities Dropdown */
    .opportunities-dropdown {
      position-anchor: right;
      margin-left: 1rem;
    }

    /* Auth Section */
    .auth {
      display: flex;
      gap: 1.5rem;
      align-items: center;
    }

    .auth-link {
      color: white;
      text-decoration: none;
      font-weight: var(--font-medium);
      font-size: var(--text-base);
      transition: color 0.2s ease;
    }

    .auth-link:hover {
      color: white;
    }

    /* Mobile Menu Button */
    .mobile-menu-button {
      display: none;
      background: none;
      border: none;
      color: black;
      cursor: pointer;
      padding: 0.5rem;
      z-index: 1002;
    }

    .mobile-menu-button svg {
      width: 28px;
      height: 28px;
    }

    /* Mobile Drawer */
    .nav-drawer {
      position: fixed;
      top: 0;
      left: -100%;
      width: 85%;
      max-width: 320px;
      height: 100vh;
      background-color: white;
      box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
      transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      z-index: 1001;
      overflow-y: auto;
    }

    .nav-drawer.open {
      left: 0;
    }

    .nav-drawer-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 1.5rem;
      border-bottom: 1px solid #e5e5e5;
    }

    .nav-drawer-header img {
      height: 18px;
      margin: auto;
    }

    .drawer-close {
      background: none;
      border: none;
      cursor: pointer;
      padding: 0.5rem;
      color: #1a1a1a;
    }

    .drawer-close svg {
      width: 24px;
      height: 24px;
    }

    /* Drawer Content */
    .nav-drawer-content {
      padding: 1rem 0;
    }

    .drawer-item {
      display: block;
      padding: 1rem 1.5rem;
      color: #1a1a1a;
      text-decoration: none;
      font-size: var(--text-base);
      font-weight: var(--font-medium);
      transition: background-color 0.2s ease;
    }

    .drawer-item:hover {
      background-color: #f5f5f5;
    }

    /* Drawer Accordion */
    .drawer-accordion {
      border-bottom: 1px solid #e5e5e5;
    }

    .drawer-accordion summary {
      padding: 1rem 1.5rem;
      cursor: pointer;
      font-weight: var(--font-semibold);
      font-size: var(--text-base);
      color: #1a1a1a;
      list-style: none;
      display: flex;
      justify-content: space-between;
      align-items: center;
      user-select: none;
    }

    .drawer-accordion summary::after {
      content: '+';
      font-size: 1.5rem;
      transition: transform 0.3s ease;
    }

    .drawer-accordion[open] summary::after {
      transform: rotate(45deg);
    }

    .drawer-accordion summary:hover {
      background-color: #f5f5f5;
    }

    .drawer-accordion ul {
      list-style: none;
      padding: 0;
      margin: 0;
      background-color: #fafafa;
    }

    .drawer-accordion ul li {
      margin: 0;
    }

    .drawer-accordion ul a {
      display: block;
      padding: 0.75rem 2rem;
      color: #4a4a4a;
      text-decoration: none;
      font-size: var(--text-sm);
      transition: all 0.2s ease;
    }

    .drawer-accordion ul a:hover {
      background-color: #f0f0f0;
      color: #e5e5e5;
      padding-left: 2.5rem;
    }

    /* Nested Accordion */
    .nested-accordion {
      margin: 0.5rem 0;
    }

    .nested-accordion summary {
      padding: 0.75rem 2rem;
      background-color: #f5f5f5;
      font-weight: var(--font-medium);
      font-size: var(--text-sm);
    }

    .nested-accordion ul a {
      padding-left: 3rem;
      font-size: var(--text-xs);
    }

    .drawer-divider {
      height: 1px;
      background-color: #e5e5e5;
      margin: 1rem 0;
    }

    .mobile-cta {
      margin: 1rem 1.5rem;
      display: block;
      text-align: center;
    }

    /* Backdrop */
    .backdrop {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.6);
      z-index: 1000;
      transition: opacity 0.3s ease;
      opacity: 0;
    }

    .backdrop.show {
      display: block;
      opacity: 1;
    }

    /* Mobile Responsive */
    @media (max-width: 1080px) {
      .mobile-menu-button {
        display: block;
        order: -1;
      }

      .desktop-nav,
      .desktop-auth {
        display: none;
      }

      .navbar {
        padding: 1rem 1.5rem;
        justify-content: space-between;
      }

      .logo {
        max-width: 140px;
        order: 2;
      }

      .first-title {
        font-size: var(--text-xl);
      }

      .title {
        max-width: 100%;
        flex-wrap: wrap;
        gap: 2rem;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 0 1rem;
      }
    }

    @media (max-width: 640px) {
      .nav-drawer {
        width: 90%;
      }

      .navbar {
        padding: 1rem;
      }

      .first-title {
        font-size: var(--text-3xl);
      }

      .hero-2-section h1 {
        font-size: var(--text-3xl);
      }
    }
  }
}
