/* Troop tools: Merit Badges, Eagle Scouts and Troop Gear pages (Troop 182B / 182G) */

/* Elements the scripts show/hide with the hidden attribute stay hidden even if they are flex/grid. */
[data-merit-badges] [hidden], [data-eagle-scouts] [hidden], [data-gear] [hidden], .mb-explain [hidden] { display: none !important; }

.tt-lead { max-width: 760px; font-size: 1.15rem; color: #344052; }

.tt-callout {
  display: flex; gap: 14px; align-items: flex-start; max-width: 860px;
  margin: 0 0 32px; padding: 18px 22px; border-radius: 12px;
  background: var(--cream); border-left: 5px solid var(--unit);
}
.tt-callout > .icon { width: 26px; height: 26px; margin-top: 2px; color: var(--unit); }
.tt-callout p { margin: 0; }
.tt-callout p + p { margin-top: 6px; color: var(--muted); }
.tt-callout strong { font-family: var(--font-head); color: var(--navy-deep); }

/* ---------- Filter panel ---------- */

.tt-controls {
  display: grid; gap: 16px; margin: 0 0 14px; padding: 20px 22px;
  border-radius: var(--radius); background: var(--cream); border: 1px solid var(--line);
}
.tt-controls[hidden] { display: none; }
.tt-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 24px; }
.tt-search { position: relative; flex: 1 1 320px; min-width: 0; }
.tt-search label, .tt-label {
  display: block; margin-bottom: 6px; font: 700 .85rem var(--font-head); color: var(--navy-deep);
}
.tt-search .icon {
  position: absolute; left: 14px; bottom: 13px; width: 20px; height: 20px; color: var(--muted); pointer-events: none;
}
.tt-search input {
  width: 100%; min-height: 48px; padding: 10px 14px 10px 44px;
  border: 2px solid #cfc8b8; border-radius: 12px; background: #fff; color: var(--ink);
  font: inherit; font-size: 1rem;
}
.tt-search input::placeholder { color: #7a8391; }
.tt-search input:focus { border-color: var(--unit); outline: none; box-shadow: 0 0 0 3px rgba(0, 63, 135, .15); }
.tt-search input:focus-visible { outline: 3px solid var(--unit); outline-offset: 2px; }

/* Toggle switch (a real checkbox) */
.tt-switch {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer;
  font: 700 .95rem var(--font-head); color: var(--navy-deep);
}
.tt-switch input {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; margin: 0;
  width: 46px; height: 26px; border-radius: 999px; background: #b9c0ca; cursor: pointer;
  transition: background-color .15s;
}
.tt-switch input::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.tt-switch input:checked { background: var(--unit); }
.tt-switch input:checked::before { transform: translateX(20px); }
.tt-switch input:focus-visible { outline: 3px solid var(--unit); outline-offset: 3px; }

/* Category chips (toggle buttons) */
.tt-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.tt-chips button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: .45em 1em;
  border-radius: 999px; border: 2px solid var(--navy); background: #fff; color: var(--navy);
  font: 700 .85rem var(--font-head); cursor: pointer; white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.tt-chips button:hover { background: #e8eef7; }
.tt-chips button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.tt-chips button .n { font-weight: 600; opacity: .7; }
.tt-chips button:disabled { opacity: .45; cursor: default; }

.tt-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 18px; min-height: 2.2em; }
.tt-count { margin: 0; font-weight: 700; color: var(--navy-deep); }
.tt-clear {
  padding: 4px 2px; border: 0; background: none; cursor: pointer;
  font: 700 .9rem var(--font-head); color: var(--red); text-decoration: underline; text-underline-offset: 3px;
}
.tt-clear[hidden] { display: none; }

.tt-fine { color: var(--muted); font-size: .95rem; max-width: 860px; }

/* Tags */
.tt-tag {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font: 700 .7rem/1.6 var(--font-head); letter-spacing: .05em; text-transform: uppercase;
}
.tt-tag-eagle { background: var(--unit); color: var(--unit-ink); }
.tt-tag-new { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1.5px var(--red); }

/* Empty / no-results states */
.tt-empty {
  max-width: 760px; margin: 8px 0 32px; padding: 32px 28px; text-align: center;
  border: 2px dashed #d6cfbf; border-radius: var(--radius); background: #fff;
}
.tt-empty .tt-empty-icon {
  display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 50%; background: var(--cream); color: var(--unit);
}
.tt-empty .tt-empty-icon .icon { width: 32px; height: 32px; }
.tt-empty h3 { margin-bottom: .4em; }
.tt-empty p { color: #344052; margin-left: auto; margin-right: auto; max-width: 56ch; }
.tt-empty p:last-child { margin-bottom: 0; }
.tt-empty details { margin-top: 18px; text-align: left; border-top: 1px solid var(--line); padding-top: 14px; }
.tt-empty summary { cursor: pointer; font: 700 .95rem var(--font-head); color: var(--navy); }
.tt-empty details ol { margin: 10px 0 0; padding-left: 1.3em; color: #344052; }
.tt-empty details li { margin-bottom: .35em; }
.tt-empty code { font-size: .9em; background: var(--cream); padding: 1px 5px; border-radius: 4px; }
.tt-noresults { padding: 28px 20px; margin-bottom: 24px; text-align: center; border-radius: 12px; background: var(--cream); }
.tt-noresults p { margin: 0 0 6px; }
.tt-noresults[hidden] { display: none; }

/* ---------- Merit badge cards ---------- */

.mb-grid {
  list-style: none; margin: 0 0 40px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px;
}
.mb-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 18px; border-radius: 12px; background: #fff;
  border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0, 26, 56, .05);
  transition: border-color .15s, box-shadow .15s;
}
.mb-card:hover { border-color: var(--unit); box-shadow: var(--shadow); }
.mb-card[hidden] { display: none; }
/* Emblem: like the real patches, a green border, silver for Eagle-required badges */
.mb-body { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; align-items: flex-start; }
.mb-emblem {
  flex: none; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%;
  background: var(--cream); border: 4px solid #3f7a3a; box-shadow: inset 0 0 0 2px #fff;
  font: 800 .95rem var(--font-head); color: var(--navy-deep); letter-spacing: -.02em;
}
.mb-emblem.is-eagle { border-color: #a9b2bc; background: #eef1f4; box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px #8f99a4; }
.mb-card h3 { margin: 0; font-size: 1.02rem; line-height: 1.3; overflow-wrap: anywhere; }
.mb-cat { margin: 2px 0 0; color: var(--muted); font-size: .85rem; font-weight: 600; }
.mb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.mb-tags:empty { display: none; }
.mb-choice { margin: 6px 0 0; font-size: .85rem; color: #344052; line-height: 1.4; }
.mb-link {
  display: inline-flex; align-items: center; gap: 5px; margin-top: auto; padding-top: 10px;
  font: 700 .88rem var(--font-head); color: var(--red); text-decoration: none;
}
.mb-link:hover { text-decoration: underline; }
.mb-link .icon { width: 16px; height: 16px; }

.mb-explain { margin-top: 8px; }
.mb-explain .steps { margin-bottom: 28px; }
.mb-explain .steps h3 { font-size: 1.05rem; }
.mb-explain .steps p { font-size: .98rem; }
.mb-eagle-note {
  max-width: 860px; padding: 20px 22px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff;
}
.mb-eagle-note h3 { margin-bottom: .4em; }
.mb-eagle-note p:last-child { margin-bottom: 0; }
[data-show-until][hidden] { display: none; }

/* ---------- Eagle Scouts ---------- */

.eagle-intro { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 32px 48px; align-items: start; margin-bottom: 44px; }
.eagle-reqs { padding: 22px 24px; border-radius: var(--radius); background: var(--cream); border: 1px solid var(--line); }
.eagle-reqs h2 { font-size: 1.15rem; margin-bottom: .6em; }
.eagle-reqs ul { margin: 0; padding-left: 1.2em; }
.eagle-reqs li { margin-bottom: .4em; }
.eagle-reqs li::marker { color: var(--unit); }
.eagle-reqs p { margin: 12px 0 0; font-size: .92rem; color: var(--muted); }

.eagle-summary {
  display: flex; align-items: center; gap: 12px; margin: 0 0 20px;
  font: 800 1.2rem var(--font-head); color: var(--navy-deep);
}
.eagle-summary .icon { width: 28px; height: 28px; color: var(--unit); }
.eagle-grid {
  list-style: none; margin: 0 0 32px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
}
.eagle-card {
  display: flex; gap: 16px; align-items: flex-start; padding: 18px 20px;
  border-radius: 12px; background: var(--cream); border-left: 4px solid var(--unit);
}
.eagle-photo {
  flex: none; display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%;
  overflow: hidden; background: var(--unit); color: var(--unit-ink);
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0, 26, 56, .15);
  font: 800 1.5rem var(--font-head);
}
.eagle-photo img { width: 100%; height: 100%; object-fit: cover; }
.eagle-body { min-width: 0; }
.eagle-card h3 { margin: 2px 0 2px; font-size: 1.15rem; color: var(--navy-deep); overflow-wrap: anywhere; }
.eagle-date { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-weight: 600; font-size: .95rem; }
.eagle-date .icon { width: 17px; height: 17px; color: var(--unit); }
.eagle-project { margin: 10px 0 0; font-size: .97rem; line-height: 1.45; }
.eagle-project span {
  display: block; font: 700 .72rem var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.eagle-note { margin: 8px 0 0; font-size: .93rem; color: #344052; font-style: italic; }

/* ---------- Troop gear ---------- */

.gear-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 24px; }
.gear-table-wrap { margin: 0 0 32px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.gear-table { width: 100%; border-collapse: collapse; font-size: .98rem; }
.gear-table thead th {
  padding: 12px 14px; text-align: left; background: var(--cream); border-bottom: 1px solid var(--line);
  font: 700 .76rem var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.gear-table td, .gear-table tbody th { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; text-align: left; }
.gear-table tbody tr:first-child > * { border-top: 0; }
.gear-table tr[hidden] { display: none; }
.gear-table .gear-name { font-family: var(--font-head); font-weight: 700; color: var(--navy-deep); font-size: 1rem; }
.gear-table .gear-qty { text-align: center; font-weight: 700; }
.gear-table th.gear-qty { text-align: center; }
.gear-table .gear-notes { color: #344052; font-size: .93rem; }
.gear-table .gear-req { text-align: right; white-space: nowrap; }
.gear-cond {
  display: inline-block; justify-self: start; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700;
  background: #eef1f4; color: #3c4654;
}
.gear-cond.is-good { background: #e3f1e0; color: #2f5d2b; }
.gear-cond.is-fair { background: #fbf0d4; color: #7a5800; }
.gear-cond.is-bad { background: #fbe3e5; color: #9b1424; }

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
  .eagle-intro { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .gear-table-wrap { border: 0; border-radius: 0; overflow: visible; background: none; }
  .gear-table, .gear-table tbody, .gear-table tr, .gear-table td, .gear-table tbody th { display: block; width: 100%; }
  .gear-table thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .gear-table tr {
    margin: 0 0 12px; padding: 14px 16px; border: 1px solid var(--line); border-left: 4px solid var(--unit);
    border-radius: 12px; background: #fff;
  }
  .gear-table td { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; padding: 4px 0; border: 0; text-align: left; }
  .gear-table td::before { content: attr(data-label); font: 700 .74rem/1.9 var(--font-head); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .gear-table tbody th.gear-name { padding: 0 0 6px; border: 0; font-size: 1.08rem; }
  .gear-table td.gear-req::before { content: none; }
  .gear-table .gear-qty { text-align: left; }
  .gear-table td:empty, .gear-table td.is-empty { display: none; }
  .gear-table td.gear-req { display: block; padding-top: 10px; }
  .gear-table td.gear-req .btn { width: 100%; }
}

@media (max-width: 600px) {
  .tt-controls { padding: 16px; gap: 12px; }
  .tt-callout { padding: 16px 18px; }
  /* chips scroll sideways inside their own row instead of stacking up */
  .tt-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 8px; scrollbar-width: thin; }
  .mb-grid { grid-template-columns: 1fr; }
  .eagle-grid { grid-template-columns: 1fr; }
  .eagle-card { padding: 16px; gap: 14px; }
  .eagle-photo { width: 68px; height: 68px; font-size: 1.25rem; }
  .tt-empty { padding: 26px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .tt-switch input, .tt-switch input::before, .tt-chips button, .mb-card { transition: none; }
}

@media print {
  .tt-controls, .tt-clear, .gear-req, .gear-actions, .mb-link .icon { display: none !important; }
  .mb-card, .eagle-card, .gear-table tr { break-inside: avoid; box-shadow: none; }
}
