/* StellarTask — app.css
   Layout and components on top of /static/tokens.css.
   Colour comes ONLY from the tokens (--bg, --ink, --muted, --rule, --hover).
   No straight decorative lines here — every divider is a drawn SVG path
   placed directly in the templates. */

* {
  box-sizing: border-box;
}

.page {
  min-height: 100%;
}

.wrap {
  max-width: 1216px;
  margin: 0 auto;
  padding: 0 var(--page-pad-x, 64px);
}

.muted {
  color: var(--muted);
}

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding: 32px 0 22px;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.logo-star {
  /* The drawing has a white background of its own. */
  mix-blend-mode: multiply;
  display: block;
  width: 44px;
  height: 44px;
}

.logo-text {
  font-size: 30px;
  font-style: italic;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
}

.main-nav {
  display: flex;
  gap: 36px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  padding: 10px 0;
}

.nav-link:hover {
  color: var(--hover);
}

.nav-link.is-disabled {
  color: var(--faint);
  cursor: default;
  pointer-events: none;
}

.lang-switch {
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lang-link {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 10px 2px;
  cursor: pointer;
}

.lang-link:hover {
  color: var(--hover);
}

.lang-link[aria-pressed="true"] {
  color: var(--ink);
  text-decoration: underline wavy var(--wavy-underline);
  text-underline-offset: 6px;
}

/* Interface text exists in both languages; show the chosen one. */
html[lang="ru"] .en,
html[lang="en"] .ru {
  display: none;
}

.nav-link[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 6px;
}

.soon {
  font-size: 11px;
  color: var(--muted);
}

.lang-sep {
  color: var(--muted);
}

/* ---------- focus ---------- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--hover);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Visually hide text while keeping it available to screen readers. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- dividers ---------- */

.divider {
  display: block;
  width: 100%;
  height: 10px;
}

/* ---------- hero ---------- */

.hero {
  text-align: center;
  padding: 80px 0 40px;
}

.hero-title {
  margin: 0;
  font-size: 64px;
  font-weight: 400;
  color: var(--ink);
}

.hero-highlight {
  font-style: italic;
}

/* ---------- star map (static, non-interactive in Milestone 1) ---------- */

.map-outer {
  position: relative;
  width: 100%;
  max-width: 1088px;
  aspect-ratio: 1088 / 520;
  margin: 0 auto 64px;
}

.map-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.map-stars {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.map-star {
  position: absolute;
  transform: translate(-50%, -14px);
}

.map-star-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
}

button.map-star-link {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.map-star-link:hover {
  color: var(--hover);
}

.map-star.is-active .map-star-label {
  font-style: italic;
}

.map-aux { display: flex; justify-content: center; gap: 56px; margin: 0; padding: 24px 0 40px; list-style: none; }
.map-aux-link { font-size: 21px; font-weight: 500; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; }
.map-aux-link:hover { color: var(--hover); }
.map-aux-item.is-active .map-aux-link { font-style: italic; text-decoration: underline wavy var(--wavy-underline); text-underline-offset: 6px; }

.games-note {
  margin: 0;
  padding: 16px 0 56px;
}

.map-star-label {
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
  max-width: 160px;
  line-height: 1.15;
  background: var(--bg);
  padding: 1px 5px;
}

.map-star-link:hover .map-star-label {
  color: var(--hover);
}

.map-star-count {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--bg);
  padding: 0 4px;
}

/* Phones: the map becomes a vertical list of stars (no absolute layout, no connecting lines). */
@media (max-width: 720px) {
  .map-outer {
    max-width: 420px;
    aspect-ratio: auto;
  }

  .map-lines {
    display: none;
  }

  .map-stars {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 8px 0;
  }

  .map-star {
    position: static;
    left: auto !important;
    top: auto !important;
    transform: none;
  }

  .map-star-link {
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    text-align: left;
  }

  .map-star-label {
    white-space: normal;
  }
}

/* ---------- selected-star marker ---------- */

.map-star-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.map-star-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  display: none;
}

.map-star.is-active .map-star-ring {
  display: block;
}

.map-star-icon {
  display: block;
}

/* ---------- subtopic block (under the map) ---------- */

.topic-blocks {
  padding: 8px 0 32px;
}

/* With JS, show one area's subtopics at a time; without JS, show them all. */
.topic-blocks.has-js .topic-block {
  display: none;
}

.topic-blocks.has-js .topic-block.is-active {
  display: block;
}

.topic-block {
  padding: 8px 0 12px;
}

.topic-block + .topic-block {
  margin-top: 40px;
}

.topic-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.topic-block-title {
  margin: 0;
  font-size: 34px;
  font-weight: 400;
  color: var(--ink);
}

.all-problems-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.all-problems-link:hover {
  color: var(--hover);
}

.topic-block-desc {
  margin: 10px 0 20px;
  max-width: 640px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
}

.subtopic-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.subtopic-row {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr) 48px;
  align-items: baseline;
  column-gap: 24px;
  padding: 14px 0 12px;
  text-decoration: none;
  color: var(--ink);
}

.subtopic-row:hover {
  color: var(--hover);
}

.subtopic-row-name {
  font-size: 20px;
  font-weight: 500;
}

.subtopic-row-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.subtopic-row-count {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

@media (max-width: 720px) {
  .subtopic-row {
    grid-template-columns: 1fr auto;
    column-gap: 16px;
    row-gap: 4px;
  }

  .subtopic-row-desc {
    grid-column: 1 / -1;
  }
}

/* ---------- games ---------- */

.games-section {
  padding: 88px 0 96px;
}

.games-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 48px;
}

.games-heading {
  margin: 0;
  font-size: 52px;
  font-weight: 400;
  color: var(--ink);
}

.games-grid {
  display: flex;
  align-items: stretch;
  gap: 72px;
  flex-wrap: wrap;
}

.games-divider {
  flex: 0 0 auto;
  width: 2px;
  min-height: 220px;
  align-self: stretch;
}

.game-card {
  flex: 1 1 320px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-decoration: none;
  color: var(--ink);
}

.game-card:hover {
  color: var(--hover);
}

.game-cover {
  display: block;
  width: 100%;
  max-width: 440px;
  height: auto;
}

.game-name {
  font-size: 40px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
}

.game-blurb {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  max-width: 420px;
}

.play-link {
  font-size: 13px;
  color: var(--ink);
}

@media (max-width: 720px) {
  .games-grid {
    flex-direction: column;
    gap: 40px;
  }

  .games-divider {
    display: none;
  }
}

/* ---------- footer ---------- */

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 22px 0 40px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .wrap {
    padding: 0 24px;
  }

  .hero-title {
    font-size: 42px;
  }

  .games-heading {
    font-size: 36px;
  }

  .game-name {
    font-size: 30px;
  }
}

/* ---------- topic (area) page ---------- */

.topic-head {
  padding: 64px 0 36px;
}

.topic-title {
  margin: 0;
  font-size: 56px;
  font-weight: 400;
  color: var(--ink);
}

.topic-desc {
  margin: 14px 0 0;
  max-width: 640px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
}

.topic-count {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--faint);
}

/* ---------- search ---------- */

.search { text-align: left; }
.search[hidden] { display: none; }
.hero .search { max-width: 640px; margin: 40px auto 0; }
.problems .search { margin-bottom: 48px; }
.search input { display: block; width: 100%; font: 300 17px var(--font-sans); padding: 8px 0 4px; border: 0; background: transparent; color: var(--ink); }
.search-rule { display: block; width: 100%; height: 8px; }
.search-status { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.search-results { margin: 0; padding: 0; list-style: none; }
.search-results a { display: flex; flex-direction: column; gap: 4px; padding: 16px 0; text-decoration: none; }
.result-title { font-size: 23px; }
.result-place { font-size: 11.5px; color: var(--muted); }
.result-excerpt { font-size: 14px; line-height: 1.55; color: var(--muted); }
.result-excerpt mark { background: none; color: var(--ink); text-decoration: underline wavy var(--wavy-underline); text-underline-offset: 4px; }

/* ---------- problem list ---------- */

.problems-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  column-gap: 72px;
  padding: 56px 0 72px;
}

.rail { position: sticky; top: 24px; align-self: start; max-height: calc(100vh - 48px); overflow-y: auto; padding: 4px; }
.rail-back { display: inline-block; margin-bottom: 26px; font-size: 12px; color: var(--muted); text-decoration: none; }
.rail-topic { margin: 0 0 16px; font-size: 24px; }
.rail-list-wrap { position: relative; }
.rail-line { position: absolute; left: 4px; top: 10px; width: 6px; height: calc(100% - 20px); }
.rail-list { margin: 0; padding: 0; list-style: none; }
.rail-item { position: relative; display: flex; align-items: center; gap: 16px; min-height: 38px; font-size: 15px; text-decoration: none; }
.rail-item[aria-current="page"] .rail-name { font-weight: 500; }
.rail-dot { flex: none; }
.rail-name { flex: 1; }
.rail-count { font-size: 11px; color: var(--muted); }
.rail-topics { margin-top: 28px; font-size: 15px; }
.rail-topics summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.rail-topics ul { margin: 12px 0 0; padding: 0; list-style: none; }
.rail-topics li { padding: 5px 0; }
.rail-topics a { text-decoration: none; }

.problems { min-width: 0; }
.problems .topic-title { line-height: 1; }

.filter-form { margin-top: 24px; }
.filter-sentence { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 28px; margin: 0; }
.filter-name { font-family: var(--font-serif); font-style: italic; font-weight: 500; font-size: 22px; margin-right: 6px; }

select.pick {
  font-family: var(--font-sans);
  font-size: 16px;
  background: none;
  border: 0;
  padding: 0 2px;
  color: var(--ink);
  cursor: pointer;
  text-decoration: underline wavy var(--wavy-underline);
  text-decoration-thickness: 1.3px;
  text-underline-offset: 6px;
  appearance: none;
  -webkit-appearance: none;
}

select.pick:hover { color: var(--hover); }

.filter-clear {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 19px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.filter-clear:hover { color: var(--hover); }

.shown-count { margin: 28px 0 12px; font-size: 12px; color: var(--muted); }
.empty { font-size: 13px; color: var(--muted); }

.problem-item { display: grid; grid-template-columns: 88px minmax(0, 1fr); column-gap: 32px; }
.row-rule { grid-column: 1 / -1; display: block; width: 100%; height: 8px; }
.problem-item:first-child .row-rule { visibility: hidden; }
.problem-side { display: flex; flex-direction: column; gap: 14px; padding-top: 32px; }
.row-num { font-size: 56px; line-height: 0.8; font-weight: 400; font-variant-numeric: lining-nums; }
.stars { display: flex; gap: 3px; }
.problem-main { min-width: 0; padding-top: 28px; }
.problem-title { margin: 0; font-size: 28px; line-height: 1.2; scroll-margin-top: 40px; }
.problem-source { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }

.pager { display: flex; justify-content: center; align-items: baseline; gap: 32px; margin: var(--section-gap) 0; font-size: 13px; }
.pager[hidden] { display: none; }
.pager-numbers { display: flex; gap: 18px; }
.pager a { text-decoration: none; }
.pager a:hover { color: var(--hover); }
.pager a[aria-current="page"] { font-weight: 700; text-decoration: underline wavy var(--wavy-underline); text-underline-offset: 6px; }

/* ---------- theory notes ---------- */

.notes-groups {
  padding-bottom: 72px;
}

.notes-group {
  padding: 32px 0;
}

.notes-group-title {
  margin: 0 0 18px;
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
}

.notes-group-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.note-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 0;
  text-decoration: none;
  color: var(--ink);
}

.note-row:hover {
  color: var(--hover);
}

.note-row-title {
  font-size: 22px;
  font-weight: 500;
}

.note-row-summary {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 640px;
}

.note-title {
  font-size: 48px;
}

.note-body {
  font-size: 20px;
}

@media (max-width: 720px) {
  .topic-title {
    font-size: 40px;
  }

  .topic-body {
    grid-template-columns: 1fr;
    row-gap: 32px;
  }

  .subtopic-rail {
    position: static;
  }

  .problem-number {
    font-size: 54px;
  }
}
