/* ==========================================================================
   Services — section «Услуги» and the shared contact dialog.
   Self-contained: works on the homepage and on future /services/<slug>/
   pages. Uses the existing --cine-* / --home-* tokens with fallbacks, the
   Onest type scale of the homepage and the outline style of the hero button.
   Load after /home.css (homepage) or after the page's own stylesheet.
   ========================================================================== */

.home-services {
  --svc-ink: var(--home-cream, #f1ebdd);
  --svc-text: rgba(241, 235, 221, .72);
  --svc-muted: rgba(241, 235, 221, .64);
  --svc-card-bg: #151718;                                   /* = --cine-card over the page graphite */
  --svc-border: var(--cine-card-border, rgba(210, 214, 218, .1));
  --svc-border-active: var(--cine-card-border-active, rgba(210, 214, 218, .18));
  --svc-radius: var(--cine-card-radius, 16px);
  --svc-gutter: clamp(20px, 4vw, 58px);
  --svc-pad: clamp(22px, 1.9vw, 30px);
  position: relative;
  padding: clamp(28px, 2.6vw, 44px) var(--svc-gutter) clamp(24px, 2vw, 36px);   /* projects add their own 58px */
  background: #0e1010;                                      /* = start of the projects scene */
  color: var(--svc-ink);
}

.home-services .services-title {
  margin: 0 0 clamp(22px, 2.4vw, 32px);
  color: var(--svc-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .18em;
  line-height: 1.3;
  text-transform: uppercase;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* --- Card: text → light band → price -------------------------------------
   The artwork's near-black is blended into the graphite card (screen), so
   the image has no visible edge and the light flows stay exactly as drawn. */
.service-card {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "copy" "media" "actions";
  overflow: hidden;
  border: 1px solid var(--svc-border);
  border-radius: var(--svc-radius);
  background: var(--svc-card-bg);
  transition: border-color .25s ease;
}
.service-card:hover,
.service-card:focus-within { border-color: var(--svc-border-active); }

/* The card is a link: on hover it lights up a little — a brighter edge, a
   soft glow from the top and the artwork gets brighter. Pointer devices only. */
.service-card::before {
  content: "";
  position: absolute;
  z-index: -1;                                              /* under the content, inside the card (isolate) */
  inset: 0;
  background: radial-gradient(120% 70% at 30% 0%, rgba(241, 235, 221, .07), transparent 62%);
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
.service-media { transition: filter .45s ease; }
@media (hover: hover) {
  .service-card { transition: border-color .25s ease, box-shadow .35s ease; }
  .service-card:hover {
    border-color: rgba(241, 235, 221, .42);
    box-shadow: 0 0 0 1px rgba(241, 235, 221, .05), 0 22px 60px -28px rgba(241, 235, 221, .22);
  }
  .service-card:hover::before { opacity: 1; }
  .service-card:hover .service-media { filter: brightness(1.22); }
}

.service-media {
  grid-area: media;
  display: block;
  margin-top: -20px;                                       /* dark top of the band slides under the text */
  mix-blend-mode: screen;
  /* soft edges: the band dissolves into the card instead of ending in a line */
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 34%, #000 90%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 34%, #000 90%, transparent 100%);
}
.service-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1173 / 720;                                /* lower part of the artwork: all light flows */
  object-fit: cover;
  object-position: 50% 100%;
}

.service-copy {
  grid-area: copy;
  padding: var(--svc-pad) var(--svc-pad) 0;
}
/* the whole card is the link to the service page: the title link stretches
   over the card (its ::after); the «Обсудить» button stays above it */
.service-link { color: inherit; text-decoration: none; }
.service-link::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
}
.service-card .service-link:focus-visible { outline: none; }   /* the ring goes around the whole card */
.service-card:has(.service-link:focus-visible) { outline: 2px solid var(--svc-ink); outline-offset: 3px; }
.service-text { position: relative; z-index: 1; }      /* over the band's dark top, which slides under it */
.service-title {
  margin: 0;
  color: var(--svc-ink);
  font-size: clamp(1.375rem, 1.55vw, 1.75rem);             /* 22–28px */
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.12;
}
.service-text {
  margin: 10px 0 0;
  color: var(--svc-text);
  font-size: clamp(.9375rem, 1.05vw, 1.0625rem);           /* 15–17px */
  line-height: 1.5;
}

.service-actions {
  grid-area: actions;
  position: relative;
  z-index: 3;
  align-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px var(--svc-pad) var(--svc-pad);
}

/* «от … ₽ | Обсудить» — outline pill, same as the hero «Смотреть работы» */
.service-cta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 11px 17px;
  border: 1px solid var(--svc-ink);
  border-radius: 8px;
  color: var(--svc-ink);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.service-cta:hover { background: var(--svc-ink); color: var(--home-graphite, #232622); }
.service-cta-sep {
  width: 1px;
  height: 16px;
  background: currentColor;
  opacity: .4;
}
.service-cta-action { display: inline-flex; gap: 8px; }

.service-card:not(.service-card--featured) .service-cta { gap: 12px; padding-inline: 15px; }

/* --- Promo row: two offers under the cards, each opens its block on /offers/
   A small star in the corner — the motif of the offers page. */
.promo-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.promo-card {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "kicker arrow" "title arrow" "text arrow";
  align-content: start;
  gap: 6px 24px;
  padding: var(--svc-pad) calc(var(--svc-pad) + 4px) var(--svc-pad) calc(var(--svc-pad) + 34px);
  overflow: hidden;
  border: 1px solid var(--svc-border);
  border-radius: var(--svc-radius);
  background: var(--svc-card-bg);
  color: var(--svc-ink);
  text-decoration: none;
  transition: border-color .25s ease, box-shadow .35s ease;
}
.promo-card::before {                                      /* the star */
  content: "";
  position: absolute;
  top: calc(var(--svc-pad) - 2px);
  left: calc(var(--svc-pad) - 6px);
  width: 24px;
  height: 24px;
  background:
    radial-gradient(circle, #fff 0 1.3px, rgba(255, 255, 255, .6) 2.2px, rgba(228, 232, 236, .16) 5px, transparent 10px),
    linear-gradient(90deg, transparent, rgba(255, 255, 255, .8) 50%, transparent) 50% 50% / 100% 1px no-repeat,
    linear-gradient(180deg, transparent, rgba(255, 255, 255, .8) 50%, transparent) 50% 50% / 1px 100% no-repeat;
}
.promo-kicker {
  grid-area: kicker;
  color: var(--svc-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .18em;
  line-height: 1.3;
  text-transform: uppercase;
}
.promo-title {
  grid-area: title;
  font-size: clamp(1.375rem, 1.55vw, 1.75rem);
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.12;
}
.promo-text {
  grid-area: text;
  color: var(--svc-text);
  font-size: clamp(.9375rem, 1.05vw, 1.0625rem);
  line-height: 1.5;
}
.promo-arrow {
  grid-area: arrow;
  align-self: center;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--svc-border-active);
  border-radius: 8px;
  transition: border-color .2s ease, background-color .2s ease;
}
.promo-card:focus-visible { outline: 2px solid var(--svc-ink); outline-offset: 3px; }
@media (hover: hover) {
  .promo-card:hover {
    border-color: rgba(241, 235, 221, .42);
    box-shadow: 0 0 0 1px rgba(241, 235, 221, .05), 0 22px 60px -28px rgba(241, 235, 221, .22);
  }
  .promo-card:hover .promo-arrow { border-color: var(--svc-ink); background: rgba(241, 235, 221, .06); }
}
@media (max-width: 680px) {
  .promo-row { grid-template-columns: minmax(0, 1fr); }
  .promo-arrow { width: 40px; height: 40px; }
}

/* --- Featured card: corporate websites ----------------------------------
   Desktop: fixed-height banner, the whole galaxy on the right (contain),
   text and price on the left over the empty part of the sky. */
.service-card--featured {
  grid-column: 1 / -1;
  grid-template-rows: auto 1fr;
  grid-template-areas: "copy" "actions";
  min-height: clamp(300px, 21vw, 400px);
}
.service-card--featured .service-media {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  max-width: 100%;
  aspect-ratio: 2079 / 756;                                /* box = the image itself, right-aligned */
  margin: 0;
  /* the left 40% of the artwork is empty sky: fade it into the card */
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 34%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 34%);
}
.service-card--featured .service-media img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
  object-position: 100% 50%;
}
.service-card--featured .service-copy,
.service-card--featured .service-actions { max-width: min(56%, 780px); }
.service-card--featured .service-copy { padding: clamp(28px, 2.8vw, 48px) clamp(28px, 2.8vw, 48px) 0; }
.service-card--featured .service-actions { padding: 24px clamp(28px, 2.8vw, 48px) clamp(28px, 2.8vw, 48px); }
.service-card--featured .service-title {
  font-size: clamp(2.25rem, 3.1vw, 3.5rem);                /* 36–56px */
  font-weight: 300;
  letter-spacing: -.04em;
  line-height: 1;
}
.service-card--featured .service-text {
  max-width: 520px;
  margin-top: 16px;
  font-size: clamp(1rem, 1.2vw, 1.1875rem);                /* 16–19px */
}

/* --- Below 1280: small cards 2 × 2 -------------------------------------- */
@media (max-width: 1279px) {
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- Tablet: featured image as a band above the text -------------------- */
@media (max-width: 960px) {
  .service-card--featured {
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "media" "copy" "actions";
    min-height: 0;
  }
  .service-card--featured .service-media {
    position: static;
    aspect-ratio: auto;
    -webkit-mask-image: linear-gradient(180deg, #000 78%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 78%, transparent 100%);
  }
  .service-card--featured .service-media img { height: auto; aspect-ratio: 2079 / 756; object-fit: cover; object-position: 50% 50%; }
  .service-card--featured .service-copy,
  .service-card--featured .service-actions { max-width: none; }
  .service-card--featured .service-copy { padding: 4px 24px 0; }
  .service-card--featured .service-actions { padding: 20px 24px 24px; }
}

/* --- Mobile: one column, individual crops ------------------------------- */
@media (max-width: 680px) {
  .home-services { padding: 28px 20px 20px; --svc-pad: 20px; }
  .service-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .service-card--featured .service-media img { aspect-ratio: 1209 / 756; }
  .service-card--featured .service-copy { padding: 4px 20px 0; }
  .service-card--featured .service-actions { padding: 18px 20px 20px; }
  .service-cta { flex: 1 1 auto; justify-content: flex-start; }
  .service-cta .service-cta-sep { margin-left: auto; }   /* price left, «| Обсудить →» right */
}
@media (max-width: 374px) {
  .service-cta { gap: 10px; padding-inline: 14px; }
}

/* ==========================================================================
   Contact dialog (contact-dialog.js). Native <dialog> + showModal().
   ========================================================================== */
html.has-contact-dialog { overflow: hidden; scrollbar-gutter: stable; }

.contact-dialog {
  width: min(440px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--cine-card-border-active, rgba(210, 214, 218, .18));
  border-radius: var(--cine-card-radius, 16px);
  background: #121416;
  color: var(--home-cream, #f1ebdd);
  font-family: inherit;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.contact-dialog::backdrop { background: rgba(6, 7, 8, .74); }
.contact-dialog[open] { animation: contact-dialog-in .22s ease-out; }
@keyframes contact-dialog-in { from { opacity: 0; transform: translateY(8px); } }

.contact-dialog-panel { position: relative; padding: 30px 28px 28px; }
.contact-dialog-kicker {
  margin: 0 0 12px;
  color: rgba(241, 235, 221, .64);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .18em;
  line-height: 1.3;
  text-transform: uppercase;
}
.contact-dialog-title {
  margin: 0;
  padding-right: 40px;
  font-size: 1.75rem;                                      /* 28px */
  font-weight: 300;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.contact-dialog-service {
  margin: 10px 0 0;
  color: rgba(241, 235, 221, .72);
  font-size: .9375rem;
  line-height: 1.45;
}
.contact-dialog-service:empty { display: none; }

.contact-dialog-list { margin: 24px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--cine-line, rgba(218, 224, 230, .14)); }
.contact-dialog-list li { border-bottom: 1px solid var(--cine-line, rgba(218, 224, 230, .14)); }
.contact-dialog-link {
  display: grid;
  grid-template-columns: 24px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 60px;
  padding: 8px 6px;
  color: var(--home-cream, #f1ebdd);
  font-size: 1rem;
  text-decoration: none;
  transition: background-color .2s ease;
}
.contact-dialog-link:hover { background: rgba(241, 235, 221, .05); }
.contact-dialog-link svg { width: 22px; height: 22px; justify-self: center; }
.contact-dialog-hint {
  overflow: hidden;
  color: rgba(241, 235, 221, .6);
  font-size: .875rem;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-dialog-go { color: rgba(241, 235, 221, .6); }

.contact-dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(241, 235, 221, .72);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.contact-dialog-close:hover { color: var(--home-cream, #f1ebdd); border-color: var(--cine-card-border-active, rgba(210, 214, 218, .18)); }

.contact-dialog a:focus-visible,
.contact-dialog button:focus-visible { outline: 2px solid var(--cine-silver, #b9c0c7); outline-offset: 2px; }

@media (max-width: 680px) {
  /* bottom sheet */
  .contact-dialog {
    width: 100%;
    max-height: calc(100dvh - 24px);
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
  }
  .contact-dialog[open] { animation-name: contact-dialog-up; }
  @keyframes contact-dialog-up { from { transform: translateY(24px); opacity: 0; } }
  .contact-dialog-panel { padding: 26px 20px calc(20px + env(safe-area-inset-bottom)); }
  .contact-dialog-title { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .service-card, .service-card::before, .service-media, .service-cta, .promo-card, .promo-arrow,
  .contact-dialog-link, .contact-dialog-close { transition: none; }
  .contact-dialog[open] { animation: none; }
}
