/* ============================================================
   ABHAYLABS — COMPONENTS
   One card system, one button system, one form system.
   Every surface on the site is built from these primitives, so
   padding, radius, border and hover behaviour stay consistent.
   ============================================================ */

/* ============================================================
   CARD SYSTEM
   ============================================================ */
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition:
    border-color var(--dur-mid) var(--ease-soft),
    background-color var(--dur-mid) var(--ease-soft),
    transform var(--dur-mid) var(--ease-out);
}
.card--flush { padding: 0; overflow: hidden; }
.card--quiet { background: transparent; }
.card--raised { background: var(--surface-2); }

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--line-soft);
}
.card__title { font-size: 1.02rem; font-variation-settings: "wdth" 98; }
.card__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}
.card__body { padding-top: var(--s-4); flex: 1; }
.card__foot { margin-top: auto; padding-top: var(--s-4); }

/* Equal-height card rows: the footer is pushed to the bottom so
   buttons and labels line up across a grid. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(0.75rem, 1.6vw, 1.25rem);
  align-items: stretch;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  --btn-py: 0.9rem;
  --btn-px: 1.5rem;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: var(--btn-py) var(--btn-px);
  font-size: var(--fs-sm);
  font-weight: 550;
  line-height: 1.2;
  letter-spacing: 0.005em;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  white-space: nowrap;
  overflow: hidden;
  transition:
    background-color var(--dur-fast) var(--ease-soft),
    color var(--dur-fast) var(--ease-soft),
    border-color var(--dur-fast) var(--ease-soft),
    transform var(--dur-fast) var(--ease-soft),
    box-shadow var(--dur-mid) var(--ease-out);
  will-change: transform;
}
.btn--sm { --btn-py: 0.55rem; --btn-px: 1rem; font-size: var(--fs-xs); }
.btn--lg { --btn-py: 1.05rem; --btn-px: 1.9rem; font-size: var(--fs-body); }
.btn--block { width: 100%; }

.btn__arrow {
  width: 15px; height: 15px;
  flex: none;
  transition: transform var(--dur-mid) var(--ease-out);
}
.btn:hover .btn__arrow { transform: translateX(3px); }

/* Primary — the single accent action */
.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}
.btn--primary:hover {
  background: var(--accent-hi);
  box-shadow: var(--shadow-accent);
}
.btn--primary:active { transform: translateY(1px); }

/* Secondary — bordered, neutral */
.btn--secondary {
  border-color: var(--line-strong);
  color: var(--text);
  background: transparent;
}
.btn--secondary:hover {
  border-color: var(--accent-line);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Ghost — quiet, for tertiary actions */
.btn--ghost {
  color: var(--text-2);
  border-color: var(--line);
  background: transparent;
}
.btn--ghost:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface); }

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.is-sent { background: var(--accent-hi); }

/* Sheen sweep on hover */
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.26) 50%, transparent 62%);
  transform: translateX(-130%);
  transition: transform 760ms var(--ease-out);
}
.btn:hover::after { transform: translateX(130%); }
.btn--primary::after { background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.44) 50%, transparent 62%); }

/* Text link with an arrow */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--fs-sm);
  color: var(--text-2);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 2px;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.link-arrow .icon { width: 14px; height: 14px; transition: transform var(--dur-mid) var(--ease-out); }
.link-arrow:hover { color: var(--accent); border-color: var(--accent-line); }
.link-arrow:hover .icon { transform: translate(2px, -2px); }

/* ============================================================
   CHIPS + TAGS
   ============================================================ */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--text-2);
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface);
  transition: color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.chip:hover { color: var(--accent); border-color: var(--accent-line); transform: translateY(-2px); }

/* ============================================================
   FORMS
   ============================================================ */
.field { display: grid; gap: 0.45rem; }
.field__label {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-3);
}
.field__input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.8rem 0.9rem;
  font-size: var(--fs-body);
  color: var(--text);
  transition: border-color var(--dur-fast), background-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field__input::placeholder { color: var(--text-3); opacity: 0.7; }
.field__input:hover { border-color: var(--line-strong); }
.field__input:focus {
  border-color: var(--accent-line);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field__input--area { resize: vertical; min-height: 130px; line-height: 1.6; }
.field__input--select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2386827a' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.4rem;
  cursor: pointer;
}
.field__input--select option { background: var(--surface-2); color: var(--text); }

.field.has-error .field__input { border-color: rgba(242, 116, 106, 0.6); }
.field__error { font-size: var(--fs-xs); color: #f2746a; min-height: 1em; }
.field__error:empty { display: none; }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
  position: relative;
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.5rem);
}
.timeline::before {
  content: "";
  position: absolute;
  left: clamp(84px, 11vw, 132px);
  top: 6px; bottom: 6px;
  width: 1px;
  background: var(--line);
}
.timeline__progress {
  position: absolute;
  left: clamp(84px, 11vw, 132px);
  top: 6px;
  width: 1px;
  height: 0;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(201, 242, 75, 0.5);
  transition: height 120ms linear;
}
.timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: clamp(84px, 11vw, 132px) minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  opacity: 0.62;
  transition: opacity 600ms var(--ease-out);
}
.timeline__item.is-active { opacity: 1; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: calc(clamp(84px, 11vw, 132px) - 4px);
  top: 8px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--canvas);
  border: 1px solid var(--line-strong);
  transition: background-color var(--dur-mid), border-color var(--dur-mid), box-shadow var(--dur-mid);
}
.timeline__item.is-active::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.timeline__year {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding-top: 0.2rem;
  transition: color var(--dur-mid);
}
.timeline__item.is-active .timeline__year { color: var(--accent); }
.timeline__body h3 {
  font-size: var(--fs-h3);
  font-variation-settings: "wdth" 95;
  margin-bottom: 0.5rem;
}
.timeline__body p { color: var(--text-3); font-size: var(--fs-sm); max-width: 58ch; }

@media (max-width: 640px) {
  .timeline::before, .timeline__progress { left: 74px; }
  .timeline__item { grid-template-columns: 74px minmax(0, 1fr); gap: 1rem; }
  .timeline__item::before { left: 70px; }
}

/* ============================================================
   EXPERIMENT CARDS
   ============================================================ */
.exp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(0.75rem, 1.6vw, 1.25rem);
  align-items: stretch;
}
.exp-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--dur-mid) var(--ease-soft), transform var(--dur-mid) var(--ease-out);
}
.exp-card:hover { border-color: var(--line-strong); transform: translateY(-3px); }
.exp-card--wide { grid-column: span 2; }
.exp-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line-soft);
}
.exp-card__head h3 { font-size: 1rem; font-variation-settings: "wdth" 98; white-space: nowrap; }
.exp-card__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  text-align: right;
}
.exp-card__body { padding: var(--s-5); flex: 1; }
.exp-card__body--center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  flex-wrap: wrap;
  min-height: 150px;
}
.exp-card__note {
  padding: 0 var(--s-5) var(--s-5);
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.6;
}
.exp-card__replay {
  align-self: flex-start;
  margin: 0 var(--s-5) var(--s-5);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 2px;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.exp-card__replay:hover { color: var(--accent); border-color: var(--accent-line); }
.exp-card__actions { display: flex; gap: 0.5rem; padding: 0 var(--s-5) var(--s-5); }

@media (max-width: 760px) {
  .exp-card--wide { grid-column: span 1; }
}

/* On narrow screens the card head stacks so the meta label is never
   clipped by the card's own overflow. */
@media (max-width: 560px) {
  .exp-card__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }
  .exp-card__head h3 { white-space: normal; }
  .exp-card__meta { text-align: left; }
  /* Roomier tap targets for the small text buttons. */
  .exp-card__replay { padding-block: 0.5rem; }
}

/* ============================================================
   TERMINAL
   ============================================================ */
.terminal {
  background: #0a0a0c;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.terminal__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.55rem 0.8rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.terminal__bar span { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.terminal__bar span:first-child { background: #f2746a; }
.terminal__bar span:nth-child(2) { background: #f0a94b; }
.terminal__bar span:nth-child(3) { background: var(--accent); }
.terminal__bar em {
  margin-left: auto;
  font-style: normal;
  color: var(--text-3);
  font-size: var(--fs-micro);
}
.terminal__out {
  margin: 0;
  padding: 0.9rem 0.85rem;
  min-height: 190px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-2);
}
.terminal__out .t-prompt { color: var(--accent); }
.terminal__out .t-dim { color: var(--text-3); }
.terminal__out .t-key { color: #f0a94b; }
.terminal__out .t-caret {
  display: inline-block;
  width: 7px; height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: caret-blink 1.05s steps(2) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

/* ============================================================
   CODE SNIPPET
   ============================================================ */
.codesnippet {
  margin: 0;
  background: #0a0a0c;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1rem 1.1rem;
  min-height: 190px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.85;
  overflow-x: auto;
  white-space: pre;
}
.tok-key { color: #a98cf5; }
.tok-fn  { color: #5fd4e4; }
.tok-str { color: var(--accent); }
.tok-num { color: #f0a94b; }
.tok-com { color: var(--text-3); }
.tok-pun { color: var(--text-3); }

/* ============================================================
   SPOTLIGHT
   ============================================================ */
.spotlight {
  position: relative;
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #0a0a0c;
  overflow: hidden;
}
.spotlight__glow {
  position: absolute;
  width: 220px; height: 220px;
  left: 0; top: 0;
  margin: -110px 0 0 -110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 242, 75, 0.3), transparent 62%);
  opacity: 0;
  transition: opacity 400ms var(--ease-soft);
  pointer-events: none;
}
.spotlight__ring {
  position: absolute;
  width: 120px; height: 120px;
  left: 0; top: 0;
  margin: -60px 0 0 -60px;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 400ms var(--ease-soft);
  pointer-events: none;
}
.spotlight.is-active .spotlight__glow,
.spotlight.is-active .spotlight__ring { opacity: 1; }
.spotlight__copy {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-3);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
}

/* ============================================================
   PARTICLES
   ============================================================ */
.particles {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #0a0a0c;
}

/* ============================================================
   PLAYGROUND
   ============================================================ */
.playground {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: var(--s-4);
}
.playground__editor {
  display: flex;
  gap: 0.7rem;
  background: #0a0a0c;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.8rem;
}
.playground__gutter {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.85;
  color: var(--text-3);
  text-align: right;
  user-select: none;
}
.playground__code {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  resize: none;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.85;
  color: var(--text);
  padding: 0;
}
.playground__code:focus { outline: none; }
.playground__out {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.8rem;
  min-height: 100%;
}
.playground__out-label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.4rem;
}
.playground__out pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.8;
  color: var(--accent);
  white-space: pre-wrap;
  word-break: break-word;
}
.playground__out pre.is-error { color: #f2746a; }

@media (max-width: 620px) {
  .playground { grid-template-columns: 1fr; }
}
