/* Fonts (@font-face) live in the space.common submodule -> /common/fonts.css,
   linked before this file. This file is homepage-specific design + layout. */

/* Design tokens — the light/dark palette (--bg/--ink/--muted/--line/--card2/
   --accent/--surf/--tg) is the SHARED one from /common/base.css. These are
   homepage-only: the Yandex brand colour + the app-tile palette (per-card
   size/color pick via styleForSlug / POST /prefs/card, editable in Customize mode). */
:root {
  --yandex: #fc3f1d;
  --banana-cream: #efe669;
  --sandy-brown: #f5a768;
  --bubblegum-pink: #fb626c;
  --orchid: #df67c7;
  --lavender-purple: #9567df;
  --blue-energy: #4f8de5;
  --sky-surge: #3dbee8;
  --strong-cyan: #3cdbe9;
  --aquamarine: #41eac5;
  --mint-glow: #55f164;
}

/* Homepage-specific base additions. The universal *{box-sizing}, body
   (margin/background/color/font-family/-webkit-font-smoothing/transition),
   a{-webkit-tap-highlight-color}, input{font-family}, and the shared keyframes
   (fade/…) all live in /common/base.css — do NOT redeclare them here. */
* {
  margin: 0;
  padding: 0;
}

html {
  -moz-osx-font-smoothing: grayscale;
}

body {
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fade-in {
  animation: fade .5s ease;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.03em;
  text-decoration: none;
}

.logo-accent {
  color: var(--accent);
}

/* Theme button */
.theme-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--ink);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .5s ease, opacity .3s ease;
}

.theme-btn:hover {
  opacity: .8;
}

.theme-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--bg);
  stroke-width: 2;
  fill: none;
}

/* Contact links */
.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--muted);
  font: 600 14px 'Bricolage Grotesque', sans-serif;
  transition: color .2s ease;
}

.contact-link:hover {
  color: var(--accent);
}

/* Pill buttons */
.pill-btn,
.pill-btn-yandex {
  height: 52px;
  padding: 0 32px;
  border-radius: 26px;
  font-size: 16px;
  font-weight: 600;
  transition: all .3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.pill-btn {
  background: var(--card2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.pill-btn:hover {
  background: var(--muted);
  color: var(--bg);
}

.pill-btn-yandex {
  background: var(--yandex);
  color: #ffffff;
  border: none;
}

.pill-btn-yandex:hover {
  background: #e84410;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(252,63,29,.2);
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  transition: color .3s ease;
}

.back-link:hover {
  color: var(--ink);
}

.back-link::before {
  content: "←";
}

/* Tilt effect for cards */
[data-tilt-grid] > .app-card {
  --rx: 0deg;
  --ry: 0deg;
  --lift: 0;
  --tdur: .65s;
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) translateZ(calc(var(--lift) * 12px));
  transition: transform var(--tdur) cubic-bezier(.23, 1, .320, 1);
}

/* App card styles */
.app-card {
  border-radius: 24px;
  padding: 26px;
  box-shadow: inset 0 1px 0 rgba(255, 252, 242, 0.22),
    0 calc(var(--lift, 0) * 26px) calc(var(--lift, 0) * 46px)
      rgba(20, 16, 30, calc(var(--lift, 0) * 0.28));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: perspective(820px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform var(--tdur, 0.35s) cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.3s ease;
}

/* The card <a> is a full-cover overlay (not a wrapper — see apps.ts) so the
   edit toolbar <form> can sit above it without nesting a form inside a link. */
.app-card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.app-card-content {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  pointer-events: none;
}

/* Customize (edit) mode: reveal each card's own toolbar, stop the card link
   from navigating (clicks go to the toolbar instead), and freeze the tilt so
   the controls don't swim under the pointer. */
.card-edit-toolbar {
  display: none;
}

body.editing .card-edit-toolbar {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: inherit;
  background: rgba(10, 9, 15, .58);
  backdrop-filter: blur(2px);
}

body.editing .app-card-link {
  pointer-events: none;
}

body.editing .app-card {
  --rx: 0deg;
  --ry: 0deg;
  --lift: 0;
}

.card-size-row,
.card-color-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-color-row {
  max-width: 150px;
}

.card-size-btn {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .14);
  color: #fffcf2;
  font: 700 11px 'IBM Plex Mono', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease, transform .15s ease;
}

.card-size-btn:hover {
  background: rgba(255, 255, 255, .26);
}

.card-size-btn[data-active="true"] {
  background: #fffcf2;
  color: #12121a;
}

.card-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25);
  transition: transform .15s ease, box-shadow .15s ease;
}

.card-color-swatch:hover {
  transform: scale(1.15);
}

.card-color-swatch[data-active="true"] {
  box-shadow: 0 0 0 2px rgba(255, 252, 242, .9);
}

.app-icon-lg {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 24px;
}

.app-icon-md {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

.app-icon-sm {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.profile-logout-pill {
  height: 40px;
  padding: 0 20px;
  border-radius: 12px;
  background: var(--ink);
  border: none;
  color: var(--bg);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  transition: background .5s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.profile-pill-text,
.profile-pill-arrow {
  transition: opacity .25s ease;
}

.profile-pill-text {
  opacity: 1;
}

.profile-pill-arrow {
  opacity: 0;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.profile-logout-pill:hover .profile-pill-text {
  opacity: 0;
}

.profile-logout-pill:hover .profile-pill-arrow {
  opacity: 1;
}

.settings-pill {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--ink);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .5s ease, opacity .3s ease;
}

.settings-pill:hover {
  opacity: .8;
}

.settings-pill[aria-pressed="true"] {
  background: var(--accent);
}

/* Responsive apps grid (UX-1). The grid + card spans are inline-styled in
   apps.ts, so these overrides need !important. Desktop (>820px) is untouched:
   the inline repeat(4,1fr) stands. Tablet → 2 cols (a 2-span card fills the
   row, fine); phone → 1 col with all cards collapsed to a single span so the
   big/wide tiles don't overflow. */
@media (max-width: 820px) {
  [data-tilt-grid] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 520px) {
  [data-tilt-grid] {
    grid-template-columns: 1fr !important;
  }
  [data-tilt-grid] > .app-card {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
  }
}

/* Exit-transition veil (portal -> app): a full-screen wash in the clicked
   card's own gradient, bridging the two origins so the hop reads as one
   continuous surface instead of a hard cut. See public/theme.js. */
.nav-veil {
  position: fixed;
  inset: 0;
  z-index: 9999;
  opacity: 0;
  transform: scale(.94);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.nav-veil.nav-veil-show {
  opacity: 1;
  transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .nav-veil {
    display: none;
  }
}

/* Touch targets (UX-12): bump the header icon controls to ≥44px on touch
   devices without changing the desktop (mouse) appearance. The inner icon size
   is unchanged; only the hit area grows. #themeToggle is inline-styled 40px in
   common/src/ui.ts, so it needs !important here. */
@media (pointer: coarse) {
  .theme-btn,
  .settings-pill,
  #themeToggle {
    width: 44px !important;
    height: 44px !important;
  }
  .profile-logout-pill {
    min-height: 44px;
  }
}
