html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  /* House background — full viewport, nothing covers it */
  background-image: url("house-background-16x9.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #111;
  /* Accessibility: label for decorative house background image */
  aria-label="Family home photograph — decorative background image";
}

/* Keyboard navigation: visible focus indicator for all interactive elements */
*:focus-visible {
  outline: 3px solid #0a3d62;
  outline-offset: 2px;
}

/* Ensure focus styles work in all browsers */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #0a3d62;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip link for keyboard users (hidden until focused) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #0a3d62;
  color: #fff;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  top: 0;
}

/* Top-of-page legal banner — always visible */
.legal-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  padding: 6px 16px;
}

.legal-links {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.95rem;
}

.legal-link {
  color: #0a3d62;
  text-decoration: none;
  font-weight: 600;
}

.legal-link:hover {
  text-decoration: underline;
}

.separator {
  color: #999;
}

/* Shell — background shows through; nothing overlays the house image except this semi-transparent shell */
.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.shell > .toolbar,
.shell > h2,
.shell > .member-page {
  flex: 1 1 100%;
}

/* Member page layout — form left half, calendar right half */
.member-page {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
}

/* Keep member page hidden until login */
.member-page[hidden],
#memberPage.hidden {
  display: none !important;
}

.member-page > h2 {
  flex: 1 1 100%;
  margin-top: 0;
}

.member-page > .toolbar-btn {
  flex: 0 0 auto;
}

/* Dedicated equal-width row below the member toolbar. */
.member-page {
  padding: 0 20px 24px;
}

.member-calendar-layout {
  flex: 0 0 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}

.member-calendar-layout > #addItemForm,
.member-calendar-layout > .calendar-section {
  box-sizing: border-box;
  min-width: 0;
  margin: 0;
}

.member-calendar-layout > .calendar-section {
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

/* Calendar grid — fill its container */
.calendar-grid {
  width: 100%;
  overflow-x: auto;
  flex: 1 1 auto;
}

.calendar-grid table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Custom items list — full width under both columns */
.member-page > #customItemsList {
  flex: 1 1 100%;
  margin-top: 24px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-btn {
  padding: 8px 14px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-size: 0.95rem;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.95);
}

.toolbar-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toolbar-btn.donate {
  border-color: #d32f2f;
  color: #d32f2f;
  font-weight: 700;
}

.catalog h1 {
  margin: 0 0 8px 0;
  font-size: 1.75rem;
}

.invite-note {
  margin: 0 0 16px 0;
  font-size: 0.95rem;
  color: #333;
}

.samsclub-section {
  margin: 20px 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}

.samsclub-section h2 {
  margin: 0 0 8px 0;
  font-size: 1.25rem;
}

.samsclub-note {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  color: #333;
}

.samsclub-frame-wrapper {
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
  background: #fff;
}

.samsclub-frame-wrapper iframe {
  width: 100%;
  height: 600px;
  border: none;
  display: block;
}

/* Modals (pop-ups — login + legal docs) */
.modal {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  opacity: 0.7;
}

.modal-content h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.invite-text {
  margin: 8px 0 16px 0;
  font-size: 0.9rem;
  color: #333;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
}

input[type="text"] {
  padding: 8px 10px;
  border: 1px solid #bbb;
  border-radius: 6px;
  font-size: 1rem;
}

.submit-btn {
  padding: 8px 14px;
  border: none;
  background: #0a3d62;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  width: fit-content;
}

.submit-btn:hover {
  background: #083252;
}

.error {
  color: #d32f2f;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.legal-doc {
  max-width: 700px;
}

/* Cookie Consent Banner — fixed at bottom of screen, white background, above everything */
.cookie-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  color: #111;
  border-top: 4px solid #d32f2f;
  padding: 24px 28px;
  z-index: 2147483647;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: auto;
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
}

.cookie-content h3 {
  color: #111;
}

.cookie-text {
  margin: 0;
  font-size: 1rem;
  color: #111;
  line-height: 1.6;
  font-weight: 500;
}

.cookie-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.cookie-btn {
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: none;
  min-width: 110px;
  text-align: center;
}

.cookie-yes {
  background: #d32f2f;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.cookie-yes:hover {
  background: #b71c1c;
}

.cookie-no {
  background: #fff;
  color: #111;
  border: 2px solid #111;
}

.cookie-no:hover {
  background: #f5f5f5;
}

.cookie-link {
  background: #f5f5f5;
  color: #111;
  border: 1px solid #ccc;
}

.cookie-link:hover {
  background: #e0e0e0;
}

/* ================================================================
   Mobile responsiveness — all cell phones
   ================================================================ */

/* Prevent iOS Safari from zooming into form inputs (keeps 1:1 scale) */
input, select, textarea {
  font-size: 16px;
}

/* Mobile-first adjustments — phones up to 600px wide */
@media (max-width: 600px) {
  body {
    overflow-x: hidden;
    font-size: 1rem;
    -webkit-text-size-adjust: 100%;
  }

  .shell {
    padding: 10px;
    gap: 16px;
  }

  .legal-banner {
    padding: 6px 10px;
  }

  .legal-links {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    font-size: 1rem;
  }

  .toolbar {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 16px;
  }

  .toolbar-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    min-height: 44px;
    box-sizing: border-box;
  }

  /* Member page: stack the two columns into one */
  .member-calendar-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .member-calendar-layout > .calendar-section {
    min-height: auto;
  }

  /* Member page heading */
  .member-page > h2 {
    font-size: 1.25rem;
    margin-bottom: 12px;
  }

  /* Modals: full-width on phones, no overflow */
  .modal-content {
    width: 94vw;
    max-width: none;
    padding: 16px;
    margin: 10px;
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
  }

  .legal-doc {
    max-width: none;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
  }

  .close-btn {
    font-size: 2rem;
    top: 8px;
    right: 12px;
    min-height: 44px;
    min-width: 44px;
  }

  /* Calendar grid: horizontal scroll on narrow screens */
  .calendar-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .calendar-grid table {
    min-width: 320px;
  }

  .calendar-grid td {
    height: 50px;
    font-size: 1rem;
    padding: 4px 1px;
  }

  .calendar-grid th {
    font-size: 1rem;
    padding: 8px 4px;
  }

  .cal-nav {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  /* Calendar legend stacks vertically */
  .calendar-legend {
    flex-direction: column;
    gap: 6px;
    font-size: 1rem;
    text-align: center;
  }

  /* Add-item form inputs full width */
  .add-item-form input[type="date"],
  .add-item-form input[type="text"],
  .add-item-form select {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
    padding: 8px 10px;
  }

  .add-item-form button.submit-btn {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
  }

  /* Policy agreement banner — stack button on phones */
  #policyBanner {
    padding: 16px 16px;
    font-size: 1rem;
  }

  #policyBanner > div > div:last-child {
    flex-direction: column;
    gap: 8px;
  }

  #policyBanner button {
    width: 100%;
    min-width: unset;
    min-height: 44px;
    font-size: 1rem;
  }

  /* Credentials display */
  #credsDisplay {
    padding: 12px;
    font-size: 1rem;
  }

  #credsDisplay .copy-btn {
    min-height: 40px;
    padding: 6px 12px;
    font-size: 1rem;
  }

  /* Help dialog policy links — full-width tappable rows */
  .help-policy-link {
    display: block;
    width: 100%;
    text-align: center;
    padding: 10px;
    min-height: 44px;
    box-sizing: border-box;
  }

  /* Form inputs full width */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  select {
    width: 100%;
    box-sizing: border-box;
  }

  .submit-btn {
    width: 100%;
    min-height: 44px;
    font-size: 1.1rem;
  }

  textarea {
    min-height: 100px;
  }

  /* House background — avoid fixed attachment on mobile (Safari quirk) */
  body {
    background-attachment: scroll;
  }

  /* Donation buttons — stack vertically on phones */
  .donation-buttons {
    flex-direction: column !important;
  }
  .donation-item {
    width: 100%;
  }
  .donation-item input {
    width: 110px;
  }
  .donate-btn {
    width: 100%;
    font-size: 1rem;
    min-height: 44px;
  }

  /* Policy banner — prevent horizontal overflow on phones */
  #policyBanner {
    padding: 14px 12px !important;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
  #policyBanner > div > div:nth-child(3) {
    flex-wrap: wrap !important;
    gap: 6px !important;
    justify-content: flex-start !important;
  }
  #policyBanner a {
    overflow-wrap: break-word;
    word-wrap: break-word;
    white-space: normal !important;
  }

  /* Cookie banner — prevent horizontal overflow on phones */
  #cookieConsentBanner {
    padding: 12px 12px !important;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
  #cookieConsentBanner div {
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
  #cookieConsentBanner button {
    min-width: unset !important;
    width: 100% !important;
    min-height: 44px !important;
    font-size: 1rem !important;
    box-sizing: border-box;
  }
}

/* Small tablets / large phones — 601px to 900px */
@media (min-width: 601px) and (max-width: 900px) {
  .member-calendar-layout {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar-btn {
    min-height: 44px;
    font-size: 1rem;
  }

  .modal-content {
    width: 90vw;
    max-width: 520px;
  }
}

@media (min-width: 600px) {
  .cookie-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.muted {
  color: #666;
  font-size: 0.9rem;
}

.last-updated {
  font-style: italic;
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.success {
  color: #2e7d32;
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* Family Calendar */
.calendar-section {
  margin: 24px 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 4px 8px;
  background: #0a3d62;
  color: #fff;
  border-radius: 6px 6px 0 0;
}

.calendar-header h2 {
  margin: 0;
  font-size: 1.1rem;
  flex: 1;
  text-align: center;
}

.cal-nav {
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-nav:hover {
  background: rgba(255,255,255,0.2);
}

.calendar-section h2 {
  margin-top: 0;
  font-size: 1.25rem;
  color: #111;
}

.cal-today {
  background: #fff9c4 !important;
  border-color: #fbc02d !important;
  font-weight: bold;
}

.calendar-grid {
  overflow-x: auto;
}

.calendar-grid table {
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 320px;
}

.calendar-grid th {
  background: #0a3d62;
  color: #fff;
  padding: 10px;
  text-align: center;
  border: 1px solid #0a3d62;
  font-size: 0.9rem;
}

.calendar-grid td {
  width: calc(100% / 7);
  min-width: 40px;
  height: 70px;
  padding: 6px 2px;
  text-align: center;
  vertical-align: top;
  border: 1px solid #ccc;
  background: #fff;
  font-size: 0.85rem;
}

.calendar-grid td.cal-trash-pickup {
  background: #ffebee;
  border-color: #d32f2f;
}

.calendar-grid td.cal-trash-road {
  background: #e3f2fd;
  border-color: #0a3d62;
}

.calendar-grid td.cal-shopping {
  background: #f3e5f5;
  border-color: #7b1fa2;
}

.calendar-grid td.cal-label {
  display: block;
  font-size: 0.65rem;
  margin-top: 2px;
  color: #333;
}

.calendar-grid td.cal-custom {
  border-color: #7b1fa2;
  background: #fce4ec !important;
}

.add-item-form {
  background: rgba(255, 255, 255, 0.9);
  padding: 12px;
  border-radius: 6px;
}

.add-item-form h3 {
  font-size: 1rem;
  color: #111;
}

.add-item-form input[type="date"],
.add-item-form input[type="text"],
.add-item-form select {
  padding: 6px 8px;
  border: 1px solid #bbb;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
}

.custom-items-list {
  font-size: 1rem;
}

.calendar-legend {
  margin-top: 12px;
  font-size: 1rem;
  color: #333;
}

/* Button disabled state */
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(100%);
}

/* Donation buttons */
.donate-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  background: #0a3d62;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  min-height: 44px;
}

.donate-btn:hover {
  background: #083252;
}

.donate-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(100%);
}

/* Donation tracker dialog */
#donationTrackerDialog .modal-content {
  max-width: 700px;
}

.submit-btn:disabled {
  background: #999 !important;
}

.close-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Help dialog — ticket form + policy links */
#helpTicketForm textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #bbb;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.help-policy-link {
  color: #0a3d62;
  text-decoration: none;
  font-weight: 600;
  padding: 6px 12px;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 6px;
}

.help-policy-link:hover {
  background: rgba(255,255,255,0.9);
  text-decoration: underline;
}

/* All buttons disabled until policies agreed */
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(100%);
}

.submit-btn:disabled {
  background: #999 !important;
}

.close-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Help dialog — ticket form + policy links */
#helpTicketForm textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #bbb;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.help-policy-link {
  color: #0a3d62;
  text-decoration: none;
  font-weight: 600;
  padding: 6px 12px;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 6px;
}

.help-policy-link:hover {
  background: rgba(255,255,255,0.9);
  text-decoration: underline;
}
/* Font and image licensing attribution:
 * Fonts: system-ui / system default fonts (no license required — system fonts)
 * Images: house-background-16x9.png — decorative background, owner-supplied image
 * No web fonts are loaded. No licensed third-party assets are used. */
