/* Morse Code Translator Tool — stylesheet
   Clean, mobile-first, fast. Single-file, no external fonts. */

:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --border: #e2e8f0;
  --ink: #0f172a;
  --muted: #64748b;
  --accent: #0c4a6e;
  --accent-hover: #083548;
  --good: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15,23,42,0.05), 0 4px 12px rgba(15,23,42,0.04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}

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

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.brand {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-weight: 700; font-size: 18px; text-decoration: none; color: var(--ink);
}
.brand-dot { color: var(--accent); font-size: 22px; }
.brand-dash { color: var(--accent); font-size: 22px; letter-spacing: -2px; }
.brand-text { margin-left: 6px; }
.site-header nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-header nav a { text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; }
.site-header nav a:hover { color: var(--accent); }

/* Hero */
.hero { padding: 28px 0 12px; }
.hero h1 { font-size: clamp(26px, 4.5vw, 36px); margin: 0 0 8px; }
.lede { font-size: 17px; color: var(--muted); margin: 0; max-width: 640px; }

/* Ads */
.ad-slot {
  margin: 20px 0;
  padding: 8px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.ad-slot::before { content: "Advertisement"; opacity: 0.6; }
.ad-slot ins { width: 100%; }

/* Tool */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0 24px;
}
.mode-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.mode-tabs button {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  transition: all 0.15s;
}
.mode-tabs button:hover { border-color: var(--accent); color: var(--accent); }
.mode-tabs button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.io-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) { .io-grid { grid-template-columns: 1fr; } }
.io-cell label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
textarea {
  width: 100%;
  padding: 12px;
  font-family: var(--mono);
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  resize: vertical;
  line-height: 1.5;
  color: var(--ink);
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 20px 0 16px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ctrl label { font-size: 13px; font-weight: 600; color: var(--ink); display: block; margin-bottom: 6px; }
.ctrl label span { color: var(--accent); font-weight: 700; }
.ctrl select,
.ctrl input[type="range"] { width: 100%; }
.ctrl select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 14px;
}
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: auto; margin: 0; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.actions button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: all 0.15s;
}
.actions button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.actions button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.actions button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.actions button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Flash overlay */
#flash-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  pointer-events: none;
  opacity: 0;
  z-index: 9999;
  transition: opacity 0.03s;
}
#flash-overlay.on { opacity: 1; background: #fff; }

/* Article content */
.content { margin: 32px 0; }
.content h2 {
  font-size: 24px;
  margin: 32px 0 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}
.content h2:first-child { border-top: none; padding-top: 0; }
.content h3 { font-size: 18px; margin: 20px 0 8px; }
.content p, .content li { font-size: 16px; line-height: 1.7; }
.content ul { padding-left: 22px; }
.content code {
  font-family: var(--mono);
  background: var(--surface);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.92em;
  color: var(--accent);
}
.content .prosign {
  font-family: var(--mono);
  text-decoration: overline;
  font-weight: 700;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 32px 0;
  margin-top: 48px;
}
.site-footer .brand-line { margin: 0 0 12px; font-weight: 600; }
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 16px;
}
.footer-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.footer-nav a:hover { color: var(--accent); }
.copy { color: var(--muted); font-size: 13px; margin: 0; }

/* Legal/simple pages */
.page-simple { max-width: 760px; margin: 32px auto; padding: 0 16px; }
.page-simple h1 { font-size: 28px; margin: 0 0 8px; }
.page-simple .updated { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.page-simple h2 { font-size: 20px; margin: 28px 0 10px; }
.page-simple p, .page-simple li { font-size: 15px; line-height: 1.7; }
.page-simple a.email {
  font-family: var(--mono);
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
}

/* Accessibility */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
