/* Packing Cubes — functional, neutral UI.
   Local Atkinson Hyperlegible (same fonts the rest of the site ships),
   one green accent, plain surfaces. Legacy token names (--gold, --brown, …)
   are kept as aliases so builder.css and inline styles keep working. */

@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* semantic tokens */
  --ink: #23282d;
  --muted: #5b636b;
  --faint: #8a929a;
  --bg: #f3f4f6;
  --card: #ffffff;
  --border-c: #d9dde1;
  --accent: #2f6b4f;
  --accent-strong: #275a42;
  --accent-soft: #e3efe8;
  --info: #3d6c96;
  --info-soft: #e3ecf4;
  --danger: #b2452f;
  --danger-soft: #f4e4df;
  --chip: #eaedef;

  /* legacy aliases (builder.css + older markup) */
  --cream: var(--bg);
  --gold: var(--accent);
  --gold-soft: var(--accent-soft);
  --green: var(--accent);
  --green-bright: var(--accent);
  --purple: var(--muted);
  --purple-soft: var(--chip);
  --pink: var(--danger);
  --pink-soft: var(--danger-soft);
  --blue: var(--info);
  --blue-soft: var(--info-soft);
  --brown: var(--muted);
  --grey: var(--faint);
  --grey-soft: var(--chip);

  --outline: 1px solid var(--border-c);
  --outline-strong: 1px solid var(--ink);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(35, 40, 45, 0.05), 0 3px 8px rgba(35, 40, 45, 0.05);
  --shadow-sm: 0 1px 2px rgba(35, 40, 45, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

.pc-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.pc-body {
  font-family: 'Atkinson Hyperlegible', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
}

/* Nav */
.pc-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 6px;
  column-gap: 12px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: var(--outline);
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: max(10px, env(safe-area-inset-top));
}

.pc-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.pc-nav-logo {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--card);
  background: var(--ink);
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Installed to a home screen: the app is the site, drop the site pill. */
html.pc-standalone .pc-nav-logo { display: none; }

.pc-nav-section {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}

.pc-nav-section span {
  font-weight: 700;
  font-size: 0.95rem;
}

.pc-nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.pc-nav-links a {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
  padding: 4px 0;
}

.pc-nav-links a:hover { color: var(--ink); }

@media (max-width: 480px) {
  .pc-nav { padding-left: 12px; padding-right: 12px; }
  .pc-nav-links { gap: 8px 12px; }
}

/* Buttons */
.pc-btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border: var(--outline);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  background: var(--card);
  color: var(--ink);
  transition: background 0.12s ease, border-color 0.12s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pc-btn:hover { background: var(--chip); border-color: var(--faint); }
.pc-btn:active { background: var(--chip); }
.pc-btn:disabled { opacity: 0.45; cursor: default; }

.pc-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pc-btn.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.pc-btn.green {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pc-btn.green:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.pc-btn.sm {
  font-size: 0.78rem;
  padding: 5px 10px;
}

/* Focus */
.pc-btn:focus-visible,
.pc-input:focus-visible,
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 1px;
}

/* Cards (cube.html detail page) */
.pc-card {
  background: var(--card);
  border: var(--outline);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.pc-card h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 6px;
}

.pc-card p.blurb {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.pc-card .pc-meta {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 16px;
}

.pc-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.pc-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.pc-card .pc-tags { justify-content: center; }

.pc-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--chip);
  border-radius: 5px;
  padding: 2px 8px;
}

/* Checklist base (shared by app + cube.html) */
.pc-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
}

.pc-checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--chip);
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--ink);
}

.pc-checklist li:last-child { border-bottom: none; }

.pc-checklist input[type="checkbox"] {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.pc-checklist li.packed .pc-item-label {
  color: var(--faint);
  text-decoration: line-through;
}

/* Inputs */
.pc-input,
.b-mini-input,
.pc-search-input,
.b-field input[type="text"],
.b-field input[type="number"],
.b-field input[type="date"],
.b-field select,
.b-field textarea {
  font: inherit;
  font-size: 0.85rem;
  padding: 7px 10px;
  border: var(--outline);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  width: 100%;
}

.pc-input.sm { padding: 6px 10px; font-size: 0.8rem; }
.pc-input.grow { flex: 1; min-width: 120px; }

.pc-input:focus,
.b-field input:focus,
.b-field textarea:focus,
.b-mini-input:focus,
.pc-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* iOS zooms the page when a focused field is under 16px — never let that
   happen on touch devices. */
@media (pointer: coarse) {
  .pc-input,
  .b-mini-input,
  .pc-search-input,
  .b-field input[type="text"],
  .b-field input[type="number"],
  .b-field input[type="date"],
  .b-field select,
  .b-field textarea,
  .pc-list-controls select,
  .pc-item-cube-select,
  .pc-auth input {
    font-size: 16px;
  }
}

/* Form scaffolding shared with the builder */
.b-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

@media (max-width: 480px) {
  .b-field-row { grid-template-columns: 1fr; }
}

.b-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.b-field label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.b-item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  background: var(--card);
  border: var(--outline);
  border-radius: var(--radius-sm);
  padding: 5px 6px;
  margin-bottom: 4px;
}

.b-remove-btn {
  border: var(--outline);
  background: var(--card);
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-weight: 700;
}

.b-remove-btn:hover { background: var(--danger-soft); border-color: var(--danger); }
.b-remove-btn:disabled { opacity: 0.35; cursor: default; }

.b-add-row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  border: var(--outline);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: var(--card);
  color: var(--ink);
  width: 100%;
}

.b-add-row-btn:hover { background: var(--chip); border-color: var(--faint); }

.pc-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 10px 0 6px;
}

.pc-toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.pc-toggle-chip input { accent-color: var(--accent); cursor: pointer; }
.pc-toggle-chip input:disabled { cursor: default; }

.pc-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px;
}

.hidden { display: none !important; }

/* ── Sign-in gate (inline form; used on the app, builder, and cube pages) ── */
.pc-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 130px);
  padding: 24px 16px 48px;
}

.pc-gate-card {
  background: var(--card);
  border: var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px 26px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.pc-gate-art {
  display: block;
  margin: 0 auto 14px;
  max-width: 60%;
  height: auto;
}

.pc-gate-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
}

.pc-gate-copy {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 20px;
}

.pc-gate-error {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 0 0 16px;
  text-align: left;
}

.pc-gate-btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.92rem;
}

.pc-gate-small {
  font-size: 0.76rem;
  color: var(--faint);
  margin: 12px 0 0;
  line-height: 1.45;
}

.pc-gate-small a { color: var(--ink); }

.pc-auth { text-align: left; }

.pc-auth-tabs {
  display: flex;
  border: var(--outline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--chip);
  margin: 0 0 16px;
}

.pc-auth-tab {
  flex: 1;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  min-height: 44px;
}

.pc-auth-tab.is-active {
  background: var(--ink);
  color: var(--card);
}

.pc-auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pc-auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.pc-auth-field span {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.pc-auth-error {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--danger);
  margin: 10px 0 0;
}

.pc-auth .pc-gate-btn { margin-top: 4px; }

/* Toast */
.pc-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 300;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  max-width: min(92vw, 480px);
  text-align: center;
}

.pc-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.pc-boot-message {
  padding: 40px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

@media (max-width: 480px) {
  .pc-card { padding: 16px; }
  .pc-card h1 { font-size: 1.2rem; }
}
