/* Revision 11: client round 11 (header). Loaded after the r6 files.

   1. The desktop header row: one underline for the current section, under
      the label only, and a small chevron on the items that open a panel.
   2. The mega menu panels, from 64rem (template-parts/components/mega-panel.php).
   3. The phone and tablet menu, below 64rem (template-parts/components/mega-drawer.php).
   4. Revision 12: portraits, the page being viewed inside a panel, the office
      hours, the Also at Elite row, and the phone menu's header. */

/* ------------------------------------------------------------ 1. the row */
@media (min-width: 64rem) {
  /* The line sits under the label, so it does not run under the chevron.
     Every label carries a transparent line, so the current item is exactly
     as tall as the others and no text moves between pages. */
  [data-header].site-header .nav-desktop > ul > li > a,
  [data-header].site-header .nav-desktop > ul > li > a[aria-current],
  [data-header].site-header .nav-desktop > ul > li:is(.current-menu-item, .current-menu-ancestor) > a { padding-bottom: 0; border-bottom: 0; }
  .site-header .nav-desktop .mega-top__label { display: inline-block; padding-bottom: 2px; border-bottom: 2px solid transparent; }
  .site-header .nav-desktop a[aria-current] .mega-top__label,
  .site-header .nav-desktop li:is(.current-menu-item, .current-menu-ancestor) > a .mega-top__label { border-bottom-color: currentColor; }

  .site-header .nav-desktop > ul > li > a.mega-top { display: inline-flex; align-items: center; gap: 0.32rem; }
  .mega-top__chev { flex: none; width: 10px; height: 10px; margin-bottom: 2px; color: var(--muted); transition: transform 0.2s ease, color 0.2s ease; }
  .site-header .nav-desktop a.mega-top:hover .mega-top__chev,
  .site-header .nav-desktop a.mega-top[aria-current] .mega-top__chev { color: currentColor; }
  .site-header .nav-desktop a.mega-top[aria-expanded="true"] { color: var(--ortho); }
  .site-header .nav-desktop a.mega-top[aria-expanded="true"] .mega-top__chev { color: currentColor; transform: rotate(180deg); }
  /* Pediatric Dentistry keeps its own colour, as its panel does. */
  .site-header .nav-desktop a.mega-top[aria-controls="mega-p-ped"]:is(:hover, [aria-expanded="true"]) { color: var(--ped); }
}

/* ---------------------------------------------------------- 2. the panels */
.site-header .mega { display: none; }

@media (min-width: 64rem) {
  .site-header .mega:not([hidden]) { display: block; position: absolute; top: 100%; left: 0; right: 0; }
  .mega__panel[hidden] { display: none; }

  /* The page under an open panel dims a little. The veil never takes clicks. */
  .mega__scrim {
    position: absolute; top: 0; left: 0; right: 0; height: 100vh; pointer-events: none;
    background: rgba(26, 18, 54, 0.16); opacity: 0; transition: opacity 0.2s ease;
  }
  .mega__panel {
    position: relative; background: #fff; border-top: 1px solid var(--line);
    box-shadow: 0 28px 48px -28px rgba(26, 18, 54, 0.34);
    opacity: 0; transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  .mega.is-open .mega__scrim { opacity: 1; }
  .mega.is-open .mega__panel { opacity: 1; transform: none; }

  .mega__in {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(17rem, 21.5rem); align-items: start;
    gap: clamp(1.75rem, 3.2vw, 3.5rem); padding-top: 1.6rem; padding-bottom: 1.9rem;
  }

  .mega__kicker { margin: 0; font-size: 0.74rem; font-weight: 700; line-height: 1.3; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ortho); }
  .mega__panel--ped .mega__kicker { color: var(--ped); }

  /* Every column opens with the same ruled heading row, so the rules line up. */
  .mega__head,
  .mega__col > .mega__kicker {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    min-height: 2.65rem; margin-bottom: 0.85rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--line);
  }

  /* "Orthodontics overview", "Meet the whole team", "Get Directions". */
  .mega__all { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; font-weight: 650; color: var(--ortho); text-decoration: none; white-space: nowrap; }
  .mega__all svg { flex: none; transition: transform 0.2s ease; }
  .mega__all:hover { color: var(--ortho-dark); }
  .mega__all:hover svg:last-child { transform: translateX(3px); }
  .mega__panel--ped .mega__all { color: var(--ped); }
  .mega__panel--ped .mega__all:hover { color: var(--ped-dark); }

  .mega__list { list-style: none; margin: 0; padding: 0; }
  .mega__list--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.2rem 1.75rem; }
  .mega__list--stack { display: grid; gap: 0.2rem; }

  /* A link: icon tile, title, one short line. The hover wash reaches past the
     text on both sides, so the icons still line up with the grid. */
  .mega-link {
    display: flex; align-items: center; gap: 0.85rem; margin-inline: -0.7rem; padding: 0.55rem 0.7rem;
    border-radius: 12px; color: var(--ink); text-decoration: none; transition: background-color 0.18s ease;
  }
  .mega-link:hover, .mega-link:focus-visible { background: var(--mist); color: var(--ink); }
  .mega-link__ic {
    flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 10px;
    background: var(--ortho-tint); color: var(--ortho); transition: background-color 0.18s ease, color 0.18s ease;
  }
  .mega-link__ic svg { width: 21px; height: 21px; }
  .mega-link:hover .mega-link__ic, .mega-link:focus-visible .mega-link__ic { background: var(--ortho); color: #fff; }
  .mega__panel--ped .mega-link__ic { background: var(--ped-tint); color: var(--ped); }
  .mega__panel--ped .mega-link:is(:hover, :focus-visible) .mega-link__ic { background: var(--ped); color: #fff; }
  .mega-link__txt { display: flex; flex-direction: column; min-width: 0; }
  .mega-link__t { font-size: 0.95rem; font-weight: 650; line-height: 1.3; letter-spacing: -0.005em; }
  .mega-link__d { margin-top: 0.1rem; overflow: hidden; font-size: 0.82rem; line-height: 1.35; color: var(--body); white-space: nowrap; text-overflow: ellipsis; }
  .mega-link--plain { padding-block: 0.7rem; }
  .mega-link[aria-current] .mega-link__t { color: var(--ortho); }
  .mega__panel--ped .mega-link[aria-current] .mega-link__t { color: var(--ped); }
  /* The page being viewed: its tile is filled, as on hover. */
  .mega-link[aria-current] .mega-link__ic { background: var(--ortho); color: #fff; }
  .mega__panel--ped .mega-link[aria-current] .mega-link__ic { background: var(--ped); color: #fff; }

  /* The card beside the links: the lane's doctors and booking, the office, or booking. */
  .mega-card { padding: 1.25rem 1.3rem 1.35rem; border-radius: 16px; background: var(--ortho-tint); }
  .mega-card--ped { background: var(--ped-tint); }
  .mega-card--visit, .mega-card--book { background: var(--mist); }
  .mega-card > * + * { margin-top: 0.8rem; }
  .mega-card .mega__kicker + * { margin-top: 0.7rem; }

  .mega-docs { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
  .mega-doc { display: flex; align-items: center; gap: 0.85rem; margin: 0 -0.5rem; padding: 0.45rem 0.5rem; border-radius: 12px; color: var(--ink); text-decoration: none; transition: background-color 0.18s ease; }
  .mega-doc:hover, .mega-doc:focus-visible { background: rgba(255, 255, 255, 0.72); color: var(--ink); }
  .mega-doc__ph { flex: none; display: block; width: 3.4rem; height: 3.4rem; overflow: hidden; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px #fff, 0 6px 14px -8px rgba(26, 18, 54, 0.45); }
  .mega-doc__ph img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .mega-doc__txt { display: flex; flex-direction: column; min-width: 0; }
  .mega-doc__n { font-size: 0.95rem; font-weight: 700; line-height: 1.3; }
  .mega-doc__r { font-size: 0.82rem; line-height: 1.35; color: var(--body); }
  .mega-doc__b { margin-top: 0.35rem; font-size: 0.82rem; line-height: 1.45; color: var(--body); }
  .mega-ph__initial { display: grid; place-items: center; width: 100%; height: 100%; font-family: var(--display); font-size: 1.3rem; font-weight: 700; color: var(--ortho); }

  .mega-card .mega-book,
  .premium-inner .mega-card .mega-book { width: 100%; min-height: 3rem; padding: 0.7rem 1rem; gap: 0.55rem; font-size: 0.9rem; }
  .mega-card .mega-book + .mega-book { margin-top: 0.5rem; }
  .mega__all--call { margin-top: 0.95rem; color: var(--ink); }
  .mega__all--call svg { color: var(--ortho); }
  .mega-card__note { font-size: 0.86rem; line-height: 1.5; color: var(--body); }
  .mega-card--visit .mega-card__t + .mega-card__note { margin-top: 0.3rem; font-size: 0.82rem; }
  .mega-card__t { font-size: 0.98rem; font-weight: 700; line-height: 1.35; color: var(--ink); }
  .mega-card__img { display: block; overflow: hidden; aspect-ratio: 5 / 2; border-radius: 12px; background: var(--line); }
  .mega-card__img img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .mega-card__img + .mega__kicker { margin-top: 1rem; }
  .mega-card__acts { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }

  /* Our team: the doctors as three portraits. */
  .mega-people { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 1.4rem; }
  .mega-person { display: flex; flex-direction: column; color: var(--ink); text-decoration: none; }
  .mega-person__ph {
    display: block; overflow: hidden; aspect-ratio: 16 / 11; margin-bottom: 0.7rem; border-radius: 14px;
    background: linear-gradient(160deg, var(--ortho-tint), #fff);
  }
  .mega-person--ped .mega-person__ph { background: linear-gradient(160deg, var(--ped-tint), #fff); }
  .mega-person__ph img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; transition: transform 0.4s ease; }
  .mega-person:hover .mega-person__ph img, .mega-person:focus-visible .mega-person__ph img { transform: scale(1.035); }
  .mega-person__n { font-size: 1rem; font-weight: 700; line-height: 1.3; }
  .mega-person:hover .mega-person__n { color: var(--ortho); }
  .mega-person--ped:hover .mega-person__n { color: var(--ped); }
  .mega-person__r { margin-top: 0.1rem; font-size: 0.85rem; color: var(--body); }
  .mega-card--team { background: var(--mist); }
  .mega-card .mega__list--stack .mega-link:hover, .mega-card .mega__list--stack .mega-link:focus-visible { background: rgba(255, 255, 255, 0.8); }
  .mega-card .mega__list--stack .mega-link__ic { background: #fff; }
  .mega-rating { padding-top: 0.9rem; border-top: 1px solid var(--line); }
  .mega-rating .hero-rating { margin-top: 0; font-size: 0.86rem; }
  .mega-rating--main { margin-top: 1.1rem; }
  .mega-card__books { display: grid; gap: 0.5rem; }
  .mega-card__books .mega-book + .mega-book { margin-top: 0; }

  /* Link columns (Patient info). */
  .mega__main--cols { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 1.75rem; }

  .mega :where(a, button):focus-visible { outline: 2px solid var(--ortho); outline-offset: 2px; }
  .mega__panel--ped :where(a, button):focus-visible { outline-color: var(--ped); }
}

/* Small laptops: a little tighter, so every title and line stays on one row. */
@media (min-width: 64rem) and (max-width: 79.99rem) {
  .mega__in { grid-template-columns: minmax(0, 1fr) 19rem; gap: 1.75rem; padding-top: 1.35rem; padding-bottom: 1.6rem; }
  .mega-card .mega-book,
  .premium-inner .mega-card .mega-book { padding-inline: 0.8rem; font-size: 0.86rem; }
  .mega__list--grid { column-gap: 1.5rem; }
  .mega-link { gap: 0.7rem; }
  .mega-link__ic { width: 2.3rem; height: 2.3rem; }
  .mega-link__t { font-size: 0.9rem; }
  .mega-link__d { font-size: 0.79rem; }
  .mega-people { gap: 1.1rem; }
  .mega-card { padding: 1.1rem 1.1rem 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .mega__scrim, .mega__panel, .mega-top__chev, .mega-person__ph img, .mega__all svg { transition: none; }
  .mega__panel { transform: none; }
}

/* ------------------------------------------------- 3. phone and tablet menu */
@media (max-width: 63.99rem) {
  .nav-drawer.dnav { padding-bottom: calc(var(--gut) + env(safe-area-inset-bottom, 0px)); }
  .dnav .nav-drawer__head { margin-bottom: 0.75rem; }

  /* A group row reads like the links around it, with a chevron. */
  .dnav__toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; min-height: 52px;
    margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none;
    font-family: inherit; font-size: 1.1rem; font-weight: 600; line-height: 1.25; color: var(--ink); text-align: left; cursor: pointer;
  }
  .dnav__chev { flex: none; width: 14px; height: 14px; margin-right: 0.35rem; transition: transform 0.2s ease; }
  .dnav__toggle[aria-expanded="true"] .dnav__chev { transform: rotate(180deg); }

  .dnav .dnav__sub { list-style: none; margin: 0; padding: 0.45rem 0 0.7rem; border-bottom: 1px solid var(--line); }
  .dnav .dnav__sub[hidden] { display: none; }
  .dnav-link { display: flex; align-items: center; gap: 0.8rem; min-height: 46px; padding: 0.2rem 0; color: var(--body); font-size: 0.98rem; font-weight: 500; line-height: 1.3; text-decoration: none; }
  .dnav-link__ic { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px; background: var(--ortho-tint); color: var(--ortho); }
  .dnav-link__ic svg { width: 18px; height: 18px; }
  .dnav-link__txt { min-width: 0; }

  /* The smaller links, in a wrapping row under the main list. */
  .dnav .dnav__more { list-style: none; display: flex; flex-wrap: wrap; gap: 0 1.4rem; margin: 0.6rem 0 0; padding: 0; }
  body .nav-drawer > ul.dnav__more > li > a {
    display: flex; align-items: center; min-height: 44px; border-bottom: 0;
    font-size: 0.96rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--body); text-decoration: none;
  }

  .dnav .nav-drawer__cta { margin-top: 1.25rem; }
  .dnav__kicker { margin: 0; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--body); }

  /* On the brand-purple menu (body.mh2, revision 7). */
  body.mh2 .dnav__toggle {
    border-bottom-color: rgba(255, 255, 255, 0.16); color: #fff;
    font-size: 1rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  }
  body.mh2 .dnav__group.current-menu-ancestor > .dnav__toggle { color: var(--cyan, #3aecf1); }
  body.mh2 .dnav .dnav__sub { border-bottom-color: rgba(255, 255, 255, 0.16); }
  body.mh2 .dnav-link { color: rgba(255, 255, 255, 0.92); }
  body.mh2 .dnav-link__ic { background: rgba(255, 255, 255, 0.12); color: var(--cyan, #3aecf1); }
  body.mh2 .dnav-link[aria-current] { color: var(--cyan, #3aecf1); font-weight: 600; }
  body.mh2 .dnav-link[aria-current] .dnav-link__ic { background: var(--cyan, #3aecf1); color: var(--ortho); }
  body.mh2 .nav-drawer > ul.dnav__more > li > a { color: rgba(255, 255, 255, 0.86); }
  body.mh2 .nav-drawer > ul.dnav__more > li > a[aria-current] { color: var(--cyan, #3aecf1); font-weight: 600; }
  body.mh2 .dnav__kicker { color: rgba(255, 255, 255, 0.72); }
  body.mh2 .dnav :where(a, button):focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
}

/* Tablets: the treatment lists take two columns. */
@media (min-width: 40rem) and (max-width: 63.99rem) {
  .dnav .dnav__sub:not([hidden]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .dnav__chev { transition: none; }
}

/* ------------------------------------------------------------ 4. revision 12 */
@media (min-width: 64rem) {
  /* Our team: the three portraits as one set. The crop starts at the top of
     each photograph, so no forehead or hair is cut, and runs past the chin. */
  .mega-person__ph { aspect-ratio: 6 / 5; }
  .mega-person__ph img { object-position: 50% 0; transform-origin: 50% 0; }

  /* The doctor whose profile is open, in the team panel and in a lane's card. */
  .mega-person[aria-current] .mega-person__n { color: var(--ortho); }
  .mega-person--ped[aria-current] .mega-person__n { color: var(--ped); }
  .mega-person[aria-current] .mega-person__ph { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ortho); }
  .mega-person--ped[aria-current] .mega-person__ph { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ped); }
  .mega-doc[aria-current] { background: rgba(255, 255, 255, 0.72); }
  .mega-doc[aria-current] .mega-doc__n { color: var(--ortho); }
  .mega-card--ped .mega-doc[aria-current] .mega-doc__n { color: var(--ped); }
  .mega-doc[aria-current] .mega-doc__ph { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ortho); }
  .mega-card--ped .mega-doc[aria-current] .mega-doc__ph { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ped); }

  /* Why Elite: four tiles in a 2 x 2 grid. The column runs the height of the
     office card, with the rating row at its foot, level with Get Directions. */
  .mega__in:has(> .mega-card--visit) { align-items: stretch; }
  .mega__in:has(> .mega-card--visit) > .mega__main:not(.mega__main--cols) { display: flex; flex-direction: column; padding-bottom: 1.35rem; }
  .mega__in:has(> .mega-card--visit) > .mega__main > .mega__list { margin-bottom: 1.1rem; }
  .mega__in:has(> .mega-card--visit) > .mega__main > .mega-rating--main { margin-top: auto; }

  /* The office hours break between days only, in balanced lines. */
  .mega .mega-card__hours { text-wrap: balance; }
  .mega-card__hours > span { white-space: nowrap; }

  /* A column's list is never wider than its column: a long line ends in an
     ellipsis rather than running towards the card beside it. */
  .mega__list--stack { grid-template-columns: minmax(0, 1fr); }

  /* Also at Elite: a small row under the columns, its links under the columns' links. */
  .mega__also { grid-column: 1 / -1; margin-top: -0.7rem; padding-top: 0.85rem; border-top: 1px solid var(--line); }
  .mega__list + .mega__also { margin-top: 0.9rem; }
  .mega__also > .mega__kicker { margin-bottom: 0.3rem; }
  .mega__list--also { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 0.2rem 1.75rem; }
}

/* Small laptops: square portraits fill the height of the card beside them,
   and the Google rating in that card stays on one line. */
@media (min-width: 64rem) and (max-width: 79.99rem) {
  .mega-people .mega-person__ph { aspect-ratio: 1 / 1; }
  .mega__in:has(> .mega-card--visit) > .mega__main:not(.mega__main--cols) { padding-bottom: 1.2rem; }
  .mega-card--team .mega-rating .hero-rating { flex-wrap: nowrap; column-gap: 0.4rem; font-size: 0.8rem; white-space: nowrap; }
  .mega-card--team .mega-rating .hero-rating strong { font-size: 0.95rem; }
}

@media (max-width: 63.99rem) {
  /* The menu's header stays in view while the list scrolls under it, and its
     close button sits exactly where the Menu button was (centre 30px down). */
  .nav-drawer.dnav { padding-top: 0; }
  .dnav .nav-drawer__head {
    position: sticky; top: 0; z-index: 2;
    margin: 0 calc(var(--gut) * -1) 0.75rem; padding: 7px var(--gut) 0.55rem;
    background: inherit;
  }
}

@supports (animation-timeline: scroll()) {
  @media (max-width: 63.99rem) {
    /* A faint edge under the header once the list has moved under it. */
    .dnav .nav-drawer__head { animation: elite-dnav-edge linear both; animation-timeline: scroll(nearest block); animation-range: 0 1.5rem; }
  }
}
@keyframes elite-dnav-edge {
  from { box-shadow: 0 1px 0 rgba(255, 255, 255, 0); }
  to { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14), 0 12px 18px -14px rgba(10, 6, 30, 0.6); }
}
