/* ============================================================
   SPATIAL BENTO UI — WORLD-CLASS EDITION
   Latest Web Standards: View Transitions, CSS Cascade Layers,
   @starting-style, scroll-driven animations, container queries
   ============================================================ */

@layer base, animations, components, responsive;

@layer base {
  .spatial-wrapper {
    min-height: 100vh;
    background-color: #030305;
    color: #ffffff;
    font-family: var(--font-ar);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
  }
}

/* ============================================================
   KEYFRAMES — All animations defined here
   ============================================================ */
@layer animations {

  @keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  @keyframes fadeSlideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  @keyframes slowSpin {
    0%   { transform: rotate(0deg) scale(1); }
    50%  { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
  }

  @keyframes floatWidget {
    0%   { transform: translateY(0px); }
    100% { transform: translateY(-12px); }
  }

  @keyframes shimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
  }

  @keyframes islandPulse {
    0%, 100% { box-shadow: 0 20px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 0 0 rgba(255,255,255,0.05); }
    50%       { box-shadow: 0 20px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05), 0 0 0 8px rgba(255,255,255,0); }
  }

  @keyframes particleDrift {
    0%   { transform: translate(0, 0) scale(1); opacity: 0.6; }
    33%  { transform: translate(30px, -20px) scale(1.2); opacity: 1; }
    66%  { transform: translate(-20px, 10px) scale(0.9); opacity: 0.4; }
    100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
  }

  @keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
  }

  @keyframes glowPulse {
    0%, 100% { opacity: 0.12; transform: scale(1); }
    50%       { opacity: 0.2; transform: scale(1.03); }
  }

  @keyframes borderGlow {
    0%, 100% { border-color: rgba(255,255,255,0.08); }
    50%       { border-color: rgba(255,255,255,0.2); }
  }

  @keyframes scaleIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
  }
}

/* ============================================================
   CINEMATIC BACKGROUND
   ============================================================ */
@layer components {

  .spatial-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
  }

  /* Ambient glow blobs */
  .spatial-bg::before {
    content: '';
    position: absolute;
    width: 700px; height: 700px;
    top: -20%; right: -10%;
    background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 70%);
    animation: glowPulse 15s ease-in-out infinite;
    border-radius: 50%;
  }

  .spatial-bg::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    bottom: -15%; left: 10%;
    background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 70%);
    animation: glowPulse 20s ease-in-out infinite reverse;
    border-radius: 50%;
  }

  .spatial-shape {
    position: absolute;
    width: 800px; height: 800px;
    top: -10%; left: -10%;
    opacity: 0.15;
    filter: blur(16px);
    mix-blend-mode: screen;
    /* animation: slowSpin 60s linear infinite; removed to prevent JS conflict */
  }

  .teacher-cinematic {
    position: absolute;
    inset: 0;
    background-image: url('teacher.jpg');
    background-size: cover;
    background-position: center 20%;
    opacity: 0.3;
    mask-image: radial-gradient(circle at center, black 0%, transparent 65%);
    -webkit-mask-image: radial-gradient(circle at center, black 0%, transparent 65%);
    animation: fadeIn 1.5s ease 0.5s both;
  }

  /* Particle Canvas Layer */
  #particleCanvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.4;
  }

  /* ============================================================
     DYNAMIC ISLAND NAVBAR
     ============================================================ */

  .dynamic-island {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(20, 20, 25, 0.95);
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 24px;
    animation: fadeSlideDown 0.6s ease-out both;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
    will-change: transform;
  }

  .dynamic-island:hover {
    background: rgba(25, 25, 35, 0.8);
    padding: 10px 28px;
    gap: 32px;
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.15);
  }

  .island-logo {
    font-weight: 800;
    font-size: 15px;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    letter-spacing: -0.3px;
  }

  .island-links {
    display: flex;
    gap: 24px;
  }

  .island-links a {
    color: #71717a;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.3s ease;
    position: relative;
    white-space: nowrap;
  }

  .island-links a::after {
    content: '';
    position: absolute;
    bottom: -4px; left: 0; right: 0;
    height: 1px;
    background: white;
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: right;
  }

  .island-links a:hover::after,
  .island-links a.active::after {
    transform: scaleX(1);
    transform-origin: left;
  }

  .island-links a:hover,
  .island-links a.active {
    color: #ffffff;
  }

  .island-btn {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 8px 18px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease;
    white-space: nowrap;
    font-family: inherit;
  }

  .island-btn:hover {
    background: #ffffff;
    color: #000000;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255,255,255,0.2);
  }

  /* ============================================================
     SPATIAL HERO CONTENT
     ============================================================ */

  .spatial-hero {
    flex: 1;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 60px;
    padding: 120px 20px 60px;
  }

  /* ============================================================
     CENTRAL TYPOGRAPHY — Staggered Entrance
     ============================================================ */

  .central-title-container {
    text-align: center;
    max-width: 900px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }

  .central-title {
    font-size: 72px;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -2.5px;
    background: linear-gradient(160deg, #ffffff 0%, #ffffff 40%, #a5b4fc 70%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    animation: fadeSlideUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
    will-change: transform, opacity;
  }

  .central-subtitle {
    font-size: 20px;
    color: #a1a1aa;
    max-width: 580px;
    line-height: 1.7;
    margin: 0;
    animation: fadeSlideUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
    will-change: transform, opacity;
  }

  /* Typewriter cursor */
  .typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: #818cf8;
    margin-right: 2px;
    vertical-align: text-bottom;
    animation: cursorBlink 1s step-end infinite;
    border-radius: 1px;
  }

  /* CTA Button — Shimmer Effect */
  .btn-start-orbit {
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(8px);
    color: white;
    padding: 16px 40px;
    border-radius: 100px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    animation: fadeSlideUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.5s both;
    will-change: transform;
  }

  .btn-start-orbit::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.15) 40%,
      rgba(255, 255, 255, 0.3) 50%,
      rgba(255, 255, 255, 0.15) 60%,
      transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 7s linear infinite;
    border-radius: inherit;
  }

  .btn-start-orbit:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #000000;
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 20px 40px rgba(255,255,255,0.15), 0 0 60px rgba(139,92,246,0.2);
    border-color: rgba(255,255,255,0.8);
  }

  .btn-start-orbit:active {
    transform: scale(0.97);
  }

  /* ============================================================
     BENTO WIDGETS — Staggered Entrance + Float
     ============================================================ */

  .spatial-widgets {
    position: relative;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 780px;
    width: 100%;
  }

  .bento-widget.glass {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(30, 30, 45, 0.95);
  will-change: transform;
    pointer-events: auto;
    background: rgba(18, 18, 24, 0.5);
    backdrop-filter: blur(8px) saturate(150%);
    -webkit-backdrop-filter: blur(8px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    animation: fadeSlideUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) var(--stagger, 0.6s) both;
    will-change: transform;
  }

  .bento-widget.glass:nth-child(1) { --stagger: 0.6s; }
  .bento-widget.glass:nth-child(2) { --stagger: 0.75s; animation-direction: normal, normal, alternate; }
  .bento-widget.glass:nth-child(3) { --stagger: 0.9s; }
  .bento-widget.glass:nth-child(4) { --stagger: 1.05s; animation-direction: normal, normal, alternate; }

  .bento-widget.glass:hover {
    background: rgba(35, 35, 50, 0.85);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-4px) scale(1.01) !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    z-index: 50;
  }

  .bento-widget.glass:active {
    transform: scale(0.97) !important;
  }

  .w-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    transition: all 0.3s ease;
  }

  .bento-widget.glass:hover .w-icon {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.3);
    transform: scale(1.1) rotate(-5deg);
  }

  .w-content h4 {
    font-size: 15px;
    font-weight: 700;
    color: white;
    margin: 0 0 4px 0;
  }

  .w-content span {
    font-size: 13px;
    color: #71717a;
    line-height: 1.5;
  }

  .w-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: center;
  }

  .stat-num {
    font-size: 40px;
    font-weight: 900;
    background: linear-gradient(135deg, #4ade80, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    letter-spacing: -1px;
  }

  .stat-label {
    font-size: 13px;
    color: #a1a1aa;
    font-weight: 600;
  }

  .student-avatars {
    display: flex;
    margin-top: 4px;
    justify-content: center;
  }

  .student-avatars .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #030305;
    object-fit: cover;
    margin-right: -10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
  }

  .student-avatars .avatar:first-child { margin-right: 0; }
  .student-avatars:hover .avatar { transform: translateX(0); }
  .student-avatars .avatar:hover { transform: translateY(-4px) scale(1.1) !important; z-index: 10; }

} /* end @layer components */

/* ============================================================
   MOBILE & TABLET RESPONSIVE
   ============================================================ */
@layer responsive {

  /* --- Tablet Landscape (≤1024px) --- */
  @media (max-width: 1024px) {
    .central-title { font-size: 52px; letter-spacing: -1.5px; }
    .central-subtitle { font-size: 18px; }
    .spatial-widgets { max-width: 680px; gap: 16px; }
  }

  /* --- Tablet Portrait (≤768px) --- */
  @media (max-width: 768px) {
    .dynamic-island {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(20, 20, 25, 0.95);
      top: auto;
      bottom: 16px;
      left: 50%;
      transform: translateX(-50%);
      width: calc(100% - 32px);
      max-width: 480px;
      justify-content: space-between;
      padding: 10px 16px;
      border-radius: 20px;
      /* Glassmorphism bottom nav */
      background: rgba(10, 10, 15, 0.85);
      backdrop-filter: blur(16px) saturate(200%);
      border-top: 1px solid rgba(255,255,255,0.1);
      animation: fadeSlideUp 0.6s ease-out both;
    }

    .island-links { gap: 16px; }
    .island-links a { font-size: 13px; }

    .spatial-hero {
      padding: 80px 16px 120px;
      gap: 40px;
      justify-content: center;
      padding-top: 100px;
    }

    .central-title {
      font-size: 42px;
      letter-spacing: -1px;
    }

    .central-subtitle {
      font-size: 16px;
    }

    .btn-start-orbit {
      width: 100%;
      max-width: 340px;
      text-align: center;
      padding: 16px 24px;
    }

    .spatial-widgets {
      grid-template-columns: 1fr 1fr;
      gap: 12px;
      max-width: 100%;
    }

    .bento-widget.glass {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(30, 30, 45, 0.95);
  will-change: transform;
      padding: 16px;
      gap: 12px;
      animation: fadeSlideUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) var(--stagger, 0.6s) both; /* no float on mobile */
    }

    .w-content h4 { font-size: 14px; }
    .w-content span { font-size: 12px; }
  }

  /* --- Mobile Small (≤480px) --- */
  @media (max-width: 480px) {
    .central-title {
      font-size: 34px;
      letter-spacing: -0.8px;
    }

    .central-subtitle { font-size: 15px; }

    .spatial-widgets {
      grid-template-columns: 1fr;
    }

    .bento-widget.glass:nth-child(1),
    .bento-widget.glass:nth-child(2),
    .bento-widget.glass:nth-child(3),
    .bento-widget.glass:nth-child(4) {
      --stagger: 0.5s;
    }

    .island-links { display: none; }
    .island-logo { font-size: 14px; }
  }

  /* --- Very Small Mobile (≤390px) --- */
  @media (max-width: 390px) {
    .central-title { font-size: 28px; letter-spacing: -0.5px; }
    .spatial-hero { padding-top: 80px; }
    .stat-num { font-size: 32px; }
  }

  /* Disable parallax / heavy animations on touch devices */
  @media (hover: none) {
    .bento-widget.glass {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(30, 30, 45, 0.95);
  will-change: transform;
      animation: fadeSlideUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) var(--stagger, 0.6s) both !important;
    }

    .spatial-shape { animation: none; opacity: 0.08; }
  }

  /* Respect reduced motion preference */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      transition-duration: 0.01ms !important;
    }
  }

} /* end @layer responsive */
