/* ==========================================================================
   UA Living Spec Book — base layer
   Reset, typography foundations, layout primitives, utilities, login view.
   Consumes variables from css/tokens.css only — no raw brand values here.
   ========================================================================== */

/* ======================= Reset ======================= */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
  scroll-padding-top: calc(var(--ua-header-h) + var(--ua-s4));
  /* clip (not hidden): forbids stray horizontal panning on phones without
     creating a scroll container, so sticky chrome keeps working. */
  overflow-x: clip;
}

@media (prefers-reduced-motion: no-preference) {
  html:focus-within {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100vh;
  background: var(--ua-bg);
  color: var(--ua-text);
  font-family: var(--ua-font-body);
  font-size: var(--ua-fs-body);
  font-weight: 200;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-variant-ligatures: none;
  font-feature-settings: 'liga' 0, 'clig' 0, 'dlig' 0;
}

::selection {
  background: var(--ua-ink);
  color: var(--ua-bg);
}

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

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

button {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}

button:disabled {
  cursor: not-allowed;
}

fieldset {
  border: 0;
  padding: 0;
  min-inline-size: auto;
}

::placeholder {
  color: var(--ua-text-faint);
  opacity: 1;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--ua-line-soft);
}

/* ======================= Typography ======================= */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-family: var(--ua-font-display);
  font-weight: 400;
  line-height: 1.18;
  color: var(--ua-text-strong);
}

h1,
h2,
h3 {
  text-wrap: balance;
}

/* The body face is hairline — emphasis means a step up, never faux bold. */
strong,
b {
  font-weight: 400;
}

p,
ul,
ol,
dl {
  margin: 0 0 var(--ua-s4);
}

p:last-child,
ul:last-child,
ol:last-child,
dl:last-child {
  margin-bottom: 0;
}

ul,
ol {
  padding-left: 1.2rem;
}

a {
  color: currentColor;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: opacity var(--ua-fast) var(--ua-ease);
}

a:not(.ua-btn):hover {
  opacity: 0.7;
}

/* ======================= Focus ======================= */

:focus-visible {
  outline: 2px solid var(--ua-ink);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Dark-surface contexts swap the ring to the on-ink text color.
   Mark any ink-background region with .ua-on-ink to inherit this. */
.ua-on-ink :focus-visible,
.ua-on-ink:focus-visible,
.lg-photo :focus-visible {
  outline-color: var(--ua-text-on-ink);
}

/* The router focuses #app after navigation — no ring on the page itself. */
#app:focus,
#app:focus-visible {
  outline: none;
}

/* ======================= Layout primitives ======================= */

.ua-container {
  width: 100%;
  max-width: var(--ua-container);
  padding-inline: clamp(1.25rem, 4vw, 3.5rem);
  margin-inline: auto;
}

.ua-eyebrow {
  display: block;
  margin: 0;
  font-family: var(--ua-font-body);
  font-size: var(--ua-fs-tiny);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: var(--ua-tracking-caps);
  color: var(--ua-text-muted);
}

.ua-display {
  font-family: var(--ua-font-display);
  font-weight: 400;
  letter-spacing: var(--ua-tracking-display);
  line-height: 1.15;
}

.ua-divider {
  display: block;
  height: 0;
  border: 0;
  border-top: 1px solid var(--ua-line-soft);
  margin: var(--ua-s5) 0;
}

/* ======================= Utilities ======================= */

.u-muted {
  color: var(--ua-text-muted);
}

.u-small {
  font-size: var(--ua-fs-small);
}

.u-flex {
  display: flex;
}

.u-flex-col {
  display: flex;
  flex-direction: column;
}

.u-aic {
  align-items: center;
}

.u-jcb {
  justify-content: space-between;
}

.u-gap-1 {
  gap: var(--ua-s2);
}

.u-gap-2 {
  gap: var(--ua-s4);
}

.u-gap-3 {
  gap: var(--ua-s5);
}

.u-mt-1 {
  margin-top: var(--ua-s2);
}

.u-mt-2 {
  margin-top: var(--ua-s4);
}

.u-mt-3 {
  margin-top: var(--ua-s6);
}

.u-mt-4 {
  margin-top: var(--ua-s7);
}

.u-hidden {
  display: none !important;
}

/* Visually hidden, available to assistive technology. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ======================= Skip link ======================= */

.ua-skip-link {
  position: fixed;
  top: -100%;
  left: var(--ua-s4);
  z-index: 1000;
  padding: 0.65rem 1.25rem;
  background: var(--ua-ink);
  color: var(--ua-text-on-ink);
  font-size: var(--ua-fs-small);
  letter-spacing: 0.05em;
  text-decoration: none;
  border-radius: var(--ua-radius-pill);
  box-shadow: var(--ua-shadow-pop);
}

.ua-skip-link:focus {
  top: var(--ua-s4);
}

.ua-skip-link:focus-visible {
  outline-color: var(--ua-text-on-ink);
}

/* ======================= Icons ======================= */

.ua-icon {
  display: inline-flex;
  flex: none;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
}

.ua-icon svg {
  width: 100%;
  height: 100%;
}

/* ======================= Image fallback ======================= */

.ua-img-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--ua-s2);
  min-height: 160px;
  padding: var(--ua-s5);
  background: var(--ua-bg-card);
  border: 1px dashed var(--ua-line);
  border-radius: var(--ua-radius);
  color: var(--ua-text-muted);
  font-size: var(--ua-fs-tiny);
  text-align: center;
}

.ua-img-fallback .ua-icon {
  width: 1.6em;
  height: 1.6em;
  color: var(--ua-text-faint);
}

/* ==========================================================================
   Login view (.lg-*)
   Split layout: form panel on the brand surface, full-bleed portfolio
   photo with an overlay quote. The studio's first impression — keep it calm.
   ========================================================================== */

.lg,
.lg-wrap {
  display: grid;
  grid-template-columns: minmax(420px, 5fr) minmax(0, 7fr);
  min-height: 100vh;
  min-height: 100svh;
}

/* ---- Form panel ---- */

.lg-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--ua-bg);
  padding: clamp(2rem, 6vh, 4rem) clamp(1.5rem, 5vw, 4rem);
}

.lg-panel > * {
  width: 100%;
  max-width: 26.5rem;
}

.lg-mark {
  width: 52px;
  height: 52px;
  max-width: 52px;
  min-height: 0;
  border-radius: 50%;
  margin-bottom: var(--ua-s5);
}

.lg-mark.ua-img-fallback {
  padding: 0;
  border-radius: 50%;
}

.lg-mark.ua-img-fallback span {
  display: none;
}

.lg-panel .ua-eyebrow {
  margin-bottom: var(--ua-s2);
}

.lg-panel h1 {
  font-size: var(--ua-fs-h1);
  letter-spacing: var(--ua-tracking-display);
  text-transform: uppercase;
  margin-bottom: var(--ua-s3);
}

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

.lg-form {
  margin-top: var(--ua-s5);
}

.lg-form > * + * {
  margin-top: var(--ua-s4);
}

.lg-form .ua-btn {
  width: 100%;
  justify-content: center;
}

.lg-error {
  color: var(--ua-status-danger);
  font-size: var(--ua-fs-small);
  font-weight: 400;
}

.lg-error:empty {
  margin: 0;
}

.lg-hint {
  margin-top: var(--ua-s4);
  font-size: var(--ua-fs-tiny);
  color: var(--ua-text-muted);
  text-align: center;
}

/* ---- Demo accounts panel ---- */

.lg-demo {
  margin-top: var(--ua-s6);
  padding: var(--ua-s4) var(--ua-s5);
}

.lg-demo .ua-eyebrow {
  margin-bottom: var(--ua-s2);
  padding-bottom: var(--ua-s2);
  border-bottom: 1px solid var(--ua-line-soft);
}

.lg-demo__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ua-s4);
  width: 100%;
  padding: var(--ua-s3) var(--ua-s2);
  margin-inline: calc(-1 * var(--ua-s2));
  border-radius: var(--ua-radius);
  font-weight: 200;
  color: var(--ua-text);
  transition: background-color var(--ua-fast) var(--ua-ease);
}

.lg-demo__row + .lg-demo__row {
  border-top: 1px solid var(--ua-line-soft);
}

.lg-demo__row:hover {
  background: var(--ua-bg-raised);
}

.lg-demo__row > :first-child {
  font-weight: 400;
}

.lg-demo__row > :last-child:not(:first-child) {
  flex: 0 1 auto;
  min-width: 0;
  text-align: right;
  font-size: var(--ua-fs-tiny);
  color: var(--ua-text-muted);
  letter-spacing: 0.03em;
}

.lg-demo__name {
  font-weight: 400;
}

.lg-demo__role {
  font-size: var(--ua-fs-tiny);
  color: var(--ua-text-muted);
}

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

.lg-footer {
  margin-top: var(--ua-s7);
  font-size: var(--ua-fs-tiny);
  color: var(--ua-text-muted);
  text-align: center;
}

/* ---- Photo panel ---- */

.lg-photo {
  position: relative;
  overflow: hidden;
  background: var(--ua-ink);
  color: var(--ua-text-on-ink);
}

.lg-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lg-photo .ua-img-fallback {
  position: absolute;
  inset: 0;
  min-height: 100%;
  border: 0;
  border-radius: 0;
  background: var(--ua-ink-soft);
  color: var(--ua-text-on-ink-muted);
}

.lg-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ua-overlay-dark);
}

.lg-photo figure,
.lg-photo .lg-photo__overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: clamp(1.5rem, 4vw, 3.5rem);
}

.lg-photo blockquote,
.lg-photo .lg-quote {
  font-family: var(--ua-font-display);
  font-size: clamp(1.5rem, 2.4vw, 2.25rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: var(--ua-tracking-display);
  color: var(--ua-text-on-ink);
}

.lg-photo figcaption,
.lg-photo .lg-caption {
  margin-top: var(--ua-s3);
  font-size: var(--ua-fs-tiny);
  text-transform: uppercase;
  letter-spacing: var(--ua-tracking-caps);
  color: var(--ua-text-on-ink-muted);
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .lg,
  .lg-wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .lg-photo {
    order: -1;
    height: 38vh;
  }

  .lg-panel {
    justify-content: flex-start;
    padding-top: clamp(2rem, 5vh, 3rem);
  }
}

@media (max-width: 600px) {
  .lg-photo {
    display: none;
  }
}

/* ---- Focus rings on dark surfaces stay visible ---- */

.ua-portal-header :focus-visible,
.lbx :focus-visible,
.lg-photo :focus-visible,
.sb-hero :focus-visible,
.toc-fab:focus-visible {
  outline-color: var(--ua-text-on-ink);
}

/* ======================= Motion preferences ======================= */

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