/**
 * Legal / info pages — design layer.
 *
 * Covers "Všeobecné obchodné podmienky", "Ochrana osobných údajov" and
 * "Informácie o platbe a doručení". These pages had no mockup: the look is built
 * from DESIGN-SYSTEM.md (tokens, card shell, teal buttons, eco-leaf bullets) and
 * the copy is the untouched editor content.
 *
 * Because that content is legacy WPBakery output, this file also neutralizes the
 * vc_row / wpb_* wrappers and restyles the raw HTML the editor produces
 * (h2 / p / ul / table / strong / a). Everything is scoped under .legal.
 */

.legal { margin-bottom: var(--space-9); }

/* ---- Breadcrumb ---------------------------------------------------------- */
.legal-crumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
  font-size: 13px;
  color: var(--muted);
}
.legal-crumbs a { color: var(--muted); }
.legal-crumbs a:hover { color: var(--teal); text-decoration: none; }
.legal-crumbs svg { width: 14px; height: 14px; opacity: .55; flex: none; }
.legal-crumbs .legal-crumbs__current { color: var(--ink); font-weight: 600; }

/* ---- Hero ---------------------------------------------------------------- */
.legal-hero {
  text-align: center;
  max-width: 760px;
  margin: var(--space-7) auto 0;
}
.legal-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--teal-50);
  color: var(--teal);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .02em;
}
.legal-eyebrow svg { width: 16px; height: 16px; }
.legal-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.015em;
  color: var(--ink);
  margin: var(--space-3) 0 0;
}

/* ---- Document card ------------------------------------------------------- */
.legal-doc {
  max-width: 900px;
  margin: var(--space-8) auto 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  box-shadow: var(--shadow-card);
}

/* Neutralize the legacy WPBakery wrappers the page content still ships with. */
.legal-doc .vc_row,
.legal-doc .wpb_column,
.legal-doc .vc_column-inner,
.legal-doc .wpb_wrapper,
.legal-doc .wpb_text_column,
.legal-doc .wpb_content_element {
  margin: 0;
  padding: 0;
  width: auto;
  float: none;
  background: none;
  box-shadow: none;
}

/* ---- Editor content typography ------------------------------------------- */
.legal-doc__body {
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.75;
}
.legal-doc__body .wpb_wrapper > :first-child { margin-top: 0; }
.legal-doc__body .wpb_wrapper > :last-child { margin-bottom: 0; }

.legal-doc__body p { margin: 0 0 var(--space-4); }

.legal-doc__body h2 {
  margin: var(--space-7) 0 var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--line-soft);
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.35;
}
/* A document that opens straight with a heading keeps the card top clean. */
.legal-doc__body .wpb_wrapper > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.legal-doc__body h3 {
  margin: var(--space-6) 0 var(--space-3);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}
/* Some legacy headings carry align="justify" — a heading is never justified. */
.legal-doc__body h2,
.legal-doc__body h3 { text-align: left; }
.legal-doc__body strong { color: var(--ink); font-weight: 700; }
.legal-doc__body a {
  color: var(--teal);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-doc__body address { font-style: normal; }

/* Eco-leaf bullets (design-system list treatment). */
.legal-doc__body ul {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.legal-doc__body ul li {
  position: relative;
  padding-left: var(--space-6);
}
.legal-doc__body ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .3em;
  width: 16px;
  height: 16px;
  background: var(--leaf-green) center / contain no-repeat;
}
.legal-doc__body ol {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
}
.legal-doc__body li + li { margin-top: 0; }

/* Highlighted note — the builder's "note" block (inc/legal-builder.php). Used
   for the standalone bold lines the legacy copy carried between sections. */
.legal-doc__body .legal-note {
  margin: 0 0 var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--teal-50);
  color: var(--ink);
  font-weight: 600;
}

/* ---- Tables (GDPR processor list) ---------------------------------------- */
.legal-table-wrap {
  margin: 0 0 var(--space-5);
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.legal-doc__body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.legal-doc__body th,
.legal-doc__body td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  background: none;
  text-align: left;
  vertical-align: top;
  width: auto;
}
.legal-doc__body th:last-child,
.legal-doc__body td:last-child { border-right: none; }
.legal-doc__body tr:last-child td { border-bottom: none; }
.legal-doc__body thead td,
.legal-doc__body th {
  background: var(--teal-50);
  color: var(--ink);
  font-weight: 700;
}
.legal-doc__body td p { margin: 0; }
.legal-doc__body td p + p { margin-top: var(--space-2); }
/* Legacy tables carry filler rows with no content — hidden, never deleted. */
.legal-doc__body tr.is-blank { display: none; }

/* ---- Help band ----------------------------------------------------------- */
.legal-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-5);
  max-width: 900px;
  margin: var(--space-6) auto 0;
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--teal-50);
}
.legal-help__title {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.legal-help__text {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: 14.5px;
}
.legal-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: 9px;
  background: var(--teal);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.legal-btn:hover { background: var(--teal-600); color: var(--bg); text-decoration: none; }
.legal-btn svg { width: 16px; height: 16px; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 700px) {
  /* Justified legacy copy tears into rivers at phone width. */
  .legal-doc__body p,
  .legal-doc__body li { text-align: left; }
  .legal-title { font-size: 26px; }
  .legal-doc { padding: var(--space-5); }
  .legal-doc__body h2 { font-size: 18px; }
  .legal-help { padding: var(--space-5); }
  .legal-btn { width: 100%; justify-content: center; }
}

/* ---- AI articles: material blocks inside the editor body ------------------
 * wa-ai-writer renders each section as .eko-sec.mat-block, the same shell the
 * hand-built Ekomateriály page uses (icon beside the H2, optional image column
 * that alternates side). pages/ekomaterialy.css already styles that pattern; the
 * three rules here are only where the two layers disagree.
 */

/* The separator moves from the heading to the block. Inside .mat-head the H2 sits
 * next to a 48px icon tile, and a border-top across the pair cuts the icon in
 * half. */
.legal-doc__body .mat-block { border-top: 1px solid var(--line-soft); padding-top: var(--space-6); }
.legal-doc__body .mat-block:first-child { border-top: none; padding-top: 0; }
.legal-doc__body .mat-head h2 { margin: 2px 0 0; padding-top: 0; border-top: none; }

/* The last paragraph of a block sits against the separator of the next one. */
.legal-doc__body .mat-text > :last-child { margin-bottom: 0; }

/* Unfilled slot: the editor sees where the picture goes, in the place it will
 * take. Visitors never get this far — Image_Slots strips the placeholder and the
 * grid classes with it. */
.legal-doc__body .wa-ai-image-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: var(--space-5);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--paper, #fafafa);
}
.legal-doc__body .wa-ai-image-slot figcaption {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* The filled image is a <figure> so wpautop cannot wrap it in a <p> and steal its
 * place in the grid; .mat-media then styles the wrapper, and the image fills it. */
.legal-doc__body figure.mat-media { margin: 0; }
.legal-doc__body figure.mat-media img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

/* Image left, text still wide.
 *
 * pages/ekomaterialy.css does this by reordering the image inside the same
 * "1fr 320px" grid, so the alternate block ends up with a 608px image and a 320px
 * text column. On that page it is the intent — the copy is two short paragraphs
 * next to a decorative photo. An AI article puts three full paragraphs in the same
 * column, and 320px of that reads like a newspaper gutter. Swapping the template
 * instead keeps the zigzag and the line length; scoped to .legal-doc__body, so the
 * material page is untouched. */
.legal-doc__body .mat-block.media-left.has-media { grid-template-columns: 320px minmax(0, 1fr); }

/* wa-ai-writer: a video pinned to a section.
 *
 * The figure is a sibling of .mat-text and .mat-media, so on a block that has a
 * picture it would land in one of the two grid columns. Spanning both keeps the
 * video the width of the section — a 16:9 frame in a 320px column is a stamp.
 * On a block without media the parent is not a grid and the property is ignored,
 * which is exactly the behaviour wanted. */
.legal-doc__body .wa-ai-embed {
  grid-column: 1 / -1;
  margin: var(--space-5) 0 0;
}

.legal-doc__body .wa-ai-embed iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: var(--radius-md);
}

/* Complianz replaces the iframe with its own consent placeholder, which brings
 * its own height. Let it: forcing 16:9 onto a notice clips the button. */
.legal-doc__body .wa-ai-embed .cmplz-placeholder-parent {
  aspect-ratio: auto;
}

/* wa-ai-writer: a PDF catalogue pinned to a section, rendered as a dFlip
 * flipbook.
 *
 * dFlip sizes its canvas from the container, so the figure needs a height of
 * its own — with none it collapses to zero and the book never paints. 4:3 with
 * a floor: on a phone a 16:9 catalogue page is a strip nobody can read. Full
 * width comes from the shared .wa-ai-embed rule above (grid-column: 1 / -1) —
 * this only adds what the flipbook variant needs on top of it.
 *
 * min-width: 0, max-width: 100% and overflow-x: auto exist because dFlip
 * measures its own canvas at init and, left unconstrained, sets an explicit
 * inline pixel width on it — verified on a real page, not assumed. Without a
 * cap here the figure would happily grow to whatever dFlip decided. With the
 * ancestor rule below also in place (which is what keeps dFlip's own
 * measurement honest — see there for why), this settles the figure at exactly
 * its section's width, and overflow-x: auto is the fallback for the case
 * dFlip still wants more room than that (e.g. a very high page-count book):
 * it scrolls inside the figure rather than pushing the layout wider. */
.legal-doc__body .wa-ai-embed.is-flipbook {
  aspect-ratio: 4 / 3;
  min-height: 420px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

.legal-doc__body .wa-ai-embed.is-flipbook > div {
  width: 100%;
  height: 100%;
}

/* wa-ai-writer: keeps dFlip's own width measurement honest, on the pages that
 * actually carry a flipbook.
 *
 * The figure's own min-width/max-width above were not enough by themselves:
 * traced with a getBoundingClientRect() dump at every level from the figure up
 * to <main>, every plain-block ancestor up to .eko-content was shrink-wrapping
 * to dFlip's unconstrained canvas instead of filling its own container — so
 * dFlip, which measures its *container's* width at init, read an
 * already-inflated number and rendered at that size. Clamping the ancestors
 * fixes the cause rather than papering over the effect: dFlip then measures
 * the correct (narrow) width and renders its canvas at that size to begin
 * with, instead of rendering wide and being clipped/scrolled after the fact.
 *
 * Verified resolved on a live article at 390px: document.body.scrollWidth is
 * exactly 390 (no page-level horizontal scroll), the flipbook renders at the
 * section's actual width, and both /kompostovanie/ and
 * /ochrana-osobnych-udajov/ (no flipbook) measure byte-identical to before
 * this rule existed — :has() confines the clamp to pages that need it.
 * Reaches exactly as far up the chain as the trace showed growing
 * (.mat-block/.eko-sec, .legal-doc__body, .eko-content) and no further —
 * .eko-layout and everything above it were already correctly sized. */
.legal-doc__body:has( .wa-ai-embed.is-flipbook ),
.legal-doc__body:has( .wa-ai-embed.is-flipbook ) .mat-block,
.legal-doc__body:has( .wa-ai-embed.is-flipbook ) .eko-sec,
.eko-content:has( .wa-ai-embed.is-flipbook ) {
  min-width: 0;
  max-width: 100%;
}

/* wa-ai-writer: an image the editor pinned unchanged.
 *
 * Same full-width treatment as an embed — it is a sibling of .mat-text and
 * .mat-media, so without the span it would land in one grid column. */
.legal-doc__body .wa-ai-exact {
  grid-column: 1 / -1;
  margin: var(--space-5) 0 0;
}

.legal-doc__body .wa-ai-exact img {
  display: block;
  width: 100%;
  height: auto;
}

.legal-doc__body .wa-ai-exact figcaption {
  margin-top: var(--space-2);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
