/*
 * Legacy public-site defaults (semantic classes), coloured by the --rb-* theme
 * tokens in app/assets/tailwind/application.css. Prefer Tailwind utilities
 * on new/edited public views; do not grow this file for layout/chrome.
 * Loaded only from layouts/application.html.erb.
 */

/* -------------------------------------------------------------------------- */
/* Page shell                                                                 */
/* -------------------------------------------------------------------------- */

html {
  color-scheme: var(--rb-scheme);
}

body {
  color: var(--rb-ink);
  background: var(--rb-ground);
  font-family: var(--rb-font-sans);
  font-size: 1rem;
  line-height: 1.5;
}

main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* Full-bleed map workspace (home trips + trip show) under site header.
   min-height on body does not cap the flex column, so a tall sidebar stretches the map.
   Lock the page to the viewport only while that shell is showing. */
body:has(main.main--map-workspace) {
  height: 100dvh;
  overflow: hidden;
}

main.main--map-workspace {
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* -------------------------------------------------------------------------- */
/* Flash messages                                                             */
/* -------------------------------------------------------------------------- */

.notice,
.alert {
  max-width: 48rem;
  margin: 0.75rem auto;
  padding: 0.65rem 1rem;
  border-radius: 0.125rem;
  border: 1px solid transparent;
}

.notice {
  background: var(--rb-notice-bg);
  border-color: var(--rb-notice-line);
  color: var(--rb-notice-ink);
}

.alert {
  background: var(--rb-danger-bg);
  border-color: var(--rb-danger-line);
  color: var(--rb-danger);
}

/* -------------------------------------------------------------------------- */
/* Typography                                                                 */
/* -------------------------------------------------------------------------- */

h1,
h2,
h3,
h4 {
  color: var(--rb-ink);
  font-family: var(--rb-font-heading);
  line-height: 1.15;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.25rem;
  margin-top: 1.75rem;
}

h3 {
  font-size: 1.1rem;
  margin-top: 1.25rem;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--rb-accent);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

a:hover {
  color: var(--rb-ink);
}

strong,
b {
  font-weight: 600;
}

hr {
  border: 0;
  border-top: 1px solid var(--rb-line);
  margin: 1.5rem 0;
}

/* -------------------------------------------------------------------------- */
/* Sections & spacing                                                         */
/* -------------------------------------------------------------------------- */

section > h1:first-child,
section > h2:first-child {
  margin-top: 0;
}

section + section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rb-line);
}

/* -------------------------------------------------------------------------- */
/* Lists                                                                      */
/* -------------------------------------------------------------------------- */

ul,
ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

li {
  margin-bottom: 0.35rem;
}

ul.trip-collaborators-list,
ul.trip-collaborators-pending-list,
ul.trip-invitations-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

ul.trip-collaborators-list li,
ul.trip-collaborators-pending-list li,
ul.trip-invitations-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.65rem 0.75rem;
  margin: 0 0 0.5rem;
  background: var(--rb-surface);
  border: 1px solid var(--rb-line);
  border-radius: 0.125rem;
}

/* -------------------------------------------------------------------------- */
/* Description lists                                                          */
/* -------------------------------------------------------------------------- */

dl {
  margin: 0 0 1.25rem;
}

dl > div {
  display: grid;
  grid-template-columns: minmax(7rem, 10rem) 1fr;
  gap: 0.35rem 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rb-line);
}

dt {
  margin: 0;
  font-weight: 600;
  color: var(--rb-muted);
  font-size: 0.9rem;
}

dd {
  margin: 0;
}

/* -------------------------------------------------------------------------- */
/* Tables                                                                     */
/* -------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  background: var(--rb-surface);
  border: 1px solid var(--rb-line);
  border-radius: 0.125rem;
  overflow: hidden;
  font-size: 0.95rem;
}

thead {
  background: var(--rb-sunken);
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--rb-line);
  vertical-align: top;
}

th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rb-muted);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--rb-ground);
}

.trips-list-empty {
  color: var(--rb-muted);
  font-style: italic;
}

/* -------------------------------------------------------------------------- */
/* Forms (theme — shared control density)                                     */
/* -------------------------------------------------------------------------- */

form {
  margin: 0 0 0.65rem;
}

/* button_to generates a form; keep nav/actions tidy */
form.button_to {
  display: inline;
  margin: 0;
}

/* Flat fieldsets (no chrome); legends stay in the a11y tree only */
fieldset {
  margin: 0 0 0.65rem;
  padding: 0;
  border: 0;
  background: transparent;
  min-inline-size: 0;
}

/* Visually hide legends and left-column section headings; keep for AT
   (not display:none — still exposed to screen readers / aria-labelledby) */
legend,
.main--map-workspace aside section > :is(h2, h3) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.field {
  margin: 0 0 0.55rem;
}

.field > p {
  margin: 0 0 0.2rem;
}

.field > p:last-child {
  margin-bottom: 0;
}

label {
  display: inline-block;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--rb-ink);
  margin-bottom: 0.1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="datetime-local"],
input[type="file"],
textarea,
select {
  display: block;
  width: 100%;
  max-width: 28rem;
  box-sizing: border-box;
  margin: 0;
  padding: 0.3rem 0.45rem;
  font: inherit;
  font-size: 0.9rem;
  color: inherit;
  background: var(--rb-raised);
  border: 1px solid var(--rb-line-strong);
  border-radius: 0.125rem;
  line-height: 1.35;
}

input[type="file"] {
  max-width: 100%;
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
}

textarea {
  min-height: 3.5rem;
  resize: vertical;
}

select {
  max-width: 20rem;
  cursor: pointer;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--rb-accent);
  outline-offset: 1px;
  border-color: var(--rb-accent);
}

input:disabled,
textarea:disabled,
select:disabled {
  background: var(--rb-sunken);
  color: var(--rb-muted);
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  display: inline-block;
  width: auto;
  max-width: none;
  margin: 0 0.4rem 0 0;
  vertical-align: middle;
  accent-color: var(--rb-accent);
}

.field-checkbox label,
.field-checkbox p label {
  font-weight: 500;
  display: inline;
}

.newsletter-options p {
  margin: 0.25rem 0;
}

.hint {
  color: var(--rb-muted);
  font-size: 0.8rem;
  margin: 0.15rem 0 0.35rem;
}

/* -------------------------------------------------------------------------- */
/* Buttons & actions                                                          */
/* -------------------------------------------------------------------------- */

button,
a.btn,
input[type="submit"],
input[type="button"],
input[type="reset"] {
  display: inline-block;
  text-decoration: none;
  margin: 0;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-family: var(--rb-font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--rb-on-primary);
  background: var(--rb-primary);
  border: 1px solid var(--rb-primary);
  border-radius: 0.125rem;
  cursor: pointer;
}

button:hover,
a.btn:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
  color: var(--rb-on-primary);
  background: var(--rb-primary-hover);
  border-color: var(--rb-primary-hover);
}

button:focus,
input[type="submit"]:focus,
input[type="button"]:focus,
input[type="reset"]:focus {
  outline: 2px solid var(--rb-accent);
  outline-offset: 2px;
}

button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Link-styled actions (workspace / secondary) */
button.btn-link,
input[type="submit"].btn-link,
input[type="button"].btn-link,
a.btn-link {
  display: inline;
  padding: 0;
  margin: 0;
  font-family: var(--rb-font-sans);
  letter-spacing: normal;
  text-transform: none;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: inherit;
  color: var(--rb-accent);
  background: transparent;
  border: 0;
  border-radius: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

button.btn-link:hover,
input[type="submit"].btn-link:hover,
input[type="button"].btn-link:hover,
a.btn-link:hover {
  color: var(--rb-ink);
  background: transparent;
}

button.btn-link:focus,
input[type="submit"].btn-link:focus,
input[type="button"].btn-link:focus,
a.btn-link:focus {
  outline: 2px solid var(--rb-accent);
  outline-offset: 2px;
}

button.btn-link-danger,
input[type="submit"].btn-link-danger,
input[type="button"].btn-link-danger,
a.btn-link-danger {
  display: inline;
  padding: 0;
  margin: 0;
  font-family: var(--rb-font-sans);
  letter-spacing: normal;
  text-transform: none;
  font-weight: 500;
  font-size: 0.875rem;
  line-height: inherit;
  color: var(--rb-danger);
  background: transparent;
  border: 0;
  border-radius: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

button.btn-link-danger:hover,
input[type="submit"].btn-link-danger:hover,
input[type="button"].btn-link-danger:hover,
a.btn-link-danger:hover {
  color: var(--rb-danger);
  background: transparent;
}

/* Quiet segmented buttons (theme switch on the dark bar) */
button.btn-quiet {
  padding: 0.45rem 0.7rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--rb-on-panel);
  background: transparent;
  border: 0;
  border-radius: 0;
}

button.btn-quiet:hover {
  background: transparent;
  text-decoration: underline;
}

button.btn-quiet[aria-pressed="true"] {
  font-weight: 600;
  color: var(--rb-bar);
  background: var(--rb-on-panel);
}

/* Tabs */
button.tab {
  padding: 0.7rem 0.75rem;
  font-weight: 500;
  color: var(--rb-muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
}

button.tab:hover {
  color: var(--rb-ink);
  background: transparent;
}

button.tab[aria-selected="true"] {
  font-weight: 600;
  color: var(--rb-ink);
  border-bottom-color: var(--rb-accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  margin: 0.4rem 0 0.15rem;
}

.account-actions,
.trip-show-actions,
.trips-actions,
.trip-invitation-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
}

/* -------------------------------------------------------------------------- */
/* Errors                                                                     */
/* -------------------------------------------------------------------------- */

#error_explanation {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--rb-danger-bg);
  border: 1px solid var(--rb-danger-line);
  border-radius: 0.125rem;
  color: var(--rb-danger);
}

#error_explanation h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--rb-danger);
}

#error_explanation ul {
  margin: 0;
  padding-left: 1.15rem;
}

#error_explanation li {
  margin-bottom: 0.2rem;
}

/* -------------------------------------------------------------------------- */
/* Danger / leave zones                                                       */
/* -------------------------------------------------------------------------- */

.account-danger-zone,
.trip-edit-danger,
.trip-edit-leave {
  margin-top: 2rem;
  padding: 1rem;
  border: 1px solid var(--rb-danger-line);
  border-radius: 0.125rem;
  background: var(--rb-danger-bg);
}

.account-danger-zone h2,
.trip-edit-danger h2,
.trip-edit-leave h2 {
  margin-top: 0;
  color: var(--rb-danger);
}

.account-danger-zone input[type="submit"],
.trip-edit-danger button,
.trip-edit-danger input[type="submit"] {
  background: var(--rb-danger);
  border-color: var(--rb-danger);
  color: var(--rb-surface);
}

.account-danger-zone input[type="submit"]:hover,
.trip-edit-danger button:hover,
.trip-edit-danger input[type="submit"]:hover {
  background: var(--rb-danger);
  opacity: 0.9;
}

/* -------------------------------------------------------------------------- */
/* Media / avatars                                                            */
/* -------------------------------------------------------------------------- */

.account-avatar-image,
.avatar-preview-image {
  display: block;
  max-width: 8rem;
  height: auto;
  border-radius: 0.125rem;
  border: 1px solid var(--rb-line);
  background: var(--rb-surface);
}

/* -------------------------------------------------------------------------- */
/* Auth + bail links                                                          */
/* -------------------------------------------------------------------------- */

.account-edit-bail,
.trip-edit-bail,
.trip-show-bail {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rb-line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
