/* Einhell Battery Runtime Card — template stylesheet
 *
 * One design, every DIN A format. The card is AUTHORED at A6 trim
 * (105 × 148 mm) and scaled to the chosen format with a single factor:
 *
 *   k = max(trimW / 105, trimH / 148)
 *
 * max(), not min(): the card is a full-bleed piece, so it must cover the
 * sheet. The A series is not a perfect √2 series once rounded to whole mm
 * (105×148 → 148×210 → 210×297 → 297×420), so the card overhangs the sheet
 * by ~0.5 mm on one axis and .page clips it. Scaling non-uniformly to fill
 * exactly would distort the type.
 *
 * Because only the scale changes, every format lays out identically — the
 * same rows fit, the same rows drop. card.js measures in unscaled layout
 * px, so the transform never enters its arithmetic.
 *
 * Sheet geometry (mm), per mode:
 *   trim sheet  : trim, card covers all of it            — what Ctrl+P prints
 *   bleed sheet : trim + 2×(3 bleed + 5 mark zone)       — production sheet
 *
 * Everything is in mm and pt, never px — the card is a physical object.
 */

@font-face{font-family:"Einhell Campaign";src:url("fonts/Einhell_Campaign.ttf") format("truetype");font-weight:400 900;font-style:normal;font-display:block}
@font-face{font-family:"Einhell Technology";src:url("fonts/Einhell_Technology.ttf") format("truetype");font-weight:400 900;font-style:normal;font-display:block}
@font-face{font-family:"Inter";src:url("fonts/Inter-300.ttf") format("truetype");font-weight:300;font-style:normal;font-display:block}
@font-face{font-family:"Inter";src:url("fonts/Inter-400.ttf") format("truetype");font-weight:400;font-style:normal;font-display:block}
@font-face{font-family:"Inter";src:url("fonts/Inter-600.ttf") format("truetype");font-weight:600;font-style:normal;font-display:block}
@font-face{font-family:"Inter";src:url("fonts/Inter-700.ttf") format("truetype");font-weight:700;font-style:normal;font-display:block}

:root{
  /* --- format. card.js overwrites these from data-format; the values here
         are A6 so the template still works with JS disabled. --- */
  --trim-w:105mm; --trim-h:148mm; --k:1;

  /* --- authored design box: A6 trim, insets measured from the trim edge --- */
  --design-w:105mm; --design-h:148mm;
  --margin-x:5.5mm; --margin-top:5.5mm;
  /* bottom inset is tighter than the sides on purpose: it seats the runtime
     block lower and buys the space the block above it needs */
  --margin-bottom:4mm;

  /* --- production constants, the same at every format --- */
  --bleed:3mm; --mark-len:5mm;
  --inset:0mm;        /* sheet edge -> trim edge */
  --ground-out:0mm;   /* how far the ground reaches past the trim edge */

  /* --- colours. Every screen colour has a `-cmyk` twin (C M Y K, 0–100):
         the PDF/X-4 export (pdf.js) looks each rendered colour up in these
         pairs and writes the CMYK value verbatim — no conversion. A colour
         without a twin is converted naively and reported as a warning, so
         add a pair here for anything new you put on the card. --- */
  --red:#D50B1E;     --red-cmyk:0 100 100 0;
  --grey:#868489;    --grey-cmyk:0 0 0 60;
  --silver:#ADAFB1;  --silver-cmyk:0 0 0 35;     /* PXC battery outline */
  --white:#FFFFFF;   --white-cmyk:0 0 0 0;
  --black:#000000;   --black-cmyk:0 0 0 100;
  /* Card ground. On press this is C40 M20 Y0 K100 (TAC 160 %).
     The darker screen value reads the way the printed solid does in context. */
  --ground:#0A0D14;  --ground-cmyk:40 20 0 100;
  /* runtime tiles: sizes in the sorting selection dark grey, the others
     light grey; the recommended size gets a frame. renderer.php takes
     these from its settings (panel "Runtime chips"). */
  --chip-sel:#5A5A5C;   --chip-sel-cmyk:0 0 0 75;
  --chip-other:#C4C4C6; --chip-other-cmyk:0 0 0 25;
  --chip:var(--chip-sel);

  /* Professional ground (PROFESSIONAL = true), top to bottom:
     20 % C3 M100 Y91 K9  ->  10 % C0 M83 Y81 K0  ->  70 % ground.
     Stops are measured on the TRIM height, so the bleed does not shift them.
     Default for the bare template — renderer.php takes it from its settings
     (UI: Professional background). */
  --pro-a:#BE1622;   --pro-a-cmyk:3 100 91 9;
  --pro-b:#E4423A;   --pro-b-cmyk:0 83 81 0;
  --pro-stop-a:0;    --pro-stop-b:0.2;   --pro-stop-c:0.3;

  /* hairlines are painted as background bands, not borders: browsers snap
     border widths to whole device pixels (0.25 pt would print as 0.75 pt),
     background geometry is exact */
  --hair:0.25pt;
  --rule-w:0.6mm;
}

/* Which sheet, via data-sheet on <html>:
     (none)  screen shows the production sheet, print gives the trimmed card
     "bleed" production sheet everywhere — 3 mm bleed + 5 mm mark zone
     "trim"  trimmed card everywhere, no marks
   Crop marks and the info slug follow whichever sheet is active. */
@media screen{
  html:not([data-sheet="trim"]){ --inset:8mm; --ground-out:3mm; }
  html[data-sheet="trim"] .mark,
  html[data-sheet="trim"] .slug{display:none}
}
@media print{
  html[data-sheet="bleed"]{ --inset:8mm; --ground-out:3mm; }
  html:not([data-sheet="bleed"]) .mark,
  html:not([data-sheet="bleed"]) .slug{display:none}
}

*{box-sizing:border-box}
html{background:#f5f5f4}
body{
  margin:0;
  font-family:'Inter',sans-serif;
  /* one character = one glyph: the PDF export maps characters to glyphs
     through the font's cmap and has no shaping engine. Kerning stays on —
     the export takes every glyph position from the browser's layout. */
  font-variant-ligatures:none;
  font-feature-settings:"liga" 0,"clig" 0,"calt" 0;
  /* unhinted glyph advances: hinting rounds advances at the unscaled
     layout size, which the format scale then magnifies into visible gaps
     ("FEAT URES") — and print needs the font's real metrics anyway */
  text-rendering:geometricPrecision;
  -webkit-print-color-adjust:exact;
  print-color-adjust:exact;
}

/* Ctrl+P prints the chosen format as a real sheet. card.js rewrites this
   rule per format; the A6 value here is the no-JS fallback.
   Written out in mm, not as `size: A6`: CSS Paged Media only defines the
   keywords A5/A4/A3/B5/B4/JIS-B5/JIS-B4/letter/legal/ledger, so `A6` is an
   invalid value that browsers drop — which puts us back on the default
   paper, scaled to fit. */
@page{size:105mm 148mm;margin:0}

.page{
  position:relative;
  width:calc(var(--trim-w) + 2 * var(--inset));
  height:calc(var(--trim-h) + 2 * var(--inset));
  background:var(--white);
  overflow:hidden;      /* clips the ~0.5 mm scaling overhang */
}

/* ---- crop marks: production constants, they do not scale ---- */
.mark{position:absolute}
.page.no-marks .mark{display:none}
.mark.h{width:var(--mark-len);height:0;border-top:0.25pt solid #000}
.mark.v{height:var(--mark-len);width:0;border-left:0.25pt solid #000}
.mark.tl{left:0;top:var(--inset)}
.mark.tr{right:0;top:var(--inset)}
.mark.bl{left:0;bottom:var(--inset)}
.mark.br{right:0;bottom:var(--inset)}
.mark.lt{top:0;left:var(--inset)}
.mark.rt{top:0;right:var(--inset)}
.mark.lb{bottom:0;left:var(--inset)}
.mark.rb{bottom:0;right:var(--inset)}

.slug{
  position:absolute;left:var(--inset);bottom:1.5mm;
  font:5pt/1 'Inter',sans-serif;color:#000;letter-spacing:0.03em;
}
.page.no-marks .slug{display:none}

/* ---- the ground: trim plus bleed, unscaled ---- */
.ground{
  position:absolute;
  left:calc(var(--inset) - var(--ground-out));
  top:calc(var(--inset) - var(--ground-out));
  width:calc(var(--trim-w) + 2 * var(--ground-out));
  height:calc(var(--trim-h) + 2 * var(--ground-out));
  background:var(--ground);
}
/* conditional ground — card.js sets .is-professional from PROFESSIONAL.
   The model name turns white there: Einhell red on the red top of the
   gradient is unreadable. */
.page.is-professional .model{color:var(--white)}

/* optional white ground for normal cards (WHITE_BG, set in the renderer's
   settings): no ground, the type that sits on it turns black; the runtime
   tiles keep their colours; the battery line gets a black rounded box */
.page.is-white-bg .ground{background:none}
.page.is-white-bg .type,
.page.is-white-bg .rule-label,
.page.is-white-bg .rule-item,
.page.is-white-bg table.t,
.page.is-white-bg .rt-sub,
.page.is-white-bg .note,
.page.is-white-bg .rec-legend{color:var(--black)}
.page.is-white-bg .batt{background:var(--ground);color:var(--white);border-radius:1mm;padding:0.6mm 1.2mm}
/* runtime tiles: red on normal cards, black on Professional ones
   (renderer.php takes the colour from its settings) */

.page.is-professional .ground{
  /* base under the gradient: where a viewer or RIP shows a seam at the
     edge of the shading, the base shows through, not paper white */
  background-color:var(--ground);
  --pdf-bg-cmyk:40 20 0 100;
  background-image:linear-gradient(to bottom,
    var(--pro-a) calc(var(--ground-out) + var(--trim-h) * var(--pro-stop-a)),
    var(--pro-b) calc(var(--ground-out) + var(--trim-h) * var(--pro-stop-b)),
    var(--ground) calc(var(--ground-out) + var(--trim-h) * var(--pro-stop-c)));
  /* CMYK of the stops, in order — pdf.js writes these verbatim.
     renderer.php replaces this whole rule with the one from its settings. */
  --pdf-gradient-cmyk:3 100 91 9 / 0 83 81 0 / 40 20 0 100;
}

/* ---- the card: laid out at the authored A6 box, scaled onto the trim box
       and centred on it. A flex column — everything above .runtime flows
       from the top, .runtime takes the leftover space as margin and sits on
       the bottom inset. ---- */
.card{
  position:absolute;
  left:calc(var(--inset) + (var(--trim-w) - var(--design-w) * var(--k)) / 2);
  top:calc(var(--inset) + (var(--trim-h) - var(--design-h) * var(--k)) / 2);
  width:var(--design-w);
  height:var(--design-h);
  transform:scale(var(--k));
  transform-origin:top left;
  padding:var(--margin-top) var(--margin-x) var(--margin-bottom);
  color:var(--white);
  display:flex;flex-direction:column;
}

.head{display:flex;justify-content:space-between;align-items:flex-start;gap:3mm}
.logo{height:8.5mm;width:auto;display:block}
/* Professional logo (LOGO slot, Professional variant): 1.2x as high, same
   top-left corner — the head aligns to the top, the logo comes first */
.logo.is-pro{height:calc(8.5mm * 1.2)}
/* optional asset slot (asset pool), top right; removed when unassigned */
.badge{height:8.5mm;width:auto;max-width:40mm;display:block;object-fit:contain}

/* Fonts, weights, sizes and uppercase of the text elements are defaults —
   renderer.php overrides them from its Typography settings. */
.type{
  margin-top:6mm;
  font-family:'Inter',sans-serif;font-weight:700;
  font-size:14pt;line-height:1.05;text-transform:uppercase;
  color:var(--white);text-wrap:balance;
}
.model{
  margin-top:1.8mm;
  font-family:'Inter',sans-serif;font-weight:400;font-size:12pt;line-height:1;
  color:var(--red);
}

/* ---- section rules: label + red underline ---- */
.rule{
  display:flex;justify-content:space-between;align-items:baseline;
  padding-bottom:calc(1.2mm + var(--rule-w));
  background:linear-gradient(to top, var(--red) var(--rule-w), transparent var(--rule-w));
}
/* --fit: 1, or less when features + technical data must shrink to fit the
   card (card.js fitScale) — nothing is ever dropped */
.card{--fit:1}
.rule.specs{margin-top:calc(3.5mm * var(--fit))}
.rule.tech{margin-top:calc(3mm * var(--fit))}
.rule.runtime{gap:3mm;padding-bottom:calc(0.8mm + var(--rule-w))}   /* line a touch closer */
.rule-label{
  font-family:'Inter',sans-serif;font-weight:600;font-size:7.5pt;
  letter-spacing:0.03em;text-transform:uppercase;color:var(--white);
  text-wrap:balance;
}
.rule-item{font-family:'Inter',sans-serif;font-weight:600;font-size:7.5pt;color:var(--white)}

/* ---- tables ---- */
table.t{width:100%;border-collapse:separate;border-spacing:0;font-family:'Inter',sans-serif;color:var(--white)}
table.features{font-size:calc(8pt * var(--fit));line-height:1.2}
table.spec{font-size:calc(8pt * var(--fit));line-height:1.15}
table.t td{
  padding:calc(1.2mm * var(--fit)) 0 calc(1mm * var(--fit) + var(--hair)) 0;vertical-align:top;
  background:linear-gradient(to top, var(--grey) var(--hair), transparent var(--hair));
}
/* bullet: red square, slightly rounded, centred on the cap height of the
   first line (line box 1.2em, cap centre ~0.6em for Inter) */
td.bullet{width:calc(4mm * var(--fit))}
td.bullet .sq{display:block;width:0.46em;height:0.46em;border-radius:0.09em;
  background:var(--red);margin-top:0.37em}   /* 1.3 mm at 8 pt, scales with the type */
td.feature{font-weight:700;text-wrap:pretty}
td.spec-label{font-weight:600;width:55%}
td.spec-value{font-weight:300;text-align:right}
/* yes/no features (lib/feature_rules.php): vector tick / cross, sized to the type */
td.spec-value svg.bool{display:inline-block;width:0.95em;height:0.95em;vertical-align:-0.12em}

/* ---- runtime block, anchored to the bottom ---- */
.runtime{margin-top:auto;padding-top:3mm}
.batt{
  display:flex;align-items:center;gap:1.2mm;
  font-family:'Inter',sans-serif;font-weight:600;font-size:8pt;
  color:var(--white);white-space:nowrap;
}
.batt img{height:4.5mm;width:auto;display:block}
.rt-sub{margin-top:1.5mm;font-family:'Inter',sans-serif;font-weight:300;font-size:7.5pt;color:var(--white)}

.tiles{display:flex;gap:0.8mm;margin-top:2.5mm}
.tile{
  position:relative;
  flex:1 1 0;min-width:0;background:var(--chip);
  padding:1.8mm 0.8mm 1.6mm;
  display:flex;flex-direction:column;align-items:center;gap:1.8mm;
}
.tile>*{max-width:100%}
.tile.is-other{--chip:var(--chip-other)}

/* recommended size: rounded frame around the tile with ~2 px inner space,
   the legend as red type inside the frame, above the tile */
/* --rec-b = stroke width (settings: runtime chips); on .card so the row
   spacing below can make room for a thicker frame */
.card{--rec-pad:0.5mm;--rec-b:0.3mm;--rec-lh:2mm}
.tile>.rec-frame{display:none;position:absolute;max-width:none;pointer-events:none;
  top:calc(-1 * (var(--rec-pad) + var(--rec-b) + var(--rec-lh)));
  right:calc(-1 * (var(--rec-pad) + var(--rec-b)));
  bottom:calc(-1 * (var(--rec-pad) + var(--rec-b)));
  left:calc(-1 * (var(--rec-pad) + var(--rec-b)));
  border:var(--rec-b) solid var(--red);border-radius:1.1mm}
.tile>.rec-frame:empty{top:calc(-1 * (var(--rec-pad) + var(--rec-b)))}   /* second row: no legend */
.tile.is-rec>.rec-frame{display:block}
.rec-legend{position:absolute;left:0;right:0;top:0.35mm;text-align:center;
  color:var(--white);font-family:'Inter',sans-serif;font-weight:600;font-size:4.5pt;line-height:1;
  letter-spacing:0.02em;white-space:nowrap}
/* ~2 px between the frame and the neighbouring tiles; the others keep
   their spacing. Room above the row for the frame's legend. */
.tile.is-rec{margin:0 calc(var(--rec-pad) + var(--rec-b))}
.tiles.has-rec{margin-top:calc(3.3mm + var(--rec-b))}
/* value + unit; with one matrix it is transparent and the whole tile is the box */
.tile-box{align-self:stretch;display:flex;flex-direction:column;align-items:center;gap:1.8mm}
.tile-box>*{max-width:100%}
.tile-label{
  background:var(--white);color:#000;border-radius:0.35mm;
  /* Einhell Technology sits low in its line box: less padding on top than
     below centres the figures optically; in em so it holds at any size */
  padding:0.16em 0.3em 0.34em;
  font-family:'Einhell Technology','Inter',sans-serif;font-size:6pt;line-height:1;
  white-space:nowrap;
}
.tile-num{font-family:'Inter',sans-serif;font-weight:700;font-size:12pt;line-height:1;color:var(--white);white-space:nowrap}
.tile-unit{font-family:'Inter',sans-serif;font-weight:600;font-size:7pt;line-height:1;color:var(--white);white-space:nowrap;
  min-height:1em}   /* an empty unit ("–" tiles) keeps the row height */

/* ---- two PXC matrices (RUNTIME_2): row 1 = Ah label + value + unit in
       one box as before, only more compact; row 2 = value + unit, under
       its own condition line ---- */
.page.is-runtime-2 .rt-sub{line-height:1.1}
.page.is-runtime-2 .tiles{margin-top:0.8mm}
.page.is-runtime-2 .tiles.has-rec{margin-top:calc(2.9mm + var(--rec-b))}
.page.is-runtime-2 .tiles.has-rec + .rt2 > .rt-sub{margin-top:calc(1.2mm + var(--rec-b))}
.page.is-runtime-2 .tile{padding:1.2mm 0.6mm 1mm;gap:0.9mm}
.page.is-runtime-2 .tile-box{gap:0.7mm}
.page.is-runtime-2 .tile-num{font-size:10.5pt}
.page.is-runtime-2 .tile-unit{font-size:6.5pt}
.rt2 .rt-sub{margin-top:0.9mm}
.rt2 .tiles{margin-top:0.8mm}
.page.is-runtime-2 .rt2 .tiles.has-rec{margin-top:calc(1mm + var(--rec-b))}

.note{margin-top:1.5mm;font-family:'Inter',sans-serif;font-weight:300;font-size:5.5pt;line-height:1.2;color:var(--white)}

/* ---- preview only ----
   card.js adds .demo while any {{PLACEHOLDER}} is still in the markup, and
   drops it on fill(). Placeholder names are longer than real values, so the
   runtime rule's single no-wrap row would otherwise push the Power X-Change
   graphic off the card. Nothing here affects a filled card. */
.page.demo .rule.runtime .rule-label,
.page.demo .batt{font-size:6pt}
.page.demo .batt img{height:3.6mm}

/* ---- screen chrome, never printed ---- */
@media screen{
  body{padding:24px}
  .page{margin:0 auto;box-shadow:0 2px 10px rgba(0,0,0,.25)}
  /* card.js sets this when the card is in a preview frame */
  body.embedded{padding:0;background:#fff}
  body.embedded .page{box-shadow:none}
}

@media print{
  html,body{background:#fff;padding:0;margin:0}
  .page{margin:0;box-shadow:none}
}
