/* =====================
   Cases page: local styles
   Uses common site styles from style.css: header, burger, footer, glass, background.
===================== */

/* Page flow */
.cases-main {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* =====================
   Hero block
===================== */

.cases-hero {
  position: relative;
  height: 520px;
  padding: 50px;
  border-radius: var(--radius-xl);

  display: flex;
  align-items: flex-end;

  background: transparent;
  overflow: hidden;
}

.cases-hero__title {
  margin: 0 0 20px 0px;

  font-family: var(--font-heading);
  font-size: 150px;
  font-weight: 600;
  line-height: 1;
  color: #ffffff;
  text-transform: uppercase;
}

.cases-back {
  position: absolute;
  top: 50px;
  left: 50px;
  width: 54px;
  height: 54px;
}

.cases-back__icon {
  position: absolute;
  width: 54px;
  height: 54px;
  object-fit: contain;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.cases-back__icon--default {
  opacity: 1;
}

.cases-back__icon--hover {
  opacity: 0;
}

.cases-back:hover .cases-back__icon--default {
  opacity: 0;
}

.cases-back:hover .cases-back__icon--hover {
  opacity: 1;
}

/* ПК */
@media (hover: hover) and (pointer: fine) {
  .cases-back:hover .cases-back__icon--default {
    opacity: 0;
  }

  .cases-back:hover .cases-back__icon--hover {
    opacity: 1;
  }
}

/* Телефон */
@media (hover: none) and (pointer: coarse) {
  .cases-back {
    transition: transform 0.3s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .cases-back:active {
    transform: scale(0.9);
  }
}

/* =====================
   Visual constructor
   grid     — wrapper grid
   panel    — large block
   tile     — image block
   section-bar — divider
   span-* / rows-* — size helpers
===================== */

.grid {
  display: grid;
  gap: var(--gap);
}

.grid-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: 150px;
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }

.rows-1 { grid-row: span 1; }
.rows-2 { grid-row: span 2; }
.rows-3 { grid-row: span 3; }
.rows-4 { grid-row: span 4; }
.rows-5 { grid-row: span 5; }

/* =====================
   Panel: large block
===================== */

.panel {
  position: relative;
  overflow: hidden;
  border-radius: 30px;
}

.panel--text {
  padding: 44px 54px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.panel--text h2 {
  margin: 0;

  font-family: var(--font-heading);
  font-size: 56px;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
  color: #77adff;

  transition: color 0.35s ease;
}

.panel--text:hover h2 {
  color: #0e5ce2;
}

.panel--image {
  display: block;
}

.panel--image img,
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;

  filter: brightness(0.3);
  transition: filter 0.35s ease;
}

.panel--image:hover img,
.tile:hover img {
  filter: brightness(1);
}

.panel--image::after,
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;

  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.10),
    inset 1.8px 3px 0 -2px rgba(255, 255, 255, 0.4),
    inset -2px -2px 0 -2px rgba(255, 255, 255, 0.60),
    inset -3px -8px 1px -6px rgba(255, 255, 255, 0.2);
}

.panel-text,
.tile-text {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;

  width: 100%;
  padding: 0 32px;

  transform: translate(-50%, -50%);

  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.35s ease;

  text-shadow: 0 0 16px rgba(0, 0, 0, 0.55);
}

.panel--image:hover .panel-text,
.tile:hover .tile-text {
  color: rgba(255, 255, 255, 1);
}

.panel-title,
.tile-title {
  font-family: var(--font-heading);
  font-size: clamp(28px, 2.6vw, 50px);
  font-weight: 800;
  line-height: 1.05;
  text-transform: uppercase;
}

.tile-subtitle,
.panel-subtitle {
  margin-top: clamp(6px, 0.7vw, 14px);

  font-family: var(--font-heading);
  font-size: clamp(15px, 1.35vw, 26px);
  font-weight: 400;
  line-height: 1.1;
  text-transform: none;
}

.tile-center-text .tile-text {
  inset: 0;
  left: auto;
  top: auto;

  width: 100%;
  height: 100%;
  padding: 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  transform: none;
  text-align: center;
}

.tile-center-text .tile-title {
  width: 100%;
  margin: 0 auto;
  text-align: center;
}

/* =====================
   Section divider
===================== */

.section-bar {
  min-height: 160px;
  padding: 34px 54px;
  border-radius: 30px;

  display: flex;
  align-items: center;
  overflow: hidden;
}

.section-bar h2 {
  margin: 0;

  font-family: var(--font-heading);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: #77adff;
}

/* =====================
   Tile: image card
===================== */

.tile {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 30px;
  background: transparent;
}

/* =====================
   Responsive
===================== */

@media (max-width: 1200px) {
  .grid-6 {
    grid-auto-rows: 130px;
  }

  .panel--text h2,
  .section-bar h2 {
    font-size: 44px;
  }

  .panel-title,
  .tile-title {
    font-size: 38px;
  }

  .tile-subtitle,
  .panel-subtitle {
    font-size: 22px;
  }
}

@media (max-width: 900px) {
  .cases-hero {
    height: 420px;
    padding: 28px 24px;
  }

  .cases-hero__title {
    margin: 0;
    font-size: 84px;
  }

  .cases-back {
    top: 28px;
    left: 24px;
    width: 48px;
    height: 48px;
  }

  .cases-back__icon {
    width: 48px;
    height: 48px;
  }

  .grid-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 120px;
  }

  .span-2,
  .span-3,
  .span-4,
  .span-6 {
    grid-column: span 2;
  }

  .rows-2,
  .rows-3,
  .rows-4,
  .rows-5 {
    grid-row: span 2;
  }

  .panel--text {
    padding: 28px 24px;
  }

  .panel--text h2,
  .section-bar h2 {
    font-size: 34px;
  }

  .section-bar {
    min-height: 110px;
    padding: 24px;
  }

  .panel-title,
  .tile-title {
    font-size: 30px;
  }

  .tile-subtitle,
  .panel-subtitle {
    margin-top: 10px;
    font-size: 20px;
  }
}

@media (max-width: 600px) {
  .cases-hero {
    height: 320px;
  }

  .cases-hero__title {
    font-size: 56px;
  }

  .grid-6 {
    grid-template-columns: 1fr;
    grid-auto-rows: 170px;
  }

  .span-2,
  .span-3,
  .span-4,
  .span-6 {
    grid-column: 1 / -1;
  }

  .rows-1,
  .rows-2,
  .rows-3,
  .rows-4,
  .rows-5 {
    grid-row: span 2;
  }

  .panel--text h2,
  .section-bar h2 {
    font-size: 28px;
  }

  .panel-title,
  .tile-title {
    font-size: 24px;
  }

  .tile-subtitle,
  .panel-subtitle {
    margin-top: 8px;
    font-size: 16px;
  }
}

/* Intermediate widths retain the desktop mosaic with content-sized rows. */
.grid-6 > * { min-width: 0; }
.panel--text { overflow: visible; }
.panel--text h2, .section-bar h2, .panel-title, .tile-title { overflow-wrap: anywhere; }
@media (min-width: 769px) {
  .cases-hero { height: auto; min-height: clamp(320px, 27vw, 520px); }
  .cases-hero__title { font-size: clamp(64px, 7.8vw, 150px); }
  .grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: minmax(clamp(65px, 7.8vw, 150px), auto); }
  .span-2 { grid-column: span 2; }
  .span-3 { grid-column: span 3; }
  .span-4 { grid-column: span 4; }
  .span-6 { grid-column: span 6; }
  .rows-1 { grid-row: span 1; }
  .rows-2 { grid-row: span 2; }
  .rows-3 { grid-row: span 3; }
  .rows-4 { grid-row: span 4; }
  .rows-5 { grid-row: span 5; }
  /* Standard case tiles keep the same portrait shape across desktop widths. */
  .grid-6 > .tile.span-2 {
    grid-row: auto;
    min-height: 0;
    aspect-ratio: 3 / 4;
  }
  .panel--text, .section-bar { padding: clamp(24px, 2.3vw, 44px) clamp(24px, 2.8vw, 54px); }
  .panel--text h2 { font-size: clamp(25px, 2.7vw, 52px); line-height: 1.2; }
  .panel-title, .tile-title { font-size: clamp(19px, 2.44vw, 47px); }
  .panel-subtitle, .tile-subtitle { font-size: clamp(14px, 1.27vw, 24.5px); }
  .panel-text, .tile-text { padding: 0 clamp(16px, 1.7vw, 32px); }
}

/* Mobile composition from mobile-reference/cases.svg. */
@media (max-width: 768px) {
  .cases-main {
    gap: 6px;
  }

  .cases-main > .cases-hero { order: 0; }
  .cases-main > #presentation { order: 1; }
  .cases-main > #polygraphy { order: 2; }
  .cases-main > #polygraphy + .grid { order: 3; }
  .cases-main > #exhibition { order: 4; }
  .cases-main > #exhibition + .grid { order: 5; }
  .cases-main > #exhibition + .grid + .grid { order: 6; }
  .cases-main > #digital { order: 7; }
  .cases-main > #digital + .grid { order: 8; }
  .cases-main > #uiux { order: 9; }
  .cases-main > #uiux + .grid { order: 10; }
  .cases-main > #branding { order: 11; }
  .cases-main > #branding + .grid { order: 12; }

  .cases-hero {
    height: 139px;
    min-height: 139px;
    padding: 20px;
    border-radius: 20px;
  }

  .cases-hero__title {
    margin: 0;
    font-size: 40px;
    line-height: 1;
  }

  .cases-back {
    top: 20px;
    left: 20px;
    width: 30px;
    height: 30px;
  }

  .cases-back__icon {
    width: 30px;
    height: 30px;
  }

  .grid-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row dense;
    grid-auto-rows: auto;
    gap: 6px;
  }

  .grid-6 > .panel,
  .grid-6 > .tile,
  .grid-6 > .span-2,
  .grid-6 > .span-3,
  .grid-6 > .span-4,
  .grid-6 > .span-6 {
    grid-row: auto;
    grid-column: span 1;
    min-height: 0;
    aspect-ratio: 151 / 147;
    border-radius: 20px;
  }

  .grid-6 > .panel--text,
  .grid-6 > .panel--image,
  .grid-6 > .tile--wide {
    grid-column: 1 / -1;
    aspect-ratio: 308 / 149;
  }

  .grid-6 > .panel--text {
    min-height: 60px;
    padding: 20px;
    aspect-ratio: auto;
  }

  .panel--text h2,
  .section-bar h2 {
    font-size: 18px;
    line-height: 1.05;
  }

  .section-bar {
    min-height: 54px;
    padding: 18px 20px;
    border-radius: 20px;
  }

  .panel-title,
  .tile-title {
    font-size: clamp(10px, 3.1vw, 14px);
    line-height: 1.02;
  }

  .tile-subtitle,
  .panel-subtitle {
    margin-top: clamp(2px, 0.8vw, 5px);
    font-size: clamp(9px, 2.6vw, 12px);
    line-height: 1.08;
  }

  .panel-text,
  .tile-text {
    padding: 0 14px;
  }

  #branding + .grid > :nth-child(3) {
  grid-column: 1 / -1;
  aspect-ratio: 308 / 149;
  }

  #exhibition + .grid > :first-child {
    grid-column: 1 / -1;
    aspect-ratio: 308 / 149;
  }

  #digital + .grid > :first-child,
  #uiux + .grid > :nth-child(3) {
    grid-column: 1 / -1;
    aspect-ratio: 308 / 149;
  }

  #motion,
  #motion + .grid {
    display: none;
  }
}

/* Align the hero, section content and outer edge of the back button. */
.cases-main .cases-hero,
.cases-main .panel--text,
.cases-main .section-bar { padding-inline: var(--section-content-inset); }
.cases-main .cases-back { left: var(--section-content-inset); }
