/* Wika Dictionary styles — dark glass theme */

:root {
  color-scheme: dark;

  --bg: #464947;
  --text: #ececee;
  --text-soft: rgb(255 255 255 / 68%);
  --muted: rgb(255 255 255 / 45%);

  /* Accents (kept from the original English / Finnish colours, brightened) */
  --english: #4fdc9a;
  --finnish: #5eabff;
  --translation: #a9cbff;
  --error: #ff8f8f;

  /* Glass */
  --glass-sheen: linear-gradient(
    160deg,
    rgb(255 255 255 / 9%) 0%,
    rgb(255 255 255 / 5%) 40%,
    rgb(255 255 255 / 2%) 40.4%,
    rgb(255 255 255 / 1.5%) 100%
  );
  --glass-fill: rgb(22 22 24 / 62%);
  --glass-border: rgb(255 255 255 / 26%);
  --glass-border-soft: rgb(255 255 255 / 14%);
  --glass-shadow:
    inset 0 1px 0 rgb(255 255 255 / 22%),
    inset 0 -1px 0 rgb(255 255 255 / 8%),
    0 18px 40px rgb(0 0 0 / 55%);
  --glass-blur: blur(18px) saturate(120%);

  --radius: 18px;
  --content-width: min(86%, 900px);
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}

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

body {
  margin: 0;
  padding: 28px 20px;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

/* Soft light spots behind the glass so the blur has something to show. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60vmax 40vmax at 15% 10%, rgb(255 255 255 / 7%), transparent 70%),
    radial-gradient(50vmax 35vmax at 90% 85%, rgb(255 255 255 / 5%), transparent 70%),
    radial-gradient(40vmax 30vmax at 80% 20%, rgb(94 171 255 / 5%), transparent 70%),
    var(--bg);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Glass surface (shared) ---------- */

.glass,
.search-box,
.suggestions,
.card,
.box,
.entry-image,
.translator select,
.translator textarea,
.translator-result,
.action-button,
.mode-switch {
  position: relative;
  background: var(--glass-sheen), var(--glass-fill);
  border: 1.5px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

/* Bright glints on the top and bottom edges, like light catching glass. */
.search-box::after,
.card::after,
.box::after,
.entry-image::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(35% 1.5px at 50% 0, rgb(255 255 255 / 95%), transparent),
    radial-gradient(30% 1.5px at 50% 100%, rgb(255 255 255 / 70%), transparent),
    radial-gradient(1.5px 25% at 100% 50%, rgb(255 255 255 / 55%), transparent);
}

/* ---------- Header ---------- */

h1 {
  margin: 4px 0 14px;
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.english {
  color: var(--english);
  text-shadow: 0 0 18px rgb(79 220 154 / 35%);
}

.finnish {
  color: var(--finnish);
  text-shadow: 0 0 18px rgb(94 171 255 / 35%);
}

.tilde {
  color: var(--text-soft);
}

/* ---------- Search ---------- */

/* The search bar stays pinned to the top while scrolling. */
.search {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  margin: 0 -20px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 20px 14px;
  background: linear-gradient(color-mix(in srgb, var(--bg) 92%, transparent) 60%, transparent);
}

.search-box {
  z-index: 20; /* keep the suggestion list above the cards below */
  width: var(--content-width);
  border-radius: 999px;
}

.home-button,
.search-icon {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  transform: translateY(-50%);
  color: var(--text);
  background: rgb(255 255 255 / 8%);
  border: 1px solid var(--glass-border-soft);
  border-radius: 50%;
}

.home-button {
  left: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.home-button:hover {
  background: rgb(255 255 255 / 16%);
  border-color: var(--glass-border);
}

.home-button:active {
  transform: translateY(-50%) scale(0.94);
}

.home-button:focus-visible {
  outline: 2px solid rgb(255 255 255 / 60%);
  outline-offset: 2px;
}

.home-button svg {
  width: 19px;
  height: 19px;
}

.search-icon {
  left: 54px;
  color: var(--text-soft);
  background: none;
  border-color: transparent;
  pointer-events: none;
}

.search-icon svg {
  width: 18px;
  height: 18px;
}

.search input {
  width: 100%;
  padding: 16px 20px 16px 96px;
  font: 18px var(--font);
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 999px;
}

.search input::placeholder {
  color: var(--muted);
}

.search input:focus {
  outline: none;
}

.search-box:focus-within {
  border-color: rgb(255 255 255 / 45%);
}

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: 6px;
  list-style: none;
  text-align: left;
  background: var(--glass-sheen), #121214;
  border-radius: 16px;
}

.suggestions li {
  padding: 11px 16px;
  font-size: 17px;
  color: var(--text-soft);
  border-radius: 10px;
  cursor: pointer;
}

.suggestions li[aria-selected="true"],
.suggestions li:hover {
  color: var(--text);
  background: rgb(255 255 255 / 9%);
}

.suggestions mark {
  background: none;
  color: var(--english);
  font-weight: 600;
}

.status {
  min-height: 1.2em;
  margin: 14px auto 0;
  color: var(--error);
}

.status:empty {
  margin: 0;
}

/* ---------- Results ---------- */

.entry + .entry {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid rgb(255 255 255 / 10%);
}

.translation {
  width: var(--content-width);
  margin: 24px auto 18px;
  font-size: 28px;
  font-weight: 500;
  color: var(--translation);
  text-shadow: 0 0 20px rgb(94 171 255 / 30%);
}

.section-title {
  width: var(--content-width);
  margin: 18px auto 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
}

.box {
  width: var(--content-width);
  margin: 10px auto;
  padding: 20px 22px;
  overflow-x: auto;
  text-align: left;
  border-radius: var(--radius);
}

.notes {
  white-space: pre-line;
  line-height: 1.6;
  color: var(--text);
}

.finnish-notes {
  background: var(--glass-sheen), rgb(30 50 80 / 45%);
}

.entry-image {
  width: var(--content-width);
  margin: 14px auto;
  padding: 8px;
  border-radius: var(--radius);
}

.entry-image img {
  display: block;
  width: 100%;
  border-radius: calc(var(--radius) - 8px);
  cursor: zoom-in;
}

.entry table {
  border-collapse: collapse;
  width: 100%;
}

.entry td {
  padding: 9px 10px;
  border: 1px solid rgb(255 255 255 / 16%);
}

.entry tr:first-child td {
  background: rgb(255 255 255 / 5%);
}

/* Colour tags used inside dictionary.json, e.g. <red>word</red> */
red    { color: #ff7a7a; font-weight: bold; }
green  { color: #5fe39a; font-weight: bold; }
blue   { color: #74b9ff; font-weight: bold; }
purple { color: #cf96ff; font-weight: bold; }
yellow { color: #ffe45c; font-weight: bold; }
strike { text-decoration: line-through; opacity: 0.75; }

/* ---------- Translator ---------- */

.card {
  width: 100%;
  max-width: 580px;
  margin: 40px auto 24px;
  padding: 24px 22px;
  border-radius: 26px;
  text-align: left;
}

.translator h2 {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
}

.translator .subnote {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.translator label {
  display: block;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0 18px;
}

.field-row .field {
  flex: 0 1 auto;
}

.field {
  margin-bottom: 16px;
}

.translator select,
.translator textarea {
  display: block;
  width: 100%;
  padding: 11px 14px;
  font: 16px var(--font);
  color: var(--text);
  border-radius: 14px;
}

.translator .field-row select {
  width: auto;
  min-width: 180px;
  height: 44px;
  padding-right: 38px;
  border-radius: 999px;
  appearance: none;
  cursor: pointer;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23ddd' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 16px center,
    var(--glass-sheen),
    var(--glass-fill);
}

.translator select option {
  color: var(--text);
  background: #19191b;
}

.translator textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.translator textarea::placeholder {
  color: var(--muted);
}

.translator select:focus-visible,
.translator textarea:focus-visible {
  outline: none;
  border-color: rgb(255 255 255 / 50%);
}

/* Online / offline switch: a glass pill with a glossy knob */
.mode-switch {
  display: block;
  width: 108px;
  height: 44px;
  padding: 0;
  font: 600 14px var(--font);
  color: var(--text-soft);
  border-radius: 999px;
  cursor: pointer;
}

.mode-switch:focus-visible,
.action-button:focus-visible {
  outline: 2px solid rgb(255 255 255 / 60%);
  outline-offset: 3px;
}

.mode-switch-knob {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #b9b9be 55%, #6d6d73 100%);
  box-shadow: 0 2px 6px rgb(0 0 0 / 60%), inset 0 -2px 3px rgb(0 0 0 / 25%);
  transition: left 0.22s ease;
}

.mode-switch[aria-checked="true"] {
  color: var(--text);
  border-color: rgb(79 220 154 / 55%);
}

.mode-switch[aria-checked="true"] .mode-switch-knob {
  left: 69px;
}

.mode-switch-text {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
}

.mode-switch-text::before {
  content: attr(data-off);
}

.mode-switch[aria-checked="true"] .mode-switch-text {
  right: auto;
  left: 14px;
}

.mode-switch[aria-checked="true"] .mode-switch-text::before {
  content: attr(data-on);
}

/* Glass pill button with a round arrow badge */
.action-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: 2px 0 16px;
  padding: 6px 6px 6px 22px;
  font: 500 16px var(--font);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.action-button::after {
  content: "";
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 1.5l4.5 4.5L4 10.5'/%3E%3C/svg%3E") no-repeat center,
    rgb(255 255 255 / 12%);
  border: 1px solid var(--glass-border-soft);
}

.action-button:hover:not(:disabled) {
  border-color: rgb(255 255 255 / 48%);
}

.action-button:active:not(:disabled) {
  transform: translateY(1px);
}

.action-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.translator-result {
  display: block;
  min-height: 58px;
  padding: 14px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  border-color: var(--glass-border-soft);
  border-radius: 16px;
  background: rgb(0 0 0 / 30%);
}

.translator-result.is-error {
  color: var(--error);
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 24px;
  padding-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Image viewer ---------- */

.image-viewer {
  max-width: 100vw;
  max-height: 100vh;
  padding: 0;
  border: none;
  background: transparent;
}

.image-viewer::backdrop {
  background: rgb(0 0 0 / 88%);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.image-viewer img {
  display: block;
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 12px;
}

.close-button {
  position: fixed;
  top: 12px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  font-size: 28px;
  line-height: 1;
  color: #fff;
  background: rgb(255 255 255 / 10%);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  cursor: pointer;
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  body { padding: 18px 14px; }
  .search { margin-inline: -14px; padding-inline: 14px; }
  :root { --content-width: 100%; }
  .box { padding: 16px; }
  .card { padding: 20px 16px; }
}
