/* ============================================================
   ShoppingList — hunter's-night theme (Rails + Hotwire)
   ============================================================ */

:root {
  /* Surfaces (green-dark family) */
  --deep-night: #1A2321;   /* recessed: inputs, wells */
  --night: #212C2A;        /* base background */
  --card: #293735;         /* surface: cards, rows */
  --card-raised: #30413E;  /* default row surface */
  --card-hover: #263330;   /* row hover: a touch darker/stronger */
  --selection: #415854;    /* selected / borders */

  /* Text */
  --fg: #F8F8F2;           /* primary off-white */
  --comment: #70A99F;      /* secondary green-gray */

  /* Neons */
  --green: #8AFF80;        /* brand / action / done / up */
  --green-hi: #A3FF9B;
  --red: #FF9580;          /* destructive / offline */
  --orange: #FFCA80;       /* warning / connecting */
  --cyan: #80FFEA;         /* links / info / local sync */

  /* Effects */
  --border: #415854;
  --border-subtle: #293735;
  --shadow-card: rgba(0, 0, 0, 0.3) 0 4px 12px;
  --shadow-dialog: rgba(0, 0, 0, 0.5) 0 8px 24px;
  --glow-green: rgba(138, 255, 128, 0.4) 0 0 0 3px;
  --glow-green-dot: rgba(138, 255, 128, 0.4) 0 0 8px;
  --glow-red-dot: rgba(255, 149, 128, 0.5) 0 0 8px;

  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--fg);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(65, 88, 84, 0.35), transparent 60%),
    var(--night);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: 32px 16px 48px;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 24px;
  align-self: flex-start;
}

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.card__title-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.card__title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.2px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.card__logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex: none;
}

/* ---------- Status pill ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--comment);
}
.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: var(--glow-green-dot);
  flex: none;
}
.status__label { color: var(--green); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  flex: none;
}
.btn--danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn--danger:hover { background: rgba(255, 149, 128, 0.12); }
.btn:focus-visible { outline: none; box-shadow: var(--glow-green); }

/* icon-only button (clear/trash) */
.btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  line-height: 0;
}
.btn__icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

/* ---------- Composer ---------- */
.composer {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.composer__input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--fg);
  background: var(--deep-night);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 18px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer__input::placeholder { color: var(--comment); }
.composer__input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: var(--glow-green);
}
.composer__add {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: var(--night);
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.composer__add:hover { background: var(--green-hi); }
.composer__add:active { transform: scale(0.94); }
.composer__add:focus-visible { outline: none; box-shadow: var(--glow-green); }

/* ---------- Lists ---------- */
.list-section { margin-bottom: 8px; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-section--done { margin-top: 24px; }
.list-section__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 10px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}
.list-section__title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--comment);
}
.list-section__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--night);
  background: var(--green);
  border-radius: 6px;
  padding: 1px 7px;
  font-weight: 700;
}

/* button_to wraps its button in a <form>; keep those transparent to layout */
.clear-form { margin: 0; }
.item__toggle { flex: none; margin: 0; line-height: 0; }
.item__edit-form { margin: 0; }

/* ---------- Item row ---------- */
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
  position: relative;
  overflow: hidden;
  /* vertical scroll stays native; horizontal swipe-to-done is handled in JS */
  touch-action: pan-y;
}
.item:hover { background: var(--card-hover); }

/* SortableJS drag-to-reorder states */
.item.sortable-ghost {           /* the drop-target placeholder */
  opacity: 0.4;
  border-color: var(--green);
  border-style: dashed;
}
.item.sortable-chosen { background: var(--card-raised); }
.item.sortable-drag,
.item.sortable-fallback {        /* the floating row that follows the pointer */
  cursor: grabbing;
  border-color: var(--green);
  background: var(--card-raised);
  box-shadow: var(--shadow-dialog);
  opacity: 1;
}

/* Swipe-right-to-done affordance: a green tail that reveals past the threshold */
.item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(138, 255, 128, 0.18), transparent 55%);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.item--will-done::before { opacity: 1; }

.item__name {
  flex: 1;
  min-width: 0;
}
.item__label {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  word-break: break-word;
  padding: 2px 0;
  background: none;
  border: none;
}
.item__edit {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  color: var(--fg);
  background: var(--deep-night);
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 4px 8px;
  box-shadow: var(--glow-green);
}
.item__edit:focus { outline: none; }

/* Circle (right) — the complete / reopen toggle */
.item__circle {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--comment);
  background: transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.item__circle:hover { border-color: var(--green); box-shadow: var(--glow-green-dot); }
.item__circle:focus-visible { outline: none; box-shadow: var(--glow-green); }

/* Done rows */
.list--done .item__label { color: var(--comment); text-decoration: line-through; }
.list--done .item__circle {
  border-color: var(--green);
  background: var(--green);
}
.list--done .item__circle::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid var(--night);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------- Empty / hint ---------- */
/* Empty-state text shows only while its list has no rows. `:has(li)` (not
   `:empty`) so stray whitespace left by Turbo stream inserts doesn't count. */
.empty {
  margin: 8px 4px;
  font-size: 13px;
  color: var(--comment);
}
.list:has(li) + .empty { display: none; }

.hint {
  margin: 20px 4px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--comment);
  font-family: var(--font-mono);
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .app { padding: 16px 10px 32px; }
  .card { padding: 18px; border-radius: 12px; }
  .card__title { font-size: 22px; }
}
