/* Screen layout for the onboarding guides: sticky contents, progress bar, click-to-zoom pictures.
   Print and PDF keep the A4 styles in the page itself; everything here is screen-only or hidden in print. */

:root { color-scheme: light; --side: 290px; --shadow: 0 10px 30px rgba(40, 20, 120, .10); }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }

@media screen {
  body { background: var(--bg); font-size: 16px; }
  main { margin-left: var(--side); padding: 32px 48px 80px; max-width: calc(880px + 96px); }
  section { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 28px 32px;
            margin: 0 0 18px; box-shadow: 0 1px 2px rgba(40, 20, 120, .04); }
  section.page-break { break-before: auto; }
  /* a chapter that runs over several print pages reads as one block on screen */
  section:not(:has(h2)):not(.cover) { margin-top: -18px; border-top: 0; border-top-left-radius: 0;
            border-top-right-radius: 0; padding-top: 4px; }
  section:has(+ section:not(:has(h2)):not(.cover)) { border-bottom-left-radius: 0; border-bottom-right-radius: 0;
            border-bottom: 0; padding-bottom: 8px; }
  h2 { font-size: 28px; scroll-margin-top: 24px; }
  h3 { font-size: 19px; scroll-margin-top: 24px; }
  .lead { font-size: 18px; }
  .box { font-size: 15px; }
  table { font-size: 15px; }

  /* cover becomes a hero */
  .cover { height: auto; display: grid; grid-template-columns: 1.05fr 1fr; gap: 28px; align-items: center;
           padding: 36px; background: linear-gradient(135deg, #fff 0%, var(--brand-soft) 100%); }
  .cover h1 { font-size: 40px; margin: 18px 0 12px; }
  .cover .sub { font-size: 18px; }
  .cover img { max-height: none; }
  .cover .foot { grid-column: 1 / -1; font-size: 13px; }

  /* pictures: full width, click to enlarge */
  figure img { max-height: none; max-width: 100%; cursor: zoom-in; transition: transform .15s, box-shadow .15s; }
  figure img:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
  figure.half img { max-width: 70%; }
  figure.tall img { max-height: none; }
  .two figure img { max-height: 520px; }
  figcaption::after { content: " · click to enlarge"; opacity: .7; }

  /* contents list on the page */
  .toc a { display: flex; gap: 10px; width: 100%; color: inherit; text-decoration: none; }
  .toc li:hover { background: var(--brand-soft); }
  .toc li { padding-left: 8px; border-radius: 6px; }

  /* section-2 checklist can be ticked */
  .checklist li { cursor: pointer; user-select: none; }
  .checklist li.done::before { background: var(--brand); box-shadow: inset 0 0 0 2px #fff; }
  .checklist li.done { color: var(--muted); }

  /* heading anchors */
  .anchor { margin-left: 8px; font-size: .7em; color: var(--muted); text-decoration: none; opacity: 0; }
  h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

  /* previous / next at the end of each chapter */
  .chapnav { display: flex; justify-content: space-between; gap: 12px; margin: 22px 0 6px; padding-top: 16px;
             border-top: 1px dashed var(--line); }
  .chapnav a { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 1px solid var(--line);
               border-radius: 10px; text-decoration: none; color: var(--ink); max-width: 48%; background: #fff; }
  .chapnav a:hover { border-color: var(--brand); box-shadow: var(--shadow); }
  .chapnav a small { color: var(--muted); font-size: 12px; }
  .chapnav a.next { margin-left: auto; text-align: right; }
}

/* sidebar */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: #fff; border-right: 1px solid var(--line);
        overflow-y: auto; padding: 22px 16px 16px; display: flex; flex-direction: column; z-index: 30; }
.side .brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--ink);
               font-weight: 700; font-size: 18px; margin: 0 6px 18px; }
.side .brand .mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #7b5cff, #e0559b);
                     display: grid; place-items: center; color: #fff; font-size: 13px; flex: none; }
img.mark { background: none !important; display: block; object-fit: contain; }
.side .brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.side ol { list-style: none; margin: 0; padding: 0; }
.side .chapters > li > a { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px;
                           text-decoration: none; color: var(--ink2); font-size: 14px; line-height: 1.35; }
.side .chapters .n { flex: none; width: 22px; height: 22px; border-radius: 999px; background: var(--brand-soft);
                     color: var(--brand); font-weight: 700; font-size: 12px; display: grid; place-items: center; }
.side a:hover { background: var(--bg); }
.side a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side a.active .n { background: var(--brand); color: #fff; }
.side a.seen .n { background: var(--ok-soft); color: var(--ok); }
.side .sub { margin: 2px 0 6px 42px; border-left: 2px solid var(--line); }
.side .sub a { display: block; padding: 5px 10px; font-size: 13px; color: var(--muted); text-decoration: none;
               border-radius: 0 6px 6px 0; margin-left: -2px; border-left: 2px solid transparent; }
.side .sub a.active { border-left-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.side-links { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.side-links a { font-size: 13px; font-weight: 600; text-decoration: none; color: var(--ink2); padding: 6px 10px;
                border-radius: 8px; }
.side-links a.cta { color: var(--brand); background: var(--brand-soft); text-align: center; }
.side-foot { margin-top: 8px; padding-top: 16px; display: flex; gap: 8px; }
.side-foot a, .side-foot button { flex: 1; font: inherit; font-size: 13px; font-weight: 600; text-align: center;
               padding: 9px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink);
               text-decoration: none; cursor: pointer; }
.side-foot a { background: var(--brand); color: #fff; border-color: var(--brand); }

.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 40; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .1s; }
.topbar, .scrim { display: none; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(20, 18, 43, .88); z-index: 50; display: grid;
            grid-template-columns: 56px 1fr 56px; align-items: center; padding: 24px 8px; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; text-align: center; overflow: auto; max-height: 100%; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 8px; background: #fff; cursor: zoom-out; }
.lightbox figcaption { color: #e8e4ff; font-size: 14px; margin-top: 10px; }
.lightbox figcaption::after { content: none; }
.lightbox button { background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 999px; width: 44px;
                   height: 44px; font-size: 26px; cursor: pointer; }
.lightbox button:hover { background: rgba(255, 255, 255, .25); }
.lb-x { position: absolute; top: 14px; right: 14px; font-size: 18px !important; }

/* phones and small tablets */
@media screen and (max-width: 900px) {
  main { margin-left: 0; padding: 64px 16px 60px; }
  section { padding: 20px 18px; border-radius: 12px; }
  .cover { grid-template-columns: 1fr; padding: 22px; }
  .cover h1 { font-size: 30px; }
  .two { grid-template-columns: 1fr; }
  figure.half img { max-width: 100%; }
  table { display: block; overflow-x: auto; }
  .step { gap: 10px; }
  .side { transform: translateX(-100%); transition: transform .2s; width: min(86vw, 320px); box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .topbar { display: flex; gap: 12px; align-items: center; position: fixed; top: 3px; left: 0; right: 0; z-index: 20;
            background: rgba(255, 255, 255, .95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
            padding: 10px 16px; }
  h2, h3 { scroll-margin-top: 72px; }
  .topbar button { white-space: nowrap; flex: none; font: inherit; font-weight: 600; font-size: 14px; border: 1px solid var(--line); background: #fff;
                   border-radius: 8px; padding: 6px 12px; color: var(--ink); }
  #where { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(20, 18, 43, .35); z-index: 25; }
  .lightbox { grid-template-columns: 40px 1fr 40px; padding: 16px 2px; }
  .lightbox button { width: 36px; height: 36px; }
  .chapnav a { max-width: 100%; }
}

@media print {
  .side, .topbar, .progress, .scrim, .lightbox, .chapnav, .anchor { display: none !important; }
}
