/*
 * Base layout for the public pages: reset, typography, header, footer,
 * buttons and pills. Uses only the variables from tokens.css.
 */

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-ground);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
}

main {
  flex: 1;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* Typography */
h1,
h2,
h3 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); font-weight: var(--weight-medium); }

p {
  margin: 0 0 var(--space-4);
}

a {
  color: var(--color-accent);
}

:focus-visible {
  outline: var(--space-1) solid var(--focus-ring-color);
  outline-offset: var(--space-1);
}

/* Hidden visually, still read by screen readers. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Vertical rhythm for top-level page sections. */
.page-section {
  padding: var(--space-8) 0;
}

.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* Buttons and pills */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-ground);
}

.btn-primary:hover {
  background: var(--color-ink);
}

.btn-secondary {
  background: var(--color-ground);
  border-color: var(--color-ink);
  color: var(--color-ink);
}

.btn-secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-soft);
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.card {
  padding: var(--space-6);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-card);
  background: var(--color-ground);
}

/* Header */
.site-header {
  border-bottom: var(--border-width) solid var(--color-line);
  background: var(--color-ground);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-6);
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
}

/* Wordmark: the name is all caps already; uppercase keeps it so whatever the
   setting holds. */
.site-logo {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-logo);
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--color-ink);
  text-decoration: none;
}

/* Nav wraps onto extra lines on narrow screens instead of overflowing. */
.site-nav {
  flex: 1 1 auto;
  min-width: 0;
}

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__link {
  color: var(--color-ink);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.site-nav__link:hover,
.site-nav__link[aria-current="page"] {
  color: var(--color-accent);
}

/* "Отзывы" before any review is published: plain text, not a link. */
.site-nav__link--soon,
.site-nav__link--soon:hover {
  color: var(--color-muted);
  cursor: default;
}

.site-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* RU / EN switch */
.lang-switch {
  display: inline-flex;
  margin: 0;
  padding: var(--space-1);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-pill);
}

.lang-switch__btn {
  padding: var(--space-1) var(--space-3);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
}

.lang-switch__btn[aria-pressed="true"] {
  background: var(--color-ink);
  color: var(--color-ground);
  cursor: default;
}

/* Footer */
.site-footer {
  margin-top: var(--space-9);
  padding: var(--space-7) 0;
  background: var(--color-soft);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-5);
}

.site-footer__name {
  margin: 0 0 var(--space-2);
  font-family: var(--font-heading);
  font-weight: var(--weight-medium);
  color: var(--color-ink);
}

.site-footer__legal {
  margin: 0;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__links a {
  color: var(--color-muted);
}

.site-footer__links a:hover {
  color: var(--color-accent);
}

/* Narrow screens */
@media (max-width: 40rem) {
  h1 { font-size: var(--text-2xl); }

  /* Sides only: the shorthand would also zero the header's own top/bottom padding. */
  .container {
    padding-right: var(--space-4);
    padding-left: var(--space-4);
  }

  .site-nav {
    order: 3;
    flex-basis: 100%;
  }

  /* Logo, RU/EN switch and "Мой кабинет" share the first line down to 360px:
     the logo keeps its size, the gaps and the controls get tighter. */
  .site-header__inner {
    justify-content: space-between;
    column-gap: var(--space-3);
  }

  .site-header__actions {
    gap: var(--space-2);
  }

  .lang-switch__btn {
    padding: var(--space-1) var(--space-2);
  }

  .site-header__actions .btn {
    padding: var(--space-3);
    font-size: var(--text-sm);
  }
}
