/* brand.fablabbrno.cz — logomanuál FabLab Brno jako jedna dlouhá stránka.
 *
 * Každá strana PDF (842 × 595 pt) je jeden .canvas. Na desktopu se prvky kladou
 * absolutně v souřadnicích PDF: --x, --y, --w jsou body (pt) ze zdroje a --u je
 * velikost jednoho bodu na obrazovce. Na úzkém displeji se z téhož HTML stane
 * obyčejný tok pod sebou — souřadnice se ignorují, --u zůstane jen pro velikosti.
 */

:root {
  --red: #E4032E;   /* manuál str. 14: RGB 228 | 3 | 46 */
  --grey: #3C3C3B;  /* manuál str. 14: RGB 60 | 60 | 60, Pantone Black 7 */
  --black: #000;
  --white: #fff;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--white);
  color: var(--grey);
  font-family: "Raleway", Arial, sans-serif;
  font-weight: 500;
  /* Raleway má ve výchozím stavu skákavé (old-style) číslice; manuál sází lining. */
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}

/* ---------- strana ---------- */

.sheet { background: var(--white); color: var(--grey); }
.sheet--red { background: var(--red); color: var(--black); }
.sheet--black { background: var(--black); color: var(--white); }
.sheet--grey { background: var(--grey); color: var(--white); }
.sheet--cover { background: var(--red); color: var(--white); }

.page { max-width: 1440px; margin: 0 auto; container-type: inline-size; }

.canvas {
  --u: calc(100cqw / 842);
  position: relative;
  aspect-ratio: 842 / 595;
  overflow: hidden;
}

.a {
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  width: calc(var(--w) * var(--u));
  margin: 0;
}

/* ---------- typografie (velikosti v pt ze zdroje) ---------- */

.h {
  font-size: calc(14 * var(--u));
  line-height: calc(16 * var(--u));
  font-weight: 500;
  color: var(--red);
  white-space: nowrap;
}
.sheet--black .h, .sheet--black .t { color: var(--white); }
.sheet--red .h, .sheet--red .t { color: var(--black); }

.t {
  font-size: calc(8 * var(--u));
  line-height: calc(12 * var(--u));
  font-weight: 500;
  margin: 0;
}
/* Zalomení řádků drží <br class="d"> ze zdroje, ne šířka bloku. */
.t.a { white-space: nowrap; }

.cover-title {
  font-size: calc(30 * var(--u));
  line-height: 1.2;
  font-weight: 700;
  margin: 0;
}
/* Dva dokumenty vedle sebe stejným písmem (na mobilu pod sebou). */
.cover-title { display: flex; gap: 1em; white-space: nowrap; }
.cover-title a { color: inherit; text-decoration: none; }
.cover-title a:hover { text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .12em; }
.cover-title a:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- loga ke stažení ---------- */

.logo {
  display: block;
  color: inherit;
  cursor: pointer;
  border-radius: 2px;
  transition: opacity .15s;
}
.logo img { display: block; width: 100%; height: auto; }
.logo:hover { opacity: .82; }
.logo:focus-visible { outline: 2px solid currentColor; outline-offset: 6px; }

/* Dlaždice s podkladem (str. 11) — logo uprostřed */
.tile {
  height: calc(var(--h) * var(--u));
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile img { width: calc(var(--lw) * var(--u)); }
.tile--black { background: var(--black); color: var(--white); }
.tile--red { background: var(--red); color: var(--black); }

/* Klikací plochy přes nákres strojové varianty (str. 10) */
.figure { position: relative; }
.figure > img { display: block; width: 100%; height: auto; }
.hotspot {
  position: absolute;
  left: var(--l); top: var(--t); width: var(--hw); height: var(--hh);
}
.hotspot:hover { opacity: 1; background: rgb(0 0 0 / .04); }

.shape { display: block; height: auto; }

/* ---------- obsah (str. 2) ---------- */

.toc-col { text-align: center; }
.toc-h {
  display: block;
  font-size: calc(10 * var(--u));
  line-height: calc(12 * var(--u));
  font-weight: 400;
  color: inherit;
  text-decoration: none;
}
.toc-list {
  list-style: none;
  margin: calc(7 * var(--u)) 0 0;
  padding: 0;
  text-align: left;
  font-size: calc(8 * var(--u));
  line-height: calc(12 * var(--u));
}
.toc-list a, a.toc-h { color: inherit; text-decoration: none; }
.toc-list a:hover, a.toc-h:hover { color: var(--red); }

/* ---------- barevnost (str. 14) ---------- */

.swatch {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.swatch svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.swatch--red { color: var(--red); }
.swatch--grey { color: var(--grey); }

/* ---------- písmo (str. 15, 16) ---------- */

.display { font-size: calc(65 * var(--u)); line-height: 1.15; font-weight: 400; color: var(--black); margin: 0; }
/* Odkaz na stažení písma — doplněk webu, v PDF není. */
.font-link {
  font-size: calc(10 * var(--u));
  line-height: calc(12 * var(--u));
  font-weight: 600;
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: .2em;
  white-space: nowrap;
}
.font-link:hover { text-decoration-thickness: 2px; }
.font-link:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }
.display--arial { font-family: Arial, Helvetica, sans-serif; line-height: 1.37; }
.cut { font-size: calc(15 * var(--u)); line-height: 1.2; color: var(--black); margin: 0 0 calc(7 * var(--u)); }
.specimen { color: var(--black); }
.arial { font-family: Arial, Helvetica, sans-serif; }

.w300 { font-weight: 300; } .w400 { font-weight: 400; } .w500 { font-weight: 500; }
.w600 { font-weight: 600; } .w700 { font-weight: 700; } .w800 { font-weight: 800; }
.it { font-style: italic; }

/* ---------- horní lišta ---------- */

:root { --bar-h: 64px; }

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  height: var(--bar-h);
  background: var(--white);
  box-shadow: 0 1px 0 rgb(0 0 0 / .08);
  transform: translateY(-100%);
  transition: transform .2s ease-out;
}
.topbar.is-visible { transform: none; }
@media (prefers-reduced-motion: reduce) { .topbar { transition: none; } }

/* Okraje lícují s nadpisy stran (x = 71 pt v plátně o šířce max. 1440 px). */
.topbar__inner {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 calc(min(100vw, 1440px) * 71 / 842);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
/* Celé logo i s BRNO; výška 40 px je minimum, kdy je nápis ještě čitelný. */
.topbar__home { display: block; border-radius: 2px; }
.topbar__home img { display: block; width: auto; height: 40px; }
.topbar__nav {
  display: flex;
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.topbar__nav a {
  display: block;
  padding: 22px 0 20px;
  border-bottom: 2px solid transparent;
  color: var(--grey);
  text-decoration: none;
  font-size: 13px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.topbar__nav a:hover { color: var(--red); }
.topbar__nav a[aria-current="true"] { color: var(--red); border-bottom-color: var(--red); }
.topbar__home:focus-visible, .topbar__nav a:focus-visible, .topbar__toggle:focus-visible {
  outline: 2px solid var(--red); outline-offset: 2px;
}

/* Tři čárky — jen na úzkém displeji. */
.topbar__toggle {
  display: none;
  width: 48px; height: 48px;
  margin-right: -12px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: none;
  color: var(--grey);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ---------- dialog stažení ---------- */

.dl {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--grey);
  background: var(--white);
  box-shadow: 0 12px 40px rgb(0 0 0 / .25);
}
.dl::backdrop { background: rgb(0 0 0 / .55); }
.dl__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0 24px;
}
.dl__title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--red); }
.dl__close {
  width: 40px; height: 40px;
  border: 0; background: none; cursor: pointer;
  font: 400 26px/1 "Raleway", Arial, sans-serif; color: var(--grey);
}
.dl__close:focus-visible, .dl__swatch:focus-visible, .dl__fmt:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.dl__preview {
  margin: 16px 24px 0;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #F2F2F2;
}
.dl__preview.is-dark { background: var(--grey); }
.dl__preview img { max-width: 100%; max-height: 100%; }
.dl__name { margin: 12px 24px 0; font-size: 12px; font-weight: 500; word-break: break-all; }
.dl__label { margin: 20px 24px 8px; font-size: 12px; font-weight: 600; }
.dl__swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 24px; }
.dl__swatch {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 12px 0 8px;
  border: 1px solid #D9DADB; border-radius: 2px;
  background: var(--white); cursor: pointer;
  font: 500 13px "Raleway", Arial, sans-serif; color: var(--grey);
}
.dl__swatch::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  background: var(--dot); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .2);
}
.dl__swatch[aria-pressed="true"] { border-color: var(--grey); box-shadow: inset 0 0 0 1px var(--grey); }
.dl__formats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 24px; }
.dl__fmt {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 56px; padding: 8px;
  border-radius: 2px; background: var(--red); color: var(--white);
  text-decoration: none; font-weight: 700; font-size: 15px; letter-spacing: .04em;
}
.dl__fmt small { font-weight: 500; font-size: 11px; letter-spacing: 0; opacity: .9; margin-top: 2px; }
.dl__fmt:hover { background: #C20227; }
.dl__fmt--alt { background: var(--grey); }
.dl__fmt--alt:hover { background: #262626; }

/* ---------- úzký displej: tok místo plátna ---------- */

br.d { display: inline; }

@media (max-width: 760px) {
  .topbar__inner { padding: 0 16px; }
  .topbar__home img { height: 36px; }
  .topbar__toggle { display: flex; }
  /* Menu vyjede pod lištou přes celou šířku. */
  .topbar__menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    box-shadow: 0 8px 16px rgb(0 0 0 / .12);
  }
  .topbar__menu:not(.is-open) { display: none; }
  .topbar__nav { flex-direction: column; gap: 0; padding: 8px 0; }
  .topbar__nav a {
    padding: 14px 16px;
    border-bottom: 0;
    border-left: 3px solid transparent;
    font-size: 14px;
  }
  .topbar__nav a[aria-current="true"] { border-left-color: var(--red); }
  /* Na mobilu začíná nadpis strany 48 px od jejího vrchu — lišta by ho po skoku zakryla. */
  .sheet { scroll-margin-top: var(--bar-h); }
  .canvas {
    --u: 1.75px;
    aspect-ratio: auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 48px 16px;
  }
  .a { position: static; left: auto; top: auto; max-width: 100%; }
  .h { white-space: normal; font-size: 18px; line-height: 1.3; }
  .t, .t.a { font-size: 14px; line-height: 1.6; white-space: normal; }
  br.d { display: none; }

  .cover-title { font-size: 34px; flex-direction: column; gap: 4px; }
  .sheet--cover .canvas { min-height: 70vh; justify-content: space-between; }
  .corner { align-self: flex-end; width: 32px !important; }

  .toc-frame { display: none; }
  .toc-col { text-align: left; }
  .toc-h { font-size: 15px; line-height: 1.4; font-weight: 600; }
  .toc-list { font-size: 15px; line-height: 2; margin-top: 4px; }
  .toc-h br { display: none; }

  .swatch { position: relative; width: 240px; align-self: center; font-size: 14px; line-height: 1.6; }

  .uni { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .uni > .logo { width: auto; height: 120px; display: flex; align-items: center; justify-content: center; padding: 16px; }
  .uni > .logo img { width: auto; max-width: 100%; max-height: 64px; }
  .uni > .logo.v img { max-height: 80px; }

  .display { font-size: 64px; }
  .font-link { font-size: 16px; line-height: 1.4; white-space: normal; }
  .cut { font-size: 20px; margin-bottom: 6px; }
  .specimen .t { margin-bottom: 20px; }

}

/* Na desktopu se obal dlaždic str. 11 nevykresluje — děti se kladou do plátna. */
@media (min-width: 761px) { .uni { display: contents; } }

/* ---------- handbook ----------
 * Generuje tools/handbook.py. Strana A4 (595 × 842 pt) = podklad bez textu (JPEG)
 * + text v HTML, řádek po řádku na účaří z PDF. --u je jeden bod na obrazovce.
 * Široký displej: dvoustrany jako v tisku; střední: jedna strana pod druhou;
 * mobil: podklad pryč, text v toku, ilustrace jako výřezy (.hb-fig).
 */

.hb { background: var(--white); }
.hb-spread {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.hb-page { container-type: inline-size; background: var(--bg); }
.hb-canvas {
  --u: calc(100cqw / 595.276);
  position: relative;
  aspect-ratio: 595.276 / 841.89;
  overflow: hidden;
  color: var(--black);
}
.hb-art { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.hb-fig { display: none; }

.hb-p {
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  margin: 0;
}
.hb-l {
  position: absolute;
  left: calc(var(--dx) * var(--u));
  top: calc(var(--dy) * var(--u));
  font-size: calc(var(--s) * var(--u));
  line-height: 1.174; /* = ascender + descender Raleway → účaří sedí na PDF */
  white-space: nowrap;
}
.hb-l span, .hb-toc__title span {
  font-size: calc(var(--s) * var(--u));
  letter-spacing: calc(var(--ls, 0) * 1em);
}
.hb-l a { color: inherit; }
.hb-bullet { display: inline-block; width: calc(var(--bw) * var(--u)); }
/* Skok z odkazu nesmí skončit pod horní lištou. */
.hb, .hb-page { scroll-margin-top: var(--bar-h); }
.hb-w400 { font-weight: 400; } .hb-w600 { font-weight: 600; }
.hb-w800 { font-weight: 800; } .hb-w900 { font-weight: 900; }

/* Obsah handbooku — strana, která v PDF není; tvarosloví ze stran 2 a 3. */
.hb-toc__title { line-height: 1.174; white-space: nowrap; color: var(--black); }
.hb-toc__list {
  list-style: none;
  padding: 0;
  font-size: calc(18 * var(--u));
  line-height: calc(34 * var(--u));
  font-weight: 600;
}
.hb-toc__list a { color: var(--black); text-decoration: none; }
.hb-toc__list a:hover { color: var(--red); }
.hb-toc__list a:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.hb-corner {
  position: absolute;
  width: calc(95 * var(--u));
  height: calc(95 * var(--u));
  border: 0 solid var(--red);
}
.hb-corner--tl { left: 0; top: 0; border-top-width: calc(30 * var(--u)); border-left-width: calc(30 * var(--u)); }
.hb-corner--bl { left: calc(113.4 * var(--u)); top: calc(650 * var(--u)); border-bottom-width: calc(30 * var(--u)); border-left-width: calc(30 * var(--u)); }

/* Střední šířka: dvoustrana by byla moc drobná → strany pod sebou. */
@media (max-width: 1099px) {
  .hb-spread { grid-template-columns: 1fr; max-width: 720px; }
}

/* Mobil: tok textu. Strany s velkým písmem (.hb-page--keep) zůstávají celé. */
@media (max-width: 760px) {
  .hb-spread { display: block; max-width: none; }
  .hb-page:not(.hb-page--keep) .hb-canvas {
    aspect-ratio: auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 48px 16px;
  }
  .hb-page:not(.hb-page--keep) .hb-art { display: none; }
  .hb-page:not(.hb-page--keep) .hb-fig { display: block; width: 100%; height: auto; margin: 8px 0; }
  .hb-page:not(.hb-page--keep) .hb-p { position: static; line-height: 1.5; }
  .hb-page:not(.hb-page--keep) .hb-l { position: static; display: inline; white-space: normal; font-size: inherit; line-height: inherit; }
  .hb-page:not(.hb-page--keep) .hb-l span,
  .hb-page:not(.hb-page--keep) .hb-toc__title span {
    font-size: clamp(14px, calc(8px + var(--s) * 0.62px), 46px);
  }
  .hb-page:not(.hb-page--keep) .hb-bullet { width: 1.2em; }
  .hb-toc .hb-corner { display: none; }
  .hb-toc .hb-toc__title { white-space: normal; }
  .hb-page.hb-toc .hb-toc__list { font-size: 18px; line-height: 2.4; margin: 0; }
}
