/**
 * App shell — layout, chrome, home hub
 * Depends on vifc-theme.css (load first in HTML).
 */

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--vifc-font-sans);
  background: var(--vifc-bg-base);
  color: var(--vifc-text);
}

.shell-skip {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.shell-skip:focus {
  left: var(--vifc-space-4);
  top: var(--vifc-space-4);
  width: auto;
  height: auto;
  padding: var(--vifc-space-2) var(--vifc-space-3);
  z-index: 100;
  background: var(--vifc-bg-raised);
  border: 1px solid var(--vifc-border-default);
  border-radius: var(--vifc-radius-sm);
  color: var(--vifc-text);
  font-size: var(--vifc-text-sm);
  font-weight: 500;
  box-shadow: var(--vifc-focus-ring);
}

/* Subtle top light — restrained, not a “hero gradient template” */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% -30%, rgba(45, 212, 191, 0.07), transparent 55%);
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100%;
}

.shell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--vifc-space-4);
  padding: var(--vifc-space-3) var(--vifc-space-5);
  min-height: 3.5rem;
  border-bottom: 1px solid var(--vifc-border-subtle);
  background: rgba(12, 14, 20, 0.92);
  background: color-mix(in srgb, var(--vifc-bg-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.shell-brand-wrap {
  display: flex;
  align-items: center;
  gap: var(--vifc-space-3);
  min-width: 0;
}

.shell-mark {
  width: 2rem;
  height: 2rem;
  border-radius: var(--vifc-radius-sm);
  background: linear-gradient(145deg, var(--vifc-accent-dim), transparent);
  border: 1px solid rgba(45, 212, 191, 0.25);
  box-shadow: var(--vifc-shadow-xs);
  flex-shrink: 0;
}

.shell-brand {
  font-weight: 650;
  font-size: var(--vifc-text-md);
  letter-spacing: var(--vifc-tracking-tight);
  line-height: var(--vifc-leading-tight);
}

.shell-brand-kicker {
  display: block;
  font-size: var(--vifc-text-xs);
  font-weight: 500;
  color: var(--vifc-text-tertiary);
  letter-spacing: var(--vifc-tracking-wide);
  text-transform: uppercase;
  margin-top: 2px;
}

.shell-nav {
  display: flex;
  align-items: center;
  gap: var(--vifc-space-1);
  flex-wrap: wrap;
  padding: var(--vifc-space-1);
  margin: 0;
  border-radius: var(--vifc-radius-md);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--vifc-border-subtle);
}

.shell-nav a {
  color: var(--vifc-text-secondary);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: var(--vifc-radius-sm);
  font-size: var(--vifc-text-sm);
  font-weight: 500;
  letter-spacing: var(--vifc-tracking-tight);
  border: 1px solid transparent;
  transition:
    background var(--vifc-duration) var(--vifc-ease-out),
    color var(--vifc-duration) var(--vifc-ease-out),
    border-color var(--vifc-duration) var(--vifc-ease-out);
}

.shell-nav a:hover {
  color: var(--vifc-text);
  background: rgba(255, 255, 255, 0.05);
}

.shell-nav a:focus-visible {
  outline: none;
  box-shadow: var(--vifc-focus-ring);
  border-radius: var(--vifc-radius-sm);
}

.shell-nav a.active {
  color: var(--vifc-text);
  background: rgba(45, 212, 191, 0.1);
  border-color: rgba(45, 212, 191, 0.28);
}

.shell-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--vifc-space-3);
  flex-wrap: wrap;
  font-size: var(--vifc-text-sm);
  color: var(--vifc-text-secondary);
  min-width: 0;
}

.shell-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.shell-user button {
  font-family: inherit;
  margin: 0;
  padding: 0.45rem 0.9rem;
  border-radius: var(--vifc-radius-sm);
  border: 1px solid var(--vifc-border-default);
  background: var(--vifc-bg-raised);
  color: var(--vifc-text);
  cursor: pointer;
  font-size: var(--vifc-text-sm);
  font-weight: 500;
  transition:
    background var(--vifc-duration) var(--vifc-ease-out),
    border-color var(--vifc-duration) var(--vifc-ease-out);
}

.shell-user button:hover {
  border-color: var(--vifc-border-strong);
  background: #181c28;
}

.shell-user button:focus-visible {
  outline: none;
  box-shadow: var(--vifc-focus-ring);
}

.shell-main {
  min-height: 0;
  position: relative;
}

.shell-home {
  padding: var(--vifc-space-6) var(--vifc-space-5) var(--vifc-space-10);
  max-width: 72rem;
  margin: 0 auto;
}

.shell-home-hero {
  margin-bottom: var(--vifc-space-8);
}

.shell-home h1 {
  margin: 0 0 var(--vifc-space-2);
  font-size: clamp(1.5rem, 2.5vw, 1.875rem);
  font-weight: 650;
  letter-spacing: var(--vifc-tracking-tight);
  line-height: var(--vifc-leading-tight);
}

.shell-home-lead {
  color: var(--vifc-text-secondary);
  margin: 0;
  max-width: 42rem;
  line-height: var(--vifc-leading-relaxed);
  font-size: var(--vifc-text-md);
}

.shell-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: var(--vifc-space-4);
}

.shell-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--vifc-space-5);
  min-height: 10.5rem;
  background: var(--vifc-bg-surface);
  border: 1px solid var(--vifc-border-default);
  border-radius: var(--vifc-radius-lg);
  box-shadow: var(--vifc-shadow-xs), var(--vifc-shadow-sm);
  transition:
    border-color var(--vifc-duration) var(--vifc-ease-out),
    box-shadow var(--vifc-duration) var(--vifc-ease-out);
}

.shell-card:hover {
  border-color: rgba(45, 212, 191, 0.22);
  box-shadow: var(--vifc-shadow-xs), var(--vifc-shadow-md);
}

.shell-card h2 {
  margin: 0 0 var(--vifc-space-2);
  font-size: var(--vifc-text-md);
  font-weight: 600;
  letter-spacing: var(--vifc-tracking-tight);
}

.shell-card p {
  margin: 0 0 var(--vifc-space-4);
  font-size: var(--vifc-text-sm);
  color: var(--vifc-text-secondary);
  line-height: var(--vifc-leading-relaxed);
  flex: 1;
}

.shell-card a {
  align-self: flex-start;
  margin-top: auto;
  font-size: var(--vifc-text-sm);
  font-weight: 600;
  color: var(--vifc-accent-text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.shell-card a::after {
  content: "→";
  transition: transform var(--vifc-duration) var(--vifc-ease-out);
}

.shell-card a:hover::after {
  transform: translateX(3px);
}

.shell-card a:focus-visible {
  outline: none;
  border-radius: 4px;
  box-shadow: var(--vifc-focus-ring);
}

.shell-groups {
  margin-top: var(--vifc-space-8);
  padding: var(--vifc-space-5);
  border-radius: var(--vifc-radius-lg);
  border: 1px dashed var(--vifc-border-default);
  background: rgba(255, 255, 255, 0.02);
  font-size: var(--vifc-text-sm);
  color: var(--vifc-text-secondary);
}

.shell-groups p {
  margin: 0 0 var(--vifc-space-3);
  color: var(--vifc-text);
  font-weight: 500;
}

.shell-groups code {
  font-family: var(--vifc-font-mono);
  font-size: 0.75rem;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--vifc-border-subtle);
  color: var(--vifc-text-secondary);
}

#widget-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--vifc-bg-base);
}

.shell-main.frame-mode .shell-home {
  display: none;
}

.shell-main.frame-mode #widget-frame {
  display: block;
}

.shell-main:not(.frame-mode) #widget-frame {
  display: none;
}

@media (max-width: 640px) {
  .shell-header {
    flex-direction: column;
    align-items: stretch;
  }

  .shell-nav {
    justify-content: flex-start;
  }

  .shell-user {
    justify-content: space-between;
    border-top: 1px solid var(--vifc-border-subtle);
    padding-top: var(--vifc-space-3);
  }

  .shell-user-name {
    max-width: none;
  }
}
