/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: #333;
  background: #fff;
}

/* === Typography === */
h1, h2, h3 { font-weight: 600; line-height: 1.3; color: #1a1a2e; }
h1 { font-size: 1.75rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.4rem; margin-top: 1.2rem; }
p { margin-bottom: 1rem; }
a { color: #2a6496; text-decoration: none; }
a:hover { color: #1a4066; text-decoration: underline; }
ul, ol { margin-left: 1.75rem; margin-bottom: 1rem; }
li { margin-bottom: 0.3rem; }
hr { border: none; border-top: 2px solid #e0e0e0; margin: 1.5rem 0; }
strong { font-weight: 600; }

/* === Layout === */
.site-wrapper { max-width: 920px; margin: 0 auto; padding: 0 1.5rem; }

/* === Header === */
.site-header { background: #1a1a2e; color: #fff; }

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-branding { flex-shrink: 0; }

.site-title a {
  color: #fff;
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.site-title a:hover { color: #c8d8f0; text-decoration: none; }

.site-subtitle {
  font-size: 0.78rem;
  color: #8898bb;
  margin-top: 0.1rem;
  letter-spacing: 0.01em;
}

/* === Navigation === */
.site-nav { position: relative; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font-size: 1.1rem;
  border-radius: 3px;
  line-height: 1;
}

.nav-list {
  list-style: none;
  display: flex;
  gap: 0;
}

.nav-list li { position: relative; }

.nav-list a {
  display: block;
  color: #c8d0e8;
  text-decoration: none;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-list a:hover,
.nav-list a[aria-current="page"] {
  color: #fff;
  background: rgba(255,255,255,0.13);
  text-decoration: none;
}
.nav-list a[aria-current="page"] { font-weight: 600; }

/* Dropdown menus */
.nav-list li ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #222244;
  min-width: 190px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  z-index: 200;
  list-style: none;
  flex-direction: column;
}

.nav-list li:hover > ul { display: flex; }

/* Nested dropdown (Math sub-menu) */
.nav-list li ul li { position: relative; }
.nav-list li ul li ul {
  top: 0;
  left: 100%;
  min-width: 175px;
}
.nav-list li ul li:hover > ul { display: flex; }

.nav-list li ul a {
  padding: 0.5rem 1rem;
  font-size: 0.84rem;
}

/* === Page Title Bar === */
.page-title-bar {
  background: #f2f4f8;
  border-bottom: 1px solid #d8dde8;
  padding: 0.75rem 0;
}
.page-title-bar h1 {
  font-size: 1.35rem;
  color: #1a1a2e;
  margin: 0;
}

/* === Main Content === */
main { padding: 2rem 0 2.5rem; }

/* === Images === */
img { max-width: 100%; height: auto; display: block; }

.img-center { text-align: center; margin: 1rem 0; }
.img-center img { margin: 0 auto; }

.app-icon { max-width: 140px; margin: 0 auto 0.5rem; }
.store-badge { max-width: 180px; margin: 0.75rem auto 1rem; }

/* === Screenshot Grids === */
.screenshots-2,
.screenshots-3,
.screenshots-4 {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
  align-items: start;
}
.screenshots-2 { grid-template-columns: repeat(2, 1fr); }
.screenshots-3 { grid-template-columns: repeat(3, 1fr); }
.screenshots-4 { grid-template-columns: repeat(4, 1fr); }

/* === Apps Index Grid === */
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin: 1.5rem 0;
  text-align: center;
}
.app-grid a { text-decoration: none; color: inherit; }
.app-grid a:hover .app-grid-label { color: #2a6496; }
.app-grid img { margin: 0 auto 0.6rem; }
.app-grid-label { font-size: 0.85rem; font-weight: 600; color: #333; line-height: 1.3; }

/* === Privacy / Info Notes === */
.note-privacy {
  color: #1a44bb;
  font-weight: 600;
  text-align: center;
  margin-top: 1rem;
  font-size: 0.95rem;
}

/* === PDF / CTA Button === */
.btn {
  display: inline-block;
  background: #2a6496;
  color: #fff;
  padding: 0.6rem 1.5rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1rem 0;
  transition: background 0.15s;
}
.btn:hover { background: #1a4470; color: #fff; text-decoration: none; }

/* === Math pages === */
.math-figure { text-align: center; margin: 1rem 0; }
.math-figure img { margin: 0 auto; }
.math-figure figcaption { font-size: 0.9rem; color: #555; margin-top: 0.4rem; }

/* === Footer === */
.site-footer {
  background: #f2f4f8;
  border-top: 1px solid #d8dde8;
  padding: 1.1rem 0;
  margin-top: 1.5rem;
}
.footer-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
  font-size: 0.88rem;
  color: #666;
}
.footer-inner a { color: #2a6496; }
.footer-inner a:hover { color: #1a4066; }

/* === Responsive === */
@media (max-width: 720px) {
  .nav-toggle { display: block; }

  .nav-list {
    display: none;
    flex-direction: column;
    width: 100%;
    background: #222244;
  }
  .nav-list.open { display: flex; }

  /* On mobile, sub-menus are toggled with a class */
  .nav-list li ul {
    position: static;
    display: none;
    box-shadow: none;
    background: #2c2c58;
    min-width: auto;
    width: 100%;
  }
  .nav-list li.sub-open > ul { display: flex; }
  .nav-list li ul li ul { left: 0; background: #363670; }

  .app-grid { grid-template-columns: repeat(2, 1fr); }
  .screenshots-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .screenshots-3 { grid-template-columns: repeat(2, 1fr); }
  .screenshots-2 { grid-template-columns: 1fr; }
}
