/* ==========================================================================
   Розкладка головної сторінки. Токени й базові примітиви — в assets/theme.css.
   ========================================================================== */

body {
  padding-bottom: 72px;
}

.layout {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--s-5) var(--s-7);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* --------------------------------------------------------------------------
   Верхня панель
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--s-4) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.brand {
  min-width: 0;
}

.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  margin: 5px 0 0;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-muted);
}

.call-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  flex: none;
  background: transparent;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 11px var(--s-4);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
}

.call-btn::after {
  content: "";
  position: absolute;
  inset: -6px;
}

.call-btn .icon {
  width: 13px;
  height: 13px;
}

.call-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

.hero {
  padding: var(--s-8) 0 var(--s-6);
  text-align: center;
}

.hero h1 {
  margin: 0 auto;
  font-size: clamp(22px, 5.2vw, 29px);
  line-height: 1.32;
  max-width: 26ch;
  text-wrap: balance;
}

.hero-rule {
  width: 48px;
  height: 1px;
  background: var(--accent);
  margin: var(--s-6) auto 0;
}

/* --------------------------------------------------------------------------
   Смуга довіри
   -------------------------------------------------------------------------- */

.trust-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
  margin: var(--s-6) 0 0;
  padding: var(--s-5) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.trust-item {
  min-width: 0;
  text-align: center;
}

.trust-item .num {
  display: block;
  margin-bottom: var(--s-2);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.trust-item p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Послуги. Порядок груп — за терміновістю: замки, аварійні виклики,
   планові та побутові роботи.
   -------------------------------------------------------------------------- */

.service-group + .service-group {
  margin-top: var(--s-2);
}

.service-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-2);
}

.service-grid > li {
  min-width: 0;
}

.service-grid > li.is-feature {
  grid-column: 1 / -1;
}

/* Головна послуга — картка на всю ширину з підпунктами. */
.service-feature {
  position: relative;
  width: 100%;
  display: block;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: var(--s-5);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.service-feature:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.feature-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.feature-head .icon {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.feature-eyebrow {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--accent);
}

.feature-code {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
}

.feature-title {
  display: block;
  margin: var(--s-4) 0 0;
  font-family: var(--font-display);
  font-size: clamp(19px, 4.6vw, 23px);
  font-weight: 500;
  line-height: 1.25;
}

.feature-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

.feature-tags span {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.feature-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
  width: 100%;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.feature-cta .icon {
  width: 14px;
  height: 14px;
}

/* Решта послуг — вирівняні рядки: іконка, назва, стрілка. */
.service-row {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 20px 1fr 14px;
  align-items: center;
  gap: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px var(--s-4);
  text-align: left;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.service-row:hover {
  border-color: var(--accent-line);
  background: var(--surface-hover);
}

.service-row .service-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.service-name {
  font-size: 13.5px;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.service-arrow {
  width: 14px;
  height: 14px;
  color: var(--ink-dim);
}

.service-row:hover .service-arrow {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Майстри
   -------------------------------------------------------------------------- */

.masters-row {
  display: flex;
  gap: var(--s-5);
  overflow-x: auto;
  padding: var(--s-1) var(--s-1) var(--s-3);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.master-card {
  flex: 0 0 88px;
  text-align: center;
}

.monogram {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  color: var(--accent);
  margin: 0 auto var(--s-3);
}

.master-card span {
  font-size: 12.5px;
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------------
   Підвал
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer p:first-child {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

.site-footer p + p {
  margin-top: var(--s-2);
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.7;
}

/* --------------------------------------------------------------------------
   Внутрішні вкладки
   -------------------------------------------------------------------------- */

.page-head {
  text-align: center;
  padding: var(--s-7) 0 var(--s-5);
}

.page-head .eyebrow {
  margin-bottom: var(--s-3);
}

.page-head h2 {
  font-size: 25px;
}

.account-state {
  display: none;
}

.account-state.active {
  display: block;
}

.request-row {
  border-top: 1px solid var(--line);
  padding: var(--s-4) 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-3);
}

.request-row:last-child {
  border-bottom: 1px solid var(--line);
}

.request-row > div {
  min-width: 0;
}

.r-service {
  font-size: 14px;
}

.r-date {
  margin-top: var(--s-1);
  font-size: 11.5px;
  color: var(--ink-muted);
}

.status-pill {
  flex: none;
  border-radius: var(--radius);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 9px;
  white-space: nowrap;
}

.status-new {
  color: var(--accent);
  border: 1px solid var(--accent-line);
}

.status-done {
  color: var(--success);
  border: 1px solid var(--success);
}

.empty-note {
  margin: var(--s-5) 0 0;
  font-size: 13.5px;
  color: var(--ink-muted);
  text-align: center;
}

.announcement {
  border-top: 1px solid var(--line);
  padding: var(--s-5) 0;
}

.announcement:last-child {
  border-bottom: 1px solid var(--line);
}

.a-date {
  margin-bottom: var(--s-2);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.announcement h3 {
  font-size: 16px;
  margin: 0 0 var(--s-2);
}

.announcement p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-muted);
  line-height: 1.7;
}

.directory-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-3);
  border-top: 1px solid var(--line);
  padding: var(--s-4) 0;
}

.directory-item:last-child {
  border-bottom: 1px solid var(--line);
}

.d-label {
  font-size: 13px;
  color: var(--ink-muted);
}

.d-value {
  font-size: 13.5px;
  text-align: right;
}

.d-value a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
}

/* --------------------------------------------------------------------------
   Нижня навігація
   -------------------------------------------------------------------------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--bg);
  border-top: 1px solid var(--line);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  padding: 13px var(--s-1) 11px;
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: inherit;
  cursor: pointer;
}

.tab .icon {
  width: 19px;
  height: 19px;
}

.tab span {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Активну вкладку позначає волосяна лінія зверху, а не заливка. */
.tab::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: transparent;
}

.tab.active {
  color: var(--accent);
}

.tab.active::before {
  background: var(--accent);
}

/* --------------------------------------------------------------------------
   Модальне вікно заявки
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: end;
}

.modal.is-open {
  display: grid;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 11, 0.78);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(92vh, 780px);
  overflow: auto;
  background: var(--surface);
  border-top: 1px solid var(--accent-line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: var(--s-6) var(--s-5) var(--s-6);
}

.modal-close {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.modal-close::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.modal-close:hover {
  border-color: var(--accent-line);
  color: var(--ink);
}

.modal-state {
  display: none;
}

.modal-state.active {
  display: block;
}

.modal-title {
  margin: 0 0 var(--s-2);
  padding-right: var(--s-6);
  font-size: 21px;
}

.modal-desc {
  margin: 0 0 var(--s-5);
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Вибір фото
   -------------------------------------------------------------------------- */

.photo-input-native {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.photo-picker {
  position: relative;
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--ink-muted);
  font: inherit;
  font-size: 13px;
  padding: 13px var(--s-4);
  cursor: pointer;
}

.photo-picker::after {
  content: "";
  position: absolute;
  inset: -2px 0;
}

.photo-picker:hover {
  border-color: var(--accent-line);
  color: var(--ink);
}

.photo-picker .icon {
  width: 17px;
  height: 17px;
}

.photo-preview {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  padding: var(--s-2) var(--s-3);
}

.photo-preview img {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--line);
  flex: none;
}

.photo-preview-name {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-remove {
  position: relative;
  margin-left: auto;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

.photo-remove::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.photo-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.photo-error {
  margin: var(--s-2) 0 0;
  font-size: 11.5px;
  color: var(--danger);
}

.photo-picker[hidden],
.photo-preview[hidden],
.photo-error[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Стани модалки: вхід потрібен / з'єднуємо / результат
   -------------------------------------------------------------------------- */

.state-center {
  display: grid;
  place-items: center;
  text-align: center;
  gap: var(--s-3);
  padding: var(--s-5) 0 var(--s-1);
  min-height: 240px;
}

.orb {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: var(--accent);
}

.orb.calling {
  border-color: var(--accent-line);
}

.orb .icon {
  width: 20px;
  height: 20px;
}

/* Один повільний контур замість трьох пульсуючих кілець. */
.pulse-ring {
  position: absolute;
  inset: -1px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  opacity: 0;
}

.status-title {
  margin: var(--s-2) 0 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
}

.status-text {
  margin: 0;
  max-width: 32ch;
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.6;
}

.done-btn {
  max-width: 200px;
  margin-top: var(--s-4);
}

/* --------------------------------------------------------------------------
   Адаптив
   -------------------------------------------------------------------------- */

@media (min-width: 560px) {
  .trust-strip {
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
  }

  .trust-item + .trust-item {
    border-left: 1px solid var(--line);
  }

  .trust-item {
    padding: 0 var(--s-4);
  }

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

  .masters-row {
    justify-content: center;
    flex-wrap: wrap;
    overflow-x: visible;
  }
}

@media (min-width: 640px) {
  .modal {
    place-items: center;
    padding: var(--s-5);
  }

  .modal-panel {
    max-width: 460px;
    width: min(460px, 100%);
    border-radius: var(--radius);
    border: 1px solid var(--accent-line);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .service-feature,
  .service-row,
  .call-btn,
  .photo-picker,
  .modal-close,
  .photo-remove,
  .tab {
    transition:
      border-color var(--dur) var(--ease),
      background-color var(--dur) var(--ease),
      color var(--dur) var(--ease);
  }

  .service-arrow {
    transition: color var(--dur) var(--ease);
  }

  .modal-panel {
    transform: translateY(8px);
    transition: transform 220ms var(--ease);
  }

  .modal.is-open .modal-panel {
    transform: translateY(0);
  }

  .pulse-ring {
    animation: ring 1800ms var(--ease) infinite;
  }

  @keyframes ring {
    0% {
      transform: scale(1);
      opacity: 0.5;
    }
    100% {
      transform: scale(1.35);
      opacity: 0;
    }
  }
}
