/* =========================================================
   GraphMath site.css  (shared styles for all pages)
   ========================================================= */

/* ---- Theme tokens ---- */
:root {
  --bg: #f7f7f7;
  --card: #ffffff;
  --text: #1e1e1e;
  --muted: #555;
  --border: #e6e6e6;
  --accent: #1f6feb;
  --accent2: #0b4db3;
  --shadow: 0 6px 24px rgba(0,0,0,0.07);
  --radius: 16px;
  --maxw: 1080px;

  /* Document viewer tokens (used by PDF/PNG topic pages) */
  --doc-max: 980px;
  --doc-radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f12;
    --card: #151821;
    --text: #f2f3f5;
    --muted: #b0b6c2;
    --border: #262b36;
    --accent: #5aa2ff;
    --accent2: #88bbff;
    --shadow: 0 10px 30px rgba(0,0,0,0.35);
  }
}

/* ---- Base ---- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* =========================================================
   Layout container
   ========================================================= */

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 18px 60px;
}

/* =========================================================
   Top navigation
   ========================================================= */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0 22px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand span { font-size: 22px; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 14px;
  color: var(--muted);
}

.nav a {
  padding: 8px 10px;
  border-radius: 10px;
}

.nav a:hover {
  background: rgba(31,111,235,0.10);
  color: var(--text);
}

/* =========================================================
   Hero
   ========================================================= */

header.hero {
  background: linear-gradient(180deg, rgba(31,111,235,0.10), transparent 60%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
}

.hero h1 {
  margin: 0;
  font-size: 46px;
  letter-spacing: -0.8px;
}

.hero .subtitle {
  margin-top: 6px;
  font-size: 18px;
  color: var(--muted);
}

.hero .desc {
  margin-top: 14px;
  max-width: 72ch;
  font-size: 16px;
  color: var(--muted);
}

/* =========================================================
   Buttons
   ========================================================= */

.btnrow {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
  font-weight: 600;
  font-size: 14px;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn.primary:hover { background: var(--accent2); }
.btn:hover { border-color: rgba(31,111,235,0.35); }

/* =========================================================
   Sections + text helpers
   ========================================================= */

section { margin-top: 26px; }

.section-title {
  margin: 0 0 12px;
  font-size: 20px;
  letter-spacing: -0.2px;
}

.muted { color: var(--muted); }

/* =========================================================
   Cards, grids, tutorial links
   ========================================================= */

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 960px) {
  .grid3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: -0.2px;
}

.card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.card .small {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.card .links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

/* Why box */
.whybox {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

.whybox ul { margin: 10px 0 0; padding-left: 18px; }
.whybox li { margin: 6px 0; color: var(--muted); }

/* Tutorials grid */
.tgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 960px) {
  .tgrid { grid-template-columns: 1fr; }
}

.tlink {
  display: block;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

.tlink:hover { border-color: rgba(31,111,235,0.45); }
.tlink .tname { font-weight: 650; }
.tlink .tmeta { margin-top: 4px; font-size: 13px; color: var(--muted); }

/* =========================================================
   Footer
   ========================================================= */

footer {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

footer .fnav { display: flex; flex-wrap: wrap; gap: 12px; }
footer .fnav a:hover { color: var(--text); }

/* =========================================================
   Document viewer styles (PDF/PNG topic pages)
   Use these classes only on those topic pages:
   .docwrap, .doccard, .docbar, .docimg, .docfine
   ========================================================= */

.docwrap {
  max-width: var(--doc-max);
  margin: 18px auto;
  padding: 0 14px 26px;
}

.doccard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--doc-radius);
  overflow: hidden;
}

.docbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.docimg {
  padding: 10px;
  background: var(--card);
}

.docimg img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.docfine {
  color: var(--muted);
  font-size: 12px;
  margin: 10px 2px 0;
}

/* ------------------------------------------------------------
   Disabled links (used for "Under construction" items)
   ------------------------------------------------------------ */
a[aria-disabled="true"] {
  pointer-events: none;
  cursor: default;
  opacity: 0.55;
  text-decoration: none;
}

/* If your .tlink has hover styles, neutralize them when disabled */
a.tlink[aria-disabled="true"]:hover {
  transform: none;
  filter: none;
}

/* Apps page: icon layouts */
.apphead{
  display:flex;
  gap:12px;
  align-items:center;
  margin-bottom:10px;
}

.appicon{
  width:56px;
  height:56px;
  border-radius:14px;
  flex:0 0 auto;
}

.tlink-app{
  display:flex;
  gap:12px;
  align-items:center;
}

.ticon{
  width:44px;
  height:44px;
  border-radius:12px;
  flex:0 0 auto;
}

/* Button with app icon */
.btn.appbtn{
  display:inline-flex;
  align-items:center;
  gap:10px;
}

.btnicon{
  width:22px;
  height:22px;
  border-radius:6px;
  flex:0 0 auto;
}

/* iOS Safari safety: never render 1024px icons at intrinsic size */
img.appicon{
  width:56px;
  height:56px;
  max-width:56px;
  max-height:56px;
  object-fit:cover;
  display:block;
  border-radius:14px;
}

img.ticon{
  width:44px;
  height:44px;
  max-width:44px;
  max-height:44px;
  object-fit:cover;
  display:block;
  border-radius:12px;
}

img.btnicon{
  width:22px;
  height:22px;
  max-width:22px;
  max-height:22px;
  object-fit:cover;
  display:block;
  border-radius:6px;
}

.vec{
  position: relative;
  display: inline-block;
  padding-right: 0.10em;
}
.vec::after{
  content: "→";
  position: absolute;
  left: 0.18em;
  top: -0.55em;
  font-size: 0.85em;
  line-height: 1;
}