:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-muted: #f0f2ed;
  --primary: #5c3c84;
  --accent: #04744c;
  --text: #1d1f26;
  --text-muted: #5c6470;
  --border: rgba(29, 31, 38, 0.08);
  color-scheme: light;
}

@font-face {
  font-family: 'Computer Modern Serif';
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url('vendor/fonts/computer-modern-regular.woff') format('woff');
}

@font-face {
  font-family: 'Computer Modern Serif';
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url('vendor/fonts/computer-modern-bold.woff') format('woff');
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.66;
}

h1,
h2,
h3,
h4 {
  font-family: 'Crimson Text', 'Georgia', serif;
  margin: 0 0 0.75rem;
  line-height: 1.3;
  color: var(--text);
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

.container {
  width: min(1100px, calc(100% - 2.5rem));
  margin: 0 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.section {
  padding: clamp(1.25rem, 4vw, 2.4rem) 0;
}

.section-heading {
  max-width: 720px;
  margin-bottom: 1.25rem;
}

.site-header {
  background: linear-gradient(135deg, #c8e6df, #d0c5e8 65%);
  padding: clamp(1.2rem, 4vw, 2.6rem) 0;
}

.header-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
  align-items: flex-end;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.lede {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 540px;
}

.site-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-weight: 600;
  align-items: center;
}

.site-nav a {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(92, 60, 132, 0.15);
  text-decoration: none;
  color: var(--text);
}

.site-nav a:hover {
  background: var(--surface);
}

.site-nav a.active {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

.site-nav-toggle {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(92, 60, 132, 0.25);
  background: rgba(255, 255, 255, 0.6);
  font-weight: 700;
  cursor: pointer;
}

.site-nav-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.about-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: start;
}

.contact-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}

.contact-list li + li {
  margin-top: 0.75rem;
}

.contact-list .label {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.contact-link {
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(5, 116, 76, 0.25);
  background: rgba(4, 116, 76, 0.08);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.contact-link:hover,
.contact-link:focus-visible {
  background: rgba(4, 116, 76, 0.16);
}

.highlight-card {
  background: var(--surface);
  border-radius: 1rem;
  padding: 1.75rem;
  border: 1px solid var(--border);
  box-shadow: 0 20px 45px rgba(24, 37, 56, 0.08);
}

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface);
  padding: 0.75rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid rgba(74, 30, 117, 0.15);
  box-shadow: 0 6px 18px rgba(74, 30, 117, 0.08);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.abstract-toggle {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 1.06em;
  color: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.abstract-toggle:hover {
  color: var(--accent);
}

.abstract-toggle:active {
  transform: translateY(1px);
}

.abstract-toggle::after {
  content: '▼';
  font-size: 0.75em;
  color: currentColor;
  transition: transform 0.2s ease, color 0.2s ease;
  margin-left: 0.5rem;
}

.abstract-toggle[aria-expanded="true"]::after {
  transform: rotate(-180deg);
}

.abstract-label {
  font-size: 0.78em;
  font-weight: 600;
  color: var(--accent);
}

.abstract {
  margin: 0.05rem 0 0.1rem;
  font-size: 0.95em;
  color: #3b3b3b;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.2rem;
  margin-bottom: 0.35rem;
}

.card-links a {
  font-size: 0.85rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(5, 116, 76, 0.25);
  color: var(--accent);
  background: rgba(4, 116, 76, 0.12);
}

.card-links .problem-link {
  border: 1px solid rgba(248, 179, 50, 0.4);
  background: rgba(248, 179, 50, 0.15);
  color: #7a5100;
  font-weight: 600;
}

.meta {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card-grid {
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  list-style: none;
  padding: 0;
  margin: 0;
}
.card-grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.problem-sheet {
  background: #fff;
  border: 1px solid #d7d3c3;
  border-radius: 1rem;
  padding: clamp(1.25rem, 3vw, 2.1rem);
  box-shadow: 0 25px 65px rgba(33, 23, 4, 0.08);
  font-family: 'Computer Modern Serif', 'Crimson Text', serif;
  color: #1f150e;
  margin-bottom: 0.75rem;
}

.sheet-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 1px solid #d9cfb9;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}
.sheet-heading--compact {
  margin-bottom: 0.75rem;
}

.sheet-title {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sheet-date {
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
  font-style: italic;
  color: #695947;
}

.sheet-author {
  margin-left: auto;
  text-align: right;
  font-size: 0.95rem;
  color: #3d3124;
}

.sheet-author p {
  margin: 0;
}

.sheet-note {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  color: #4b3d2c;
}

.problem-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.problem-sections.is-loading {
  opacity: 0.85;
}

.problem-sheet-placeholder {
  margin: 0;
  font-style: italic;
  color: #7c6b52;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.problem-sheet-placeholder::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(124, 107, 82, 0.35);
  border-top-color: #7a5100;
  animation: spin 0.8s linear infinite;
}

.problem-section {
  border: 1px solid #d7d3c3;
  border-radius: 0.85rem;
  background: #fffcf4;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  overflow: hidden;
  position: relative;
}

.problem-section summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 0.9rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid #e7ddcf;
  background: linear-gradient(90deg, rgba(248, 179, 50, 0.18), rgba(255, 252, 244, 0.7));
}

.problem-section summary::-webkit-details-marker {
  display: none;
}

.problem-section summary span:last-child {
  font-size: 0.85rem;
  color: #6a5d45;
}

.problem-section summary a {
  color: inherit;
  text-decoration: none;
}

.problem-section summary a:hover,
.problem-section summary a:focus-visible {
  text-decoration: underline;
}

.problem-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filter-chip {
  border: 1px solid rgba(92, 60, 132, 0.3);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.filter-chip:hover,
.filter-chip:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.problem-grid {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  padding: 0.5rem 0.85rem 0.15rem;
}

.problem-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.problem-filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#problem-search {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

@media (max-width: 900px) {
  .problem-grid {
    column-count: 1;
  }
}

@media print {
  .site-header,
  .site-footer,
  .problem-controls,
  .recent-problems,
  .problem-actions-row,
  .site-nav {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .problem-sheet {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  details.problem-section {
    border: none;
  }

  .problem-grid {
    column-count: 1;
    padding: 0.5rem 0;
  }
}

.problem-card {
  border: none;
  border-bottom: 1px dashed #d9cfb9;
  border-radius: 0;
  background: transparent;
  padding: 0 0 0.25rem;
  margin: 0 0 0.35rem;
  font-family: 'Computer Modern Serif', 'Crimson Text', serif;
  font-size: 1.01rem;
  line-height: 1.52;
  color: #20160e;
  break-inside: avoid;
}

.problem-card:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.problem-card--placeholder {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  border-bottom: none;
  margin-bottom: 0;
  column-span: all;
  -webkit-column-span: all;
}

.problem-text {
  margin: 0 0 0.15rem;
  white-space: pre-line;
  text-align: justify;
  text-indent: 0;
  font-weight: 400;
}

.problem-text .MathJax_Display {
  text-align: center !important;
  margin: 0.5rem 0;
}

.problem-text .MathJax_Display > .MathJax {
  display: inline-block;
}

.problem-links {
  margin: 0.35rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.links-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7c6b52;
  margin-right: 0.35rem;
}

.problem-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.problem-link {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(248, 179, 50, 0.4);
  background: rgba(248, 179, 50, 0.15);
  color: #7a5100;
  font-weight: 600;
  text-decoration: none;
}

.problem-link:hover,
.problem-link:focus-visible {
  border-color: #7a5100;
}

.problem-link[target="_blank"]::after {
  content: "↗";
  font-size: 0.85em;
  margin-left: 0.35rem;
  color: inherit;
  opacity: 0.75;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
}

.button:hover {
  opacity: 0.9;
}

.button-secondary {
  background: var(--accent);
}

.camp-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.camp-links a {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(248, 179, 50, 0.4);
  background: rgba(248, 179, 50, 0.15);
  font-size: 0.9rem;
  font-weight: 600;
  color: #7a5100;
  text-decoration: none;
}

.camp-links a:hover,
.camp-links a:focus-visible {
  border-color: #7a5100;
}

.site-footer {
  background: var(--surface-muted);
  padding: 1.5rem 0;
}

.footer-layout {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.back-to-top {
  font-weight: 600;
}

@media (max-width: 640px) {
  .site-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .card {
    padding: 1.25rem;
  }

  .header-layout {
    align-items: flex-start;
  }
}
.card-grid--compact .card {
  font-size: 0.92rem;
}

.info-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
}

.info-grid--three {
  gap: 1.35rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.info-grid--two {
  gap: 1.45rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.wda-page .section {
  padding: clamp(0.9rem, 3vw, 1.6rem) 0;
}

.wda-page .highlight-card,
.wda-page .problem-sheet {
  padding: clamp(0.85rem, 2.5vw, 1.4rem);
  margin-bottom: 0.5rem;
}
.wda-page .sheet-title {
  font-size: 1.5rem;
  letter-spacing: 0;
  text-transform: none;
  margin: 0 0 0.75rem;
}

.wda-page .site-header {
  padding: clamp(1rem, 3vw, 1.8rem) 0;
}

.olympiad-page .problem-sheet {
  padding: clamp(1.1rem, 3vw, 2rem);
  margin-bottom: 0.85rem;
}

.olympiad-page .problem-section {
  margin-bottom: 0.8rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  .nav-actions {
    width: 100%;
    justify-content: space-between;
  }

  .site-nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 0.5rem;
  }

  .site-nav.is-open {
    display: flex;
  }
}
