/*
 * Design tokens: a soft neutral canvas with faint colour glows, floating
 * frosted-glass bars made of grey groups, white rounded cards with long soft
 * shadows, thin grey line icons and a blue accent used sparingly (selection,
 * sliders, focus). See ROADMAP.md, "Дизайн-система".
 *
 * Everything is measured on a few scales, never in between:
 * - space: a 4px grid (4 8 12 16 20 24 32 40 48 64 80);
 * - radius: 6 10 14 20 28 and pills; a shape inside another shares its
 *   centre, so an inner radius is the outer one less the padding between;
 * - type: 11 12 13 14 16 20 28 and the hero; tracking tightens as type grows;
 * - heights: 30 small controls, 36 controls, 44 fields, 54 bars.
 */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;
  /* Kept for the places that name them. */
  --radius-card: var(--radius-lg);
  --radius-panel: var(--radius-xl);

  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 28px;
  --text-hero: clamp(36px, 5vw, 56px);

  --control-sm: 30px;
  --control: 36px;
  --field: 44px;
  --bar: 54px;
  /* Floating chrome: its distance from the window's edges and between pieces. */
  --edge: 16px;
  --gap: 12px;

  --canvas: #f3f3f1;
  --canvas-2: #ebebe8;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  /* Frosted glass: bars, panels and menus over the canvas. */
  --glass: rgba(255, 255, 255, 0.8);
  /* Denser, for lists and panels that sit over the page. */
  --glass-strong: rgba(255, 255, 255, 0.9);
  --glass-edge: rgba(255, 255, 255, 0.9);
  --blur: blur(24px) saturate(1.8);
  /* Greys are see-through, so they sit the same on white, on glass and on the canvas. */
  --pill: rgba(20, 20, 18, 0.055);
  --pill-hover: rgba(20, 20, 18, 0.085);
  --pill-active: #ffffff;
  /* Warm grey squircles (shapes, quick tools) with light glyphs. */
  --tile: #efeeea;
  --tile-hover: #e7e6e1;
  --tile-ink: #6b6a64;
  --tile-glyph: #a9a8a1;
  --line: rgba(20, 20, 18, 0.07);
  --line-strong: rgba(20, 20, 18, 0.12);
  --text: #191918;
  --text-2: #6b6b67;
  --text-3: #a3a39e;
  --accent: #2f6fed;
  --accent-soft: rgba(47, 111, 237, 0.12);
  --guide: #e93d82;
  --success: #2f9e5b;
  --success-soft: rgba(47, 158, 91, 0.12);
  --danger: #d64933;
  --ink: #191918;
  --on-ink: #ffffff;
  --tip: #232322;
  --dots: rgba(20, 20, 18, 0.12);
  /* A hairline ring and a long soft fall-off; bigger things fall further. */
  --ring: 0 0 0 0.5px rgba(20, 20, 18, 0.08);
  --shadow-pill: var(--ring), 0 1px 2px rgba(20, 20, 18, 0.04), 0 10px 30px -8px rgba(20, 20, 18, 0.14);
  --shadow-card: var(--ring), 0 1px 2px rgba(20, 20, 18, 0.04), 0 24px 56px -12px rgba(20, 20, 18, 0.16);
  --shadow-page: 0 0 0 0.5px rgba(20, 20, 18, 0.06), 0 1px 2px rgba(20, 20, 18, 0.05), 0 18px 44px -10px rgba(20, 20, 18, 0.16);
  --shadow-knob: 0 0 0 0.5px rgba(20, 20, 18, 0.1), 0 1px 2px rgba(20, 20, 18, 0.18), 0 2px 8px rgba(20, 20, 18, 0.12);
  --shadow-raised: 0 0 0 0.5px rgba(20, 20, 18, 0.06), 0 1px 3px rgba(20, 20, 18, 0.12);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
}
:root[data-theme='dark'] {
  --canvas: #131313;
  --canvas-2: #1a1a1a;
  --surface: #1e1e1e;
  --surface-2: #232323;
  --glass: rgba(32, 32, 32, 0.78);
  --glass-strong: rgba(32, 32, 32, 0.9);
  --glass-edge: rgba(255, 255, 255, 0.06);
  --pill: rgba(255, 255, 255, 0.065);
  --pill-hover: rgba(255, 255, 255, 0.1);
  --pill-active: #3a3a3a;
  --tile: #262624;
  --tile-hover: #2e2e2b;
  --tile-ink: #b3b2ab;
  --tile-glyph: #7c7b75;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #f0f0ee;
  --text-2: #a6a6a1;
  --text-3: #6d6d69;
  --accent: #6d9bff;
  --accent-soft: rgba(109, 155, 255, 0.16);
  --success-soft: rgba(47, 158, 91, 0.2);
  --ink: #f0f0ee;
  --on-ink: #141414;
  --tip: #3a3a39;
  --dots: rgba(255, 255, 255, 0.09);
  --ring: 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  --shadow-pill: var(--ring), 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -8px rgba(0, 0, 0, 0.5);
  --shadow-card: var(--ring), 0 1px 2px rgba(0, 0, 0, 0.3), 0 24px 56px -12px rgba(0, 0, 0, 0.6);
  --shadow-page: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 44px -10px rgba(0, 0, 0, 0.55);
  --shadow-knob: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-raised: 0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body,
#root {
  height: 100%;
  margin: 0;
}
body {
  background: var(--canvas);
  color: var(--text);
  font: var(--text-base) / 1.45 var(--font);
  letter-spacing: -0.006em;
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
[hidden] {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------ the template pages (scripts/pages.ts) */

body {
  height: auto;
  min-height: 100%;
  background:
    radial-gradient(60% 40% at 85% 0%, rgba(160, 140, 255, 0.12), transparent 70%),
    radial-gradient(50% 35% at 0% 100%, rgba(255, 150, 190, 0.08), transparent 70%),
    var(--canvas);
}
a {
  color: inherit;
  text-decoration: none;
}
.wrap {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* The bar at the top: the mark (home), Templates and Your designs, on glass. */
.top {
  position: sticky;
  top: var(--space-3);
  z-index: 10;
  display: flex;
  justify-content: center;
  margin: var(--space-3) 0 var(--space-12);
}
.bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-pill);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: inset 0 0.5px 0 var(--glass-edge), var(--shadow-pill);
}
.brand,
.pill {
  display: inline-flex;
  align-items: center;
  height: 42px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--text-base);
  font-weight: 500;
  transition: background 0.15s;
}
.brand {
  gap: var(--space-2);
  padding-left: 8px;
  font-weight: 600;
}
.brand img {
  border-radius: 8px;
  box-shadow: 0 0 0 0.5px var(--line-strong);
}
.pill {
  color: var(--text-2);
  white-space: nowrap;
}
.pill:hover {
  background: var(--pill);
  color: var(--text);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  color: var(--text-3);
  font-size: var(--text-md);
}
.crumbs a:hover {
  color: var(--text);
}
h1 {
  max-width: 760px;
  margin: 0;
  font-size: var(--text-hero);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.017em;
}
.lead {
  max-width: 640px;
  margin: var(--space-4) 0 var(--space-6);
  color: var(--text-2);
  font-size: var(--text-lg);
  line-height: 1.5;
  text-wrap: pretty;
}
.cta {
  display: inline-flex;
  align-items: center;
  height: var(--field);
  padding: 0 var(--space-6);
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--on-ink);
  font-size: var(--text-lg);
  font-weight: 600;
  box-shadow: var(--shadow-pill);
  transition: transform 0.2s var(--ease);
}
.cta:hover {
  transform: translateY(-1px);
}

/* Thumbnails, as many across as fit, each over its name. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-8) var(--space-5);
  align-items: start;
  margin-top: var(--space-6);
}
.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.card__shot {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--ring);
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.card:hover .card__shot {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}
.card__shot img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-raised);
}
.card__name {
  padding: 0 var(--space-1);
  font-size: var(--text-base);
  font-weight: 500;
}

.shelf {
  margin-top: var(--space-16);
}
.shelf__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}
.shelf__head h2 a:hover {
  color: var(--accent);
}
.shelf__about {
  margin: var(--space-2) 0 0;
  color: var(--text-2);
}
.more {
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
}

/* One template: its picture beside what it is. */
.one {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: var(--space-12);
  align-items: start;
}
.one__shot {
  display: grid;
  place-items: center;
  margin: 0;
  padding: var(--space-8);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.one__shot img {
  display: block;
  width: 100%;
  max-width: 400px;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-raised);
}
.one h1 {
  font-size: clamp(30px, 4vw, 44px);
}
.one h2 {
  margin-top: var(--space-8);
  font-size: var(--text-lg);
}
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-8);
  margin: var(--space-8) 0 0;
}
.facts dt {
  color: var(--text-3);
  font-size: var(--text-sm);
}
.facts dd {
  margin: 2px 0 0;
  font-weight: 500;
}
.facts a {
  color: var(--accent);
}
.words {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  color: var(--text-2);
}
.words li + li {
  margin-top: var(--space-1);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
}
.tags li {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--pill);
  color: var(--text-2);
  font-size: var(--text-sm);
}

.foot {
  margin-top: var(--space-20);
  padding-top: var(--space-8);
  padding-bottom: var(--space-12);
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: var(--text-md);
}
.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}
.foot strong {
  width: 100%;
  color: var(--text);
  font-weight: 600;
}
.foot nav a:hover {
  color: var(--text);
}
.foot p {
  max-width: 640px;
  margin: var(--space-6) 0 0;
}

@media (max-width: 720px) {
  .wrap {
    padding: 0 var(--space-4);
  }
  .top {
    margin-bottom: var(--space-8);
  }
  .one {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
  .one__shot {
    padding: var(--space-5);
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6) var(--space-3);
  }
  .card__shot {
    padding: var(--space-3);
  }
}

/* Header: the editor one press away; on a phone, the mark alone. */
.pill--ink {
  margin-left: var(--space-1);
  background: var(--ink);
  color: var(--on-ink);
}
.pill--ink:hover {
  background: var(--ink);
  color: var(--on-ink);
  opacity: 0.9;
}

/* A tool: what it does and the button on the left, a picture on the right. */
.one--tool {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: center;
}
.one--tool .one__about {
  order: -1;
}
.lead p {
  margin: 0;
}
.small {
  margin: var(--space-3) 0 0;
  color: var(--text-3);
  font-size: var(--text-md);
}

/* Articles: one readable column. */
.prose {
  max-width: 720px;
  margin-top: var(--space-16);
  color: var(--text);
  font-size: var(--text-lg);
  line-height: 1.65;
}
.prose--post {
  margin: 0 auto;
}
.prose h1 {
  font-size: clamp(32px, 4.5vw, 48px);
}
.prose h2 {
  margin: var(--space-12) 0 var(--space-3);
  font-size: var(--text-2xl);
  line-height: 1.2;
  letter-spacing: -0.025em;
}
.prose h3 {
  margin: var(--space-8) 0 var(--space-2);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.011em;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0 0 var(--space-4);
}
.prose ul,
.prose ol {
  padding-left: var(--space-6);
}
.prose li + li {
  margin-top: var(--space-2);
}
.prose li > ul {
  margin: var(--space-2) 0 0;
}
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.prose strong {
  font-weight: 600;
}
.prose table {
  width: 100%;
  margin: 0 0 var(--space-6);
  border-collapse: collapse;
  font-size: var(--text-base);
}
.prose th,
.prose td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line-strong);
  text-align: left;
}
.prose th {
  color: var(--text-2);
  font-weight: 600;
}
.prose .byline {
  margin: var(--space-4) 0 var(--space-10);
  color: var(--text-3);
  font-size: var(--text-md);
}

/* Under a post: the tool it's about, on a card. */
.try {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  max-width: 720px;
  margin: var(--space-12) auto 0;
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.try div {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.try strong {
  font-size: var(--text-lg);
  font-weight: 600;
}
.try span {
  color: var(--text-2);
}

/* Lists of posts and of tools: a card each. */
.posts,
.tools {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
}
.posts a,
.tools a {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100%;
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--ring);
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.posts a:hover,
.tools a:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}
.posts strong,
.tools strong {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.011em;
  line-height: 1.3;
}
.posts span,
.tools span {
  color: var(--text-2);
}
.posts small {
  margin-top: auto;
  color: var(--text-3);
  font-size: var(--text-md);
}
.foot nav + nav {
  margin-top: var(--space-5);
}

@media (max-width: 720px) {
  /* The mark without its name (it leads to the app), and no separate editor button. */
  .top {
    padding: 0 var(--space-4);
  }
  .brand span,
  .pill--ink {
    display: none;
  }
  .brand {
    padding: 0 8px;
  }
  .pill {
    padding: 0 var(--space-3);
  }
  .one--tool {
    grid-template-columns: 1fr;
  }
  .one--tool .one__shot {
    display: none;
  }
  .prose {
    font-size: var(--text-base);
  }
  .try {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .try .cta {
    justify-content: center;
  }
  .posts,
  .tools {
    grid-template-columns: 1fr;
  }
}

/* The page in other languages, in the footer. */
.foot .langs {
  gap: var(--space-2) var(--space-4);
}
.langs [aria-current] {
  color: var(--text);
  font-weight: 600;
}
