/* Tokens mirror my_emu (src/app/styles/index.css) so the link page reads as
   the same product. EMU brand book: orange #EF7F1A · violet #8F2B83. */

@font-face {
  font-family: "EMU Express";
  src: url("assets/fonts/EMU-Logo-Font.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --brand: oklch(0.7091 0.169 54.65);
  --brand-ink: oklch(0.58 0.16 50);
  --violet: oklch(0.4736 0.168 333.11);

  --background: oklch(0.9846 0.0017 247.84);
  --foreground: oklch(0.2457 0.0055 67);
  --card: oklch(1 0 0);
  --muted: oklch(0.967 0.003 67);
  --muted-foreground: oklch(0.512 0.008 67);
  --border: oklch(0.918 0.0025 67);
  --destructive: oklch(0.577 0.245 27.325);

  --radius: 0.75rem;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-brand: "EMU Express", var(--font-sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-ink: oklch(0.8 0.13 60);
    --violet: oklch(0.62 0.175 331);

    --background: oklch(0.17 0.015 255);
    --foreground: oklch(0.97 0.005 255);
    --card: oklch(0.22 0.015 255);
    --muted: oklch(0.27 0.015 255);
    --muted-foreground: oklch(0.7 0.015 255);
    --border: oklch(1 0 0 / 11%);
    --destructive: oklch(0.704 0.191 22.216);
  }
}

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

/* Phones only — nobody opens this from a desktop. It is an Instagram bio link,
   so the usual host is Instagram's in-app browser on iOS or Android. */
html {
  /* What iOS shows when the page is pulled past its top or bottom edge. */
  background: var(--background);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* No double-tap-to-zoom wait on anything that is tapped. */
a,
button,
[role="option"] {
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(
      60rem 28rem at 50% -8rem,
      color-mix(in srgb, var(--brand) 16%, transparent),
      transparent 70%
    ),
    var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

.page {
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
  /* The notch and home indicator, and the side insets of a phone held in
     landscape. */
  padding: calc(0.75rem + env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    calc(2rem + env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
}

/* ---------- Language switcher ---------- */

/* Same shape as my_emu's compact LanguageSwitcher: the trigger is just the
   flag, the menu spells the language out next to each flag. A native <select>
   cannot show images in its options, hence the listbox. */
.lang {
  position: relative;
  width: max-content;
  margin: 0 0 1rem auto;
}

.lang__trigger {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 2.75rem; /* 44px — the smallest comfortable touch target */
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.lang__trigger[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
}

.lang__menu {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  z-index: 10;
  min-width: 11rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 12px 32px -12px oklch(0 0 0 / 30%);
  animation: menu-in 0.12s ease-out;
}

.lang__menu[hidden] {
  display: none;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.lang__option {
  /* A fixed flag column, so the names line up although the flags differ in
     width. */
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) * 0.6);
  font-size: 0.9375rem;
  cursor: pointer;
  outline: none;
}

.lang__option:active,
.lang__option:focus-visible {
  background: var(--muted);
}

.lang__option[aria-selected="true"] {
  font-weight: 600;
}

.lang__check {
  width: 1rem;
  height: 1rem;
  color: var(--brand-ink);
  visibility: hidden;
}

.lang__option[aria-selected="true"] .lang__check {
  visibility: visible;
}

.lang__trigger:focus-visible,
.lang__option:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent);
  outline-offset: 2px;
}

/* Wikipedia's flags come in their own proportions (2:1, 3:2, 5:3); every one
   is shown in the same 3:2 box. The ring keeps the white stripes visible on a
   white card. */
.flag {
  display: block;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1rem;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--border);
}

/* Uzbekistan's is 2:1 with the crescent and stars at the hoist, so it is
   cropped from the fly end only — centred, the crescent would be cut. */
.flag[src$="uz.svg"] {
  object-position: left center;
}

/* ---------- Hero ---------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 2rem;
}

.hero__mark {
  display: grid;
  place-items: center;
  width: 6.5rem;
  height: 6.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--brand) 55%, transparent);
}

.hero__mark img {
  width: 76%;
  height: auto;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  /* No "Save image" sheet on a long press. */
  -webkit-touch-callout: none;
}

/* "EMU" stays the literal brand violet in both themes — a logo does not
   change colour with the theme (same rule as my_emu's BrandWordmark). */
.wordmark {
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: 2.5rem;
  line-height: 1;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.wordmark__emu {
  color: #8f2b83;
}

.wordmark__express {
  font-size: 0.6em;
  color: var(--foreground);
}

.hero__legal {
  margin-top: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.hero__address {
  margin-top: 0.25rem;
  max-width: 20rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.4;
}

/* ---------- Groups ---------- */

.group + .group {
  margin-top: 1.5rem;
}

.group[hidden] {
  display: none;
}

.group__title {
  margin: 0 0 0.625rem 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.links {
  display: grid;
  /* minmax(0, …): without it the track grows to fit a one-line URL and the
     card spills past the screen edge instead of cutting it with an ellipsis. */
  grid-template-columns: minmax(0, 1fr);
  gap: 0.625rem;
}

/* ---------- Link card ---------- */

.link {
  --c: var(--brand-ink);

  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-height: 4rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.4);
  background: var(--card);
  color: inherit;
  text-decoration: none;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background-color 0.12s ease;
}

/* Tap feedback. iOS only applies :active when a touchstart listener exists,
   which app.js registers. */
.link:active {
  transform: scale(0.98);
  border-color: color-mix(in srgb, var(--c) 45%, var(--border));
  background: color-mix(in srgb, var(--c) 6%, var(--card));
}

.link--primary:active {
  background: color-mix(in srgb, var(--brand) 88%, black);
}

.link:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent);
  outline-offset: 2px;
}

.link--primary {
  border-color: transparent;
  background: var(--brand);
  color: oklch(0.2257 0.008 60);
}

.link--primary .link__icon {
  background: oklch(1 0 0 / 35%);
  color: oklch(0.2257 0.008 60);
}

.link--primary .link__sub,
.link--primary .link__chevron {
  color: oklch(0.2257 0.008 60 / 72%);
}

.link__icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  color: var(--c);
}

.link__icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* A network's own full-colour logo, on a neutral tile rather than a tint of
   its colour — the logo already carries the brand. */
.link__icon--logo {
  background: var(--muted);
}

.link__icon--logo img {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.link__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.link__title {
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* Up to two lines, so a translated hint or a long address still reads on a
   narrow phone. */
.link__sub {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* A URL or @handle breaks badly mid-word, so it stays on one line and is cut
   with an ellipsis instead. */
.link__sub--url {
  display: block;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link__chevron {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  color: var(--muted-foreground);
}

.badge {
  display: inline-block;
  margin-left: 0.375rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: var(--c);
  font-size: 0.6875rem;
  font-weight: 600;
  vertical-align: 0.1em;
}

/* ---------- Address + map buttons ---------- */

.place {
  --c: var(--brand-ink);

  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.4);
  background: var(--card);
}

.place__head {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

/* A fixed height: the widget has no intrinsic size, and on a phone a map
   taller than this starts to feel like a page of its own. */
.place__map {
  display: block;
  width: 100%;
  height: 18rem;
  margin-top: 0.75rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--muted);
}

/* ---------- Store badges ---------- */

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

.stores {
  display: flex;
  gap: 0.625rem;
}

.stores > li {
  flex: 1 1 0;
  min-width: 0;
}

/* Black in both themes, as the stores' own badges are; the grey hairline is
   the one Apple's badge carries, and keeps it from dissolving into a dark
   page. */
.store {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  height: 3.25rem;
  padding: 0 0.875rem;
  border: 1px solid oklch(1 0 0 / 22%);
  border-radius: var(--radius);
  background: #000;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease;
}

.store:active {
  transform: scale(0.97);
}

.store:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent);
  outline-offset: 2px;
}

.store__logo {
  display: block;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  object-fit: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.store__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.store__caption {
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
  opacity: 0.85;
}

.store__name {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

/* ---------- Skeleton ---------- */

.skeleton {
  height: 4rem;
  border-radius: calc(var(--radius) * 1.4);
  background: linear-gradient(
      90deg,
      transparent,
      color-mix(in srgb, var(--foreground) 6%, transparent),
      transparent
    )
    0 0 / 200% 100% var(--muted);
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

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

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid color-mix(in srgb, var(--destructive) 35%, var(--border));
  border-radius: calc(var(--radius) * 1.4);
  background: color-mix(in srgb, var(--destructive) 7%, var(--card));
  font-size: 0.875rem;
}

.notice[hidden] {
  display: none;
}

.notice__retry {
  flex-shrink: 0;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--brand);
  color: oklch(0.2257 0.008 60);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.notice__retry:active {
  background: color-mix(in srgb, var(--brand) 88%, black);
}

.footer {
  margin-top: 1rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  line-height: 1.6;
  text-align: center;
}

.footer__apps {
  margin-bottom: 1.25rem;
}

.footer__apps[hidden] {
  display: none;
}

/* Small phones (iPhone SE 1st gen, compact Androids — 320–359px wide). */
@media (max-width: 359px) {
  /* Two badges side by side leave "Google Play" no room; stack them. */
  .stores {
    flex-direction: column;
  }

  .hero {
    margin-bottom: 1.5rem;
  }

  .hero__mark {
    width: 5.5rem;
    height: 5.5rem;
  }

  .wordmark {
    font-size: 2.125rem;
  }

  .hero__legal {
    font-size: 0.875rem;
  }

  .hero__address {
    font-size: 0.8125rem;
  }

  .link {
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
  }

  .link__icon {
    width: 2.25rem;
    height: 2.25rem;
  }
}

/* A phone on its side: the hero would fill the whole short screen, so it
   shrinks and the links start sooner. */
@media (orientation: landscape) and (max-height: 500px) {
  .hero {
    margin-bottom: 1.25rem;
  }

  .hero__mark {
    width: 4.5rem;
    height: 4.5rem;
    margin-bottom: 0.625rem;
  }

  .wordmark {
    font-size: 2rem;
  }
}

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