/* ============================================================
   Spindle — Diner Countertop with Receipt Spike
   Warm wooden diner counter, brass rod tab bar, paper slips.
   ============================================================ */

:root {
  --paper: #fdf5e6;
  --paper-dark: #f6ecd4;
  --primary: #c0392b;      /* coral / red-brown */
  --accent: #2e8b57;       /* sea green, minor accents only */
  --olive: #6b7f3a;        /* Done stripe */
  --slate: #6b7280;        /* Archived stripe */
  --ink: #3b2a1f;          /* dark brown ink */
  --brass: #b98a3a;
  --brass-dark: #8a6424;
  --wood-1: #b57a3e;
  --wood-2: #9a5f2f;
  --wood-3: #c98f52;
  --wood-4: #a86b36;
  --shadow: rgba(59, 42, 31, 0.28);
}

* { box-sizing: border-box; }

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

body {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.16) 0%, transparent 38%),
    radial-gradient(circle at 78% 74%, rgba(255,255,255,0.10) 0%, transparent 42%),
    repeating-linear-gradient(45deg, var(--wood-1) 0, var(--wood-1) 22px, var(--wood-3) 22px, var(--wood-3) 46px);
  background-color: var(--wood-2);
  min-height: 100%;
}

/* ============================================================
   Counter head
   ============================================================ */
.counter-head {
  text-align: center;
  padding: calc(20px + env(safe-area-inset-top)) 16px 8px;
}

.brand {
  margin: 0;
  font-size: 26px;
  letter-spacing: 2px;
  color: #fff6e6;
  text-shadow: 0 2px 4px rgba(59,42,31,0.45);
  font-family: 'Brush Script MT', 'Comic Sans MS', cursive;
  font-weight: normal;
}

.tagline {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #ffe9c9;
  font-style: italic;
  opacity: 0.9;
}

/* ============================================================
   Views
   ============================================================ */
.view {
  display: none;
  padding: 12px 14px calc(120px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
  animation: fade 0.25s ease;
}

.view.is-active { display: block; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ============================================================
   Counter cards (oversized receipt slips)
   ============================================================ */
.counters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 6px 0 18px;
}

.counter-card {
  position: relative;
  background: var(--paper);
  border-radius: 4px;
  padding: 18px 10px 14px;
  box-shadow: 0 6px 14px var(--shadow);
  text-align: center;
  --edge: 8px;
}
.counter-card::before,
.counter-card::after {
  content: "";
  position: absolute;
  left: -4px; right: -4px;
  height: 12px;
  background-image: repeating-linear-gradient(60deg, transparent 0 4px, var(--paper) 4px 9px);
}
.counter-card::before { top: -5px; }
.counter-card::after { bottom: -5px; }

.counter-card .ring {
  position: absolute;
  top: 8px; right: 12px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff, #c9c9c9 60%, #8a8a8a);
  box-shadow: inset 0 0 2px rgba(0,0,0,0.5);
}

.counter-card::selection, .counter-card *::selection { background: transparent; }

.counter-label {
  font-family: 'Brush Script MT', 'Comic Sans MS', cursive;
  font-size: 19px;
  color: #4a352a;
  margin-bottom: 2px;
}

.counter-num {
  font-size: 62px;
  font-weight: bold;
  line-height: 1;
  color: var(--primary);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.counter-stamp {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 1px 8px;
  border-radius: 2px;
  opacity: 0.85;
  transform: rotate(-4deg);
}

/* ============================================================
   Section labels (handwritten)
   ============================================================ */
.section-label {
  font-family: 'Brush Script MT', 'Comic Sans MS', cursive;
  font-weight: normal;
  font-size: 22px;
  margin: 18px 2px 10px;
  color: #fff6e6;
  text-shadow: 0 2px 3px rgba(59,42,31,0.5);
}

.hint {
  text-align: center;
  font-style: italic;
  color: #ffe9c9;
  font-size: 13px;
  margin-top: 16px;
}

/* ============================================================
   Search
   ============================================================ */
.search-wrap { margin: 4px 0 14px; }

.search {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: Georgia, serif;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(59,42,31,0.25);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(59,42,31,0.15);
}
.search::placeholder { color: #9c7f66; font-style: italic; }

/* ============================================================
   Slip list
   ============================================================ */
.slip-list { display: flex; flex-direction: column; gap: 14px; }

/* ============================================================
   Receipt slip card
   ============================================================ */
.slip {
  position: relative;
  background: var(--paper);
  border-radius: 3px;
  padding: 18px 14px 14px;
  box-shadow: 0 5px 12px var(--shadow);
  touch-action: pan-y;
  user-select: none;
  transition: transform 0.08s linear, opacity 0.2s ease;
  --edge: 7px;
}
.slip::before,
.slip::after {
  content: "";
  position: absolute;
  left: -5px; right: -5px;
  height: 11px;
  background-image: repeating-linear-gradient(58deg, transparent 0 4px, var(--paper) 4px 8px);
}
.slip::before { top: -5px; }
.slip::after { bottom: -5px; }

/* punched hole */
.slip .hole {
  position: absolute;
  top: 10px; left: 10px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff, #c9c9c9 58%, #9a9a9a);
  box-shadow: inset 0 0 3px rgba(0,0,0,0.45);
}

/* faint coffee ring stain */
.slip .coffee {
  position: absolute;
  right: -6px; bottom: 2px;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(161, 115, 79, 0.12);
  box-shadow: 0 0 0 4px rgba(161, 115, 79, 0.10), 0 0 0 1px rgba(161, 115, 79, 0.12);
  transform: rotate(15deg);
}

/* left status stripe */
.slip .stripe {
  position: absolute;
  top: 8px; left: 0; bottom: 8px;
  width: 5px;
  border-radius: 0 3px 3px 0;
}
.slip[data-status="Active"] .stripe { background: var(--primary); }
.slip[data-status="Done"] .stripe { background: var(--olive); }
.slip[data-status="Archived"] .stripe { background: var(--slate); }

.slip .client {
  font-size: 17px;
  font-weight: bold;
  color: var(--ink);
  padding-left: 20px;
}
.slip .project {
  font-size: 15px;
  font-style: italic;
  color: #6b4a32;
  margin: 4px 0 8px;
  padding-left: 20px;
}
.slip .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #8a6a50;
  padding-top: 6px;
  border-top: 1px dashed rgba(59,42,31,0.25);
}
.slip .status-chip {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
}
.slip[data-status="Active"] .status-chip { color: var(--primary); border: 1px solid var(--primary); }
.slip[data-status="Done"] .status-chip { color: var(--olive); border: 1px solid var(--olive); }
.slip[data-status="Archived"] .status-chip { color: var(--slate); border: 1px solid var(--slate); }

.slip .due {
  font-weight: bold;
}
.slip .due.overdue { color: var(--primary); }

/* swipe hint / action labels */
.swipe-action {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  align-items: center;
  font-family: 'Brush Script MT', cursive;
  font-size: 16px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.swipe-action.left-action { left: 14px; }
.swipe-action.right-action { right: 14px; }

/* empty state */
.empty {
  text-align: center;
  padding: 36px 20px;
  color: #ffe9c9;
}
.empty .spike-doodle { font-size: 46px; opacity: 0.9; display: block; margin-bottom: 10px; }
.empty .empty-title {
  font-family: 'Brush Script MT', cursive;
  font-size: 24px;
  margin: 0 0 6px;
}
.empty .empty-sub { font-style: italic; font-size: 14px; opacity: 0.85; }

/* ============================================================
   FAB
   ============================================================ */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff6e6;
  font-size: 34px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(59,42,31,0.4);
  cursor: pointer;
  z-index: 40;
}
.fab:active { transform: scale(0.95); }

/* ============================================================
   Bottom tab bar — brass rod with four spikes
   ============================================================ */
.tabbar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--brass) 0%, var(--brass) 12%, var(--brass-dark) 100%);
  border-top: 3px solid #cfa94f;
  box-shadow: 0 -6px 18px rgba(59,42,31,0.4);
  z-index: 50;
}

.tab {
  position: relative;
  flex: 1;
  background: none;
  border: none;
  padding: 0 4px;
  text-align: center;
  cursor: pointer;
}

/* spike shape */
.tab .spike {
  display: block;
  width: 44px; height: 44px;
  margin: 0 auto;
  background: linear-gradient(180deg, #7a5a2a, #5c4420);
  border-radius: 50% 50% 6px 6px;
  box-shadow: inset 0 -6px 8px rgba(0,0,0,0.35);
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.tab .spike::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -16px;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 18px solid #5c4420;
  transition: border-bottom-color 0.15s ease;
}

.tab-label {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #3a2a12;
  font-family: 'Brush Script MT', cursive;
  font-size: 13px;
}

/* active spike — colored, raised, slip impaled + shadow */
.tab.is-active .spike {
  transform: translateY(-12px) rotate(-2deg);
  box-shadow: 0 10px 14px rgba(20,12,4,0.55);
  animation: bob 2.6s ease-in-out infinite;
}
.tab.is-active[data-tab="counter"] .spike { background: var(--primary); }
.tab.is-active[data-tab="active"] .spike { background: #b3543f; }
.tab.is-active[data-tab="filled"] .spike { background: #c9a227; }
.tab.is-active[data-tab="archived"] .spike { background: #6a7280; }
.tab.is-active .spike::after { border-bottom-color: inherit; }
.tab.is-active .tab-label { color: #fff6e6; font-weight: bold; text-shadow: 0 1px 2px rgba(20,12,4,0.5); }

@keyframes bob { 0%,100% { transform: translateY(-12px) rotate(-2deg); } 50% { transform: translateY(-16px) rotate(-2deg); } }

/* little slip impaled on active spike */
.tab.is-active .spike::before {
  content: "";
  position: absolute;
  left: 6px; right: 6px; top: -10px;
  height: 14px;
  background: var(--paper);
  border-radius: 2px;
  opacity: 0.95;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ============================================================
   Sheet / form
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(59,42,31,0.55);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.overlay.hidden { display: none; }

.sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--paper);
  border-radius: 14px 14px 0 0;
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(59,42,31,0.45);
}
.sheet h2 {
  font-family: 'Brush Script MT', cursive;
  font-weight: normal;
  font-size: 28px;
  margin: 0 0 16px;
  color: var(--primary);
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-family: 'Brush Script MT', cursive;
  font-size: 18px;
  color: #6b4a32;
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  font-family: Georgia, serif;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(59,42,31,0.3);
  border-radius: 6px;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field .err { display: block; color: var(--primary); font-size: 12px; font-style: italic; margin-top: 3px; min-height: 14px; }

.row { display: flex; gap: 12px; margin-top: 8px; }
.btn {
  flex: 1;
  padding: 12px;
  font-size: 16px;
  font-family: Georgia, serif;
  border-radius: 8px;
  cursor: pointer;
  border: none;
}
.btn.solid { background: var(--primary); color: #fff6e6; }
.btn.ghost { background: transparent; border: 1px solid rgba(59,42,31,0.4); color: var(--ink); }

/* ============================================================
   Edit menu
   ============================================================ */
.menu {
  align-self: flex-end;
  width: 100%;
  max-width: 520px;
  background: var(--paper);
  border-radius: 14px 14px 0 0;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 15px 10px;
  font-size: 17px;
  font-family: Georgia, serif;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(59,42,31,0.12);
  cursor: pointer;
  color: var(--ink);
}
.menu button.danger { color: var(--primary); }
.menu button.restore-only { color: var(--accent); }
.menu .restore-only { display: none; }

/* ============================================================
   Utility
   ============================================================ */
body.no-scroll { overflow: hidden; }