/**
 * Homepage visual composition — premium educational layout.
 */

.kutby-home {
  display: block;
}

/* ------------------------------------------------------------------ */
/* Shared section rhythm                                              */
/* ------------------------------------------------------------------ */

.kutby-home-section {
  padding-block: var(--kutby-space-10);
}

.kutby-home-section:nth-child(even) {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--kutby-color-surface) 88%, transparent) 0%,
    transparent 100%
  );
}

.kutby-home-section__header {
  max-width: none;
  margin-bottom: var(--kutby-space-8);
}

.kutby-home-section__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--kutby-space-3) var(--kutby-space-6);
  max-width: none;
}

.kutby-home-section__title {
  margin: 0;
  max-width: 40rem;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: var(--kutby-font-weight-bold);
  line-height: var(--kutby-line-height-tight);
  color: var(--kutby-color-text);
  letter-spacing: 0;
}

.kutby-home-section__more {
  color: var(--kutby-color-link);
  font-size: var(--kutby-font-size-sm);
  font-weight: var(--kutby-font-weight-medium);
  text-decoration: none;
  white-space: nowrap;
}

.kutby-home-section__more:hover {
  color: var(--kutby-color-hover);
  text-decoration: underline;
}

.kutby-home-section__more:focus-visible {
  outline: none;
  box-shadow: var(--kutby-focus-ring);
  border-radius: var(--kutby-radius-sm);
}

.kutby-home-section__lead {
  margin: var(--kutby-space-3) 0 0;
  max-width: 40rem;
  font-size: var(--kutby-font-size-lg);
  line-height: var(--kutby-line-height);
  color: var(--kutby-color-muted);
}

/* ------------------------------------------------------------------ */
/* Semester navigation                                                */
/* ------------------------------------------------------------------ */

.kutby-semester-nav__list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--kutby-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.kutby-semester-nav__link {
  display: flex;
  align-items: center;
  gap: var(--kutby-space-3);
  min-height: 3.5rem;
  padding: var(--kutby-space-4) var(--kutby-space-5);
  border: 1px solid var(--kutby-color-border);
  border-radius: var(--kutby-radius-lg);
  background: var(--kutby-color-card);
  color: var(--kutby-color-text);
  text-decoration: none;
  font-weight: var(--kutby-font-weight-medium);
  box-shadow: var(--kutby-shadow-sm);
  transition:
    border-color var(--kutby-transition),
    box-shadow var(--kutby-transition),
    transform var(--kutby-transition),
    background-color var(--kutby-transition);
}

.kutby-semester-nav__link:hover {
  border-color: color-mix(in srgb, var(--kutby-color-primary) 40%, var(--kutby-color-border));
  box-shadow: var(--kutby-shadow-md);
  transform: translateY(-2px);
}

.kutby-semester-nav__link:focus-visible {
  outline: none;
  box-shadow: var(--kutby-focus-ring);
}

.kutby-semester-nav__link.is-active {
  border-color: var(--kutby-color-primary);
  background: color-mix(in srgb, var(--kutby-color-primary) 8%, var(--kutby-color-card));
  color: var(--kutby-color-primary);
}

.kutby-semester-nav__icon {
  display: inline-flex;
  color: var(--kutby-color-primary);
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Grades grid                                                        */
/* ------------------------------------------------------------------ */

.kutby-grades-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--kutby-space-4);
}

.kutby-grade-card {
  display: flex;
  flex-direction: column;
  gap: var(--kutby-space-2);
  padding: var(--kutby-space-5);
  border: 1px solid var(--kutby-color-border);
  border-radius: var(--kutby-radius-lg);
  background: var(--kutby-color-card);
  color: var(--kutby-color-text);
  text-decoration: none;
  box-shadow: var(--kutby-shadow-sm);
  transition:
    border-color var(--kutby-transition),
    box-shadow var(--kutby-transition),
    transform var(--kutby-transition);
}

.kutby-grade-card:hover {
  border-color: color-mix(in srgb, var(--kutby-color-primary) 35%, var(--kutby-color-border));
  box-shadow: var(--kutby-shadow-md);
  transform: translateY(-3px);
}

.kutby-grade-card:focus-visible {
  outline: none;
  box-shadow: var(--kutby-focus-ring);
}

.kutby-grade-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: var(--kutby-space-1);
  border-radius: var(--kutby-radius-md);
  background: color-mix(in srgb, var(--kutby-color-primary) 12%, transparent);
  color: var(--kutby-color-primary);
}

.kutby-grade-card__stage {
  font-size: var(--kutby-font-size-sm);
  color: var(--kutby-color-muted);
}

.kutby-grade-card__label {
  font-size: var(--kutby-font-size-body);
  font-weight: var(--kutby-font-weight-bold);
  line-height: var(--kutby-line-height-tight);
}

/* ------------------------------------------------------------------ */
/* Subjects                                                           */
/* ------------------------------------------------------------------ */

.kutby-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kutby-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.kutby-subject-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--kutby-space-2);
  padding: var(--kutby-space-3) var(--kutby-space-4);
  border: 1px solid var(--kutby-color-border);
  border-radius: var(--kutby-radius-md);
  background: var(--kutby-color-card);
  color: var(--kutby-color-text);
  text-decoration: none;
  font-weight: var(--kutby-font-weight-medium);
  box-shadow: var(--kutby-shadow-sm);
  transition:
    background-color var(--kutby-transition),
    border-color var(--kutby-transition),
    color var(--kutby-transition);
}

.kutby-subject-chip:hover {
  border-color: var(--kutby-color-primary);
  color: var(--kutby-color-primary);
  background: color-mix(in srgb, var(--kutby-color-primary) 6%, var(--kutby-color-card));
}

.kutby-subject-chip:focus-visible {
  outline: none;
  box-shadow: var(--kutby-focus-ring);
}

.kutby-subject-chip__icon {
  display: inline-flex;
  color: var(--kutby-color-primary);
}

/* ------------------------------------------------------------------ */
/* Latest files                                                       */
/* ------------------------------------------------------------------ */

.kutby-home-files {
  display: grid;
  gap: var(--kutby-space-5);
}

.kutby-home-files .kutby-card {
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* Latest articles                                                    */
/* ------------------------------------------------------------------ */

.kutby-home-articles {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--kutby-space-6);
  align-items: stretch;
}

.kutby-home-articles__featured .kutby-card {
  height: 100%;
  min-height: 22rem;
}

.kutby-home-articles__grid {
  display: grid;
  gap: var(--kutby-space-4);
}

.kutby-home-articles__grid .kutby-card {
  height: 100%;
}

/* ------------------------------------------------------------------ */
/* Calendar                                                           */
/* ------------------------------------------------------------------ */

.kutby-calendar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--kutby-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: kutby-cal;
}

.kutby-calendar__item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--kutby-space-4);
  align-items: center;
  padding: var(--kutby-space-5);
  border: 1px solid var(--kutby-color-border);
  border-radius: var(--kutby-radius-lg);
  background: var(--kutby-color-card);
  box-shadow: var(--kutby-shadow-sm);
  border-inline-start: 4px solid var(--kutby-color-primary);
}

.kutby-calendar__item--holiday {
  border-inline-start-color: var(--kutby-color-accent);
}

.kutby-calendar__item--exam {
  border-inline-start-color: var(--kutby-color-secondary);
}

.kutby-calendar__date {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 6.5rem;
  padding: var(--kutby-space-2) var(--kutby-space-3);
  border-radius: var(--kutby-radius-md);
  background: var(--kutby-color-surface);
  color: var(--kutby-color-primary);
  font-size: var(--kutby-font-size-sm);
  font-weight: var(--kutby-font-weight-bold);
  text-align: center;
}

.kutby-calendar__title {
  font-weight: var(--kutby-font-weight-medium);
  line-height: var(--kutby-line-height-tight);
}

/* ------------------------------------------------------------------ */
/* App banner                                                         */
/* ------------------------------------------------------------------ */

.kutby-app-banner {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--kutby-space-8);
  align-items: center;
  padding: clamp(1.5rem, 4vw, 3rem);
  border-radius: var(--kutby-radius-lg);
  background:
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--kutby-color-accent) 22%, transparent), transparent 45%),
    linear-gradient(135deg, var(--kutby-color-secondary) 0%, var(--kutby-color-primary) 70%);
  color: var(--kutby-color-on-inverse);
  overflow: hidden;
}

.kutby-app-banner__eyebrow {
  margin: 0 0 var(--kutby-space-2);
  font-size: var(--kutby-font-size-sm);
  opacity: 0.85;
}

.kutby-app-banner__title {
  margin: 0 0 var(--kutby-space-3);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  line-height: var(--kutby-line-height-tight);
  color: inherit;
}

.kutby-app-banner__text {
  margin: 0 0 var(--kutby-space-6);
  max-width: 36rem;
  font-size: var(--kutby-font-size-lg);
  line-height: var(--kutby-line-height);
  opacity: 0.92;
}

.kutby-app-banner .kutby-btn--primary {
  background: var(--kutby-color-on-inverse);
  color: var(--kutby-color-secondary);
}

.kutby-app-banner .kutby-btn--primary:hover {
  background: color-mix(in srgb, var(--kutby-color-on-inverse) 90%, var(--kutby-color-accent));
  color: var(--kutby-color-secondary);
}

.kutby-app-banner__visual {
  border-radius: var(--kutby-radius-lg);
  overflow: hidden;
  box-shadow: var(--kutby-shadow-lg);
  border: 1px solid color-mix(in srgb, #fff 25%, transparent);
}

.kutby-app-banner__visual img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* ------------------------------------------------------------------ */
/* About                                                              */
/* ------------------------------------------------------------------ */

.kutby-about {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: var(--kutby-space-8);
  align-items: stretch;
}

.kutby-about__title {
  margin: 0 0 var(--kutby-space-4);
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  line-height: var(--kutby-line-height-tight);
}

.kutby-about__text {
  margin: 0;
  max-width: 42rem;
  font-size: var(--kutby-font-size-lg);
  line-height: var(--kutby-line-height);
  color: var(--kutby-color-muted);
}

.kutby-about__panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: var(--kutby-space-3);
  padding: var(--kutby-space-6);
  border-radius: var(--kutby-radius-lg);
  border: 1px solid var(--kutby-color-border);
  background:
    linear-gradient(
      160deg,
      color-mix(in srgb, var(--kutby-color-primary) 10%, var(--kutby-color-surface)) 0%,
      var(--kutby-color-surface) 100%
    );
  color: var(--kutby-color-primary);
  font-weight: var(--kutby-font-weight-medium);
}

.kutby-about__panel svg {
  width: 2rem;
  height: 2rem;
}

/* ------------------------------------------------------------------ */
/* Responsive — tablet                                                */
/* ------------------------------------------------------------------ */

@media (max-width: 1024px) {
  .kutby-home-section {
    padding-block: var(--kutby-space-8);
  }

  .kutby-grades-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kutby-home-articles {
    grid-template-columns: 1fr;
  }

  .kutby-home-articles__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kutby-app-banner,
  .kutby-about {
    grid-template-columns: 1fr;
  }

  .kutby-app-banner__visual {
    order: -1;
    max-width: 28rem;
  }
}

/* ------------------------------------------------------------------ */
/* Responsive — mobile                                                */
/* ------------------------------------------------------------------ */

@media (max-width: 720px) {
  .kutby-home-section {
    padding-block: var(--kutby-space-6);
  }

  .kutby-home-section__header {
    margin-bottom: var(--kutby-space-5);
  }

  .kutby-semester-nav__list {
    grid-template-columns: 1fr;
  }

  .kutby-grades-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--kutby-space-3);
  }

  .kutby-grade-card {
    padding: var(--kutby-space-4);
  }

  .kutby-subjects {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kutby-subject-chip {
    justify-content: flex-start;
    width: 100%;
  }

  .kutby-home-articles__grid {
    grid-template-columns: 1fr;
  }

  .kutby-calendar {
    grid-template-columns: 1fr;
  }

  .kutby-calendar__item {
    grid-template-columns: 1fr;
    gap: var(--kutby-space-3);
  }

  .kutby-calendar__date {
    justify-self: start;
  }

  .kutby-app-banner {
    padding: var(--kutby-space-5);
  }

  .kutby-app-banner__visual {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .kutby-grades-grid {
    grid-template-columns: 1fr;
  }

  .kutby-subjects {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kutby-semester-nav__link,
  .kutby-grade-card,
  .kutby-subject-chip {
    transition: none;
  }

  .kutby-semester-nav__link:hover,
  .kutby-grade-card:hover {
    transform: none;
  }
}
