/*
 * Axiom Forge — laboratory UI
 * Tokens + components. Works alongside Tailwind utilities.
 */

:root {
  --af-ink: #0b1324;
  --af-ink-soft: #3d4a63;
  --af-mute: #6b7a94;
  --af-paper: #eef2f6;
  --af-paper-deep: #e2e8f0;
  --af-panel: rgba(255, 255, 255, 0.82);
  --af-panel-solid: #ffffff;
  --af-line: rgba(11, 19, 36, 0.1);
  --af-line-strong: rgba(11, 19, 36, 0.18);
  --af-accent: #0f6e66;
  --af-accent-deep: #0a524c;
  --af-accent-soft: rgba(15, 110, 102, 0.12);
  --af-accent-glow: rgba(45, 180, 160, 0.35);
  --af-warn: #9a6700;
  --af-warn-bg: #fff7e6;
  --af-danger: #b42318;
  --af-ok: #067647;
  --af-ok-bg: #ecfdf3;
  --af-radius: 10px;
  --af-radius-sm: 6px;
  --af-shadow: 0 1px 0 rgba(11, 19, 36, 0.04), 0 12px 32px rgba(11, 19, 36, 0.06);
  --af-font-display: "Outfit", "Segoe UI", sans-serif;
  --af-font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --af-font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.af-body {
  margin: 0;
  min-height: 100vh;
  color: var(--af-ink);
  font-family: var(--af-font-body);
  font-size: 15px;
  line-height: 1.55;
  background-color: var(--af-paper);
  background-image:
    radial-gradient(ellipse 90% 60% at 10% -10%, rgba(15, 110, 102, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(11, 19, 36, 0.06), transparent 50%),
    linear-gradient(rgba(11, 19, 36, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 19, 36, 0.035) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
  background-attachment: fixed;
}

a {
  color: var(--af-accent-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 160ms ease;
}

a:hover {
  color: var(--af-accent);
}

/* —— Shell —— */
.af-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.af-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(238, 242, 246, 0.78);
  border-bottom: 1px solid var(--af-line);
}

.af-topbar__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.af-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--af-ink);
}

.af-brand:hover {
  color: var(--af-ink);
}

.af-brand__mark {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 7px;
  background:
    linear-gradient(145deg, var(--af-accent) 0%, var(--af-accent-deep) 100%);
  box-shadow: 0 0 0 1px rgba(15, 110, 102, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  position: relative;
  flex-shrink: 0;
}

.af-brand__mark::after {
  content: "";
  position: absolute;
  inset: 28% 28%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 2px;
  transform: rotate(45deg);
}

.af-brand__name {
  font-family: var(--af-font-display);
  font-weight: 650;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.af-brand__tag {
  display: none;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--af-mute);
  margin-left: 0.15rem;
}

@media (min-width: 720px) {
  .af-brand__tag {
    display: inline;
  }
}

.af-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.85rem;
  font-size: 0.875rem;
}

.af-nav__link {
  position: relative;
  color: var(--af-ink-soft);
  text-decoration: none;
  padding: 0.25rem 0;
}

.af-nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 1.5px;
  background: var(--af-accent);
  transition: right 200ms ease;
}

.af-nav__link:hover {
  color: var(--af-ink);
}

.af-nav__link:hover::after {
  right: 0;
}

.af-nav__meta {
  color: var(--af-mute);
  font-size: 0.8rem;
  font-family: var(--af-font-mono);
}

.af-nav__btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.25rem 0;
  font: inherit;
  font-size: 0.875rem;
  color: var(--af-ink-soft);
  cursor: pointer;
  position: relative;
}

.af-nav__btn:hover {
  color: var(--af-ink);
}

.af-main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.af-main--narrow {
  max-width: 720px;
}

/* —— Motion —— */
@keyframes af-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes af-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes af-pulse-ring {
  0% { box-shadow: 0 0 0 0 var(--af-accent-glow); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.af-rise {
  animation: af-rise 480ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.af-rise-delay-1 { animation-delay: 80ms; }
.af-rise-delay-2 { animation-delay: 140ms; }
.af-rise-delay-3 { animation-delay: 200ms; }

@media (prefers-reduced-motion: reduce) {
  .af-rise,
  .af-auth__panel,
  .af-brand__mark {
    animation: none !important;
  }
}

/* —— Type —— */
.af-h1 {
  font-family: var(--af-font-display);
  font-size: clamp(1.65rem, 2.4vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

.af-h2 {
  font-family: var(--af-font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  color: var(--af-ink);
}

.af-lede {
  margin: 0 0 1.5rem;
  color: var(--af-ink-soft);
  max-width: 42rem;
}

.af-section {
  margin-top: 2rem;
}

.af-section + .af-section {
  padding-top: 0.25rem;
}

/* —— Surfaces —— */
.af-panel {
  background: var(--af-panel);
  border: 1px solid var(--af-line);
  border-radius: var(--af-radius);
  box-shadow: var(--af-shadow);
  backdrop-filter: blur(8px);
  padding: 1rem 1.1rem;
}

.af-panel--flush {
  padding: 0;
  overflow: hidden;
}

.af-panel__row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--af-line);
  transition: background 160ms ease;
}

.af-panel__row:last-child {
  border-bottom: 0;
}

.af-panel__row:hover {
  background: rgba(15, 110, 102, 0.04);
}

.af-empty {
  color: var(--af-mute);
  font-size: 0.9rem;
  margin: 0;
}

.af-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* —— Buttons & forms —— */
.af-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--af-radius-sm);
  padding: 0.55rem 1rem;
  font-family: var(--af-font-body);
  font-size: 0.875rem;
  font-weight: 560;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease, box-shadow 160ms ease;
}

.af-btn:active {
  transform: translateY(1px);
}

.af-btn--primary {
  background: linear-gradient(180deg, #148278 0%, var(--af-accent-deep) 100%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(11, 19, 36, 0.2);
}

.af-btn--primary:hover {
  color: #fff;
  background: linear-gradient(180deg, #17968b 0%, var(--af-accent) 100%);
}

.af-btn--primary:focus-visible {
  outline: none;
  animation: af-pulse-ring 1.2s ease;
}

.af-btn--ghost {
  background: var(--af-panel-solid);
  border-color: var(--af-line-strong);
  color: var(--af-ink);
}

.af-btn--ghost:hover {
  border-color: var(--af-accent);
  color: var(--af-accent-deep);
  background: var(--af-accent-soft);
}

.af-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.af-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--af-ink-soft);
  margin-bottom: 0.35rem;
}

.af-input,
.af-textarea {
  width: 100%;
  border: 1px solid var(--af-line-strong);
  border-radius: var(--af-radius-sm);
  background: var(--af-panel-solid);
  padding: 0.65rem 0.8rem;
  font: inherit;
  color: var(--af-ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.af-input:focus,
.af-textarea:focus {
  outline: none;
  border-color: var(--af-accent);
  box-shadow: 0 0 0 3px var(--af-accent-soft);
}

.af-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 28rem;
}

.af-hint {
  font-size: 0.78rem;
  color: var(--af-mute);
  margin: 0;
}

/* —— Badges —— */
.af-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--af-font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--af-paper-deep);
  color: var(--af-ink-soft);
  white-space: nowrap;
}

.af-badge--ok {
  background: var(--af-ok-bg);
  color: var(--af-ok);
}

.af-badge--warn {
  background: var(--af-warn-bg);
  color: var(--af-warn);
}

.af-badge--accent {
  background: var(--af-accent-soft);
  color: var(--af-accent-deep);
}

/* —— Flash —— */
.af-flash {
  border-radius: var(--af-radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  animation: af-fade 280ms ease;
}

.af-flash--notice {
  background: var(--af-ok-bg);
  color: var(--af-ok);
  border: 1px solid rgba(6, 118, 71, 0.2);
}

.af-flash--alert {
  background: #fef3f2;
  color: var(--af-danger);
  border: 1px solid rgba(180, 35, 24, 0.2);
}

/* —— Project tools —— */
.af-tools {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.5rem;
  margin: 1.25rem 0 1.75rem;
}

.af-tools .button_to {
  display: contents;
}

.af-tool {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--af-radius-sm);
  border: 1px solid var(--af-line);
  background: var(--af-panel);
  text-decoration: none;
  color: var(--af-ink);
  transition: border-color 160ms ease, background 160ms ease, transform 120ms ease;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.af-tool:hover {
  border-color: rgba(15, 110, 102, 0.45);
  background: var(--af-accent-soft);
  color: var(--af-ink);
  transform: translateY(-1px);
}

.af-tool__label {
  font-weight: 600;
  font-size: 0.85rem;
}

.af-tool__hint {
  font-size: 0.7rem;
  color: var(--af-mute);
}

.af-warn-panel {
  border: 1px solid rgba(154, 103, 0, 0.35);
  background: var(--af-warn-bg);
  border-radius: var(--af-radius);
  padding: 1rem;
  font-size: 0.9rem;
}

.af-meta {
  font-size: 0.85rem;
  color: var(--af-ink-soft);
  margin: 0 0 1rem;
}

.af-link-quiet {
  color: var(--af-mute);
  text-decoration: none;
  font-size: 0.875rem;
}

.af-link-quiet:hover {
  color: var(--af-accent);
}

.af-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.af-claim {
  font-size: 0.9rem;
}

.af-claim__head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.af-provenance {
  margin-top: 0.5rem;
  color: var(--af-mute);
  font-size: 0.8rem;
}

.af-provenance code {
  font-family: var(--af-font-mono);
  font-size: 0.75rem;
  color: var(--af-ink-soft);
}

/* —— Auth —— */
body.af-auth-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--af-font-body);
  color: var(--af-ink);
  background:
    radial-gradient(ellipse 80% 55% at 15% 20%, rgba(15, 110, 102, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 45% at 90% 85%, rgba(11, 19, 36, 0.12), transparent 50%),
    linear-gradient(165deg, #dfe7ef 0%, #eef2f6 40%, #e6edf2 100%);
}

.af-auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .af-auth {
    grid-template-columns: 1.15fr 0.85fr;
  }
}

.af-auth__hero {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(1.5rem, 4vw, 3.5rem);
  position: relative;
  overflow: hidden;
  min-height: 42vh;
}

.af-auth__hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(11, 19, 36, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 19, 36, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, transparent, #000 30%);
  pointer-events: none;
}

.af-auth__hero-inner {
  position: relative;
  z-index: 1;
  max-width: 28rem;
  animation: af-rise 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.af-auth__wordmark {
  font-family: var(--af-font-display);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.95;
  margin: 0 0 1rem;
}

.af-auth__wordmark span {
  display: block;
  color: var(--af-accent-deep);
}

.af-auth__blurb {
  margin: 0;
  font-size: 1.05rem;
  color: var(--af-ink-soft);
  max-width: 22rem;
}

.af-auth__panel-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.af-auth__panel {
  width: 100%;
  max-width: 24rem;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--af-line);
  border-radius: 14px;
  box-shadow: var(--af-shadow);
  padding: 1.75rem 1.5rem;
  backdrop-filter: blur(12px);
  animation: af-rise 560ms 120ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.af-auth__panel h1 {
  font-family: var(--af-font-display);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}

.af-auth__panel .af-lede {
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.af-auth__creds {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--af-line);
  font-size: 0.78rem;
  color: var(--af-mute);
}

.af-auth__creds code {
  font-family: var(--af-font-mono);
  font-size: 0.75rem;
  color: var(--af-ink-soft);
  background: var(--af-paper);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.af-auth__footer {
  margin-top: auto;
  padding: 1rem clamp(1.5rem, 4vw, 3.5rem) 1.5rem;
  font-size: 0.75rem;
  color: var(--af-mute);
  position: relative;
  z-index: 1;
}

/* Legacy stone utility softening when mixed with af shell */
.af-main .underline {
  text-underline-offset: 3px;
}
