/* Pocket BASIC site — clean responsive stylesheet
   Rebuilt for Safari/iOS/macOS compatibility and readability. */

:root {
  --page-bg: #f4efe4;
  --panel-bg: #fff8ed;
  --panel-border: #dccfb9;
  --text: #1f1f1f;
  --muted: #666666;
  --primary: #2f3b45;
  --accent: #0f7a55;
  --chip: #e8dcc8;
  --code-bg: #101417;
  --code-fg: #e9f0e9;
  --callout-bg: #fff2c2;
  --callout-border: #c89622;
  --shadow: 0 2px 10px rgba(0,0,0,.07);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.58;
}

a {
  color: #0a5f8f;
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

button,
.btn,
.toc a {
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

/* Panels */

.topbar,
.hero,
.card,
.example,
.sidecard {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}

.hero h2,
.card h3,
.example h3,
.sidecard h3 {
  margin-top: 0;
}

/* Header / navigation */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  flex: 0 1 auto;
}

.logo {
  flex: 0 0 auto;
  background: #222;
  color: #fff;
  border-radius: 10px;
  padding: 12px;
  font-weight: 800;
  letter-spacing: .03em;
}

.brand h1 {
  margin: 0;
  line-height: 1.1;
  font-size: 1.55rem;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .92rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 360px;
  margin: 0;
}

.right {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.lang {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  border: 0;
  font-weight: 600;
}

.btn:hover,
.btn:focus {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn.active {
  background: var(--accent);
}

.lang button {
  min-height: 36px;
  border: 1px solid var(--panel-border);
  background: #f7ead5;
  color: var(--primary);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}

.lang button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* SPA visibility */

.hidden {
  display: none !important;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

/* Main layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.main,
.side {
  min-width: 0;
}

/* TOC / anchors */

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  position: sticky;
  top: 118px;
  z-index: 10;
  background: rgba(244, 239, 228, .96);
  padding: 8px 0;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.toc a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 10px;
  cursor: pointer;
}

:target {
  scroll-margin-top: 160px;
}

/* Content blocks */

.grid2,
.exampleGrid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
}

.pillrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.callout {
  background: var(--callout-bg);
  border-left: 4px solid var(--callout-border);
  padding: 10px 12px;
  border-radius: 8px;
}

.exampleHead {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex: 0 0 auto;
}

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

.note {
  font-size: 12px;
  color: var(--muted);
}

.bookRow {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.bookCover {
  max-width: 96px;
  border-radius: 8px;
}

/* Code and tables */

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.code pre,
pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 14px;
  border-radius: 12px;
  overflow-x: auto;
  line-height: 1.42;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

.tableWrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  background: #fff;
}

td,
th {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #fbf5ea;
}

.qr img {
  max-width: 118px;
  height: auto;
  margin: 4px;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.footer {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
}

/* Mobile */

@media (max-width: 900px) {
  .wrap {
    padding: 10px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    padding: 12px;
    justify-content: center;
  }

  .brand {
    flex: 1 1 100%;
    justify-content: center;
    text-align: center;
  }

  .brand h1 {
    font-size: 1.45rem;
  }

  .brand p {
    font-size: .88rem;
  }

  .nav {
    flex: 1 1 100%;
    justify-content: center;
  }

  .right {
    width: 100%;
    justify-content: center;
    margin-left: 0;
    margin-top: 2px;
  }

  .btn,
  .pill,
  .toc a,
  .lang button {
    min-height: 44px;
  }

  .hero h2 {
    font-size: 1.65rem;
  }

  .grid2,
  .exampleGrid {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
    justify-content: center;
    padding: 4px 0;
  }

  :target {
    scroll-margin-top: 20px;
  }

  .code pre,
  pre {
    font-size: .82rem;
    white-space: pre-wrap;
    word-break: normal;
    overflow-wrap: anywhere;
  }

  table {
    min-width: 480px;
  }

  .qr {
    text-align: center;
  }

  .qr img {
    max-width: 46%;
  }

  .bookRow {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .bookCover {
    max-width: 120px;
  }

  th,
  td {
    padding: .45rem;
    font-size: .82rem;
  }
}

@media (max-width: 420px) {
  body {
    font-size: 15px;
  }

  .btn {
    padding: 7px 10px;
    font-size: .85rem;
  }

  .topbar,
  .hero,
  .card,
  .example,
  .sidecard {
    border-radius: 12px;
    padding: 12px;
  }

  .qr img {
    max-width: 96%;
    display: block;
    margin-left: auto;
    margin-right: auto;
  }
}
