/* =====================================================================
   JustFlip — User Manual (manual/**, generated by manual-src/build.sh)
   Builds on styles.css tokens; nothing here overrides site-wide rules
   outside .manual-page.
   ===================================================================== */

.manual-page {
  --m-card:        #1f1e1d;
  --m-card-edge:   rgba(255, 205, 87, 0.16);
  --m-tip:         var(--secondary);
  --m-gotcha:      #e8917b;
  --m-note:        var(--primary-container);
  --m-mono:        "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
}

/* ---------------------------------------------------------------- hero */

.m-hero {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(6.5rem, 12vh, 8.5rem) var(--gutter) clamp(2.5rem, 5vw, 4rem);
  overflow: hidden;
}
.m-hero__inner { position: relative; z-index: 1; max-width: 780px; }
.m-hero__number {
  position: absolute;
  right: var(--gutter);
  bottom: -0.18em;
  font-size: clamp(10rem, 26vw, 22rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 205, 87, 0.22);
  pointer-events: none;
  user-select: none;
}
.m-crumb { margin: 0 0 1.4rem; font-size: 0.9rem; }
.m-crumb a { color: var(--on-surface-variant); border-bottom: 1px solid var(--outline-variant); }
.m-crumb a:hover { color: var(--primary-container); }
.m-hero .lede { max-width: 60ch; }
.m-hero .lede p { margin: 0; }
.m-hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

/* "In this chapter" */
.m-hero .inthischapter { margin-top: 2.25rem; }
.m-hero .inthischapter ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 2rem;
}
.m-hero .inthischapter li {
  position: relative;
  padding-left: 1.4rem;
  color: var(--on-surface);
  font-size: 0.98rem;
}
.m-hero .inthischapter li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.8em;
  width: 0.8rem;
  height: 1px;
  background: var(--primary-container);
}

/* ---------------------------------------------------------------- layout */

.m-layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(4rem, 8vw, 6rem);
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

.m-toc {
  position: sticky;
  top: 5.5rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 1.2rem 0 1.2rem;
  border-top: 1px solid var(--outline-variant);
  font-size: 0.88rem;
}
.m-toc__title {
  margin: 0 0 0.8rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}
.m-toc ul { list-style: none; margin: 0; padding: 0; }
.m-toc li { margin: 0; }
.m-toc a {
  display: flex;
  gap: 0.6rem;
  padding: 0.32rem 0 0.32rem 0.8rem;
  border-left: 1px solid var(--outline-variant);
  color: var(--on-surface-variant);
  line-height: 1.35;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.m-toc a:hover { color: var(--on-surface); }
.m-toc a.is-active { color: var(--primary-container); border-left-color: var(--primary-container); }
.m-toc .toc-section-number { color: var(--outline); font-variant-numeric: tabular-nums; min-width: 2.2em; }
.m-toc a.is-active .toc-section-number { color: inherit; }

/* ---------------------------------------------------------------- content */

.m-content {
  min-width: 0;
  max-width: 760px;
  font-size: 1.04rem;
  line-height: 1.7;
  color: var(--on-surface);
}
.m-content > p, .m-content > ul, .m-content > ol { color: var(--on-surface); }
.m-content p { margin: 0 0 1.05rem; }
.m-content strong { color: var(--primary); font-weight: 600; }
.m-content a { color: var(--primary-container); border-bottom: 1px solid rgba(255, 205, 87, 0.35); }
.m-content a:hover { border-bottom-color: var(--primary-container); }

.m-content h2 {
  margin: clamp(3.5rem, 7vw, 5rem) 0 1.1rem;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.018em;
  font-weight: 600;
  scroll-margin-top: 5.5rem;
}
.m-content h2:first-child { margin-top: 1rem; }
.m-content h2 .header-section-number {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  font-weight: 500;
  color: var(--primary-container);
}
.m-content h2 .header-section-number::before {
  content: "";
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-container));
}
.m-content h3 {
  margin: 2.4rem 0 0.7rem;
  font-size: 1.22rem;
  font-weight: 600;
  scroll-margin-top: 5.5rem;
}
.m-content h3 .header-section-number { display: none; }

.m-content ul, .m-content ol { margin: 0 0 1.2rem; padding-left: 1.3rem; }
.m-content li { margin: 0.3rem 0; }
.m-content ul li::marker { color: var(--primary-container); }
.m-content ol li::marker { color: var(--primary-container); font-weight: 600; }

.m-content .ui { font-weight: 600; color: var(--primary); }
.m-content code,
.m-content pre { font-family: var(--m-mono); font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }

.m-content__end {
  margin-top: 4rem !important;
  padding-top: 1.4rem;
  border-top: 1px solid var(--outline-variant);
  font-size: 0.92rem;
  color: var(--on-surface-variant);
}

/* code blocks */
/* pandoc tags highlighted Markdown with class "markdown", which styles.css
   already uses for a home-page section grid — undo that inside the manual. */
.m-content .sourceCode.markdown {
  display: block;
  grid-template-columns: none;
  gap: 0;
  align-items: initial;
  justify-items: initial;
}
.m-content div.sourceCode,
.m-content pre {
  margin: 0 0 1.2rem;
  background: var(--surface-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  overflow: auto;
}
.m-content pre {
  padding: 0.95rem 1.1rem;
  font-family: var(--m-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--on-surface);
}
.m-content div.sourceCode pre { margin: 0; border: 0; background: none; }
.m-content pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

/* tables */
.m-content table {
  width: 100%;
  margin: 0.4rem 0 1.6rem;
  border-collapse: collapse;
  font-size: 0.94rem;
}
.m-content th, .m-content td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--outline-variant);
}
.m-content thead th {
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--primary-container);
  border-bottom-color: rgba(255, 205, 87, 0.4);
}
.m-content tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* maths (MathML) */
.m-content math { font-family: "Latin Modern Math", "STIX Two Math", math; font-size: 1.08em; }
.m-content math[display="block"] { margin: 0.6rem 0; }

/* ---------------------------------------------------------------- callouts */

.callout {
  --c: var(--m-note);
  position: relative;
  margin: 1.8rem 0;
  padding: 1.15rem 1.35rem 0.4rem 1.35rem;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--c) 9%, transparent), transparent 70%),
    var(--surface-low);
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
  border-left: 3px solid var(--c);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.callout--tip { --c: var(--m-tip); }
.callout--gotcha { --c: var(--m-gotcha); }
.callout__label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--c);
}
.callout__label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}
.callout__title { margin: 0 0 0.45rem; font-size: 1.12rem; font-weight: 600; color: var(--on-surface); }
.callout p, .callout li { font-size: 0.98rem; color: var(--on-surface-variant); }
.callout strong { color: var(--on-surface); }

/* ---------------------------------------------------------------- pairs */

.pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  margin: 1.6rem 0 2rem;
}
.pair__label {
  margin-bottom: 0.55rem;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}
.pair__arrow {
  align-self: center;
  margin-top: 1.4rem;
  font-size: 1.3rem;
  color: var(--primary-container);
}
.pair div.sourceCode { margin: 0; }
.pair .m-figure { margin: 0; }

/* ---------------------------------------------------------------- app card */

.jf-card {
  display: flex;
  flex-direction: column;
  min-height: 176px;
  padding: 0.95rem 1.2rem 0.8rem;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 205, 87, 0.07), transparent 55%),
    var(--m-card);
  border: 1px solid var(--m-card-edge);
  border-radius: 20px;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.jf-card__side {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--primary-container);
}
.jf-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.7rem 0;
  font-size: 1.08rem;
  line-height: 1.5;
}
.jf-card__body > :last-child { margin-bottom: 0; }
.jf-card__body p { margin: 0 0 0.6rem; color: var(--on-surface); }
.jf-card__body strong { color: var(--on-surface); font-weight: 700; }
.jf-card__body table { margin: 0; font-size: 0.9rem; }
.jf-card__body thead th { color: var(--on-surface); letter-spacing: 0; text-transform: none; font-size: 0.9rem; }
.jf-card__body th, .jf-card__body td { padding: 0.35rem 0.5rem; }
.jf-card__body div.sourceCode { margin: 0; background: var(--surface-high); border: 0; }
.jf-card--hero .jf-card__body { align-items: center; text-align: center; }
.jf-card--hero .jf-card__body p { font-size: clamp(3.4rem, 8vw, 4.6rem); line-height: 1.1; font-weight: 500; margin: 0; }
.jf-card__foot { display: flex; justify-content: flex-end; }
.jf-card__flip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  color: var(--primary);
  background: var(--surface-high);
  border-radius: 999px;
}
.jf-spoken { margin: 0.7rem 0 0 !important; font-size: 0.9rem; color: var(--on-surface-variant); font-style: italic; }
.jf-spoken__label { font-style: normal; font-weight: 600; color: var(--primary-container); }
.jf-spoken__label::before { content: "🔊\FE0E"; margin-right: 0.35rem; }

/* cloze */
.blank {
  display: inline-block;
  padding: 0 0.35em;
  font-weight: 700;
  color: var(--primary-container);
  background: rgba(255, 205, 87, 0.14);
  border-radius: 5px;
}
.reveal {
  padding: 0 0.25em;
  font-weight: 600;
  color: var(--ink);
  background: var(--primary-container);
  border-radius: 4px;
}

/* ---------------------------------------------------------------- figures */

.m-figure { margin: 1.8rem 0 2rem; }
.m-figure img {
  width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid var(--outline-variant);
  box-shadow: 0 30px 60px -35px rgba(0, 0, 0, 0.9);
}
.m-figure figcaption {
  margin-top: 0.75rem;
  font-size: 0.86rem;
  color: var(--on-surface-variant);
}
.m-figure--shot { max-width: 620px; }
.m-figure--phone img {
  max-width: 280px;
  border: 7px solid #070707;
  border-radius: 38px;
  box-shadow: 0 0 0 1px var(--outline-variant), 0 40px 70px -30px rgba(0, 0, 0, 0.95);
}
.m-figure--card-shot img { border-radius: 16px; }

.split {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  margin: 1.4rem 0 1rem;
}
.split .m-figure { margin: 0; }

/* ---------------------------------------------------------------- landing */

.m-hero--home { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 3rem; align-items: center; }
.m-hero--home .display { margin-bottom: 1.4rem; }

.m-deck { position: relative; height: 300px; z-index: 1; }
.m-deck__card {
  position: absolute;
  inset: 40px 20px auto auto;
  width: min(360px, 90%);
  height: 220px;
  display: grid;
  place-items: center;
  background: var(--m-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 22px;
  font-size: 3.2rem;
  color: var(--on-surface-variant);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9);
}
.m-deck__card--back { transform: rotate(12deg) translate(24px, -26px); color: rgba(255, 205, 87, 0.6); }
.m-deck__card--mid { transform: rotate(4deg) translate(6px, -6px); }
.m-deck__card--front {
  place-items: start;
  align-content: space-between;
  padding: 1.2rem 1.4rem 1.6rem;
  transform: rotate(-5deg) translate(-26px, 20px);
  border-color: rgba(255, 205, 87, 0.55);
  font-size: 1.3rem;
  color: var(--on-surface);
}

.m-chapters {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem var(--gutter) clamp(4rem, 8vw, 6rem);
}
.m-chapters__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.m-chapter > a, .m-chapter > div {
  display: grid;
  gap: 0.45rem;
  height: 100%;
  padding: 1.4rem 1.4rem 1.3rem;
  background: var(--surface-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
}
.m-chapter__number { font-size: 2.4rem; font-weight: 700; line-height: 1; color: var(--outline); letter-spacing: -0.03em; }
.m-chapter__title { font-size: 1.12rem; font-weight: 600; }
.m-chapter__blurb { font-size: 0.92rem; color: var(--on-surface-variant); }
.m-chapter__soon, .m-chapter__go { align-self: end; margin-top: 0.6rem; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; }
.m-chapter__soon { color: var(--outline); }
.m-chapter:not(.m-chapter--ready) { opacity: 0.72; }
.m-chapter--ready > a {
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(255, 205, 87, 0.12), transparent 60%),
    var(--surface-low);
  border-color: rgba(255, 205, 87, 0.45);
  transition: transform .3s var(--ease), border-color .3s var(--ease);
}
.m-chapter--ready > a:hover { transform: translateY(-3px); border-color: var(--primary-container); }
.m-chapter--ready .m-chapter__number { color: var(--primary-container); }
.m-chapter__go { color: var(--primary-container); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 980px) {
  .m-layout { grid-template-columns: minmax(0, 1fr); }
  .m-toc { position: static; max-height: none; border: 1px solid var(--outline-variant); border-radius: var(--radius-md); padding: 1rem 1.1rem; }
  .m-toc ul { columns: 2; column-gap: 1.5rem; }
  .m-toc a { border-left: 0; padding-left: 0; break-inside: avoid; }
  .m-hero--home { grid-template-columns: minmax(0, 1fr); }
  .m-deck { display: none; }
}
@media (max-width: 720px) {
  .m-hero .inthischapter ul { grid-template-columns: minmax(0, 1fr); }
  .m-toc ul { columns: 1; }
  .pair { grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
  .pair__arrow { margin: 0; justify-self: center; transform: rotate(90deg); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .split .m-figure--phone { justify-self: center; }
  .m-figure--phone img { max-width: 240px; }
  .m-hero__number { display: none; }
}

/* ---------------------------------------------------------------- screenshot placeholders */
/* Rendered by the filter while a screenshot has not been captured yet. */
.m-placeholder {
  display: grid;
  place-content: center;
  gap: 0.6rem;
  margin: 1.8rem 0 2rem;
  min-height: 220px;
  padding: 1.5rem;
  text-align: center;
  border: 1.5px dashed var(--outline);
  border-radius: 18px;
  background: repeating-linear-gradient(135deg, var(--surface-low) 0 14px, var(--surface) 14px 28px);
}
.m-placeholder--phone { max-width: 280px; min-height: 520px; border-radius: 38px; }
.m-placeholder__file { font-family: var(--m-mono); font-size: 0.8rem; color: var(--primary-container); }
.m-placeholder__caption { font-size: 0.86rem; color: var(--on-surface-variant); }
.m-placeholder__caption p { margin: 0; }
