/* polish: packing-page — see AGENTS.md (v77 polish pass).
 * Linked only from packing.html (which does NOT load trip.css; tokens come from its inline <style>).
 * Spacing scale 4/8/12/16/20/24/32. Buttons: md 40px / sm 32px / icon 40px.
 */

:root {
  --pk-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --pk-transition:
    background-color 140ms var(--pk-ease),
    border-color 140ms var(--pk-ease),
    color 140ms var(--pk-ease),
    box-shadow 140ms var(--pk-ease),
    transform 140ms var(--pk-ease);
}

/* ---------- Top nav (links back to index) ---------- */
.sticky-nav-wrapper { padding: 8px 0; margin-bottom: 20px; }
.view-tabs { gap: 8px; align-items: center; padding: 0 0 2px; }
.tab-btn {
  box-sizing: border-box;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  font-family: inherit;
  line-height: 1.2;
  transition: var(--pk-transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.view-tabs .tab-btn { flex-shrink: 0; }
.tab-btn:active { transform: translateY(1px); }
.tab-btn:focus-visible,
.btn-share:focus-visible,
.packing-chip:focus-visible,
.packing-item-del-btn:focus-visible,
.custom-item-input:focus-visible,
.custom-item-select:focus-visible {
  outline: 2px solid var(--shu-red);
  outline-offset: 2px;
}
@media (max-width: 768px) {
  .sticky-nav-wrapper { padding: 8px 0; }
  .view-tabs { gap: 8px; padding: 0 0 2px; }
  .tab-btn { min-height: 40px; padding: 0 12px; font-size: 0.82rem; }
}

/* ---------- md action buttons ---------- */
.btn-share {
  box-sizing: border-box;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px !important;   /* beats inline padding on the toolbar buttons */
  border-radius: var(--radius-sm);   /* 8px in this file */
  font-family: inherit;
  font-size: 0.86rem !important;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: var(--pk-transition);
  touch-action: manipulation;
}
.btn-share:active { transform: translateY(1px); }
:root[data-theme="dark"] .btn-share:hover { background: #1F365F !important; border-color: var(--ai-indigo) !important; }

/* ---------- Header card ---------- */
#packingView .packing-header-card { padding: 24px 20px 20px; }
#packingView .packing-header-card > div:first-child {
  gap: 16px !important;
  margin-bottom: 0 !important;
  align-items: flex-start !important;
}
#packingView .packing-header-card > div:first-child h2 { line-height: 1.3; }
#packingView .packing-header-card > div:first-child p { margin-top: 8px !important; line-height: 1.5; }
#packingView .packing-header-card > div:first-child > div:last-child { gap: 8px !important; }
#packingView .packing-progress-section { margin: 20px 0 16px; padding: 16px 20px; }
#packingView .packing-progress-info { gap: 12px; margin-bottom: 12px; }
#packingView .packing-toolbar { margin-top: 0; gap: 8px; }
#packingView .packing-toolbar > span { line-height: 1.5; }

/* ---------- Fold-away reference cards ---------- */
#packingView .packing-fold-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0 16px;
}
#packingView .packing-fold { margin: 0; }
#packingView .packing-fold > summary { gap: 12px; padding: 12px 20px; line-height: 1.4; }
#packingView .packing-fold > summary > span:first-child { min-width: 0; }
#packingView .packing-fold > summary::after { margin: -4px 0 0 0; }
#packingView .packing-fold[open] > summary::after { margin-top: 4px; }
#packingView .packing-fold-body { padding: 0 20px 20px; }
#packingView .packing-fold-body > div { margin: 0 !important; }

#packingView .packing-fold-body > div[style*="padding: 18px 20px"] { padding: 16px !important; }
#packingView .packing-fold-body > div > div[style*="line-height: 1.65"] { margin-bottom: 0 !important; }
#packingView .packing-fold-body > div > div[style*="line-height: 1.65"] > div[style*="margin-bottom"] { margin-bottom: 8px !important; }
#packingView .packing-fold-body > div > div[style*="grid-template-columns"] {
  gap: 12px !important;
  margin-top: 12px !important;
  padding-top: 12px !important;
}
#packingView .packing-fold-body div[style*="grid-template-columns"] > div[style*="padding:10px"] {
  padding: 12px !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left !important;
}
#packingView .packing-fold-body div[style*="grid-template-columns"] > div[style*="padding:10px"] > * { margin: 0 !important; }
#packingView .packing-fold-body div[style*="grid-template-columns"] > div[style*="padding:10px"] > div:first-child { gap: 8px; line-height: 1.4; }
#packingView .packing-fold-body div[style*="grid-template-columns"] > div[style*="padding:10px"] > div:first-child .cat-badge { flex-shrink: 0; white-space: nowrap; }
#packingView .packing-fold-body div[style*="grid-template-columns"] img { display: block; }

#packingView .packing-fold-body > div[style*="grid-template-columns"] { gap: 12px !important; }
#packingView .packing-fold-body > div[style*="grid-template-columns"] > div { padding: 16px !important; }
#packingView .packing-fold-body > div[style*="grid-template-columns"] > div > div:first-child {
  margin-bottom: 12px !important;
  gap: 8px !important;
  line-height: 1.4;
}
#packingView .packing-fold-body > div[style*="grid-template-columns"] ul { margin: 0; padding-left: 20px !important; }
#packingView .packing-fold-body > div[style*="grid-template-columns"] li + li { margin-top: 4px; }

#packingView .packing-fold-body > div[style*="display: flex"] { padding: 12px 16px !important; gap: 12px !important; }

/* ---------- Add custom item ---------- */
#packingView .packing-add-dock { margin: 0 0 16px; }
#packingView .custom-item-bar { margin: 0; padding: 16px; gap: 8px; align-items: center; flex-wrap: wrap; }
#packingView .custom-item-bar > span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  white-space: nowrap;
}
#packingView .custom-item-input,
#packingView .custom-item-select {
  box-sizing: border-box;
  height: 40px;
  margin: 0;
  border-radius: var(--radius-sm);
  font-family: inherit;
  line-height: 1.2;
  color: var(--sumi-dark);
  transition: border-color 140ms var(--pk-ease), box-shadow 140ms var(--pk-ease);
}
#packingView .custom-item-input { padding: 0 12px; flex: 1 1 220px; }
#packingView .custom-item-select { padding: 0 32px 0 12px; flex: 0 0 auto; }
/* the add button reuses .tab-btn; make it a primary md button in both themes */
#packingView .custom-item-bar .tab-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px !important;
  margin: 0;
  border-radius: var(--radius-sm);
  border-color: var(--ai-indigo);
  font-size: 0.86rem;
  font-weight: 600;
}
#packingView .custom-item-bar .tab-btn:hover { box-shadow: 0 2px 8px rgba(28, 46, 74, 0.22); border-color: var(--ai-indigo); }
:root[data-theme="dark"] #packingView .custom-item-bar .tab-btn {
  background: #2C4778 !important;
  border-color: #4A6FA5 !important;
  color: #F2F7FF !important;
}
:root[data-theme="dark"] #packingView .custom-item-bar .tab-btn:hover { background: #355691 !important; }

@media (max-width: 768px) {
  #packingView .custom-item-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
  }
  #packingView .custom-item-bar > span,
  #packingView .custom-item-input { grid-column: 1 / -1; }
  #packingView .custom-item-bar > span { min-height: 0; }
  #packingView .custom-item-input,
  #packingView .custom-item-select { width: 100%; min-width: 0; font-size: 16px; }
  #packingView .custom-item-bar .tab-btn { width: 100%; }
}

/* ---------- Filter chips (sm) ---------- */
#packingView .packing-filter-chips { gap: 8px; margin: 0 0 20px; padding: 0; }
#packingView .packing-chip {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  margin: 0;
  padding: 0 12px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: var(--pk-transition);
  touch-action: manipulation;
}
#packingView .packing-chip:active { transform: translateY(1px); }
:root[data-theme="dark"] #packingView .packing-chip { background: var(--washi-subtle); border-color: var(--border-color); color: var(--sumi-muted); }
:root[data-theme="dark"] #packingView .packing-chip:hover { color: var(--ai-indigo); border-color: var(--ai-indigo); }
:root[data-theme="dark"] #packingView .packing-chip.active { background: #2C4778; border-color: #4A6FA5; color: #F2F7FF; }
@media (max-width: 768px) {
  #packingView .packing-chip { min-height: 32px; padding: 0 12px; }
}

/* ---------- Category cards ---------- */
#packingView .packing-category-section { padding: 20px; margin-bottom: 16px; }
#packingView .packing-category-title-bar { gap: 12px; margin-bottom: 12px; padding-bottom: 12px; }
#packingView .packing-category-title { line-height: 1.3; min-width: 0; }
#packingView .packing-category-stat {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 12px;
  line-height: 1.2;
  white-space: nowrap;
}
#packingView .packing-items-grid { gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }

/* ---------- Checklist rows ---------- */
#packingView .packing-item-card {
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  transition: background-color 140ms var(--pk-ease), border-color 140ms var(--pk-ease), box-shadow 140ms var(--pk-ease), transform 140ms var(--pk-ease), opacity 140ms var(--pk-ease);
}
#packingView .packing-item-card:hover { transform: none; }
#packingView .packing-item-card:active { transform: translateY(1px); }
#packingView .packing-checkbox { box-sizing: border-box; margin-top: 0; transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease; }
#packingView .packing-item-header { align-items: flex-start; gap: 8px; margin-bottom: 4px; }
#packingView .packing-item-title { line-height: 20px; }
#packingView .packing-item-badge {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  line-height: 1;
}
#packingView .packing-item-desc { line-height: 1.5; }
#packingView .packing-item-content > div:not([class]) { margin-top: 12px !important; gap: 8px !important; }
/* in-item link pills (sm); allow wrapping so long order numbers never overflow the page */
#packingView .packing-item-content > div:not([class]) > a.tab-btn {
  min-height: 32px;
  padding: 6px 12px !important;
  max-width: 100%;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
}

#packingView .packing-item-del-btn {
  box-sizing: border-box;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  margin: -10px -6px -10px 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-size: 1rem;
  line-height: 1;
  transition: background-color 140ms ease, opacity 140ms ease, transform 140ms ease;
}
#packingView .packing-item-del-btn:hover { background: var(--shu-red-light); }
#packingView .packing-item-del-btn:active { transform: translateY(1px); }
#packingView .packing-item-del-btn:focus-visible { opacity: 1; }
@media (hover: none) {
  #packingView .packing-item-del-btn { opacity: 0.75; }
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  #packingView .packing-header-card { padding: 20px 16px 16px; }
  #packingView .packing-header-card > div:first-child > div:last-child { width: 100%; }
  #packingView .packing-header-card > div:first-child > div:last-child > .btn-share { flex: 1 1 auto; min-width: 0; padding: 0 12px !important; white-space: normal; text-align: center; }
  #packingView .packing-progress-section { padding: 16px; }
  #packingView .packing-fold > summary { padding: 12px 16px; }
  #packingView .packing-fold-body { padding: 0 16px 16px; }
  #packingView .packing-fold-body > div[style*="padding: 18px 20px"] { padding: 12px !important; }
  #packingView .packing-fold-body div[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  #packingView .packing-category-section { padding: 16px; }
}
@media (max-width: 768px) {
  /* toolbar stacks in this file at ≤768px: keep the two buttons side by side, hint below */
  #packingView .packing-toolbar { flex-direction: row !important; flex-wrap: wrap; align-items: center !important; }
  #packingView .packing-toolbar > .btn-share { flex: 1 1 0; min-width: 0; }
  #packingView .packing-toolbar > span { flex-basis: 100%; margin-left: 0 !important; }
}

/* ==== Contrast (v79): flagged by tools/audit_contrast.py ==== */
:root { --sumi-muted: #5E584E; --sumi-faint: #6E685E; --yamabuki-gold: #8A5B12; }
:root[data-theme="dark"] { --sumi-muted: #B8B0A2; --sumi-faint: #A8A092; }
/* The hero tags were tuned for a dark photo; inside the light header card they vanished */
:root:not([data-theme="dark"]) .editorial-view-header .hanko-tag:not(.primary),
:root:not([data-theme="dark"]) .packing-view-header .hanko-tag:not(.primary),
:root:not([data-theme="dark"]) main .hanko-tag:not(.primary) { color: #9B2C28; background: #FBEDEC; border-color: rgba(199, 62, 58, 0.35); }
:root[data-theme="dark"] .hanko-tag.primary { background: #A8322B; border-color: #A8322B; color: #FFFFFF; }
:root[data-theme="dark"] .hanko-tag:not(.primary) { color: #FFC9C5; }
:root[data-theme="dark"] .packing-item-badge { color: #F8A39B !important; }
/* Category titles are coloured inline from data meant for a light card */
:root[data-theme="dark"] .packing-category-title,
:root[data-theme="dark"] .packing-category-title > span { color: #F3EFE6 !important; }
:root[data-theme="dark"] .tab-btn.active { color: #0A1428 !important; }
:root[data-theme="dark"] .custom-item-input::placeholder { color: #A9B8D2; opacity: 1; }
:root:not([data-theme="dark"]) a.tab-btn[href*="trip.com"] { color: #1557B0 !important; }
footer p { color: var(--sumi-muted) !important; }
:root:not([data-theme="dark"]) .packing-category-title[style*="#C28E36"],
:root:not([data-theme="dark"]) .packing-category-title[style*="#c28e36"] { color: #8A5B12 !important; }
:root:not([data-theme="dark"]) a.tab-btn { color: #1557B0 !important; }
.container > footer p, footer p { opacity: 1 !important; color: #5E584E !important; }
:root[data-theme="dark"] .container > footer p, :root[data-theme="dark"] footer p { color: #B8B0A2 !important; }
