/* Institute of Education application site.
   Colours come from the UCC crest. The crest's wave bands are the one signature
   element (partials/waves.twig); everything around them stays quiet. */

:root {
  --navy: #27357a;
  --navy-deep: #1a2458;
  --gold: #ffd92e;
  --red: #b81d28;
  --red-tint: #fdf0f0;
  --green: #17693c;
  --green-tint: #edf7f1;
  --ink: #1b2140;
  --muted: #565d7a;
  --line: #d3d8e6;
  --mist: #f1f3f9;
  --white: #fff;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --measure: 66ch;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
}

h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 600; line-height: 1.2; color: var(--navy-deep); }
h1 { font-size: clamp(2.25rem, 1.6rem + 3vw, 3.75rem); letter-spacing: -.015em; }
h2 { font-size: clamp(1.625rem, 1.35rem + 1.2vw, 2.25rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--navy); text-underline-offset: .15em; }
a:hover { color: var(--navy-deep); }

:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; border-radius: 2px; }
.on-navy :focus-visible { outline-color: var(--gold); }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 20;
  padding: .6rem 1rem; background: var(--white); color: var(--navy-deep);
}
.skip-link:focus { top: 1rem; }

.wrap { width: min(72rem, 100% - 2 * var(--gutter)); margin-inline: auto; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 3rem; padding: .625rem 1.5rem;
  border: 2px solid transparent; border-radius: 6px;
  font: 600 1rem/1.2 var(--sans); text-align: center; text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn--primary { background: var(--navy); color: var(--white); }
.btn--primary:hover { background: var(--navy-deep); color: var(--white); }
.btn--gold { background: var(--gold); color: var(--navy-deep); }
.btn--gold:hover { background: #ffe670; color: var(--navy-deep); }
.btn--quiet { background: transparent; border-color: var(--line); color: var(--navy-deep); }
.btn--quiet:hover { border-color: var(--navy); color: var(--navy-deep); }
.btn--ghost { background: transparent; border-color: rgba(255, 255, 255, .55); color: var(--white); }
.btn--ghost:hover { border-color: var(--white); color: var(--white); background: rgba(255, 255, 255, .1); }
.btn--small { min-height: 2.25rem; padding: .25rem .875rem; font-size: .9375rem; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }

/* ---- Site header ---- */
.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.site-header__row { display: flex; align-items: center; gap: 1rem; min-height: 4.5rem; }
.brand { display: flex; align-items: center; gap: .75rem; margin-right: auto; color: var(--navy-deep); text-decoration: none; }
.brand img { width: 40px; height: auto; }
.brand__name { font: 600 1.0625rem/1.2 var(--serif); }
.brand__sub { display: block; font: 400 .8125rem/1.3 var(--sans); color: var(--muted); }
.site-nav { display: flex; align-items: center; gap: 1.25rem; }
.site-nav a:not(.btn) { color: var(--ink); font-weight: 500; text-decoration: none; }
.site-nav a:not(.btn):hover { text-decoration: underline; }
@media (max-width: 40rem) {
  .brand__sub, .site-nav a:not(.btn) { display: none; }
  .brand__name { font-size: 1rem; }
}

/* ---- Crest wave bands ---- */
.waves { display: block; position: relative; overflow: visible; width: 100%; height: clamp(44px, 7vw, 96px); margin-bottom: -1px; }
.waves__white { fill: var(--white); }
.waves__navy { fill: var(--navy); }
.waves__end { fill: var(--wave-end, var(--white)); }

/* ---- Home: hero ---- */
.hero { position: relative; background: var(--navy); color: var(--white); }
.hero__grid { display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 12fr); min-height: min(38rem, 76vh); }
.hero__text {
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1.5rem, 4vw, 3.5rem) clamp(5rem, 11vw, 9rem) max(var(--gutter), calc((100vw - 72rem) / 2));
}
.hero h1 { color: var(--white); }
.hero__lead { margin: 1.25rem 0 2rem; font-size: 1.1875rem; line-height: 1.5; color: #e5e8f5; max-width: 30em; }
.hero__actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.hero__photo { position: relative; min-height: 18rem; }
.hero__photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 48% 40%; }
.hero .waves { position: absolute; left: 0; right: 0; bottom: -1px; margin: 0; }
@media (max-width: 52rem) {
  .hero__grid { grid-template-columns: 1fr; min-height: 0; }
  .hero__photo { order: -1; height: 56vw; max-height: 22rem; min-height: 13rem; }
  .hero__text { padding: 2rem var(--gutter) clamp(4.5rem, 16vw, 7rem); }
}

/* ---- Home: sections ---- */
.section { padding-block: clamp(3rem, 7vw, 5.5rem); }
.section--mist { background: var(--mist); }
.section h2 + p, .section h2 + ul { margin-top: 1rem; }

.about { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
.about__photo { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 62% 60%; border-radius: 4px; }
@media (max-width: 52rem) {
  .about { grid-template-columns: 1fr; }
  .about__photo { aspect-ratio: 3 / 2; }
}

.programmes-title { margin-top: 2rem; }
.programmes { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--line); }
.programmes li { padding: .875rem 0; border-bottom: 1px solid var(--line); font: 500 1.125rem/1.4 var(--serif); color: var(--navy-deep); }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.5rem; margin: 0; padding-block: 2rem; border-block: 1px solid var(--line); }
.figures div { display: flex; flex-direction: column-reverse; }
.figures dt { color: var(--muted); }
.figures dd { margin: 0; font: 600 clamp(2rem, 1.5rem + 2vw, 3rem)/1.1 var(--serif); color: var(--navy); }
@media (max-width: 34rem) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.notes { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(2rem, 5vw, 4.5rem); }
.notes ul { margin: 0; padding: 0; list-style: none; }
.notes li { padding: 1rem 0; border-top: 1px solid var(--line); }
.notes li:first-child { border-top: 0; padding-top: 0; }
@media (max-width: 52rem) { .notes { grid-template-columns: 1fr; } }

.help { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.5rem; }
.help h2 { margin-bottom: .5rem; }
.help__lines { display: flex; flex-wrap: wrap; gap: .75rem; }
.help__line { display: flex; flex-direction: column; gap: .125rem; padding: .625rem 1rem; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.help__line strong { font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.help__line span a { font-size: .9375rem; margin-right: .75rem; }

/* ---- Site footer ---- */
.site-footer { background: var(--navy-deep); color: #d9ddef; font-size: .9375rem; }
.site-footer a { color: var(--white); }
.site-footer a:hover { color: var(--gold); }
.site-footer h2 { font: 600 1rem/1.3 var(--sans); color: var(--white); margin-bottom: .75rem; }
.site-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; padding-block: 3rem 2rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { padding: .1875rem 0; }
.site-footer address { font-style: normal; }
.site-footer__base { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; padding-block: 1.25rem; border-top: 1px solid rgba(255, 255, 255, .18); }
.site-footer__social { display: flex; flex-wrap: wrap; gap: 1rem; }
@media (max-width: 40rem) { .site-footer__grid { grid-template-columns: 1fr 1fr; } .site-footer__grid > :first-child { grid-column: 1 / -1; } }

/* ---- Application pages ---- */
.page-head { display: flow-root; background: var(--navy); color: var(--white); --wave-end: var(--white); }
.page-head__text { padding-block: clamp(2rem, 5vw, 3.25rem) .75rem; }
.page-head h1 { color: var(--white); font-size: clamp(1.875rem, 1.45rem + 2vw, 2.875rem); }
.page-head p { margin: .625rem 0 0; color: #e5e8f5; }
.page-head .waves { height: clamp(32px, 4.5vw, 60px); }

.page-body { padding-block: 1.5rem clamp(3rem, 7vw, 5rem); }
.narrow { width: min(38rem, 100%); }

.notice { max-width: 48rem; margin: 0 0 1.5rem; padding: .875rem 1rem; border-left: 4px solid; border-radius: 0 4px 4px 0; }
.notice--error { background: var(--red-tint); border-color: var(--red); color: #6e0f17; }
.notice--success { background: var(--green-tint); border-color: var(--green); color: #0d4527; }
.notice .btn { margin-top: .75rem; }

.tabs { display: flex; gap: .25rem; margin-bottom: 2rem; border-bottom: 2px solid var(--line); }
.tabs a {
  padding: .75rem 1rem; margin-bottom: -2px; border-bottom: 3px solid transparent;
  color: var(--muted); font-weight: 600; line-height: 1.3; text-decoration: none;
}
@media (max-width: 34rem) { .tabs a { flex: 1; padding-inline: .5rem; text-align: center; } }
.tabs a:hover { color: var(--navy-deep); }
.tabs a[aria-current="page"] { color: var(--navy-deep); border-color: var(--navy); }

/* ---- Fields ---- */
.field { margin-bottom: 1.375rem; }
.field label, .field legend { display: block; margin-bottom: .375rem; padding: 0; font-weight: 600; font-size: 1rem; line-height: 1.35; }
.field fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.field__optional { font-weight: 400; color: var(--muted); }
.field__hint { margin: -.125rem 0 .5rem; font-size: .9375rem; line-height: 1.45; color: var(--muted); }
.field__error { margin: .375rem 0 0; color: var(--red); font-size: .9375rem; font-weight: 500; }
.field__error:empty { display: none; }

.input {
  display: block; width: 100%; min-height: 3rem; padding: .625rem .75rem;
  background: var(--white); border: 1px solid #8f96b0; border-radius: 6px;
  color: var(--ink); font: 400 1rem/1.4 var(--sans);
}
.input:focus { outline: 2px solid var(--navy); outline-offset: 0; border-color: var(--navy); }
.input[readonly] { background: var(--mist); color: var(--muted); }
.input--upper { text-transform: uppercase; }
.input--upper::placeholder { text-transform: none; }
.input[aria-invalid="true"] { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' fill='none' stroke='%2327357a' stroke-width='2'%3E%3Cpath d='m1 1 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .875rem center;
}
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
@media (max-width: 34rem) { .field-pair { grid-template-columns: 1fr; } }

.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice { position: relative; flex: 1 1 7rem; margin: 0; }
.choice input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.field .choice span {
  display: flex; align-items: center; justify-content: center; min-height: 3rem; padding: .5rem .75rem;
  border: 1px solid #8f96b0; border-radius: 6px; background: var(--white); font-weight: 500; text-align: center;
}
.choice input:hover + span { border-color: var(--navy); }
.choice input:checked + span { background: var(--navy); border-color: var(--navy); color: var(--white); font-weight: 600; }
.choice input:focus-visible + span { outline: 3px solid var(--navy); outline-offset: 2px; }
.choices[aria-invalid="true"] .choice span { border-color: var(--red); }

.upload { display: block; padding: 1rem; border: 1px dashed #8f96b0; border-radius: 6px; background: var(--mist); }
.upload input { display: block; width: 100%; font: inherit; font-size: .9375rem; }
.upload__preview { display: block; max-height: 11rem; width: auto; margin-top: .75rem; border-radius: 4px; }
.upload[aria-invalid="true"] { border-color: var(--red); background: var(--red-tint); }

.field .declare { display: flex; gap: .75rem; align-items: flex-start; margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 6px; font-weight: 400; cursor: pointer; }
.declare input { flex: none; width: 1.375rem; height: 1.375rem; margin-top: .125rem; accent-color: var(--navy); }

/* ---- Form wizard ---- */
.wizard { display: grid; grid-template-columns: 14rem minmax(0, 40rem); gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
.wizard__rail { position: sticky; top: 1.5rem; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { position: relative; padding-bottom: .375rem; counter-increment: step; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 1.125rem; top: 2.5rem; bottom: -.125rem; width: 2px; background: var(--line); }
.steps li.is-done:not(:last-child)::after { background: var(--navy); }
.step-btn {
  display: flex; align-items: center; gap: .75rem; width: 100%; padding: .25rem; border: 0; background: none;
  color: var(--muted); font: 500 1rem/1.3 var(--sans); text-align: left; cursor: default;
}
.step-btn::before {
  content: counter(step); flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem;
  border: 2px solid var(--line); border-radius: 50%; background: var(--white); font-size: .875rem; font-weight: 600;
}
.is-done .step-btn { color: var(--navy-deep); cursor: pointer; }
.is-done .step-btn:hover { text-decoration: underline; }
.is-done .step-btn::before { content: "\2713"; background: var(--navy); border-color: var(--navy); color: var(--white); }
.is-current .step-btn { color: var(--navy-deep); font-weight: 700; }
.is-current .step-btn::before { border-color: var(--navy); color: var(--navy-deep); box-shadow: 0 0 0 3px var(--gold); }

.progress { display: none; }
.progress__text { margin: 0 0 .5rem; font-weight: 600; max-width: none; }
.progress__bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress__bar span { display: block; height: 100%; background: var(--navy); transition: width .2s; }

.wizard__panel h2 { margin-bottom: 1.25rem; scroll-margin-top: 1.5rem; }
.wizard__panel h2:focus { outline: 0; }
.js .wizard-step:not(.is-current) { display: none; }
.wizard-step + .wizard-step { margin-top: 3rem; }
.js .wizard-step + .wizard-step { margin-top: 0; }
.step-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.step-nav .btn { min-width: 8rem; }
.step-nav .btn--primary { margin-left: auto; }
html:not(.js) .btnNext, html:not(.js) .btnPrev { display: none; }
[hidden] { display: none !important; }

@media (max-width: 52rem) {
  .wizard { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .wizard__rail { position: static; }
  .steps { display: none; }
  .js .progress { display: block; }
}

/* ---- Confirmation ---- */
.ref { margin: 1.5rem 0; padding: 1.25rem 1.5rem; border-left: 6px solid var(--gold); background: var(--mist); }
.ref p { margin: 0; color: var(--muted); }
.ref strong { display: block; margin: .25rem 0 .75rem; font: 600 clamp(1.75rem, 1.4rem + 2vw, 2.5rem)/1.2 var(--serif); color: var(--navy-deep); overflow-wrap: anywhere; }

/* ---- Admin ---- */
.admin { background: var(--mist); min-height: 100vh; font-size: 1rem; }
.admin-bar { background: var(--navy); color: var(--white); }
.admin-bar__row { display: flex; align-items: center; gap: 1rem; min-height: 4rem; }
.admin-bar .brand { color: var(--white); }
.admin-bar .brand__name { font-size: 1rem; }
.admin-bar__user { display: flex; align-items: center; gap: 1rem; }
@media (max-width: 34rem) { .admin-bar__name { display: none; } }

.admin-main { width: min(90rem, 100% - 2 * var(--gutter)); margin-inline: auto; padding-block: 1.75rem 3rem; }
.admin-main h1 { font-size: 1.75rem; margin-bottom: 1.25rem; }

.stats { display: flex; flex-wrap: wrap; gap: 1.25rem clamp(2rem, 5vw, 4rem); margin: 0 0 1.75rem; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { color: var(--muted); font-size: .9375rem; }
.stats dd { margin: 0; font: 600 2rem/1.15 var(--serif); color: var(--navy-deep); font-variant-numeric: tabular-nums; }

.filters {
  display: grid; grid-template-columns: minmax(14rem, 2fr) repeat(4, minmax(8rem, 1fr)) auto; gap: .875rem;
  align-items: end; margin-bottom: 1.5rem; padding: 1rem; background: var(--white); border: 1px solid var(--line); border-radius: 8px;
}
.filters .field { margin: 0; }
.filters label { font-size: .875rem; margin-bottom: .25rem; }
.filters .input { min-height: 2.5rem; padding-block: .375rem; font-size: .9375rem; }
.filters__actions { display: flex; gap: .5rem; }
.filters__actions .btn { min-height: 2.5rem; padding-inline: 1rem; font-size: .9375rem; }
@media (max-width: 72rem) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters > :first-child, .filters__actions { grid-column: 1 / -1; } }

.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.results-head h2 { font: 600 1rem/1.3 var(--sans); color: var(--ink); }

.table-scroll { max-height: 72vh; overflow: auto; background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
.applicants { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9375rem; }
.applicants th {
  position: sticky; top: 0; z-index: 1; padding: .625rem .75rem; background: var(--navy-deep); color: var(--white);
  font-weight: 600; text-align: left; white-space: nowrap;
}
.applicants td { padding: .625rem .75rem; border-top: 1px solid var(--line); vertical-align: middle; }
.applicants tbody tr:hover { background: var(--mist); }
.applicants__ref { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.applicants__name { min-width: 11rem; }
.applicants__nowrap { white-space: nowrap; }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }

@media (max-width: 52rem) {
  .table-scroll { max-height: none; overflow: visible; background: none; border: 0; }
  .applicants, .applicants tbody, .applicants tr, .applicants td { display: block; }
  .applicants thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .applicants tr { margin-bottom: .75rem; padding: .75rem 1rem; background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
  .applicants td { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; border: 0; text-align: right; }
  .applicants td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: none; }
  .applicants td.empty { display: block; text-align: center; }
  .applicants td.empty::before { content: none; }
  .applicants td:last-child::before { content: none; }
  .applicants td:last-child { justify-content: flex-end; padding-top: .5rem; }
}

.detail { width: min(52rem, 100vw - 2rem); max-height: 90vh; padding: 0; border: 0; border-radius: 8px; color: var(--ink); }
.detail::backdrop { background: rgba(26, 36, 88, .55); }
.detail__head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; background: var(--navy); color: var(--white); }
.detail__head h2 { color: var(--white); font-size: 1.25rem; }
.detail__body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 2rem; padding: 1.25rem; }
.detail__body h3 { font: 600 1rem/1.3 var(--sans); color: var(--navy); margin-bottom: .5rem; }
.detail dl { margin: 0; display: grid; grid-template-columns: minmax(7rem, auto) 1fr; gap: .25rem .75rem; font-size: .9375rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 40rem) { .detail__body { grid-template-columns: 1fr; } }

/* ---- Admin sign in ---- */
.login { min-height: 100vh; display: flex; flex-direction: column; background: var(--navy); --wave-end: var(--mist); }
.login .waves { flex: none; margin-top: auto; }
.login__top { padding-top: clamp(2rem, 8vh, 5rem); text-align: center; color: var(--white); }
.login__top img { width: 76px; margin: 0 auto .875rem; }
.login__top h1 { color: var(--white); font-size: 1.875rem; }
.login__bottom { flex: 1 0 auto; background: var(--mist); padding-bottom: 3rem; }
.login__card { width: min(26rem, 100% - 2rem); margin: -1rem auto 0; position: relative; padding: 1.75rem; background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
.login__card .btn { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .waves, .no-print { display: none !important; }
  .page-head { background: none; color: var(--ink); }
  .page-head h1, .page-head p { color: var(--ink); }
}
