/* ============================================================
   PickAProject — style.css
   Beach-inspired, mobile-first PWA
   ============================================================ */

:root {
  --clr-ocean:        #1a6b8a;
  --clr-ocean-dark:   #124d65;
  --clr-ocean-light:  #2596be;
  --clr-sky:          #e8f4f8;
  --clr-gold:         #f0a500;
  --clr-gold-dark:    #c88800;
  --clr-coral:        #e84545;
  --clr-coral-dark:   #c73333;
  --clr-white:        #ffffff;
  --clr-text:         #1d2b3a;
  --clr-text-muted:   #6a7d8e;
  --clr-border:       #dde5ec;
  --clr-surface:      #ffffff;
  --clr-bg:           #f0f6fa;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.10);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.18);

  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --radius-pill: 9999px;

  --fab-size:    56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --t-fast: 150ms ease;
  --t-base: 220ms ease;
  --t-spring: 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  overflow: hidden;
  height: 100dvh;
}
ul  { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input  { font: inherit; }

/* ── Views ───────────────────────────────────── */
.view {
  display: none;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
.view.active { display: flex; }

/* ── Header ──────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  background: var(--clr-ocean);
  color: var(--clr-white);
  padding: 14px 16px 14px;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* Condensed header for compact display */
.app-header.condensed {
  padding: 10px 12px;
}
.app-header.condensed .app-title {
  font-size: 1.1rem;
  margin-bottom: 0;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-token {
  background: rgba(255,255,255,0.12);
  color: var(--clr-white);
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
}
.app-version {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  margin-left: 8px;
  opacity: 0.85;
  vertical-align: middle;
}

.app-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--clr-white);
  margin-bottom: 12px;
}

/* Category view header */
.category-header { padding: 10px 12px 14px; }

.category-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.category-view-title {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--clr-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.15);
  color: var(--clr-white);
  font-size: 1.05rem;
  transition: background var(--t-fast);
}
.btn-nav:hover  { background: rgba(255,255,255,0.28); }
.btn-nav:active { background: rgba(255,255,255,0.38); }

/* ── Main content ────────────────────────────── */
.view-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px calc(76px + var(--safe-bottom));
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--clr-text-muted);
  margin-bottom: 10px;
}

/* ── Card list ───────────────────────────────── */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Category card ───────────────────────────── */
.category-card {
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: slide-in 0.22s ease both;
}

.cat-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--t-fast);
  outline: none;
}
.cat-main:hover  { background: var(--clr-sky); }
.cat-main:active { background: #d8edf5; }
.cat-main:focus-visible {
  box-shadow: inset 0 0 0 2px var(--clr-ocean);
}

.cat-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--clr-ocean-light), var(--clr-ocean));
  color: var(--clr-white);
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cat-info {
  flex: 1;
  min-width: 0;
}

.cat-name {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: var(--clr-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-count {
  display: block;
  font-size: 0.78rem;
  color: var(--clr-text-muted);
  margin-top: 2px;
}

.cat-chevron {
  font-size: 1.3rem;
  color: var(--clr-text-muted);
  flex-shrink: 0;
}

.cat-actions {
  display: flex;
  border-top: 1px solid var(--clr-border);
}

.cat-act-btn {
  flex: 1;
  padding: 9px 8px;
  font-size: 0.80rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.cat-act-btn:first-child { border-right: 1px solid var(--clr-border); }
.cat-rename:hover { background: var(--clr-sky); color: var(--clr-ocean); }
.cat-delete:hover { background: #fff0f0; color: var(--clr-coral); }

/* ── Item card ───────────────────────────────── */
.item-card {
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  animation: slide-in 0.2s ease both;
  transition: box-shadow var(--t-base);
}
.item-card:hover { box-shadow: var(--shadow-sm); }

.item-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--clr-ocean-light);
  flex-shrink: 0;
}

.item-text {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.item-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.item-act-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
  color: var(--clr-text-muted);
}
.item-edit:hover   { background: var(--clr-sky); }
.item-delete:hover { background: #fff0f0; }

/* ── Empty state ─────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 24px;
  text-align: center;
  gap: 6px;
}
.empty-state.hidden { display: none; }
.empty-icon  { font-size: 3rem; margin-bottom: 8px; }
.empty-title { font-weight: 700; font-size: 1rem; }
.empty-sub   { font-size: 0.85rem; color: var(--clr-text-muted); }

/* ── FAB ─────────────────────────────────────── */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: var(--radius-pill);
  background: var(--clr-ocean);
  color: var(--clr-white);
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(26,107,138,0.45);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--t-spring), box-shadow var(--t-fast);
}
.fab:hover  { transform: scale(1.08); box-shadow: 0 6px 22px rgba(26,107,138,0.55); }
.fab:active { transform: scale(0.94); }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  user-select: none;
}
.btn:active { transform: scale(0.97); }

.btn-random {
  width: 100%;
  padding: 13px 20px;
  background: var(--clr-gold);
  color: var(--clr-text);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.98rem;
  box-shadow: 0 2px 8px rgba(240,165,0,0.30);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.btn-random:hover  { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(240,165,0,0.45); }
.btn-random:active { transform: scale(0.98); }

.btn-primary {
  background: var(--clr-ocean);
  color: var(--clr-white);
}
.btn-primary:hover { background: var(--clr-ocean-dark); }

.btn-gold {
  background: var(--clr-gold);
  color: var(--clr-text);
  font-weight: 700;
}
.btn-gold:hover { background: var(--clr-gold-dark); }

.btn-ghost {
  background: transparent;
  color: var(--clr-text-muted);
  padding: 11px 18px;
}
.btn-ghost:hover { background: var(--clr-bg); }

.btn-ghost-light {
  background: rgba(255,255,255,0.15);
  color: var(--clr-white);
  border: 2px solid rgba(255,255,255,0.35);
  padding: 9px 18px;
}
.btn-ghost-light:hover { background: rgba(255,255,255,0.25); }

.btn-danger {
  background: var(--clr-coral);
  color: var(--clr-white);
}
.btn-danger:hover { background: var(--clr-coral-dark); }

/* ── Modals ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 35, 50, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--clr-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 370px;
  padding: 26px 22px;
  transform: translateY(22px) scale(0.96);
  transition: transform var(--t-spring);
}
.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Pick card */
.pick-card {
  text-align: center;
  background: linear-gradient(150deg, var(--clr-ocean-light) 0%, var(--clr-ocean-dark) 100%);
  color: var(--clr-white);
  padding: 32px 24px 24px;
}

.pick-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.75;
  margin-bottom: 18px;
}

.pick-result {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
  min-height: 2.4rem;
  margin-bottom: 28px;
}

.pick-result.popin {
  animation: popin 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.pick-card .modal-actions { justify-content: center; gap: 10px; }

/* Dialog card */
.dialog-card { padding: 22px 20px; }

.dialog-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--clr-text);
  margin-bottom: 14px;
}

.dialog-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--clr-text);
  background: var(--clr-bg);
  outline: none;
  margin-bottom: 16px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.dialog-input:focus {
  border-color: var(--clr-ocean);
  box-shadow: 0 0 0 3px rgba(26,107,138,0.14);
}
.dialog-input.shake {
  animation: shake 0.32s ease;
  border-color: var(--clr-coral);
}

.confirm-message {
  font-size: 0.88rem;
  color: var(--clr-text-muted);
  line-height: 1.55;
  margin-bottom: 18px;
}

/* ── Helpers ─────────────────────────────────── */
.hidden { display: none !important; }

/* Update toast */
.update-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(90px + var(--safe-bottom));
  background: rgba(26,107,138,0.95);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  font-weight: 700;
  z-index: 60;
  font-size: 0.95rem;
}

/* ── Animations ──────────────────────────────── */
@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popin {
  0%   { opacity: 0; transform: scale(0.4) rotate(-4deg); }
  60%  { transform: scale(1.08) rotate(1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-7px); }
  75%       { transform: translateX(7px); }
}

/* ── Responsive ──────────────────────────────── */
@media (min-width: 540px) {
  .app-header  { padding: 18px 20px 16px; }
  .app-title   { font-size: 1.75rem; }
  .view-main   { padding: 18px 20px calc(84px + var(--safe-bottom)); }
}

@media (min-width: 768px) {
  /* Center narrow column on wide screens */
  body { display: flex; align-items: flex-start; justify-content: center; overflow: auto; }
  .view.active {
    height: 100dvh;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 0 60px rgba(0,0,0,0.18);
  }
}

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: var(--radius-pill); }
