/*
  WAI Design System — компоненты. Версия 0.1, 30 октября 2026.
  Композиция и типографика по Wabi. Контролы и границы по Clonk: кольцо 1 px и мягкая тень.
*/

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: var(--weight-regular) var(--text-body) / var(--text-body-lh) var(--font-sans);
  letter-spacing: var(--text-body-ls);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--ink); color: var(--canvas); }

.emoji { font-family: var(--font-emoji); font-style: normal; line-height: 1; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.tnum { font-variant-numeric: tabular-nums; }

/* Сетка */
.wrap { width: min(var(--wide), 100% - 2 * var(--gut)); margin-inline: auto; }
.narrow { max-width: var(--narrow); margin-inline: auto; }
.section { padding-block: var(--section-y); }
.section + .section { padding-top: 0; }
.section-head { max-width: 640px; margin: 0 auto clamp(56px, 7vw, 96px); text-align: center; }
.section-head .lead { margin-top: var(--s-4); }
.center { text-align: center; }
.stack > * + * { margin-top: var(--s-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--wgap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--wgap); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--wgap); }
.row-flex { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

/* Типографика */
.display {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--text-display);
  line-height: var(--text-display-lh);
  letter-spacing: var(--text-display-ls);
  text-wrap: balance;
}
.h1 { margin: 0; font-size: var(--text-h1); line-height: var(--text-h1-lh); letter-spacing: var(--text-headline-ls); font-weight: 400; text-wrap: balance; }
.h2 { margin: 0; font-size: var(--text-h2); line-height: var(--text-h2-lh); letter-spacing: var(--text-headline-ls); font-weight: 400; text-wrap: balance; }
.h3 { margin: 0; font-size: var(--text-h3); line-height: var(--text-h3-lh); letter-spacing: var(--text-h3-ls); font-weight: 500; }
.h4 { margin: 0; font-size: 19px; line-height: 1.3; letter-spacing: -.015em; font-weight: 500; }
.lead { font-size: var(--text-lead); line-height: var(--text-lead-lh); letter-spacing: var(--text-lead-ls); color: var(--ink-2); text-wrap: pretty; }
.body-l { font-size: var(--text-body-l); line-height: 1.5; }
.small { font-size: var(--text-small); line-height: 1.5; color: var(--grey-500); }
.caption { font-size: var(--text-caption); line-height: 1.4; color: var(--ink-3); }
.eyebrow { font-size: var(--text-eyebrow); line-height: 1.25; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-2); }
.serif { font-family: var(--font-serif); font-weight: 400; }

/* Шапка */
.nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; justify-content: space-between;
  height: var(--nav-h); padding: 0 var(--s-6);
  background: var(--canvas);
  transition: box-shadow var(--dur-2) var(--ease), height var(--dur-2) var(--ease);
}
.nav.is-scrolled { height: var(--nav-h-scrolled); box-shadow: 0 1px 0 var(--hair-soft); }
.nav-links { display: flex; align-items: center; gap: var(--s-6); }
.nav-link { font-size: var(--text-nav); letter-spacing: var(--text-nav-ls); color: var(--ink); opacity: .72; transition: opacity var(--dur-1) var(--ease); }
.nav-link:hover { opacity: 1; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; letter-spacing: -.04em; }
.wordmark svg { width: 28px; height: 28px; }

/* Кнопки: Clonk */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--control); padding: 0 24px;
  border: 0; border-radius: var(--r-pill);
  background: var(--canvas); color: var(--ink);
  font-size: var(--text-button); font-weight: 500; letter-spacing: var(--text-button-ls); line-height: 1;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  box-shadow: var(--ring), var(--shadow-control);
  transition: box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease), background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.btn:hover { box-shadow: var(--ring), var(--shadow-control-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); transition-duration: var(--dur-1); }
.btn:disabled, .btn[aria-disabled="true"] { color: var(--ink-3); box-shadow: var(--ring-soft); cursor: default; transform: none; }
.btn svg { width: 1.2em; height: 1.2em; flex: none; }
.btn-primary { background: var(--ink); color: var(--on-dark); box-shadow: var(--shadow-dark-control); }
.btn-primary:hover { background: var(--dark-2); box-shadow: var(--shadow-dark-control); }
.btn-primary:disabled { background: var(--ink-14); color: var(--canvas); box-shadow: none; }
.btn-quiet { background: var(--paper); box-shadow: none; }
.btn-quiet:hover { background: var(--tile); box-shadow: none; transform: none; }
.btn-ghost-dark { background: transparent; color: var(--on-dark); box-shadow: var(--ring-on-dark); }
.btn-ghost-dark:hover { background: rgba(255, 255, 255, .06); box-shadow: var(--ring-on-dark); }
.btn-s { height: var(--control-s); padding: 0 16px; font-size: 14px; gap: 8px; }
.btn-l { height: var(--control-l); padding: 0 28px; font-size: 17px; }
.btn-xl { height: var(--control-xl); padding: 0 32px; font-size: var(--text-button-l); font-weight: 400; }
.btn-icon { width: var(--control); padding: 0; }
.btn-icon.btn-s { width: var(--control-s); }
.btn-icon.btn-l { width: var(--control-l); }
.btn-row { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }

/* Чипы и бейджи */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: var(--r-pill);
  background: var(--paper); color: var(--ink-2);
  font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.chip-outline { background: var(--canvas); box-shadow: var(--ring); color: var(--ink); }
.chip-school { background: var(--school-tint); color: var(--school-ink); }
.chip-adult { background: var(--adult-tint); color: var(--adult-ink); }
.chip-dev { background: var(--dev-tint); color: var(--dev-ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.dot-school { background: var(--school); }
.dot-adult { background: var(--adult); }
.dot-dev { background: var(--dev); }

/* Карточки, плитки, виджеты */
.card { padding: var(--s-5); border-radius: var(--r-xl); background: var(--canvas); box-shadow: var(--ring-soft), var(--shadow-card); }
.tile { padding: var(--s-5); border-radius: var(--r-l); background: var(--paper); }
.tile-dark { background: var(--dark); color: var(--on-dark); }
.tile-school { background: var(--school-tint); }
.tile-adult { background: var(--adult-tint); }
.tile-dev { background: var(--dev-tint); }
.widget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--wtile), 1fr)); gap: var(--wgap); }
.widget {
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-3);
  aspect-ratio: 1; padding: 20px;
  border-radius: var(--r-xl); background: var(--tile);
  box-shadow: var(--ring-soft);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.widget:hover { transform: translateY(-2px); box-shadow: var(--ring-soft), var(--shadow-sheet); }
.widget-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.widget-title { font-size: 19px; font-weight: 500; line-height: 1.2; letter-spacing: -.02em; color: var(--ink); }
.widget-sub { margin-top: 4px; font-size: 14px; line-height: 1.35; color: var(--ink-2); }
.widget-value { font-size: clamp(44px, 3.8vw, 64px); line-height: 1; letter-spacing: -.03em; font-weight: 400; font-variant-numeric: tabular-nums; }
.widget .emoji { font-size: 40px; }
.widget-fill-dev { background: var(--dev); color: var(--on-dark); box-shadow: none; }
.widget-fill-dev .widget-title { color: var(--on-dark); }
.widget-fill-dev .widget-sub, .widget-fill-dev .caption { color: var(--on-dark-2); }
.widget-fill-school { background: var(--school); box-shadow: none; }
.widget-fill-adult { background: var(--adult); box-shadow: none; }
.widget-fill-school .widget-sub, .widget-fill-adult .widget-sub, .widget-fill-school .caption, .widget-fill-adult .caption { color: var(--ink-70); }
.chip-on-dark { background: rgba(255, 255, 255, .16); color: var(--on-dark); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 72px; }
.bars i { flex: 1; border-radius: 4px; background: var(--school); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -10px; background: var(--canvas); box-shadow: 0 0 0 3px var(--tile); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.widget-wide { grid-column: span 2; aspect-ratio: auto; }
.widget-2x { grid-row: span 2; aspect-ratio: auto; }

/* Аватары из Apple emoji */
.avatar {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--paper);
  font-family: var(--font-emoji); font-size: 26px; line-height: 1;
}
.avatar-s { width: 36px; height: 36px; border-radius: 11px; font-size: 20px; }
.avatar-xs { width: 24px; height: 24px; border-radius: 7px; font-size: 14px; }
.avatar-l { width: 64px; height: 64px; border-radius: 18px; font-size: 34px; }
.avatar-xl { width: 96px; height: 96px; border-radius: 26px; font-size: 52px; }
.avatar-round { border-radius: 50%; }
.avatar-mark img { width: 78%; height: 78%; }
.avatar-school { background: var(--school-tint); }
.avatar-adult { background: var(--adult-tint); }
.avatar-dev { background: var(--dev-tint); }

/* Строки списков */
.list { display: flex; flex-direction: column; gap: 2px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 14px;
  color: inherit; text-decoration: none;
  transition: background var(--dur-1) var(--ease);
}
.row:hover { background: var(--paper); }
.row.is-selected { background: var(--paper); }
.row-text { min-width: 0; flex: 1; }
.row-title { display: block; font-size: 14px; font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: block; font-size: 13px; line-height: 1.3; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 12px; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; }
.row-badge { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); flex: none; }
.divided > * + * { border-top: 1px solid var(--hair-soft); }
.hr { height: 1px; margin: 0; border: 0; background: var(--hair-soft); }

/* Чат */
.chat { display: flex; flex-direction: column; gap: var(--s-5); }
.turn { display: flex; gap: 12px; align-items: flex-end; max-width: 100%; }
.turn-me { justify-content: flex-end; }
.bubble { max-width: 75%; padding: 11px 15px; border-radius: 20px; background: var(--paper); line-height: 1.45; font-size: 15px; }
.turn-me .bubble { background: var(--ink); color: var(--on-dark); }
.turn-them .bubble { background: var(--paper); }
.turn-open { display: flex; gap: 12px; align-items: flex-start; }
.turn-open .text { max-width: 75%; line-height: 1.5; font-size: 15px; padding-top: 4px; }
.turn-open .text + .text { margin-top: 8px; }
.chat-time { text-align: center; font-size: 12px; color: var(--ink-3); }
.chat-card {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 10px 14px 10px 10px; border-radius: 16px;
  background: var(--canvas); box-shadow: var(--ring-soft), var(--shadow-sheet);
  font-size: 14px; font-weight: 500;
}
.chat-card .caption { font-weight: 400; }

/* Композер и поля */
.composer {
  display: flex; align-items: center; gap: 8px;
  min-height: var(--control-l); padding: 6px 6px 6px 8px;
  border-radius: var(--r-pill); background: var(--canvas);
  box-shadow: var(--ring), var(--shadow-control);
}
.composer input { flex: 1 1 0; width: 0; min-width: 0; border: 0; background: transparent; padding: 0 8px; font-size: 15px; }
.composer input::placeholder { color: var(--ink-3); }
.composer input:focus { outline: none; }
.input {
  height: var(--control); padding: 0 16px; width: 100%;
  border: 0; border-radius: 14px; background: var(--canvas);
  box-shadow: var(--ring); font-size: 15px;
  transition: box-shadow var(--dur-1) var(--ease);
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; box-shadow: 0 0 0 2px var(--ink); }
.input-pill { border-radius: var(--r-pill); }
.input-s { height: var(--control-s); padding: 0 14px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }

/* Переключатель */
.switch {
  position: relative; width: 46px; height: 28px; flex: none;
  border: 0; border-radius: var(--r-pill); background: var(--ink-14);
  cursor: pointer; transition: background var(--dur-1) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--canvas);
  box-shadow: 0 1px 2px rgba(25,25,25,.2), 0 0 0 1px rgba(25,25,25,.06);
  transition: transform var(--dur-2) var(--pop);
}
.switch[aria-checked="true"] { background: var(--ink); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* Сегменты */
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--paper); box-shadow: var(--ring-soft); }
.seg button {
  height: 34px; padding: 0 14px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--ink-2);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.seg button[aria-pressed="true"] { background: var(--canvas); color: var(--ink); box-shadow: var(--ring-soft), 0 2px 6px rgba(25,25,25,.08); }

/* Чекбокс и радио */
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { appearance: none; width: 20px; height: 20px; margin: 0; border-radius: 6px; background: var(--canvas); box-shadow: var(--ring); display: grid; place-items: center; transition: background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease); }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--ink); box-shadow: none; }
.check input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--canvas); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--canvas); }

/* Окно Mac */
.window { border-radius: var(--r-l); background: var(--canvas); box-shadow: var(--ring), var(--shadow-window); overflow: hidden; text-align: left; }
.window-bar { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; border-bottom: 1px solid var(--hair-soft); }
.window-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 1px var(--hair); }
.window-title { margin-left: auto; margin-right: auto; font-size: 13px; color: var(--ink-3); }
.window-body { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 560px; }
.sidebar { padding: 12px; border-right: 1px solid var(--hair-soft); display: flex; flex-direction: column; gap: 12px; }
.sidebar-label { padding: 8px 12px 0; }
.sidebar-foot { margin-top: auto; }
.main { display: flex; flex-direction: column; }
.main-head { display: flex; align-items: center; justify-content: center; gap: 10px; height: 60px; padding: 0 24px; border-bottom: 1px solid var(--hair-soft); font-size: 14px; font-weight: 500; }
.main-body { flex: 1; padding: 32px; display: flex; flex-direction: column; justify-content: flex-end; }
.main-foot { padding: 0 32px 24px; }

/* Телефон */
.phone { width: min(363px, 100%); aspect-ratio: 363 / 746; margin: 0 auto; border-radius: 54px; background: var(--canvas); box-shadow: var(--ring), var(--shadow-window); padding: 14px; }
.phone-screen { width: 100%; height: 100%; border-radius: 42px; background: var(--card); overflow: hidden; padding: 20px 16px; }

/* Образцы для витрины */
.swatch { aspect-ratio: 1; min-width: 0; width: 100%; border-radius: var(--r-m); box-shadow: var(--ring-soft); }
.swatch-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s-4); align-items: start; }
.swatch-row > div { min-width: 0; }
.swatch-name { margin-top: 8px; font-size: 13px; font-weight: 500; }
.swatch-code { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); }
.spec { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); letter-spacing: 0; }
.demo { padding: var(--s-6); border-radius: var(--r-xl); background: var(--card); box-shadow: var(--ring-soft); }
.demo-dark { background: var(--dark); color: var(--on-dark); }
.demo-row { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.demo-title { margin-bottom: var(--s-4); }
.specimen { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s-5); align-items: baseline; padding: var(--s-5) 0; }
.specimen + .specimen { border-top: 1px solid var(--hair-soft); }

/* Знаки «Линзы» */
.mark { width: 100%; aspect-ratio: 1; }
.mark-row { display: flex; align-items: flex-end; gap: var(--s-5); flex-wrap: wrap; }
.mark-sample { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }

/* Появление */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity var(--dur-3) var(--ease), transform var(--dur-3) var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* Футер */
.foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; padding: 22px 24px 30px; border-top: 1px solid var(--hair-soft); font-size: var(--text-small); color: var(--grey-500); }
.foot a { color: var(--grey-500); }
.foot a:hover { color: var(--ink); }
.foot-links { display: flex; gap: var(--s-4); }

/* Адаптив */
@media (max-width: 1024px) {
  .window-body { grid-template-columns: 220px minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .nav { padding: 0 16px; }
  .nav-links .nav-link { display: none; }
  .wrap { width: min(var(--wide), 100% - 32px); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .widget-wide { grid-column: auto; aspect-ratio: 1; }
  .window-body { grid-template-columns: 1fr; min-height: 0; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--hair-soft); }
  .main-body { padding: 20px 16px; }
  .main-foot { padding: 0 16px 16px; }
  .specimen { grid-template-columns: 1fr; gap: 6px; }
  .bubble, .turn-open .text { max-width: 88%; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row .btn { justify-content: center; }
}
