/* Velora: classic, quiet, endless.
   Tokens first, then layout, header, cards, motion. */

:root {
  --bg: #f4f5f6;
  --bg-glass: rgba(244, 245, 246, 0.88);
  --surface: #ffffff;
  --text: #1b2229;
  --text-soft: #46515b;
  --muted: #6b7580;
  --line: #e3e6e9;
  --line-strong: #cfd5da;
  --accent: #34566f;
  --accent-soft: #e6edf2;
  --shadow: 0 1px 2px rgba(27, 34, 41, 0.04), 0 8px 24px -12px rgba(27, 34, 41, 0.12);
  --shadow-pop: 0 10px 30px -10px rgba(27, 34, 41, 0.25);

  --radius: 16px;
  --header-h: 58px;
  --gap: 14px;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --bg-glass: rgba(16, 20, 24, 0.88);
    --surface: #171c21;
    --text: #e8ecef;
    --text-soft: #b6c0c8;
    --muted: #8f9aa5;
    --line: #262d34;
    --line-strong: #38414a;
    --accent: #8fb4d1;
    --accent-soft: #1f2a33;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-anchor: none; /* scroll position is managed by script.js */
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-anchor: none;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  background: var(--bg-glass);
  -webkit-backdrop-filter: saturate(1.3) blur(12px);
  backdrop-filter: saturate(1.3) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}

.header-inner {
  position: relative;
  max-width: 1000px;
  height: 100%;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 16px;
}

.bar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  flex: none;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 0.28em;
  margin-right: -0.28em;
}

.brand-sub {
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.counter {
  margin-left: auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}

.counter-label {
  font-size: 0.7rem;
  color: var(--muted);
}

.counter-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
}

.counter-num {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.counter-inf {
  flex: none;
  font-size: 0.78rem;
  color: var(--muted);
}

.icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Controls: an overlay panel on phones, inline on wide screens */

.controls {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
}

.controls.open { display: flex; }

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  margin: 0;
  padding: 0 5px 0 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  -webkit-appearance: none;
  appearance: none;
}

.field input::placeholder { color: var(--muted); opacity: 1; }
.field input::-webkit-search-cancel-button { -webkit-appearance: none; }

.field .prefix {
  flex: none;
  font-size: 0.9rem;
  color: var(--muted);
}

.field .go {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.18s ease;
}

.field .go:hover { opacity: 0.88; }

@media (min-width: 860px) {
  .bar { display: contents; }
  .brand { order: 0; }
  .controls { order: 1; }
  .counter { order: 2; margin-left: 0; min-width: 120px; }
  .toggle { display: none; }

  .controls,
  .controls.open {
    position: static;
    display: flex;
    flex: 1;
    flex-direction: row;
    gap: 10px;
    max-width: 560px;
    margin: 0 auto;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }
  .field { height: 38px; }
  .field .go { width: 30px; height: 30px; }
  .search { flex: 1.5 1 0; min-width: 0; }
  .jump { flex: 1 1 0; min-width: 0; }
  .counter-num { max-width: 180px; }
}

/* ---------- Feed ---------- */

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--gap) max(16px, env(safe-area-inset-right)) calc(72px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.feed { overflow-anchor: none; }

.noscript {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
}

/* ---------- Profile card ---------- */

.card {
  margin: 0 0 var(--gap);
  padding: 20px 22px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: calc(var(--header-h) + env(safe-area-inset-top) + var(--gap));
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Cards arriving below the fold wait here until they scroll into view */
.card.pending:not(.in) {
  opacity: 0;
  transform: translateY(12px);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.avatar {
  --h: 210;
  --h2: 30;
  flex: none;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  overflow: hidden;
  background: hsl(var(--h) 34% 93%);
  box-shadow: inset 0 0 0 1px hsl(var(--h) 30% 40% / 0.16);
}

.avatar svg { display: block; width: 100%; height: 100%; }

.av-a, .av-b { stroke-width: 0.5; stroke-linejoin: round; }
.av-a { fill: hsl(var(--h) 38% 38%); stroke: hsl(var(--h) 38% 38%); }
.av-b { fill: hsl(var(--h2) 58% 52%); stroke: hsl(var(--h2) 58% 52%); }

@media (prefers-color-scheme: dark) {
  .avatar { background: hsl(var(--h) 22% 21%); box-shadow: inset 0 0 0 1px hsl(var(--h) 30% 70% / 0.18); }
  .av-a { fill: hsl(var(--h) 52% 72%); stroke: hsl(var(--h) 52% 72%); }
  .av-b { fill: hsl(var(--h2) 62% 66%); stroke: hsl(var(--h2) 62% 66%); }
}

.ident { flex: 1; min-width: 0; padding-top: 2px; }

.name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.name a { text-decoration: none; }
.name a:hover { color: var(--accent); }

.handle {
  margin: 2px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.meta {
  margin: 8px 0 0;
  font-size: 0.92rem;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.copy { margin: -4px -8px 0 0; width: 36px; height: 36px; }

.status {
  margin: 18px 0 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.about {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--text-soft);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 18px 0 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stats > div { text-align: center; min-width: 0; }
.stats > div + div { border-left: 1px solid var(--line); }

.stats dt {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.stats dd {
  margin: 1px 0 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 3px 11px;
  font-size: 0.8rem;
  color: var(--text-soft);
  background: var(--accent-soft);
  border-radius: 999px;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.foot .joined { color: var(--text-soft); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: center;
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Screen sizes ---------- */

@media (max-width: 380px) {
  .card { padding: 16px 16px 14px; }
  .card-head { gap: 12px; }
  .avatar { width: 54px; height: 54px; }
  .name { font-size: 1.2rem; }
  .stats dd { font-size: 1.15rem; }
  .brand-name { font-size: 1.05rem; letter-spacing: 0.22em; }
}

@media (min-width: 1100px) {
  .wrap { max-width: 720px; }
  .card { padding: 26px 30px 20px; }
  .avatar { width: 76px; height: 76px; }
  .name { font-size: 1.55rem; }
}

@media (min-width: 1800px) {
  html { font-size: 18px; }
  body { font-size: 1rem; }
  .wrap { max-width: 800px; }
  .header-inner { max-width: 1160px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .card.pending:not(.in) { opacity: 1; transform: none; }
}
