/* Stark Minimal Design - Monochromatic, Grid-based, System fonts */
/* Inspired by Sang Han + Patrick Johnson */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --black: #000000;
  --white: #ffffff;
  --gray-1: #f5f5f5;
  --gray-2: #e0e0e0;
  --gray-3: #666666;
  --gray-4: #333333;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--black);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 32px;
  min-height: 100vh;
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 64px 32px;
  min-height: 100vh;
}

/* Typography */
h1 {
  font-size: 64px;
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--black);
  display: inline-block;
}

/* Profile Image */
.header-with-image {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 0;
}

.profile-image {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--black);
  object-fit: cover;
}

h2 {
  font-size: 32px;
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

h3 {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 400;
  margin-bottom: 12px;
}

p {
  margin-bottom: 24px;
  font-size: 16px;
  line-height: 1.6;
}

.lead {
  font-size: 18px;
  color: var(--gray-3);
  line-height: 1.7;
  margin-bottom: 64px;
}

.small {
  font-size: 14px;
  color: var(--gray-3);
}

/* Links */
a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.6;
}

/* Navigation */
nav {
  margin: 48px 0 96px;
  display: flex;
  gap: 0;
  flex-direction: column;
}

nav a {
  font-size: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--black);
  text-decoration: none;
  transition: padding-left 0.2s ease;
}

nav a:hover {
  padding-left: 16px;
  opacity: 1;
}

/* Navigation Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  font-size: 20px;
  padding: 16px 0;
  display: block;
  cursor: pointer;
  transition: padding-left 0.2s ease;
  border-bottom: 1px solid var(--black);
}

.nav-dropdown:hover .nav-dropdown-toggle {
  padding-left: 16px;
}

.nav-dropdown-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding-left: 24px;
}

.nav-dropdown:hover .nav-dropdown-content {
  max-height: 200px;
}

.nav-dropdown-content a {
  font-size: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-2);
  display: block;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.nav-dropdown-content a:last-child {
  border-bottom: 1px solid var(--black);
}

.nav-dropdown-content a:hover {
  opacity: 1;
  padding-left: 12px;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 32px;
  margin: 48px 0;
}

/* Problem Card */
.problem-card {
  border: 2px solid var(--black);
  padding: 40px;
  background: var(--white);
  transition: all 0.2s ease;
  position: relative;
}

.problem-card:hover {
  background: var(--gray-1);
  transform: translateY(-2px);
}

.problem-card h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-3);
  margin-bottom: 12px;
  font-weight: 400;
}

.problem-card h2 {
  font-size: 28px;
  margin-bottom: 0;
  font-weight: 400;
}

.problem-card h2 a {
  text-decoration: none;
}

.problem-meta {
  font-size: 13px;
  color: var(--gray-3);
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Problem sections in main content */
.olympiad-content {
  margin-top: 48px;
}

/* Olympiad page title - refined scale */
.container:has(.olympiad-content) > h1 {
  font-size: 42px;
  border-bottom-width: 2px;
  margin-bottom: 12px;
  padding-bottom: 12px;
}

.olympiad-content a {
  text-decoration: underline;
}

.olympiad-content > blockquote {
  border: 2px solid var(--black);
  padding: 40px 44px;
  margin: 36px 0;
  background: var(--white);
  position: relative;
  transition: all 0.2s ease;
  color: var(--black);
  font-size: 17px;
  line-height: 1.7;
}

.olympiad-content > blockquote:hover {
  background: var(--gray-1);
  transform: translateY(-2px);
}

/* Problem number styling */
.olympiad-content > blockquote > p:first-child {
  margin-bottom: 20px;
  font-size: 17px;
}

.olympiad-content > blockquote > p:first-child::before {
  content: "Problem ";
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray-3);
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

/* Center tag inside blockquotes */
.olympiad-content > blockquote center {
  margin: 24px 0;
  padding: 24px;
  border-left: 3px solid var(--black);
  background: var(--gray-1);
  text-align: left;
}

/* Section headers - prominent but refined */
.olympiad-content > h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 72px;
  margin-bottom: 28px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--black);
  font-weight: 600;
  color: var(--black);
}

/* Olympiad Landing Page */
.olympiad-landing {
  margin-top: 48px;
}

.olympiad-landing h3 {
  font-size: 24px;
  margin-top: 48px;
  margin-bottom: 12px;
}

.olympiad-landing h3 a {
  text-decoration: none;
  border-bottom: 2px solid var(--black);
  padding-bottom: 4px;
}

.olympiad-landing p {
  color: var(--gray-3);
  margin-bottom: 0;
}

/* Olympiad Materials Page */
.olympiad-materials {
  margin-top: 48px;
}

.olympiad-materials h3 {
  font-size: 17px;
  margin-top: 48px;
  margin-bottom: 16px;
}

.olympiad-materials embed {
  border: 2px solid var(--black);
  margin-top: 24px;
}

/* Individual Problem */
.problem-header {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--black);
}

.problem-content {
  margin-bottom: 48px;
}

/* Details/Solution */
details {
  margin: 32px 0;
  border: 1px solid var(--gray-2);
  padding: 24px;
  background: var(--white);
}

summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-3);
  transition: color 0.2s ease;
  position: relative;
  padding-left: 24px;
}

summary::before {
  content: "▸ ";
  position: absolute;
  left: 0;
  transition: transform 0.2s ease;
}

details[open] summary::before {
  transform: rotate(90deg);
}

summary:hover {
  color: var(--black);
}

summary::-webkit-details-marker {
  display: none;
}

details[open] summary {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gray-2);
  color: var(--black);
}

/* Footer */
footer {
  display: none;
}

/* Horizontal Rule */
hr {
  border: none;
  border-top: 2px solid var(--black);
  margin: 64px 0;
}

/* Back Link */
.back-link {
  display: inline-block;
  margin-bottom: 48px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-decoration: none;
  transition: padding-left 0.2s ease;
}

.back-link:hover {
  padding-left: 8px;
  opacity: 1;
}

/* Math Content */
.math {
  overflow-x: auto;
  margin: 24px 0;
  padding: 12px 0;
}

/* Lists */
ul, ol {
  margin: 24px 0;
  padding-left: 32px;
}

li {
  margin-bottom: 12px;
  line-height: 1.6;
}

/* Blockquote (non-problem) */
blockquote {
  border-left: 3px solid var(--black);
  padding-left: 24px;
  margin: 24px 0;
  color: var(--gray-3);
}

/* Mobile */
@media (max-width: 768px) {
  .container,
  .container-narrow {
    padding: 48px 24px;
  }

  h1 {
    font-size: 48px;
  }

  .profile-image {
    width: 60px;
    height: 60px;
  }

  .header-with-image {
    gap: 16px;
  }

  h2 {
    font-size: 28px;
  }

  h3 {
    font-size: 18px;
  }

  .lead {
    font-size: 16px;
  }

  nav {
    flex-direction: column;
    gap: 16px;
  }

  nav a {
    font-size: 18px;
    padding: 12px 0;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .problem-card {
    padding: 24px;
  }

  .olympiad-content > blockquote {
    padding: 28px 24px;
    font-size: 16px;
  }

  .container:has(.olympiad-content) > h1 {
    font-size: 32px;
  }

  .olympiad-content > h3 {
    font-size: 12px;
    margin-top: 56px;
  }

  details {
    padding: 20px;
  }

  footer {
    flex-direction: column;
    gap: 12px;
  }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --black: #ffffff;
    --white: #000000;
    --gray-1: #1a1a1a;
    --gray-2: #333333;
    --gray-3: #999999;
    --gray-4: #cccccc;
  }
}

/* Selection */
::selection {
  background: var(--black);
  color: var(--white);
}
