/* ============================================================
   Oversaet.dk — Premium UI
   Aesthetic: Nordic Precision · Deep Sapphire · DM Sans
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ── Design tokens ── */
:root {
  /* Sapphire palette */
  --sapphire-950: #0c1e3e;
  --sapphire-900: #112952;
  --sapphire-800: #1a3a6b;
  --sapphire-700: #1e4a85;
  --sapphire-600: #2358a0;
  --sapphire-500: #2d6bc4;
  --sapphire-400: #4f88d4;
  --sapphire-300: #7baee3;
  --sapphire-200: #b3d0f1;
  --sapphire-100: #daeaf9;
  --sapphire-50:  #f0f6fd;

  /* Warm neutrals */
  --warm-50:  #fafaf9;
  --warm-100: #f4f4f2;
  --warm-200: #e8e8e4;
  --warm-300: #d4d4ce;
  --warm-400: #a8a89e;
  --warm-500: #7a7a72;
  --warm-600: #5a5a54;
  --warm-700: #3d3d38;
  --warm-800: #262622;
  --warm-900: #141410;

  /* Semantic */
  --color-bg:        #f5f6f8;
  --color-surface:   #ffffff;
  --color-border:    #e2e4e9;
  --color-border-subtle: #eceef2;
  --color-text:      var(--warm-800);
  --color-text-muted: var(--warm-500);
  --color-text-faint: var(--warm-400);
  --color-accent:    var(--sapphire-600);
  --color-accent-hover: var(--sapphire-700);
  --color-accent-subtle: var(--sapphire-50);
  --color-error:     #c0392b;
  --color-error-bg:  #fdf3f2;

  /* Radius */
  --radius-xs:  4px;
  --radius-sm:  8px;
  --radius:    14px;
  --radius-lg: 20px;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(10, 25, 55, 0.04);
  --shadow-sm:  0 2px 6px rgba(10, 25, 55, 0.06), 0 1px 2px rgba(10, 25, 55, 0.04);
  --shadow-md:  0 4px 16px rgba(10, 25, 55, 0.08), 0 2px 6px rgba(10, 25, 55, 0.05);
  --shadow-lg:  0 12px 32px rgba(10, 25, 55, 0.10), 0 4px 12px rgba(10, 25, 55, 0.06);
  --shadow-btn: 0 2px 8px rgba(35, 88, 160, 0.30), 0 1px 3px rgba(35, 88, 160, 0.20);
  --shadow-btn-hover: 0 4px 16px rgba(35, 88, 160, 0.40), 0 2px 6px rgba(35, 88, 160, 0.25);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast:   120ms;
  --t-base:   200ms;
  --t-slow:   350ms;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ── */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* Subtle dot-grid background on the page */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(35, 88, 160, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */
.container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--sapphire-950) 0%, var(--sapphire-800) 55%, var(--sapphire-700) 100%);
  color: #ffffff;
  padding: 22px 0 20px;
  position: relative;
  overflow: hidden;
}

/* Mesh highlight in header */
.header::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -10%;
  width: 520px;
  height: 520px;
  background: radial-gradient(ellipse at center, rgba(79, 136, 212, 0.22) 0%, transparent 70%);
  pointer-events: none;
}

.header::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: 5%;
  width: 320px;
  height: 320px;
  background: radial-gradient(ellipse at center, rgba(26, 58, 107, 0.5) 0%, transparent 70%);
  pointer-events: none;
}

.header .container {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Globe icon before logo */
.header-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

.header-text {
  display: flex;
  flex-direction: column;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ffffff;
  line-height: 1.15;
}

.logo span {
  color: var(--sapphire-300);
}

.tagline {
  font-size: 0.8125rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
  letter-spacing: 0.01em;
}

/* ── Main ── */
main {
  flex: 1;
  padding: 28px 0 20px;
  position: relative;
  z-index: 1;
}

/* ── Translator card ── */
.translator {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--color-border-subtle);
  transition: box-shadow var(--t-slow) var(--ease-out);
}

.translator:focus-within {
  box-shadow: var(--shadow-lg), 0 0 0 3px rgba(35, 88, 160, 0.08);
}

/* ── Language bar ── */
.lang-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: linear-gradient(to bottom, var(--sapphire-50), #f8fafd);
  border-bottom: 1px solid var(--color-border-subtle);
}

/* Language label chips above selects on mobile */
.lang-bar-label {
  display: none;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: 3px;
}

.lang-select-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.lang-bar select {
  width: 100%;
  padding: 9px 36px 9px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237a7a72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  transition: border-color var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out);
  outline: none;
}

.lang-bar select:hover {
  border-color: var(--sapphire-300);
}

.lang-bar select:focus {
  border-color: var(--sapphire-500);
  box-shadow: 0 0 0 3px rgba(45, 107, 196, 0.14);
}

/* ── Swap button ── */
.swap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1.5px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--sapphire-600);
  cursor: pointer;
  transition:
    background var(--t-base) var(--ease-out),
    border-color var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out),
    transform var(--t-slow) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out);
  position: relative;
}

.swap-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--sapphire-50);
  opacity: 0;
  transition: opacity var(--t-base) var(--ease-out);
}

.swap-btn:hover {
  background: var(--sapphire-600);
  border-color: var(--sapphire-600);
  color: #ffffff;
  transform: rotate(180deg);
  box-shadow: var(--shadow-btn);
}

.swap-btn:active {
  transform: rotate(180deg) scale(0.93);
}

.swap-btn svg {
  position: relative;
  z-index: 1;
  transform: rotate(90deg);
}

/* ── Text panels ── */
.text-panels {
  display: grid;
  grid-template-columns: 1fr;
}

.panel {
  display: flex;
  flex-direction: column;
}

.source-panel {
  border-bottom: 1px solid var(--color-border-subtle);
}

/* Subtle label inside panel */
.panel-label {
  display: none;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  padding: 10px 18px 0;
}

.panel textarea {
  flex: 1;
  min-height: 190px;
  padding: 18px 18px 10px;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
  resize: vertical;
  color: var(--color-text);
  background: transparent;
  outline: none;
  transition: background var(--t-base) var(--ease-out);
}

.panel textarea::placeholder {
  color: var(--color-text-faint);
  font-style: italic;
  font-weight: 300;
}

.source-panel textarea:focus {
  background: rgba(240, 246, 253, 0.4);
}

.target-panel {
  background: #fafbfd;
}

.target-panel textarea {
  background: transparent;
  color: var(--sapphire-800);
  font-weight: 400;
}

/* ── Panel footer ── */
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--color-border-subtle);
}

#char-count {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--color-text-faint);
  letter-spacing: 0.02em;
  transition: color var(--t-base) var(--ease-out);
}

#char-count.has-text {
  color: var(--warm-500);
}

/* ── Action buttons (clear / copy) ── */
.clear-btn,
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  color: var(--warm-600);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out);
}

.clear-btn:hover {
  background: #fff1f0;
  border-color: #f7c5c0;
  color: var(--color-error);
}

.copy-btn:hover {
  background: var(--sapphire-50);
  border-color: var(--sapphire-200);
  color: var(--sapphire-700);
}

.clear-btn:active,
.copy-btn:active {
  transform: scale(0.96);
}

/* Success state for copy */
.copy-btn.copied {
  background: #f0fdf4;
  border-color: #86efac;
  color: #16a34a;
}

/* ── Translate button ── */
.translate-btn-wrap {
  padding: 16px 18px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-top: 1px solid var(--color-border-subtle);
  background: linear-gradient(to bottom, #fafbfd, var(--color-surface));
}

.translate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 40px;
  background: linear-gradient(135deg, var(--sapphire-600) 0%, var(--sapphire-800) 100%);
  color: #ffffff;
  border: none;
  border-radius: 40px;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition:
    background var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out),
    transform var(--t-base) var(--ease-out),
    opacity var(--t-base) var(--ease-out);
  position: relative;
  overflow: hidden;
  min-width: 160px;
}

/* Shimmer overlay on hover */
.translate-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.55s var(--ease-out);
  pointer-events: none;
}

.translate-btn:hover {
  background: linear-gradient(135deg, var(--sapphire-500) 0%, var(--sapphire-700) 100%);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-1px);
}

.translate-btn:hover::before {
  left: 140%;
}

.translate-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-btn);
}

.translate-btn:disabled {
  background: linear-gradient(135deg, var(--warm-300) 0%, var(--warm-400) 100%);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
  opacity: 0.7;
}

/* Loading spinner */
.translate-btn.loading {
  position: relative;
  color: transparent;
}

.translate-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Keyboard shortcut hint */
.kbd-hint {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--color-text-faint);
  letter-spacing: 0.02em;
  white-space: nowrap;
  display: none;
}

.kbd-hint kbd {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid var(--color-border);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--warm-50);
  font-family: inherit;
  font-size: inherit;
  color: var(--warm-500);
  line-height: 1.4;
}

/* ── Error message ── */
.error-msg {
  padding: 12px 18px;
  margin: 0 18px 14px;
  background: var(--color-error-bg);
  color: var(--color-error);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid rgba(192, 57, 43, 0.15);
  animation: slideDown 0.2s var(--ease-out);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── SEO content ── */
.seo-content {
  margin-top: 28px;
  padding: 24px 26px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-xs);
  color: var(--warm-600);
  line-height: 1.75;
  font-size: 0.9375rem;
  position: relative;
  overflow: hidden;
}

.seo-content h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--warm-800);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.seo-content p {
  margin-bottom: 10px;
}

.seo-content p:last-child {
  margin-bottom: 0;
}

.seo-content strong {
  color: var(--sapphire-700);
  font-weight: 600;
}

/* ── Popular pairs ── */
.popular-pairs {
  margin-top: 24px;
  padding: 24px 26px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-subtle);
  position: relative;
  z-index: 1;
}

.popular-pairs h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--warm-800);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.lang-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lang-link {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  background: var(--warm-100);
  color: var(--sapphire-700);
  border: 1px solid var(--color-border-subtle);
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}

.lang-link:hover {
  background: var(--sapphire-50);
  border-color: var(--sapphire-200);
}

.lang-link--active {
  background: var(--sapphire-600);
  color: #fff;
  border-color: var(--sapphire-600);
}

/* ── FAQ ── */
.faq {
  margin-top: 24px;
  padding: 24px 26px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-subtle);
  position: relative;
  z-index: 1;
}

.faq h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--warm-800);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.faq details {
  border-top: 1px solid var(--color-border-subtle);
  padding: 0;
}

.faq details:first-of-type {
  border-top: none;
}

.faq summary {
  padding: 14px 0;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--warm-800);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq summary::after {
  content: '+';
  font-size: 1.125rem;
  color: var(--sapphire-500);
  font-weight: 600;
  flex-shrink: 0;
  margin-left: 12px;
  transition: transform var(--t-fast) var(--ease-out);
}

.faq details[open] summary::after {
  content: '−';
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq details p {
  padding: 0 0 14px;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--color-text-secondary);
}

/* ── Footer ── */
.footer {
  padding: 20px 0 24px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-faint);
  letter-spacing: 0.01em;
  position: relative;
  z-index: 1;
}

.footer a {
  color: var(--sapphire-500);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--t-fast) var(--ease-out);
}

.footer a:hover {
  color: var(--sapphire-700);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* ── Desktop ── */
@media (min-width: 640px) {
  .kbd-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 0 24px;
  }

  .header {
    padding: 26px 0 24px;
  }

  .logo {
    font-size: 1.75rem;
  }

  .tagline {
    font-size: 0.875rem;
  }

  main {
    padding: 36px 0 24px;
  }

  .lang-bar {
    padding: 16px 22px;
    gap: 12px;
  }

  .text-panels {
    grid-template-columns: 1fr 1fr;
  }

  .source-panel {
    border-bottom: none;
    border-right: 1px solid var(--color-border-subtle);
  }

  .panel textarea {
    min-height: 290px;
  }

  .translate-btn-wrap {
    padding: 18px 22px 20px;
  }

  .translate-btn {
    min-width: 200px;
    padding: 14px 52px;
    font-size: 1.0625rem;
  }
}

@media (min-width: 960px) {
  .container {
    padding: 0 32px;
  }

  main {
    padding: 40px 0 32px;
  }
}

/* ── Focus visible (keyboard nav) ── */
:focus-visible {
  outline: 2px solid var(--sapphire-400);
  outline-offset: 2px;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--sapphire-400);
  outline-offset: 2px;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
