/* MorseFlare - Morse Code Translator Styles */
:root {
  --navy: #0A2540;
  --navy-2: #123456;
  --teal: #20C997;        /* brand accent */
  --teal-dark: #16A784;   /* hover / darker accent */
  --teal-text: #0B7A5E;   /* accessible teal for text on white */
  --light: #F8FAFC;
  --gray: #64748B;
  --white: #FFFFFF;
  --line: #E2E8F0;
  --shadow: 0 4px 20px rgba(10, 37, 64, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--light);
  color: var(--navy);
  line-height: 1.7;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

a {
  color: var(--teal-dark);
}

/* ---------- header ---------- */
header {
  background: var(--navy);
  color: var(--white);
  padding: 0.75rem 0;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--white);
  font-weight: 700;
  font-size: 1.35rem;
}

.logo img {
  height: 34px;
  width: auto;
}

nav a {
  color: var(--white);
  text-decoration: none;
  margin-left: 1.25rem;
  font-weight: 500;
  opacity: 0.9;
  transition: opacity 0.2s, color 0.2s;
}

nav a:hover, nav a.active {
  opacity: 1;
  color: var(--teal);
}

/* ---------- hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: var(--white);
  padding: 2.25rem 0 2.75rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.4rem;
  font-weight: 800;
  line-height: 1.15;
}

.hero p {
  font-size: 1.15rem;
  max-width: 720px;
  margin: 0 auto;
  opacity: 0.92;
}

/* ---------- tool ---------- */
.tool-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-top: -32px;
  position: relative;
  z-index: 10;
}

.tool-controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.mode-toggle {
  display: flex;
  background: #E2E8F0;
  border-radius: 8px;
  padding: 4px;
  gap: 2px;
  flex-wrap: wrap;
}

.mode-toggle button {
  border: none;
  background: transparent;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
}

.mode-toggle button.active {
  background: var(--teal);
  color: var(--navy);
}

button#swap {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--navy);
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
}

.mode-hint {
  color: var(--gray);
  font-size: 0.9rem;
}

label.input-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--navy);
}

textarea {
  width: 100%;
  min-height: 130px;
  padding: 0.9rem 1rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  font-size: 1.05rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
  color: var(--navy);
  background: var(--white);
}

textarea:focus {
  outline: none;
  border-color: var(--teal-dark);
}

.output-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.25rem 0 0.4rem;
}

.output-heading span {
  font-weight: 600;
  color: var(--navy);
}

.output {
  background: #F1F5F9;
  padding: 1.1rem 1.2rem;
  border-radius: 12px;
  min-height: 72px;
  font-family: 'Courier New', ui-monospace, Menlo, monospace;
  font-size: 1.15rem;
  word-break: break-all;
  margin-bottom: 0.6rem;
  white-space: pre-wrap;
  color: var(--navy);
  border: 2px solid transparent;
}

.output.flash {
  animation: flash 1.4s ease-out;
}

@keyframes flash {
  0% { border-color: var(--teal); background: #D9F5EC; }
  100% { border-color: transparent; background: #F1F5F9; }
}

.note {
  font-size: 0.9rem;
  color: #92400E;
  background: #FEF3C7;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
}

.btn-group {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

button, .btn {
  background: var(--teal);
  color: var(--navy); /* dark-on-teal: passes WCAG AA */
  border: none;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 0.2s, transform 0.1s;
}

button:hover, .btn:hover {
  background: var(--teal-dark);
  color: var(--navy);
  transform: translateY(-1px);
}

button:focus-visible, .btn:focus-visible, .mode-toggle button:focus-visible,
.alphabet-item:focus-visible, summary:focus-visible, nav a:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

button.secondary {
  background: #E2E8F0;
  color: var(--navy);
}

button.secondary:hover {
  background: #CBD5E1;
}

.audio-controls {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.audio-controls label {
  font-size: 0.9rem;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.val {
  display: inline-block;
  min-width: 2.4rem;
  text-align: center;
  background: var(--navy);
  color: var(--white);
  border-radius: 6px;
  padding: 0.05rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
}

input[type="range"] {
  width: 120px;
  accent-color: var(--teal-dark);
}

/* ---------- content ---------- */
.content-section {
  padding: 3.5rem 0 2rem;
}

.content-section h2 {
  font-size: 1.9rem;
  margin: 2rem 0 1rem;
  color: var(--navy);
  line-height: 1.25;
}

.content-section h2:first-child {
  margin-top: 0;
}

.content-section h3 {
  font-size: 1.35rem;
  margin: 1.5rem 0 0.6rem;
  color: var(--navy);
}

.content-section p,
.content-section li {
  color: #334155;
}

.content-section ul,
.content-section ol {
  margin: 0.5rem 0 1rem 1.4rem;
}

.content-section li {
  margin-bottom: 0.4rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--white);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

ol.steps {
  list-style: none;
  margin: 1.5rem 0;
  counter-reset: step;
  display: grid;
  gap: 1rem;
}

ol.steps li {
  counter-increment: step;
  position: relative;
  padding: 1rem 1rem 1rem 3.5rem;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

ol.steps li::before {
  content: counter(step);
  position: absolute;
  left: 1rem;
  top: 1rem;
  width: 1.8rem;
  height: 1.8rem;
  background: var(--teal);
  color: var(--navy);
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- alphabet grid ---------- */
.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0 1.5rem;
}

.alphabet-item {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  color: var(--navy);
  font-family: inherit;
}

.alphabet-item:hover {
  transform: translateY(-3px);
  border-color: var(--teal-dark);
}

.alphabet-item .char {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--navy);
}

.alphabet-item .code {
  font-family: ui-monospace, 'Courier New', monospace;
  color: var(--teal-text); /* accessible on white */
  font-size: 1.05rem;
}

.alphabet-note {
  background: #F1F5F9;
  border-left: 4px solid var(--teal-dark);
  padding: 0.9rem 1.1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
  margin: 1.5rem 0;
  color: #334155;
}

/* ---------- FAQ ---------- */
.faq details {
  background: var(--white);
  margin-bottom: 0.75rem;
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow);
}

.faq summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--navy);
}

.faq details p {
  margin-top: 0.6rem;
  color: #334155;
}

/* ---------- footer ---------- */
footer {
  background: var(--navy);
  color: var(--white);
  padding: 2.5rem 0 1.5rem;
  margin-top: 3rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-inner a {
  color: var(--teal);
  text-decoration: none;
}

.footer-inner a:hover {
  text-decoration: underline;
}

.footer-meta {
  color: #94A3B8;
  font-size: 0.85rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #1E3A5F;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--navy);
  color: var(--white);
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
}

/* ---------- character-by-character ---------- */
.char-map-details {
  margin: 0.5rem 0 1.25rem;
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
}

.char-map-details summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--navy);
}

.char-map {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  margin-top: 0.7rem;
}

.cm-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.95rem;
}

.cm-item b { color: var(--navy); }

.cm-item code {
  font-family: ui-monospace, 'Courier New', monospace;
  color: var(--teal-text);
}

.cm-word {
  align-self: center;
  color: var(--gray);
  font-weight: 700;
  font-family: ui-monospace, monospace;
}

/* ---------- flashlight ---------- */
#flashlight-overlay {
  position: fixed;
  inset: 0;
  background: #050d18;
  z-index: 9999;
  cursor: pointer;
  transition: background 0.03s;
}

#flashlight-overlay.lit {
  background: #FFFFFF;
}

#flashlight-overlay .hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: #94A3B8;
  font-size: 0.85rem;
  background: rgba(10, 37, 64, 0.6);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  pointer-events: none;
}

#flashlight-overlay.lit .hint {
  color: #0A2540;
  background: rgba(255, 255, 255, 0.6);
}

/* ---------- responsive ---------- */
@media (max-width: 768px) {
  .hero { padding: 1.75rem 0 2.25rem; }
  .hero h1 { font-size: 1.9rem; }
  .grid-2 { grid-template-columns: 1fr; }
  nav a { margin-left: 0.9rem; font-size: 0.9rem; }
  .header-inner { flex-direction: column; gap: 0.4rem; }
  .tool-card { padding: 1.1rem; }
  .audio-controls { gap: 0.9rem; }
  input[type="range"] { width: 100px; }
  .content-section h2 { font-size: 1.6rem; }
  .mode-toggle button { padding: 0.45rem 0.7rem; }
}
