/* Oxford — tiny helper companion (CRM first). Exact sprite 8×11 × 192×208. */
:root{
  --ox-fw:192; --ox-fh:208; --ox-cols:8; --ox-rows:11;
  --ox-size:72px;
  --ox-disp-h:calc(var(--ox-size) * var(--ox-fh) / var(--ox-fw));
  --ox-sheet-w:calc(var(--ox-size) * var(--ox-cols));
  --ox-sheet-h:calc(var(--ox-disp-h) * var(--ox-rows));
  --ox-cell-w:var(--ox-size);
  --ox-cell-h:var(--ox-disp-h);
  --ox-gear:36px;
  --ox-dock-gap:10px;
  /* Clear the dog and the settings button above him, not only the sprite. */
  --ox-pad:calc(var(--ox-disp-h) + var(--ox-gear) + var(--ox-dock-gap) + 20px + env(safe-area-inset-bottom, 0px));
  --ox-navy:#0B1F44;
  --ox-line:#E2E8F0;
  --ox-muted:#64748B;
}
/* Thin reserve only — puppy corner, not a control strip. */
html.ox-companion-on body{ padding-bottom:var(--ox-pad) !important; }
html.ox-companion-hidden body{ padding-bottom:0 !important; }
html.ox-companion-on.ox-has-phone-card body{
  padding-bottom:calc(var(--ox-pad) + 72px) !important;
}

.ox-root{
  position:fixed; z-index:70;
  right:16px; bottom:calc(14px + env(safe-area-inset-bottom, 0px));
  left:auto; width:auto; height:auto;
  display:flex; flex-direction:column; align-items:flex-end; gap:8px;
  pointer-events:none; font-family:inherit;
  background:transparent; border:0; padding:0;
  box-sizing:border-box;
}
.ox-root *{ box-sizing:border-box; }
.ox-root.ox-hidden{ display:none; }
.ox-root .ox-hit{ pointer-events:auto; }

/* Reminder: compact chip above the puppy — not a full-width dock. */
.ox-rail{
  position:relative; z-index:2;
  display:flex; flex-direction:column; align-items:flex-end; gap:6px;
  max-width:min(300px, calc(100vw - 24px));
}
.ox-card, .ox-bubble{
  background:#fff; border:1px solid var(--ox-line); border-radius:12px;
  padding:8px 10px; box-shadow:0 6px 18px rgba(11,31,68,.12);
  color:var(--ox-navy); text-align:left; width:100%;
}
.ox-card{ display:none; }
.ox-card[hidden], .ox-bubble[hidden]{ display:none !important; }
.ox-card b, .ox-bubble b{ display:block; font-size:12.5px; line-height:1.35; font-weight:700; }
.ox-card .ox-sub, .ox-bubble span{ display:block; margin-top:2px; font-size:11.5px; color:var(--ox-muted); }
.ox-card-actions{ display:flex; gap:6px; margin-top:8px; flex-wrap:wrap; }
.ox-card-actions button{
  appearance:none; border:1px solid var(--ox-line); background:#fff; color:var(--ox-navy);
  border-radius:8px; padding:7px 10px; font:inherit; font-size:12px; font-weight:700;
  cursor:pointer; min-height:36px;
}
.ox-card-actions button.ox-primary{ background:var(--ox-navy); color:#fff; border-color:var(--ox-navy); }
.ox-bubble{ cursor:pointer; animation:ox-in .28s ease-out; }

/* Dog, then the settings button above him. They do not share one box. */
.ox-dock{
  position:relative;
  display:flex; flex-direction:column; align-items:flex-end;
  gap:var(--ox-dock-gap);
  pointer-events:none;
}
.ox-stage{
  position:relative; z-index:1;
  width:calc(var(--ox-size) + 44px);
  height:var(--ox-disp-h);
  background:transparent; pointer-events:none;
  overflow:visible;
}
.ox-actor{
  position:absolute; right:0; bottom:0; z-index:1;
  width:calc(var(--ox-size) + 40px); height:var(--ox-disp-h);
  pointer-events:none;
}
.ox-sprite{
  position:absolute; right:0; bottom:0; left:auto !important; top:auto !important; z-index:1;
  display:block; width:var(--ox-size); height:var(--ox-disp-h);
  margin:0; padding:0; border:0;
  appearance:none; -webkit-appearance:none;
  background-color:transparent;
  background-image:url('oxford-dog-sprite.png');
  background-repeat:no-repeat;
  background-size:var(--ox-sheet-w) var(--ox-sheet-h);
  background-position:0 0;
  cursor:pointer; outline:none; pointer-events:auto;
  transform:none; transform-origin:center bottom;
  transition:none !important;
  touch-action:manipulation;
  image-rendering:auto;
}
.ox-sprite:focus-visible{ outline:2px solid var(--ox-navy); outline-offset:2px; }
/* Face flip only — never translateX (that reads as sliding away on iPhone) */
.ox-sprite.ox-face-left{ transform:scaleX(-1); }
.ox-sprite.ox-face-right{ transform:none; }
/* Lower into the bowl while eating/lapping — vertical only, no horizontal drift */
.ox-sprite.ox-eating{
  transform:translateY(3px);
}
.ox-sprite.ox-face-left.ox-eating{
  transform:scaleX(-1) translateY(3px);
}

.ox-gear{
  appearance:none; border:1px solid var(--ox-line); background:#fff; color:var(--ox-navy);
  width:var(--ox-gear); height:var(--ox-gear); border-radius:999px; padding:0;
  font:inherit; line-height:0; cursor:pointer; pointer-events:auto;
  box-shadow:0 4px 14px rgba(15,23,42,.14);
  display:inline-flex; align-items:center; justify-content:center;
  flex:0 0 auto; align-self:flex-end; margin:0;
  position:relative; z-index:3;
}
.ox-gear svg{ display:block; width:18px; height:18px; }
.ox-gear[aria-expanded="true"]{ border-color:var(--ox-navy); background:#EEF2FF; }

/* Bowl sits in front of the snout when Oxford faces left (toward it) */
.ox-bowl{
  position:absolute; z-index:3;
  width:40px; height:16px; left:0; bottom:3px;
  transform:none;
  border-radius:0 0 14px 14px; border:2px solid #64748B; border-top:0;
  background:linear-gradient(#F8FAFC,#E2E8F0);
  opacity:0; pointer-events:none; transition:opacity .15s;
  box-shadow:0 1px 2px rgba(15,23,42,.12);
}
.ox-bowl.on{ opacity:1; }
.ox-bowl.food::after, .ox-bowl.water::after{
  content:""; position:absolute; left:4px; right:4px; top:2px; height:7px; border-radius:6px;
}
.ox-bowl.food::after{ background:#C4A574; }
.ox-bowl.water::after{ background:#38BDF8; }

/* Settings popover — hidden until the gear opens. Sits above the gear, clear of the dog. */
.ox-panel{
  display:none;
  position:absolute; right:0; bottom:calc(100% + 8px);
  width:min(260px, calc(100vw - 32px));
  background:#fff; border:1px solid var(--ox-line); border-radius:14px;
  padding:10px; box-shadow:0 10px 28px rgba(15,23,42,.16);
  flex-direction:column; gap:8px; z-index:5;
}
.ox-root.ox-settings-open .ox-panel{ display:flex; }
.ox-panel-head{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  font-size:12px; font-weight:750; color:var(--ox-navy);
}
.ox-panel-close{
  appearance:none; border:0; background:#F1F5F9; color:var(--ox-muted);
  width:28px; height:28px; border-radius:8px; cursor:pointer; font:inherit; font-size:16px;
}
.ox-care{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:6px; }
.ox-care button{
  appearance:none; border:1px solid var(--ox-line); background:#F8FAFC; color:var(--ox-navy);
  border-radius:10px; padding:8px 4px; font:inherit; font-size:12px; font-weight:700;
  cursor:pointer; min-height:40px; white-space:nowrap;
}
.ox-care button:hover{ background:#EEF2FF; }
.ox-toggles{ display:flex; flex-direction:column; gap:6px; }
.ox-tog{
  appearance:none; border:1px solid var(--ox-line); background:#fff; color:var(--ox-navy);
  border-radius:10px; padding:8px 10px; font:inherit; font-size:13px; font-weight:650;
  cursor:pointer; display:flex; align-items:center; justify-content:space-between; gap:8px;
  min-height:40px; width:100%; line-height:1.2;
}
.ox-tog .ox-tog-label{ color:var(--ox-muted); }
.ox-tog .ox-tog-state{
  min-width:2.6em; text-align:center; font-size:12px; font-weight:800;
  padding:4px 8px; border-radius:999px; background:#F1F5F9; color:var(--ox-muted);
}
.ox-tog[aria-pressed="true"]{ border-color:var(--ox-navy); }
.ox-tog[aria-pressed="true"] .ox-tog-label{ color:var(--ox-navy); }
.ox-tog[aria-pressed="true"] .ox-tog-state{ background:var(--ox-navy); color:#fff; }
.ox-test{
  appearance:none; border:0; background:transparent; color:var(--ox-muted);
  font:inherit; font-size:12px; font-weight:650; cursor:pointer;
  text-decoration:underline; text-underline-offset:2px; padding:4px 0; align-self:flex-start;
}

.ox-show-btn{
  position:fixed; z-index:70; right:12px; bottom:calc(12px + env(safe-area-inset-bottom, 0px));
  appearance:none; border:1px solid var(--ox-line); background:#fff; color:var(--ox-navy);
  border-radius:999px; padding:8px 12px; font:inherit; font-size:12px; font-weight:700;
  box-shadow:0 4px 14px rgba(15,23,42,.1); cursor:pointer; display:none; min-height:40px;
}
.ox-show-btn.on{ display:inline-flex; align-items:center; }

@keyframes ox-idle{
  from{background-position:0 0}
  to{background-position:calc(-6 * var(--ox-cell-w)) 0}
}
@keyframes ox-walk{
  from{background-position:0 calc(-1 * var(--ox-cell-h))}
  to{background-position:calc(-8 * var(--ox-cell-w)) calc(-1 * var(--ox-cell-h))}
}
@keyframes ox-wave{
  from{background-position:0 calc(-3 * var(--ox-cell-h))}
  to{background-position:calc(-4 * var(--ox-cell-w)) calc(-3 * var(--ox-cell-h))}
}
@keyframes ox-hop{
  from{background-position:0 calc(-4 * var(--ox-cell-h))}
  to{background-position:calc(-5 * var(--ox-cell-w)) calc(-4 * var(--ox-cell-h))}
}
@keyframes ox-tilt{
  from{background-position:0 calc(-6 * var(--ox-cell-h))}
  to{background-position:calc(-6 * var(--ox-cell-w)) calc(-6 * var(--ox-cell-h))}
}
@keyframes ox-look{
  from{background-position:0 calc(-7 * var(--ox-cell-h))}
  to{background-position:calc(-6 * var(--ox-cell-w)) calc(-7 * var(--ox-cell-h))}
}
@keyframes ox-lookup{
  from{background-position:0 calc(-9 * var(--ox-cell-h))}
  to{background-position:calc(-8 * var(--ox-cell-w)) calc(-9 * var(--ox-cell-h))}
}
@keyframes ox-lookdown{
  from{background-position:0 calc(-10 * var(--ox-cell-h))}
  to{background-position:calc(-8 * var(--ox-cell-w)) calc(-10 * var(--ox-cell-h))}
}
@keyframes ox-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}

.ox-sprite.act-idle{ animation:ox-idle 1.6s steps(6) infinite; }
.ox-sprite.act-walk{ animation:ox-walk .85s steps(8) infinite; }
.ox-sprite.act-wave{ animation:ox-wave 1.0s steps(4) 1 forwards; }
.ox-sprite.act-hop{ animation:ox-hop .7s steps(5) 1 forwards; }
.ox-sprite.act-tilt{ animation:ox-tilt 1.1s steps(6) 1 forwards; }
.ox-sprite.act-look{ animation:ox-look 1.1s steps(6) 1 forwards; }
.ox-sprite.act-lookup{ animation:ox-lookup .9s steps(8) 1 forwards; }
.ox-sprite.act-lookdown{ animation:ox-lookdown 1.4s steps(8) 1 forwards; }
/* JS-driven care frames — never blank mid-action */
.ox-sprite.ox-manual{
  animation:none !important;
  background-image:url('oxford-dog-sprite.png') !important;
  background-repeat:no-repeat !important;
  background-size:var(--ox-sheet-w) var(--ox-sheet-h) !important;
  opacity:1 !important; visibility:visible !important;
}

@media (prefers-reduced-motion: reduce){
  .ox-sprite.act-idle,.ox-sprite.act-walk,.ox-sprite.act-wave,
  .ox-sprite.act-hop,.ox-sprite.act-tilt,.ox-sprite.act-look,
  .ox-sprite.act-lookup,.ox-sprite.act-lookdown{ animation:none !important; }
  .ox-sprite{ background-position:0 0; transition:none !important; }
  .ox-bubble,.ox-card{ animation:none; }
}
.ox-root.ox-reduced .ox-sprite.act-idle,
.ox-root.ox-reduced .ox-sprite.act-walk,
.ox-root.ox-reduced .ox-sprite.act-wave,
.ox-root.ox-reduced .ox-sprite.act-hop,
.ox-root.ox-reduced .ox-sprite.act-tilt,
.ox-root.ox-reduced .ox-sprite.act-look,
.ox-root.ox-reduced .ox-sprite.act-lookup,
.ox-root.ox-reduced .ox-sprite.act-lookdown{ animation:none !important; }
.ox-root.ox-reduced .ox-sprite{ background-position:0 0; transition:none !important; }

@media (max-width:700px){
  :root{ --ox-size:64px; --ox-gear:40px; --ox-dock-gap:12px; }
  .ox-root{
    right:max(12px, env(safe-area-inset-right, 0px));
    bottom:calc(12px + env(safe-area-inset-bottom, 0px));
    max-width:calc(100vw - 20px);
  }
  .ox-stage{ width:calc(var(--ox-size) + 40px); }
  .ox-actor{ width:calc(var(--ox-size) + 36px); }
  .ox-card:not([hidden]){ display:block; }
  .ox-bubble{ display:none !important; } /* phone uses card with Open/Dismiss */
  .ox-gear svg{ width:18px; height:18px; }
  .ox-panel{ width:min(260px, calc(100vw - 24px)); right:0; }
}
