/* V1 "Traka računa": the page is one long thermal receipt strip lying on a steel counter.
 *
 * Grid: every row is three tracks, [counter] [strip] [counter]. The paper is painted by one
 * gradient on .paper-bg so the strip stays continuous from the top edge of the page down to the
 * perforation, whatever the rows do. Headlines hang across the strip edge into the counter;
 * marginal notes (leads, sources, the later phases) sit on the counter beside the strip.
 *
 * Breakpoints: narrow < 45rem (strip fills the screen), mid 45rem to 73.75rem (headlines hang,
 * notes stay on the strip), wide >= 73.75rem (notes move into the margins).
 */

:root {
  /* Palette */
  --counter: #C4C8C7;   /* steel counter the strip lies on */
  --paper: #FBFBF9;     /* thermal paper */
  --ink: #000000;       /* print and headline ink */
  --ink-2: #474747;     /* faded thermal print: leaders, fine print, sources */
  --red: #A8101A;       /* fiscal red, used only as a stamp */

  /* Type */
  --serif: "Bodoni Moda", "Bodoni 72", Didot, "Book Antiqua", Georgia, serif;
  --mono: "Martian Mono", ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  /* Layout */
  --strip: min(30rem, 100% - 1rem);
  --pad: 1rem;          /* paper edge to print */
  --gutter: 1.5rem;     /* screen edge to anything */
  --dash: repeating-linear-gradient(90deg, var(--ink) 0 .5rem, transparent 0 .8rem);

  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--counter);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.55;
  font-optical-sizing: auto;
  overflow-x: hidden;
  overflow-x: clip;
}

h1, h2, h3, p, ul, ol, dl, dd { margin-block: 0; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .2em; }
section[id], #pilot-kontakt { scroll-margin-top: 1.5rem; }
main:focus { outline: none; }

/* ---------- Paper and grid ---------- */

.paper-bg {
  background: linear-gradient(90deg,
    transparent calc(50% - var(--strip) / 2),
    var(--paper) 0,
    var(--paper) calc(50% + var(--strip) / 2),
    transparent 0);
}

.grid,
.head,
.phases,
.rules > li {
  display: grid;
  grid-template-columns: 1fr var(--strip) 1fr;
}

/* Grid children are wrappers; atoms inside them stay free of grid margins. */
.grid > *,
.head > *,
.phases > *,
.rules > li > * {
  grid-column: 2;
  margin-inline: var(--pad);
  min-width: 0;
}

.grid > .head,
.grid > .phases,
.grid > .rules {
  grid-column: 1 / -1;
  margin-inline: 0;
}

/* ---------- Receipt rules: dashes for minor breaks, doubled dashes for major ones ---------- */

.rule-major {
  height: 7px;
  background:
    var(--dash) left top / 100% 2px no-repeat,
    var(--dash) left bottom / 100% 2px no-repeat;
}

.block { padding-block: 0 4.5rem; }

.block::before {
  content: "";
  grid-column: 2;
  margin-inline: var(--pad);
  margin-block: 0 3.5rem;
  height: 2px;
  background: var(--dash);
}

.block-major::before {
  height: 7px;
  background:
    var(--dash) left top / 100% 2px no-repeat,
    var(--dash) left bottom / 100% 2px no-repeat;
}

/* ---------- Type ---------- */

.display {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.75rem, 1rem + 6.6vw, 7.5rem);
  line-height: 1;
  letter-spacing: -.02em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.headline {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.25rem, 1rem + 4.2vw, 5.25rem);
  line-height: 1.02;
  letter-spacing: -.012em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.lead {
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.55;
  max-width: 36rem;
}

.body {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.55;
}

.fine {
  font-family: var(--mono);
  font-size: .875rem;
  line-height: 1.6;
  color: var(--ink-2);
}

/* ---------- Masthead: the receipt header ---------- */

.masthead { position: relative; }

.masthead > * { grid-column: 2; margin-inline: var(--pad); min-width: 0; }

.masthead {
  display: grid;
  grid-template-columns: 1fr var(--strip) 1fr;
}

.receipt-head {
  grid-row: 1;
  padding-block: 2.75rem 1.5rem;
  text-align: center;
}

.brand-name {
  font-family: var(--mono);
  font-weight: 800;
  font-stretch: 112.5%;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: .02em;
}

.brand-by {
  margin-block-start: .5rem;
  font-family: var(--mono);
  font-size: .875rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.masthead-bar {
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  padding-block: 0 1rem;
}

.nav { position: relative; flex: 1 1 100%; }
.head-cta { flex: 0 1 auto; margin-inline-start: auto; }
.masthead-rule { grid-row: 3; }

.menu-toggle {
  display: none;
  min-height: 2.75rem;
  padding: .5rem .9rem;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 700;
  font-size: .875rem;
  cursor: pointer;
}

.menu-toggle[aria-expanded="true"] { background: var(--ink); color: var(--paper); }

.nav-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

.nav-list a {
  display: inline-block;
  padding-block: .6rem;
  font-family: var(--mono);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
}

.nav-list a:hover { text-decoration: underline; }

/* With JS the narrow menu becomes a dropdown slip under the toggle. */
.js .nav { flex: 0 0 auto; }
.js .menu-toggle { display: inline-flex; align-items: center; }

.js .nav-list {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + .5rem);
  left: 0;
  width: min(18rem, calc(100vw - 3rem));
  padding: .5rem 1rem;
  flex-direction: column;
  background: var(--paper);
  border: 2px solid var(--ink);
}

.js .nav-list.is-open { display: flex; }
.js .nav-list li + li { background: var(--dash) left top / 100% 1px no-repeat; }
.js .nav-list a { display: block; padding-block: .75rem; }

/* ---------- Buttons ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: .75rem 1.25rem;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
}

/* Reverse print: white on black, as thermal printers do for emphasis. */
.btn-reverse { background: var(--ink); color: var(--paper); }
.btn-reverse:hover { outline: 2px dashed var(--paper); outline-offset: -6px; }

.btn-line { border: 2px solid var(--ink); color: var(--ink); background: transparent; }
.btn-line:hover { background: rgba(0, 0, 0, .07); }

.btn-small { min-height: 2.75rem; padding: .5rem .9rem; font-size: .875rem; }

/* ---------- Stamp: the only red on the page ---------- */

.stamp {
  display: inline-block;
  max-width: 24ch;
  padding: .45rem .75rem;
  border: 4px double var(--red);
  color: var(--red);
  font-family: var(--mono);
  font-weight: 800;
  font-stretch: 87.5%;
  font-size: .875rem;
  line-height: 1.3;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
  transform: rotate(-4deg);
  mix-blend-mode: multiply;
}

/* ---------- Hero ---------- */

.hero { padding-block: 2rem 4.5rem; }

.hero > .hero-stamp { justify-self: end; }

.hero > .display {
  grid-column: 1 / -1;
  justify-self: center;
  max-width: 76rem;
  margin-inline: var(--gutter);
  margin-block: 2rem 2.25rem;
  text-align: center;
}

.hero > .hero-lead { margin-block-end: 2rem; }

.actions { display: grid; gap: .75rem; }

.hero > .hero-note { margin-block-start: 1.5rem; text-align: center; }

/* ---------- Section heads ---------- */

.grid > .head { margin-block-end: 2.25rem; align-items: end; }
.head > .lead { margin-block-start: 1.5rem; }

/* ---------- Line items with dot leaders ---------- */

.items { list-style: none; padding: 0; }

.item { padding-block: .9rem; }

.line {
  display: flex;
  align-items: baseline;
  align-items: last baseline;
  gap: .75ch;
  font-family: var(--mono);
  font-size: .875rem;
  line-height: 1.5;
}

.qty { flex: none; color: var(--ink-2); }
.label { flex: 0 1 auto; font-weight: 700; }
.leader { flex: 1 1 2ch; min-width: 2ch; height: 1em; border-bottom: 2px dotted var(--ink-2); }
.status { flex: none; font-weight: 700; text-align: right; }

.item > .body { margin-block-start: .35rem; padding-inline-start: 2.25rem; }

/* ---------- B5 offline cases ---------- */

.cases { list-style: none; padding: 0; }
.case { padding-block: 1rem; }
.case + .case { background: var(--dash) left top / 100% 1px no-repeat; }

.case-title,
.rule-title,
.zreport dt,
.list-label,
.spoj-title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: .875rem;
  line-height: 1.5;
}

.case > .body { margin-block-start: .35rem; }

/* ---------- B6 five rules ---------- */

.rules { list-style: none; padding: 0; counter-reset: rule; }

.rules > li { counter-increment: rule; position: relative; padding-block: 1.25rem; }
.rules > li + li::after {
  content: "";
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  margin-inline: var(--pad);
  margin-block-start: -1.25rem;
  height: 1px;
  background: var(--dash);
}

.rules > li::before {
  content: counter(rule);
  grid-column: 2;
  margin-inline: var(--pad);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 2.25rem;
  line-height: 1;
}

.rule-text > .body { margin-block-start: .4rem; }

.rules > li > .source {
  margin-block-start: .6rem;
  font-family: var(--mono);
  font-size: .875rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.rules > li.has-stamp { padding-block-start: 1.75rem; }

.stamp-storno {
  position: absolute;
  top: 1.1rem;
  right: calc(50% - var(--strip) / 2 + var(--pad));
  transform: rotate(-9deg);
}

/* ---------- B7 end-of-day report ---------- */

.zreport {
  padding-block: .75rem;
  background:
    var(--dash) left top / 100% 2px no-repeat,
    var(--dash) left 5px / 100% 2px no-repeat,
    var(--dash) left calc(100% - 5px) / 100% 2px no-repeat,
    var(--dash) left bottom / 100% 2px no-repeat;
}

.z-row { padding-block: 1rem; }
.z-row + .z-row { background: var(--dash) left top / 100% 1px no-repeat; }
.zreport dd { margin-block-start: .35rem; }

/* ---------- B8 first version and later ---------- */

.list-label {
  padding-block-end: .6rem;
  background: var(--dash) left bottom / 100% 2px no-repeat;
}

.ticks { list-style: none; padding: .5rem 0 0; }

.ticks > li {
  position: relative;
  padding-block: .45rem;
  padding-inline-start: 1.6rem;
  font-family: var(--mono);
  font-size: .875rem;
  line-height: 1.5;
}

/* Filled square: in the first version. Hollow square: later. */
.ticks > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .8rem;
  width: .65rem;
  height: .65rem;
  background: var(--ink);
}

.ticks-later > li::before { background: transparent; box-shadow: inset 0 0 0 2px var(--ink); }

.phases > .phase-later { margin-block-start: 2.5rem; }

/* ---------- B4 optional line ---------- */

.block-small { padding-block-end: 3.5rem; }

.spoj-box { padding: 1.25rem; border: 2px dashed var(--ink-2); }
.spoj-note { margin-block-start: .5rem; }
.items-compact { margin-block-start: .5rem; }
.items-compact > .item { padding-block: .3rem; }
.items-compact .label { font-weight: 600; }

/* ---------- Perforation and the torn-off coupon ---------- */

.perf { height: 3.25rem; position: relative; }

.perf > .tear {
  margin-inline: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 1ch;
  padding-inline: var(--pad);
  padding-block-end: .9rem;
  font-family: var(--mono);
  font-size: .75rem;
  line-height: 1.3;
  color: var(--ink-2);
  /* Half holes cut into the bottom edge of the strip. */
  background: radial-gradient(circle at 50% 100%, var(--counter) .42rem, transparent calc(.42rem + .5px)) 0 100% / 1.4rem .9rem repeat-x;
}

.tear::before,
.tear::after {
  content: "";
  flex: 1 1 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--ink-2) 0 .3rem, transparent 0 .55rem);
}

.tear > span { flex: none; max-width: 70%; text-align: center; }

.coupon-zone {
  display: grid;
  justify-items: center;
  padding: 1.75rem .5rem 4.5rem;
}

.coupon {
  position: relative;
  isolation: isolate;
  width: var(--strip);
  padding: 2.75rem 1.25rem 2.25rem;
  transform: rotate(-1.25deg);
}

/* The coupon paper, with the other half of the holes on its top edge. */
.coupon::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--paper);
  -webkit-mask: radial-gradient(circle at 50% 0, transparent .42rem, #000 calc(.42rem + .5px)) 0 0 / 1.4rem 100% repeat-x;
  mask: radial-gradient(circle at 50% 0, transparent .42rem, #000 calc(.42rem + .5px)) 0 0 / 1.4rem 100% repeat-x;
}

/* Cut line of a coupon. */
.coupon::after {
  content: "";
  position: absolute;
  inset: 1.25rem .6rem .6rem;
  z-index: -1;
  border: 2px dashed var(--ink-2);
  pointer-events: none;
}

.coupon-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 1rem + 3.2vw, 4.25rem);
  line-height: 1;
  letter-spacing: -.012em;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.coupon-lead { margin-block-start: 1.25rem; }
.coupon-who { margin-block-start: 1rem; }
.coupon-cta { margin-block-start: 1.75rem; }
.contact { margin-block-start: 1rem; text-align: center; }

/* ---------- Footer, on the counter ---------- */

.foot {
  padding: 0 var(--gutter) 3rem;
  text-align: center;
  font-family: var(--mono);
  font-size: .75rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.foot p { max-width: 60ch; margin-inline: auto; }
.foot p + p { margin-block-start: .5rem; }

/* ---------- Focus and skip link ---------- */

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.btn-reverse:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.skip {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 100;
  padding: .75rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-weight: 700;
  font-size: .875rem;
  text-decoration: none;
}

.skip:focus { top: 1rem; }

/* ---------- The one motion: the receipt header prints, line by line ---------- */

@media (prefers-reduced-motion: no-preference) {
  .receipt-head { animation: feed .45s steps(5, end) backwards; }
  .hero { animation: feed 1s steps(14, end) .3s backwards; }
}

@keyframes feed {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- Narrow only: line items print in the condensed width, like a printer's small font ---------- */

@media (max-width: 44.99rem) {
  .line { font-stretch: 87.5%; }
}

/* ---------- Mid: wider strip, headlines hang over its edge ---------- */

@media (min-width: 45rem) {
  :root {
    --strip: min(36rem, 100% - 4rem);
    --pad: 2rem;
    --gutter: 2rem;
  }

  .head-l > .headline {
    grid-column: 1 / 3;
    margin-inline: var(--gutter) var(--pad);
    text-align: right;
  }

  .head-r > .headline {
    grid-column: 2 / 4;
    margin-inline: var(--pad) var(--gutter);
    text-align: left;
  }

  .coupon-zone { padding-inline: var(--gutter); }
  .coupon { padding-inline: calc(var(--pad) + .75rem); }

  .block { padding-block-end: 5.5rem; }
  .block::before { margin-block-end: 4.5rem; }
}

/* ---------- Wide: notes move into the margins ---------- */

@media (min-width: 73.75rem) {
  :root {
    --strip: 31rem;
    --pad: 2.25rem;
    --gutter: 2.5rem;
  }

  /* Masthead: index on the left counter, call on the right, receipt header on the strip. */
  .masthead > .masthead-bar { display: contents; }

  .masthead-bar > .nav,
  .js .masthead-bar > .nav {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
    margin-inline: var(--gutter) 0;
    padding-block: 2.5rem 0;
  }

  .js .menu-toggle { display: none; }

  .nav-list,
  .js .nav-list {
    display: grid;
    position: static;
    width: auto;
    padding: 0;
    gap: 0;
    background: none;
    border: 0;
  }

  .js .nav-list li + li { background: none; }
  .nav-list a, .js .nav-list a { padding-block: .3rem; }

  .masthead-bar > .head-cta {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    margin-inline: 0 var(--gutter);
    padding-block: 2.5rem 0;
  }

  .masthead > .masthead-rule { grid-row: 2; }

  /* Hero: the lead sits on the counter beside the buttons. */
  .hero > .hero-stamp { grid-row: 1; }
  .hero > .display { grid-row: 2; margin-block: 2.5rem 3rem; }

  .hero > .hero-lead {
    grid-column: 1;
    grid-row: 3 / span 2;
    justify-self: end;
    align-self: start;
    max-width: 24rem;
    margin-inline: var(--gutter) 3rem;
    margin-block-end: 0;
  }

  .hero > .actions { grid-row: 3; }
  .hero > .hero-note { grid-row: 4; }

  /* Section heads: headline over the strip edge, lead in the opposite margin. */
  .head > .headline { grid-row: 1; }

  .head-l > .lead,
  .head-r > .lead {
    grid-row: 1;
    align-self: end;
    max-width: 24rem;
    margin-block-start: 0;
  }

  .head-l > .lead { grid-column: 3; justify-self: start; margin-inline: 3rem var(--gutter); }
  .head-r > .lead { grid-column: 1; justify-self: end; margin-inline: var(--gutter) 3rem; }

  /* Rules: number in the left margin, source in the right one. */
  .rules > li::before {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    margin-inline: 0 1.5rem;
    font-size: 4.5rem;
    line-height: .8;
  }

  .rules > li > .rule-text { grid-row: 1; }

  .rules > li > .source {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    max-width: 18rem;
    margin-inline: 1.75rem var(--gutter);
    margin-block-start: .1rem;
  }

  .rules > li.has-stamp > .rule-text { padding-block-start: 2.5rem; }
  .stamp-storno { top: 1.25rem; }

  /* Later phases lie on the counter beside the printed first version. */
  .phases > .phase-later {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    max-width: 22rem;
    margin-inline: 3rem var(--gutter);
    margin-block-start: 0;
  }

  /* The coupon headline breaks out of the coupon, like the others break out of the strip. */
  .coupon-title { margin-inline: -7rem; }
}
