/* ===== CSS-переменные (цветовая схема) ===== */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #1a1a2e;
  --bg-card: #161b22;
  --bg-input: #0d1117;
  --bg-table-alt: #1c2333;
  --text-primary: #e6e6e6;
  --text-secondary: #b0b0b0;
  --text-muted: #8b949e;
  --accent: #f0c040;
  --accent-hover: #ffd700;
  --accent-dim: rgba(240, 192, 64, 0.15);
  --border-color: #30363d;
  --border-focus: #f0c040;
  --font-main: 'Segoe UI', Arial, sans-serif;
  --max-width: 920px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: 0.2s ease;
}

/* ===== Сброс и базовые стили ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Макет: одноцентровая колонка ===== */
.page-header,
main,
.page-footer {
  width: 100%;
  max-width: var(--max-width);
  padding-left: 20px;
  padding-right: 20px;
}

main {
  flex: 1;
}

/* ===== HEADER ===== */
.page-header {
  text-align: center;
  padding-top: 40px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 10px;
}

.page-title {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 18px;
  text-shadow: 0 0 30px rgba(240, 192, 64, 0.15);
}

/* ===== Навигация ===== */
.nav-list {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}

.nav-list a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.nav-list a:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ===== Секции ===== */
.section {
  padding: 40px 0;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 24px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent-dim);
}

/* ===== Историческая справка ===== */
.history-content p {
  margin-bottom: 18px;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.history-content strong {
  color: var(--accent);
  font-weight: 600;
}

/* ===== Таблица ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.morse-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 320px;
}

.morse-table thead {
  background-color: var(--bg-secondary);
}

.morse-table th {
  padding: 12px 18px;
  text-align: left;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.morse-table td {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-color);
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}

/* Zebra-striping */
.morse-table tbody tr:nth-child(even) {
  background-color: var(--bg-table-alt);
}

.morse-table tbody tr:nth-child(odd) {
  background-color: transparent;
}

.morse-table tbody tr:hover {
  background-color: var(--accent-dim);
  transition: background var(--transition);
}

/* ===== Переводчик ===== */
.translator-container {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.translator-mode {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.translator-label {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Поля ввода/вывода */
.translator-input,
.translator-output {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.translator-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.translator-output:focus {
  border-color: var(--text-muted);
  box-shadow: 0 0 0 3px rgba(139, 148, 158, 0.15);
}

.translator-output {
  background-color: var(--bg-secondary);
  border-left: 3px solid var(--accent-dim);
  cursor: text;
  user-select: text;
}

/* Кнопки */
.btn {
  display: inline-block;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-main);
  color: #0d1117;
  background-color: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  align-self: flex-start;
}

.btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(240, 192, 64, 0.3);
}

.btn:active {
  transform: translateY(0);
}

/* ===== FOOTER ===== */
.page-footer {
  text-align: center;
  padding: 24px 20px;
  border-top: 1px solid var(--border-color);
  margin-top: 20px;
}

.page-footer p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== Медиа-запросы (мобильные устройства) ===== */

/* Планшеты и маленькие экраны */
@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }

  .section-title {
    font-size: 1.3rem;
  }

  .section {
    padding: 28px 0;
  }

  .translator-mode {
    padding: 18px;
  }

  .btn {
    width: 100%;
    text-align: center;
  }
}

/* Телефоны */
@media (max-width: 480px) {
  .page-header {
    padding-top: 24px;
    padding-bottom: 20px;
  }

  .page-title {
    font-size: 1.6rem;
  }

  .nav-list {
    gap: 12px;
  }

  .nav-list a {
    font-size: 0.9rem;
    padding: 4px 10px;
  }

  .section-title {
    font-size: 1.1rem;
  }

  .history-content p {
    font-size: 0.95rem;
  }

  /* Поля на всю ширину уже через width: 100% */
  .translator-input,
  .translator-output {
    font-size: 0.9rem;
    padding: 10px 12px;
  }

  .morse-table {
    font-size: 0.85rem;
  }

  .morse-table th,
  .morse-table td {
    padding: 8px 12px;
  }

  .page-footer p {
    font-size: 0.75rem;
  }
}

/* Специально для очень узких экранов — дополнительная прокрутка */
@media (max-width: 360px) {
  .table-wrapper {
    margin: 0 -10px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}
