/* Chart controls on the birth chart and chat pages (markup: js/charts/chart-markup.js, CHART_SHELL_HTML).
   The shared look (panels, gold-edged cards, coins, badges) comes from css/surfaces.css; this file adds
   each part's layout and details. Load order: styles.css, surfaces.css, chart-controls.css, page CSS.

   Contents
   1. Saved / Search / New chart switch
   2. Action bar (chart actions, focus button)
   3. Panels and their headings
   4. Saved charts (cards, pager)
   5. Search charts
   6. New chart form
   7. Responsive and reduced motion */

/* 1. Switch: the same bar as the reading tabs (frame: css/surfaces.css). ------------------------ */
.chart-source-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  width: 100%;
  margin: 0 0 12px;
  padding: 6px;
  overflow: visible;
  border-radius: 17px;
}
.chart-source-button {
  display: flex;
  min-width: 0;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 5px 10px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #5d594f;
  cursor: pointer;
  text-align: left;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.chart-source-button:not([aria-pressed="true"]):hover { border-color: var(--gold-line); background: var(--gold-100); color: var(--ink); }
.chart-source-button[aria-pressed="true"] { border-color: var(--yellow); background: #252523; box-shadow: 0 8px 18px -10px rgb(37 37 35 / 60%); color: var(--white); }
.chart-source-button:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
/* No saved charts yet: only the New chart tab is shown (saved-charts.js), across the full width. */
.chart-source-button[hidden] { display: none; }
.chart-source-switch.is-new-only { grid-template-columns: minmax(0, 1fr); }
/* Until the saved list loads it is not known which tabs apply; the space is kept so nothing jumps. */
.chart-source-switch.is-loading { visibility: hidden; }
.chart-source-icon { width: 26px; height: 26px; flex-basis: 26px; font-size: 13px; transition: transform .2s ease; }
.chart-source-button:hover .chart-source-icon { transform: scale(1.08); }
.chart-source-button > span:last-child { display: grid; gap: 1px; min-width: 0; }
.chart-source-button strong { overflow: hidden; font-size: 12px; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.chart-source-button small { color: #77736b; font-size: 9px; }
.chart-source-button[aria-pressed="true"] small { color: #d8c27a; }

/* 2. Action bar: sticks to the top while the reading scrolls. ------------------------------------ */
.reading-focus-bar {
  position: relative;
  z-index: 8;
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: -3px 0 8px;
  pointer-events: none;
}
.person-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--gold-border);
  border-radius: 999px;
  background: var(--surface-card-bg);
  box-shadow: var(--surface-raise);
  pointer-events: auto;
}
.person-actions[hidden] { display: none; }
/* "Chart readings" shortens to "Readings" on phones (see the 780px block). */
.person-action-label-short { display: none; }
.person-action-status { max-width: 260px; padding: 0 6px 0 10px; overflow: hidden; color: #77736b; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.person-action-status:empty { display: none; }
.person-action-status.is-error { color: #a53e38; }
.person-action,
.reading-focus-toggle {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  padding: 0 12px 0 9px;
  border: 1px solid var(--gold-pill-border);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
  text-decoration: none;
  transition: background .18s, border-color .18s, color .18s, box-shadow .18s;
}
.person-action-icon,
.reading-focus-icon { width: 13px; height: 13px; flex: 0 0 13px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.person-action:focus-visible,
.reading-focus-toggle:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
.person-action:hover:not(:disabled) { border-color: var(--ink); background: var(--ink); color: var(--white); }
.person-action:hover:not(:disabled) .person-action-icon { color: var(--yellow); }
.person-action:disabled { cursor: progress; opacity: .55; }
/* "Ask in chat" / "Chart readings" and the focus button: yellow at rest, black on hover or press. */
.person-action-chat,
.reading-focus-toggle { border-color: var(--yellow-deep); background: linear-gradient(180deg, #fae58a, var(--yellow) 60%, #efcb45); }
.reading-focus-toggle { min-height: 36px; padding: 0 15px 0 12px; box-shadow: 0 6px 16px -4px rgb(229 191 57 / 55%); font-weight: 800; pointer-events: auto; }
.reading-focus-toggle:hover,
.reading-focus-toggle:active { border-color: var(--ink); background: var(--ink); box-shadow: 0 6px 16px -4px rgb(37 37 35 / 45%); color: var(--white); }
.reading-focus-toggle:hover .reading-focus-icon { color: var(--yellow); }
.reading-focus-toggle[hidden] { display: none; }
.reading-focus-icon { width: 14px; height: 14px; flex-basis: 14px; }
/* aria-expanded="true": controls are showing, so the button offers "Focus on reading" (book). */
.reading-focus-toggle[aria-expanded="true"] .reading-focus-icon-controls,
.reading-focus-toggle[aria-expanded="false"] .reading-focus-icon-read { display: none; }
.person-action-danger { border-color: #eed3cf; background: #fbf0ee; color: #8d3935; }
.person-action-danger:hover:not(:disabled) { border-color: #a53e38; background: #a53e38; color: var(--white); }
.person-action-danger:hover:not(:disabled) .person-action-icon { color: inherit; }
.person-action-danger[data-confirming="true"] { border-color: #a53e38; background: #a53e38; box-shadow: 0 0 0 3px rgb(165 62 56 / 18%); color: var(--white); }
/* Re-process waiting for its confirming click: dark with a yellow ring (Delete's is red). */
.person-action:not(.person-action-danger)[data-confirming="true"] { border-color: var(--ink); background: var(--ink); box-shadow: 0 0 0 3px rgb(245 214 83 / 55%); color: var(--white); }
.person-action.is-busy { border-color: var(--yellow-deep); background: var(--yellow); color: var(--ink); opacity: 1; }
.person-action.is-busy .person-action-icon { animation: person-action-spin .9s linear infinite; }

/* 3. Panels: plain white surface-panels; heading = large coin, eyebrow, title, description. ------ */
.saved-list-panel,
.saved-charts-panel,
.intro { padding: 20px; }
.saved-list-panel { display: grid; gap: 12px; padding-block: 15px; }
.saved-list-panel[hidden] { display: none; }
.saved-charts-panel,
.intro { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); align-items: center; gap: 26px; }
.saved-charts-copy,
.intro-copy { display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: center; column-gap: 13px; min-width: 0; }
.saved-charts-copy > *,
.intro-copy > * { grid-column: 2; }
.saved-charts-copy > .chart-panel-icon,
.intro-copy > .chart-panel-icon { grid-row: 1 / span 3; grid-column: 1; align-self: start; margin-top: 2px; }
.saved-charts-copy .eyebrow,
.intro-copy .eyebrow { color: var(--ink); }
.saved-charts-copy h1,
.intro-copy h1 { margin: 5px 0 4px; font-size: 20px; line-height: 1.15; letter-spacing: -.04em; }
.saved-charts-copy p,
.intro-copy p { max-width: 420px; margin: 0; color: #6f6b63; font-size: 11px; line-height: 1.55; }

/* 4. Saved charts ------------------------------------------------------------------------------ */
.saved-list-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.saved-list-controls { display: flex; min-width: 0; flex: 0 1 auto; align-items: center; justify-content: flex-end; gap: 10px; }
.saved-list-count { flex: 0 0 auto; padding: 4px 10px; font-size: 9.5px; }
.saved-list-status { margin: 0; color: #6f6b63; font-size: 11px; }
.saved-list-status:empty { display: none; }
.saved-list-status.is-error { color: #8d3935; }
.saved-list-empty-action {
  padding: 0;
  border: 0;
  background: none;
  color: #7a5b12;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.saved-list-empty-action:hover { color: #4f3a08; }
.saved-list-empty-action:focus-visible { outline: 2px solid #c9a227; outline-offset: 2px; border-radius: 2px; }
.saved-list-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.saved-list-grid:empty { display: none; }
.saved-person-item { display: flex; min-width: 0; }
/* Person cards: compact (about 75% of the original height). */
.saved-person-card {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  padding: 10px 9px 9px;
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.saved-person-card:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
/* Person card colours: grey at rest, the ivory-and-gold card look on hover, black when selected.
   The avatar coin and the birth/place icons keep their gold look at rest and on hover. */
.saved-person-card {
  border-color: #dcdcdc;
  background:
    radial-gradient(120% 70% at 100% 0%, rgb(255 255 255 / 70%), transparent 55%),
    linear-gradient(160deg, #f7f7f7 0%, #ececec 55%, #dedede 100%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 90%), 0 1px 2px rgb(0 0 0 / 5%), 0 8px 18px -12px rgb(0 0 0 / 28%);
}
.saved-person-card::before { background: linear-gradient(90deg, transparent, #9a9a9a, #c4c4c4, #9a9a9a, transparent); }
.saved-person-card .saved-person-saved { border-top-color: #d4d4d4; color: #5f5f5f; }
/* Hover: the current dark/light yellow look. */
.saved-person-card:not([aria-pressed="true"]):hover { border-color: var(--gold-border-strong); background: var(--surface-card-bg); box-shadow: var(--surface-raise-hover); }
.saved-person-card:not([aria-pressed="true"]):hover::before { background: var(--gold-edge); }
.saved-person-card:not([aria-pressed="true"]):hover .saved-person-saved { border-top-color: var(--gold-line); color: var(--gold-ink); }
/* The open chart's card: black. */
.saved-person-card[aria-pressed="true"],
.saved-person-card[aria-pressed="true"]:hover { border-color: #000; background: linear-gradient(135deg, #2a2a2a 0%, #161616 60%, #0b0b0b 100%); box-shadow: 0 0 0 1px #000, 0 12px 24px -12px rgb(0 0 0 / 75%); color: var(--white); }
.saved-person-card[aria-pressed="true"]::before { background: linear-gradient(90deg, transparent, #6a6a6a, #9a9a9a, #6a6a6a, transparent); }.saved-person-head { display: flex; min-width: 0; align-items: center; gap: 8px; margin-bottom: 1px; }
.saved-person-avatar { width: 26px; height: 26px; flex-basis: 26px; font-size: 9px; font-weight: 850; letter-spacing: .02em; }
.saved-person-name { min-width: 0; overflow: hidden; font-size: 10.5px; line-height: 1.2; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.saved-person-detail { display: flex; min-width: 0; align-items: center; gap: 5px; color: #4e4b45; font-size: 9px; line-height: 1.2; }
.saved-person-detail > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-person-detail-icon { display: grid; width: 14px; height: 14px; flex: 0 0 14px; place-items: center; border-radius: 50%; background: var(--gold-100); color: var(--gold-ink); font-size: 7.5px; }
.saved-person-saved { margin-top: auto; padding-top: 6px; border-top: 1px solid var(--gold-line); color: var(--gold-ink); font-size: 8px; font-weight: 700; letter-spacing: .03em; }
/* Top-right badges in the name row: "New" (gold sparkle) and "Recently viewed" (eye). The name shortens to make room. */
.saved-person-badges { display: flex; flex: 0 0 auto; align-items: center; gap: 3px; margin-left: auto; }
.saved-person-badges:empty { display: none; }
.saved-person-badge { display: grid; width: 16px; height: 16px; place-items: center; border-radius: 50%; }
.saved-person-badge svg { width: 10px; height: 10px; }
.saved-person-badge-new { background: linear-gradient(145deg, #f7d96b, #d9a82a); color: #5a3f05; box-shadow: 0 0 0 1px rgb(154 112 16 / 35%); }
.saved-person-badge-viewed { background: #fff; color: var(--gold-ink); box-shadow: 0 0 0 1px var(--gold-line); }
.saved-person-card[aria-pressed="true"] .saved-person-badge-viewed { background: rgb(255 255 255 / 14%); color: #f2f2f2; box-shadow: 0 0 0 1px rgb(255 255 255 / 25%); }
/* Footer rows: Created above, Accessed below. */
.saved-person-saved { display: flex; flex-direction: column; gap: 2px; }
.saved-person-stamp { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-person-card[aria-pressed="true"] .saved-person-detail { color: #e6e2d6; }
.saved-person-card[aria-pressed="true"] .saved-person-detail-icon { background: rgb(255 255 255 / 14%); color: #f2f2f2; }
.saved-person-card[aria-pressed="true"] .saved-person-saved { border-color: rgb(255 255 255 / 18%); color: #c8c8c8; }
.saved-person-skeleton {
  min-height: 108px; /* the card's height with its two-row Created/Accessed footer */
  border: 1px solid var(--gold-border);
  border-radius: 12px;
  background: linear-gradient(90deg, #f8f1df, #fffaf0, #f8f1df);
  background-size: 200% 100%;
  animation: saved-list-shimmer 1.2s ease-in-out infinite;
}
@keyframes saved-list-shimmer { to { background-position: -200% 0; } }
/* Pager: a small toggle in the card frame. */
.saved-list-pager { display: flex; max-width: 100%; align-items: center; gap: 3px; padding: 4px; overflow: visible; border-radius: 13px; }
.saved-list-pager[hidden] { display: none; }
.saved-list-page {
  min-width: 32px;
  min-height: 30px;
  padding: 0 9px;
  border: 2px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #5d594f;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 750;
  transition: background .15s, border-color .15s, color .15s;
}
.saved-list-page:hover:not(:disabled):not([aria-current="page"]) { border-color: var(--gold-line); background: var(--gold-100); color: var(--ink); }
.saved-list-page[aria-current="page"] { border-color: var(--yellow); background: #252523; box-shadow: 0 2px 6px rgb(37 37 35 / 18%); color: var(--yellow); cursor: default; }
.saved-list-page:disabled { cursor: default; opacity: .38; }
.saved-list-page:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
.saved-list-page-step { color: var(--ink); white-space: nowrap; }
.saved-list-page-gap { min-width: 18px; color: var(--gold-ink); font-size: 11px; font-weight: 800; text-align: center; }

/* 5. Search charts. Cards that hold suggestion lists must not clip or move (z-index keeps the list on top). */
.saved-search-card,
.entry-card { z-index: 2; overflow: visible; padding: 16px; border-radius: 15px; }
.saved-search-card > label { display: block; margin-bottom: 8px; color: var(--gold-ink); font-size: 8.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.saved-search-card input {
  min-height: 46px;
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237a6726' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.3'/%3E%3Cpath d='m10.3 10.3 3.2 3.2'/%3E%3C/svg%3E");
  background-position: 13px center;
  background-repeat: no-repeat;
  background-size: 17px;
}
.saved-chart-hint { margin: 10px 0 0; color: #77736b; font-size: 10px; line-height: 1.5; }
.autocomplete { position: relative; }
.autocomplete-options {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 220px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--gold-border-strong);
  border-radius: 13px;
  background: var(--white);
  box-shadow: 0 18px 40px -8px rgb(37 37 35 / 26%);
}
.autocomplete-option {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.autocomplete-option:hover,
.autocomplete-option[aria-selected="true"] { background: var(--gold-100); }
.autocomplete-status { margin: 0; color: #a53e38; font-size: 10px; }
.autocomplete-status:empty { display: none; }
.saved-search-card .autocomplete-status { margin-top: 7px; }

/* 6. New chart form ---------------------------------------------------------------------------- */
.form-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.form-heading strong { font-size: 13px; letter-spacing: -.02em; }
.private-pill { padding: 4px 10px; text-transform: none; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
/* minmax(0, 1fr): date and time inputs may shrink below their natural width on narrow phones. */
.field { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 6px; min-width: 0; }
.field label,
.field-label { color: var(--gold-ink); font-size: 8.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.gender-toggle {
  display: grid;
  min-height: 40px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid #dccf9f;
  border-radius: 12px;
  background: #faf7ee;
}
.gender-toggle-option {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 32px;
  border-radius: 9px;
  color: #5d594f !important;
  cursor: pointer;
  font-size: 12px !important;
  font-weight: 650 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
}
.gender-toggle-option span { display: grid; place-items: center; border: 2px solid transparent; border-radius: inherit; transition: background .15s, color .15s; }
.gender-toggle-option:hover input:not(:checked) + span { background: var(--gold-100); }
.gender-toggle-option input:checked + span { border-color: var(--yellow); background: #252523; box-shadow: 0 2px 6px rgb(37 37 35 / 18%); color: var(--yellow); }
.gender-toggle-option input:focus-visible + span { outline: 2px solid var(--gold-ink); outline-offset: 2px; }
.gender-toggle-option input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.submit-button { min-height: 40px; margin-top: 13px; }
.submit-icon { width: 15px; height: 15px; flex: 0 0 15px; fill: none; stroke: var(--yellow); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.submit-button > span { white-space: nowrap; }
.form-error { min-height: 12px; margin: 6px 0 0; color: #a53e38; font-size: 11px; }
.form-status { margin: 4px 0 0; color: #3f6b46; font-size: 11px; }
.form-status:empty { display: none; }

/* 7. Responsive and reduced motion -------------------------------------------------------------- */
@media (max-width: 1100px) and (min-width: 781px) {
  .saved-list-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 780px) {
  /* Switch: the coin sits above a short title, no subtitle (like the reading tabs). */
  .chart-source-switch { gap: 2px; margin-bottom: 10px; padding: 5px; border-radius: 15px; }
  .chart-source-button { min-height: 56px; flex-direction: column; gap: 4px; padding: 5px 2px; }
  .chart-source-button > span:last-child { max-width: 100%; }
  .chart-source-button small { display: none; }
  .chart-source-button strong { font-size: 10px; }
  .chart-source-icon { width: 22px; height: 22px; flex-basis: 22px; font-size: 11px; }
  .saved-list-panel, .saved-charts-panel, .intro { padding: 14px; border-radius: 17px; }
  .saved-charts-panel { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .saved-list-panel { gap: 9px; padding-block: 11px; }
  .saved-charts-copy h1, .intro-copy h1 { font-size: 18px; }
  .saved-list-heading { flex-wrap: wrap; align-items: flex-start; gap: 12px; }
  .saved-list-controls { width: 100%; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
  .saved-list-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .saved-person-card { padding: 9px 8px 8px; }
  .saved-person-avatar { width: 23px; height: 23px; flex-basis: 23px; font-size: 8px; }
  .saved-person-head { gap: 6px; }
  .saved-list-pager { gap: 1px; padding: 3px; }
  .person-action-label-long { display: none; }
  .person-action-label-short { display: inline; }
  .saved-list-page { min-height: 36px; padding: 0 7px; }
  .saved-search-card { padding: 14px; }
  .intro { display: block; }
  .intro-copy { display: none; }
  .entry-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 8px; padding: 12px; }
  .form-heading { grid-column: 1 / -1; margin-bottom: 0; }
  .form-heading strong { font-size: 12px; }
  .form-grid { display: contents; }
  .field { gap: 4px; }
  .field input, .field select, .gender-toggle, .saved-search-card input { min-height: 44px; font-size: 16px; }
  .gender-toggle-option { min-height: 36px; }
  .submit-button { grid-column: 2; align-self: end; min-height: 44px; margin-top: 0; padding: 0 8px; font-size: 11px; }
  .form-error, .form-status { grid-column: 1 / -1; min-height: 0; margin: 0; }
}
@media (max-width: 420px) {
  .form-grid { gap: 8px; }
  .field input { min-width: 0; padding: 0 9px; font-size: 16px; }
  .entry-card { padding: 10px; }
  .private-pill { padding: 3px 8px; }
  /* Narrow phones: let "Create & read chart" wrap onto two lines inside the button. */
  .submit-button { gap: 6px; }
  .submit-button > span { white-space: normal; line-height: 1.15; text-align: left; }
  /* Icon-only Re-process/Delete on phones (accessible names kept via title + hidden label).
     "Ask in chat" / "Chart readings" keep their text labels, as on desktop. */
  .person-action:not(.person-action-chat) { min-width: 34px; min-height: 34px; justify-content: center; padding: 0; }
  .person-action:not(.person-action-chat) .person-action-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .person-action-status { max-width: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .saved-person-skeleton, .person-action.is-busy .person-action-icon { animation: none; }
  .chart-source-button:hover .chart-source-icon { transform: none; }
}
