/*
 * Courses with prices («Курси з цінами», layout courses) of the department
 * block page. Loaded only on a page that has the block (enqueue.php), so the
 * other department pages do not carry it; page-department.css comes first.
 */

/* ==========================================================================
   Courses with prices: the common terms as a row of figures, then a card per
   course with its level, results, price and a button to sign up.
   ========================================================================== */

.dept-courses {
  --course-accent: var(--color-blue-200);
}

html[data-theme="dark"] .dept-courses {
  --course-accent: var(--color-accent);
  --course-plaque: rgba(var(--color-tint--rgb), 0.08);
  --course-plaque-hover: rgba(var(--color-tint--rgb), 0.13);
}

/* As wide as the cards under it: the plaque in it must not stand squeezed to the left. */
.dept-courses__intro {
  margin: -12px 0 32px;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--color-text-secondary);
}

.dept-courses__intro p {
  margin: 0 0 0.6em;
}

.dept-courses__intro p:last-child {
  margin-bottom: 0;
}

.dept-courses__facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 0 0 clamp(28px, 3vw, 40px);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

/* The figure reads first, the words under it explain it. */
.dept-courses__fact {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 4px;
  padding: 20px 24px;
  border-left: 1px solid var(--color-border);
}

.dept-courses__fact:first-child {
  border-left: none;
  padding-left: 0;
}

.dept-courses__fact dd {
  margin: 0;
  font-size: clamp(1.375rem, 1rem + 1.2vw, 2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--color-text-heading);
}

.dept-courses__fact dt {
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--color-text-secondary);
}

/* --------------------------------------------------------- the staircase */

/* The levels as tabs that rise like stairs, each a step higher than the one before,
   in the blue of its card; the chosen one stands full and points down at its card. */
.dept-courses__ladder {
  display: grid;
  grid-template-columns: repeat(var(--steps, 5), minmax(0, 1fr));
  align-items: end;
  gap: 6px;
  margin-bottom: 14px;
}

.dept-courses__ladder[hidden] {
  display: none;
}

.dept-courses__step {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  min-height: calc(64px + var(--rise, 0) * 16px);
  padding: 12px 16px;
  border: 0;
  background: var(--course-head, var(--color-blue-200));
  color: var(--color-white);
  font: inherit;
  text-align: left;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.dept-courses__step:hover,
.dept-courses__step:focus-visible {
  opacity: 0.8;
}

.dept-courses__step[aria-selected="true"] {
  opacity: 1;
}

/* The chosen step points at the card under it. */
.dept-courses__step[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: -8px;
  border: 8px solid transparent;
  border-bottom: 0;
  border-top-color: var(--course-head, var(--color-blue-200));
}

.dept-courses__step:focus-visible {
  outline: 2px solid var(--color-red);
  outline-offset: 2px;
}

.dept-courses__step-code {
  font-size: clamp(1.25rem, 1rem + 0.8vw, 1.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.dept-courses__step-name {
  font-size: 0.8125rem;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.82);
}

/* --------------------------------------------------------- the level's card */

.dept-courses__levels {
  display: grid;
  gap: 16px;
}

/* The chosen level's card: its blue head (or its photo) beside what it says. */
.dept-courses--ladder .dept-course {
  display: grid;
  grid-template-columns: minmax(260px, 34%) minmax(0, 1fr);
}

.dept-courses--ladder .dept-course[hidden] {
  display: none;
}

.dept-courses--ladder .dept-course__head {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 320px;
  padding: 28px;
}

.dept-courses--ladder .dept-course__body {
  padding: 28px 32px;
}

/* A photo fills the head, the level and the name on a navy haze at its foot. */
.dept-course__photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* A touch more colour and depth, so the people look alive under the haze. */
  filter: saturate(1.15) contrast(1.05);
}

.dept-course--photo .dept-course__head::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(var(--color-blue-200--rgb), 0.82) 0%, rgba(var(--color-blue-200--rgb), 0.4) 30%, transparent 58%);
}

.dept-course__head-in {
  position: relative;
  z-index: 1;
}

.dept-course--photo .dept-course__watermark {
  display: none;
}

/* The price and the button side by side under the plaque. */
.dept-course__deal {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.dept-course__deal .dept-course__price {
  margin: 0;
  padding: 0;
  border: 0;
}

@media (max-width: 899px) {
  .dept-courses__ladder {
    gap: 4px;
  }

  .dept-courses__step {
    min-height: calc(48px + var(--rise, 0) * 10px);
    padding: 8px;
  }

  .dept-courses__step-name {
    display: none;
  }

  .dept-courses__step-code {
    font-size: 0.9375rem;
    letter-spacing: -0.03em;
  }

  .dept-courses__step[aria-selected="true"]::after {
    left: 12px;
  }

  .dept-courses--ladder .dept-course {
    grid-template-columns: 1fr;
  }

  .dept-courses--ladder .dept-course__head {
    min-height: 0;
    padding: 20px;
  }

  .dept-courses--ladder .dept-course--photo .dept-course__head {
    min-height: 260px;
  }

  .dept-courses--ladder .dept-course__body {
    padding: 20px;
  }
}

.dept-course {
  display: flex;
  flex-direction: column;
  background: var(--color-surface-card);
  overflow: hidden;
}

/*
 * The header is a designed brand object, the same in both themes: its blue deepens
 * level by level up to the brand navy, the level code lies huge and outlined behind it,
 * and a meter of bars fills up to the level.
 */
.dept-course__head {
  position: relative;
  overflow: hidden;
  padding: 24px 24px 22px;
  background: var(--course-head, var(--color-blue-200));
  color: var(--color-white);
}

.dept-course--step-1 { --course-head: #4570c0; }
.dept-course--step-2 { --course-head: #3a64b4; }
.dept-course--step-3 { --course-head: #2c5199; }
.dept-course--step-4 { --course-head: #213e7d; }
.dept-course--step-5 { --course-head: var(--color-blue-200); }

.dept-course__watermark {
  position: absolute;
  right: -0.06em;
  bottom: -0.24em;
  font-size: 8.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
  /* A faint solid fill: an outline of this heavy face showed the joins of the strokes as holes. */
  color: rgba(255, 255, 255, 0.09);
  pointer-events: none;
  user-select: none;
}

.dept-course__level {
  display: block;
  font-size: clamp(2.5rem, 2rem + 1.5vw, 3.25rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  white-space: nowrap;
  color: var(--color-white);
}

.dept-course__name {
  position: relative;
  margin: 14px 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-white);
}

.dept-course__subtitle {
  display: block;
  margin-top: 4px;
  font-size: 0.9375rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.78);
}

/* The international exam the level leads to, a quiet line at the foot of the header. */
.dept-course__exam {
  position: relative;
  margin: 12px 0 0;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--color-white);
}

.dept-course__exam span {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
}

.dept-course__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 22px 24px 24px;
}

.dept-course__who {
  margin: 0 0 18px;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-text-primary);
}

.dept-course__label {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-secondary);
}

.dept-course__outcomes {
  margin: 0;
  padding: 0;
  list-style: none;
}

.dept-course__outcomes li {
  position: relative;
  margin: 0;
  padding: 9px 0 9px 18px;
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.dept-course__outcomes li::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 0;
  width: 6px;
  height: 6px;
  background: var(--course-accent);
}

.dept-course__foot {
  margin-top: auto;
  padding-top: 20px;
}

.dept-course__price {
  margin: 0 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.dept-course__price strong {
  display: block;
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-heading);
}

.dept-course__price span {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

/* The way to the course's programme: a plaque above the price, edged in the card's own
   blue, saying how big the programme is; the arrow moves on under the pointer. */
.dept-course__program {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px;
  padding: 14px 14px 14px 18px;
  background: var(--course-plaque, rgba(22, 41, 91, 0.07));
  color: var(--color-text-heading);
  text-decoration: none;
  transition: background-color 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dept-course__program:hover,
.dept-course__program:focus-visible {
  background: var(--course-plaque-hover, rgba(22, 41, 91, 0.12));
}

.dept-course__program-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dept-course__program-text strong {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

.dept-course__program-text span {
  font-size: 0.8125rem;
  line-height: 1.3;
  color: var(--color-text-secondary);
}

/* The arrow in a navy square, as the button to sign up is: the plaque reads as a way on. */
.dept-course__program svg,
.dept-course__program .ph-icon {
  flex: none;
  box-sizing: content-box;
  width: 18px;
  height: 18px;
  padding: 9px;
  background: var(--color-blue-200);
  color: var(--color-white);
  transition: background-color 0.2s ease;
}

.dept-course__program:hover svg,
.dept-course__program:hover .ph-icon {
  background: var(--color-blue-100, var(--color-blue-200));
}

@media (prefers-reduced-motion: reduce) {
  .dept-course__program svg,
  .dept-course__program .ph-icon {
    transition: none;
  }
}

.dept-courses__note {
  margin-top: clamp(24px, 3vw, 32px);
  padding: 20px 24px;
  background: rgba(var(--color-tint--rgb), 0.04);
  border: 1px solid var(--color-red);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text-primary);
}

.dept-courses__note p {
  margin: 0;
}

.dept-courses__note a {
  color: var(--color-link);
  font-weight: 700;
}

@media (max-width: 899px) {
  .dept-courses__facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dept-courses__fact {
    padding: 16px 0 16px 16px;
  }

  .dept-courses__fact:nth-child(odd) {
    border-left: none;
    padding-left: 0;
  }

  .dept-courses__fact:nth-child(n + 3) {
    border-top: 1px solid var(--color-border);
  }

  .dept-course__head,
  .dept-course__body {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* Courses: the word lies huge and faint in the top corner of the section, behind the cards. */
.dept-courses__decor {
  position: absolute;
  top: clamp(8px, 2vw, 24px);
  right: -0.04em;
  font-size: clamp(4rem, 2rem + 8vw, 11rem);
  white-space: nowrap;
  color: var(--course-accent);
  opacity: 0.06;
}

.dept-courses > .dept-container {
  position: relative;
  z-index: 1;
}

/* Phones: the block at a phone's scale, as the rest of the page (page-department.css). */
@media (max-width: 899px) {
  .dept-courses__decor {
    font-size: 3.5rem !important;
  }

  /* Level cards */
  .dept-course__head {
    padding-top: 18px;
    padding-bottom: 16px;
  }

  .dept-course__level {
    font-size: 2.25rem;
  }

  .dept-course__watermark {
    font-size: 6rem;
  }

  .dept-course__name {
    margin-top: 12px;
    padding-top: 10px;
    font-size: 1.0625rem;
  }

  .dept-course__body {
    padding-top: 16px;
    padding-bottom: 18px;
  }

  .dept-course__price strong {
    font-size: 1.375rem;
  }

  .dept-courses__fact dd {
    font-size: 1.25rem;
  }
}

/* ---------------------------------------------- the level's card, refined */

/* The type of the card at the scale of the page's own text, not a size smaller. */
.dept-courses--ladder .dept-course__who {
  margin-bottom: 20px;
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--color-text-heading);
}

.dept-courses--ladder .dept-course__label {
  margin-bottom: 6px;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-text-heading);
}

.dept-courses--ladder .dept-course__outcomes li {
  padding: 10px 0 10px 22px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-text-primary);
}

.dept-courses--ladder .dept-course__outcomes li::before {
  top: 19px;
  width: 8px;
  height: 2px;
  background: var(--course-head, var(--color-blue-200));
}

.dept-courses__step-code {
  letter-spacing: -0.01em;
}

.dept-courses__step-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.dept-course__head-in .dept-course__name {
  margin-top: 12px;
}

/* ------------------------------------------------------------------ motion */

/* The steps answer the pointer by rising a little. */
.dept-courses__step {
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* The stairs build up step after step as the section comes into view. */
.dept-courses__ladder.is-waiting .dept-courses__step {
  opacity: 0;
  transform: translateY(24px);
}

.dept-courses__ladder.is-in .dept-courses__step {
  animation: dept-courses-step-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  animation-delay: calc(var(--rise, 0) * 80ms);
}

/* Each entrance gives only its first frame and holds it while it waits (backwards):
   once over, the element's own styles rule again, hover lifts included. */

/* A chosen level comes in: the photo settles from a slight zoom, the words rise into place one after another. */
.dept-course.is-shown .dept-course__photo {
  animation: dept-courses-photo-in 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.dept-course.is-shown .dept-course__head-in,
.dept-course.is-shown .dept-course__body > *,
.dept-course.is-shown .dept-course__outcomes li,
.dept-course.is-shown .dept-course__foot > * {
  animation: dept-courses-rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.dept-course.is-shown .dept-course__body > :nth-child(2) { animation-delay: 60ms; }
.dept-course.is-shown .dept-course__outcomes li:nth-child(1) { animation-delay: 120ms; }
.dept-course.is-shown .dept-course__outcomes li:nth-child(2) { animation-delay: 170ms; }
.dept-course.is-shown .dept-course__outcomes li:nth-child(3) { animation-delay: 220ms; }
.dept-course.is-shown .dept-course__outcomes li:nth-child(4) { animation-delay: 270ms; }
.dept-course.is-shown .dept-course__foot > :nth-child(1) { animation-delay: 300ms; }
.dept-course.is-shown .dept-course__foot > :nth-child(2) { animation-delay: 360ms; }

/* The list and the foot move by their own children, not as a whole. */
.dept-course.is-shown .dept-course__body > .dept-course__outcomes,
.dept-course.is-shown .dept-course__body > .dept-course__foot {
  animation: none;
}

@keyframes dept-courses-step-in {
  from { opacity: 0; transform: translateY(24px); }
}

@keyframes dept-courses-photo-in {
  from { opacity: 0.4; transform: scale(1.08); }
}

@keyframes dept-courses-rise {
  from { opacity: 0; transform: translateY(12px); }
}

@media (prefers-reduced-motion: reduce) {
  .dept-courses__step,
  .dept-course__program {
    transition: none;
  }

  .dept-courses__ladder.is-in .dept-courses__step,
  .dept-course.is-shown .dept-course__photo,
  .dept-course.is-shown .dept-course__head-in,
  .dept-course.is-shown .dept-course__body > *,
  .dept-course.is-shown .dept-course__outcomes li,
  .dept-course.is-shown .dept-course__foot > * {
    animation: none;
  }

  .dept-courses__step:hover,
  .dept-course__program:hover {
    transform: none;
  }
}

/* The next group: when it starts and how many places are left, in red when few. */
.dept-course__group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin: 0 0 12px;
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

.dept-course__group strong {
  color: var(--color-text-heading);
}

.dept-course__group.is-few strong {
  color: var(--color-red);
}

/* Phones: the courses' words at the page's phone size (15px), not a size above it. */
@media (max-width: 599px) {
  .dept-courses__intro,
  .dept-courses--ladder .dept-course__who {
    font-size: 0.9375rem;
    line-height: 1.55;
  }

  .dept-courses--ladder .dept-course__outcomes li {
    padding-top: 8px;
    padding-bottom: 8px;
    font-size: 0.9375rem;
  }

  .dept-courses--ladder .dept-course__outcomes li::before {
    top: 18px;
  }

  .dept-courses--ladder .dept-course__level {
    font-size: 1.875rem;
  }

  .dept-courses--ladder .dept-course__name {
    font-size: 1.0625rem;
  }

  .dept-course__program-text strong {
    font-size: 0.9375rem;
  }

  .dept-course__price strong {
    font-size: 1.25rem;
  }
}

/* The levels go by themselves until one is chosen (courses.php): a line along the
   foot of the chosen step fills for as long as it stays. */
.dept-courses__timer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.85);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

.dept-courses__ladder.is-auto .dept-courses__step[aria-selected="true"] .dept-courses__timer {
  animation: dept-courses-timer var(--level-delay, 6s) linear both;
}

@keyframes dept-courses-timer {
  to { transform: scaleX(1); }
}

/* The intro: its first paragraph a lead; the next ones — «don't know your level?» —
   a plaque of their own on a faint navy, its link to the form ending it as an arrow. */
.dept-courses__intro p:first-child {
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--color-text-heading);
}

.dept-courses__intro p + p {
  position: relative;
  margin-top: 16px;
  padding: 16px 200px 16px 20px;
  background: var(--course-plaque, rgba(22, 41, 91, 0.07));
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-text-primary);
}

.dept-courses__intro p + p strong {
  color: var(--color-text-heading);
}

.dept-courses__intro a {
  color: var(--color-link);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(var(--color-tint--rgb), 0.25);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
}

.dept-courses__intro a:hover {
  text-decoration-color: currentColor;
}

/* The plaque's own way to the form: a short navy button at its right, level with its middle. */
.dept-courses__intro .dept-courses__intro-go {
  position: absolute;
  top: 50%;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  transform: translateY(-50%);
  background: var(--color-blue-200);
  color: var(--color-white);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

.dept-courses__intro .dept-courses__intro-go::after {
  content: "→";
}

.dept-courses__intro .dept-courses__intro-go:hover {
  background: var(--color-blue-100);
}

@media (max-width: 599px) {
  .dept-courses__intro p:first-child {
    font-size: 1rem;
  }

  .dept-courses__intro p + p {
    padding: 14px 16px;
  }

  .dept-courses__intro .dept-courses__intro-go {
    position: static;
    display: flex;
    width: fit-content;
    margin-top: 12px;
    transform: none;
  }
}
