/*
  Avatar 09 — Smart Fallback Avatar — standalone HTML/CSS/JS.
  No build step, no framework, no external dependency: copy index.html,
  this file, and script.js into any project as-is.
*/

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

:root {
  --id-fg: oklch(0.2 0 0);
  --id-muted: oklch(0.55 0 0);
  --id-line: oklch(0.92 0 0);
  --id-soft: oklch(0.955 0 0);
  --id-accent: #39ff14;
}

.avatar09 {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  vertical-align: middle;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji";
}

.avatar09--sm {
  width: 2rem;
  height: 2rem;
}

.avatar09--lg {
  width: 3rem;
  height: 3rem;
}

.avatar09__face {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 9999px;
  user-select: none;
}

/* The fallback chain: photo, placeholder, initials, guest glyph. */
.avatar09__initials,
.avatar09__guest,
.avatar09__image {
  display: none;
}

.avatar09[data-state="image"] .avatar09__image {
  display: block;
  animation: avatar09-fade 260ms ease-out both;
}

.avatar09[data-state="initials"] .avatar09__initials {
  display: block;
  animation: avatar09-fade 260ms ease-out both;
}

.avatar09[data-state="guest"] .avatar09__guest {
  display: block;
  animation: avatar09-fade 260ms ease-out both;
}

.avatar09[data-state="initials"] .avatar09__face {
  background-color: var(--avatar09-tint-bg, oklch(0.93 0.03 250));
  color: var(--avatar09-tint-fg, oklch(0.38 0.06 250));
}

.avatar09[data-state="guest"] .avatar09__face {
  background-color: var(--id-soft);
  color: var(--id-muted);
}

.avatar09[data-state="image"] .avatar09__face {
  background-color: var(--id-soft);
}

/* While the photo loads, a quiet sweep stands in for it — never an empty
   circle, and never initials that then get replaced a moment later. */
.avatar09[data-state="loading"] .avatar09__face {
  background-image: linear-gradient(90deg, oklch(0.94 0 0) 0%, oklch(0.97 0 0) 50%, oklch(0.94 0 0) 100%);
  background-size: 200% 100%;
  animation: avatar09-sweep 1.4s ease-in-out infinite;
}

.avatar09__initials {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
}

.avatar09--sm .avatar09__initials {
  font-size: 11px;
}

.avatar09--lg .avatar09__initials {
  font-size: 1rem;
  line-height: 1.5rem;
}

.avatar09__guest {
  width: 1.25rem;
  height: 1.25rem;
}

.avatar09--sm .avatar09__guest {
  width: 1rem;
  height: 1rem;
}

.avatar09--lg .avatar09__guest {
  width: 1.5rem;
  height: 1.5rem;
}

.avatar09__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar09__badge {
  position: absolute;
  right: -0.125rem;
  bottom: -0.125rem;
  display: flex;
  width: 1rem;
  height: 1rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background-color: var(--id-fg);
  color: var(--id-accent);
  box-shadow: 0 0 0 2px #ffffff;
}

.avatar09--sm .avatar09__badge {
  width: 0.875rem;
  height: 0.875rem;
}

.avatar09--lg .avatar09__badge {
  right: -0.25rem;
  bottom: -0.25rem;
  width: 18px;
  height: 18px;
}

.avatar09__badge svg {
  display: block;
  width: 0.625rem;
  height: 0.625rem;
}

.avatar09--sm .avatar09__badge svg {
  width: 0.5rem;
  height: 0.5rem;
}

.avatar09--lg .avatar09__badge svg {
  width: 0.75rem;
  height: 0.75rem;
}

@keyframes avatar09-sweep {
  from {
    background-position: 150% 0;
  }
  to {
    background-position: -50% 0;
  }
}

@keyframes avatar09-fade {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .avatar09[data-state="loading"] .avatar09__face,
  .avatar09[data-state="image"] .avatar09__image,
  .avatar09[data-state="initials"] .avatar09__initials,
  .avatar09[data-state="guest"] .avatar09__guest {
    animation: none;
  }
}

/*
  Page layout — the canvas this resource is presented on. Adjust or drop it
  when placing the resource inside your own layout.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  line-height: 1.5;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom, #fafafa, #f4f4f5);
}
p,
ul {
  margin: 0;
  padding: 0;
}
ul {
  list-style: none;
}
.avatar09-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
}
.avatar09-layout__card {
  width: 100%;
  max-width: 40rem;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 1rem;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 16px 40px -16px rgba(0, 0, 0, 0.12);
}
.avatar09-layout__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  border-bottom: 1px solid oklch(0.97 0 0);
  padding: 0.875rem 1.25rem;
}
.avatar09-layout__heading {
  font-size: 15px;
  font-weight: 600;
  color: oklch(0.205 0 0);
}
.avatar09-layout__sub {
  font-size: 0.75rem;
  line-height: 1rem;
  color: oklch(0.556 0 0);
}
.avatar09-layout__reload {
  min-height: 2rem;
  margin: -0.25rem 0;
  border: 0;
  border-radius: 0.375rem;
  background: none;
  padding: 0 0.5rem;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 500;
  color: oklch(0.439 0 0);
  text-decoration: underline;
  text-decoration-color: oklch(0.87 0 0);
  text-underline-offset: 3px;
  cursor: pointer;
  outline: none;
  transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.avatar09-layout__reload:hover {
  color: oklch(0.205 0 0);
}
.avatar09-layout__reload:focus-visible {
  outline: 2px solid oklch(0.205 0 0);
}
.avatar09-layout__comment {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
}
.avatar09-layout__comment + .avatar09-layout__comment {
  border-top: 1px solid oklch(0.97 0 0);
}
.avatar09-layout__body {
  min-width: 0;
  flex: 1;
}
.avatar09-layout__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
}
.avatar09-layout__name {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  color: oklch(0.205 0 0);
}
.avatar09-layout__verified {
  font-size: 11px;
  line-height: 1rem;
  font-weight: 500;
  color: oklch(0.556 0 0);
}
.avatar09-layout__time {
  font-size: 0.75rem;
  line-height: 1rem;
  font-variant-numeric: tabular-nums;
  color: oklch(0.708 0 0);
}
.avatar09-layout__text {
  margin-top: 0.125rem !important;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: oklch(0.439 0 0);
}
.avatar09-layout__state {
  display: none;
  flex-shrink: 0;
  border-radius: 9999px;
  background: oklch(0.97 0 0);
  padding: 0.125rem 0.5rem;
  font-size: 11px;
  line-height: 1rem;
  font-weight: 500;
  color: oklch(0.556 0 0);
}
@media (min-width: 40rem) {
  .avatar09-layout {
    padding: 2rem;
  }
  .avatar09-layout__head,
  .avatar09-layout__comment {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
  }
  .avatar09-layout__state {
    display: inline;
  }
}
