/* --------------------------------------------------------------------------
   login.gnash.xyz theme — standalone
   Hosted at https://assets.gnash.xyz/web/login/styles.css. Link it from the
   login server's pages, after their inline <style>:
     <link rel="stylesheet" href="https://assets.gnash.xyz/web/login/styles.css">

   Self-contained: carries its own copy of the gnash.xyz tokens (palette,
   type scale, spacing) from the homepage's assets/css/main.css. Keep the
   "Shared with main.css" block in sync when the homepage changes.

   Styles the login server's bare markup (body > h1, form, p…) by element,
   since those pages carry no classes of their own. Everything sits in
   cascade layers so the server's unlayered inline rules (e.g. the
   .needs-signup / .needs-forgot toggles) always win.

   Fonts load from gnash.xyz, which serves them with
   `Access-Control-Allow-Origin: *`.
   -------------------------------------------------------------------------- */
@layer reset, tokens, base, layout, components, utilities;

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("https://gnash.xyz/assets/fonts/inter-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("https://gnash.xyz/assets/fonts/inter-latin-400-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; padding: 0; }
  a { color: inherit; }
  h1, h2, h3 { font: inherit; }
}

/* --- Shared with main.css (subset the login page uses) ------------------- */
@layer tokens {
  :root {
    color-scheme: light dark;

    --color-paper: light-dark(#E7E5E4, #292524);
    --color-ink:   light-dark(#292524, #E7E5E4);

    --color-bg:           var(--color-paper);
    --color-fg:           var(--color-ink);
    --color-fg-muted:     color-mix(in srgb, var(--color-ink) 78.8%, transparent);
    --color-fg-subtle:    color-mix(in srgb, var(--color-ink) 56.9%, transparent);
    --color-border:       color-mix(in srgb, var(--color-ink) 10.2%, transparent);
    --color-border-hover: var(--color-fg);
    --color-focus:        var(--color-fg);

    --font-sans:  "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-serif: "Baskerville", ui-serif, serif;

    --root-size: 11pt;

    --text-section: 3em;
    --text-body:    1em;
    --text-small:   0.75em;

    --tracking-section: -0.075rem;
    --tracking-body:     0.025rem;
    --tracking-ui:      -0.025rem;
    --tracking-caps:     0.125rem;

    --leading-tight: 1;
    --leading-body:  1.625;
    --leading-small: 1.75;

    --page-pad-block:  7rem;
    --page-pad-inline: 3.5rem;

    --space-major:  3.5rem;
    --space-stack:  1.75rem;
    --space-tight:  1rem;
    --space-para:   1.5rem;
    --space-action: 2rem;

    --radius:         0.25rem;
    --border-width:   1px;
    --duration-ui:    0.25s;
    --duration-intro: 1s;
    --ease:           ease;

    --button-hover-grow: 0.25rem;
  }

  @media (width > 1680px)         { :root { --root-size: 15pt; } }
  @media (736px < width <= 980px) { :root { --root-size: 9pt; } }

  @media (width <= 736px) {
    :root {
      --page-pad-block:  3rem;
      --page-pad-inline: 2rem;
      --text-section:    2em;
      --tracking-section: -0.065625rem;
      --tracking-body:     0.021875rem;
      --tracking-caps:     0.109375rem;
      --space-major:  2.625rem;
      --space-action: 1.5rem;
    }
  }

  @media (width <= 480px) { :root { --space-stack: 1.53125rem; } }

  @media (width <= 360px) {
    :root {
      --page-pad-block:  2.25rem;
      --page-pad-inline: 1.5rem;
      --space-stack: 1.3125rem;
      --space-tight: 0.875rem;
    }
  }
}

@layer base {
  html {
    font-size: var(--root-size);
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
  }

  body {
    min-block-size: 100dvh;
    min-inline-size: 320px;
    background-color: var(--color-bg);
    color: var(--color-fg);
    font-family: var(--font-sans);
    font-weight: 400;
    line-height: var(--leading-tight);
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
  }

  a:focus-visible {
    outline: var(--border-width) solid var(--color-focus);
    outline-offset: 2px;
  }

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

@layer utilities {
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      transition-duration: 0.01ms !important;
    }
  }
}

@keyframes page-intro {
  from { opacity: 0; }
}

/* --- Login-specific ------------------------------------------------------ */

@layer tokens {
  :root {
    --login-width: 26rem;
    --mark-size: 3.25rem;
    --field-gap: 0.625rem;   /* label → input */
    --color-danger: light-dark(#b91c1c, #fca5a5);

    /* The homepage favicon's "G", used as a cut-out mask (see body::before). */
    --mark-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M212.517 402.6C191.184 402.6 172.784 398.467 157.317 390.2C142.117 381.667 130.251 369.667 121.717 354.2C113.451 338.467 109.317 319.667 109.317 297.8C109.317 278.067 112.517 259 118.917 240.6C125.584 221.933 134.517 204.6 145.717 188.6C157.184 172.333 170.384 158.2 185.317 146.2C200.517 134.2 216.917 124.733 234.517 117.8C252.117 110.867 270.117 107.4 288.517 107.4C297.851 107.4 306.517 108.467 314.517 110.6C322.784 112.733 331.717 116.2 341.317 121C347.717 124.2 352.117 126.333 354.517 127.4C357.184 128.2 359.717 128.6 362.117 128.6C368.784 128.6 373.851 124.333 377.317 115.8H390.117L373.717 159.8L358.917 207H345.717C347.317 189.4 346.117 174.467 342.117 162.2C338.117 149.667 331.851 140.067 323.317 133.4C314.784 126.733 304.117 123.4 291.317 123.4C278.517 123.4 265.717 126.733 252.917 133.4C240.384 140.067 228.517 149.4 217.317 161.4C206.384 173.133 196.651 186.733 188.117 202.2C179.584 217.667 172.784 234.2 167.717 251.8C162.917 269.133 160.517 286.733 160.517 304.6C160.517 330.467 165.851 350.6 176.517 365C187.451 379.4 202.651 386.6 222.117 386.6C233.584 386.6 244.517 384.333 254.917 379.8C265.584 375.267 274.784 369.133 282.517 361.4C290.517 353.667 295.984 345 298.917 335.4L302.517 325C305.984 313.8 306.384 305.933 303.717 301.4C301.317 296.6 295.051 293.8 284.917 293L268.117 291.4L272.117 278.6L336.517 280.2L398.117 278.6L394.117 291.4L381.317 292.6C364.517 294.467 353.584 303.667 348.517 320.2L344.517 332.6C342.117 340.6 341.051 347.667 341.317 353.8C341.584 359.933 343.317 367.4 346.517 376.2L333.317 386.2C330.117 380.867 326.784 377 323.317 374.6C319.851 372.2 316.117 371 312.117 371C308.651 371 305.051 371.667 301.317 373C297.851 374.333 291.584 377.533 282.517 382.6C269.717 389.8 257.851 394.867 246.917 397.8C236.251 401 224.784 402.6 212.517 402.6Z'/%3E%3C/svg%3E");
  }
}

@layer layout {
  body {
    display: grid;
    /* minmax(0, …) so the column never grows to fit 26rem-wide children. */
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    padding: var(--page-pad-block) var(--page-pad-inline);
  }

  /* One narrow centred column. */
  body > * {
    inline-size: min(100%, var(--login-width));
    margin-inline: auto;
    animation: page-intro var(--duration-intro) var(--ease) both;
  }

  /* Brand mark: the favicon — an ink disc with the "G" punched out — drawn
     with masks so it inverts with the colour scheme. */
  body::before {
    content: "";
    justify-self: center;
    inline-size: min(100%, var(--login-width));
    block-size: var(--mark-size);
    margin-block-end: var(--space-stack);
    background:
      radial-gradient(circle closest-side, var(--color-fg) 99%, transparent)
      left / var(--mark-size) var(--mark-size) no-repeat;
    -webkit-mask:
      linear-gradient(#000 0 0),
      var(--mark-glyph) left / var(--mark-size) var(--mark-size) no-repeat;
    -webkit-mask-composite: xor;
    mask:
      linear-gradient(#000 0 0) exclude,
      var(--mark-glyph) left / var(--mark-size) var(--mark-size) no-repeat;
    animation: page-intro var(--duration-intro) var(--ease) both;
  }

  body > form { margin-block-start: var(--space-stack); }
  body > form > * + * { margin-block-start: var(--space-para); }
  body > form > button { margin-block-start: var(--space-action); }

  body > p { margin-block-start: var(--space-tight); }
  body > form + p,
  body > form + p[hidden] + p { margin-block-start: var(--space-major); }
}

@layer components {
  [hidden] { display: none !important; }

  /* --- Heading ------------------------------------------------------------ */
  h1 {
    font-family: var(--font-serif);
    font-size: var(--text-section);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-section);
    color: var(--color-fg);
  }

  /* --- Fields ------------------------------------------------------------- */
  /* Labels wrap their inputs: eyebrow-style caption above a bordered box. */
  label {
    display: grid;
    gap: var(--field-gap);
    color: var(--color-fg-subtle);
    font-size: var(--text-small);
    line-height: var(--leading-small);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  input:not([type="hidden"], [type="checkbox"], [type="radio"]),
  select,
  textarea {
    inline-size: 100%;
    padding: 0.625rem 1rem;
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-fg);
    font: inherit;
    font-size: calc(var(--text-body) / 0.75);  /* label is --text-small */
    line-height: 1.25rem;
    letter-spacing: var(--tracking-ui);
    text-transform: none;
    caret-color: var(--color-fg);
    transition: border-color var(--duration-ui) var(--ease);
  }

  input:hover,
  select:hover,
  textarea:hover { border-color: var(--color-fg-subtle); }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: var(--color-border-hover);
    outline: none;
  }

  /* After a failed submit attempt only, so empty fields aren't red on load. */
  input:user-invalid { border-color: var(--color-danger); }

  /* Keep browser autofill on-palette instead of yellow/blue. */
  input:autofill,
  input:-webkit-autofill {
    -webkit-text-fill-color: var(--color-fg);
    box-shadow: 0 0 0 100vmax var(--color-bg) inset;
    transition: background-color 600000s 0s, color 600000s 0s;
  }

  /* --- Button (mirrors .button.button--caps on the homepage) ------------- */
  button {
    --button-outset: 0px;

    position: relative;
    display: block;
    inline-size: 100%;
    padding: 0.5859375rem 0.9375rem;
    border: var(--border-width) solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-fg);
    font: inherit;
    font-size: var(--text-small);
    line-height: 1.171875rem;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    cursor: pointer;
  }

  button::before {
    content: "";
    position: absolute;
    inset: calc(-1 * (var(--border-width) + var(--button-outset)));
    border: var(--border-width) solid var(--color-border);
    border-radius: calc(var(--radius) + var(--button-outset));
    pointer-events: none;
    transition:
      inset var(--duration-ui) var(--ease),
      border-radius var(--duration-ui) var(--ease),
      border-color var(--duration-ui) var(--ease);
  }

  button:is(:hover, :focus-visible)::before { border-color: var(--color-border-hover); }
  button:focus-visible { outline: none; }

  @media (prefers-reduced-motion: no-preference) {
    button:is(:hover, :focus-visible) { --button-outset: var(--button-hover-grow); }
  }

  /* --- Messages ----------------------------------------------------------- */
  #error {
    padding: 0.75rem 1rem;
    border: var(--border-width) solid color-mix(in srgb, var(--color-danger) 45%, transparent);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--color-danger) 6%, transparent);
    color: var(--color-danger);
    font-size: var(--text-body);
    line-height: var(--leading-body);
    letter-spacing: var(--tracking-body);
  }

  /* --- Secondary links ---------------------------------------------------- */
  body > p {
    color: var(--color-fg-subtle);
    font-size: var(--text-body);
    line-height: var(--leading-body);
    letter-spacing: var(--tracking-body);
    text-align: center;
  }

  body > p a {
    color: var(--color-fg-muted);
    text-decoration-line: underline;
    text-decoration-color: var(--color-border);
    text-decoration-thickness: var(--border-width);
    text-underline-offset: 0.3em;
    transition:
      color var(--duration-ui) var(--ease),
      text-decoration-color var(--duration-ui) var(--ease);
  }

  body > p a:is(:hover, :focus-visible) {
    color: var(--color-fg);
    text-decoration-color: currentColor;
  }
}
