/* Sized for the Model 3 browser viewport: about 773x601 CSS px. */

/* Unbounded (SIL OFL 1.1, see /fonts/OFL.txt), variable weight, latin subset */
@font-face {
  font-family: "Unbounded";
  src: url("/fonts/unbounded-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}

:root {
  --bg: #0b0d10;
  --card: #15181d;
  --card-hover: #1c2027;
  --line: #262b34;
  --text: #eef1f5;
  --muted: #8d96a5;
  --accent: #ffb547;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; cursor: pointer; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 24px; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
/* While the language's file loads, so English doesn't flash first */
.i18n-wait .top, .i18n-wait main, .i18n-wait .foot { visibility: hidden; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font: 700 24px/1 "Unbounded", system-ui, sans-serif; letter-spacing: -0.02em; }
.brand img { display: block; }
.brand .tld { color: var(--accent); font-weight: 500; }

.ghost { background: transparent; border: 1px solid var(--line); border-radius: 12px; padding: 10px 18px; min-height: 48px; }
.ghost:active { background: var(--card); }

.lang { position: relative; }
.lang-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; }
.lang-btn svg { flex: none; color: var(--muted); }
.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 5; min-width: 180px; padding: 6px;
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.lang-menu[hidden] { display: none; }
.lang-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 8px 14px;
  background: transparent; border: 0; border-radius: 10px; text-align: left; font-size: 16px;
}
.lang-menu button:active { background: var(--card-hover); }
.lang-menu [aria-checked="true"] { color: var(--accent); font-weight: 600; }
.lang-menu [aria-checked="true"]::after { content: "✓"; }

main { flex: 1; padding: 4px 24px 24px; max-width: 1100px; width: 100%; margin: 0 auto; }
h1 { font-size: 30px; line-height: 1.15; margin: 8px 0 4px; letter-spacing: -0.02em; }
.lede { color: var(--muted); margin: 0 0 20px; }

.recent { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 12px; }
.recent-app {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0; min-height: 48px; padding: 8px 16px 8px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; font-size: 15px; font-weight: 600;
}
.recent-app img { flex: none; border-radius: 8px; }
.recent-app span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-app:active, .chip:active { transform: scale(.97); }
/* Chips to filter the grid, and a search box at the row's end */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 16px; margin: 0 0 16px; }
.toolbar[hidden] { display: none; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
/* while a search is on, it covers every app: the chip isn't the filter */
.filters[data-off] .chip[aria-pressed="true"] { background: transparent; border-color: var(--line); color: #c3cad6; }
/* gives way to long chip labels (German, Dutch) before it wraps to a row of its own */
.search { position: relative; flex: 1 1 150px; max-width: 224px; margin-left: auto; }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 44px; padding: 8px 16px 8px 42px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line); color: var(--text); font: inherit; font-size: 15px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }   /* too small to tap; the × button instead */
.search.typed input { padding-right: 44px; }   /* room for the × */
.search .clear {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 42px; height: 40px;
  background: transparent; border: 0; border-radius: 999px; color: var(--muted); font-size: 24px; line-height: 1;
}
.search .clear[hidden] { display: none; }
.empty { grid-column: 1 / -1; margin: 0; padding: 12px 4px; color: var(--muted); }
.chip {
  min-height: 44px; padding: 8px 16px; border-radius: 999px; background: transparent;
  border: 1px solid var(--line); color: #c3cad6; font-size: 15px; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: #111418; }
.recent[hidden] { display: none; }
/* Moving between apps with a controller or arrow keys: the one in focus
   lit, where a tap shows no ring */
.card:focus-visible, .chip:focus-visible, .recent-app:focus-visible, .padnav .card:focus, .padnav .chip:focus, .padnav .recent-app:focus {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.card, .chip, .recent-app { scroll-margin: 20px; }   /* room around the one scrolled into view */

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-height: 190px; transition: background .12s, transform .12s;
}
/* hover only where there's a mouse: on the car's touch screen it stays lit
   on the card last tapped */
@media (hover: hover) { .card:hover { background: var(--card-hover); } }
.card:active { transform: scale(.98); }
.card img { width: 64px; height: 64px; border-radius: 16px; }
.badge {
  position: absolute; top: 14px; right: 14px; padding: 3px 10px; border-radius: 999px;
  background: var(--accent); color: #111418; font-size: 12px; font-weight: 700;
}
.card h2 { font-size: 19px; margin: 0; }
.card p { margin: 0; color: var(--muted); font-size: 15px; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: #22262e; color: #c3cad6; }

.skeleton { background: var(--card); border-radius: var(--radius); min-height: 190px; opacity: .5; }
.error { color: #ff8a80; }

.contact { margin-top: 28px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); }
.contact h2 { font-size: 19px; margin: 0 0 6px; }
.contact p { margin: 0; color: var(--muted); }
.contact a { color: var(--accent); font-weight: 600; word-break: break-all; }

.reqs { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 4px; }
.reqs summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; font-weight: 600; font-size: 17px;
}
.reqs summary::-webkit-details-marker { display: none; }
.reqs summary::after { content: "+"; font-size: 26px; font-weight: 400; color: var(--accent); }
.reqs[open] summary::after { content: "−"; }
.req-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); padding: 6px 0 4px; }
.req { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.req-wide { grid-column: 1 / -1; }
.req h3 { margin: 0 0 8px; font-size: 16px; color: var(--accent); }
.req ul { margin: 0; padding-left: 18px; color: #c3cad6; font-size: 15px; }
.req li + li { margin-top: 6px; }
.req code { font-size: 13px; background: #22262e; padding: 1px 5px; border-radius: 5px; }
.contact .req-note { margin-top: 10px; font-size: 14px; }

.foot p { margin: 0; }
.foot .support { font-size: 15px; color: #c3cad6; }
.coffee {
  display: inline-flex; align-items: center; gap: 10px; margin: 12px 0 20px;
  min-height: 48px; padding: 10px 22px; border-radius: 12px;
  background: var(--accent); color: #111418; font-weight: 700; font-size: 16px; text-decoration: none;
}
.coffee:active { transform: scale(.98); }
.foot .follow { margin: 0 0 14px; font-size: 14px; }
.follow a { display: inline-block; padding: 10px 4px; color: #c3cad6; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.foot .referral { max-width: 34em; margin: 0 auto 14px; font-size: 14px; color: #c3cad6; }
.referral a { display: inline-block; padding: 8px 4px; color: var(--accent); font-weight: 600; }
.token { max-width: 34em; margin: 0 auto 14px; font-size: 13px; }
.token-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 !important; }
.token code { font: 13px ui-monospace, "DejaVu Sans Mono", monospace; color: #c3cad6; word-break: break-all; user-select: all; }
.token-copy { min-height: 36px; padding: 4px 14px; border-radius: 10px; background: transparent; border: 1px solid var(--line); color: #c3cad6; font-size: 13px; }
.token-open { min-height: 44px; margin: 4px 0 8px; padding: 6px 18px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: 14px; font-weight: 600; }
.token-open:active { transform: scale(.98); }
.token-note { font-size: 12px; }

.foot { color: var(--muted); font-size: 13px; text-align: center; padding: 16px 24px 24px; }

/* Full-viewport app runner */
.runner { position: fixed; inset: 0; background: #000; z-index: 10; }
.runner iframe { width: 100%; height: 100%; border: 0; display: block; }
.home {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  /* no backdrop blur: it sits over apps that redraw every frame, such as
     games, and a blur there costs the car's GPU an extra pass each frame */
  background: rgba(20, 22, 27, .92); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 12px; padding: 8px 14px; min-height: 44px; font-size: 16px;
}
.loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; pointer-events: none; }
.slow-load { margin: 0; padding: 0 24px; max-width: 26em; text-align: center; color: var(--muted); font-size: 15px; }
.slow-load[hidden] { display: none; }
.loading[hidden] { display: none; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #2a2f37; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

@media (max-width: 480px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  /* the globe alone, so the header still fits on one line */
  #langName { display: none; }
  h1 { font-size: 24px; }
  /* minmax(0, …) and the word breaks keep long German and Dutch words
     ("Fractalverkenner") from widening a column past the screen */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card h2, .card p { overflow-wrap: break-word; hyphens: auto; }
  /* two columns leave no room beside the icon for "Aktualisiert" */
  .badge { position: static; align-self: flex-start; margin-bottom: -2px; }
  /* one row of chips that scrolls sideways, rather than two */
  /* no wrap: a wrapping column takes the chip row's full width, past the screen */
  .toolbar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chip { flex: none; }
  .search { flex: none; max-width: none; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .spinner { transition: none; animation-duration: 2s; }
}
