/*
 * Birthdaycal enhancements
 * Loaded after styles.css and navigation.css.
 * This file contains only additive overrides for the new home and profile UI.
 */

/* Keep native hidden state authoritative even when a component has display rules. */
[hidden],
#calendar-filter-panel[hidden],
#calendar-filter-badge[hidden],
#form-error[hidden] {
  display: none !important;
}

/* Shared resilience and accessible focus treatment. */
.workspace,
.upcoming-section,
.calendar-column,
.people-section,
.artist-profile-section,
.global-search-results,
.profile-hero,
.preview-identity,
.preview-facts,
.avatar-editor-row {
  min-width: 0;
}

button,
a,
input,
select,
textarea {
  overflow-wrap: anywhere;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(232, 137, 117, .34);
  outline-offset: 3px;
}

/* Home structure: the upcoming birthdays section now precedes one full-width calendar. */
.workspace {
  display: block;
  width: 100%;
  max-width: none;
}

.upcoming-section {
  width: 100%;
  margin-bottom: 48px;
}

.upcoming-section .section-heading {
  align-items: end;
}

.upcoming-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-height: 0;
  padding: 12px;
  border: 1px solid #f0e1d8;
  border-radius: var(--radius-lg, 26px);
  background: #f8efe9;
}

.upcoming-item {
  min-width: 0;
  min-height: 88px;
  padding: 14px;
  border: 1px solid #eddfd6;
  border-radius: var(--radius-md, 18px);
  background: var(--white, #fff);
}

.upcoming-item:last-child,
.upcoming-item:nth-last-child(-n + 2) {
  border-bottom: 1px solid #eddfd6;
}

.upcoming-info {
  min-width: 0;
}

.upcoming-info strong,
.upcoming-info span {
  min-width: 0;
}

.upcoming-info span {
  white-space: normal;
  line-height: 1.35;
}

.upcoming-item .person-name-button {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upcoming-arrow {
  flex: 0 0 auto;
}

.upcoming-card > .empty-state,
.upcoming-card > .upcoming-empty {
  grid-column: 1 / -1;
  min-height: 132px;
  padding: 28px;
  border: 1px dashed #dfc9bc;
  border-radius: var(--radius-md, 18px);
  background: rgba(255, 255, 255, .45);
}

.upcoming-section .add-quiet-button {
  max-width: 280px;
}

.calendar-column {
  width: 100%;
}

/* Calendar heading and controls remain usable at narrow widths. */
.calendar-column .section-heading {
  align-items: center;
  flex-wrap: wrap;
  row-gap: 12px;
}

.calendar-column .section-heading > h2,
.calendar-column .section-heading > div:first-child {
  min-width: 0;
}

.calendar-month-label {
  display: block;
  margin-top: 4px;
  color: var(--muted, #887a73);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .04em;
}

.calendar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  margin-left: auto;
}

.calendar-controls .calendar-filter-tools {
  order: 4;
}

.calendar-filter-tools {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 44px;
}

.filter-icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line, #eee3db);
  border-radius: 11px;
  background: var(--white, #fff);
  color: var(--ink, #39302d);
}

.filter-icon-button:hover,
.filter-icon-button:focus-visible,
.filter-icon-button.is-active {
  border-color: #e6b0a2;
  background: #fff4ed;
  color: var(--coral-deep, #cd6958);
}

.filter-icon-button svg {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}

.filter-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 2px solid var(--white, #fff);
  border-radius: 50%;
  background: var(--coral, #e88975);
  color: #fff;
  font-size: 9px;
  font-weight: 750;
  line-height: 1;
}

.calendar-filter-panel {
  width: 100%;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid #f0e1d8;
  border-radius: 15px;
  background: #fffaf7;
}

.calendar-filter-panel .calendar-filters {
  margin: 0;
}

.calendar-filter-panel:not([hidden]) {
  display: block;
}

.calendar-filter-status {
  position: relative;
  z-index: 0;
}

.calendar-card {
  width: 100%;
}

/* Artist navigation dropdown wrappers, including safe right alignment on phones. */
#movies-nav-wrap,
#shows-nav-wrap {
  position: relative;
}

#movies-nav,
#shows-nav {
  width: 100%;
}

#movies-dropdown,
#shows-dropdown {
  left: 0;
  right: auto;
}

@media (max-width: 680px) {
  #movies-dropdown,
  #shows-dropdown {
    right: 0;
    left: auto;
  }

  #movies-dropdown::before,
  #shows-dropdown::before {
    right: 28px;
    left: auto;
  }
}

/* Search results under the global search form. */
.global-search-results {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line, #eee3db);
  border-radius: var(--radius-md, 18px);
  background: #fff;
  box-shadow: 0 8px 22px rgba(91, 62, 49, .045);
}

.global-search-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}

.global-search-heading h2 {
  margin: 0;
  font-size: 22px;
}

.global-search-total,
.global-search-group-count {
  color: var(--muted, #887a73);
  font-size: 11px;
  font-weight: 650;
}

.global-search-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.global-search-group {
  min-width: 0;
  padding: 13px;
  border: 1px solid #f0e6df;
  border-radius: 13px;
  background: #fffaf7;
}

.global-search-group h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 9px;
  color: var(--ink, #39302d);
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 400;
}

.global-search-list {
  display: grid;
  gap: 5px;
}

.global-search-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink, #39302d);
  text-align: left;
  text-decoration: none;
}

.global-search-item:hover,
.global-search-item:focus-visible {
  background: #fff1e9;
  color: var(--coral-deep, #cd6958);
}

.global-search-item-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--peach, #f8ded1);
  color: var(--coral-deep, #cd6958);
  font-size: 11px;
  font-weight: 750;
}

.global-search-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.global-search-item-copy {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.global-search-item-copy strong,
.global-search-item-copy small {
  display: block;
}

.global-search-item-copy strong {
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-search-item-copy small {
  margin-top: 2px;
  color: var(--muted, #887a73);
  font-size: 10px;
}

.global-search-empty {
  margin: 0;
  color: var(--muted, #887a73);
  font-size: 11px;
  line-height: 1.5;
}

.global-search-more {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin-top: 7px;
  color: var(--coral-deep, #cd6958);
  font-size: 11px;
  font-weight: 700;
  text-underline-offset: 3px;
}

/* Shared person-name buttons and image-ready avatar wrappers. */
.person-name-button {
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: inherit;
}

.person-name-button:hover {
  color: var(--coral-deep, #cd6958);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.birthday-chip {
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.birthday-chip:hover {
  box-shadow: inset 0 0 0 1px rgba(205, 105, 88, .35);
}

.upcoming-avatar,
.person-avatar,
.age-avatar,
.preview-avatar,
.profile-avatar {
  overflow: hidden;
}

.upcoming-avatar img,
.person-avatar img,
.age-avatar img,
.preview-avatar img,
.profile-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.preview-avatar,
.profile-avatar {
  display: grid;
  place-items: center;
  background: var(--peach, #f8ded1);
  color: var(--coral-deep, #cd6958);
  font-weight: 750;
}

.person-card h3 {
  min-width: 0;
  overflow: hidden;
}

.person-card h3 .person-name-button {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.age-person .person-name-button {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Quick artist preview modal. */
.artist-preview-modal.modal {
  width: min(100%, 520px);
}

.preview-identity {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 0 0 22px;
}

.preview-avatar {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 50%;
  font-size: 22px;
}

.preview-meta {
  min-width: 0;
}

.preview-meta h2 {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.preview-meta p {
  margin: 0;
  color: var(--muted, #887a73);
  font-size: 12px;
}

.preview-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin: 0 0 18px;
}

.preview-facts div {
  min-width: 0;
}

.preview-facts dt {
  margin-bottom: 3px;
  color: var(--muted, #887a73);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.preview-facts dd {
  margin: 0;
  color: var(--ink, #39302d);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.preview-note {
  margin: 0 0 20px;
  padding: 13px 15px;
  border-left: 3px solid var(--peach, #f8ded1);
  background: #fff6f0;
  color: var(--muted, #887a73);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.preview-actions a {
  text-decoration: none;
}

/* Artist profile page. */
.artist-profile-section {
  margin-top: 18px;
}

.profile-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
}

.profile-nav-row .directory-back-link {
  margin-bottom: 0;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 26px;
  border: 1px solid #f0ddd4;
  border-radius: var(--radius-lg, 26px);
  background: #fffdfb;
  box-shadow: 0 12px 30px rgba(91, 62, 49, .045);
}

.profile-avatar {
  width: 120px;
  height: 120px;
  flex: 0 0 120px;
  border-radius: 50%;
  font-size: 32px;
}

.profile-copy {
  min-width: 0;
}

.profile-copy h2 {
  max-width: 100%;
  margin: 0 0 7px;
  font-size: clamp(27px, 4vw, 32px);
  overflow-wrap: anywhere;
}

.profile-copy p {
  max-width: 540px;
  margin: 0;
  color: var(--muted, #887a73);
  font-size: 13px;
  line-height: 1.55;
}

.profile-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 0;
}

.profile-facts div {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line, #eee3db);
  border-radius: 12px;
  background: #fff;
}

.profile-facts dt {
  margin-bottom: 4px;
  color: var(--muted, #887a73);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.profile-facts dd {
  margin: 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.profile-note {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid #f0e1d8;
  border-radius: var(--radius-md, 18px);
  background: #fff8f3;
}

.profile-note h3 {
  margin: 0 0 8px;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 400;
}

.profile-note p {
  margin: 0;
  color: var(--muted, #887a73);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.profile-missing {
  padding: 28px;
  border: 1px dashed #dfc9bc;
  border-radius: var(--radius-md, 18px);
  color: var(--muted, #887a73);
  text-align: center;
}

/* Avatar form/editor. */
.avatar-picker {
  margin-top: 15px;
}

.avatar-editor-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.avatar-edit-preview {
  display: grid;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #efd8cc;
  border-radius: 50%;
  background: var(--peach, #f8ded1);
  color: var(--coral-deep, #cd6958);
  font-size: 19px;
  font-weight: 750;
}

.avatar-edit-preview > span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}

.avatar-edit-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.avatar-editor-controls {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1 1 250px;
  flex-wrap: wrap;
}

.avatar-file-label {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  max-width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line, #eee3db);
  border-radius: 10px;
  background: #fff;
  color: var(--ink, #39302d);
  font-size: 11px;
  font-weight: 700;
}

.avatar-file-label input {
  width: min(100%, 250px);
  min-width: 0;
  max-width: 100%;
  color: var(--muted, #887a73);
  font-size: 12px;
}

#person-avatar-file {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: 13px;
}

#remove-avatar {
  min-height: 42px;
  white-space: nowrap;
}

#avatar-edit-status.field-help {
  display: block;
  margin-top: 7px;
  color: var(--muted, #887a73);
  font-size: 11px;
  line-height: 1.4;
}

#form-error.form-error {
  margin: 8px 0 0;
  padding: 9px 11px;
  border: 1px solid #efc7ba;
  border-radius: 9px;
  background: #fff0eb;
  color: #a45040;
  font-size: 11px;
  line-height: 1.45;
}

#form-error.form-error[hidden] {
  display: none !important;
}

@media (max-width: 950px) {
  .upcoming-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .global-search-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .upcoming-section {
    margin-bottom: 38px;
  }

  .upcoming-section .section-heading {
    align-items: start;
  }

  .upcoming-card {
    display: flex;
    align-items: stretch;
    gap: 10px;
    overflow-x: auto;
    padding: 10px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .upcoming-item {
    flex: 0 0 min(260px, 85vw);
    scroll-snap-align: start;
  }

  .upcoming-card > .empty-state,
  .upcoming-card > .upcoming-empty {
    flex: 1 0 100%;
    min-height: 125px;
  }

  .upcoming-section .add-quiet-button {
    max-width: none;
  }

  .calendar-column .section-heading {
    align-items: flex-start;
  }

  .calendar-column .section-heading > h2,
  .calendar-column .section-heading > div:first-child {
    flex: 1 1 145px;
  }

  .calendar-controls {
    width: 100%;
    margin-left: 0;
  }

  .calendar-controls .today-button {
    margin-right: auto;
  }

  .calendar-filter-tools {
    margin-left: 0;
  }

  .calendar-filter-panel .calendar-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .global-search-results {
    padding: 14px;
  }

  .global-search-heading {
    display: block;
  }

  .global-search-total {
    display: block;
    margin-top: 4px;
  }

  .global-search-grid {
    grid-template-columns: 1fr;
  }

  .profile-nav-row {
    align-items: flex-start;
  }

  .profile-hero {
    display: block;
    padding: 21px;
  }

  .profile-avatar {
    margin-bottom: 16px;
  }

  .profile-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-facts {
    grid-template-columns: 1fr;
  }

  .preview-actions > * {
    flex: 1 1 auto;
    text-align: center;
  }

  .avatar-editor-controls {
    flex-basis: 100%;
  }

  .avatar-file-label {
    width: 100%;
  }

  .avatar-file-label input {
    width: 100%;
    min-width: 0;
    font-size: 16px;
  }

  #person-avatar-file { font-size: 16px; }

  #remove-avatar {
    flex: 0 0 auto;
  }
}

@media (max-width: 380px) {
  .profile-facts {
    grid-template-columns: 1fr;
  }

  .preview-identity {
    align-items: flex-start;
  }

  .preview-avatar {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .upcoming-card {
    scroll-behavior: auto;
    scroll-snap-type: none;
  }
}
