/*
 * Styles for the whole site, in page order: theme, base, buttons, nav, hero (with the token card),
 * about, sections, chat, experience, skills, contact, footer, then the mobile layout.
 * Colors and fonts are defined once as variables in :root; change them there.
 */

/* ---------- Theme: "Midnight", always dark with an amber accent ---------- */
:root {
  color-scheme: dark; /* dark scrollbars and form controls */
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d2129;
  --ink: #ece8df;
  --muted: #9ca0a8;
  --line: #272b34;
  --accent: #f5b642;
  --accent-ink: #1c1303;
  --accent-soft: rgba(245, 182, 66, 0.13);
  /* The three parts of the token in the hero card: header, payload, signature */
  --jwt-h: #fb7185;
  --jwt-p: #a78bfa;
  --jwt-s: #f5b642;
  --warn: #fb923c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 40px -16px rgba(0, 0, 0, 0.7);

  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --radius: 14px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.8rem, 3.2vw, 2.4rem); font-weight: 700; margin-bottom: 1rem; }
h3 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 1rem; }
ul, ol { margin: 0; padding: 0; }
.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.eyebrow {
  font: 500 0.78rem/1.4 var(--font-mono);
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 0.9rem;
}
.lead { font-size: 1.15rem; color: var(--muted); max-width: 38rem; }
.open-to { display: flex; align-items: center; gap: 0.6rem; font-size: 0.95rem; color: var(--ink); margin: -0.25rem 0 1.5rem; }
.open-to::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.open-to[hidden] { display: none; }
.fine { font-size: 0.85rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--accent); color: var(--accent-ink);
  font: 600 0.95rem/1 var(--font-body);
  padding: 0.85rem 1.2rem; border-radius: 10px; border: 1px solid transparent;
  text-decoration: none; cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); filter: none; }
.btn-small { padding: 0.55rem 0.85rem; font-size: 0.85rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; font-weight: 600; }
.mono-badge {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font: 700 0.8rem/1 var(--font-display); letter-spacing: 0.02em;
}
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a:not(.btn) { color: var(--muted); text-decoration: none; font-size: 0.92rem; }
.nav-links a:not(.btn):hover { color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 3.5rem; align-items: center;
  padding: clamp(3rem, 8vw, 6rem) 0 3rem;
}
.hero h1 { font-size: clamp(2.8rem, 7vw, 5rem); font-weight: 700; margin-bottom: 1.1rem; letter-spacing: -0.035em; }
.avatar {
  display: block; width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  margin-bottom: 1.25rem; border: 2px solid var(--accent);
  box-shadow: 0 0 0 5px var(--bg), 0 0 0 6px var(--line);
}
.avatar[hidden] { display: none; }
.cert-row { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 2rem; }
.cert-row li {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font: 500 0.78rem/1 var(--font-mono); color: var(--muted);
  padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.cert-row li::before { content: "✓"; color: var(--accent); font-weight: 700; }

/* Token card */
.token {
  margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; font-family: var(--font-mono); font-size: 0.8rem;
  animation: rise 0.7s cubic-bezier(.2, .7, .2, 1) both;
}
.token-head, .token-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted);
}
.token-title { color: var(--ink); font-weight: 500; }
.token-alg { padding: 0.15rem 0.45rem; border-radius: 6px; background: var(--surface-2); font-size: 0.72rem; }
/* Padding lives on the wrapper: a clamped element with its own padding lets the next line peek through. */
.token-raw-wrap { padding: 0.9rem 1rem; border-bottom: 1px solid var(--line); }
.token-raw {
  margin: 0; word-break: break-all; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.token-raw .h { color: var(--jwt-h); }
.token-raw .p { color: var(--jwt-p); }
.token-raw .s { color: var(--jwt-s); }
.token-label {
  padding: 0.7rem 1rem 0; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.token-json { margin: 0; padding: 0.5rem 1rem 1rem; white-space: pre-wrap; line-height: 1.55; color: var(--muted); }
.token-json .jl { display: block; } /* one JSON line; wrapped text hangs under the value, not at the left edge */
.tk-key { color: var(--jwt-p); }
.tk-str { color: var(--ink); }
.tk-num { color: var(--jwt-h); }
.token-foot { border-bottom: 0; border-top: 1px solid var(--line); justify-content: flex-start; color: var(--accent); font-weight: 500; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- About ---------- */
.about { padding-bottom: 2rem; }
.about-text {
  border-top: 1px solid var(--line); padding-top: 2rem;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; color: var(--muted);
}
.about-text p { margin: 0; }
.about-text p:first-child { color: var(--ink); font-size: 1.05rem; }

/* ---------- Sections ---------- */
.section { padding: clamp(3.5rem, 8vw, 6rem) 0; border-top: 1px solid var(--line); }
.two-col { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 3.5rem; align-items: start; }
.section-intro { position: sticky; top: 96px; }
.section-intro p:not(.eyebrow):not(.fine) { color: var(--muted); font-size: 1.05rem; }

/* ---------- Chat ---------- */
.chat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.chat-bar {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line); font: 500 0.78rem/1 var(--font-mono); color: var(--muted);
}
.chat-bar-right { margin-left: auto; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-dot.on { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.chat-log { height: 440px; overflow-y: auto; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.msg { max-width: 88%; padding: 0.75rem 0.95rem; border-radius: 12px; font-size: 0.95rem; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.error { background: color-mix(in srgb, #dc2626 12%, var(--surface)); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1rem 0.9rem; }
.chip {
  font: 400 0.84rem/1.3 var(--font-body); color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 0.45rem 0.8rem; cursor: pointer; text-align: left;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chat-form { display: flex; gap: 0.5rem; align-items: flex-end; padding: 0.75rem; border-top: 1px solid var(--line); }
.chat-form textarea, .access input, .access select, .access textarea {
  font: 400 0.95rem/1.5 var(--font-body); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.65rem 0.8rem;
}
.chat-form textarea { flex: 1; resize: none; max-height: 140px; }
.chat-form textarea:focus, .access input:focus, .access select:focus, .access textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.send {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none;
  border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.send:disabled { opacity: 0.5; cursor: not-allowed; }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Markdown inside answers */
.md p { margin: 0 0 0.6rem; }
.md p:last-child, .md ul:last-child, .md ol:last-child { margin-bottom: 0; }
.md ul, .md ol { padding-inline-start: 1.2rem; margin: 0 0 0.6rem; } /* bullets on the right in Hebrew */
.md li { margin: 0.2rem 0; }
.md h4 { font: 700 1rem/1.3 var(--font-display); margin: 1rem 0 0.4rem; }
.md h4:first-child { margin-top: 0; }
.md code { font: 0.85em var(--font-mono); background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
.msg.bot .md code { background: var(--surface); }

/* ---------- Experience ---------- */
.timeline { list-style: none; margin-top: 2rem; }
.role {
  display: grid; grid-template-columns: 180px 1fr; gap: 2rem;
  padding: 1.75rem 0; border-top: 1px solid var(--line);
}
.role:first-child { border-top: 0; padding-top: 0.5rem; }
.role-when { font: 500 0.82rem/1.5 var(--font-mono); color: var(--muted); }
.role-when .now {
  display: inline-block; margin-top: 0.4rem; padding: 0.15rem 0.5rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 0.72rem;
}
.role h3 { font-size: 1.25rem; }
.role-org { color: var(--muted); margin: 0.3rem 0 0.9rem; font-size: 0.95rem; }
.role ul { padding-left: 1.1rem; color: var(--ink); }
.role li { margin: 0.35rem 0; }
.role li::marker { color: var(--accent); }

/* ---------- Skills ---------- */
.skill-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 2rem; }
.skill-card, .cred-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem;
}
.skill-card h3, .cred-card h3 { margin-bottom: 0.9rem; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tags li {
  font-size: 0.85rem; padding: 0.35rem 0.65rem; border-radius: 8px;
  background: var(--surface-2); color: var(--ink);
}
.creds { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.cred-card ul { list-style: none; }
.cred-card li { padding: 0.35rem 0; color: var(--muted); }
.cred-card li strong { color: var(--ink); font-weight: 600; }

/* ---------- Contact (access request form) ---------- */
.section-intro code { font: 0.88em var(--font-mono); background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
.direct-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
#copy-email { justify-content: center; }
.btn svg { flex: none; }
#copy-email svg { flex: none; color: var(--muted); }
#copy-email:hover svg { color: var(--ink); }
#copy-email.copied svg { color: var(--accent); }
.access {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.access-head {
  display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line); font: 500 0.78rem/1 var(--font-mono); color: var(--muted);
}
.pill {
  padding: 0.3rem 0.55rem; border-radius: 999px; font-size: 0.7rem; letter-spacing: 0.06em;
  background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn);
}
.pill.sent { background: var(--accent-soft); color: var(--accent); }
.access-body { display: grid; gap: 1rem; padding: 1.25rem 1rem 1rem; }
.access label { display: grid; gap: 0.35rem; font-size: 0.85rem; font-weight: 500; }
.access .opt { color: var(--muted); font-weight: 400; }
.access input, .access select, .access textarea { width: 100%; }
.access textarea { resize: vertical; min-height: 120px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.access-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.access-fallback { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; font-size: 0.85rem; color: var(--muted); padding-top: 0.85rem; border-top: 1px dashed var(--line); }
.access-fallback[hidden] { display: none; }
.access-fallback a, .link-btn { color: var(--accent); font-weight: 500; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 1.75rem 0; font-size: 0.85rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero, .two-col { grid-template-columns: 1fr; gap: 2.5rem; }
  .section-intro { position: static; }
  .about-text { grid-template-columns: 1fr; gap: 1rem; }
  .nav-links a:not(.btn) { display: none; }
}
@media (max-width: 640px) {
  .role { grid-template-columns: 1fr; gap: 0.5rem; }
  .skill-grid, .creds, .field-row { grid-template-columns: 1fr; }
  .chat-log { height: 380px; }
  .msg { max-width: 94%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
