/* ==========================================================================
   Маджонг · лаборатория — базовые стили и оболочка сайта
   Этап 1: концепт-галерея фишек
   ========================================================================== */

:root {
  --bg: #0c6044;
  --bg-deep: #073e2e;
  --bg-soft: #0f6e4d;
  --surface: #0b523a;
  --surface-2: #0e6045;
  --panel: #f3ead8;
  --panel-2: #eaddc5;
  --ink: #18221d;
  --ink-soft: #3f4b43;
  --cream: #f5eedf;
  --muted: #bfd2c5;
  --muted-2: #9ab5a5;
  --gold: #d7ae68;
  --gold-2: #f0d49b;
  --line: rgba(245, 238, 223, 0.14);
  --line-strong: rgba(245, 238, 223, 0.24);
  --line-dark: rgba(24, 34, 29, 0.13);
  --danger: #e28a6f;
  --success: #88d7b4;

  --font-display: "Palatino Linotype", "Book Antiqua", Palatino, "Iowan Old Style", Georgia, serif;
  --font-sans: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;

  --shell: min(1240px, calc(100vw - 48px));
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 30px;
  --shadow-soft: 0 18px 60px rgba(0, 0, 0, 0.22);
  --shadow-card: 0 24px 70px rgba(0, 0, 0, 0.28);
  --header-h: 78px;
  --ease-out: cubic-bezier(0.22, 0.8, 0.22, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  min-width: 320px;
  color: var(--cream);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 820px at 8% -12%, rgba(44, 155, 98, 0.34), transparent 62%),
    radial-gradient(900px 700px at 100% 32%, rgba(4, 40, 29, 0.48), transparent 66%),
    linear-gradient(135deg, #117a52 0%, #0c6044 44%, #083f2f 100%);
  background-attachment: fixed;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: clip;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image: radial-gradient(rgba(245, 238, 223, 0.22) 0.55px, transparent 0.55px);
  background-size: 4px 4px;
  mix-blend-mode: soft-light;
}

body.nav-open,
body.is-locked {
  overflow: hidden;
}

main {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  overflow: clip;
}

img,
svg {
  max-width: 100%;
}

img {
  height: auto;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

p,
h1,
h2,
h3,
h4,
ul,
ol,
dl,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

:focus-visible {
  outline: 3px solid var(--gold-2);
  outline-offset: 4px;
}

::selection {
  color: var(--ink);
  background: var(--gold-2);
}

.shell {
  width: var(--shell);
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--gold-2);
  font-weight: 700;
  transform: translateY(-160%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Типографика ---------- */

.display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.035em;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--gold-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 26px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 4vw, 56px);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.section-title em {
  color: var(--gold-2);
  font-style: italic;
}

.section-lead {
  max-width: 440px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

/* ---------- Кнопки ---------- */

.button {
  --button-bg: var(--gold-2);
  --button-ink: #201e18;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 13px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--button-ink);
  background: var(--button-bg);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.2s var(--ease-out),
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.button svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
}

.button:active {
  transform: translateY(0);
}

.button--ghost {
  --button-bg: transparent;
  --button-ink: var(--cream);
  border-color: var(--line-strong);
}

.button--ghost:hover {
  border-color: var(--gold);
  background: rgba(215, 174, 104, 0.09);
}

.button--small {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 12.5px;
}

.button--quiet {
  --button-bg: rgba(245, 238, 223, 0.08);
  --button-ink: var(--cream);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--gold-2);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.text-link svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.text-link:hover svg {
  transform: translateX(3px);
}

/* ---------- Шапка ---------- */

.site-header {
  position: relative;
  z-index: 100;
  background: linear-gradient(180deg, rgba(5, 51, 36, 0.9), rgba(4, 43, 30, 0.84));
  border-bottom: 1px solid rgba(245, 238, 223, 0.1);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 30px;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: none;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 33px;
  height: 43px;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-copy {
  display: grid;
  gap: 1px;
  line-height: 1;
}

.brand-name {
  position: relative;
  display: inline-block;
  color: var(--gold-2);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.13em;
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.brand-name::after {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  margin-top: 4px;
  background: linear-gradient(90deg, var(--gold), transparent);
  opacity: 0.8;
}

.brand-sub {
  color: var(--muted);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-left: auto;
}

.site-nav a {
  position: relative;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 1px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s var(--ease-out);
}

.site-nav a:hover {
  color: var(--cream);
}

.site-nav a:hover::after,
.site-nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

.site-nav a[aria-current="page"] {
  color: var(--cream);
}

.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-left: 4px;
  padding: 7px 13px 7px 9px;
  border: 1px solid rgba(215, 174, 104, 0.32);
  border-radius: 999px;
  color: var(--gold-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stage-chip::before {
  content: "01";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #1c1a14;
  background: var(--gold-2);
  font-size: 9px;
  letter-spacing: 0;
}

.stage-chip span {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.08em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.035);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.icon-button:hover {
  border-color: var(--gold);
  background: rgba(215, 174, 104, 0.09);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  color: var(--gold-2);
}

@media (max-width: 700px) {
  .icon-button__label {
    display: none;
  }

  .icon-button {
    padding: 0;
    width: 44px;
  }
}

/* ---------- Настройки ---------- */

.settings[hidden] {
  display: none;
}

.settings {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  justify-items: end;
}

.settings__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 12, 9, 0.7);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.settings.is-open .settings__backdrop {
  opacity: 1;
}

.settings__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  height: 100%;
  padding: clamp(20px, 4vw, 34px);
  overflow-y: auto;
  color: var(--cream);
  background:
    radial-gradient(500px 300px at 100% 0%, rgba(78, 136, 109, 0.2), transparent 65%),
    #0c211a;
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.35);
  transform: translateX(30px);
  opacity: 0;
  transition: transform 0.24s var(--ease-out), opacity 0.2s ease;
  outline: none;
}

.settings.is-open .settings__panel {
  transform: translateX(0);
  opacity: 1;
}

.settings__head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.settings__head h2 {
  margin-top: 9px;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.settings__head p:not(.eyebrow) {
  max-width: 380px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.settings__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--cream);
  background: transparent;
  cursor: pointer;
}

.settings__close:hover {
  border-color: var(--gold);
}

.settings__close svg {
  width: 18px;
  height: 18px;
}

.settings__themes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: 20px;
}

.theme-option {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 92px;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.theme-option:has(input:focus-visible) {
  outline: 3px solid var(--gold-2);
  outline-offset: 2px;
}

.theme-option:hover {
  border-color: rgba(215, 174, 104, 0.45);
  background: rgba(255, 255, 255, 0.04);
}

.theme-option:has(input:checked) {
  border-color: var(--gold);
  background: rgba(215, 174, 104, 0.08);
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option__preview {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 72px;
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.16), transparent 70%),
    rgba(255, 255, 255, 0.035);
}

.theme-option__preview img {
  display: block;
  width: auto;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 7px 8px rgba(0, 0, 0, 0.35));
}

.theme-option__copy {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
}

.theme-option__name {
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.1;
}

.theme-option__desc {
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}

.theme-option__meta {
  color: var(--muted-2);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.theme-option__check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.theme-option:has(input:checked) .theme-option__check {
  border-color: var(--gold-2);
  background: var(--gold-2);
  box-shadow: 0 0 0 4px rgba(240, 212, 155, 0.12);
}

.settings__rows {
  display: grid;
  margin-top: 22px;
  border-top: 1px solid var(--line);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.settings-row span {
  display: grid;
  gap: 2px;
}

.settings-row strong {
  font-size: 12px;
}

.settings-row small {
  color: var(--muted);
  font-size: 10px;
}

.settings-row input[type="checkbox"] {
  width: 42px;
  height: 24px;
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.settings-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.settings-row input[type="checkbox"]:checked {
  border-color: var(--gold);
  background: rgba(215, 174, 104, 0.22);
}

.settings-row input[type="checkbox"]:checked::after {
  transform: translateX(18px);
  background: var(--gold-2);
}

.settings__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 24px;
}

@media (max-width: 480px) {
  .settings__themes {
    grid-template-columns: 1fr;
  }

  .theme-option {
    min-height: 100px;
  }

  .theme-option__preview {
    min-height: 80px;
  }

  .theme-option__preview img {
    height: 70px;
  }
}

@media (max-width: 860px) {
  .header-actions {
    margin-left: auto;
  }

  .nav-toggle {
    margin-left: 0;
  }
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 46px;
  min-height: 44px;
  margin-left: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.nav-toggle__icon {
  display: grid;
  gap: 4px;
  width: 16px;
}

.nav-toggle__icon span {
  display: block;
  height: 1.5px;
  background: currentColor;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon span:first-child {
  transform: translateY(5.5px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__icon span:last-child {
  transform: translateY(-5.5px) rotate(-45deg);
}

/* ---------- Подвал ---------- */

.site-footer {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 54px 0 28px;
  border-top: 1px solid var(--line);
  background: rgba(4, 38, 27, 0.46);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 46px;
}

.footer-brand p {
  max-width: 420px;
  margin-top: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.footer-heading {
  margin-bottom: 14px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.footer-links {
  display: grid;
  gap: 9px;
}

.footer-links a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--gold-2);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 42px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.7;
}

.footer-bottom p {
  max-width: 720px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(136, 215, 180, 0.12);
}

/* ---------- Утилиты ---------- */

.hairline {
  height: 1px;
  border: 0;
  background: var(--line);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--ok {
  color: #b9edd7;
  border-color: rgba(136, 215, 180, 0.28);
  background: rgba(136, 215, 180, 0.08);
}

.badge--accent {
  color: var(--gold-2);
  border-color: rgba(215, 174, 104, 0.34);
  background: rgba(215, 174, 104, 0.08);
}

.badge--ink {
  color: var(--ink-soft);
  border-color: var(--line-dark);
  background: rgba(24, 34, 29, 0.04);
}

@media (max-width: 1020px) {
  .header-inner {
    gap: 20px;
  }

  .site-nav {
    gap: 20px;
  }

  .stage-chip {
    display: none;
  }
}

@media (max-width: 860px) {
  :root {
    --header-h: 68px;
    --shell: calc(100vw - 40px);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    display: none;
    margin: 0;
    padding: 16px 20px 24px;
    background: rgba(4, 43, 30, 0.98);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.32);
  }

  .site-nav.is-open {
    display: grid;
    gap: 4px;
  }

  .site-nav a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 4px;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
  }

  .site-nav a::after {
    display: none;
  }

  .site-nav .stage-chip {
    display: inline-flex;
    justify-self: start;
    margin-top: 14px;
    margin-left: 0;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  :root {
    --shell: calc(100vw - 32px);
  }

  body {
    font-size: 15px;
  }

  .header-inner {
    min-height: 62px;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-mark {
    width: 29px;
    height: 38px;
  }

  .nav-toggle span.nav-toggle__label {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .footer-bottom {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

html[data-reduce-motion="true"] *,
html[data-reduce-motion="true"] *::before,
html[data-reduce-motion="true"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
