@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:opsz,wght@6..144,1..1000&display=swap');

:host {
  /* Neutral palette */
  --neutral-0: #ffffff;
  --neutral-1: #f8f9fa;
  --neutral-2: #f1f3f5;
  --neutral-3: #e9ecef;
  --neutral-4: #dee2e6;
  --neutral-5: #ced4da;
  --neutral-6: #adb5bd;
  --neutral-7: #6a7178;
  --neutral-8: #4f575e;
  --neutral-9: #272b30;
  --neutral-10: #101213;
  --neutral-11: #000000;

  /* Primary */
  --primary-light: #f8f9ff;
  --primary-base: #0a66f4;
  --primary-hover: #20439b;
  --primary-dark: #1c2855;

  /* Type scale */
  --font-displayLarge: 45px;
  --font-displaymedium: 40px;
  --font-displaySmall: 36px;
  --font-heading1: 32px;
  --font-heading2: 28px;
  --font-heading3: 25px;
  --font-heading4: 22px;
  --font-heading5: 20px;
  --font-heading6: 18px;
  --font-subtitle: 16px;
  --font-body: 14px;
  --font-caption: 12px;
  --font-label: 11px;
  --font-tagline: 10px;
  --font-sans: "Google Sans Flex", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.32s ease-in-out;

  /* Inherit shared variables from root or use standard defaults */
  --atproto-bg: var(--neutral-0, #ffffff);
  --atproto-border-color: var(--neutral-3, #e9ecef);
  --atproto-text-color: var(--neutral-10, #101213);
  --atproto-muted-color: var(--neutral-7, #6a7178);
  --atproto-accent-color: var(--primary-base, #0a66f4);
  --atproto-radius: 12px;
  --atproto-font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
}

/* Dark mode (opt-in) */
:host([data-dark="true"]),
:host([data-theme="dark"]) {
  --neutral-0: #0e0e0e;
  --neutral-1: #161616;
  --neutral-2: #1e1e1e;
  --neutral-3: #272727;
  --neutral-4: #323232;
  --neutral-5: #464646;
  --neutral-6: #5e5e5e;
  --neutral-7: #858585;
  --neutral-8: #ababab;
  --neutral-9: #cecece;
  --neutral-10: #e8e8e8;
  --neutral-11: #f7f7f7;

  --primary-light: #e8f0ff;
  --primary-base: #3d8ef0;
  --primary-hover: #1a6ad4;
  --primary-dark: #0a3a8a;
}

:host(.atproto-profile-host) {
  display: block;
  width: var(--atproto-width, 100%);
  max-width: var(--atproto-max-width, none);
  margin: 32px auto;
  box-sizing: border-box;
  font-family: var(--atproto-font-family);
  color: var(--atproto-text-color);
}

.atproto-profile-inner {
  margin: 0 auto;
  box-sizing: border-box;
  width: 100%;
}

/* Card Sizing */
.atproto-profile-card--size-full {
  width: 100%;
}

.atproto-profile-card--size-md {
  width: 100%;
  max-width: 480px;
}

.atproto-profile-card--size-fit {
  width: fit-content;
  min-width: 0;
  max-width: 100%;
}

/* Radius Variants (Removed) */


.atproto-profile--loading,
.atproto-profile--error {
  padding: 18px;
  border: 1px solid var(--atproto-border-color);
  border-radius: var(--atproto-radius);
  background: var(--atproto-bg);
  color: var(--atproto-muted-color);
  text-align: center;
  font-size: var(--font-body, 14px);
}

.atproto-profile-card {
  margin: 0 auto;
  overflow: hidden;
  background: var(--atproto-bg);
  border: 1px solid var(--neutral-3);
  border-radius: 20px;
  box-shadow: 0 0 0 3px var(--neutral-1);
}

.atproto-profile__cover {
  height: 140px;
  background: var(--neutral-2);
  position: relative;
  /* Sync with current card radius */
  border-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  overflow: hidden;
}

.atproto-profile__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.atproto-profile__cover--empty {
  background: linear-gradient(135deg, var(--neutral-1), var(--neutral-3));
}

.atproto-profile__body {
  padding: 16px 18px 18px;
  position: relative;
}

.atproto-profile__header {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.atproto-profile-card--no-cover .atproto-profile__header {
  margin-top: 0;
}

.atproto-profile__avatar-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--atproto-profile-bg);
  border: 1px solid var(--atproto-profile-bg);
  flex-shrink: 0;
  overflow: hidden;
}

.atproto-profile-card--no-cover .atproto-profile__avatar-wrap {
  border: none;
  box-shadow: none;
}

.atproto-profile__avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.atproto-profile__identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.atproto-profile__name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.atproto-profile__name {
  font-size: var(--font-subtitle);
  font-weight: 600;
  color: var(--neutral-11);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 100%;
  display: block;
}

.atproto-profile__badge {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.atproto-profile__handle {
  font-size: var(--font-body);
  color: var(--atproto-muted-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
  display: block;
}

.atproto-profile__description {
  margin-top: 12px;
  font-size: var(--font-body);
  line-height: 1.5;
  color: var(--atproto-text-color);
  white-space: pre-wrap;
  word-break: break-all;
}

.atproto-profile__paragraph:not(:last-child) {
  margin-bottom: 8px;
}

.atproto-profile__link {
  color: var(--primary-base);
  font-weight: 500;
  text-decoration: none;
  text-underline-offset: 2px;
}

.atproto-profile__link:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.atproto-profile__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 16px;
}

.atproto-profile__metric {
  display: flex;
  gap: 4px;
  min-width: 80px;
}

.atproto-profile__metric-count {
  font-size: var(--font-body);
  font-weight: 600;
  color: var(--atproto-text-color);
}

.atproto-profile__metric-label {
  font-size: var(--font-body);
  color: var(--neutral-8);
}

/* Actions */
.atproto-profile__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.atproto-profile__btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 100px;
  font-size: var(--font-body);
  line-height: 1;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}

.atproto-profile__btn:hover {}

.atproto-profile__btn--primary {
  background: var(--primary-base);
  color: #ffffff;
  border: 1px solid var(--primary-base);
}

.atproto-profile__btn--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.atproto-profile__btn--secondary {
  background: transparent;
  color: var(--neutral-11);
  border: 1px solid var(--neutral-2);
}

.atproto-profile__btn--secondary:hover {
  background: var(--neutral-2);
  border-color: var(--neutral-3);
}

@media (max-width: 540px) {
  .atproto-profile__actions {
    flex-direction: column;
  }

  .atproto-profile__header {
    align-items: flex-start;
  }

  .atproto-profile__body {
    padding: 14px 14px 16px;
  }
}