/* ==========================================================================
   Lines For Life – Resource Database
   Component styles for results list, fields, loading, and modal
   ========================================================================== */

/* Theme tokens */
:root {
  --rdb-color-primary: #305c7f;
  --rdb-color-accent:  #f9dd62;
  --rdb-color-accent-h:#f7d231;
  --rdb-color-card-bg: #f8f1e9;
  --rdb-color-card-br: #305c7f;
  --rdb-color-link:    #0369a1;
  --rdb-color-ink:     #0f172a;
  --rdb-color-disabled:#ddd;

  --rdb-radius-sm: 6px;
  --rdb-radius-md: 8px;
  --rdb-radius-lg: 14px;

  --rdb-filter-height: 37px;

  --rdb-col-gap: 2.5%;

  --rdb-shadow-xl:
    0 10px 15px -3px rgba(0,0,0,.10),
    0 4px 6px -2px rgba(0,0,0,.05);
}

/* ==========================================================================
   Field lists & truncation
   ========================================================================== */

/* Hide truncated items beyond the first 2 and show "+N more" indicator */
.rdb-field-list.-is-truncated li:nth-child(n+3) { display: none; }
.rdb-field-list.-is-truncated::after {
  content: " +" attr(data-truncate) " more";
  display: list-item;
}

/* Base list formatting for ACF-derived lists */
.rdb-field-list,
.rdb-phone-list {
  margin: 0;
  padding: 0;
}
.rdb-field-list { padding-left: 1em; } /* keep bullets for generic field lists */
.rdb-phone-list { list-style: none; padding-left: 0; }  /* phone list is unstyled */

/* ==========================================================================
   Phone numbers
   ========================================================================== */

.rdb-phone-item { display: flex; flex-direction: column; }
.rdb-phone-item:not(:last-child) { margin-bottom: .5em; }
.rdb-phone-label { color: var(--rdb-color-primary); margin: 0; }
.rdb-phone-label::after { content: ':'; display: inline; }

/* ==========================================================================
   Hours of operation
   ========================================================================== */

.hours-of-operation {
  display: grid;
  grid-template-columns: auto 1fr; /* label then value */
  gap: .25rem 1rem;
}
.hours-of-operation dt { font-weight: 500; }
.hours-of-operation dd { margin-bottom: 0; }
/* dd inherits grid cell behavior; no flex needed */

/* ==========================================================================
   Results list
   ========================================================================== */

.rdb-results {
  position: relative;
}


.rdb-results-list { list-style: none; margin: 0; padding: 0; }

/* Result card */
.rdb-results-item {
  background-color: var(--rdb-color-card-bg);
  border: 1px solid var(--rdb-color-card-br);
  border-radius: var(--rdb-radius-md);
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  margin: 1rem 0;
  padding: 1.25rem;
}
.rdb-results-item:first-child {
  margin-top: 0;
}

/* Rows & columns inside result */
.rdb-row {
  display: flex;
  flex-basis: 100%;
  column-gap: var(--rdb-col-gap);
  margin-top: 20px;
}
.rdb-col {
  flex: 1 0 auto;
  max-width: 100%;
}

.rdb-col.rdb-addr,
.rdb-col[class*="rdb-phone"] {
  flex-shrink: 1;
}

.rdb-col-heading {
  color: var(--rdb-color-primary);
  margin: 0;
}

.-is-private > h4,
h4:has(+ .-is-private) {
  background-image: url(../img/padlock.png);
  background-position: left 0.1875rem;
  background-repeat: no-repeat;
  background-size: 0.75rem auto;
  padding-left: 1rem;
}

/* Meta/verified line */
.rdb-verified { font-style: italic; margin-top: 0; }

/* Title row */
.rdb-top {
  align-items: center;
  column-gap: 1rem;
  justify-content: space-between;
}
.rdb-title {
  color: var(--rdb-color-primary);
  font-size: 1.3em;
  font-weight: 600;
  line-height: 1;
  margin: 0;
  flex-shrink: 1;
}

/* Buttons */
.rdb-button {
  align-items: center;
  appearance: none;
  background-color: var(--rdb-color-accent);
  border-radius: 40px;
  color: var(--rdb-color-primary);
  cursor: pointer;
  display: flex;
  font-size: 1em;
  font-weight: 800;
  gap: .5rem;
  justify-content: center;
  line-height: 1.2;
  padding: 10px 20px;
  position: relative;
  text-align: center;
  text-decoration: none;
}
.rdb-button:hover { background-color: var(--rdb-color-accent-h); }
.rdb-view-details { flex: 0 0 auto; }

.rdb-btn-icon {
  width: 20px;
  height: 20px;
  padding: 3px;
  border: 1px solid var(--rdb-color-primary);
  border-radius: 20px;
}

.rdb-results-note {
  background: #f8f1e9;
  border: 1px #ffe8a2 solid;
  line-height: 1.5;
  margin: 2.5rem auto;
  max-width: 52rem;
  padding: 1.25rem;
  text-align: center;
}

/* ==========================================================================
   Loading state
   ========================================================================== */

.rdb-loading {
  position: absolute;
  inset: 0 0 auto 0; /* full width; height controlled below */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: column;
  z-index: 100;
  background-color: rgba(255,255,255,.75);
}

.rdb-spinner {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-block;
  border: 4px solid #000;
  border-top-color: var(--rdb-color-accent);
  border-radius: 50%;
  animation: rdb-spin 1s linear infinite;
}

.rdb-loading .rdb-spinner {
  margin-top: 2.5rem;
}

/* Only show loading UI when parent has .loading */
.rdb-results:not(.loading) > .rdb-loading { display: none; }

/* Spinner keyframes */
@keyframes rdb-spin {
  to { transform: rotate(360deg); }
}

.rdb-load-more-container {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  height: 2.75rem;
  align-items: center;
}

/* ==========================================================================
   Modal shell
   ========================================================================== */

.rdb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease-out;
  z-index: 9998;
}

.rdb-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease-out;
  z-index: 9999;
}

.rdb-modal.is-open { opacity: 1; pointer-events: auto; }
.rdb-modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.rdb-modal-container {
  position: relative;
  width: min(920px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  background: #fff;
  color: var(--rdb-color-ink);
  border-radius: var(--rdb-radius-lg);
  box-shadow: var(--rdb-shadow-xl);
  transform: translateY(6px) scale(.98);
  transition: transform 180ms ease-out;
  overflow: hidden;
}

.rdb-modal.is-open .rdb-modal-container { transform: translateY(0) scale(1); }

/* “X” close button in the top-right of the modal header */
.rdb-modal-x {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  font-size: 1.25rem;
  border: none;
  background: transparent;
  color: #475569;              /* slate-500 */
  cursor: pointer;
  border-radius: 6px;
}
.rdb-modal-x:hover,
.rdb-modal-x:focus {
  background: #f1f5f9;         /* slate-100 */
  color: #0f172a;              /* slate-900 */
  outline: none;
  box-shadow: 0 0 0 3px rgba(14,165,233,.35); /* accessible focus ring */
}

.rdb-modal-title {
  margin: 0;
  padding: 1rem 1.25rem .5rem 1.25rem;
  font-size: 1.25rem;
  line-height: 1.4;
  font-weight: 700;
  color: var(--rdb-color-ink);
}

.rdb-modal-content {
  padding: 0 1.25rem 1.25rem 1.25rem;
  overflow: auto;
  max-height: calc(100vh - 5.5rem);
}

/* Container for the rendered card layout inside the dialog */
.rdb-modal-body { display: block; }

/* Harmonize card spacing within the dialog */
.rdb-modal-body .rdb-results-item { margin: 0; }
.rdb-modal-body .rdb-top { align-items: center; padding-top: .25rem; }

/* Ensure columns wrap nicely in narrow modals */
.rdb-modal-body .rdb-row {
  flex-wrap: wrap;
  margin-top: 1.5rem;
}
.rdb-modal-body .rdb-col { min-width: 220px; }
.rdb-row:has(> .-is-desc) > .rdb-col {
  flex-basis: calc(50% - (var(--rdb-col-gap) / 2));
}
.rdb-row:has(> .-is-desc) > .rdb-col:not(:last-child) {
  margin-bottom: 1.5rem;
}


/* Website links remain readable on white background */
.rdb-modal-body .rdb-website-link {
  color: var(--rdb-color-link);
  text-decoration: none;
  word-break: break-word;
}
.rdb-modal-body .rdb-website-link:hover,
.rdb-modal-body .rdb-website-link:focus { text-decoration: underline; outline: none; }

/* Verified badge stands out in modal */
.rdb-modal-body .rdb-verified {
  background: #ecfdf5;
  border: 1px solid #99f6e4;
  border-radius: var(--rdb-radius-sm);
  padding: .5rem .75rem;
  margin-top: 0;
}

.rdb-modal-body .rdb-col-heading {
  margin-bottom: 0.25rem;
}

.rdb-modal-body .hours-of-operation {
  margin: 0;
}

.rdb-modal-body .rdb-field-list.rdb-phone-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5%;
  padding-left: 0;
}
.rdb-modal-body .rdb-phone-item {
  flex-basis: 47.5%;
}
/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  .rdb-modal-container {
    width: calc(100vw - 1.25rem);
    max-height: calc(100vh - 1.25rem);
    border-radius: 12px;
  }
  .rdb-modal-title {
    padding: .875rem 1rem .25rem 1rem;
    font-size: 1.125rem;
  }
  .rdb-modal-content {
    padding: 0 1rem 1rem 1rem;
    max-height: calc(100vh - 4.5rem);
  }
}

/* ==========================================================================
   Motion reduction
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .rdb-modal,
  .rdb-modal-overlay,
  .rdb-modal-container {
    transition: none;
  }
}

/* ==========================================================================
   Page scroll lock when modal is open (toggle on <body>)
   ========================================================================== */

body.rdb-modal-open { overflow: hidden; }


.rdb-nearby-form {
  --rdb-field-col-gap: 1rem;
  --rdb-field-height: 2.3125rem;
  --rdb-field-row-gap: 1rem;
  display: flex;
  flex-direction: column;
  gap: var(--rdb-field-row-gap) var(--rdb-field-col-gap);
  margin-bottom: 1.5rem;
}

.rdb-form-row {
  display: flex;
  gap: var(--rdb-field-row-gap) var(--rdb-field-col-gap);
}

.rdb-form-item {
  display: flex;
  flex: 0;
  flex-direction: column;
}

.-is-online-only .rdb-form-item:not(.rdb-form-item--submit) {
  flex-grow: 1;
}

.-is-online-only .rdb-form-item--online,
.-is-online-only .rdb-form-item--location,
.-is-online-only .rdb-form-item--radius {
  display: none;
}

.rdb-form-item--categories {
  flex-basis: calc(30% - var(--rdb-field-col-gap));
}

.rdb-form-item--region {
  flex-basis: calc(13% - var(--rdb-field-col-gap));
}

.rdb-form-item--online {
  flex-basis: calc(13% - var(--rdb-field-col-gap));
}

.rdb-form-item--location {
  flex-basis: calc(21% - var(--rdb-field-col-gap));
  flex-grow: 1;
  position: relative;
}

.rdb-form-item--radius {
  flex-basis: calc(6% - var(--rdb-field-col-gap));
}

.rdb-form-item--submit {
  flex-basis: calc(7.125% - var(--rdb-field-col-gap));
  margin-top: 27px;
}

.rdb-form-label {
  color: #305c7f;
  font-size: 1em;
  font-weight: 600;
  line-height: 1.75;
}

.rdb-form-label-note {
  bottom: 1px;
  font-size: 0.85em;
  position: relative;
}

.rdb-form-field,
input.rdb-form-field,
select.rdb-form-field,
.rdb-nearby-form div.treeselect-input,
#rdb-address-pac {
  border-radius: 19px;
  border: 1px #305c7f solid;
  cursor: pointer;
  font-size: .8em;
  height: var(--rdb-filter-height);
  line-height: 1.2;
  padding: 7px 12px;
  position: relative;
}

.-is-disabled #rdb-address-pac {
  background-color: #e7e7e7;
}
.-is-disabled #rdb-address-overlay {
  background-color: transparent;
  cursor: default;
  display: none;
  height: var(--rdb-filter-height);
  width: 100%;
  z-index: 9999999;
  transform: translateY(calc(-1 * var(--rdb-filter-height)));
}
.-is-disabled #rdb-address-overlay {
  display: block;
}

#rdb-address-pac {
  padding: 0;
}

.rdb-address-clear {
  align-items: center;
  background: #fff;
  border-radius: 50%;
  border: none;
  bottom: 2px;
  box-sizing: content-box;
  cursor: pointer;
  display: flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  position: absolute;
  right: 8px;
  width: 32px;
  z-index: 999999;
}

.rdb-address-clear:active,
.rdb-address-clear:focus {
  box-shadow: none;
}

.rdb-address-clear:after {
  background: transparent;
  content: '';
  display: block;
  height: 52px;
  position: absolute;
  width: 52px;
}

.rdb-address-clear svg {
  height: 21px;
  width: 21px;
}

.rdb-address-clear:hover svg {
  stroke: #838790;
}

select.rdb-form-field {
  appearance: none;
}

select.rdb-form-field[disabled] {
  background-color: var(--rdb-color-disabled);
  cursor: default;
}

select.rdb-form-field,
.rdb-form-item .treeselect-input__arrow {
  background-image: url('../img/chevron-down-blue.svg');
  background-position: 95% center;
  background-repeat: no-repeat;
  background-size: 10px 7px;
}

.focus-ring {
  border-color: #305c7f;
}

.rdb-nearby-form .treeselect-list {
  -ms-flex-direction: column;
  -webkit-flex-direction: column;
  background-color: light-dark(#fff, #131314);
  border-radius: 8px;
  border: none;
  box-shadow: 0 1px 2px 0 light-dark(rgba(60, 64, 67, .3), rgba(0, 0, 0, .3)), 0 2px 6px 2px light-dark(rgba(60, 64, 67, .15), rgba(0, 0, 0, .15));
  flex-direction: column;
  width: 100%;
  z-index: 1000;
}

.rdb-nearby-form .treeselect-list__item {
  padding: 2px 8px;
}

.rdb-nearby-form .treeselect-list__item.treeselect-list__item--focused {
  background-color: #f8f1e9 !important;
}


.rdb-nearby-form div.treeselect-input {
  min-height: 37px;
  height: auto;
}

.rdb-nearby-form div.treeselect-input.treeselect-input--focused {
  box-shadow: 0 0 0 2px #305c7f;
}

.rdb-form-item .treeselect-input__operators {
  right: 10px;
}

.rdb-form-item .treeselect-input__clear svg {
  height: 21px;
  stroke: #000;
  width: 20px;
}

.rdb-form-item .treeselect-input__arrow {
  align-self: center;
  height: 7px;
  margin-left: 5px;
  width: 10px;
}

.rdb-form-item .treeselect-input__arrow svg {
  display: none;
}

.rdb-form-item--submit .rdb-button {
  height: 37px;
}

.rdb-status {
  margin-bottom: 1rem;
  text-align: center;
}

.rdb-results-filter {
  align-items: center;
  background: #efefef;
  border: 1px solid #c6c6c6;
  border-radius: 0.75rem;
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
}

.rdb-results-filter-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}

.rdb-results-filter .rdb-results-filter-field {
  flex: 1 1 auto;
  padding-right: 2rem; /* make space for clear button */
}

.rdb-results-filter-clear {
  background: transparent;
  border: none;
  cursor: pointer;
  position: absolute;
  right: 0.5rem;
  background-color: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rdb-results-filter-clear svg {
  height: 1.25rem;
  pointer-events: none;
  width: 1.25rem;
}

.rdb-results:not(.-has-query) .rdb-results-filter {
  display: none;
}