/* Millennium Problems for Palestine. Colours of the Palestinian flag. */
:root {
  --black: #0d0d0d;
  --white: #ffffff;
  --green: #007a3d;
  --green-dark: #00592c;
  --red: #ce1126;
  --paper: #f7f5f0;
  --ink: #161616;
  --muted: #5c5a55;
  --line: #dedad1;
  --tri: clamp(72px, 22vw, 320px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--sans);
}
a { color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--red); }
code, pre { font-family: var(--mono); font-size: 0.88em; }
code { background: #ebe7dd; padding: 0.1em 0.35em; border-radius: 3px; }
pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
img, svg { max-width: 100%; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.kicker {
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem;
  font-weight: 700; color: var(--red); margin: 0 0 0.5rem;
}

/* Top flag ribbon and navigation */
.ribbon { position: relative; height: 12px; background: linear-gradient(var(--black) 0 33.4%, var(--white) 0 66.7%, var(--green) 0); }
.ribbon::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 22px; background: var(--red); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.site-head { background: var(--black); color: var(--white); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { color: var(--white); text-decoration: none; font-weight: 700; letter-spacing: 0.01em; display: flex; align-items: center; gap: 10px; }
.brand:hover { color: var(--white); }
.brand svg { width: 30px; height: 20px; flex: none; }
.nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.95rem; }
.nav a { color: #e8e8e8; text-decoration: none; }
.nav a:hover, .nav a[aria-current] { color: var(--white); text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; }

/* Hero: the flag, with the text across its bands */
.flag-hero { position: relative; overflow: hidden; }
.flag-hero .tri { position: absolute; inset: 0 auto 0 0; width: var(--tri); background: var(--red); clip-path: polygon(0 0, 100% 50%, 0 100%); z-index: 1; }
.band { position: relative; }
/* Keep text clear of the triangle: it starts at the viewport edge, the wrap is centred. */
.band .wrap { padding-left: max(16px, calc(var(--tri) + 28px - max(0px, (100vw - 1080px) / 2))); }
.band-black { background: var(--black); color: var(--white); padding: 56px 0 28px; }
.band-white { background: var(--white); padding: 26px 0; }
.band-green { background: var(--green); color: var(--white); padding: 26px 0 40px; }
.flag-hero h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(2rem, 5.4vw, 4.4rem); line-height: 1.05; margin: 0; letter-spacing: -0.01em; max-width: 20ch; }
.flag-hero .kicker { color: #f3b0b8; }
.flag-hero .lead { font-size: clamp(1.05rem, 2.1vw, 1.35rem); margin: 0; max-width: 40ch; }
.btn { display: inline-block; background: var(--white); color: var(--green-dark); font-weight: 700; padding: 11px 18px; border-radius: 4px; text-decoration: none; margin: 4px 10px 4px 0; border: 2px solid var(--white); }
.btn:hover { background: var(--black); border-color: var(--black); color: var(--white); }
.btn-ghost { background: transparent; color: var(--white); }

/* Tatreez (cross-stitch) divider */
.tatreez { height: 24px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cg fill='%23ce1126'%3E%3Crect x='10' y='2' width='4' height='4'/%3E%3Crect x='6' y='6' width='4' height='4'/%3E%3Crect x='14' y='6' width='4' height='4'/%3E%3Crect x='2' y='10' width='4' height='4'/%3E%3Crect x='10' y='10' width='4' height='4'/%3E%3Crect x='18' y='10' width='4' height='4'/%3E%3Crect x='6' y='14' width='4' height='4'/%3E%3Crect x='14' y='14' width='4' height='4'/%3E%3Crect x='10' y='18' width='4' height='4'/%3E%3C/g%3E%3C/svg%3E") repeat-x center; margin: 8px 0; }

/* Hero extras */
.flag-hero h1 { font-size: clamp(2.2rem, 6vw, 4.8rem); }
.band-black { padding: 72px 0 36px; }
.band-green { padding: 28px 0 44px; }
.hero-note { margin: 14px 0 0; font-size: 0.92rem; color: #d7efe1; }

/* Manifesto */
.manifesto { padding: 72px 0 56px; }
.manifesto-grid { display: grid; grid-template-columns: 180px 1fr; gap: 48px; align-items: start; }
.motif svg { width: 100%; height: auto; display: block; }
.manifesto .big { font-family: var(--serif); font-size: clamp(1.45rem, 2.9vw, 2.1rem); line-height: 1.3; margin: 0 0 22px; max-width: 30ch; }
.manifesto p { max-width: 62ch; font-size: 1.08rem; }
.manifesto .sign { font-family: var(--serif); font-style: italic; color: var(--green-dark); font-size: 1.15rem; margin-top: 22px; }

/* Three steps */
.steps-section { padding-top: 24px; }
.steps { list-style: none; padding: 0; margin: 26px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; counter-reset: none; }
.step { background: var(--white); border: 1px solid var(--line); padding: 26px 22px 22px; position: relative; }
.step .num { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--white); background: var(--black); font-family: var(--serif); font-size: 1.35rem; font-weight: 700; margin-bottom: 14px; }
.step:nth-child(2) .num { background: var(--green); }
.step:nth-child(3) .num { background: var(--red); }
.step h3 { font-family: var(--serif); font-size: 1.3rem; margin: 0 0 8px; }
.step p { margin: 0; color: #3b3a36; }
.more { margin-top: 18px; }

/* Pledge band */
.pledge-band { background: var(--black); color: var(--white); padding: 18px 0; margin: 24px 0; }
.pledge-band .wrap { padding-top: 40px; padding-bottom: 40px; }
.pledge-band blockquote { font-family: var(--serif); font-size: clamp(1.45rem, 3.1vw, 2.3rem); line-height: 1.3; margin: 0 0 30px; max-width: 36ch; }
.pledge-band .zero { display: flex; align-items: center; gap: 18px; margin: 0 0 24px; }
.pledge-band .zero b { font-family: var(--serif); font-size: clamp(3rem, 7vw, 4.6rem); line-height: 1; color: var(--red); }
.pledge-band .zero span { color: #e3e3e3; font-size: 1.05rem; line-height: 1.4; }
.pledge-band .fine { color: #bdbdbd; font-size: 0.92rem; max-width: 70ch; margin: 0; }
.pledge-band a { color: #8fd9b0; }

.stats-inline { display: flex; flex-wrap: wrap; gap: 8px 26px; color: var(--muted); margin: 6px 0 0; }
.stats-inline b { color: var(--ink); font-family: var(--serif); font-size: 1.25rem; }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 40px 0 8px; }
.stat { background: var(--white); padding: 18px 16px; }
.stat b { display: block; font-family: var(--serif); font-size: 2rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.9rem; }
.stat.zero b { color: var(--red); }

/* Sections */
.section { padding: 40px 0; }
.section h2, .prose h2 { font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.2; margin: 0 0 12px; }
.section > .wrap > p { max-width: 64ch; }

/* Problem cards */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 22px; }
.card { background: var(--white); border: 1px solid var(--line); border-top: 6px solid var(--black); padding: 20px; display: flex; flex-direction: column; gap: 8px; color: inherit; text-decoration: none; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.card:nth-child(3n+2) { border-top-color: var(--green); }
.card:nth-child(3n) { border-top-color: var(--red); }
.grid .card:first-child { grid-column: span 2; }
.card:hover { color: inherit; transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.card h3 { font-family: var(--serif); font-size: 1.3rem; line-height: 1.2; margin: 0; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.card .meta { margin-top: auto; padding-top: 8px; font-size: 0.85rem; color: var(--muted); }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 3px; vertical-align: middle; }
.badge-lean { background: var(--green); color: var(--white); }
.badge-paper { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.badge-proved { background: var(--green); color: var(--white); }
.badge-open { background: #ebe7dd; color: var(--ink); }
.badge-closed { background: #ccc; color: var(--ink); }

/* Join box */
.join { background: var(--green); color: var(--white); padding: 32px; border-left: 8px solid var(--red); }
.join .kicker { color: #ffd0d6; }
.join h2 { color: var(--white); }
.copy { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; margin: 14px 0 6px; }
.copy code { flex: 1 1 320px; background: #1f1f1f; color: #f2f2f2; padding: 12px 14px; border-radius: 4px; font-size: 0.92rem; overflow-wrap: anywhere; }
.copy button { font: inherit; font-weight: 700; background: var(--black); color: var(--white); border: 0; border-radius: 4px; padding: 0 18px; cursor: pointer; min-height: 44px; }
.copy button:hover { background: var(--red); }
.join .small { color: #d7efe1; font-size: 0.9rem; margin: 6px 0 0; }
.join a { color: var(--white); }

.pledge { border: 2px solid var(--green); background: var(--white); padding: 24px; }
.pledge p { max-width: 70ch; }

/* Inner pages */
.page { padding: 44px 16px 56px; }
.prose { max-width: 760px; }
.prose h1 { font-family: var(--serif); font-size: clamp(2rem, 4.6vw, 3rem); line-height: 1.1; margin: 0 0 16px; }
.prose .lead { font-size: 1.2rem; color: #33322f; }
.prose h2 { margin-top: 36px; }
.prose li { margin: 6px 0; }
.prose details { background: var(--white); border: 1px solid var(--line); padding: 12px 16px; margin: 10px 0; }
.prose summary { cursor: pointer; font-weight: 700; }
table.plain { border-collapse: collapse; width: 100%; background: var(--white); }
table.plain th, table.plain td { text-align: left; padding: 8px 12px; border: 1px solid var(--line); vertical-align: top; }
.notice { background: #fff4f5; border-left: 5px solid var(--red); padding: 12px 16px; }

/* Inner page header */
.page-head { background: var(--black); color: var(--white); padding: 52px 0 40px; border-bottom: 6px solid var(--green); position: relative; }
.page-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -18px; height: 12px; background: var(--red); clip-path: polygon(0 0, 120px 0, 0 100%); }
.page-head h1 { font-family: var(--serif); font-size: clamp(2rem, 4.8vw, 3.3rem); line-height: 1.1; margin: 0 0 14px; max-width: 22ch; }
.page-head .lead { font-size: clamp(1.05rem, 2vw, 1.25rem); color: #e6e6e6; max-width: 62ch; margin: 0; }
.page-head + .page { padding-top: 36px; }
.pledge-quote { font-family: var(--serif); font-size: clamp(1.35rem, 3vw, 1.9rem); line-height: 1.3; margin: 18px 0; padding: 18px 22px; background: var(--white); border-left: 6px solid var(--red); }

/* Problem page */
.problem-head { background: var(--black); color: var(--white); padding: 40px 0 34px; border-bottom: 6px solid var(--green); }
.problem-head h1 { font-family: var(--serif); font-size: clamp(2rem, 4.6vw, 3.1rem); line-height: 1.1; margin: 8px 0 12px; }
.problem-head p { max-width: 66ch; color: #e6e6e6; margin: 0; }
.problem-head a { color: #8fd9b0; }
.gap { background: var(--white); border: 1px solid var(--line); margin: 12px 0; }
.gap summary { cursor: pointer; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; list-style: none; }
.gap summary::-webkit-details-marker { display: none; }
.gap summary .id { font-family: var(--mono); font-weight: 700; color: var(--green-dark); }
.gap summary .t { font-weight: 600; flex: 1 1 260px; }
.gap .body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.gap pre { background: #161616; color: #f1f1f1; padding: 14px; border-radius: 4px; overflow-x: auto; white-space: pre; }
.gap h4 { margin: 14px 0 4px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }

/* Footer */
.site-foot { background: var(--black); color: #cfcfcf; margin-top: 40px; font-size: 0.9rem; }
.site-foot .wrap { padding-top: 26px; padding-bottom: 30px; display: grid; gap: 10px; }
.site-foot a { color: var(--white); }
.site-foot strong { color: var(--white); }

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr; }
  .manifesto-grid { grid-template-columns: 110px 1fr; gap: 28px; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .grid { grid-template-columns: 1fr; }
  .grid .card:first-child { grid-column: auto; }
  .manifesto { padding: 48px 0 36px; }
  .manifesto-grid { grid-template-columns: 1fr; gap: 18px; }
  .motif { width: 84px; }
  .band-black { padding-top: 40px; }
  .nav { gap: 12px; font-size: 0.9rem; }
  .join, .pledge { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } }

/* ---- Mathematics ---- */
.math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", "Iowan Old Style", Georgia, serif; }
.formula {
  font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", "Iowan Old Style", Georgia, serif;
  background: var(--black); color: var(--white); text-align: center;
  padding: 26px 16px; font-size: 1.3rem; line-height: 1.55; min-height: 112px;
  display: flex; align-items: center; justify-content: center;
  background-image: radial-gradient(rgba(255,255,255,0.07) 1px, transparent 1px);
  background-size: 14px 14px;
}
.formula i { font-style: italic; }
.formula sub, .formula sup { font-size: 0.68em; }
.formula .rel { color: var(--red); padding: 0 0.15em; }
.card { padding: 0; gap: 0; }
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.grid .card:first-child .formula { font-size: clamp(2.6rem, 6vw, 3.6rem); letter-spacing: 0.04em; }
.badge-main { background: var(--red); color: var(--white); }

/* Hero motif */
.hero-motif { position: absolute; right: max(24px, calc((100vw - 1080px) / 2 + 16px)); top: 58px; width: 150px; z-index: 1; opacity: 0.95; }
.hero-motif svg { width: 100%; height: auto; display: block; }

/* Lean sample */
.sample { display: grid; grid-template-columns: 1fr 1.15fr; gap: 36px; align-items: center; margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--line); }
.sample h3 { font-family: var(--serif); font-size: clamp(1.4rem, 2.6vw, 1.8rem); line-height: 1.2; margin: 0 0 12px; }
.code-window { background: #141414; border-radius: 8px; overflow: hidden; box-shadow: 0 14px 40px rgba(0,0,0,0.18); }
.code-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: #222; }
.code-bar span { width: 11px; height: 11px; border-radius: 50%; background: var(--red); }
.code-bar span:nth-child(2) { background: var(--white); }
.code-bar span:nth-child(3) { background: var(--green); }
.code-bar em { margin-left: 10px; color: #9a9a9a; font-style: normal; font-family: var(--mono); font-size: 0.82rem; }
.code-window pre { margin: 0; padding: 18px 18px 8px; color: #eaeaea; overflow-x: auto; font-size: 0.86rem; line-height: 1.6; }
.code-window .c { color: #8a8a8a; }
.code-window .k { color: #ff7b8a; font-weight: 600; }
.code-window .o { color: #6fd3a0; }
.code-verdict { padding: 10px 18px 14px; color: #6fd3a0; font-family: var(--mono); font-size: 0.82rem; }

/* Problem page header */
.problem-head-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center; }
.formula-head { border: 1px solid #333; font-size: clamp(1.3rem, 2.6vw, 1.9rem); min-height: 160px; }

@media (max-width: 1279px) { .hero-motif { display: none; } }
@media (max-width: 860px) {
  .sample { grid-template-columns: 1fr; }
  .problem-head-grid { grid-template-columns: 1fr; }
}

/* Formula fitting and small fixes */
.formula span { white-space: nowrap; }
.card .formula { font-size: clamp(1rem, 1.6vw, 1.2rem); }
.problem-head .badge-paper { color: var(--white); border-color: var(--white); }
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
