/* Reset, document frame and the page scaffold every screen renders into. */

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

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(91, 58, 166, 0.45), transparent 60%),
    radial-gradient(90% 60% at 100% 100%, rgba(27, 107, 71, 0.22), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image:
    repeating-linear-gradient(0deg, rgba(251, 243, 228, 0.6) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(251, 243, 228, 0.35) 0 1px, transparent 1px 4px);
  z-index: 0;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.005em;
}

p {
  margin: 0;
}

ul {
  margin: 0;
  padding-left: 1.1rem;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/*
 * An inline <svg> without width/height has no intrinsic size and stretches to fill a flex
 * row. Every icon here sets both attributes; this is the guard for anything that does not.
 */
svg:not([width]):not([height]) {
  width: 24px;
  height: 24px;
  flex: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.outlet {
  flex: 1;
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  padding: 0 max(var(--space-4), var(--safe-left)) 0 max(var(--space-4), var(--safe-right));
}

/* ---- Page scaffold ------------------------------------------------------ */

.page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-bottom: calc(var(--space-8) + var(--safe-bottom));
  animation: page-in var(--normal) var(--ease) both;
}

.page--center {
  justify-content: center;
  padding-top: calc(var(--space-6) + var(--safe-top));
}

.page--hub {
  padding-top: calc(var(--space-5) + var(--safe-top));
}

.page__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-top: var(--space-4);
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: var(--space-2);
  padding: calc(var(--space-3) + var(--safe-top)) 0 var(--space-3);
  background: linear-gradient(180deg, var(--bg) 62%, rgba(21, 12, 36, 0));
}

.topbar__titles {
  text-align: center;
  min-width: 0;
}

.topbar__title {
  font-size: var(--size-title);
  letter-spacing: 0.01em;
}

.topbar__subtitle {
  margin-top: 2px;
  font-size: var(--size-small);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__spacer {
  display: block;
  width: 44px;
  height: 44px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.section-title h2 {
  font-size: 1.0625rem;
  letter-spacing: 0.02em;
}

.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent-soft);
  font-size: var(--size-small);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---- Boot and noscript -------------------------------------------------- */

.boot {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  text-align: center;
}

.boot__crest {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 35%, var(--brass-300), transparent 55%),
    linear-gradient(160deg, var(--violet-600), var(--violet-800));
  box-shadow: var(--shadow-md);
  animation: boot-pulse 1.6s var(--ease) infinite;
}

.boot__title {
  font-family: var(--font-display);
  font-size: var(--size-title);
}

.boot__text,
.noscript p {
  color: var(--text-muted);
  font-size: var(--size-small);
}

.noscript {
  max-width: var(--app-max);
  margin: 0 auto;
  padding: var(--space-7) var(--space-4);
  text-align: center;
}

.boot-error {
  max-width: 420px;
  margin: 18vh auto;
  padding: var(--space-6);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-lg);
}

@keyframes boot-pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.04); opacity: 1; }
}

/* ---- Connectivity banner ------------------------------------------------ */

.connection-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: calc(var(--space-2) + var(--safe-top)) var(--space-4) var(--space-2);
  border: none;
  background: linear-gradient(180deg, var(--ember-500), #9c3f2c);
  color: var(--cream-100);
  font-size: var(--size-small);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.connection-banner[hidden] {
  display: none;
}
