/* =============================================================
   Курс «Мобильные и веб-технологии, сервисы»
   Общие стили всех страниц
   ============================================================= */

/* ---------- 1. Токены темы ---------- */
:root {
  --bg:          #f5f7fb;
  --surface:     #ffffff;
  --surface-2:   #eef2f8;
  --text:        #0f172a;
  --muted:       #64748b;
  --accent:      #2563eb;
  --accent-soft: #e0ecff;
  --accent-2:    #7c3aed;
  --border:      #e2e8f0;
  --ok:          #16a34a;
  --ok-soft:     #dcfce7;
  --err:         #dc2626;
  --err-soft:    #fee2e2;
  --warn:        #d97706;
  --warn-soft:   #fef3c7;

  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 12px 28px -18px rgba(15, 23, 42, .5);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --t: .22s ease;
}

[data-theme="dark"] {
  --bg:          #0a1120;
  --surface:     #111a2e;
  --surface-2:   #182338;
  --text:        #e8eefc;
  --muted:       #93a3bd;
  --accent:      #60a5fa;
  --accent-soft: #17243d;
  --accent-2:    #a78bfa;
  --border:      #22304a;
  --ok-soft:     #10331f;
  --err-soft:    #3a1414;
  --warn-soft:   #3a2a0c;
  --shadow:      0 12px 28px -18px rgba(0, 0, 0, .95);
}

/* ---------- 2. База ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  transition: background var(--t), color var(--t);
}

h1, h2, h3, h4 { margin: 0 0 .6em; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(1.75rem, 1.1rem + 2.4vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.65rem); }
h3 { font-size: 1.1rem; }
p  { margin: 0 0 1em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--surface-2);
  padding: .12em .42em;
  border-radius: 5px;
}

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

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

.container { width: min(1160px, 100%); margin-inline: auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--accent); color: #fff; padding: .7rem 1.1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------- 3. Навигация ---------- */
.navbar {
  position: sticky; top: 0; z-index: 900;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 64px;
}

.logo {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 800; font-size: 1.02rem; color: var(--text); letter-spacing: -.03em;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: .8rem; font-weight: 800; letter-spacing: -.04em;
}
.logo-text span { color: var(--accent); }

.nav-links {
  display: flex; align-items: center; gap: 1.6rem;
  list-style: none; margin: 0; padding: 0;
}
.nav-links a {
  color: var(--muted); font-size: .93rem; font-weight: 500;
  padding: .35rem 0; border-bottom: 2px solid transparent; transition: var(--t);
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.nav-actions { display: flex; align-items: center; gap: .5rem; }

.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: 1rem; cursor: pointer; transition: var(--t);
}
.icon-btn:hover { border-color: var(--accent); }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 38px; height: 38px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; transition: var(--t); }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- 4. Hero ---------- */
.hero {
  background:
    radial-gradient(900px 380px at 15% -10%, rgba(96, 165, 250, .35), transparent 65%),
    linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  color: #fff;
  padding: clamp(3rem, 8vw, 6rem) 0;
}
.hero h1 { color: #fff; }
.hero .lead { font-size: 1.1rem; color: #c7d2e5; max-width: 62ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.6rem; }

/* ---------- 5. Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.35rem; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; font-size: .94rem;
  cursor: pointer; transition: var(--t); text-decoration: none;
}
.btn:hover { background: color-mix(in srgb, var(--accent) 85%, #000); text-decoration: none; }
.btn-ghost {
  background: transparent; color: var(--text); border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--accent); }
.hero .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.hero .btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-sm { padding: .42rem .8rem; font-size: .84rem; }

/* ---------- 6. Секции ---------- */
.section { padding: clamp(2.4rem, 5vw, 3.6rem) 0; }
.section-head { max-width: 68ch; margin-bottom: 1.8rem; }
.section-head p { color: var(--muted); margin: 0; }

.page-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 2.2rem 0 1.9rem;
}
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.page-head .lead { color: var(--muted); max-width: 72ch; margin: 0; }

.badges { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.badge {
  display: inline-block; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: .28rem .6rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.badge.ok   { background: var(--ok-soft);   color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- 7. Сетка карточек ---------- */
.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  transition: var(--t);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.card h3 { margin-bottom: .4rem; }
.card p  { color: var(--muted); font-size: .93rem; margin-bottom: 1rem; }
.card .card-icon { font-size: 1.5rem; margin-bottom: .7rem; }
.card-num {
  position: absolute; top: 1.1rem; right: 1.2rem;
  font-size: .78rem; font-weight: 800; color: var(--muted); opacity: .6;
}
.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  margin-top: auto; padding-top: .9rem; border-top: 1px solid var(--border);
}
.card-foot .go { font-weight: 600; font-size: .9rem; }

/* ---------- 8. Прогресс ---------- */
.progress-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.6rem;
}
.progress-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px; transition: width .35s ease;
}
.progress-label { font-size: .87rem; color: var(--muted); margin: .6rem 0 0; }

/* ---------- 9. Демо-панели ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1.4rem;
}
.panel > h2 { margin-top: 0; }

.demo-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.demo-pane {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--surface);
}
.pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .5rem .8rem; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.code-editor {
  width: 100%; min-height: 300px; flex: 1; resize: vertical;
  border: 0; outline: none; padding: 1rem;
  font-family: var(--mono); font-size: .85rem; line-height: 1.6;
  background: var(--surface); color: var(--text);
  tab-size: 2;
}
.preview-frame {
  width: 100%; min-height: 300px; flex: 1;
  border: 0; background: #fff;
}

/* ---------- 10. Блоки кода ---------- */
.code-block {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 1.4rem; background: var(--surface);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .45rem .8rem .45rem 1rem;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: .78rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.copy-btn {
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--muted);
  font: inherit; font-size: .74rem; font-weight: 600;
  padding: .26rem .6rem; cursor: pointer; transition: var(--t);
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.is-ok { color: var(--ok); border-color: var(--ok); }
.code-block pre {
  margin: 0; padding: 1rem; overflow-x: auto;
  font-family: var(--mono); font-size: .84rem; line-height: 1.65;
}
.code-block pre code { background: none; padding: 0; font-size: inherit; }

/* ---------- 11. Заметки и задания ---------- */
.note {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: .9rem 1.1rem; margin-bottom: 1.2rem; font-size: .93rem;
}
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note.ok   { border-color: var(--ok);   background: var(--ok-soft); }
.note :last-child { margin-bottom: 0; }

.task {
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: var(--radius); padding: 1.2rem 1.3rem; background: var(--surface);
}
.task h2, .task h3 { margin-top: 0; }
.task ol, .task ul { padding-left: 1.2rem; margin: 0; }
.task li { margin-bottom: .4rem; }

/* ---------- 12. Формы и элементы управления ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .87rem; font-weight: 600; margin-bottom: .3rem; }
.field .hint { font-size: .78rem; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="url"],
select, textarea {
  width: 100%; padding: .62rem .8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .93rem; outline: none; transition: var(--t);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--err); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 18%, transparent); }

.error-text { display: block; min-height: 1.1em; font-size: .78rem; color: var(--err); margin-top: .25rem; }

.controls { display: grid; gap: .85rem; }
.control-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: .8rem; }
.control-row label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.control-row output { font-family: var(--mono); font-size: .8rem; color: var(--accent); }

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 17px; height: 17px; }

.checkline { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }

/* ---------- 13. Песочница макета (css-layout) ---------- */
.sandbox {
  display: flex; gap: 12px; padding: 14px;
  min-height: 260px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px dashed var(--border);
}
.sandbox-item {
  display: grid; place-items: center;
  min-width: 68px; min-height: 68px; padding: .6rem;
  border-radius: 10px; font-weight: 700; color: #fff; font-size: .95rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* ---------- 14. Симулятор устройства ---------- */
.device-stage {
  display: grid; place-items: center;
  padding: 1.4rem; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  overflow: auto;
}
.device-frame {
  width: 375px; max-width: 100%; height: 460px;
  border: 8px solid #1f2937; border-radius: 26px;
  background: #fff; overflow: hidden;
  transition: width .25s ease; box-shadow: var(--shadow);
}
.device-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- 15. Список дел ---------- */
.todo-form { display: flex; gap: .6rem; margin-bottom: 1rem; }
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.todo-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .8rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
}
.todo-item.is-done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-text { flex: 1; font-size: .93rem; word-break: break-word; }
.todo-del {
  border: 0; background: transparent; color: var(--muted);
  font-size: 1.1rem; line-height: 1; cursor: pointer; padding: .2rem .4rem; border-radius: 6px;
}
.todo-del:hover { color: var(--err); background: var(--err-soft); }
.todo-filters { display: flex; gap: .4rem; margin: 1rem 0 .8rem; }
.todo-filters button {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: .3rem .8rem; font: inherit; font-size: .82rem; cursor: pointer; transition: var(--t);
}
.todo-filters button.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 16. Статусы сети / SW ---------- */
.status-line { display: flex; align-items: center; gap: .5rem; font-size: .9rem; margin-bottom: .5rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.is-offline { background: var(--err); }
.output {
  margin: 0; padding: 1rem; max-height: 320px; overflow: auto;
  font-family: var(--mono); font-size: .82rem; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  white-space: pre-wrap; word-break: break-word;
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 17. Навигация между занятиями ---------- */
.lesson-nav {
  display: flex; flex-wrap: wrap; gap: .8rem; justify-content: space-between;
  margin: 2.4rem 0 1rem; padding-top: 1.4rem; border-top: 1px solid var(--border);
}
.lesson-nav a {
  flex: 1 1 220px; padding: .9rem 1.1rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); transition: var(--t);
}
.lesson-nav a:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.lesson-nav small { display: block; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
.lesson-nav strong { display: block; color: var(--text); font-size: .95rem; }
.lesson-nav .next { text-align: right; }

/* ---------- 18. Таблица ---------- */
.table-wrap { overflow-x: auto; margin-bottom: 1.4rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tbody tr:hover { background: var(--surface-2); }

/* ---------- 19. Подвал ---------- */
.footer {
  margin-top: 3rem; padding: 2rem 0;
  background: #0f172a; color: #94a3b8; font-size: .89rem;
}
.footer a { color: #e2e8f0; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; }
.footer p { margin: 0; }

/* ---------- 20. Адаптивность ---------- */
@media (max-width: 900px) {
  .demo-split { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .5rem 20px 1rem;
    display: none;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { display: block; padding: .7rem 0; border-bottom: 1px solid var(--border); }
  .nav-links a.is-active { border-bottom-color: var(--border); }
  .control-row { grid-template-columns: 1fr; gap: .25rem; }
  .lesson-nav .next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
