/* Side panel for universities (V1 and the country pages).
   Clicking a university row opens a panel from the right. Countries have pages instead.
   The panels themselves are built by university-panels.js. */

/* ---------- Things you can click ---------- */
[data-panel] { cursor: pointer; }
[data-panel]:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 4px; }

/* ---------- The panel itself ---------- */
dialog.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; border: 0;
  width: min(640px, 100vw); max-width: 100vw; height: 100vh; height: 100dvh; max-height: none;
  background: var(--cream); color: var(--ink);
  border-radius: 28px 0 0 28px; overflow: hidden;
  box-shadow: -30px 0 60px -30px rgba(42, 29, 20, .45);
}
dialog.drawer[open] { display: flex; flex-direction: column; }
dialog.drawer::backdrop { background: rgba(42, 29, 20, .45); backdrop-filter: blur(2px); }
html:has(dialog[open]) { overflow: hidden; } /* the page behind doesn't scroll */

.drawer [hidden], .consult-about[hidden] { display: none !important; }

/* The close button floats over the photo */
.drawer-bar { position: absolute; top: 18px; left: 18px; right: 18px; z-index: 5; display: flex; gap: 10px; pointer-events: none; }
.drawer-bar button {
  pointer-events: auto; height: 44px; border: 0; border-radius: 999px; padding: 0 18px; cursor: pointer;
  background: var(--cream); color: var(--ink); box-shadow: 0 6px 18px -8px rgba(42, 29, 20, .45);
  transition: background .25s, color .25s;
}
.drawer-bar button:hover { background: var(--ink); color: var(--cream); }
.drawer-close { margin-left: auto; width: 44px; padding: 0 !important; font-size: 26px; line-height: 1; }

/* Full screen toggle, sitting just left of ×. Arrows out when it's a side panel,
   arrows in when it's full screen. */
.drawer-expand { margin-left: auto; width: 44px; padding: 0 !important; display: grid; place-items: center; }
.drawer-expand + .drawer-close { margin-left: 0; }
.drawer-expand svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; grid-area: 1 / 1; }
.drawer-expand .i-collapse, .drawer.is-wide .drawer-expand .i-expand { display: none; }
.drawer.is-wide .drawer-expand .i-collapse { display: block; }
.drawer-expand:focus-visible, .drawer-close:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 3px; }

/* Full screen: the panel takes the whole window and its text settles into a centred
   column, so lines don't stretch across a wide monitor. Backgrounds (the photo, the
   fading strip behind the buttons) still run edge to edge. */
dialog.drawer { transition: width .5s cubic-bezier(.22, .61, .36, 1), border-radius .5s; }
dialog.drawer.is-wide { width: 100vw; border-radius: 0; }
.drawer.is-wide .panel { --col: max(48px, calc((100% - 860px) / 2)); }
.drawer.is-wide .panel > :not(.panel-photo) { padding-left: var(--col); padding-right: var(--col); }
.drawer.is-wide .panel-photo { height: min(52vh, 520px); }
.drawer.is-wide .panel-gallery { grid-template-columns: repeat(4, 1fr); }

/* A phone already shows the panel full width, so there's nothing to expand */
@media (max-width: 700px) { .drawer-expand { display: none; } }

.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

/* ---------- Panel content ---------- */
.panel-photo { position: relative; height: 300px; }
.panel-photo .ph { position: absolute; inset: 0; }
.panel-photo .ph::after { display: none; }

.panel-head { padding: 36px 48px 0; }
.panel-head .mono { color: var(--terracotta); }
.panel-head h2 { font-size: 76px; margin: 12px 0 14px; }
.panel-head .lead { font-size: 18px; margin: 0; opacity: .8; }

.panel-sec { padding: 44px 48px 0; }
.panel-sec > h3 {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .02em; text-transform: lowercase;
  opacity: .6; margin: 0 0 14px;
}

/* Benefits: small numbered cards */
.benefits { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; counter-reset: b; }
.benefits li { background: var(--cream-2); border-radius: 18px; padding: 18px 20px; font-size: 16px; line-height: 1.4; counter-increment: b; }
.benefits li::before { content: '0' counter(b); display: block; font-family: var(--font-mono); font-size: 12px; color: var(--terracotta); margin-bottom: 18px; }

/* Key facts: label on the left, answer on the right */
.facts { margin: 0; }
.facts > div { display: grid; grid-template-columns: 190px 1fr; gap: 20px; padding: 14px 0; border-top: 1px solid rgba(42, 29, 20, .15); }
.facts > div:last-child { border-bottom: 1px solid rgba(42, 29, 20, .15); }
.facts dt { font-family: var(--font-mono); font-size: 12px; opacity: .6; padding-top: 3px; }
.facts dd { margin: 0; font-size: 16px; }
/* Griffith's key facts: orange blocks, a small icon and label over a larger answer */
.key-facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.key-facts > div { background: var(--terracotta); color: var(--cream); border-radius: 18px; padding: 20px 22px 24px; }
.key-facts dt { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 12px; opacity: .85; margin-bottom: 16px; }
.key-facts svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.key-facts dd { margin: 0; font-size: 18px; line-height: 1.4; }
/* A world ranking, where a university has one worth showing, runs full width on top */
.key-facts > .kf-rank { grid-column: 1 / -1; }
.kf-rank dd { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.kf-rank b { font-family: var(--font-head); font-weight: 400; font-size: 64px; line-height: .9; }
.drawer.is-wide .key-facts { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) { .key-facts { grid-template-columns: 1fr; } }
/* Faculty carousel: the faculty in the middle is large, its neighbours small and faded
   at the edges, with a big see-through phrase behind. It runs edge to edge of the panel;
   sizes are in cqw so it scales with the drawer when it goes full screen. */
.fields { position: relative; margin: 0 -48px; height: 300px; overflow: hidden; container-type: inline-size; outline: none; touch-action: pan-y; user-select: none; }
.fields-bg {
  position: absolute; inset: 0; margin: 0; display: flex; flex-direction: column; justify-content: center; padding-left: 4cqw;
  font-family: var(--font-head); font-size: min(26cqw, 250px); line-height: .82; letter-spacing: -.02em;
  color: var(--ink); opacity: .07; pointer-events: none; white-space: nowrap;
}
.fields-list { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; }
.fields-list li {
  position: absolute; left: 50%; top: 50%; width: 52cqw; text-align: center;
  font-family: var(--font-head); font-size: clamp(36px, 10cqw, 96px); line-height: 1; letter-spacing: -.01em;
  transform: translate(calc(-50% + var(--d, 0) * 46cqw), -50%) scale(.45);
  opacity: 0; cursor: pointer;
  transition: transform .6s cubic-bezier(.22, .61, .36, 1), opacity .6s, color .6s;
}
.fields-list li.is-near { opacity: .4; }
.fields-list li.is-on { transform: translate(-50%, -50%); opacity: 1; color: var(--terracotta); cursor: default; }
.fields-arrow {
  position: absolute; top: 50%; width: 44px; height: 44px; margin-top: -22px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer;
}
.fields-arrow:hover { background: var(--cream-2); }
.fields-arrow[data-step="-1"] { left: 17cqw; }
.fields-arrow[data-step="1"] { right: 17cqw; }
.fields-arrow svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.fields-count { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); font-size: 12px; opacity: .55; }
.drawer.is-wide .fields { height: 460px; }
@media (prefers-reduced-motion: reduce) { .fields-list li { transition: none; } }

/* "Why we recommend it": ticked list */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid rgba(42, 29, 20, .15); }
.checks li::before { content: '✓'; font-family: var(--font-mono); color: var(--terracotta); }

.panel .uni:first-of-type { border-top: 1px solid rgba(42, 29, 20, .15); }
.panel-note { padding: 26px 48px 0; margin: 0; opacity: .55; }

/* Buttons stay at the bottom while you scroll */
.panel-cta { position: sticky; bottom: 0; margin-top: 36px; padding: 28px 48px 30px; background: linear-gradient(to top, var(--cream) 72%, rgba(246, 241, 232, 0)); }
.panel-cta .btn { width: 100%; justify-content: center; }

/* "More about Ireland": the way out of the drawer and into the country's own page.
   An outlined row rather than a second solid button, so it invites without competing
   with "ask about this university" underneath it. Hidden on that country's own page. */
.panel-explore {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin-bottom: 12px; padding: 15px 26px; border-radius: 999px;
  background: var(--cream-2); color: var(--terracotta); text-decoration: none;
  font-family: var(--font-body); font-weight: 600; font-size: 16px;
  box-shadow: inset 0 0 0 1.5px rgba(200, 82, 40, .3);
  transition: background .25s, box-shadow .25s, transform .25s;
}
/* The arrow is a pseudo-element so switching UA/EN, which rewrites the label, keeps it */
.panel-explore::after { content: '→'; font-family: var(--font-mono); transition: transform .25s; }
.panel-explore:hover { background: var(--cream); box-shadow: inset 0 0 0 1.5px var(--terracotta); transform: translateY(-1px); }
.panel-explore:hover::after { transform: translateX(5px); }
.panel-explore:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 3px; }

/* Consultation form: shows what the visitor was looking at */
.consult .consult-about { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin: -8px 0 24px; padding: 10px 16px; border-radius: 14px; background: var(--cream-2); opacity: 1; font-size: 15px; }
.consult-about .mono { font-size: 12px; opacity: .6; }

/* ---------- Motion (only when animations are on) ---------- */
@keyframes drawer-in  { from { transform: translateX(100%); } }
@keyframes drawer-out { to   { transform: translateX(100%); } }
@keyframes fade-in    { from { opacity: 0; } }
@keyframes fade-out   { to   { opacity: 0; } }
@keyframes panel-rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes photo-settle { from { transform: scale(1.12); } }

.anim dialog.drawer[open] { animation: drawer-in .6s cubic-bezier(.22, .61, .36, 1); }
.anim dialog.drawer[open]::backdrop { animation: fade-in .45s ease; }
.anim dialog.drawer.is-closing { animation: drawer-out .38s cubic-bezier(.55, 0, .75, .2) forwards; }
.anim dialog.drawer.is-closing::backdrop { animation: fade-out .38s ease forwards; }

/* Content rises in one block after another, also when you move between panels */
.anim .panel > * { animation: panel-rise .6s cubic-bezier(.22, .61, .36, 1) both; }
.anim .panel > :nth-child(2) { animation-delay: .08s; }
.anim .panel > :nth-child(3) { animation-delay: .16s; }
.anim .panel > :nth-child(4) { animation-delay: .24s; }
.anim .panel > :nth-child(n+5) { animation-delay: .3s; }
.anim .panel > .panel-photo { animation: fade-in .5s ease both; }
.anim .panel-photo img { animation: photo-settle 1.4s cubic-bezier(.22, .61, .36, 1) both; }

/* Photos inside the panel, under their section heading: one wide, then a grid */
.panel-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.panel-gallery .ph { aspect-ratio: 4 / 3; border-radius: 12px; }
.panel-gallery .ph::after { display: none; }
.panel-gallery .ph:first-child { grid-column: 1 / -1; aspect-ratio: 16 / 9; border-radius: 16px; }
@media (max-width: 680px) { .panel-gallery { grid-template-columns: 1fr 1fr; } }

/* Photo album: a panel's photos full screen, over the drawer */
.panel-gallery img, .panel-photo img { cursor: zoom-in; }
dialog.album {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(30, 21, 15, .96); color: var(--cream); overflow: hidden;
  display: none; grid-template-rows: 1fr auto; touch-action: pan-y;
}
dialog.album[open] { display: grid; }
dialog.album::backdrop { background: transparent; }
.album-stage { margin: 0; min-height: 0; display: grid; place-items: center; padding: 70px 90px 20px; }
/* The height is spelled out rather than 100%, which a grid row doesn't pass down to the
   photo: without it tall photos overflowed and got cropped, looking zoomed in. 190px is
   the stage's top and bottom padding plus the thumbnail strip. */
.album-stage img { max-width: 100%; max-height: calc(100vh - 190px); max-height: calc(100dvh - 190px); width: auto; height: auto; object-fit: contain; border-radius: 12px; user-select: none; }
.album-close {
  position: absolute; top: 18px; right: 18px; z-index: 1; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(246, 241, 232, .12); color: var(--cream); font-size: 26px; line-height: 1; cursor: pointer;
}
.album-count { position: absolute; top: 30px; left: 50%; transform: translateX(-50%); font-size: 12px; opacity: .7; }
.album-arrow {
  position: absolute; top: calc(50% - 60px); width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: rgba(246, 241, 232, .12); color: var(--cream); cursor: pointer;
}
.album-arrow:hover, .album-close:hover { background: rgba(246, 241, 232, .24); }
.album button:focus { outline: none; }
.album button:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }
.album-arrow[data-step="-1"] { left: 22px; }
.album-arrow[data-step="1"] { right: 22px; }
.album-arrow svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.album-strip { display: flex; gap: 8px; justify-content: safe center; overflow-x: auto; padding: 14px 22px 22px; scrollbar-width: none; }
.album-strip button { flex: none; width: 76px; height: 54px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: none; opacity: .45; cursor: pointer; transition: opacity .2s; }
.album-strip button:hover { opacity: .8; }
.album-strip button.is-on { opacity: 1; border-color: var(--terracotta); }
.album-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album.is-single .album-arrow, .album.is-single .album-strip { display: none; }
@media (max-width: 700px) {
  .album-stage { padding: 70px 12px 12px; }
  .album-arrow { top: auto; bottom: 90px; width: 44px; height: 44px; }
}
