/* ----------------------------------------------------------------------
   Sabina Mácha — portfolio
   Reference design: 1920×1080 frames, one stacked per screen.
   Page chrome (margins, gaps, radius) scales with the viewport and caps
   at the original design values; type scales with its own card via
   container-query units (cqi), so it stays proportional in any layout.
   ---------------------------------------------------------------------- */

:root {
  --bg: #ffffff;
  --line: #161616;
  --text: #000000;
  --accent: #ff87b1; /* same pair as the cursors: pink light, teal dark */

  --radius: clamp(24px, 2.083vw, 40px);   /* 40 @ 1920 */
  --gap-col: clamp(12px, 1.25vw, 24px);   /* 24 @ 1920 */
  --gap-row: clamp(20px, 2.292vw, 44px);  /* 44 @ 1920 */

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #000000;
  --line: #f4f4f4;
  --text: #ffffff;
  --accent: #fe5d40;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  /* 36px intrinsic size — a touch above a normal OS cursor; hotspot = arrow tip */
  cursor: url("/cursors/cursor-light.svg") 4 4, auto;
  scroll-behavior: smooth;
  scroll-snap-type: y proximity;
}

html[data-theme="dark"] {
  cursor: url("/cursors/cursor-dark.svg") 4 4, auto;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.25s ease, color 0.25s ease;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  padding: 0;
  cursor: inherit; /* keep the custom cursor over clickable tiles */
}

[hidden] {
  display: none !important;
}

/* --- Top-right controls (language + theme) in the first screen's band,
       flush with the content's right edge; they scroll away with the
       page. Theme icon per design: 32×32 at left 1688, top 40 @ 1920×1080. --- */

.top-controls {
  position: absolute;
  top: clamp(16px, 3.704dvh, 40px);                                   /* 40/1080 */
  right: max(clamp(20px, 10.417vw, 200px), calc((100vw - 1520px) / 2));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.25vw, 24px);
}

.lang-toggle {
  border: 0;
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: 0.04em;
  color: var(--line);
}

.lang-toggle:hover {
  opacity: 0.65;
}

.theme-toggle {
  width: 32px;
  height: 32px;
  border: 0;
  display: grid;
  place-items: center;
  color: var(--line);
}

.theme-toggle svg {
  display: block;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--line);
  outline-offset: 4px;
  border-radius: 50%;
}

/* The icon shows the mode you switch TO: moon in light, sun in dark */
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* --- Full-height screens: 200px sides, 156px top/bottom @ 1920×1080 --- */

.frame {
  position: relative;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(72px, 14.45dvh, 156px) clamp(20px, 10.417vw, 200px);
  scroll-snap-align: start;
}

.content {
  width: 100%;
  max-width: 1520px; /* 1920 − 2×200 */
}

/* Scroll hint: a plain arrow centred in the bottom band of screen 1 */

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: calc((clamp(72px, 14.45dvh, 156px) - 32px) / 2);
  translate: -50% 0;
  color: var(--line);
}

.scroll-hint svg {
  display: block;
}

/* --- Cards --- */

.card {
  border: 1px solid color-mix(in srgb, var(--line) 20%, transparent);
  border-radius: var(--radius);
  transition: border-color 0.25s ease, background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

/* Sharp accent drop shadow (pink in light, orange in dark) offset to the
   bottom-right so it overhangs that corner. The sphere has its own
   gradient; the overlay sits on a solid backdrop. */
.card:not(.tile--empty):not(.overlay-card) {
  box-shadow: 12px 12px 5px -1px color-mix(in srgb, var(--line) 8%, transparent);
}

a.card,
button.card {
  text-decoration: none;
}

/* Interactive cards fill with the accent on hover — border melts into
   the fill, text goes white. The sphere (.tile--empty) is excluded;
   it has its own gradient. */
a.card:hover,
button.card:not(.tile--empty):hover,
a.card:focus-visible,
button.card:not(.tile--empty):focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* Light theme only: hovered tile text turns blue instead of white.
   Dark theme keeps white text on the orange fill. */
html:not([data-theme="dark"]) a.card:hover,
html:not([data-theme="dark"]) button.card:not(.tile--empty):hover,
html:not([data-theme="dark"]) a.card:focus-visible,
html:not([data-theme="dark"]) button.card:not(.tile--empty):focus-visible {
  color: #0065f9;
}

/* Over the accent fill the cursor goes white (same arrow, white +
   half-transparent white inner layer) in both themes. */
a.card:hover,
button.card:not(.tile--empty):hover {
  cursor: url("/cursors/cursor-white.svg") 4 4, pointer;
}

/* --- Landing grid ---
   Columns 1134 : 362, column gap 24 @ 1920. The grid's own aspect ratio
   pins its height to 768 @ 1920, and the two rows split it evenly
   (362 + 44 + 362) — explicit fr rows so hover can animate them. */

.tiles {
  display: grid;
  grid-template-columns: 1134fr 362fr;
  grid-template-rows: 362fr 362fr;
  aspect-ratio: 1520 / 768;
  column-gap: var(--gap-col);
  row-gap: var(--gap-row);
}

/* --- Hero card --- */

.card--hero {
  grid-row: 1 / 3;
  display: grid;
  grid-template: 1fr / 1fr;  /* the two text copies + the water share one cell */
  position: relative;
  overflow: hidden;          /* clip the water fill to the rounded card */
  container-type: inline-size;
  --hero-water: #0065f9;     /* fill colour — light theme */
}

[data-theme="dark"] .card--hero {
  --hero-water: #f4f4f4;     /* a light fill in dark theme */
}

.card--hero .hero-layer {
  grid-area: 1 / 1;          /* stack both copies exactly */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 9.26%;            /* 105/1134 — title indent in the frame */
}

.card--hero .hero-layer:not(.hero-layer--fill) { z-index: 1; }

/* the water rising from the bottom up to where the cursor is */
.card--hero .hero-fill {
  grid-area: 1 / 1;
  align-self: end;           /* anchored to the card's bottom edge */
  z-index: 0;
  height: var(--hero-fill, 0px);
  background: var(--hero-water);
  pointer-events: none;
  transition: height 0.2s ease;
}

/* an accent-coloured copy of the text, revealed only where the water has risen */
.card--hero .hero-layer--fill {
  z-index: 2;
  color: var(--accent);
  pointer-events: none;
  clip-path: inset(calc(100% - var(--hero-fill, 0px)) 0 0 0);
  transition: clip-path 0.2s ease;
}

/* The tagline reads in the card's own colour on the fill (white on the blue in
   light theme, black on the light fill in dark theme); the name stays accent. */
.card--hero .hero-layer--fill .tagline { color: #fff; }
[data-theme="dark"] .card--hero .hero-layer--fill .tagline { color: #000; }

.card--hero h1 {
  margin: 0;
  font-weight: 700;
  font-size: clamp(2.5rem, 13.668cqi, 9.6875rem); /* 155/1134 */
  line-height: 1.1613;                            /* 180/155 */
}

.card--hero .tagline {
  margin: clamp(1.25rem, 3.88cqi, 2.75rem) 0 0;   /* 44/1134 */
  font-weight: 400;
  font-size: clamp(1rem, 2.91cqi, 2.0625rem);     /* 33/1134 */
  line-height: 1.1515;                            /* 38/33 */
}

/* --- Landing square tiles --- */

.tile {
  container-type: inline-size;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0; /* the fr tracks alone decide tile sizes */
}

/* The orb is a holographic SVG that gently pulsates (scales) in place.
   The pulse animates `scale`; the click "boing" animates `transform`
   (via the Web Animations API), so the two compose without conflict. */

button.tile--empty {
  /* Figma: 290×290 ball at (1398, 208) inside the 362 cell at (1358, 156)
     → insets 52/32/20/40, kept as percentages of the cell so it scales. */
  margin: 14.365% 7.84% 4.525% 11.05%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: none; /* the <canvas> (added by JS) draws the water-fill orb */
}

/* Water-fill orb canvas fills the (square) tile. */
button.tile--empty canvas {
  display: block;
  width: 100%;
  height: 100%;
}

@keyframes orb-pulse {
  0%, 100% { scale: 1; }
  50%      { scale: 1.06; }
}

/* The boing squash runs via the Web Animations API (see main.js) — a
   CSS class swap would replace the animation list and restart the
   sphere-pulse gradient mid-breath. */

/* Comic sound-effect labels spawned at the click point */

.boing-label {
  position: fixed;
  z-index: 20;
  font-weight: 700;
  font-style: italic;
  font-size: clamp(1.5rem, 2.1vw, 2.5rem);
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  animation: boing-label 0.9s ease-out both;
}

@keyframes boing-label {
  0%       { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(var(--rot, 0deg)); }
  18%      { opacity: 1; transform: translate(-50%, -68%) scale(1.25) rotate(var(--rot, 0deg)); }
  30%      { transform: translate(-50%, -62%) scale(0.95) rotate(var(--rot, 0deg)); }
  42%      { transform: translate(-50%, -66%) scale(1.05) rotate(var(--rot, 0deg)); }
  55%, 70% { opacity: 1; transform: translate(-50%, -64%) scale(1) rotate(var(--rot, 0deg)); }
  100%     { opacity: 0; transform: translate(-50%, -130%) scale(1) rotate(var(--rot, 0deg)); }
}

.tile--kontakt span {
  font-weight: 700;
  font-size: clamp(1.25rem, 12.431cqi, 2.8125rem); /* 45/362 */
  line-height: 1.4889;                             /* 67/45 */
}

/* --- Work masonry (screen 2) ---
   @ 1920: tall left tile 362×768, then a uniform 44 gap everywhere.
   Produkt and Typografie stay 362 squares; the two wide tiles absorb
   the rest (708 each): 362 + 44 + (362 + 44 + 708) = 1520. */

.work {
  display: grid;
  grid-template-columns: 362fr 1114fr;
  aspect-ratio: 1520 / 768;
  column-gap: var(--gap-row); /* 44 @ 1920 — same as between the rows */
  container-type: inline-size;
}

.work-right {
  display: grid;
  grid-template-rows: 362fr 362fr;
  row-gap: var(--gap-row);
}

.work-row {
  display: grid;
  column-gap: var(--gap-row);
}

.work-row--1 {
  grid-template-columns: 362fr 708fr;
}

.work-row--2 {
  grid-template-columns: 708fr 362fr;
}

.wtile {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8%;
  min-width: 0;
  min-height: 0; /* the fr tracks alone decide tile sizes */
}

.wtile span {
  font-weight: 700;
  font-size: clamp(1.25rem, 2.961cqi, 2.8125rem); /* 45/1520 of the section */
  line-height: 1.4889;                            /* 67/45 */
}

/* --- Hover: the hovered tile expands, its neighbours cede space.
       Track sums stay constant, so gaps and outer edges never move.

       TEMPORARILY DISABLED — remove this comment block's outer markers
       (and the closing one below) to re-enable.

@media (hover: hover) and (min-width: 861px) {
  .tiles,
  .work,
  .work-right,
  .work-row {
    transition:
      grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1),
      grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .tiles:has(.card--hero:hover)   { grid-template-columns: 1214fr 282fr; }
  .tiles:has(.tile--empty:hover),
  .tiles:has(.tile--kontakt:hover) { grid-template-columns: 1054fr 442fr; }
  .tiles:has(.tile--empty:hover)   { grid-template-rows: 442fr 282fr; }
  .tiles:has(.tile--kontakt:hover) { grid-template-rows: 282fr 442fr; }

  .work:has(.wtile--viz:hover)     { grid-template-columns: 442fr 1034fr; }
  .work:has(.work-right :hover)    { grid-template-columns: 302fr 1174fr; }

  .work-right:has(.work-row--1 :hover) { grid-template-rows: 422fr 302fr; }
  .work-right:has(.work-row--2 :hover) { grid-template-rows: 302fr 422fr; }

  .work-row--1:has(.wtile--produkt:hover)    { grid-template-columns: 442fr 628fr; }
  .work-row--1:has(.wtile--profilovky:hover) { grid-template-columns: 282fr 788fr; }
  .work-row--2:has(.wtile--videa:hover)      { grid-template-columns: 788fr 282fr; }
  .work-row--2:has(.wtile--typografie:hover) { grid-template-columns: 628fr 442fr; }
}
   END temporarily disabled hover expansion */

/* --- Tile overlay ---
   Design: 1262×700 centred @ 1920×1080 (left 329, top 190), heading
   104 from the card's left edge and 73 from its top. */

.overlay-card {
  /* Same footprint as the masonry content area: 1520×768 @ 1920×1080,
     i.e. it opens exactly over the grid (200, 156). */
  --card-pad-x: min(104px, 5.417vw);
  --gutter: clamp(14px, 1.15vw, 22px); /* keeps photos clear of the scrollbar */
  width: min(1520px, 79.167vw);
  height: min(768px, 71.111dvh);
  /* % padding on a <dialog> resolves against the viewport, so these are
     viewport units mirroring the card's own scale: 73/1080, 104/1920 */
  padding: min(73px, 6.759dvh) var(--card-pad-x);
  background: var(--bg);
  color: var(--text);
  view-transition-name: flip-card;
}

/* Scoped to [open]: a bare display override would make the CLOSED dialog
   render as an invisible click-blocking box over the page. */
.overlay-card[open] {
  display: flex;
  flex-direction: column;
}

.overlay-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* the inner scroller (.vscroll / .carousel) scrolls */
}

.contact-stack {
  margin-top: auto; /* bio + contact links sit at the card's bottom */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  row-gap: clamp(16px, 1.25vw, 24px);
}

/* Bio paragraph above the contact links — wraps to a readable couple of lines. */
.contact-bio {
  margin: 0 0 clamp(20px, 2.2vw, 42px); /* extra gap below → sits a little higher above the contacts */
  max-width: min(52ch, 100%);
  font-weight: 400;
  font-size: clamp(1rem, 1.719vw, 2.0625rem); /* same size as the e-mail / links */
  line-height: 1.4;
  color: var(--text);
}

.contact-link {
  /* Table-like: a fixed icon column (widest icon = 28px) so the text
     in every row starts at the same x. */
  display: grid;
  grid-template-columns: 28px auto;
  align-items: center;
  column-gap: clamp(12px, 1.042vw, 20px);
  color: var(--text);
  text-decoration: none;
  font-weight: 400;
  font-size: clamp(1rem, 1.719vw, 2.0625rem); /* 33/1920 */
  line-height: 1.1515;                        /* 38/33 */
}

.contact-link svg {
  display: block;
  justify-self: center;
}

.contact-link:hover span,
.contact-link:focus-visible span {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

/* --- Overlay content: placeholders until the real work goes in --- */

.placeholder-surface {
  border: 1px solid var(--line);
  border-radius: 8.87px; /* media corner radius from the design */
  background: repeating-linear-gradient(
    45deg,
    transparent 0 18px,
    color-mix(in srgb, var(--line) 12%, transparent) 18px 19px
  );
}

/* Videa: a row of three video cards (thumbnail + name + work done). */

.videa {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 1.667vw, 32px);
  align-content: center;
}

.videa-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.videa-thumb {
  aspect-ratio: 16 / 9;
  border: 0; /* real thumbnails: no border */
  border-radius: 8.87px; /* rounded corners */
  padding: 0;
  cursor: inherit;
  background-color: color-mix(in srgb, var(--line) 8%, transparent);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: transform 0.25s ease;
}

.videa-thumb svg {
  width: clamp(40px, 3vw, 56px);
  height: auto;
}

.videa-thumb:hover {
  transform: scale(1.02);
}

.videa-name {
  margin: clamp(10px, 0.83vw, 16px) 0 0;
  font-weight: 700;
  font-size: clamp(1rem, 1.15vw, 1.375rem);
  line-height: 1.25;
}

.videa-name a {
  color: inherit;
  text-decoration: none;
}

.videa-name a:hover,
.videa-name a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.videa-work {
  margin: clamp(2px, 0.3vw, 6px) 0 0;
  font-weight: 400;
  font-size: clamp(0.85rem, 0.95vw, 1.125rem);
  line-height: 1.4;
  color: color-mix(in srgb, var(--text) 65%, transparent);
}

/* Mobile: stack the video cards */
@media (max-width: 860px) {
  .videa {
    grid-template-columns: 1fr;
    overflow-y: auto;
    align-content: start; /* flow from the top — don't centre-crop the first card */
  }
}

/* --- Overlay scroller (Typografie, Vizuální identita, Produktové fotky) ---
   Sections stack; the card scrolls with a slim scrollbar — no arrows. */

/* Pager wraps the scroller and holds the up/down nav — the arrows replace the
   scrollbar entirely. */
.vpager {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.vscroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden; /* a hover-scaled tile must not trigger a horizontal bar */
  scroll-snap-type: y proximity;
  scrollbar-width: none; /* navigated with the up/down arrows */
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 4dvh, 56px);
  container-type: size;
}

.vscroll::-webkit-scrollbar {
  display: none;
}

/* Up/down pager arrows. The left cluster lines up with the card heading; the
   right cluster lines up with the close cross. */
.vnav {
  position: absolute;
  bottom: clamp(6px, 1.5dvh, 18px);
  z-index: 2;
  display: flex;
  gap: clamp(6px, 0.6vw, 12px);
}

.vnav--left { left: 0; bottom: 50px; } /* line up with the bottom photo row */
.vnav--right { right: var(--gutter); }

.vnav-btn {
  width: 32px;
  height: 32px;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: none;
  color: var(--line);
  cursor: inherit;
}

.vnav-btn svg { display: block; width: 22px; height: 13px; }
.vnav-up svg { rotate: 180deg; }
.vnav-btn:hover { opacity: 0.6; }
.vnav-btn:disabled { opacity: 0.25; cursor: default; }

.vsection {
  flex: none;
  height: 100%;         /* one card-height per section; scroll between them */
  scroll-snap-align: center;
  position: relative;   /* positioning context for viz's absolute layout */
}

/* Typografie: a small text block (left-aligned with the heading) beside a
   big book image. */
.typo-screen {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* text pinned left, aligned with the heading */
  gap: clamp(24px, 3vw, 56px);
}

.typo-text {
  flex: 0 0 30%; /* wider so the book title wraps later */
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.3vw, 6px); /* tight, like the video labels */
}

.typo-book-group {
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.3vw, 6px);
}

.typo-book {
  font-weight: 700;
  font-size: clamp(1rem, 1.15vw, 1.375rem);
  line-height: 1.25;
}

.typo-activity {
  font-weight: 400;
  font-size: clamp(1rem, 1.15vw, 1.375rem);
  line-height: 1.25;
}

.typo-author {
  font-weight: 400;
  font-size: clamp(0.85rem, 0.95vw, 1.125rem);
  line-height: 1.4;
  color: color-mix(in srgb, var(--text) 65%, transparent);
}

.typo-image {
  flex: 0 1 auto;
  margin-inline: auto; /* centre the book in the space right of the text */
  max-width: 66%;
  max-height: 94cqh; /* big, but fits the card height */
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8.87px;
  cursor: inherit;
  transition: scale 0.25s ease;
}

.typo-image:hover {
  scale: 1.02;
}

/* Vizuální identita screen 1: three iPads in a row, middle one bigger.
   Each is a button (opens the lightbox); kept small enough to clear the
   up/down arrows when centred. */

.viz-devices {
  display: flex;
  align-items: center;
  justify-content: center; /* grouped in the middle, not flung to the edges */
  gap: clamp(40px, 6vw, 120px);
}

.viz-pad {
  height: 62%;
  border: 0;
  background: none;
  padding: 0;
  cursor: inherit;
  transition: transform 0.2s ease;
}

.viz-pad img {
  display: block;
  height: 100%;
  width: auto;
  object-fit: contain;
}

.viz-pad--mid {
  height: 78%;
}

.viz-pad:hover {
  transform: scale(1.03);
}

/* Vizuální identita screen 2: BMM label top-left, a wide image below it,
   a detail image on the right. Positions mirror the design proportions. */

.viz-detail-text {
  position: absolute;
  left: 0;
  top: 12%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.3vw, 6px); /* tight title→subtitle gap, like the video labels */
}

.viz-detail-title {
  font-weight: 700;
  font-size: clamp(1rem, 1.15vw, 1.375rem);
  line-height: 1.25;
}

.viz-detail-caption {
  font-weight: 400;
  font-size: clamp(0.85rem, 0.95vw, 1.125rem);
  line-height: 1.4;
  color: color-mix(in srgb, var(--text) 65%, transparent);
}

.viz-detail-wide {
  position: absolute;
  left: 0;
  top: 41%;
  width: 40%;    /* 515/1262 */
  height: auto;
}

.viz-detail-side {
  position: absolute;
  right: 14%; /* centred in its column: equal gap to the wide image (right edge 40%) and the card edge */
  top: 33%;
  width: 32%;    /* 409.7/1262 */
  height: auto;
}

/* Produktové fotky: each set is a section in the vertical scroller —
   label + description on the left, masonry on the right. Photos show at
   their native aspect (no crop); a set taller than the card just scrolls. */

.produkt-screen {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(16px, 2vw, 40px);
  padding-block: clamp(16px, 4dvh, 48px);
}

.produkt-text {
  flex: 0 0 24%;
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.3vw, 6px); /* tight title→subtitle gap, like the video labels */
  align-self: start;
  margin-top: 0; /* JS aligns the label's top with the masonry's top (tracks resize) */
}

.produkt-title {
  font-weight: 700;
  font-size: clamp(1rem, 1.15vw, 1.375rem);
  line-height: 1.25;
}

.produkt-desc {
  font-weight: 400;
  font-size: clamp(0.85rem, 0.95vw, 1.125rem);
  line-height: 1.4;
  color: color-mix(in srgb, var(--text) 65%, transparent);
}

/* Masonry on the right (~60%); photos at natural aspect (no crop). */
.produkt-grid,
.produkt-rows {
  flex: 0 0 60%;
  min-width: 0;
  /* gutter so the photos clear the scrollbar / sit under the close cross.
     The masonry keeps its 60% width — the space-between gap (the label/info
     side) shrinks instead, so the photo aspect ratios are untouched. */
  margin-right: clamp(14px, 1.15vw, 22px);
}

/* Set 1 — 2×2 grid (photos are ~equal aspect). */
.produkt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 1.25vw, 20px);
}

/* Set 2 — two rows (2 + 3); each tile flex-grows by its aspect ratio, so
   widths are proportional and the row heights come out equal (no crop). */
.produkt-rows {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.25vw, 20px);
}

.produkt-row {
  display: flex;
  gap: clamp(12px, 1.25vw, 20px);
}

.produkt-row .produkt-tile {
  min-width: 0; /* flex-grow set inline ∝ aspect */
}

.produkt-tile {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  cursor: inherit;
  border-radius: 15px;
  overflow: hidden;
  transition: transform 0.25s ease;
}

.produkt-tile img {
  display: block;
  width: 100%;
  height: auto; /* natural aspect — no crop */
}

.produkt-tile:hover {
  transform: scale(1.02);
}

/* Horizontal carousel (Profilové fotky): one photo per view, prev/next. */

.carousel {
  position: relative;
  flex: 1;
  min-height: 0;
}

.carousel-track {
  height: 100%;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden; /* never scroll vertically — content is sized to fit */
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* arrows are the affordance */
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-slide {
  flex: 0 0 100%;
  height: 100%;
  min-height: 0; /* pin to track height so a tall photo can't grow it */
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* modest top/bottom margin — photo stays large, caption sits low; sides
     leave room for the arrows */
  padding: clamp(16px, 4vh, 40px) clamp(40px, 4vw, 64px);
  gap: clamp(12px, 2vh, 20px);
}

.carousel-photo {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-photo img {
  max-width: 100%;
  max-height: 100%; /* fills the space but never taller than the card */
  object-fit: contain;
  border-radius: 15px;
}

.carousel-caption {
  flex: none;
  margin-top: clamp(10px, 2.5vh, 28px); /* sit a little lower, below the photo */
  display: flex;
  flex-direction: column;     /* title and description stack on two lines */
  align-items: center;
  gap: clamp(2px, 0.3vw, 6px);
  text-align: center;
}

.carousel-caption-title {
  font-weight: 700;
  font-size: clamp(1rem, 1.15vw, 1.375rem);
  line-height: 1.25;
}

.carousel-caption-desc {
  font-weight: 400;
  font-size: clamp(0.85rem, 0.95vw, 1.125rem);
  line-height: 1.4;
  color: color-mix(in srgb, var(--text) 65%, transparent);
}

.carousel-btn {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  z-index: 1;
  width: 40px;
  height: 40px;
  border: 0;
  display: grid;
  place-items: center;
  background: none; /* no white plate behind the chevrons */
  color: var(--line);
}

.carousel-btn--prev { left: var(--gutter); }
.carousel-btn--next { right: var(--gutter); }
/* The chevron fills its box, so its rendered edges are what JS aligns the
   close cross (right) and heading (left) to. */
.carousel-btn svg { display: block; width: 24px; height: 14px; }
.carousel-btn--prev svg { rotate: 90deg; }
.carousel-btn--next svg { rotate: -90deg; }
.carousel-btn:hover { opacity: 0.6; }

/* Lightbox: a top-layer dialog (above the overlay) for an enlarged image. */

.lightbox {
  --pad: clamp(20px, 3vw, 44px);
  position: relative;
  margin: auto;
  max-width: 100vw;
  max-height: 100dvh;
  border: 0;
  padding: var(--pad);
  background: none;
  overflow: hidden; /* media is sized to fit — never a scrollbar */
}

/* White close cross, top-right; the dark disc keeps it visible on any
   background (white card or the video itself). */
.lightbox-close {
  position: fixed;
  top: clamp(12px, 2.5vh, 28px);
  right: clamp(12px, 2.5vw, 32px);
  z-index: 1;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: none; /* hidden — the lightbox closes via backdrop click or Esc */
  place-items: center;
  font-size: 1.75rem;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
}

.lightbox-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

/* Soft expand-in so opening a photo isn't abrupt. */
.lightbox[open] {
  animation: lightbox-in 0.28s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.lightbox[open]::backdrop {
  animation: lightbox-fade 0.28s ease both;
}

@keyframes lightbox-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes lightbox-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox::backdrop {
  background: var(--bg); /* solid */
}

.lightbox-img {
  display: block;
  max-width: calc(100vw - 2 * var(--pad));
  max-height: calc(100dvh - 2 * var(--pad)); /* fits the screen by height */
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8.87px;
}

.overlay-card::backdrop {
  background: var(--bg); /* solid — the page disappears behind the card */
}

.overlay-heading {
  /* Sits at the content's left edge (aligned with the section labels). JS
     mirrors it onto the carousel's left arrow when that overlay is open. */
  margin: 0;
  align-self: flex-start; /* shrink to text width so it doesn't cover the up arrow */
  font-weight: 700;
  font-size: clamp(1.25rem, 2.344vw, 2.8125rem); /* 45/1920 */
  line-height: 1.4889;                           /* 67/45 */
}

.overlay-close {
  position: absolute;
  top: 10.43%;   /* level with the heading band */
  right: 8.241%;
  width: 32px;
  height: 32px;
  border: 0;
  display: grid;
  place-items: center;
  color: var(--line);
}

/* The cross is an SVG whose strokes reach its box edges, so its visible right
   edge IS its box right edge — that's what JS aligns to the photo. */
.overlay-close svg {
  display: block;
  width: 18px;
  height: 18px;
}

.overlay-close:hover {
  opacity: 0.6;
}

/* Flip: the old face turns away while the new face turns in. The
   browser's group animation morphs position and size — slowed to match
   the flip so the flight and the rotation are one movement. Labels are
   part of the faces, so text flips with the card. */

::view-transition-group(flip-card) {
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

::view-transition-image-pair(flip-card) {
  perspective: 1200px;
}

::view-transition-old(flip-card),
::view-transition-new(flip-card) {
  height: 100%; /* faces fill the morphing box instead of keeping their own aspect */
}

::view-transition-old(flip-card) {
  animation: flip-out 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

::view-transition-new(flip-card) {
  animation: flip-in 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes flip-out {
  0%        { opacity: 1; transform: rotateY(0deg); }
  45%, 100% { opacity: 0; transform: rotateY(-90deg); }
}

@keyframes flip-in {
  0%, 45% { opacity: 0; transform: rotateY(90deg); }
  100%    { opacity: 1; transform: rotateY(0deg); }
}

/* --- Small screens --- */

@media (max-width: 860px) {
  .tiles {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    aspect-ratio: auto;
  }

  /* With auto rows, tile shapes come from their aspect ratios */
  .tile { aspect-ratio: 1; }
  .wtile--produkt,
  .wtile--typografie { aspect-ratio: 1; }
  .wtile--profilovky,
  .wtile--videa      { aspect-ratio: 708 / 362; }

  .card--hero {
    grid-row: auto;
    grid-column: 1 / -1;
  }
  .card--hero .hero-layer { padding-block: 14%; }

  /* Work masonry restacks: tall tile + the two squares keep their
     desktop relationship, the wide tiles go full width below. */
  .work {
    grid-template-columns: 1fr 1fr;
    aspect-ratio: auto;
    column-gap: var(--gap-col);
    row-gap: var(--gap-row);
    grid-template-areas:
      "viz produkt"
      "viz typografie"
      "profilovky profilovky"
      "videa videa";
  }

  .work-right,
  .work-row {
    display: contents;
  }

  .wtile--viz        { grid-area: viz; }
  .wtile--produkt    { grid-area: produkt; }
  .wtile--profilovky { grid-area: profilovky; }
  .wtile--videa      { grid-area: videa; }
  .wtile--typografie { grid-area: typografie; }

  .overlay-card {
    width: calc(100vw - 32px);
    height: calc(100dvh - 32px); /* near full-screen, 16px margin all round */
    padding: 28px 24px;
  }

  /* Cross sits in the header row, clear of the content below it. */
  .overlay-close {
    top: 24px;
    right: 24px;
  }

  /* Carousel arrows: smaller and pinned to the card edges so they clear the
     photo (the landscape shots fill nearly the whole slide width). */
  .carousel-btn { width: 32px; height: 32px; }
  .carousel-btn--prev { left: 0; }
  .carousel-btn--next { right: 0; }

  /* Pager arrows are for the desktop panel-per-screen layout; mobile scrolls by touch. */
  .vnav { display: none; }

  .gallery {
    grid-template-columns: 1fr 1fr;
  }

  /* Overlay sections stack vertically and are sized by their content, so the
     card scrolls through them instead of forcing each to full height (which
     made tall content overflow — overlapping the next screen / cropping the
     top labels). Snapping is off so you can scroll a tall section freely. */
  .vscroll {
    scroll-snap-type: none;
  }

  .typo-screen,
  .produkt-screen,
  .viz-detail,
  .viz-devices {
    height: auto;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(16px, 4vw, 28px);
    padding: 24px 0;
  }

  .typo-text,
  .viz-detail-text,
  .produkt-text {
    position: static;
    flex: none;
    width: 100%;
    max-width: 100%;
    align-items: center;
    text-align: center;
  }

  .typo-image {
    flex: none;
    max-width: 100%;
    max-height: 60vh;
  }

  /* iPads + detail images go full width in flow */
  .viz-pad,
  .viz-pad--mid {
    height: auto;
  }

  .viz-pad img {
    max-width: 62%;
    max-height: 40vh;
    margin: 0 auto;
  }

  .viz-detail-wide,
  .viz-detail-side {
    position: static;
    width: 86%;
    max-height: 40vh;
    object-fit: contain;
  }

  /* Produkt masonry full width below the label */
  .produkt-grid,
  .produkt-rows {
    flex: none;
    width: 100%;
  }

  .produkt-grid {
    grid-template-rows: auto auto;
  }
}

/* --- Reduced motion --- */

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

  .tiles,
  .work,
  .work-right,
  .work-row {
    transition: none;
  }

  button.tile--empty {
    animation: none; /* no pulse */
  }

  .lightbox[open],
  .lightbox[open]::backdrop {
    animation: none;
  }
}
