/* Layout and behaviour copied from the WoW Armory app (same header,
   card and expand behaviour); light theme: white and greys, with a per-person accent colour. Every colour
   is a variable here so the theme can be swapped in one place. Icon tile
   styling is provisional - to be revisited. */
:root {
  /* App UI: white and greys. Colour comes only from each person's own
     accent (--person, set per card from people[].color in app.js). */
  --bg: #f5f6f7;
  --panel-bg: #ffffff;
  --panel-border: #e1e4e8;
  --divider: #eceef1;
  --text: #1d2127;
  --text-dim: #646b75;
  --ui-soft: #f1f2f4;
  --ui-border: #d5d9de;
  --hover: #f7f8f9;
  --panel-inset: #fafbfb;
  --person-default: #646b75;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

/* Fixed + auto-hiding, as in the Armory (app.js toggles
   .app-header--hidden and sets body padding-top from its real height).
   The safe-area padding keeps it clear of the phone's status bar when
   installed to the home screen. */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(1.25rem + env(safe-area-inset-top)) 1.5rem 1.25rem;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel-bg);
  transition: transform 0.25s ease;
}

.app-header--hidden {
  transform: translateY(-100%);
}

.app-header__title h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-header__icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
}

.app-header__subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 4rem 1rem;
  line-height: 1.6;
}

/* ---------- Backup reminder ---------- */

.backup-reminder {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--ui-border);
  background: var(--ui-soft);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.backup-reminder[hidden] { display: none; }

.backup-reminder__button,
.export-button {
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

.export-button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- Family panel (same shape as an Armory faction panel) ---------- */

.family-panel {
  max-width: 640px;
  margin: 0 auto;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  overflow: hidden;
}

.family-panel__header {
  padding: 0.9rem 1.1rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

.person-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--divider);
}

.person-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}

.person-card:hover,
.person-card--expanded {
  background: var(--hover);
}

/* A strip of the person's colour down the left edge while their
   timeline is open, carried on down the timeline itself. */
.person-card--expanded,
.timeline {
  box-shadow: inset 3px 0 0 var(--person, var(--person-default));
}

.person-card:focus-visible {
  outline: 2px solid var(--text-dim);
  outline-offset: -2px;
}

.person-card__main {
  flex: 1 1 auto;
  min-width: 0;
}

.person-card__name {
  font-weight: 700;
  color: var(--person, var(--person-default));
  margin: 0;
  padding-right: 1rem;
}

.person-card__age {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.85rem;
}

.person-card__meta {
  margin: 0.15rem 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.person-card__toggle {
  position: absolute;
  top: 1rem;
  right: 1.1rem;
  width: 0.65rem;
  height: 0.65rem;
  color: var(--text-dim);
  transition: transform 0.15s ease;
}

.person-card--expanded .person-card__toggle {
  transform: rotate(-180deg);
}

/* ---------- Icon tiles ---------- */

.icon-tile {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  /* Tinted from the owning person's accent colour. */
  border: 1px solid color-mix(in srgb, var(--person, var(--person-default)) 28%, white);
  background: color-mix(in srgb, var(--person, var(--person-default)) 9%, white);
  color: var(--person, var(--person-default));
}

.icon-tile svg {
  width: 70%;
  height: 70%;
  display: block;
}

/* Sits inline after the age on the name line. */
.gender-icon {
  width: 1.15rem;
  height: 1.15rem;
  margin-left: 0.4rem;
  border-radius: 4px;
  vertical-align: -0.15rem;
}

.event-icon {
  width: 1.75rem;
  height: 1.75rem;
}

/* ---------- Timeline ---------- */

.timeline {
  padding: 0.9rem 1.1rem 1.1rem;
  border-bottom: 1px solid var(--divider);
  background: var(--panel-inset);
}

.timeline[hidden] { display: none; }

.timeline__empty {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.timeline__year {
  margin: 0.9rem 0 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--person, var(--person-default));
  border-top: 1px solid var(--divider);
  padding-top: 0.6rem;
}

.timeline__year:first-child {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.timeline__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.timeline__item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.timeline__text {
  flex: 1 1 auto;
  min-width: 0;
}

.timeline__primary {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.timeline__secondary {
  margin: 0.1rem 0 0;
  font-size: 0.76rem;
  color: var(--text-dim);
}

.timeline__date {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- Footer ---------- */

.app-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 2rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

.export-status {
  margin: 0.6rem 0 0;
}
