/* AnyLangKeys — shared styles */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1c1b22;
  --muted: #5d5a6b;
  --line: #dcd8cf;
  --accent: #3b4cca;
  --accent-ink: #ffffff;
  --accent-soft: #e6e9fb;
  --key: #ffffff;
  --key-mod: #ebe7de;
  --key-edge: #c5c0b3;
  --shadow: 0 1px 2px rgba(28, 27, 34, 0.06), 0 8px 24px rgba(28, 27, 34, 0.06);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15151b;
    --surface: #1e1e27;
    --ink: #ecebf2;
    --muted: #a3a0b3;
    --line: #34333f;
    --accent: #95a2ff;
    --accent-ink: #12121a;
    --accent-soft: #2a2c45;
    --key: #2b2b37;
    --key-mod: #23232d;
    --key-edge: #0e0e13;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15151b;
  --surface: #1e1e27;
  --ink: #ecebf2;
  --muted: #a3a0b3;
  --line: #34333f;
  --accent: #95a2ff;
  --accent-ink: #12121a;
  --accent-soft: #2a2c45;
  --key: #2b2b37;
  --key-mod: #23232d;
  --key-edge: #0e0e13;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
}

main {
  flex: 1;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  margin: 0 0 0.5rem;
}

h2 {
  font-size: clamp(1.3rem, 3vw, 1.6rem);
  margin: 2.5rem 0 0.75rem;
}

h3 {
  font-size: 1.05rem;
  margin: 0 0 0.25rem;
}

p {
  margin: 0 0 1rem;
}

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

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

.wrap {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 16px;
}

.prose {
  max-width: 68ch;
}

.lead {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 60ch;
}

/* ---------- header ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 57px;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.95rem;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav > a,
.nav-menu > summary {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  cursor: pointer;
}

.site-nav > a:hover,
.nav-menu > summary:hover {
  background: var(--accent-soft);
}

.nav-menu {
  position: relative;
}

.nav-menu > summary {
  list-style: none;
}

.nav-menu > summary::-webkit-details-marker {
  display: none;
}

.nav-menu > summary::after {
  content: " ▾";
  color: var(--muted);
}

.nav-menu-list {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  z-index: 10;
  min-width: 180px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.nav-menu-list a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.nav-menu-list a:hover {
  background: var(--accent-soft);
}

.lang-switch {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .nav-about {
    display: none;
  }
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--accent-soft);
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-bottom: 0.75rem;
}

.footer-links a {
  color: var(--ink);
  text-decoration: none;
}

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

.footer-note {
  margin: 0;
}

/* ---------- home ---------- */

.hero {
  padding: clamp(2.5rem, 8vw, 5rem) 0 1rem;
}

.hero .lead {
  margin-bottom: 1.5rem;
}

.cta {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.cta:hover {
  filter: brightness(1.08);
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.lang-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}

a.lang-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.lang-card.is-soon {
  box-shadow: none;
  background: transparent;
  color: var(--muted);
}

.lang-native {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.3;
}

.lang-name {
  color: var(--muted);
}

.lang-badge {
  align-self: flex-start;
  margin-top: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.is-soon .lang-badge {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 1rem;
}

.features p {
  color: var(--muted);
  margin: 0;
}

/* ---------- keyboard page ---------- */

.page-head {
  padding: 2rem 0 1.25rem;
}

.page-head h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.2rem);
}

.page-head .lead {
  margin: 0;
}

.tool {
  position: relative;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.toolbar,
.toolbar-group,
.searchbar,
.options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 10px;
}

.btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-primary:hover {
  color: var(--accent-ink);
  filter: brightness(1.08);
}

.btn-small {
  padding: 5px 12px;
  font-size: 0.88rem;
}

.btn-icon {
  min-width: 42px;
  padding-inline: 8px;
}

.tool-text {
  display: block;
  width: 100%;
  min-height: 150px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 24px;
  line-height: 1.5;
  resize: vertical;
}

.tool-text:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.searchbar {
  margin-top: 10px;
}

.searchbar-label {
  color: var(--muted);
  font-size: 0.88rem;
}

.options {
  gap: 6px 20px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.touch-only {
  display: none;
}

@media (pointer: coarse) {
  .touch-only {
    display: inline-flex;
  }
}

.keyboard {
  padding: 6px;
  border-radius: var(--radius);
  background: var(--key-mod);
  user-select: none;
  -webkit-user-select: none;
}

.kb-row {
  display: grid;
  grid-template-columns: repeat(60, minmax(0, 1fr));
}

.key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: clamp(40px, 9.5vw, 56px);
  margin: 2px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-bottom: 3px solid var(--key-edge);
  border-radius: 7px;
  background: var(--key);
  color: var(--ink);
  font-family: var(--key-font, var(--font));
  font-size: clamp(15px, 3.8vw, 22px);
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.key:hover {
  background: var(--accent-soft);
}

.key:active,
.key.is-down {
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-width: 1px;
  transform: translateY(2px);
}

.key.is-dead {
  color: var(--accent);
}

.key.is-pending {
  background: var(--accent);
  color: var(--accent-ink);
}

.key.is-empty {
  opacity: 0.45;
  cursor: default;
}

.key:disabled {
  opacity: 0.4;
  cursor: default;
}

.key-mod {
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font);
  font-size: clamp(14px, 3.2vw, 17px);
}

.key-mod[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.k-text {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.k-hint {
  position: absolute;
  top: 4px;
  left: 6px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.65rem;
}

.key:active .k-hint,
.key.is-down .k-hint {
  color: inherit;
}

@media (max-width: 640px) {
  .tool {
    padding: 10px 6px;
    border-radius: var(--radius);
  }

  .toolbar,
  .searchbar,
  .options {
    padding: 0 4px;
  }

  .keyboard {
    padding: 3px;
  }

  .key {
    height: 46px;
    margin: 1.5px;
    border-radius: 5px;
  }

  .k-hint,
  .k-text:not(.k-text-always) {
    display: none;
  }
}

.toast {
  position: absolute;
  left: 50%;
  top: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9rem;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.faq summary {
  font-weight: 600;
  cursor: pointer;
}

.faq details p {
  margin: 8px 0 0;
  color: var(--muted);
}

kbd {
  /* Key names stay left-to-right and self-contained inside right-to-left text. */
  direction: ltr;
  unicode-bidi: isolate;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font: 0.85em var(--font);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
