/* Brain Train Labs — shared article & portal styles
 *
 * Used by every non-game page: the home portal, the Brain Notes index,
 * every article, plus 404 and the privacy policy.
 * The games keep their own layout styles.
 */

:root {
  --page: #f7f8fc;
  --surface: #ffffff;
  --ink: #202943;
  --muted: #66718b;
  --line: #e3e7f1;
  --brand: #5865e8;
  --brand-soft: #eef0ff;
  --accent: #16865b;
  --green: #16865b;
  --gold: #d4a72c;
  --content-width: 760px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--brand);
  text-underline-offset: 3px;
}

a:hover {
  color: #3947c9;
}

/* ---------------------------------------------------------------- header */

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.header-inner {
  width: min(1120px, calc(100% - 40px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.35px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 21px;
}

.header-link {
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}

/* Groups two header links so they stay together on the right. */
.header-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

/* ----------------------------------------------------------------- shell */

.page-shell {
  width: min(var(--content-width), calc(100% - 40px));
  margin: 0 auto;
  padding: 52px 0 72px;
}

.breadcrumbs {
  margin-bottom: 25px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs span {
  margin: 0 8px;
}

.article-header {
  margin-bottom: 30px;
}

.category {
  display: inline-block;
  margin-bottom: 15px;
  padding: 5px 10px;
  border: 1px solid #dfe3ff;
  border-radius: 999px;
  background: var(--brand-soft);
  color: #4653d3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -0.7px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 50px);
  line-height: 1.12;
  letter-spacing: -1.8px;
}

.dek {
  margin: 20px 0 18px;
  color: #515d78;
  font-size: clamp(18px, 2.5vw, 21px);
  line-height: 1.65;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 17px;
  color: var(--muted);
  font-size: 13px;
}

/* -------------------------------------------------------------- hero art */

.hero-card {
  position: relative;
  overflow: hidden;
  min-height: 235px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px 0 38px;
  padding: 28px;
  border: 1px solid #e1e5f4;
  border-radius: 22px;
  background:
    radial-gradient(circle at 15% 20%, rgba(88, 101, 232, 0.12), transparent 34%),
    radial-gradient(circle at 85% 75%, rgba(22, 134, 91, 0.10), transparent 31%),
    #fff;
}

.grid-art {
  display: grid;
  grid-template-columns: repeat(6, 44px);
  gap: 7px;
  transform: rotate(-3deg);
}

.grid-art span {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #e0e5f3;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--brand);
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(40, 52, 100, 0.05);
}

.grid-art span:nth-child(3n) {
  background: #eef0ff;
}

.grid-art span:nth-child(4n) {
  color: var(--accent);
}

.grid-art span:nth-child(7),
.grid-art span:nth-child(16),
.grid-art span:nth-child(29) {
  background: #e5f6ed;
  color: var(--accent);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  gap: 8px;
  transform: rotate(-2deg);
}

.tile {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid #dfe4ee;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
  box-shadow: 0 5px 14px rgba(40, 52, 100, 0.04);
}

.tile.green {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.tile.gold {
  border-color: var(--gold);
  background: var(--gold);
  color: #fff;
}

.tile.gray {
  border-color: #8b95a8;
  background: #8b95a8;
  color: #fff;
}

/* ----------------------------------------------------------- article body */

.article-body {
  padding: clamp(24px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 14px 45px rgba(35, 47, 90, 0.035);
}

.article-body p {
  margin: 0 0 22px;
}

.article-body h2 {
  margin: 42px 0 16px;
  font-size: clamp(24px, 4vw, 30px);
}

.article-body h2:first-child {
  margin-top: 0;
}

.article-body h3 {
  margin: 28px 0 10px;
  font-size: 20px;
}

.article-body ul,
.article-body ol {
  margin: 0 0 24px;
  padding-left: 25px;
}

.article-body li {
  margin: 8px 0;
}

.callout {
  margin: 30px 0;
  padding: 22px 24px;
  border-left: 4px solid var(--brand);
  border-radius: 0 13px 13px 0;
  background: #f3f4ff;
  color: #384363;
}

.callout p {
  margin: 0;
}

.small-note {
  color: var(--muted);
  font-size: 14px;
}

/* -------------------------------------------------------- practice card */

.practice-card {
  margin-top: 38px;
  padding: 26px;
  border: 1px solid #dfe3ff;
  border-radius: 18px;
  background: linear-gradient(135deg, #f2f3ff, #ffffff);
}

.practice-card h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.practice-card p {
  margin: 0 0 18px;
  color: #59647e;
}

.cta {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.cta:hover {
  background: #4653d3;
  color: #fff;
}

/* -------------------------------------------------------------- related */

.related {
  margin-top: 35px;
  padding-top: 25px;
  border-top: 1px solid var(--line);
}

.related h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.related a {
  display: inline-block;
  margin: 0 14px 8px 0;
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}

/* --------------------------------------------------------- home section */

.home-section {
  margin-top: 46px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.home-section h2 {
  margin: 0 0 10px;
  font-size: clamp(22px, 4vw, 28px);
}

.home-section > p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.all-articles {
  display: inline-block;
  margin-top: 18px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

/* ------------------------------------------------------------ post list */

.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.post-card {
  display: block;
  padding: 24px 26px;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 14px 45px rgba(35, 47, 90, 0.035);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
}

.post-card h2 {
  margin: 0 0 10px;
  font-size: clamp(20px, 3vw, 25px);
  letter-spacing: -0.6px;
}

.post-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

/* ---------------------------------------------------------- home portal */

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 14px 45px rgba(35, 47, 90, 0.035);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
}

.game-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.game-avatar {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  font-size: 22px;
  font-weight: 850;
}

.avatar-2048 {
  background: linear-gradient(135deg, #827bff, #6257ef);
  box-shadow: 0 6px 15px rgba(108, 99, 255, 0.25);
}

.avatar-flow {
  background: linear-gradient(135deg, #ff6b6b, #cc5de8);
  box-shadow: 0 6px 15px rgba(204, 93, 232, 0.25);
}

.avatar-wordle {
  background: linear-gradient(135deg, #ffbd4a, #ff914d);
  box-shadow: 0 6px 15px rgba(255, 145, 77, 0.25);
}

.avatar-mines {
  background: linear-gradient(135deg, #39c5db, #252b42);
  box-shadow: 0 6px 15px rgba(37, 43, 66, 0.25);
}

.game-info {
  min-width: 0;
}

.game-info .tag {
  display: block;
  margin-bottom: 3px;
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.game-info h2 {
  margin: 0;
  font-size: 18.5px;
  font-weight: 850;
  letter-spacing: -0.6px;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

/* Personal record row injected into each game card by share-kit.js */
.game-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
  min-height: 26px;
}

.game-stats span {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f5fc;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.game-stats span.is-empty {
  color: var(--muted);
  font-weight: 700;
  background: #fafbff;
}

.game-stats span.is-best {
  border-color: #dfe3ff;
  background: var(--brand-soft);
  color: #4653d3;
}

/* -------------------------------------------------------------- footer */

.site-footer {
  padding: 28px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.site-footer p {
  margin: 0 0 6px;
}

.site-footer p:last-child {
  margin-bottom: 0;
}

.site-footer a {
  font-weight: 750;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------- responsive */

@media (max-width: 700px) {
  .game-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .header-inner {
    width: calc(100% - 28px);
    min-height: 66px;
  }

  .brand {
    font-size: 14px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .header-link {
    font-size: 12px;
  }

  .page-shell {
    width: calc(100% - 24px);
    padding: 30px 0 48px;
  }

  .breadcrumbs {
    margin-bottom: 20px;
  }

  .hero-card {
    min-height: 195px;
    margin: 24px 0;
    padding: 16px;
  }

  .grid-art {
    grid-template-columns: repeat(6, 34px);
    gap: 5px;
  }

  .grid-art span {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    font-size: 13px;
  }

  .word-grid {
    grid-template-columns: repeat(5, 39px);
    gap: 6px;
  }

  .tile {
    width: 39px;
    height: 39px;
    border-radius: 7px;
    font-size: 16px;
  }

  .article-body {
    padding: 22px 19px;
    border-radius: 17px;
  }

  .article-body h2 {
    margin-top: 34px;
  }

  .practice-card {
    padding: 21px;
  }

  .post-card {
    padding: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .post-card,
  .game-card {
    transition: none;
  }
}

/* ================================================================ *
 * Micro tools (shared by /tools pages)
 * ================================================================ */

.tool-panel {
  margin-top: 24px;
  padding: 28px 26px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 14px 45px rgba(35, 47, 90, 0.035);
}

.tool-panel > h2 {
  margin: 0 0 6px;
  font-size: clamp(20px, 3.6vw, 24px);
  font-weight: 850;
  letter-spacing: -0.5px;
}

.tool-panel > .hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

/* ------------------------------------------------------- controls */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

input[type="text"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

input:focus-visible,
select:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--brand-soft);
  outline-offset: 2px;
  border-color: var(--brand);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 11px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: #4653d3;
  border-color: #4653d3;
  color: #fff;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --------------------------------------------------------- output */

.output {
  margin-top: 20px;
  padding: 18px 20px;
  min-height: 56px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fbfcff;
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.72;
}

.output .placeholder {
  color: var(--muted);
}

.output.error {
  border-style: solid;
  border-color: #f0c9c9;
  background: #fdf5f5;
  color: #a33535;
  font-weight: 700;
}

/* ---------------------------------------------------------- timer */

.timer-face {
  position: relative;
  width: 250px;
  height: 250px;
  margin: 4px auto 0;
  border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--progress) * 1%), #eef0ff 0);
  display: grid;
  place-items: center;
}

.timer-face::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 2px 12px rgba(35, 47, 90, 0.06);
}

.timer-face.resting {
  background: conic-gradient(var(--accent) calc(var(--progress) * 1%), #e6f6ee 0);
}

.timer-inner {
  position: relative;
  text-align: center;
}

.timer-time {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -2.4px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.timer-phase {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.timer-count {
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

/* --------------------------------------------------------- matrix */

.matrix-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: flex-start;
}

.matrix-block {
  flex: 1 1 200px;
  min-width: 0;
}

.matrix-block > .field > label {
  margin-bottom: 2px;
}

.matrix {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.matrix.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.matrix.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.matrix input {
  width: 100%;
  min-width: 0;
  padding: 10px 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.result-matrix {
  display: inline-grid;
  gap: 6px;
  margin-top: 4px;
}

.result-matrix span {
  display: grid;
  place-items: center;
  min-width: 62px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- chips */

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  padding: 7px 14px;
  border: 1px solid #dfe3ff;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.chip-perfect {
  border-color: #bfe6d2;
  background: #e8f7ef;
  color: var(--accent);
}

@media (max-width: 560px) {
  .tool-panel {
    padding: 22px 17px 26px;
  }

  .timer-face {
    width: 210px;
    height: 210px;
  }

  .timer-time {
    font-size: 40px;
  }

  .btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}