/* ============================================================================
   R630 · math.science.cmu.ac.th — DESKTOP DESIGN SYSTEM (≥1170px only)

   Reference: cmu.ac.th information architecture (institutional header,
   full-width hero, section bands, card grid, dark footer) — re-implemented,
   no CMU assets, fonts or markup copied.

   Identity tokens (Faculty of Science CI per mission):
     --d-green  #286428   structure · nav · links
     --d-gold   #FFD300   accent · active state · focus
     --d-ink    #212529   headings / strong text
     --d-muted  #495057   body text
     --d-surface #FFFFFF  cards
   8px spacing scale. Everything lives inside the media query, so the verified
   mobile (≤767) and tablet (768–1169) layers are untouched by construction.
   ========================================================================== */
@media (min-width: 1170px) {

  :root {
    --d-green: var(--science-purple-strong);   /* structural purple */
    --d-green-dark: var(--science-purple-deep);
    --d-purple: var(--science-purple);
    --d-science: var(--science-green);
    --d-gold: var(--science-gold);
    --d-ink: var(--ink);
    --d-muted: var(--text-secondary);
    --d-line: var(--border);
    --d-surface: var(--surface);
    --d-canvas: var(--surface-soft);
    --d-radius: 14px;
    --d-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 24px rgba(16, 24, 40, .06);
    --d-shadow-hover: 0 2px 4px rgba(16, 24, 40, .06), 0 18px 36px rgba(16, 24, 40, .12);
    --d-container: 1240px;
  }

  /* ---------- 1 · page shell ------------------------------------------- */
  html body {
    background: var(--d-canvas);
    color: var(--d-muted);
    font-size: 16px;
    line-height: 1.7;
  }
  html body .container {
    width: min(var(--d-container), calc(100% - 96px)) !important;
    max-width: var(--d-container) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  html body .container > .row { margin-left: 0; margin-right: 0; }
  html body .container > .row > [class*="col-"] { padding-left: 0; padding-right: 0; }

  /* ---------- 2 · header: [ MATH LOGO ]  [ menu ]  ....  [ icons ] ----- */
  html body .navbar.navbar-default.navbar-static-top {
    position: sticky;
    top: 0;
    z-index: 1030;
    margin: 0 !important;
    padding: 0 !important;
    background: var(--d-surface) !important;
    border: 0 !important;
    border-bottom: 1px solid var(--d-line) !important;
    border-radius: 0 !important;
    box-shadow: 0 1px 0 rgba(16, 24, 40, .04);
  }
  html body .navbar.navbar-default.navbar-static-top > .container {
    display: flex !important;
    align-items: center;
    gap: 20px;
    min-height: 88px;
    width: min(var(--d-container), calc(100% - 96px)) !important;
  }
  /* 2a · logo */
  html body .navbar-header {
    order: 1;
    flex: 0 0 auto;
    float: none !important;
    margin: 0 !important;
    min-height: 0 !important;
  }
  html body .navbar-header > br { display: none !important; }
  html body .navbar-header > a { display: flex; align-items: center; }
  html body .navbar-header > a > picture img {
    width: auto !important;
    height: 52px !important;
    max-height: 52px !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  /* 2b · primary menu, inline right of the logo */
  html body .navbar-full_Disable {
    order: 2;
    flex: 0 1 auto;          /* menu keeps its natural width; icons are pinned right */
    min-width: 0;
    background: transparent !important;
    border: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
  }
  html body .navbar-full_Disable > div {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
  }
  html body ul.nav_head.navbar-nav_head {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
  }
  html body ul.nav_head.navbar-nav_head > li { float: none !important; margin: 0 !important; position: relative; }
  html body ul.nav_head.navbar-nav_head > li > a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 10px !important;
    font-size: 13.5px !important;
    font-weight: 500;
    color: var(--d-ink) !important;
    text-decoration: none;
    border-radius: 10px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  html body ul.nav_head.navbar-nav_head > li > a > span { font-size: inherit !important; color: inherit !important; }
  html body ul.nav_head.navbar-nav_head > li > a:hover,
  html body ul.nav_head.navbar-nav_head > li > a:focus,
  html body ul.nav_head.navbar-nav_head > li.open > a {
    background: var(--surface-purple) !important;
    color: var(--d-green) !important;
    border-bottom-color: var(--d-gold);
  }
  html body ul.nav_head.navbar-nav_head .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1040;
    min-width: 240px;
    margin: 6px 0 0 !important;
    padding: 8px !important;
    background: var(--d-surface) !important;
    border: 1px solid var(--d-line) !important;
    border-radius: 12px !important;
    box-shadow: var(--d-shadow) !important;
  }
  html body ul.nav_head.navbar-nav_head .dropdown-menu > li > a {
    display: block;
    padding: 9px 12px !important;
    border-radius: 8px;
    font-size: 14px;
    color: var(--d-ink) !important;
  }
  html body ul.nav_head.navbar-nav_head .dropdown-menu > li > a:hover {
    background: var(--surface-purple) !important;
    color: var(--d-green) !important;
  }
  /* the legacy collapse menu is replaced by the inline menu on desktop.
     Bootstrap pins `.navbar-collapse.collapse{display:block!important}` at ≥768px,
     so the override has to out-specify that exact selector pair. */
  html body .navbar-collapse,
  html body .navbar-collapse.collapse,
  html body .navbar-collapse.collapse.in { display: none !important; }

  /* 2c · floating icon cluster (CMU-style, Math palette) */
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right {
    order: 3;
    flex: 0 0 auto;
    margin-left: auto !important;   /* floating cluster hugs the right edge */
    float: none !important;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 !important;
  }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li { float: none !important; display: flex; align-items: center; }
  /* the language flags carry three legacy <br> per item — they made the icon row 120px tall */
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li > br { display: none !important; }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li > a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0 !important;
    border-radius: 50%;
    background: var(--surface-purple) !important;
    border: 0 !important;
    transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
  }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li > a img {
    height: 20px !important;
    width: auto !important;
    max-height: 22px !important;
  }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li > a:hover,
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li > a:focus {
    background: var(--d-green) !important;
    box-shadow: 0 6px 16px rgba(110, 78, 138, .28);
    transform: translateY(-1px);
  }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li > a:hover img,
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li > a:focus img { filter: brightness(0) invert(1); }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right .dropdown-menu {
    position: absolute;
    right: 0;
    left: auto;
    min-width: 230px;
    margin-top: 8px !important;
    padding: 8px !important;
    border: 1px solid var(--d-line) !important;
    border-radius: 12px !important;
    box-shadow: var(--d-shadow) !important;
  }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right .dropdown-menu > li > a {
    padding: 9px 12px !important;
    border-radius: 8px;
    font-size: 13.5px;
    color: var(--d-ink) !important;
    white-space: nowrap;
  }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right .dropdown-menu > li > a:hover {
    background: var(--surface-purple) !important;
    color: var(--d-green) !important;
  }

  /* ---------- 4 · hero (Ken Burns slider) ------------------------------ */
  html body .body-light { padding: 24px 0 0 !important; background: transparent !important; }
  html body .bannercontainer.centerme {
    width: min(var(--d-container), calc(100% - 96px)) !important;
    max-width: var(--d-container) !important;
    margin: 0 auto !important;
    border-radius: 20px !important;
    overflow: hidden;
    box-shadow: var(--d-shadow);
  }
  html body .bannershadow { display: none !important; }

  /* ---------- 5 · news area ------------------------------------------- */
  html body .container > .row { background: transparent !important; }
  html body ul.nav.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 28px 0 20px !important;
    padding: 0 !important;
    border: 0 !important;
    width: auto !important;
  }
  html body ul.nav.nav-tabs > li { float: none !important; margin: 0 !important; width: auto !important; }
  html body ul.nav.nav-tabs > li > a {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 8px 16px !important;
    margin: 0 !important;
    border: 1px solid var(--d-line) !important;
    border-radius: 999px !important;
    background: var(--d-surface) !important;
    font-size: 14.5px !important;
    font-weight: 500;
    color: var(--d-muted) !important;
    text-decoration: none;
  }
  html body ul.nav.nav-tabs > li > a i { font-size: 18px !important; margin: 0 !important; color: var(--d-green); }
  html body ul.nav.nav-tabs > li > a:hover { border-color: var(--d-green) !important; color: var(--d-green) !important; }
  html body ul.nav.nav-tabs > li.active > a,
  html body ul.nav.nav-tabs > li.active > a:hover,
  html body ul.nav.nav-tabs > li.active > a:focus {
    background: var(--d-green) !important;
    border-color: var(--d-green) !important;
    color: #FFFFFF !important;
    box-shadow: inset 0 0 0 2px var(--d-gold);   /* full ring, not a bottom arc on a pill */
  }
  html body ul.nav.nav-tabs > li.active > a i { color: var(--d-gold); }

  /* news grid: 3 columns, image on top, left-aligned text */
  html body .tab-content > .tab-pane > .row {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    margin: 0 !important;
  }
  html body .tab-content > .tab-pane > .row > .col-md-12 { grid-column: 1 / -1; }
  html body .box-height.font-news {
    display: flex !important;
    flex-direction: column;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: var(--d-surface);
    border: 1px solid var(--d-line);
    border-radius: var(--d-radius);
    box-shadow: var(--d-shadow);
    overflow: hidden;
    text-align: left;
    transition: box-shadow .18s ease, transform .18s ease;
  }
  html body .box-height.font-news:hover { box-shadow: var(--d-shadow-hover); transform: translateY(-2px); }
  html body .box-height.font-news > .col-md-5,
  html body .box-height.font-news > .col-md-7 {
    float: none !important;
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
  }
  /* the legacy .col-md-5 is display:flex, which shrink-wraps the <a>/<img> to
     356px inside a 408px column — force a block box so the image fills the card */
  html body .box-height.font-news > .col-md-5 { display: block !important; }
  html body .box-height.font-news > .col-md-5 > a { display: block !important; width: 100% !important; }
  html body .box-height.font-news > .col-md-5 img,
  html body .box-height.font-news img.thumbnail,
  html body .box-height.font-news img.img-responsive {
    width: 100% !important;
    height: 200px !important;
    max-width: none !important;   /* index.css clamps .thumbnail to 160px */
    max-height: 200px !important;
    min-height: 0 !important;
    object-fit: cover !important;
    border: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: #EDEFF1;
  }
  html body .box-height.font-news > .col-md-7 { padding: 18px 20px 20px !important; }
  html body .box-height.font-news .news-title {
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    font-size: 16.5px !important;
    line-height: 1.55 !important;
    font-weight: 600 !important;
    color: var(--d-ink) !important;
    text-align: left !important;
    margin: 0 0 10px;
  }
  html body .box-height.font-news .news-title br { display: none; }
  html body .box-height.font-news > .col-md-7 > span { display: block; }
  html body .box-height.font-news > .col-md-7 > span > a {
    font-size: 13px !important;
    font-weight: 600;
    color: var(--d-green) !important;
    text-decoration: none;
    border-bottom: 2px solid transparent;
  }
  html body .box-height.font-news > .col-md-7 > span > a:hover { border-bottom-color: var(--d-gold); }
  html body .box-height.font-news > .col-md-7 > span:last-child {
    margin-top: 8px;
    font-size: 13px !important;
    color: #6B7280 !important;
  }

  /* "see all" band */
  html body .alert.alert-warning {
    margin: 28px 0 8px !important;
    padding: 14px 20px !important;
    background: #FFF9DB !important;
    border: 1px solid #F1E28A !important;
    border-radius: 12px !important;
    color: var(--d-ink) !important;
    font-size: 15px;
  }
  html body .alert.alert-warning a { color: var(--d-green) !important; font-weight: 600; text-decoration: none; }
  html body .alert.alert-warning a:hover { text-decoration: underline; }

  /* ---------- 6 · vision / curriculum / research bands ---------------- */
  html body .vision-row {
    display: grid;
    grid-template-columns: 1.25fr .85fr 1fr;
    align-items: start;
    gap: 32px;
    margin: 48px 0 8px;
    padding: 32px;
    background: var(--d-surface);
    border: 1px solid var(--d-line);
    border-radius: var(--d-radius);
    box-shadow: var(--d-shadow);
  }
  html body .vision-title {
    margin: 0 0 12px !important;
    font-size: 26px !important;
    line-height: 1.25 !important;
    color: var(--d-green) !important;
    letter-spacing: -.01em;
  }
  html body .vision-desc { font-size: 15.5px; line-height: 1.75; color: var(--d-muted); }
  html body .vision-leader { margin-top: 16px; font-size: 14px; color: #6B7280; line-height: 1.6; }
  html body .vision-img-block img { width: 100%; height: auto; border-radius: 12px; display: block; }
  html body .vision-video-frame { box-shadow: var(--d-shadow); border-radius: 14px; overflow: hidden; }
  html body .vision-video-caption { margin-top: 8px; font-size: 13px; color: #6B7280; }

  html body h2.style1,
  html body h3.style1 {
    font-size: 26px !important;
    line-height: 1.3 !important;
    margin: 48px 0 20px !important;
    color: var(--d-ink) !important;
    letter-spacing: -.01em;
    position: relative;
    padding-bottom: 12px;
  }
  html body h2.style1::after,
  html body h3.style1::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 56px;
    height: 4px;
    border-radius: 2px;
    background: var(--d-gold);
  }
  html body .col-md-6 > img { border-radius: var(--d-radius); box-shadow: var(--d-shadow); }
  html body .col-md-6 > a > img { transition: box-shadow .18s ease; }
  html body .col-md-6 > a:hover > img { box-shadow: var(--d-shadow-hover); }

  /* ---------- 7 · events / calendar / related sites ------------------- */
  html body .container-fluid { padding-left: 0 !important; padding-right: 0 !important; }
  html body .container-fluid > .row[style*="background"] {
    background: var(--d-surface) !important;
    border-top: 1px solid var(--d-line);
    margin-top: 56px;
    padding: 40px 0 8px !important;
  }
  html body .container-fluid .container { width: min(var(--d-container), calc(100% - 96px)) !important; margin: 0 auto; }
  html body .container-fluid .row > .col-md-4 {
    padding: 20px 24px !important;
    background: var(--d-canvas);
    border: 1px solid var(--d-line);
    border-radius: var(--d-radius);
  }
  html body .container-fluid .row > .col-md-4 h3 {
    font-size: 18px !important;
    margin: 0 0 14px !important;
    color: var(--d-ink) !important;
    font-weight: 600;
  }
  html body .banner-img {
    border-radius: 10px !important;
    transition: transform .18s ease, box-shadow .18s ease;
  }
  html body .banner-img:hover { transform: translateY(-2px); box-shadow: var(--d-shadow); }

  /* ---------- 8 · typography & interaction ---------------------------- */
  html body h1, html body h2, html body h3, html body h4 {
    color: var(--d-ink);
    letter-spacing: -.01em;
  }
  html body p { color: var(--d-muted); }
  html body a { color: var(--d-green); }
  html body a:hover { color: var(--d-green-dark); }
  html body :focus-visible {
    outline: 3px solid var(--d-gold);
    outline-offset: 2px;
    border-radius: 4px;
  }

  /* ---------- 9 · footer ---------------------------------------------- */
  html body #cmu_global_foot_menu.cmu-footer {
    margin-top: 56px;
    background: var(--d-ink) !important;
    border-top: 4px solid var(--d-green);
    box-shadow: inset 0 10px 0 -8px var(--d-science)
  }
  html body #cmu_global_foot_menu .container {
    width: min(var(--d-container), calc(100% - 96px)) !important;
    margin: 0 auto;
    padding: 48px 0 24px !important;
  }
  html body .footer-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--d-gold) !important;
    margin: 0 0 16px !important;
  }
  html body #cmu_global_foot_menu .footer-icon svg { stroke: var(--d-gold); }
  html body #cmu_global_foot_menu a { color: #D7DBDF !important; text-decoration: none; }
  html body #cmu_global_foot_menu a:hover { color: var(--d-gold) !important; }
  html body #cmu_global_foot_menu li { border-bottom-color: rgba(255, 255, 255, .08) !important; }
}

/* ---------- 10 · wide screens ---------------------------------------- */
@media (min-width: 1600px) {
  html body .container,
  html body .navbar.navbar-default.navbar-static-top > .container,
  html body .bannercontainer.centerme,
  html body #cmu_global_foot_menu .container { width: 1320px !important; max-width: 1320px !important; }
  /* the inline menu keeps its natural width — stretching it pushed the icon
     cluster off-grid at ≥1600px */
  html body ul.nav_head.navbar-nav_head { width: auto !important; max-width: none !important; }
}

/* ---------- 11 · header fit between the breakpoint and the wide layout --- */
@media (min-width: 1170px) and (max-width: 1319px) {
  html body ul.nav_head.navbar-nav_head > li > a { padding: 0 8px !important; font-size: 13px !important; }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right > li > a { width: 34px; height: 34px; }
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right { gap: 4px; }
  html body .navbar > .container { gap: 12px; }
}
@media (min-width: 1170px) and (max-width: 1199px) {
  /* the narrowest desktop slice: drop the floating cluster rather than collide */
  html body .navbar > .container > ul.nav.navbar-nav.navbar-right { display: none !important; }
  html body ul.nav_head.navbar-nav_head > li > a { padding: 0 7px !important; font-size: 12.5px !important; }
  html body .navbar > .container > .navbar-header > a > picture img { height: 44px !important; max-height: 44px !important; }
}
