/* Case-study pages: a full-screen hero, then a normally scrolling info section.
   Colors and type come from ui-kit/ — no raw values here. */

/* Page-to-page transitions without a white flash (Chrome/Safari; others just swap) */
@view-transition {
  navigation: auto;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: clip; /* sections replace each other on scroll; no native page scroll */
  background: var(--color-white);
  color: var(--color-black);
}
h1,
h2,
p {
  margin: 0;
}
/* The dot (.cursor) replaces the system cursor on mouse/trackpad devices */
@media (pointer: fine) {
  html,
  html * {
    cursor: none !important;
  }
}

/* Deck: full-screen sections stacked on top of each other (scripts/case.js) */
.case-deck {
  position: relative;
  height: 100vh;
  height: 100dvh; /* the visible height: on iPhone Safari 100vh runs under the toolbar */
}
.case-section {
  position: absolute;
  inset: 0;
  overflow: clip;
  visibility: hidden;
}
.case-section.is-current,
html:not(.js) .case-section:first-child {
  visibility: visible;
}

/* Shared by every section: the photo and the top bar stay while the
   sections' content changes on top of the photo */
.case-backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Top bar: back on the left, case name centered, store/site links on the right */
.case-bar {
  position: fixed;
  inset: 8px 8px auto;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  color: var(--color-white);
}
.case-bar__name {
  position: absolute;
  left: 50%;
  top: 4px; /* 12px from the top of the screen, like the homepage ЖЕНЯ wordmark */
  text-transform: uppercase; /* in capitals, like ЖЕНЯ */
  transform: translateX(-50%);
}
.case-bar__links {
  display: flex;
  gap: 8px;
}
/* Phones: the name moves left, 16px after the back button, clear of the links */
@media (max-width: 599px) {
  .case-bar__name {
    left: 56px; /* 40px back button + 16px */
    transform: none;
  }
}

/* Hero (Figma frame 80:225908) ---------------------------------------- */
.case-hero {
  color: var(--color-white);
}
.case-hero__headline {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  /* 96px on desktop; shrinks so the one-line headline (~11.8 × the font
     size) fits; phones match the homepage headline: up to 64px, by word */
  font-size: clamp(44px, (100vw - 32px) / 12, 96px);
}
@media (max-width: 599px) {
  .case-hero__headline {
    font-size: min(64px, (100vw - 32px) / 5.9);
  }
}
/* The headline line is its own mask for the rise-in */
.case-hero__headline .line {
  display: block;
  overflow: clip;
}
.case-hero__headline .line > span {
  display: block;
}

/* CV + Contact: pinned to the bottom of the screen for the whole page.
   On arrival they glide down from the top (scripts/case.js). Pink on white
   sections; translucent black over photos (body[data-header="image"]). */
.case-dock {
  position: fixed;
  inset: auto 8px 8px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  pointer-events: none; /* only the buttons take clicks */
}
.case-dock .btn {
  pointer-events: auto;
}
body[data-header="image"] .case-dock .btn {
  background: var(--color-black-10);
}
body[data-header="image"] .case-dock .btn:hover,
body[data-header="image"] .case-dock .btn:focus-visible {
  background: var(--color-black);
}

/* Idea: bento grid (Figma frame 80:226035), 696 × 356, centered on the photo */
.bento {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 696px;
  height: 356px;
  transform: translate(-50%, -50%) scale(var(--bento-scale, 1));
  background: var(--color-white); /* the section frame is a white card on the photo */
}
.bento > * {
  position: absolute;
}
/* Phones: 2 columns of fluid square cells, 8px from the screen edges
   (scripts/case.js sets each item's --bento-col / --bento-row) */
@media (max-width: 599px) {
  .bento {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: calc(100vw - 16px);
    height: auto;
    padding: 16px;
  }
  .bento > * {
    position: relative;
    inset: auto !important; /* ignore the desktop left/top */
    grid-column: var(--bento-col);
    grid-row: var(--bento-row);
    align-self: var(--bento-align, start);
  }
  /* Tiles keep their 154px Figma composition and are zoomed to fill the cell
     (scripts/case.js sets --tile-zoom = cell width / 154), so fixed-size art
     inside them (the calendar dots, cursors, badges) scales with the tile */
  .bento > .bento__tile {
    zoom: var(--tile-zoom, 1);
  }
  .bento > .bento__text {
    width: auto;
  }
}
.bento__tile {
  width: 154px;
  height: 154px;
  overflow: clip;
}
.bento__fill {
  display: block;
  width: 100%;
  height: 100%;
}
.bento__mark--logo {
  filter: var(--shadow-logo); /* the app logo's shadow, in CSS (see tokens) */
}
.bento__mark {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.bento__tile--smiley {
  background: var(--color-living-blue);
}
.bento__tile--explosion {
  background: var(--color-living-yellow);
}
.bento__text {
  width: 154px;
}

/* Life calendar: a 7 × 7 window of the app's calendar, shifted (-18, -18)
   so the days along every edge are cropped by the tile */
.life-cal {
  background: var(--color-white);
}
.life-cal__grid {
  position: absolute;
  left: -18px;
  top: -18px;
  display: grid;
  grid-template-columns: repeat(7, 22px);
  gap: 4px;
}
.day {
  position: relative;
  width: 22px;
  height: 22px;
  overflow: clip;
}
.day--empty {
  border-radius: 4px;
}
.day--empty img {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
}
.day--shape {
  border-radius: 999px;
}
/* The day artwork is drawn larger than the circle and cropped by it */
.day--shape img {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: none;
}
.day--red { background: var(--color-living-red); }
.day--orange { background: var(--color-living-orange); }
.day--blue { background: var(--color-living-blue); }
.day--yellow { background: var(--color-living-yellow); }

/* Hidden until fonts load; then the intro reveals it (no JS → just shows) */
.js body:not(.is-ready) :is(.case-bar, .case-hero__headline, .case-dock, .cursor) {
  visibility: hidden;
}
/* …except arriving from another case page: the bar and dock stay put */
.js.case-continue body:not(.is-ready) :is(.case-bar, .case-dock) {
  visibility: visible;
}

/* Core (Figma frame 80:226343): 696 × 640 white card, centered on the photo */
.core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 696px;
  height: 640px;
  transform: translate(-50%, -50%) scale(var(--core-scale, 1));
  background: var(--color-white);
}
.core > * {
  position: absolute;
  margin: 0;
}
.core__tag { left: 16px; top: 16px; }
.core__title { left: 356px; top: 16px; }
.core__desc { left: 356px; top: 72px; width: 292px; }
/* The preview window; the app screen scrolls inside it */
.core__preview {
  left: 16px;
  top: 196px;
  width: 664px;
  height: 428px;
  background: var(--color-gray-50);
  overflow: clip;
}
.core__scroll {
  position: absolute;
  inset: 0;
  overflow-x: hidden; /* on phones a 100%-zoom screen is wider than the preview: crop, never scroll sideways */
  overflow-y: auto;
  overscroll-behavior: contain; /* scrolling the screen never scrolls the page */
  scrollbar-width: none;
}
.core__scroll::-webkit-scrollbar {
  display: none;
}
.core__scroll:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: -2px;
}
/* Phones: the card fills the screen between the top bar and the dock (32px
   gaps) and stacks — tag, title, description — with the preview taking the rest */
@media (max-width: 599px) {
  .core {
    width: calc(100vw - 16px); /* 8px from the screen edges */
    /* fills the screen: 32px below the top bar (48px) and 32px above CV/Contact */
    height: calc(100dvh - 160px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
  }
  .core > * {
    position: relative;
    left: auto;
    top: auto;
  }
  .core__tag {
    margin-bottom: 8px;
  }
  .core__desc {
    width: auto;
  }
  .core__preview {
    flex: 1;
    min-height: 0;
    width: auto;
    height: auto;
    margin-top: 16px;
  }
  /* Screenshot previews keep the desktop 664×428 proportions and scale their
     content to match (scripts/case.js sets --shot-zoom); the card wraps them */
  .core:has(.shot) {
    height: auto;
  }
  .core__preview:has(> .shot) {
    flex: none;
    aspect-ratio: 664 / 428;
  }
  .core__preview > .shot {
    zoom: var(--shot-zoom, 1);
  }
}

/* Get Living (Figma frame 80:226335): the bento card with two store tiles */
.bento__text--wide {
  width: 292px;
}
.bento__tile--link:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: 2px;
}

/* Zoom (Figma 89:266851): + / − in the preview's top-right corner (scripts/case.js) */
/* Phones: no zoom — the preview stays at the middle step (scripts/case.js) */
@media (max-width: 599px) {
  .core__preview .zoom {
    display: none;
  }
}
.zoom {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 40px;
}
.zoom__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--color-black);
}
.zoom__btn::before {
  content: "";
  width: 24px;
  height: 24px;
  background-color: currentColor;
  -webkit-mask: no-repeat center / 24px 24px;
  mask: no-repeat center / 24px 24px;
}
.zoom__btn--in::before {
  -webkit-mask-image: url("../assets/icons/zoom-in.svg");
  mask-image: url("../assets/icons/zoom-in.svg");
}
.zoom__btn--out::before {
  -webkit-mask-image: url("../assets/icons/zoom-out.svg");
  mask-image: url("../assets/icons/zoom-out.svg");
}
.zoom__btn:disabled {
  opacity: 0.25;
}
.zoom__btn:focus-visible {
  outline: 2px solid var(--color-black);
  outline-offset: -2px;
}
/* Zoomed screens scale from their top center */
.core__scroll > .app {
  transform-origin: 50% 0;
}
/* A screen fitted whole at the smallest zoom: nothing to scroll */
.core__scroll.is-fit {
  overflow-y: hidden;
}
/* "Soon" chip in a tile's top-right corner (same chip as the homepage NDA card) */
.bento__chip {
  position: absolute;
  top: 8px;
  right: 8px;
  /* phones zoom tiles to fill the screen (--tile-zoom): undo it here so the
     label stays 14px with 8px insets at every size */
  zoom: calc(1 / var(--tile-zoom, 1));
}

/* Desktop screenshot in a preview (e.g. Studysphere, Figma 80:225992): the
   903 × 564 image sits 28px from the preview's top-left, with an 8px white
   frame OUTSIDE it (so the frame starts at 20px), and is cropped by the
   preview on the right and bottom, exactly as in Figma. Static: no scroll, no zoom. */
.shot {
  position: absolute;
  left: 20px;
  top: 20px;
  width: 919px;  /* 903 + 2 × 8 */
  height: 580px; /* 564 + 2 × 8 */
  border: 8px solid var(--color-white);
  border-radius: 16px; /* the image's 8px corners + the 8px frame */
  background: var(--color-white);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.1);
}
.shot img {
  display: block;
  width: 903px;
  height: 564px;
  border-radius: 8px;
}

/* Next case: the area under a section's card (from the card's bottom edge to
   the screen's bottom, as wide as the card) is one link; scripts/case.js sizes
   it to the card. Only the label shows; hovering switches the cursor. */
.case-next {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
  text-decoration: none;
}

/* Magnifier (scripts/case.js): a round loupe over a pressed screenshot,
   showing the interface at full detail */
.loupe {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  width: 288px; /* = LOUPE in scripts/case.js */
  height: 288px;
  border: 3px solid var(--color-white);
  border-radius: 50%;
  background-color: var(--color-white);
  background-repeat: no-repeat;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  opacity: 0;
  scale: 0.6;
  transition: opacity 0.15s ease, scale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.loupe.is-open {
  opacity: 1;
  scale: 1;
}
/* the screenshot takes the press itself (no scrolling, no long-press menu) */
.shot img {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none; /* Safari still needs the prefix */
  user-select: none;
}
/* while the magnifier is open, nothing on the page gets selected */
.is-magnifying,
.is-magnifying * {
  -webkit-user-select: none;
  user-select: none;
}
