/* WishZing — forest green theme (Amethyst version) */

:root {
  --brand: #2f6a43;
  --brand-dark: #21492f;
  --ink: #1e241f;
  --paper: #f8faf7;
  --muted: #5b645c;
  --line: #dde7de;
  --gold-dark: #8f5f1d;
  --gold-bg: #fbf1e2;
  --success: #2f8f5c;
  --success-bg: #e9f7ee;
  --success-border: #bfe4cc;
  --danger: #b3401f;
  --danger-dark: #8a2f16;
  --danger-bg: #fbeae4;
  --danger-border: #f0c9b8;
}

* {
  box-sizing: border-box;
}

:focus-visible {
  outline: 2px solid var(--brand-dark);
  outline-offset: 2px;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--brand);
  color: white;
}

.site-header .brand {
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
}

/* Logged-out Log In/Sign Up links, and the avatar link, both sit
   directly in the header now that the session-nav wrapper is gone. */
.site-header a {
  color: white;
  text-decoration: none;
}

/* Shared shape for both avatar-initial circles (header + Groups-tab
   member rows) — only size/background/context differ below. */
.avatar,
.member-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 9999px;
  color: white;
  font-weight: 700;
}

/* The avatar is the header's "you are logged in as ___" indicator —
   tap it to reach Profile (deliberately off the tab bar). */
.avatar {
  margin-left: auto;
  background: var(--brand-dark);
  font-size: 0.9rem;
}

.version-badge {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--brand-dark);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* The persistent Home/Add/Groups tab bar. Docked to the bottom of the
   viewport on mobile (see the fixed positioning below); the same markup
   mirrors to the top on desktop, inside the 48rem media query. */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  background: var(--paper);
  border-top: 1px solid var(--line);
  /* Clears the iOS home-indicator gesture bar on notched devices. */
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
}

.tab[aria-current='page'] {
  color: var(--brand-dark);
  font-weight: 700;
}

/* Home/Groups icons — plain single-stroke outlines (no fill, no shadow)
   so they read as flat as the rest of the system; currentColor means
   they pick up the active/inactive tab color automatically. */
.tab-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.tab-label {
  line-height: 1;
}

/* The one non-flat element in the system: a filled circle sitting
   slightly proud of the bar, per DESIGN.md's tab-add component. */
.tab-add {
  margin-top: -1.25rem;
}

.tab-add-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  background: var(--brand);
  color: white;
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* The groups/members sidebar is desktop-only — see the 48rem media query
   below for where it actually appears. On mobile the Groups tab covers
   the same ground, so this stays hidden there (no thumb-reach cost). */
.sidebar {
  display: none;
}

.sidebar-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.sidebar-group {
  margin-bottom: 0.9rem;
}

.sidebar-group-name {
  font-weight: 600;
}

.sidebar-member-links {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-empty {
  margin: 0;
  font-size: 0.9rem;
}

main {
  flex: 1;
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  /* Clears the fixed mobile tab bar (plus its safe-area padding) so the
     last row of content isn't hidden behind it. */
  padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0));
}

a {
  color: var(--brand-dark);
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stacked-form.narrow {
  max-width: 20rem;
}

.stacked-form label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 0.6rem;
}

.stacked-form input,
.stacked-form select,
.stacked-form textarea {
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
}

.stacked-form input:focus,
.stacked-form select:focus,
.stacked-form textarea:focus {
  outline: 2px solid var(--brand);
  border-color: var(--brand);
}

.stacked-form button {
  margin-top: 1rem;
  padding: 0.55rem;
  border: none;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.stacked-form button:hover {
  background: var(--brand-dark);
}

.button-link {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  font-weight: 600;
  text-decoration: none;
}

.button-link:hover {
  background: var(--brand-dark);
}

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

/* Full-width tappable rows for a list of people (Groups tab) — replaces
   the old inline text-link chips, a deliberate tap-target-size fix. */
.member-row-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.member-row:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.member-avatar {
  background: var(--brand);
  font-size: 0.85rem;
}

.item {
  display: block;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
  min-height: 2.75rem;
  text-decoration: none;
  color: inherit;
}

.item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

/* Wish list rows only: priority badge sits as a tag before the name. */
.wish-row .item-head {
  justify-content: flex-start;
  gap: 0.6rem;
}

.item-head form {
  margin: 0;
}

.priority-badge {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}

/* Wish priority shown as gold stars (★ filled / ☆ empty, out of 5).
   The .priority-badge pill is now used only for the "admin" tag. */
.priority-stars {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--gold-dark);
  white-space: nowrap;
}

.item-image {
  display: block;
  max-width: 100%;
  max-height: 14rem;
  margin: 0.6rem 0 0;
  border-radius: 6px;
  border: 1px solid var(--line);
}

/* Wish list rows: photo to the left, everything else beside it. */
.wish-row {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}

.wish-row .item-body {
  flex: 1;
  min-width: 0;
}

.item-thumb {
  flex-shrink: 0;
  width: 5rem;
  height: 5rem;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

/* The detail page heading: title with the priority badge beside it. */
.detail-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.detail-head h1 {
  margin: 0;
}

/* The detail page's photo: shown at full width, natural height — no crop. */
.item-photo {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.6rem 0 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* Edit page: the photo field's label row, with the remove-photo toggle
   beside it. */
.photo-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.6rem;
}

.photo-block-header label {
  margin-top: 0;
}

.photo-block-header .remove-photo {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

/* The checkbox shouldn't inherit the form's text-input box styling. */
.photo-block-header input[type='checkbox'] {
  width: auto;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
}

.item-description {
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.suggested-note {
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
  margin: 0.4rem 0 0;
}

.purchased-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.purchased-row form {
  margin: 0;
}

.purchased-note {
  color: var(--success);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.inline-form {
  margin: 0.5rem 0 0;
}

.small-button {
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.small-button:hover {
  background: var(--brand-dark);
}

.invite-link {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.invite-link code {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  user-select: all;
}

/* Edit/Delete stacked, not side-by-side: Delete is de-emphasized
   (text-style, no box) so a slipped tap doesn't land on it by mistake. */
.item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.item-actions form {
  margin: 0;
}

.item-actions a {
  display: block;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  text-align: center;
  font-size: 0.95rem;
}

.item-actions a:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--paper);
}

/* Shared reset for text-style destructive buttons (Undo, Delete) — no
   box, just underlined danger-colored text so they never compete
   visually with a primary action beside them. */
.link-button {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  color: var(--danger);
  text-decoration: underline;
  cursor: pointer;
}

.link-button:hover {
  color: var(--danger-dark);
}

.item-actions .link-button {
  align-self: flex-start;
  font-size: 0.85rem;
}

.form-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  max-width: 20rem;
}

.form-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  max-width: 20rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.75rem;
}

.site-footer p {
  margin: 0;
}

/* Desktop: the same tab bar mirrors at the top of the screen instead of
   docking to the bottom, and the groups/members sidebar returns as a
   sticky left column beside the content — desktop has the width and no
   thumb-reach constraint, so both nav paths coexist here. Mouse
   precision makes tap-target sizing lower priority on this breakpoint,
   so that fix stays mobile-only. */
@media (min-width: 48rem) {
  .tab-bar {
    position: sticky;
    top: 0;
    bottom: auto;
  }

  /* Home/Groups read a little small at the mobile sizing once the tab
     bar sits at the top of a wider screen — bump both up here. */
  .tab {
    font-size: 0.9rem;
  }

  .tab-icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
    max-width: 60rem;
    margin: 0 auto;
  }

  .sidebar {
    display: block;
    width: 14rem;
    flex-shrink: 0;
    padding: 1.5rem 0;
    position: sticky;
    top: 3.5rem;
  }

  main {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-bottom: 1.5rem;
  }
}
