/* =========================================================
   FND Education Project
   Main site stylesheet
   ========================================================= */


/* ---------- Colour system ---------- */

:root {
  color-scheme: light dark;

  --background: #f4f7f8;
  --surface: #ffffff;

  --text: #17242b;
  --muted: #53636c;

  --accent: #176b78;
  --accent-strong: #0f505a;
  --accent-soft: #e7f4f5;

  --border: #cfdbdf;

  --shadow:
    0 12px 34px rgba(23, 36, 43, 0.08);

  --reading-width: 52rem;
  --site-width: 72rem;
}


@media (prefers-color-scheme: dark) {
  :root {
    --background: #101619;
    --surface: #172126;

    --text: #eef5f6;
    --muted: #b7c4c8;

    --accent: #75c6cf;
    --accent-strong: #9bd9df;
    --accent-soft: #19353a;

    --border: #34474e;

    --shadow:
      0 12px 34px rgba(0, 0, 0, 0.22);
  }
}


/* ---------- Basic document ---------- */

* {
  box-sizing: border-box;
}


html {
  scroll-behavior: smooth;
}


body {
  margin: 0;

  background: var(--background);
  color: var(--text);

  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Arial,
    sans-serif;

  font-size: 1.05rem;
  line-height: 1.7;
}


a {
  color: var(--accent-strong);
  text-underline-offset: 0.16em;
}


a:hover {
  text-decoration-thickness: 2px;
}


a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}


/* ---------- Accessibility ---------- */

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;

  z-index: 1000;

  padding: 0.7rem 1rem;

  background: var(--surface);
  color: var(--text);

  border: 2px solid var(--accent);
  border-radius: 0.4rem;
}


.skip-link:focus {
  top: 1rem;
}


/* ---------- Shared widths ---------- */

.site-wide {
  width: min(
    var(--site-width),
    calc(100% - 2rem)
  );

  margin-inline: auto;
}


.reading-column {
  width: min(
    var(--reading-width),
    calc(100% - 2rem)
  );

  margin-inline: auto;
}


/* ---------- Site header ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}


.site-header .site-wide {
  padding-top: 0.85rem;
  padding-bottom: 0.75rem;
}


.site-name {
  display: inline-block;

  color: var(--text);

  font-size: 0.9rem;
  font-weight: 650;

  text-decoration: none;
}


.site-nav {
  display: flex;
  flex-wrap: wrap;

  gap: 0.45rem 1.25rem;

  margin-top: 0.75rem;

  font-size: 0.94rem;
}


.site-nav a {
  font-weight: 600;
  text-decoration: none;
}


.site-nav a:hover {
  text-decoration: underline;
}


/* ---------- Main page area ---------- */

.site-main {
  padding:
    clamp(1.25rem, 3vw, 2.5rem)
    0
    clamp(2rem, 5vw, 4rem);
}


/* ---------- Course page ---------- */

.course-page {
  overflow: hidden;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 0.8rem;

  box-shadow: var(--shadow);
}


/* ---------- Breadcrumb ---------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;

  gap: 0.25rem 0.45rem;

  padding:
    1.1rem
    clamp(1.1rem, 4vw, 2.5rem)
    0;

  color: var(--muted);

  font-size: 0.9rem;
}


.breadcrumb a {
  color: inherit;
}


/* ---------- Page heading ---------- */

.page-heading {
  padding:
    1.3rem
    clamp(1.1rem, 4vw, 2.5rem)
    2rem;

  border-bottom: 1px solid var(--border);
}


.page-context {
  margin: 0 0 0.55rem;

  color: var(--accent-strong);

  font-size: 0.82rem;
  font-weight: 750;

  letter-spacing: 0.08em;
}


.page-heading h1 {
  max-width: 22ch;

  margin: 0;

  font-size:
    clamp(2rem, 5vw, 3.2rem);

  line-height: 1.12;
  letter-spacing: -0.025em;
}


.page-description {
  max-width: 44rem;

  margin:
    1rem 0 0;

  color: var(--muted);

  font-size: 1.08rem;
  line-height: 1.6;
}


/* ---------- Editorial status ---------- */

.page-status {
  display: flex;
  flex-wrap: wrap;

  gap: 0.4rem 1.2rem;

  margin-top: 1.35rem;
  padding: 0.8rem 1rem;

  background: var(--accent-soft);

  border-left: 4px solid var(--accent);
  border-radius: 0.35rem;

  color: var(--text);

  font-size: 0.9rem;
}


/* ---------- Main educational content ---------- */

.course-content {
  padding:
    1.5rem
    clamp(1.1rem, 4vw, 2.5rem)
    2.5rem;
}


.course-content > :first-child {
  margin-top: 0;
}


.course-content h2,
.course-content h3,
.course-content h4 {
  line-height: 1.25;

  scroll-margin-top: 2rem;
}


.course-content h2 {
  margin:
    2.7rem
    0
    0.9rem;

  font-size:
    clamp(1.55rem, 3vw, 2rem);
}


.course-content h3 {
  margin:
    2rem
    0
    0.7rem;

  font-size: 1.3rem;
}


.course-content p {
  margin:
    0.9rem
    0;
}


.course-content ul,
.course-content ol {
  padding-left: 1.4rem;
}


.course-content li + li {
  margin-top: 0.4rem;
}


/* ---------- Quotes ---------- */

.course-content blockquote {
  margin:
    1.5rem 0;

  padding:
    0.9rem 1.15rem;

  background: var(--accent-soft);

  border-left: 4px solid var(--accent);
}


.course-content blockquote > :first-child {
  margin-top: 0;
}


.course-content blockquote > :last-child {
  margin-bottom: 0;
}


/* ---------- Inline citations ---------- */

.inline-citations {
  display: inline-flex;
  align-items: center;

  gap: 0.18rem;

  margin-left: 0.18rem;

  font-size: 0.78em;
  line-height: 1;

  vertical-align: 0.12em;
}


.inline-citations a {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 1.55em;
  min-height: 1.55em;

  padding: 0.12em 0.34em;

  background: var(--accent-soft);
  color: var(--accent-strong);

  border: 1px solid var(--border);
  border-radius: 0.35rem;

  font-weight: 750;

  text-decoration: none;
}


.inline-citations a:hover {
  border-color: var(--accent);
  text-decoration: underline;
}


.inline-citations a:focus-visible {
  outline-width: 2px;
  outline-offset: 2px;
}


/* ---------- Images ---------- */

.course-content img {
  display: block;

  max-width: 100%;
  height: auto;

  margin:
    1.5rem auto;
}


/* ---------- Horizontal rules ---------- */

.course-content hr {
  margin:
    2.4rem 0;

  border: 0;
  border-top: 1px solid var(--border);
}


/* ---------- Tables ----------
   Most project tables may eventually become prose.
   Remaining tables stay usable on narrow screens.
   ----------------------------------------------- */

.course-content table {
  display: block;

  width: 100%;
  max-width: 100%;

  overflow-x: auto;

  border-collapse: collapse;

  margin:
    1.5rem 0;
}


.course-content th,
.course-content td {
  padding:
    0.6rem 0.75rem;

  border: 1px solid var(--border);

  text-align: left;
  vertical-align: top;
}


.course-content th {
  background: var(--accent-soft);
}


/* ---------- Details / reviewer notes ---------- */

.course-content details {
  margin:
    1.5rem 0;

  padding:
    0.9rem 1rem;

  border: 1px solid var(--border);
  border-radius: 0.4rem;
}


.course-content summary {
  cursor: pointer;
  font-weight: 650;
}


/* ---------- Course page navigation ---------- */

.page-navigation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);

  gap: 1rem;

  margin: 2rem 0;
  padding: 1.25rem 0 0;

  border-top: 1px solid var(--border);
}


.course-content .page-navigation {
  padding-top: 0;

  border-top: 0;
}


.page-navigation-slot {
  min-width: 0;
}


.page-navigation-slot a {
  display: block;

  height: 100%;

  padding: 0.9rem 1rem;

  border: 1px solid var(--border);
  border-radius: 0.45rem;

  background: var(--surface);

  text-decoration: none;
}


.page-navigation-slot a:hover,
.page-navigation-slot a:focus-visible {
  border-color: var(--accent);
}


.page-navigation-next {
  text-align: right;
}


.page-navigation-label,
.page-navigation-title {
  display: block;
}


.page-navigation-label {
  margin-bottom: 0.25rem;

  color: var(--accent-strong);

  font-size: 0.82rem;
  font-weight: 700;
}


.page-navigation-title {
  color: var(--text);

  font-size: 0.95rem;
  line-height: 1.35;
}




/* ---------- Home and resource cards ---------- */

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

  gap: 1rem;

  margin: 1.4rem 0 2rem;
}


.home-card {
  display: block;

  min-height: 11.5rem;

  padding: 1.2rem;

  background: var(--accent-soft);

  border: 1px solid var(--border);
  border-radius: 0.65rem;

  color: var(--text);

  text-decoration: none;

  box-shadow:
    0 4px 14px rgba(23, 36, 43, 0.05);

  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}


.home-card:hover,
.home-card:focus-visible {
  border-color: var(--accent);

  box-shadow:
    0 8px 22px rgba(23, 36, 43, 0.1);

  transform: translateY(-2px);
}


.home-card-label {
  display: block;

  margin-bottom: 0.55rem;

  color: var(--muted);

  font-size: 0.72rem;
  font-weight: 800;

  letter-spacing: 0.09em;
}


.home-card strong {
  display: block;

  margin-bottom: 0.45rem;

  color: var(--accent-strong);

  font-size: 1.12rem;
  line-height: 1.3;
}


.home-card span {
  display: block;

  color: var(--text);

  line-height: 1.45;
}


.home-actions {
  display: flex;
  flex-wrap: wrap;

  gap: 0.7rem;

  margin-top: 1.25rem;
}


.home-action {
  display: inline-block;

  padding: 0.68rem 0.9rem;

  background: var(--accent);
  color: var(--surface);

  border: 1px solid var(--accent);
  border-radius: 0.45rem;

  font-weight: 700;

  text-decoration: none;
}


.home-action:hover,
.home-action:focus-visible {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--surface);
}


@media (max-width: 48rem) {
  .home-grid {
    grid-template-columns: 1fr;
  }
}


/* ---------- Bottom site navigation ---------- */

.site-nav-bottom {
  width: min(
    var(--site-width),
    calc(100% - 2rem)
  );

  margin:
    0 auto 1.5rem;

  padding:
    1rem 0;

  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}


/* ---------- Footer ---------- */

.site-footer {
  background: var(--surface);

  border-top: 1px solid var(--border);

  color: var(--muted);

  font-size: 0.87rem;
}


.footer-inner {
  display: flex;
  flex-wrap: wrap;

  justify-content: space-between;
  align-items: center;

  gap: 0.6rem 1.5rem;

  padding:
    1rem 0;
}


.footer-project-name {
  margin-left: auto;

  text-align: right;
}


.footer-inner nav {
  display: flex;
  gap: 1rem;
}


/* ---------- Floating return-to-top button ---------- */

.return-to-top {
  position: fixed;

  right: 1rem;
  bottom: 1rem;

  z-index: 50;

  width: 2.8rem;
  height: 2.8rem;

  padding: 0;

  border: 1px solid var(--border);
  border-radius: 50%;

  background: var(--surface);
  color: var(--accent-strong);

  box-shadow: var(--shadow);

  font-size: 1.5rem;
  line-height: 1;

  cursor: pointer;

  opacity: 0;
  visibility: hidden;

  pointer-events: none;

  transform: translateY(0.35rem);

  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 140ms ease;
}


.return-to-top-icon {
  display: block;

  width: 1.55rem;
  height: 1.65rem;

  margin: 0 auto;

  color: var(--accent-strong);
  fill: currentColor;
}


.return-to-top.is-visible {
  opacity: 1;
  visibility: visible;

  pointer-events: auto;

  transform: translateY(0);
}


/* ---------- Small screens ---------- */

@media (max-width: 38rem) {

  body {
    font-size: 1rem;
  }


  .reading-column {
    width: min(
      100% - 0.8rem,
      var(--reading-width)
    );
  }


  .course-page {
    border-radius: 0.55rem;
  }


  .page-heading h1 {
    max-width: none;
  }


  .page-navigation {
    grid-template-columns: 1fr;
  }


  .page-navigation-next {
    text-align: left;
  }


  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }


  .footer-project-name {
    margin-left: 0;

    text-align: left;
  }

}


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

@media (prefers-reduced-motion: reduce) {

  html {
    scroll-behavior: auto;
  }


  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

}
