/**
 * Home screen + app chrome styles (uses tokens from w2l-app.css).
 */

#app {
  min-height: 100dvh;
}

.home-shell {
  direction: rtl;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 28px 20px 48px;
  animation: rise-in 420ms ease both;
}

.home-hero {
  margin-bottom: 36px;
}

.home-brand {
  direction: ltr;
  display: flex;
  align-items: center;
  gap: 14px;
}

.home-brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: var(--shadow);
  animation: pop-in 560ms cubic-bezier(0.2, 0.9, 0.2, 1.15) both;
  flex-shrink: 0;
}

.home-brand-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.home-brand-name {
  margin: 0;
  font-family: "Sora", "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-size: clamp(1.25rem, 4.2vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.home-tagline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.3;
  animation: rise-in 520ms ease 80ms both;
}

.home-sections {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.app-section {
  animation: rise-in 520ms ease both;
}

.app-section:nth-child(2) { animation-delay: 60ms; }
.app-section:nth-child(3) { animation-delay: 120ms; }
.app-section:nth-child(4) { animation-delay: 180ms; }
.app-section:nth-child(5) { animation-delay: 240ms; }

.section-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: right;
}

.next-activity-section[hidden] {
  display: none !important;
}

.next-activity-card {
  appearance: none;
  width: 100%;
  display: block;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.next-activity-card:hover,
.next-activity-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(15, 122, 95, 0.35);
  outline: none;
}

.next-activity-card.productivity {
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow);
}

.next-activity-card.entertainment {
  box-shadow: inset 3px 0 0 #1f9d55, var(--shadow);
}

.next-activity-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.next-activity-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
}

.next-activity-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid rgba(15, 122, 95, 0.3);
}

.next-activity-card.entertainment .next-activity-badge {
  background: rgba(31, 157, 85, 0.14);
  color: #147a3f;
  border-color: rgba(31, 157, 85, 0.35);
}

.next-activity-when {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 4px;
}

.next-activity-meta {
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.app-grid {
  direction: rtl;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 10px;
  justify-items: stretch;
}

@media (max-width: 420px) {
  .app-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.app-tile {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: inherit;
  border-radius: 18px;
  transition: transform 160ms ease, background 160ms ease;
}

.app-tile:hover,
.app-tile:focus-visible {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.35);
  outline: none;
}

.app-tile:active {
  transform: scale(0.96);
}

.app-icon {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(20, 32, 28, 0.08);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.app-banner {
  position: absolute;
  top: 0;
  inset-inline: 0;
  z-index: 1;
  padding: 3px 4px 2px;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-align: center;
  color: #fff;
  pointer-events: none;
}

.app-banner.is-green {
  background: #1f9d55;
}

.app-banner.is-yellow {
  background: #d4a017;
  color: #1a1608;
}

.app-banner.is-red {
  background: #c0392b;
}

.app-banner-pill {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-inline-start: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.35;
  color: #fff;
  vertical-align: middle;
}

.app-banner-pill.is-green {
  background: #1f9d55;
}

.app-banner-pill.is-yellow {
  background: #d4a017;
  color: #1a1608;
}

.app-banner-pill.is-red {
  background: #c0392b;
}

.app-icon-emoji {
  font-size: 1.85rem;
  line-height: 1;
}

.app-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-name {
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
}

.app-shell {
  direction: rtl;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: rise-in 280ms ease both;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(243, 246, 242, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-topbar-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-topbar-title-row {
  display: flex;
  align-items: center;
  min-width: 0;
}

.app-topbar-title {
  margin: 0;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-topbar-description {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-topbar-end {
  position: relative;
  flex-shrink: 0;
}

.app-topbar-end[hidden] {
  display: none !important;
}

.app-topbar-end.is-open .favorited-by-toggle {
  background: rgba(15, 122, 95, 0.18);
}

.app-shell.invite-open .app-frame {
  pointer-events: none;
}

.favorited-by-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 50;
  width: min(280px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.invite-search {
  width: 100%;
  box-sizing: border-box;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
}

.invite-search:focus {
  outline: 2px solid rgba(15, 122, 95, 0.35);
  border-color: var(--accent);
}

.invite-selected {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.invite-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 10px;
  background: rgba(15, 122, 95, 0.08);
}

.invite-chip-remove {
  appearance: none;
  margin-inline-start: auto;
  border: 0;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.invite-chip-remove:hover,
.invite-chip-remove:focus-visible {
  background: rgba(15, 122, 95, 0.16);
  outline: none;
}

.favorited-by-panel[hidden] {
  display: none !important;
}

.favorited-by-invite-all {
  appearance: none;
  border: 0;
  border-radius: 10px;
  min-height: 36px;
  padding: 0 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.favorited-by-invite-all:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.favorited-by-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.favorited-by-user {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: start;
}

.favorited-by-user:hover,
.favorited-by-user:focus-visible {
  background: rgba(15, 122, 95, 0.1);
  outline: none;
}

.favorited-by-user:disabled {
  opacity: 0.5;
  cursor: wait;
}

.favorited-by-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(15, 122, 95, 0.12);
  flex-shrink: 0;
}

.favorited-by-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorited-by-empty,
.favorited-by-status,
.invite-empty {
  margin: 0;
  padding: 4px 6px;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.favorited-by-status[hidden] {
  display: none !important;
}

.app-shell .icon-btn {
  appearance: none;
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font-size: 1.35rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.app-shell .icon-btn:hover,
.app-shell .icon-btn:focus-visible {
  background: rgba(15, 122, 95, 0.1);
  outline: none;
}

.favorite-btn.is-favorite {
  color: var(--warn);
}

.app-shell .icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.app-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 0;
}

.app-stage.has-frame {
  background: #0d1512;
}

.app-frame {
  direction: ltr;
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.home-patreon {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.home-patreon-cta {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}

.home-patreon-cta:hover,
.home-patreon-cta:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  outline: none;
}

.app-external,
.app-stage:not(.has-frame) {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 20px;
  gap: 12px;
}

.app-external {
  display: flex;
  flex-direction: column;
  width: min(420px, 100%);
  margin: auto;
}

.app-external-icon {
  font-size: 3rem;
  filter: drop-shadow(0 10px 20px var(--glow));
  animation: pop-in 480ms cubic-bezier(0.2, 0.9, 0.2, 1.15) both;
}

.app-external-title {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.03em;
}

.app-external-copy,
.app-missing {
  margin: 0;
  color: var(--ink-soft);
}

.primary-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 30px var(--glow);
  transition: transform 160ms ease, filter 160ms ease;
}

.primary-btn:hover,
.primary-btn:focus-visible {
  transform: translateY(-2px);
  filter: brightness(1.05);
  outline: none;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.86); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

.app-invite-toast {
  position: fixed;
  z-index: 80;
  inset-inline: 12px;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  margin-inline: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.app-invite-toast[hidden] {
  display: none !important;
}

.app-invite-toast-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.app-invite-toast-body {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.app-invite-toast-actions {
  display: flex;
  gap: 8px;
}

.app-invite-toast-actions button {
  appearance: none;
  flex: 1;
  min-height: 40px;
  border-radius: 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.app-invite-toast-join {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
}

.app-invite-toast-later {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}
