/* Root overview only. Summary pages keep using summary-style.css. */

:root {
  --index-bg: #eef2f0;
  --index-paper: #ffffff;
  --index-ink: #1f2933;
  --index-muted: #62707c;
  --index-line: #d8ded8;
  --index-soft: #f7f9f8;
  --index-accent: #176b73;
  --index-accent-strong: #123f46;
  --index-accent-soft: #e4f3f2;
  --index-focus: #3066be;
  --index-warm: #f2c94c;
  --index-shadow: rgba(31, 41, 51, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--index-bg);
}

body.index-page {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 260px),
    var(--index-bg);
  color: var(--index-ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

.index-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 56px;
}

.index-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: 34px;
  border: 1px solid var(--index-line);
  border-radius: 8px;
  background: var(--index-paper);
  box-shadow: 0 18px 44px var(--index-shadow);
}

.index-hero > * {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--index-accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 10px;
  color: var(--index-accent-strong);
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.subtitle {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--index-muted);
  font-size: 17px;
  overflow-wrap: anywhere;
}

.index-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(112px, 1fr));
  gap: 10px;
}

.stat {
  min-width: 0;
  min-height: 96px;
  padding: 16px 18px;
  border: 1px solid var(--index-line);
  border-radius: 8px;
  background: var(--index-soft);
}

.stat-number {
  display: block;
  color: var(--index-accent-strong);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: 7px;
  color: var(--index-muted);
  font-size: 14px;
}

.subjects-section {
  margin-top: 30px;
}

.section-heading {
  display: flex;
  gap: 18px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading > * {
  min-width: 0;
}

.section-heading h2 {
  margin-bottom: 0;
  color: var(--index-ink);
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-heading p {
  max-width: 460px;
  margin-bottom: 2px;
  color: var(--index-muted);
  font-size: 14px;
  text-align: right;
  overflow-wrap: anywhere;
}

.index-toolbar {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--index-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.search-label {
  color: var(--index-accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.search-control {
  position: relative;
  min-width: 0;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-icon::before {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--index-muted);
  border-radius: 50%;
  content: "";
}

.search-icon::after {
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 8px;
  height: 2px;
  border-radius: 999px;
  background: var(--index-muted);
  content: "";
  transform: rotate(45deg);
  transform-origin: center;
}

.search-control input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px 10px 42px;
  border: 1px solid var(--index-line);
  border-radius: 8px;
  background: var(--index-paper);
  color: var(--index-ink);
  font: inherit;
  line-height: 1.2;
}

.search-control input:focus {
  border-color: var(--index-focus);
  outline: 3px solid rgba(48, 102, 190, 0.18);
}

.search-control input::placeholder {
  color: #87929d;
}

.result-count {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--index-line);
  border-radius: 8px;
  background: var(--index-soft);
  color: var(--index-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.result-count span:first-child {
  color: var(--index-accent-strong);
}

.subject-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.subject-card {
  min-width: 0;
  --card-accent: var(--index-warm);
  --card-accent-soft: #fff8df;
}

.subject-card:nth-child(6n+2) {
  --card-accent: #47a184;
  --card-accent-soft: #e7f5ef;
}

.subject-card:nth-child(6n+3) {
  --card-accent: #4f7fc8;
  --card-accent-soft: #edf3ff;
}

.subject-card:nth-child(6n+4) {
  --card-accent: #d06b4c;
  --card-accent-soft: #fff0eb;
}

.subject-card:nth-child(6n+5) {
  --card-accent: #7b70b4;
  --card-accent-soft: #f0eefb;
}

.subject-card:nth-child(6n+6) {
  --card-accent: #54815d;
  --card-accent-soft: #edf6ee;
}

.subject-link {
  position: relative;
  display: flex;
  min-height: 246px;
  height: 100%;
  flex-direction: column;
  gap: 13px;
  padding: 20px;
  border: 1px solid var(--index-line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfcfb);
  box-shadow: 0 10px 26px rgba(31, 41, 51, 0.08);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.subject-link::before {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--card-accent);
  content: "";
}

.subject-link:hover {
  border-color: color-mix(in srgb, var(--card-accent) 64%, var(--index-line));
  box-shadow: 0 16px 32px rgba(31, 41, 51, 0.12);
  transform: translateY(-2px);
}

.subject-link:focus-visible {
  outline: 3px solid rgba(48, 102, 190, 0.34);
  outline-offset: 3px;
}

.subject-card-top {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.subject-count {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.15;
}

.subject-count {
  border: 1px solid var(--index-line);
  color: var(--index-muted);
}

.subject-title {
  display: block;
  color: var(--index-accent-strong);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.subject-description {
  display: block;
  color: var(--index-muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.subject-action {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: auto;
  color: var(--index-accent);
  font-size: 14px;
  font-weight: 800;
}

.subject-action::after {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--card-accent) 55%, var(--index-line));
  border-radius: 50%;
  background: var(--card-accent-soft);
  content: ">";
  line-height: 1;
  transition: transform 160ms ease;
}

.subject-link:hover .subject-action::after {
  transform: translateX(2px);
}

.empty-card {
  padding: 24px;
  border: 1px dashed var(--index-line);
  border-radius: 8px;
  background: var(--index-paper);
  color: var(--index-muted);
}

@media (prefers-reduced-motion: reduce) {
  .subject-link,
  .subject-action::after {
    transition: none;
  }

  .subject-link:hover,
  .subject-link:hover .subject-action::after {
    transform: none;
  }
}

@media (max-width: 940px) {
  .index-hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .index-stats,
  .subject-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-heading {
    display: block;
  }

  .section-heading p {
    max-width: none;
    margin-top: 5px;
    text-align: left;
  }

  .index-toolbar {
    grid-template-columns: 1fr;
  }

  .result-count {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  body.index-page {
    font-size: 15px;
  }

  .index-shell {
    width: min(100% - 20px, 1160px);
    padding: 10px 0 28px;
  }

  .index-hero {
    padding: 22px;
    border-radius: 8px;
  }

  h1 {
    font-size: 27px;
  }

  .subtitle {
    font-size: 16px;
  }

  .index-stats,
  .subject-list {
    grid-template-columns: 1fr;
  }

  .subject-link {
    min-height: 218px;
    padding: 18px;
  }

  .index-toolbar {
    padding: 10px;
  }

  .subject-card-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .subject-count {
    max-width: 100%;
  }
}

@media print {
  html,
  body.index-page {
    background: #ffffff;
  }

  .index-shell {
    width: auto;
    padding: 0;
  }

  .index-hero,
  .subject-link {
    box-shadow: none;
  }

  .subject-link {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
