/* Alfred, the assistant (shared/alfred.js). Uses the app's theme colours, so it matches all three. */

/* the launcher: a small living orb with his name */
#alfred-launch {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 100px); z-index: 45;
  display: inline-flex; align-items: center; gap: 9px; padding: 6px 16px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line-strong, rgba(217,185,127,.3)); cursor: pointer;
  background: color-mix(in srgb, var(--surface, #16130F) 82%, transparent);
  backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 12px 30px rgba(0,0,0,.28); color: var(--ink); font: inherit; font-size: 14px; font-weight: 500;
  transition: transform .3s cubic-bezier(.16,1,.3,1), opacity .25s ease;
}
#alfred-launch:hover { transform: translateY(-2px); }
#alfred-launch.al-hidden { opacity: 0; pointer-events: none; transform: scale(.9); }
@media (min-width: 900px) { #alfred-launch { bottom: 26px; right: 26px; } }
body.desk #alfred-launch { bottom: 22px; }
.al-orb-mini { position: relative; width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 40% 35%, #F6E7C4, #C9A062 50%, #4A3418); box-shadow: 0 0 18px rgba(226,190,130,.55); }
.al-orb-mini i { position: absolute; width: 70%; height: 70%; border-radius: 50%; mix-blend-mode: screen; filter: blur(4px);
  background: radial-gradient(circle, rgba(255,240,205,.9), transparent 65%); animation: al-drift 6s ease-in-out infinite; }
.al-orb-mini i:nth-child(2) { animation-duration: 7.5s; animation-delay: -2s; }
.al-orb-mini i:nth-child(3) { animation-duration: 9s; animation-delay: -4s; width: 50%; height: 50%; }
@keyframes al-drift { 0%,100% { transform: translate(-10%, -5%); } 33% { transform: translate(45%, 20%); } 66% { transform: translate(5%, 50%); } }
@media (prefers-reduced-motion: reduce) { .al-orb-mini i { animation: none; } }

/* the assistant */
#alfred { position: fixed; inset: 0; z-index: 90; }
#alfred .al-scrim { position: absolute; inset: 0; background: rgba(5,4,3,.5); opacity: 0; transition: opacity .25s ease; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#alfred.open .al-scrim { opacity: 1; }
#alfred .al-panel {
  position: absolute; display: flex; flex-direction: column; overflow: hidden;
  inset: 0; background: var(--bg, #0F0D0B); color: var(--ink);
  transform: translateY(100%); transition: transform .42s cubic-bezier(.16,1,.3,1);
}
#alfred.open .al-panel { transform: none; }
@media (min-width: 900px) {
  #alfred .al-panel { inset: 16px 16px 16px auto; width: 440px; border-radius: 28px; border: 1px solid var(--line-strong);
    transform: translateX(110%); box-shadow: 0 30px 80px rgba(0,0,0,.45); }
}
html.al-lock, html.al-lock body { overflow: hidden; }
#alfred .al-panel::before { /* a soft gold breath behind everything */
  content: ""; position: absolute; inset: -20% -20% auto; height: 70%; pointer-events: none;
  background: radial-gradient(50% 50% at 50% 40%, rgba(201,160,98,.16), transparent 70%);
}

.al-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px 18px; border-bottom: 1px solid transparent; transition: border-color .3s ease; }
#alfred.chatting .al-head { border-bottom-color: var(--line); }
.al-id { display: flex; align-items: center; gap: 10px; opacity: 0; transform: translateY(-4px); transition: opacity .35s ease, transform .35s ease; }
#alfred.chatting .al-id { opacity: 1; transform: none; }
.al-id canvas { width: 32px; height: 32px; }
.al-id b { display: block; font-size: 15px; font-weight: 600; }
.al-id span { display: block; font-size: 12px; color: var(--muted); }
#alfred[data-mode="thinking"] .al-id span { background: linear-gradient(90deg, var(--muted), var(--gold), var(--muted)); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: al-shine 1.4s linear infinite; }
@keyframes al-shine { to { background-position: -200% 0; } }
.al-head-r { display: flex; gap: 4px; }
.al-ic { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
.al-ic:hover { background: var(--track); color: var(--ink); }
.al-ic svg, .al-mic svg, .al-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.al-body { position: relative; flex: 1; overflow-y: auto; padding: 0 20px 20px; scrollbar-width: none; }
.al-body::-webkit-scrollbar { display: none; }
.al-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 6vh 6px 10px; transition: opacity .3s ease; }
#alfred.chatting .al-hero { display: none; }
.al-orb { width: 220px; height: 220px; }
@media (max-height: 700px) { .al-orb { width: 160px; height: 160px; } }
.al-hero h2 { margin: 8px 0 8px; font-size: 26px; font-weight: 400; letter-spacing: -.01em; }
.al-hero p { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; line-height: 1.55; max-width: 320px; }
.al-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.al-chip { border: 1px solid var(--line-strong); background: transparent; color: var(--ink); font: inherit; font-size: 13.5px;
  padding: 9px 14px; border-radius: 999px; cursor: pointer; transition: background .2s ease, border-color .2s ease; }
.al-chip:hover { background: var(--track); border-color: var(--gold-deep); }

.al-log { display: grid; gap: 14px; padding-top: 16px; }
.al-msg { font-size: 15px; line-height: 1.6; animation: al-in .35s cubic-bezier(.16,1,.3,1); }
@keyframes al-in { from { opacity: 0; transform: translateY(8px); } }
.al-me { justify-self: end; max-width: 84%; background: var(--track); border: 1px solid var(--line); padding: 10px 15px; border-radius: 20px 20px 6px 20px; }
.al-ai { max-width: 96%; color: var(--ink); }
.al-ai p { margin: 0 0 8px; } .al-ai p:last-child { margin: 0; }
.al-ai b { color: var(--gold-hi, var(--ink)); font-weight: 600; }
.al-li { display: block; padding-left: 14px; position: relative; }
.al-li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 4px; height: 4px; border-radius: 50%; background: var(--gold); }
.al-caret { display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; background: var(--gold); vertical-align: middle; animation: al-pulse .8s ease-in-out infinite; }
@keyframes al-pulse { 50% { opacity: .3; transform: scale(.7); } }
.al-status { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.al-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--gold); border-top-color: transparent; animation: al-spin .8s linear infinite; }
.al-status.ok::before { border-color: #8FCB9B; animation: none; background: #8FCB9B; }
.al-status.bad::before { border-color: #E39A8F; animation: none; background: #E39A8F; }
@keyframes al-spin { to { transform: rotate(360deg); } }

.al-card { border: 1px solid var(--line-strong); border-radius: 20px; padding: 16px 16px 14px; background: color-mix(in srgb, var(--surface) 70%, transparent);
  animation: al-in .4s cubic-bezier(.16,1,.3,1); }
.al-card-t { font-size: 15.5px; font-weight: 600; margin-bottom: 8px; }
.al-card-r { display: flex; justify-content: space-between; gap: 14px; font-size: 13.5px; padding: 7px 0; border-top: 1px solid var(--line); }
.al-card-r span:first-child { color: var(--muted); }
.al-card-r span:last-child { text-align: right; overflow-wrap: anywhere; }
.al-card-n { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }
.al-card-a { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 12px; }
.al-card-a button { min-height: 44px; border-radius: 999px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.al-no { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.al-yes { border: 0; background: var(--pri-bg); color: var(--pri-fg); box-shadow: var(--pri-shadow); }
.al-yes.danger { background: #B4483C; color: #fff; box-shadow: none; }
.al-done { grid-column: 1 / -1; font-size: 13px; color: #8FCB9B; }
.al-done.no { color: var(--muted); }

.al-input { position: relative; display: flex; align-items: flex-end; gap: 8px; margin: 0 14px calc(env(safe-area-inset-bottom) + 14px);
  padding: 6px; border-radius: 26px; border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--surface) 85%, transparent); }
.al-input textarea { flex: 1; resize: none; border: 0; outline: none; background: transparent; color: var(--ink); font: inherit; font-size: 16px;
  line-height: 1.45; padding: 9px 4px; max-height: 140px; }
.al-input textarea::placeholder { color: var(--muted); }
.al-mic, .al-send { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; }
.al-mic { background: transparent; color: var(--ink-2); }
.al-mic.on { background: rgba(227,154,143,.18); color: #E39A8F; animation: al-pulse 1.2s ease-in-out infinite; }
.al-send { background: var(--pri-bg); color: var(--pri-fg); }
.al-send:disabled { opacity: .5; cursor: default; }
@media (prefers-reduced-motion: reduce) { .al-msg, .al-card { animation: none; } #alfred .al-panel { transition: none; } }
