/* Shared page layout and controls for Home, Account, Settings and later pages */
.page-head { display: grid; gap: var(--s-2); margin-bottom: var(--s-6); }
.page-title { font-size: clamp(2.25rem, 6vw, 3.75rem); }
.page-head-center { text-align: center; }
[hidden] { display: none !important; }
.page-sub { margin: 0; color: var(--muted); }

/* Page content leaves room so the floating menu never covers it */
.page { padding-bottom: 7rem; }

/* Cards ease in one after another; the router numbers each .rise as --i */
.rise { animation: rise-in var(--dur-slow) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise-in { from { opacity: 0; translate: 0 18px; } }

.card-lg { border-radius: var(--r-lg); }
.card-title { font-size: 1.125rem; margin-bottom: var(--s-4); }
.grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
.grid-2 { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }

/* Pill tab switcher; the active tab is a solid white pill */
.tabs {
  display: inline-flex;
  max-width: 100%;
  gap: var(--s-1);
  padding: var(--s-1);
  margin-bottom: var(--s-5);
  overflow-x: auto;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  scrollbar-width: none;
}
.tabs-center { display: flex; width: fit-content; margin-inline: auto; }
.tab {
  flex: none;
  padding: 0.55rem 1.1rem;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out), scale var(--dur-fast) var(--ease-spring);
}
.tab:hover { color: var(--white); }
.tab:active { scale: 0.95; }
.tab[aria-selected="true"], .tab[aria-checked="true"] { background: var(--white); color: var(--black); }
[data-panel]:not([hidden]) { animation: fade-in var(--dur) var(--ease-out) both; }

/* Toggle switch: <label class="switch"><input type="checkbox" role="switch"><span class="switch-track"></span></label> */
.switch { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: inherit; }
.switch-track {
  width: 2.75rem;
  height: 1.5rem;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--bg-2);
  transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.switch-track::after {
  content: "";
  display: block;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--muted);
  transition: translate var(--dur) var(--ease-spring), background var(--dur) var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--white); border-color: var(--white); }
.switch input:checked + .switch-track::after { translate: 1.25rem 0; background: var(--black); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 3px; }
.switch input:disabled + .switch-track { opacity: 0.4; }

/* Avatar: initials in a white circle */
.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: var(--size, 3rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--white);
  color: var(--black);
  font-size: calc(var(--size, 3rem) * 0.42);
  font-weight: 600;
  overflow: hidden;
}
.avatar-lg { --size: 5rem; }
.avatar-sm { --size: 2rem; }

/* List row: label and hint on the left, a control on the right */
.list { display: grid; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) 0;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row-text { display: grid; gap: 2px; min-width: 0; }
.row-label { color: var(--white); }
.row-hint { color: var(--muted); font-size: 0.875rem; }
.row-wrap { flex-wrap: wrap; }
.row .tabs { margin: 0; }
a.row, button.row { width: 100%; background: none; border-inline: 0; border-bottom: 0; font: inherit; text-align: left; cursor: pointer; color: inherit; }

/* Level / small info pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--white);
  font-size: 0.875rem;
}

/* Notification items (the mount is in components.css) */
.notifications[data-position*="bottom"] { top: auto; bottom: var(--s-4); }
.notifications[data-position*="left"] { right: auto; left: var(--s-4); }
.notifications[data-position*="center"] { right: auto; left: 50%; translate: -50% 0; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lift);
  color: var(--white);
  animation: toast-in var(--dur-slow) var(--ease-spring) both;
}
.toast svg { flex: none; margin-top: 1px; }
.toast-text { display: grid; flex: 1; min-width: 0; }
.toast-text span { color: var(--muted); font-size: 0.875rem; }
.toast-text span:empty { display: none; }
.toast-close { border: 0; background: none; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.toast-close:hover { color: var(--white); }
/* Leaves by flying off the right edge (left edge for left-side positions) */
.toast.is-leaving { animation: toast-out 420ms var(--ease-in) both; }
.notifications[data-position*="left"] .toast.is-leaving { animation-name: toast-out-left; }
@keyframes toast-in { from { opacity: 0; scale: 0.9; translate: 0 -12px; } }
@keyframes toast-out { to { opacity: 0; translate: calc(100vw) 0; } }
@keyframes toast-out-left { to { opacity: 0; translate: calc(-100vw) 0; } }

/* Home: wordmark drops in, then the search bar appears */
.home {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--s-6);
  /* Fills the first screen so the footer sits below the fold */
  min-height: calc(100svh - 8rem);
  text-align: center;
}
.wordmark {
  position: relative;
  display: flex;
  font-size: clamp(4.5rem, 20vw, 11rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  margin-right: -0.16em; /* the trailing letter-space would push the word off centre */
  text-shadow: 0 0 28px rgb(var(--fg-rgb) / 0.35), 0 0 80px rgb(var(--fg-rgb) / 0.12);
}
.wordmark span {
  animation: letter-drop 1100ms var(--ease-spring) both;
  animation-delay: calc(200ms + var(--n) * 110ms);
}
.wordmark span:nth-child(1) { --n: 0; }
.wordmark span:nth-child(2) { --n: 1; }
.wordmark span:nth-child(3) { --n: 2; }
.wordmark span:nth-child(4) { --n: 3; }
@keyframes letter-drop {
  from { opacity: 0; translate: 0 -0.6em; filter: blur(14px); text-shadow: none; }
  60% { filter: blur(0); }
}

.search {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: min(100%, 40rem);
  height: 3.5rem;
  padding: 0 var(--s-3) 0 var(--s-5);
  background: var(--bg-1);
  /* --glow (0 to 1) is set by home.js from how close the mouse is */
  --glow: 0;
  border: 1px solid rgb(var(--fg-rgb) / calc(0.16 + var(--glow) * 0.5));
  border-radius: var(--r-pill);
  box-shadow: 0 0 calc(var(--glow) * 36px) rgb(var(--fg-rgb) / calc(var(--glow) * 0.16));
  animation: fade-in var(--dur-slow) var(--ease-out) 1000ms both;
  transition: border-color 140ms linear, box-shadow 140ms linear, scale var(--dur) var(--ease-spring);
}
.search:focus-within {
  border-color: var(--white);
  box-shadow: 0 0 0 4px rgb(var(--fg-rgb) / 0.08), 0 0 40px rgb(var(--fg-rgb) / 0.1);
  scale: 1.015;
}
.search svg { flex: none; width: 1.25rem; height: 1.25rem; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--white); font: inherit; }
.search input::placeholder { color: var(--muted); }
.search kbd {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
}
.search:focus-within kbd { opacity: 0; }

/* Theme picker: each card previews the same fake page in that theme's colours */
.stack { display: grid; gap: var(--s-4); }
.card-note { margin: calc(var(--s-2) * -1) 0 var(--s-4); }
.theme-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr)); }
.theme {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-2);
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--white);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), scale var(--dur-fast) var(--ease-spring);
}
.theme:hover { border-color: var(--line-strong); }
.theme:active { scale: 0.98; }
.theme[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 0 var(--s-1) var(--s-1); }
.theme-badge { padding: 0.15rem 0.6rem; font-size: 0.75rem; }

.theme-preview {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0.45rem;
  aspect-ratio: 16 / 10;
  padding: 0.7rem;
  background: var(--bg-0);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.tp-title { justify-self: center; width: 38%; height: 0.55rem; border-radius: var(--r-pill); background: var(--white); }
.tp-search { justify-self: center; width: 70%; height: 0.9rem; border-radius: var(--r-pill); background: var(--bg-1); border: 1px solid var(--line-strong); }
.tp-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3rem; }
.tp-cards i { position: relative; border-radius: 0.35rem; background: var(--bg-2); border: 1px solid var(--line); }
.tp-cards i::after { content: ""; position: absolute; inset: 0.3rem 35% auto 0.3rem; height: 3px; border-radius: 2px; background: var(--muted); }
.tp-cards i:nth-child(2)::after { background: var(--accent); }
.tp-dock { justify-self: center; display: flex; gap: 0.3rem; padding: 0.25rem 0.5rem; border-radius: var(--r-pill); background: var(--bg-1); border: 1px solid var(--line-strong); }
.tp-dock i { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--muted); }
.tp-dock i:first-child { background: var(--accent); }

/* Cloaking: icon tiles reuse .theme; name presets are chips */
.icon-grid { grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); margin-bottom: var(--s-4); }
.icon-tile { justify-items: center; padding: var(--s-3) var(--s-2); }
.icon-art { display: grid; place-items: center; width: 2rem; height: 2rem; }
.icon-art svg, .icon-art img { width: 100%; height: 100%; border-radius: 7px; object-fit: contain; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.chip {
  padding: 0.5rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: none;
  color: var(--white);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out), scale var(--dur-fast) var(--ease-spring);
}
.chip:active { scale: 0.95; }
.chip[aria-checked="true"] { background: var(--white); color: var(--black); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.field {
  width: min(100%, 20rem);
  padding: 0.6rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--bg-2);
  color: var(--white);
  font: inherit;
}
.field:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Proxy options: .theme cards with a description; unsupported ones are greyed out */
.option-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
.option { align-content: start; padding: var(--s-4); }
.option .theme-meta { padding: 0; }
.option:disabled { opacity: 0.4; cursor: not-allowed; }
.option:disabled:hover { border-color: var(--line); }
.option:disabled:active { scale: 1; }
.option-warn:empty { display: none; }

/* Home when signed in */
.welcome { position: relative; font-size: clamp(2.25rem, 8vw, 4.5rem); overflow-wrap: anywhere; animation: fade-in var(--dur-slow) var(--ease-out) both; }
.home.is-user .wordmark { font-size: clamp(1.25rem, 4vw, 1.75rem); text-shadow: none; color: var(--muted); }

/* Account */
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.auth { display: grid; justify-items: center; gap: var(--s-4); }
.auth .page-head, .auth .tabs { margin-bottom: 0; }
.auth-card { display: grid; gap: var(--s-4); width: min(100%, 26rem); }
.form-label { display: grid; gap: var(--s-2); color: var(--muted); font-size: 0.875rem; }
.field-block { width: 100%; }
.field-area { width: 100%; min-height: 6rem; border-radius: var(--r-md); resize: vertical; }
.form-error { margin: 0; min-height: 1.25em; font-size: 0.875rem; font-weight: 600; }
.crop { width: min(92vw, 40rem); margin: auto; color: inherit; }
.crop::backdrop { background: rgba(0, 0, 0, 0.6); }
.crop-frame { cursor: grab; touch-action: none; }
.crop-frame:active { cursor: grabbing; }
.preview-actions { margin-top: var(--s-4); }
.banner { aspect-ratio: 4 / 1; max-height: 9rem; border-radius: var(--r-md); background: var(--surface, rgba(255,255,255,0.06)); overflow: hidden; }
.banner img { width: 100%; height: 100%; object-fit: cover; }
.banner + .profile-head { margin-top: var(--s-4); }
.card .banner { margin-bottom: var(--s-3); }
.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); margin-bottom: var(--s-6); }
.profile-meta { display: grid; flex: 1; gap: var(--s-1); min-width: 12rem; }
.profile-meta .page-title { overflow-wrap: anywhere; }
.chat-preview { display: flex; align-items: flex-start; gap: var(--s-3); margin-bottom: var(--s-4); }
.card .stack { gap: var(--s-4); }
.day { margin: var(--s-5) 0 var(--s-2); color: var(--muted); font-size: 0.875rem; font-weight: 500; }
.day:first-child { margin-top: 0; }

/* Seasonal decoration on the home title (see decor.js): sits on top of VOID, or on the welcome line, like a hat */
.deco { position: absolute; width: var(--deco-size); height: auto; overflow: visible; pointer-events: none; rotate: var(--tilt, -8deg); transform-origin: 50% 100%; animation: deco-in 800ms var(--ease-spring) 900ms both, deco-sway 6s ease-in-out 1.8s infinite; }
.deco * { stroke-linecap: round; stroke-linejoin: round; }
.deco .m { fill: color-mix(in srgb, var(--white) 24%, var(--bg-0)); stroke: var(--white); stroke-width: 2.6; }
.deco .l { fill: none; stroke: var(--white); stroke-width: 2.6; }
.deco .f { fill: var(--white); stroke: none; }
.deco .a { fill: var(--accent); stroke: none; }
.wordmark .deco { --deco-size: 0.75em; left: 50%; top: 0.12em; translate: -50% -70%; --tilt: -8deg; }
.welcome .deco { --deco-size: 1.6em; left: -0.45em; top: 0.2em; translate: 0 -72%; --tilt: -14deg; }
.home.is-user .wordmark .deco { display: none; }
.home:not(.is-user) .welcome .deco { display: none; }
@keyframes deco-in { from { opacity: 0; scale: 0.4; } }
@keyframes deco-sway { 0%, 100% { rotate: var(--tilt); } 50% { rotate: calc(var(--tilt) + 4deg); } }
[data-motion="reduced"] .deco { animation: none; }

/* Friends list on the account page */
.friend-add { display: flex; gap: var(--s-2); }
.friend-add .field { flex: 1; min-width: 0; }
.friend-row { align-items: flex-start; }
.friend-row .avatar { flex: none; }
.friend-row .row-text { flex: 1; min-width: 12rem; }
.friend-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.friend-note-form { display: grid; gap: var(--s-2); margin-top: var(--s-2); }

/* Staff badge: sits in the line of the name, same colour as the name */
.staff-badge { flex: none; width: 1em; height: 1em; margin-left: 0.25em; vertical-align: -0.14em; }
.page-title .staff-badge { width: 0.5em; height: 0.5em; vertical-align: 0.05em; }
.mutuals { margin: 0; color: var(--muted); font-size: 0.875rem; }
.mutuals a { color: var(--white-2); }
.mutuals a:hover { color: var(--white); text-decoration: underline; }

.tab-count { margin-left: var(--s-2); padding: 0 0.4rem; border-radius: 999px; background: var(--white); color: var(--black); font-size: 0.6875rem; font-weight: 800; }
.tab[aria-selected="true"] .tab-count { background: var(--black); color: var(--white); }
.tab-count[hidden] { display: none; }
.friend-requests { display: grid; gap: var(--s-2); }
.friend-requests h3 { margin: 0; color: var(--muted); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

/* Staff: managing an account */
.manage { width: min(100% - 2rem, 36rem); max-height: 92svh; overflow-y: auto; border: 1px solid var(--line-strong); color: var(--white-2); }
.manage::backdrop { background: rgb(0 0 0 / 0.6); }
.manage-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.manage-delete { display: grid; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px dashed var(--line-strong); }
