/* Migasender user manual — self-contained, no external stylesheets or fonts.
   The manual is served as static files from public/manuale/, so everything it
   needs must live in this folder. */

:root {
  --brand:        #16a34a;
  --brand-soft:   #dcfce7;
  --brand-ink:    #14532d;

  --bg:           #ffffff;
  --surface:      #f8fafc;
  --surface-2:    #f1f5f9;
  --border:       #e2e8f0;
  --border-soft:  #eef2f7;
  --text:         #0f172a;
  --muted:        #64748b;

  --note:         #2563eb;
  --note-bg:      #eff6ff;
  --tip:          #16a34a;
  --tip-bg:       #f0fdf4;
  --warn:         #d97706;
  --warn-bg:      #fffbeb;
  --danger:       #dc2626;
  --danger-bg:    #fef2f2;

  --radius:       12px;
  --sidebar-w:    288px;
  --header-h:     60px;
  --content-max:  820px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand:        #22c55e;
  --brand-soft:   #052e16;
  --brand-ink:    #bbf7d0;

  --bg:           #0b1220;
  --surface:      #111a2b;
  --surface-2:    #16213a;
  --border:       #1e293b;
  --border-soft:  #172033;
  --text:         #e2e8f0;
  --muted:        #94a3b8;

  --note-bg:      #0e1c33;
  --tip-bg:       #06210f;
  --warn-bg:      #241a05;
  --danger-bg:    #2a0f0f;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 20px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ header */

.top {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.top__brand { display: flex; align-items: center; gap: 10px; }
.top__logo { height: 26px; width: auto; flex: none; display: block; }
.top__brand small {
  font-weight: 500; font-size: 11px; color: var(--muted); white-space: nowrap;
  padding-left: 10px; border-left: 1px solid var(--border);
}

/* The wordmark is dark navy, invisible on a dark background. Both versions are
   in the markup and CSS picks one: a white chip behind the dark logo left a
   visible box with padding around it, which read as a mistake. The dark version
   is generated from the same source file, so it cannot drift from the brand
   asset. */
/* Qualified with `img` on purpose. The picker's own inline <style> sets
   `.pick__logo { display: block }` and, at equal specificity, a later rule
   wins — which showed both logos at once in light mode. */
img.logo--dark { display: none; }
:root[data-theme="dark"] img.logo--light { display: none; }
:root[data-theme="dark"] img.logo--dark { display: block; }

.top__spacer { flex: 1; }

.search {
  position: relative;
  width: min(340px, 42vw);
}
.search input {
  width: 100%; height: 36px;
  padding: 0 34px 0 34px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: inherit; font: inherit; font-size: 14px;
  outline: none;
}
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.search__icon { position: absolute; left: 11px; top: 9px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search__kbd {
  position: absolute; right: 8px; top: 8px;
  font-size: 10px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--bg);
  pointer-events: none;
}

.iconbtn {
  height: 36px; min-width: 36px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: inherit; font: inherit; font-size: 13px;
  cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn svg { width: 16px; height: 16px; }

.langsel {
  height: 36px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: inherit; font: inherit; font-size: 13px;
  cursor: pointer;
}

/* reading progress */
.progress { position: fixed; top: var(--header-h); left: 0; height: 2px; background: var(--brand); z-index: 41; width: 0; }

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

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 40px;
  max-width: 1320px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 28px) 24px 96px;
}

/* -------------------------------------------------------------------- toc */

.toc {
  position: sticky; top: calc(var(--header-h) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  padding-right: 8px;
}
.toc h2 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: chapter; }
.toc li { counter-increment: chapter; }
.toc a {
  display: flex; gap: 10px; align-items: baseline;
  padding: 6px 10px; border-radius: 8px;
  color: var(--muted); font-size: 14px; line-height: 1.35;
  border-left: 2px solid transparent;
}
.toc a::before {
  content: counter(chapter) ".";
  font-variant-numeric: tabular-nums; font-size: 12px; opacity: .65; flex: none; min-width: 18px;
}
.toc a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.toc a.is-active { background: var(--brand-soft); color: var(--brand-ink); border-left-color: var(--brand); font-weight: 600; }
.toc li.is-hidden { display: none; }

.toc__empty { display: none; padding: 10px; font-size: 13px; color: var(--muted); }
.toc__empty.is-shown { display: block; }

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

.content { max-width: var(--content-max); }

.lede {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 20px 22px; margin-bottom: 40px;
}
.lede h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.02em; }
.lede p { margin: 0; color: var(--muted); }
.lede__meta { margin-top: 14px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 16px; }

.chapter { scroll-margin-top: calc(var(--header-h) + 20px); padding-top: 8px; }
.chapter + .chapter { margin-top: 56px; border-top: 1px solid var(--border-soft); padding-top: 44px; }

h2 { font-size: 23px; letter-spacing: -.015em; margin: 0 0 4px; }
h3 { font-size: 17px; margin: 32px 0 6px; }
h4 { font-size: 15px; margin: 22px 0 4px; }

.chapter__kicker { font-size: 12px; font-weight: 700; color: var(--brand); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }
.chapter__sub { margin: 0 0 22px; color: var(--muted); }

p { margin: 0 0 14px; }
ul, ol { margin: 0 0 16px; padding-left: 22px; }
li { margin: 5px 0; }
strong { font-weight: 650; }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  padding: 1px 5px; border-radius: 5px;
}

/* anchor link on headings */
.anchor {
  margin-left: 8px; opacity: 0; font-size: .7em; color: var(--muted);
  text-decoration: none; vertical-align: middle;
}
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

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

figure { margin: 22px 0; }
figure img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  cursor: zoom-in;
}
figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); }
figcaption b { color: var(--text); font-weight: 650; }

/* numbered callout legend under a screenshot */
.legend { list-style: none; margin: 12px 0 0; padding: 0; counter-reset: pin; }
/* The badge is positioned, not a grid cell. As a grid item it split the row's
   <strong> label and the sentence after it into two separate items, dropping
   the sentence into the 22px column one word per line. */
.legend li {
  counter-increment: pin;
  position: relative;
  padding-left: 32px;
  margin: 7px 0;
  font-size: 14px;
  line-height: 1.6;
}
.legend li::before {
  content: counter(pin);
  position: absolute; left: 0; top: 1px;
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 700;
}

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

.box {
  margin: 18px 0; padding: 13px 16px;
  border: 1px solid var(--border); border-left: 3px solid var(--muted);
  border-radius: 10px; background: var(--surface);
  font-size: 15px;
}
.box > :last-child { margin-bottom: 0; }
.box__label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; margin-bottom: 4px; }

.box--note   { border-left-color: var(--note);   background: var(--note-bg); }
.box--note   .box__label { color: var(--note); }
.box--tip    { border-left-color: var(--tip);    background: var(--tip-bg); }
.box--tip    .box__label { color: var(--tip); }
.box--warn   { border-left-color: var(--warn);   background: var(--warn-bg); }
.box--warn   .box__label { color: var(--warn); }
.box--danger { border-left-color: var(--danger); background: var(--danger-bg); }
.box--danger .box__label { color: var(--danger); }

/* ----------------------------------------------------------------- steps */

.steps { counter-reset: step; list-style: none; padding: 0; margin: 16px 0; }
.steps > li {
  counter-increment: step;
  position: relative; padding-left: 38px; margin: 0 0 14px;
}
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 1px;
  width: 25px; height: 25px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink);
  font-size: 12px; font-weight: 700;
}

/* ---------------------------------------------------------------- tables */

.tablewrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius); }
/* Without a min-width the table shrinks to the phone's width instead of using
   the wrapper's scroll, and a term like "Delivery Webhook URL" ends up two
   words per line. The wrapper scrolls; the page body never does. */
table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: 14px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th { background: var(--surface); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: 0; }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  white-space: nowrap;
}
.badge--ok   { background: var(--tip-bg);    color: var(--tip);    border-color: color-mix(in srgb, var(--tip) 35%, transparent); }
.badge--warn { background: var(--warn-bg);   color: var(--warn);   border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.badge--off  { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ----------------------------------------------------------- back to top */

.totop {
  position: fixed; right: 22px; bottom: 22px; z-index: 30;
  width: 42px; height: 42px; border-radius: 999px;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .18s;
  box-shadow: 0 6px 20px rgba(2, 12, 27, .12);
}
.totop.is-shown { opacity: 1; pointer-events: auto; }
.totop:hover { color: var(--brand); border-color: var(--brand); }

/* -------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: none; place-items: center;
  background: rgba(2, 12, 27, .82); padding: 32px;
  cursor: zoom-out;
}
.lightbox.is-open { display: grid; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }

/* ---------------------------------------------------------- search state */

mark { background: color-mix(in srgb, var(--brand) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.chapter.is-filtered { display: none; }
.noresults { display: none; padding: 40px 0; color: var(--muted); }
.noresults.is-shown { display: block; }

/* --------------------------------------------------------------- mobile */

.menubtn { display: none; }

@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: calc(var(--header-h) + 20px); }
  .menubtn { display: inline-flex; }
  .search { width: min(220px, 38vw); }
  .search__kbd { display: none; }

  .toc {
    position: fixed; inset: var(--header-h) auto 0 0; z-index: 45;
    width: 300px; max-height: none; height: calc(100vh - var(--header-h));
    background: var(--bg); border-right: 1px solid var(--border);
    padding: 18px 14px; transform: translateX(-102%); transition: transform .2s;
  }
  .toc.is-open { transform: none; box-shadow: 0 10px 40px rgba(2,12,27,.2); }
  .scrim { position: fixed; inset: var(--header-h) 0 0 0; z-index: 44; background: rgba(2,12,27,.45); display: none; }
  .scrim.is-open { display: block; }
}

@media (max-width: 560px) {
  /* Six controls do not fit across a phone. Keep the two that are used while
     reading — search and the menu — and drop what the browser already offers
     (print) or what is one tap away in the drawer. */
  .top { gap: 8px; padding: 0 12px; }
  .top__brand small,
  .top__brand span { display: none; }
  #print { display: none; }
  .search { flex: 1; width: auto; min-width: 0; }
  .langsel { max-width: 74px; padding: 0 4px; }
  .hide-sm { display: none; }
  .lede h1 { font-size: 24px; }
  h2 { font-size: 20px; }
}

/* ---------------------------------------------------------------- print */

@media print {
  .top, .toc, .totop, .progress, .scrim, .lightbox, .anchor { display: none !important; }
  .layout { display: block; max-width: none; padding: 0; }
  .content { max-width: none; }
  body { font-size: 11pt; }
  .chapter { page-break-inside: auto; }
  .chapter + .chapter { page-break-before: always; border-top: 0; margin-top: 0; padding-top: 0; }
  h2, h3, h4 { page-break-after: avoid; }
  figure, .box, .tablewrap { page-break-inside: avoid; }
  figure img { border-color: #ccc; cursor: default; }
  a { color: inherit; text-decoration: none; }
}
