/* Carbon site: shared tokens, shell, buttons and form controls. */

:root {
  color-scheme: dark;

  /* Colour */
  --c-bg: #08090c;
  --c-surface: #0f1116;
  --c-surface-2: #161a21;
  --c-surface-3: #1d212a;
  --c-text: #eef0f4;
  --c-text-2: #b2b8c4;
  --c-text-3: #8a91a0;
  --c-paper: #ebe8e1;
  --c-ink: #0b0c0f;
  --c-ink-2: #4a4d55;
  --c-cyan: #7fe7ff;
  --c-violet: #a99cff;
  --c-pink: #ff8ad4;
  --c-ok: #7ee2a8;
  --c-warn: #ffc56b;
  --c-err: #ff7a8a;
  --c-white: #fff;
  --c-black: #000;
  --c-line: color-mix(in srgb, var(--c-white) 9%, transparent);
  --c-line-2: color-mix(in srgb, var(--c-white) 16%, transparent);
  --c-glass: color-mix(in srgb, var(--c-white) 5%, transparent);
  --c-glass-2: color-mix(in srgb, var(--c-white) 9%, transparent);
  --c-shade: color-mix(in srgb, var(--c-black) 60%, transparent);
  --grad-iris: linear-gradient(115deg, var(--c-cyan), var(--c-violet) 48%, var(--c-pink));
  --focus: var(--c-cyan);

  /* Type */
  --f-text: "Archivo", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --w-wide: 125%;
  --w-semi: 112%;
  --t-mega: clamp(2.6rem, 1.2rem + 6.4vw, 7rem);
  --t-h1: clamp(2.2rem, 1.3rem + 3.6vw, 4.25rem);
  --t-h2: clamp(1.7rem, 1.2rem + 1.9vw, 2.75rem);
  --t-h3: clamp(1.15rem, 1.05rem + .35vw, 1.35rem);
  --t-lead: clamp(1.06rem, 1rem + .3vw, 1.25rem);
  --t-body: 1rem;
  --t-small: .875rem;
  --t-micro: .75rem;

  /* Space */
  --s-1: .25rem;
  --s-2: .5rem;
  --s-3: .75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;
  --s-9: clamp(4.5rem, 3rem + 6vw, 9rem);
  --gutter: clamp(1rem, .5rem + 2.5vw, 2.5rem);
  --max: 1280px;

  /* Shape */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 34px;
  --r-pill: 999px;

  /* Motion */
  --d-fast: 120ms;
  --d-mid: 240ms;
  --d-slow: 600ms;
  --d-hold: 500ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.22, 1, .36, 1);

  /* Depth */
  --shadow-1: 0 1px 0 var(--c-line-2) inset, 0 12px 30px -12px var(--c-shade);
  --shadow-2: 0 1px 0 var(--c-line-2) inset, 0 40px 90px -30px var(--c-shade);
}

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

[hidden] { display: none !important; }

/* Headings receive focus programmatically when a step changes; no ring needed there. */
[tabindex="-1"]:focus { outline: none; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

body {
  min-height: 100vh;
  background: var(--c-bg);
  color: var(--c-text);
  font: 400 var(--t-body) / 1.6 var(--f-text);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg,
canvas,
picture { display: block; max-width: 100%; }

button,
input,
select,
textarea { font: inherit; color: inherit; }

a { color: inherit; }

h1, h2, h3, h4 {
  font-weight: 700;
  font-stretch: var(--w-wide);
  line-height: 1.02;
  letter-spacing: -.035em;
  text-wrap: balance;
}

p { text-wrap: pretty; }

code,
kbd,
.mono { font-family: var(--f-mono); font-size: .92em; }

::selection { background: color-mix(in srgb, var(--c-violet) 45%, transparent); color: var(--c-white); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: var(--s-4);
  top: var(--s-3);
  z-index: 100;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm);
  background: var(--c-paper);
  color: var(--c-ink);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip:focus-visible { transform: none; }

/* Film grain keeps large dark fields from banding. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background: url("/assets/grain.svg");
  opacity: .035;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--c-line);
  background: color-mix(in srgb, var(--c-bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.bar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-right: auto;
  color: var(--c-text);
  text-decoration: none;
  font-weight: 700;
  font-stretch: var(--w-wide);
  font-size: 1.2rem;
  letter-spacing: -.045em;
  border-radius: var(--r-sm);
}

.brand img { width: 30px; height: 30px; }

.nav { display: flex; align-items: center; gap: var(--s-1); }

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 40px;
  padding: 0 .7rem;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  font-size: var(--t-small);
  font-weight: 500;
  text-decoration: none;
  transition: transform var(--d-fast) var(--ease-out);
}

.nav__link .ico { width: 17px; height: 17px; flex: none; opacity: .8; }

.nav__link:hover { color: var(--c-text); }
.nav__link:active { transform: scale(.95); }
.nav__link[aria-current="page"] { color: var(--c-text); }

.auth { display: flex; align-items: center; gap: var(--s-2); }
.auth [hidden] { display: none; }

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--c-surface-3);
  color: var(--c-text);
  font-weight: 700;
  font-stretch: var(--w-wide);
  font-size: .95rem;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform var(--d-mid) var(--ease-spring);
}

.avatar::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: 50%;
  background: var(--grad-iris);
}

.avatar:hover { transform: translateY(-2px) rotate(-6deg); }
.avatar:active { transform: scale(.92); }

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 860px) {
  .nav__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav__link { padding: 0 .6rem; }
  .nav__link .ico { width: 19px; height: 19px; }
}

@media (max-width: 560px) {
  .auth .auth__create { display: none; }
  .bar { gap: var(--s-2); }
}

@media (max-width: 370px) {
  .brand__word { display: none; }
  .nav__link { padding: 0 .5rem; }
}

/* ---------- Buttons ----------
   Hover lifts, press depresses, press-and-hold sweeps a fill across the face. */

.btn {
  --lift: 0px;
  --press: 1;
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  min-height: 46px;
  padding: 0 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: .9375rem;
  font-weight: 600;
  font-stretch: 100%;
  line-height: 1;
  letter-spacing: -.005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transform: perspective(500px) translateY(var(--lift)) rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--press));
  transition: transform var(--d-mid) var(--ease-out);
}

.btn::before,
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* Hover sheen */
.btn::before {
  background: linear-gradient(180deg, color-mix(in srgb, var(--c-white) 22%, transparent), transparent 60%);
  opacity: 0;
  transition: opacity var(--d-mid) var(--ease-out);
}

/* Hold fill */
.btn::after {
  background: var(--grad-iris);
  opacity: .32;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--d-mid) var(--ease-out);
}

@media (hover: hover) {
  .btn:hover { --lift: -2px; }
  .btn:hover::before { opacity: 1; }
}

.btn:active {
  --lift: 1px;
  --press: .965;
  transition-duration: 90ms;
}

.btn:active::after {
  transform: scaleX(1);
  transition: transform .9s linear .12s;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .55;
  --lift: 0px;
  --press: 1;
}

.btn[disabled]::after,
.btn[aria-disabled="true"]::after { transform: scaleX(0); }

.btn .ico { width: 18px; height: 18px; }

.btn--primary {
  background: var(--c-paper);
  color: var(--c-ink);
  box-shadow: 0 1px 0 var(--c-white) inset, 0 -1px 0 color-mix(in srgb, var(--c-black) 18%, transparent) inset, 0 8px 18px -10px var(--c-black);
}

.btn--glass {
  border-color: var(--c-line-2);
  background: linear-gradient(180deg, var(--c-glass-2), var(--c-glass));
  color: var(--c-text);
  box-shadow: 0 1px 0 var(--c-line-2) inset;
}

.btn--quiet {
  background: transparent;
  color: var(--c-text);
}

.btn--quiet::before { background: var(--c-glass-2); }

.btn--danger {
  border-color: color-mix(in srgb, var(--c-err) 55%, transparent);
  background: color-mix(in srgb, var(--c-err) 12%, transparent);
  color: var(--c-err);
}

.btn--danger::after { background: var(--c-err); }

.btn--sm { min-height: 38px; padding: 0 .9rem; font-size: var(--t-small); border-radius: 9px; }
.btn--lg { min-height: 54px; padding: 0 1.5rem; font-size: 1rem; border-radius: 13px; }
.btn--block { width: 100%; }

.btn[aria-busy="true"] { color: transparent; }

.btn[aria-busy="true"] > .spinner {
  position: absolute;
  inset: 0;
  margin: auto;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}

.btn--primary .spinner { color: var(--c-ink); }
.btn--glass .spinner,
.btn--quiet .spinner { color: var(--c-text); }

@keyframes spin { to { transform: rotate(360deg); } }

.cta { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.cta--center { justify-content: center; }

.link {
  color: var(--c-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--c-violet) 70%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
}

.link:hover { text-decoration-color: var(--c-cyan); }

/* ---------- Form controls ---------- */

.field { display: grid; gap: var(--s-2); }

.field__label {
  font-size: var(--t-small);
  font-weight: 600;
  color: var(--c-text);
}

.field__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.field__row a { font-size: var(--t-small); }

.input-wrap { position: relative; }

.input {
  width: 100%;
  min-height: 48px;
  padding: .7rem .95rem;
  border: 1px solid var(--c-line-2);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--c-surface) 85%, transparent);
  color: var(--c-text);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--c-black) 40%, transparent) inset;
}

.input::placeholder { color: var(--c-text-3); }

.input:hover { border-color: color-mix(in srgb, var(--c-white) 26%, transparent); }

.input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: transparent;
}

.input[aria-invalid="true"] { border-color: var(--c-err); }

.input-wrap .input { padding-right: 3.2rem; }

.reveal {
  position: absolute;
  right: 5px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--c-text-2);
  cursor: pointer;
  transform: translateY(-50%);
  transition: transform var(--d-fast) var(--ease-out);
}

.reveal:hover { color: var(--c-text); }
.reveal:active { transform: translateY(-50%) scale(.9); }
.reveal .ico { width: 19px; height: 19px; }
.reveal .ico--hide { display: none; }
.reveal[aria-pressed="true"] .ico--show { display: none; }
.reveal[aria-pressed="true"] .ico--hide { display: block; }

.field__error {
  display: flex;
  gap: .4rem;
  color: var(--c-err);
  font-size: var(--t-small);
}

.field__error:empty { display: none; }

.field__hint { color: var(--c-text-3); font-size: var(--t-small); }

.check {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  font-size: var(--t-small);
  color: var(--c-text-2);
  cursor: pointer;
}

.check input {
  appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: .1rem;
  border: 1px solid var(--c-line-2);
  border-radius: 6px;
  background: var(--c-surface);
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease-out);
}

.check input::after {
  content: "";
  width: 10px;
  height: 6px;
  border: 2px solid var(--c-ink);
  border-top: 0;
  border-right: 0;
  transform: translateY(-1px) rotate(-45deg) scale(0);
  transition: transform var(--d-fast) var(--ease-spring);
}

.check input:checked { background: var(--c-paper); border-color: var(--c-paper); }
.check input:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.check input:active { transform: scale(.88); }
.check input[aria-invalid="true"] { border-color: var(--c-err); }

.alert {
  display: flex;
  gap: .7rem;
  padding: .85rem 1rem;
  border: 1px solid color-mix(in srgb, var(--c-err) 45%, transparent);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--c-err) 9%, transparent);
  color: var(--c-text);
  font-size: var(--t-small);
}

.alert::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: .45rem;
  border-radius: 50%;
  background: var(--c-err);
}

.alert--ok { border-color: color-mix(in srgb, var(--c-ok) 45%, transparent); background: color-mix(in srgb, var(--c-ok) 8%, transparent); }
.alert--ok::before { background: var(--c-ok); }
.alert--info { border-color: var(--c-line-2); background: var(--c-glass); }
.alert--info::before { background: var(--c-cyan); }
.alert:empty,
.alert[hidden] { display: none; }

/* ---------- Footer ---------- */

.site-footer {
  position: relative;
  margin-top: var(--s-9);
  padding-block: var(--s-8) var(--s-6);
  border-top: 1px solid var(--c-line);
  background: linear-gradient(180deg, var(--c-surface), var(--c-bg));
  font-size: var(--t-small);
  color: var(--c-text-2);
}

.foot {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
  gap: var(--s-7) var(--s-6);
}

.foot__brand p { max-width: 26ch; margin-top: var(--s-4); }

.foot h2 {
  margin-bottom: var(--s-4);
  font-size: var(--t-micro);
  font-weight: 600;
  font-stretch: 100%;
  letter-spacing: .02em;
  color: var(--c-text-3);
}

.foot ul { list-style: none; padding: 0; display: grid; gap: .55rem; }
.foot a { text-decoration: none; color: var(--c-text-2); }
.foot a:hover { color: var(--c-text); }

.foot__legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-3) var(--s-6);
  margin-top: var(--s-8);
  padding-top: var(--s-5);
  border-top: 1px solid var(--c-line);
  color: var(--c-text-3);
  font-size: var(--t-micro);
}

.foot__legal p { max-width: 70ch; }
.foot__legal:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

@media (max-width: 860px) {
  .foot { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot__brand { grid-column: 1 / -1; }
}

/* Minimal footer (account pages, 404) */
.auth-foot {
  margin-top: var(--s-8);
  padding-block: var(--s-5);
  border-top: 1px solid var(--c-line);
  font-size: var(--t-micro);
  color: var(--c-text-3);
}

.auth-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3); }
.auth-foot a { color: var(--c-text-2); }

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
  }
}
