/* ==========================================================================
   Общие стили сайта: токены, тёмная тема, типографика, базовые элементы.
   Подключается на всех страницах.
   ========================================================================== */

/* --- Токены (светлая тема по умолчанию) --- */
:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --fg: #16181d;
  --muted: #6b7280;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --border: #e5e7eb;
  --rule: #e5e7eb;

  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-fg: #ffffff;
  --ring: rgba(217, 119, 6, 0.35);

  --shadow-sm: 0 1px 2px rgba(16, 17, 20, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 17, 20, 0.10);
}

/* --- Тёмная тема (автоматически по системной настройке) --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --fg: #f2f3f5;
    --muted: #9aa0a8;
    --surface: #17181c;
    --surface-2: #1f2126;
    --border: #2a2c32;
    --rule: #26282d;

    --accent: #f59e0b;
    --accent-strong: #fbbf24;
    --accent-fg: #1a1206;
    --ring: rgba(245, 158, 11, 0.45);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.50);
  }
}

/* --- Ручное переключение темы (атрибут data-theme на <html>) --- */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #ffffff;
  --fg: #16181d;
  --muted: #6b7280;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --border: #e5e7eb;
  --rule: #e5e7eb;

  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-fg: #ffffff;
  --ring: rgba(217, 119, 6, 0.35);

  --shadow-sm: 0 1px 2px rgba(16, 17, 20, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 17, 20, 0.10);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #101114;
  --fg: #f2f3f5;
  --muted: #9aa0a8;
  --surface: #17181c;
  --surface-2: #1f2126;
  --border: #2a2c32;
  --rule: #26282d;

  --accent: #f59e0b;
  --accent-strong: #fbbf24;
  --accent-fg: #1a1206;
  --ring: rgba(245, 158, 11, 0.45);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.50);
}

/* --- Сброс и база --- */
* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

h1, h2, h3, h4 {
  margin: 0 0 1.25rem;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 8vw, 2.75rem);
}

p {
  margin: 0 0 0.6rem;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

hr {
  margin: 2rem 0 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.muted {
  color: var(--muted);
}

/* --- Раскладка --- */
.container {
  width: 100%;
  max-width: 44rem;
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.container--wide {
  max-width: 76rem;
}

.layout-center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
}

/* --- Кнопки --- */
button {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.2;
  transition: border-color 0.15s, background 0.15s;
}

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

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn--ghost {
  background: transparent;
}

/* --- Переключатель темы --- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.9rem;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle--fixed {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 30;
}

/* --- Список проектов (главная) --- */
.projects ul {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.projects a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  color: var(--fg);
  text-decoration: none;
  background: var(--surface);
  transition: border-color 0.15s;
}

.projects a:hover {
  border-color: var(--accent);
}

/* --- Доступность --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}
