/* Interactive features (progress bar, floating buttons, chat, command palette, quote wizard,
   project drawer, terminal, metrics). Uses the colour tokens defined by each page. */

/* The hidden attribute must win over component display rules (e.g. .btn { display: inline-flex }) */
[hidden] { display: none !important; }

/* Scroll progress */
#ix-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; background: var(--gradient); transform-origin: 0 50%; transform: scaleX(0); pointer-events: none; }

/* Floating action buttons */
.ix-fab { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 12px; align-items: flex-end; }
.ix-fab a, .ix-fab button { width: 54px; height: 54px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: #fff; box-shadow: 0 10px 24px rgba(0,0,0,.35); transition: transform .2s; }
.ix-fab a:hover, .ix-fab button:hover { transform: translateY(-2px) scale(1.04); }
.ix-fab svg { width: 26px; height: 26px; }
.ix-wa { background: #25d366; }
.ix-chat-btn { background: var(--gradient); }
.ix-fab .ix-tip { position: absolute; right: 64px; white-space: nowrap; background: var(--surface); color: var(--text); border: 1px solid var(--border); font-size: .8rem; padding: 6px 10px; border-radius: 8px; opacity: 0; transform: translateX(6px); transition: opacity .2s, transform .2s; pointer-events: none; }
.ix-fab a:hover .ix-tip, .ix-fab button:hover .ix-tip, .ix-fab a:focus-visible .ix-tip, .ix-fab button:focus-visible .ix-tip { opacity: 1; transform: none; }
.ix-fab > * { position: relative; }

/* Shared overlay + dialogs */
.ix-overlay { position: fixed; inset: 0; z-index: 120; background: rgba(5, 8, 18, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.ix-overlay[hidden] { display: none; }
.ix-dialog { width: 100%; max-width: 620px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.5); overflow: hidden; }
.ix-close { background: none; border: 0; color: var(--text-muted); cursor: pointer; font-size: 1.5rem; line-height: 1; padding: 4px 8px; border-radius: 8px; }
.ix-close:hover { color: var(--text); background: var(--surface-2); }
body.ix-lock { overflow: hidden; }

/* Command palette */
.ix-cmdk-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text-muted); font: inherit; font-size: .85rem; cursor: pointer; }
.ix-cmdk-btn:hover { border-color: var(--accent); color: var(--text); }
.ix-cmdk-btn svg { width: 16px; height: 16px; }
.ix-cmdk-btn kbd { font-family: var(--mono); font-size: .72rem; border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; background: var(--surface-2); }
@media (max-width: 1080px) {
  .ix-cmdk-btn kbd { display: none; }
  .ix-cmdk-btn .ix-cmdk-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ix-cmdk-btn { width: 40px; justify-content: center; padding: 0; }
}
.ix-cmdk-input { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; padding: 18px 20px; outline: none; }
.ix-cmdk-list { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.ix-cmdk-group { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: 10px 12px 4px; }
.ix-cmdk-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.ix-cmdk-item small { color: var(--text-muted); font-size: .8rem; }
.ix-cmdk-item[aria-selected="true"] { background: var(--surface-2); outline: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); }
.ix-cmdk-empty { padding: 18px 20px; color: var(--text-muted); }
.ix-cmdk-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: .75rem; color: var(--text-muted); }

/* Quote wizard */
.ix-q-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 0; }
.ix-q-head h2 { margin: 0; font-size: 1.15rem; }
.ix-q-steps { display: flex; gap: 6px; padding: 12px 20px 0; }
.ix-q-steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.ix-q-steps span.on { background: var(--gradient); }
.ix-q-body { padding: 18px 20px; }
.ix-q-body h3 { margin: 0 0 12px; font-size: 1rem; }
.ix-q-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 18px; }
.ix-q-opt { text-align: left; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: .92rem; cursor: pointer; transition: border-color .2s; }
.ix-q-opt small { display: block; color: var(--text-muted); font-size: .8rem; margin-top: 2px; }
.ix-q-opt:hover { border-color: var(--accent); }
.ix-q-opt[aria-pressed="true"] { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 10%, var(--bg)); }
.ix-q-cur { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.ix-q-cur button { background: none; border: 0; color: var(--text-muted); font: inherit; font-size: .85rem; padding: 6px 14px; cursor: pointer; }
.ix-q-cur button[aria-pressed="true"] { background: var(--gradient); color: #fff; }
.ix-q-sum { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; white-space: pre-line; color: var(--text-muted); font-size: .92rem; margin-bottom: 16px; }
.ix-q-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 0 20px 20px; }
.ix-q-nav .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* Project drawer */
.ix-drawer-wrap { position: fixed; inset: 0; z-index: 120; background: rgba(5, 8, 18, .55); }
.ix-drawer-wrap[hidden] { display: none; }
.ix-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -20px 0 60px rgba(0,0,0,.4); overflow-y: auto; padding: 22px 24px 32px; animation: ix-slide .25s ease; }
@keyframes ix-slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.ix-drawer .ix-close { position: absolute; top: 14px; right: 14px; }
.ix-drawer .ix-d-cat { font-family: var(--mono); font-size: .75rem; color: var(--accent-2); text-transform: uppercase; letter-spacing: .06em; }
.ix-drawer h2 { margin: 8px 40px 14px 0; font-size: 1.4rem; line-height: 1.25; }
.ix-drawer p { color: var(--text-muted); }
.ix-drawer .chips { margin: 16px 0 22px; }
.ix-drawer .ix-d-actions { display: flex; flex-wrap: wrap; gap: 10px; }
[data-ix-card] { cursor: pointer; }
.ix-details { align-self: flex-start; margin-top: 14px; background: none; border: 0; padding: 0; font: inherit; font-size: .88rem; font-weight: 600; color: var(--accent-2); cursor: pointer; }
.ix-details:hover { text-decoration: underline; text-underline-offset: 3px; }
.project .ix-details { margin-top: 12px; }

/* Skill filter */
.ix-skill { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.chips li:has(.ix-skill):hover { border-color: var(--accent); color: var(--text); }
.ix-skill-pill { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 18px; padding: 10px 14px; border: 1px solid var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--accent) 10%, transparent); font-size: .92rem; }
.ix-skill-pill button { margin-left: auto; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 4px 10px; font: inherit; font-size: .85rem; cursor: pointer; }
.ix-skill-hidden { display: none !important; }

/* Copy email */
.ix-copy { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .82rem; cursor: pointer; }
.ix-copy:hover { color: var(--text); border-color: var(--accent); }
.ix-copy.done { color: #22c55e; border-color: #22c55e; }

/* Chat */
.ix-chat { position: fixed; right: 18px; bottom: 90px; z-index: 110; width: min(380px, calc(100vw - 36px)); height: min(560px, calc(100vh - 120px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.45); overflow: hidden; }
.ix-chat[hidden] { display: none; }
.ix-chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ix-chat-head b { display: block; font-size: .95rem; }
.ix-chat-head small { color: var(--text-muted); font-size: .78rem; }
.ix-chat-head .ix-close { margin-left: auto; }
.ix-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gradient); display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.ix-chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ix-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: .92rem; line-height: 1.55; white-space: pre-line; }
.ix-msg a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.ix-msg.bot { background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
.ix-msg.me { background: var(--gradient); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.ix-typing { align-self: flex-start; color: var(--text-muted); font-size: .85rem; }
.ix-sugg { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.ix-sugg button { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 6px 11px; font: inherit; font-size: .8rem; cursor: pointer; }
.ix-sugg button:hover { border-color: var(--accent); }
.ix-chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.ix-chat-form input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: .92rem; }
.ix-chat-form input:focus { outline: none; border-color: var(--accent); }
.ix-chat-form button { background: var(--gradient); color: #fff; border: 0; border-radius: 10px; padding: 0 14px; cursor: pointer; font: inherit; font-weight: 600; }
.ix-chat-note { font-size: .72rem; color: var(--text-muted); text-align: center; padding: 0 12px 10px; }

/* Interactive terminal */
.terminal .term-body { max-height: 360px; overflow-y: auto; }
.term-out { color: var(--text-muted); }
.term-out a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
.term-out .w { color: var(--text); }
.term-form { display: flex; align-items: center; gap: 8px; padding: 10px 20px 14px; border-top: 1px dashed var(--border); font-family: var(--mono); font-size: .84rem; }
.term-form label { color: var(--accent-2); }
.term-form input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font: inherit; outline: none; caret-color: var(--accent-2); }
.term-form input::placeholder { color: var(--text-muted); opacity: .7; }

/* Case-study metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 26px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.metric-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 10px; }
.metric-val { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric-val small { font-size: .9rem; font-weight: 600; color: var(--text-muted); margin-left: 4px; }
.metric-bar { display: grid; grid-template-columns: 56px 1fr 80px; align-items: center; gap: 10px; font-size: .82rem; color: var(--text-muted); margin-top: 8px; }
.metric-bar .track { display: block; height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.metric-bar .fill { display: block; height: 100%; width: var(--w); border-radius: 6px; transition: width 1.2s cubic-bezier(.2,.7,.2,1); }
.metric.ix-wait .fill { width: 0; }
.metric-bar.before .fill { background: #f87171; }
.metric-bar.after .fill { background: var(--gradient); }
.metric-bar b { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  #ix-progress { display: none; }
  .ix-drawer { animation: none; }
  .metric-bar .fill { transition: none; }
}
@media print { #ix-progress, .ix-fab, .ix-chat { display: none !important; } }
