<?php declare(strict_types=1);
/**
 * College2U — Top Engineering Colleges in Bangalore
 * public_html/engineering/top-engineering-colleges.php · v5.0.0 · May 2026
 *
 * SEO intent: "top engineering colleges in Bangalore 2026"
 * Schema: ItemList + FAQPage + BreadcrumbList
 */

require_once dirname(__DIR__) . '/includes/bootstrap.php';

$current_year = (int) date('Y');

// College data — ranked by KCET closing rank CSE (General, previous year)
$colleges = [
    ['name' => 'R V College of Engineering',              'slug' => 'rv-college-of-engineering',           'type' => 'Aided',   'est' => 1963, 'naac' => 'A++', 'aff' => 'VTU / Autonomous', 'cse_rank' => '~250',    'fee' => '₹38,000/yr', 'seats' => 420],
    ['name' => 'BMS College of Engineering',              'slug' => 'bms-college-of-engineering',          'type' => 'Aided',   'est' => 1946, 'naac' => 'A+',  'aff' => 'VTU / Autonomous', 'cse_rank' => '~500',    'fee' => '₹42,000/yr', 'seats' => 360],
    ['name' => 'M S Ramaiah Institute of Technology',     'slug' => 'ms-ramaiah-institute-of-technology',  'type' => 'Private', 'est' => 1962, 'naac' => 'A+',  'aff' => 'VTU',              'cse_rank' => '~1,200',  'fee' => '₹1.1 lakh/yr', 'seats' => 480],
    ['name' => 'PES University',                          'slug' => 'pes-university',                      'type' => 'Deemed',  'est' => 1988, 'naac' => 'A+',  'aff' => 'Deemed',           'cse_rank' => '~1,800',  'fee' => '₹2.4 lakh/yr', 'seats' => 540],
    ['name' => 'Dayananda Sagar College of Engineering',  'slug' => 'dayananda-sagar-college-engineering', 'type' => 'Private', 'est' => 1979, 'naac' => 'A',   'aff' => 'VTU',              'cse_rank' => '~5,000',  'fee' => '₹1.3 lakh/yr', 'seats' => 360],
    ['name' => 'New Horizon College of Engineering',      'slug' => 'new-horizon-college-of-engineering',  'type' => 'Private', 'est' => 2001, 'naac' => 'A',   'aff' => 'VTU',              'cse_rank' => '~8,000',  'fee' => '₹1.2 lakh/yr', 'seats' => 360],
    ['name' => 'Sir M Visvesvaraya Institute of Technology','slug' => 'sir-m-visvesvaraya-institute-tech', 'type' => 'Private', 'est' => 1986, 'naac' => 'A',   'aff' => 'VTU',              'cse_rank' => '~10,000', 'fee' => '₹1.1 lakh/yr', 'seats' => 300],
    ['name' => 'Bangalore Institute of Technology',       'slug' => 'bangalore-institute-of-technology',   'type' => 'Aided',   'est' => 1979, 'naac' => 'A',   'aff' => 'VTU',              'cse_rank' => '~12,000', 'fee' => '₹45,000/yr',   'seats' => 300],
    ['name' => 'Jain University',                         'slug' => 'jain-university',                     'type' => 'Deemed',  'est' => 1990, 'naac' => 'A',   'aff' => 'Deemed',           'cse_rank' => 'Direct',  'fee' => '₹2.2 lakh/yr', 'seats' => 480],
    ['name' => 'CMR Institute of Technology',             'slug' => 'cmr-institute-of-technology',         'type' => 'Private', 'est' => 2000, 'naac' => 'A',   'aff' => 'VTU',              'cse_rank' => '~20,000', 'fee' => '₹1.0 lakh/yr', 'seats' => 300],
];

$faqs = [
    ['q' => 'What is the best engineering college in Bangalore ' . $current_year . '?',
     'a' => 'R V College of Engineering (RVCE) is widely considered the top engineering college in Bangalore for ' . $current_year . ', with NAAC A++ accreditation and a CSE KCET closing rank around 250. BMS College of Engineering (BMSCE), founded in 1946, is a close second with a NAAC A+ grade. Both are government-aided autonomous institutions affiliated with VTU.'],
    ['q' => 'Which engineering college in Bangalore has the best placements?',
     'a' => 'RVCE, BMSCE, and MSRIT consistently top campus placement records in Bangalore. RVCE reported average CTC of ₹8–12 lakh and highest CTC above ₹1 crore for CSE graduates. Microsoft, Google, Amazon, and Infosys are top recruiters across these colleges.'],
    ['q' => 'What KCET rank do I need for top engineering colleges in Bangalore?',
     'a' => 'A KCET rank below 500 is required for CSE at RVCE or BMSCE, the top government-aided colleges. MSRIT CSE fills at ranks up to 1,200. PES University and other deemed institutions accept KCET/JEE Main with ranks typically in the 1,000–5,000 range for CSE.'],
    ['q' => 'Are RVCE and BMS College government or private?',
     'a' => 'Both RVCE (RV College of Engineering) and BMS College of Engineering are private aided colleges — they are private institutions that receive partial government grants. This is why their KCET-allotted annual fees are much lower (₹35,000–₹45,000) compared to private unaided colleges.'],
    ['q' => 'What is VTU and do all engineering colleges in Bangalore follow it?',
     'a' => 'Visvesvaraya Technological University (VTU) is the state engineering university affiliated with most government and private engineering colleges in Karnataka. Autonomous colleges like RVCE and BMSCE follow VTU affiliation but conduct their own exams. PES University and Jain University are deemed universities with independent degree-granting powers.'],
];

// ── SEO ──────────────────────────────────────────────────────────────────────
$page_title       = 'Top Engineering Colleges Bangalore ' . $current_year . ' — KCET Cutoffs &amp; Fees | College2U';
$meta_description = 'Ranked: top engineering colleges in Bangalore ' . $current_year . ' with KCET cutoffs, NAAC grades, annual fees, and seat count. Free personalised shortlist from College2U.';
$canonical_path   = 'engineering/top-engineering-colleges';
$body_class       = 'c2u-page c2u-page--college-list c2u-page--engineering-list';
$og_image         = c2u_asset('images/og/top-engineering-colleges-og.webp');

$breadcrumbs = [
    ['name' => 'Engineering', 'url' => c2u_url('engineering')],
    ['name' => 'Top Engineering Colleges ' . $current_year, 'url' => c2u_url('engineering/top-engineering-colleges')],
];

// ItemList schema
$college_list_items = array_map(fn($c, $i) => [
    'position' => $i + 1,
    'name'     => $c['name'],
    'url'      => c2u_url('college/' . $c['slug']),
], $colleges, array_keys($colleges));

$item_list_schema = [
    '@context'        => 'https://schema.org',
    '@type'           => 'ItemList',
    'name'            => 'Top Engineering Colleges in Bangalore ' . $current_year,
    'numberOfItems'   => count($colleges),
    'itemListElement' => array_map(fn($item) => [
        '@type'    => 'ListItem',
        'position' => $item['position'],
        'name'     => $item['name'],
        'url'      => $item['url'],
    ], $college_list_items),
];

$faq_schema = [
    '@context'   => 'https://schema.org',
    '@type'      => 'FAQPage',
    'mainEntity' => array_map(fn($f) => [
        '@type'          => 'Question',
        'name'           => $f['q'],
        'acceptedAnswer' => ['@type' => 'Answer', 'text' => $f['a']],
    ], $faqs),
];

$extra_schemas = [
    c2u_schema_breadcrumb($breadcrumbs),
    $item_list_schema,
    $faq_schema,
];

// ── CSS ───────────────────────────────────────────────────────────────────────
$extra_head = '<style nonce="' . c2u_e(C2U_CSP_NONCE) . '">
:root{--blue:#3b82f6;--blue-d:#1d4ed8;--blue-l:#eff6ff;--blue-m:#dbeafe;--surface:#f8fafc;--border:#e2e8f0;--text:#0f172a;--muted:#64748b;--radius:.875rem;}
.list-hero{background:linear-gradient(145deg,#050d1a 0%,#0a1f3b 100%);padding:3.5rem 1.5rem 4rem;position:relative;overflow:hidden;}
.list-hero__inner{max-width:1200px;margin:0 auto;}
.list-hero h1{font-size:clamp(1.75rem,4vw,2.75rem);font-weight:800;color:#fff;margin:.75rem 0 1rem;letter-spacing:-.025em;line-height:1.15;}
.list-hero h1 em{color:#93c5fd;font-style:normal;}
.list-hero p{color:rgba(255,255,255,.72);font-size:.9375rem;max-width:620px;line-height:1.65;margin:0;}
.list-eyebrow{display:inline-flex;align-items:center;gap:.5rem;background:rgba(59,130,246,.2);border:1px solid rgba(59,130,246,.4);color:#93c5fd;border-radius:2rem;padding:.35rem .8rem;font-size:.78rem;font-weight:600;letter-spacing:.04em;text-transform:uppercase;margin-bottom:.75rem;}
.c2u-section{padding:4rem 1.5rem;}
.c2u-section--alt{background:var(--surface);}
.c2u-section-inner{max-width:1200px;margin:0 auto;}
.c2u-section-heading{font-size:clamp(1.375rem,3vw,2rem);font-weight:800;color:var(--text);letter-spacing:-.025em;margin:0 0 .5rem;}
.c2u-section-heading em{color:var(--blue-d);font-style:normal;}
.c2u-section-sub{font-size:.9375rem;color:var(--muted);margin:0 0 2rem;line-height:1.6;max-width:600px;}
/* Filter tabs */
.filter-tabs{display:flex;flex-wrap:wrap;gap:.5rem;margin-bottom:2rem;}
.filter-tab{padding:.4rem 1rem;border:1.5px solid var(--border);border-radius:2rem;font-size:.8125rem;font-weight:600;color:var(--muted);background:#fff;cursor:pointer;transition:all .2s;}
.filter-tab.active,.filter-tab:hover{border-color:var(--blue);color:var(--blue-d);background:var(--blue-l);}
/* College cards grid */
.college-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:1.25rem;}
.college-card{background:#fff;border:1.5px solid var(--border);border-radius:var(--radius);padding:1.5rem;transition:border-color .2s,box-shadow .2s;display:flex;flex-direction:column;gap:.875rem;}
.college-card:hover{border-color:var(--blue);box-shadow:0 4px 24px rgba(59,130,246,.1);}
.college-card__header{display:flex;align-items:flex-start;gap:.875rem;}
.college-card__logo{width:52px;height:52px;flex-shrink:0;}
.college-card__title{font-size:1rem;font-weight:700;color:var(--text);margin:0 0 .25rem;line-height:1.3;}
.college-card__sub{font-size:.8125rem;color:var(--muted);}
.college-card__tags{display:flex;flex-wrap:wrap;gap:.375rem;}
.ctag{display:inline-block;padding:.2rem .625rem;border-radius:.25rem;font-size:.75rem;font-weight:600;}
.ctag--aided{background:#dcfce7;color:#166534;}
.ctag--private{background:#fef3c7;color:#92400e;}
.ctag--deemed{background:#ede9fe;color:#5b21b6;}
.ctag--naac{background:var(--blue-m);color:#1e40af;}
.college-card__stats{display:grid;grid-template-columns:1fr 1fr;gap:.625rem;}
.cstat{display:flex;flex-direction:column;gap:.125rem;}
.cstat__label{font-size:.75rem;color:var(--muted);font-weight:500;}
.cstat__val{font-size:.875rem;font-weight:700;color:var(--text);}
.cstat__val--rank{color:var(--blue-d);}
.college-card__cta{display:flex;align-items:center;justify-content:space-between;margin-top:auto;padding-top:.75rem;border-top:1px solid var(--border);}
.college-card__cta a{font-size:.8125rem;font-weight:600;color:var(--blue-d);text-decoration:none;}
.college-card__cta a:hover{text-decoration:underline;}
.college-card__rank-badge{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;background:var(--blue-l);color:var(--blue-d);font-size:.8rem;font-weight:800;flex-shrink:0;}
/* FAQ */
.faq-list{max-width:760px;}
.faq-item{border-bottom:1px solid var(--border);}
.faq-q{width:100%;display:flex;justify-content:space-between;align-items:center;background:none;border:none;cursor:pointer;padding:1rem 0;font-size:.9375rem;font-weight:600;color:var(--text);text-align:left;gap:1rem;}
.faq-q__icon{flex-shrink:0;transition:transform .25s;color:var(--muted);}
.faq-q[aria-expanded="true"] .faq-q__icon{transform:rotate(180deg);}
.faq-a{padding:0 0 1rem;font-size:.9375rem;line-height:1.65;color:var(--muted);}
.faq-a[hidden]{display:none;}
.cta-banner{background:linear-gradient(135deg,var(--blue-l),var(--blue-m));border:1.5px solid #93c5fd;border-radius:var(--radius);padding:2.5rem;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:1.5rem;margin-top:3rem;}
.cta-banner h2{font-size:1.25rem;font-weight:800;color:#1e3a8a;margin:0;}
.cta-banner p{font-size:.9375rem;color:var(--blue-d);margin:.25rem 0 0;}
.btn--cta{background:var(--blue);color:#fff;font-weight:700;font-size:.9375rem;padding:.75rem 1.75rem;border-radius:.5rem;border:none;cursor:pointer;text-decoration:none;white-space:nowrap;transition:background .2s;flex-shrink:0;}
.btn--cta:hover{background:var(--blue-d);}
@media(max-width:640px){.college-cards{grid-template-columns:1fr;}}
</style>';

$page_js = <<<'JS'
(function(){
  // FAQ accordion
  document.querySelectorAll('.faq-q').forEach(function(btn){
    btn.addEventListener('click',function(){
      var exp=this.getAttribute('aria-expanded')==='true';
      document.querySelectorAll('.faq-q').forEach(function(b){b.setAttribute('aria-expanded','false');var p=document.getElementById(b.getAttribute('aria-controls'));if(p){p.hidden=true;}});
      if(!exp){this.setAttribute('aria-expanded','true');var panel=document.getElementById(this.getAttribute('aria-controls'));if(panel){panel.hidden=false;}}
    });
  });
  // Filter tabs (graceful — all colleges visible when JS disabled)
  var tabs=document.querySelectorAll('.filter-tab');
  var cards=document.querySelectorAll('.college-card[data-type]');
  tabs.forEach(function(tab){
    tab.addEventListener('click',function(){
      tabs.forEach(function(t){t.classList.remove('active');});
      this.classList.add('active');
      var filter=this.dataset.filter;
      cards.forEach(function(card){
        card.style.display=(filter==='all'||card.dataset.type===filter)?'':'none';
      });
    });
  });
})();
JS;

require_once C2U_INCLUDES . '/header.php';
?>

<!-- HERO -->
<section class="list-hero" aria-labelledby="list-h1">
  <div class="list-hero__inner">
    <nav aria-label="Breadcrumb" style="margin-bottom:1rem;">
      <ol style="list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;align-items:center;gap:.4rem;font-size:.8125rem;color:rgba(255,255,255,.5);">
        <li><a href="<?= c2u_e(c2u_url('')) ?>" style="color:rgba(255,255,255,.5);text-decoration:none;">Home</a></li>
        <li aria-hidden="true" style="color:rgba(255,255,255,.3);">/</li>
        <li><a href="<?= c2u_e(c2u_url('engineering')) ?>" style="color:rgba(255,255,255,.5);text-decoration:none;">Engineering</a></li>
        <li aria-hidden="true" style="color:rgba(255,255,255,.3);">/</li>
        <li aria-current="page" style="color:rgba(255,255,255,.8);">Top Colleges <?= $current_year ?></li>
      </ol>
    </nav>
    <p class="list-eyebrow">AICTE Approved · NAAC Ranked · <?= $current_year ?></p>
    <h1 id="list-h1">
      Top Engineering Colleges in <em>Bangalore</em> <?= $current_year ?>
    </h1>
    <p>
      Ranked by KCET closing rank (<abbr title="Computer Science Engineering">CSE</abbr>, General category, <?= $current_year - 1 ?> allotment).
      Includes NAAC grade, annual fee, and seat count. Data from <abbr title="Karnataka Examinations Authority">KEA</abbr> and <abbr title="All India Council for Technical Education">AICTE</abbr> official sources.
    </p>
  </div>
</section>

<!-- COLLEGE LIST -->
<section class="c2u-section" id="colleges" aria-labelledby="colleges-h2">
  <div class="c2u-section-inner">
    <header style="margin-bottom:1.5rem;">
      <h2 class="c2u-section-heading" id="colleges-h2">
        Best Engineering Colleges in Bangalore <?= $current_year ?> — Ranked by KCET
      </h2>
      <p class="c2u-section-sub">
        Filter by college type. All colleges are <abbr title="All India Council for Technical Education">AICTE</abbr>-approved and <abbr title="Visvesvaraya Technological University">VTU</abbr>-affiliated unless noted.
      </p>
    </header>

    <!-- Filter tabs — JS enhanced, degrades gracefully -->
    <div class="filter-tabs" role="tablist" aria-label="Filter by college type">
      <button class="filter-tab active" data-filter="all" role="tab" aria-selected="true">All colleges</button>
      <button class="filter-tab" data-filter="aided" role="tab" aria-selected="false">Govt-Aided</button>
      <button class="filter-tab" data-filter="private" role="tab" aria-selected="false">Private Unaided</button>
      <button class="filter-tab" data-filter="deemed" role="tab" aria-selected="false">Deemed University</button>
    </div>

    <div class="college-cards" data-animate="stagger" role="list">
      <?php foreach ($colleges as $i => $col):
        $type_lc = strtolower(str_contains($col['type'], 'Aided') ? 'aided' : (str_contains($col['type'], 'Deemed') ? 'deemed' : 'private'));
      ?>
      <article class="college-card" role="listitem" data-type="<?= $type_lc ?>">
        <div class="college-card__header">
          <div class="college-card__rank-badge" aria-label="Rank <?= $i + 1 ?>"><?= $i + 1 ?></div>
          <div class="college-card__logo" aria-hidden="true">
            <?= logoHtml($col['name'], $col['slug'], 'College2U', 52) ?>
          </div>
          <div>
            <h3 class="college-card__title"><?= c2u_e($col['name']) ?></h3>
            <p class="college-card__sub">Bangalore · <?= c2u_e($col['aff']) ?> · Est. <?= c2u_e((string)$col['est']) ?></p>
          </div>
        </div>

        <div class="college-card__tags">
          <?php
          $tagClass = match(true) {
              str_contains($col['type'], 'Aided')  => 'ctag--aided',
              str_contains($col['type'], 'Deemed') => 'ctag--deemed',
              default => 'ctag--private',
          };
          ?>
          <span class="ctag <?= $tagClass ?>"><?= c2u_e($col['type']) ?></span>
          <span class="ctag ctag--naac">NAAC <?= c2u_e($col['naac']) ?></span>
        </div>

        <div class="college-card__stats">
          <div class="cstat">
            <span class="cstat__label">KCET CSE closing rank</span>
            <span class="cstat__val cstat__val--rank"><?= c2u_e($col['cse_rank']) ?></span>
          </div>
          <div class="cstat">
            <span class="cstat__label">Annual fee (KCET)</span>
            <span class="cstat__val"><?= c2u_e($col['fee']) ?></span>
          </div>
          <div class="cstat">
            <span class="cstat__label">Total intake</span>
            <span class="cstat__val"><?= c2u_e((string)$col['seats']) ?> seats</span>
          </div>
          <div class="cstat">
            <span class="cstat__label">Established</span>
            <span class="cstat__val"><?= c2u_e((string)$col['est']) ?></span>
          </div>
        </div>

        <div class="college-card__cta">
          <a href="<?= c2u_e(c2u_url('college/' . $col['slug'])) ?>" aria-label="View full profile of <?= c2u_e($col['name']) ?>">Full college profile →</a>
          <a href="<?= c2u_e(c2u_url('counselor-booking')) ?>" aria-label="Apply to <?= c2u_e($col['name']) ?>">Apply now →</a>
        </div>
      </article>
      <?php endforeach; ?>
    </div>
  </div>
</section>

<!-- FAQ -->
<section class="c2u-section c2u-section--alt" id="faq" aria-labelledby="faq-h2">
  <div class="c2u-section-inner">
    <header style="margin-bottom:2.5rem;">
      <h2 class="c2u-section-heading" id="faq-h2">
        Frequently Asked Questions — Engineering Colleges Bangalore
      </h2>
    </header>

    <div class="faq-list" role="list" data-animate="stagger">
      <?php foreach ($faqs as $i => $faq): ?>
      <div class="faq-item" role="listitem">
        <button class="faq-q" id="tecfaq-btn-<?= $i ?>" type="button"
                aria-expanded="false" aria-controls="tecfaq-a-<?= $i ?>">
          <span><?= c2u_e($faq['q']) ?></span>
          <span class="faq-q__icon" aria-hidden="true">
            <svg width="18" height="18" viewBox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><path d="M4 6l5 5 5-5"/></svg>
          </span>
        </button>
        <div class="faq-a" id="tecfaq-a-<?= $i ?>"
             role="region" aria-labelledby="tecfaq-btn-<?= $i ?>"
             data-aeo-speakable hidden>
          <p><?= c2u_e($faq['a']) ?></p>
        </div>
      </div>
      <?php endforeach; ?>
    </div>

    <div class="cta-banner" role="complementary">
      <div>
        <h2>Get a free personalised shortlist for <?= $current_year ?></h2>
        <p>Based on your KCET or COMEDK rank — from College2U engineering counsellors.</p>
      </div>
      <a href="<?= c2u_e(c2u_url('counselor-booking')) ?>" class="btn--cta">Book free counselling →</a>
    </div>

    <nav aria-label="Related engineering guides" style="margin-top:3rem;">
      <h3 style="font-size:.875rem;font-weight:700;color:#64748b;letter-spacing:.04em;text-transform:uppercase;margin:0 0 1rem;">Related guides</h3>
      <ul style="list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;gap:.625rem;">
        <?php foreach ([
            ['B.E Admission Bangalore ' . $current_year, c2u_url('engineering/engineering-admission')],
            ['KCET ' . $current_year . ' Cutoff Guide',  c2u_url('exams/kcet-2026')],
            ['COMEDK UGET ' . $current_year . ' Guide',  c2u_url('exams/comedk-2026')],
            ['Engineering Stream Hub',                   c2u_url('engineering')],
            ['All Colleges — Bangalore',                 c2u_url('colleges')],
        ] as [$label, $href]): ?>
        <li>
          <a href="<?= c2u_e($href) ?>" style="display:inline-block;padding:.375rem .875rem;background:#fff;border:1.5px solid #e2e8f0;border-radius:2rem;font-size:.8125rem;font-weight:600;color:#374151;text-decoration:none;">
            <?= c2u_e($label) ?>
          </a>
        </li>
        <?php endforeach; ?>
      </ul>
    </nav>
  </div>
</section>

<?php require_once C2U_INCLUDES . '/footer.php'; ?>
