/*
 * accounts.crossmap.com stylesheet.
 *
 * ONE sheet for all widths. The legacy shipped two full stylesheets --
 * public/css/desktop.css (190KB) and mobile.css (181KB) -- selected by sniffing
 * the user agent server-side and rendering one of two parallel view trees. The
 * two sheets styled the SAME class names differently, which is what media
 * queries are for.
 *
 * Values here are lifted from the legacy desktop.css so the pages look like
 * they did: the box geometry, the Crossmap red (#F01313), Roboto headings and
 * the card shadow are all the originals. What is gone is the ~370KB of rules
 * for a site-wide nav, search overlay, article grid and IE9 fallbacks that
 * these nine pages never used.
 */

:root {
  --color-primary: #f01313;
  --color-primary-dark: #a70000;
  --color-text: #1a1a1a;
  --color-quiet: #6b7280;
  --color-border: #d7d7db;
  --color-bg: #f2f2f4;
  --color-surface: #fff;
  --color-error: #c0261c;
  --color-success: #107c41;
  --radius: 0.625rem;
  /* One source of truth for the content column; the header bar uses it too. */
  --page-width: 60rem;
  --shadow-card: 0 0.4375rem 1.25rem rgba(0, 0, 0, 0.1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: Helvetica, Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  overflow-wrap: break-word;
}

main {
  flex: 1 0 auto;
}

/* -- header / footer ------------------------------------------------------- */

/*
 * Two header treatments, deliberately.
 *
 * Signed OUT (.sso-header): just the logo, centred above the card. The page is
 * a single focused task and a nav bar would be furniture.
 *
 * Signed IN (.app-header): a real bar, because there is now an identity and a
 * way out, and those belong together. Its contents are bounded to the same
 * width as the page below -- the first version pinned "Sign out" to the
 * viewport corner with position:absolute, which on a wide monitor left it
 * stranded an inch from the screen edge and a foot from anything it related to.
 */
.sso-header {
  margin-bottom: 1.5rem;
  padding: 1.75rem 1rem 0;
  text-align: center;
}

.sso-header .logo,
.app-header .logo {
  width: 8.125rem;
  height: auto;
  display: block;
}

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.75rem;
}

.app-header-inner {
  width: var(--page-width);
  max-width: 92%;
  margin: 0 auto;
  min-height: 3.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Avatar + name + sign out, grouped so the action reads as belonging to the user. */
.app-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.app-user-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}

.app-user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-bg);
  flex: none;
}

/*
 * Quiet, not red. It was inheriting the primary colour and underline, which
 * made the single most destructive control on the page the loudest thing in
 * the header.
 */
.app-signout {
  font-size: 0.8125rem;
  text-decoration: none;
  color: var(--color-quiet);
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.18s, border-color 0.18s;
}

.app-signout:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.sso-footer {
  padding: 2rem 1rem;
  text-align: center;
}

/* -- the card ------------------------------------------------------------- */

.sso-box {
  width: 26.25rem;
  max-width: 90%;
  margin: 1.25rem auto 2.5rem;
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  background: var(--color-surface);
}

/* -- typography ----------------------------------------------------------- */

.hd2,
.hd3 {
  font-family: Roboto, Helvetica, Arial, sans-serif;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.hd2 { font-size: 1.25rem; }
.hd3 { font-size: 1.0625rem; }

.fz13 { font-size: 0.8125rem; }
.fz14 { font-size: 0.875rem; }

.quiet { color: var(--color-quiet); }
.center-align { text-align: center; }
.upper { text-transform: uppercase; }
.tdu { text-decoration: underline; }

a { color: inherit; }
.link-color,
a.link { color: var(--color-primary); transition: color 0.18s; }
.link-color:hover,
a.link:hover { color: var(--color-primary-dark); }

.sso-des { color: var(--color-quiet); }

/* -- spacing utilities (the legacy vocabulary, kept) ---------------------- */

.spacing-b-sm { margin-bottom: 0.5rem; }
.spacing-b-md { margin-bottom: 1rem; }
.spacing-b-re { margin-bottom: 1.25rem; }
.spacing-t-sm { margin-top: 0.5rem; }
.spacing-t-lg { margin-top: 1.5rem; }

/* -- forms ---------------------------------------------------------------- */

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

.form-ul > li + li { margin-top: 0.875rem; }

.l-justify {
  display: flex;
  justify-content: flex-end;
}

label { display: block; margin-bottom: 0.25rem; }

input[type="text"],
input[type="email"],
input[type="password"] {
  font: inherit;
  color: inherit;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  background: #fff;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

input:disabled {
  background: var(--color-bg);
  color: var(--color-quiet);
}

.input-block {
  display: block;
  width: 100%;
}

.button {
  display: inline-block;
  font: inherit;
  font-size: 0.875rem;
  text-align: center;
  text-decoration: none;
  padding: 0 0.625rem;
  height: 2.5rem;
  line-height: 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
}

.button.lg {
  height: 2.875rem;
  line-height: 2.875rem;
  font-size: 0.9375rem;
}

.button.primary {
  color: #fff;
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.button.primary:hover { background: var(--color-primary-dark); }
.button:disabled { opacity: 0.6; cursor: default; }

/* Two stacked buttons on the consent screen. */
.sso-box form + form { margin-top: 0.5rem; }

/* -- messages ------------------------------------------------------------- */

.messages { margin-bottom: 0.75rem; }

.message-error,
.message-success {
  display: block;
  font-size: 0.875rem;
  margin-top: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.375rem;
}

.message-error {
  color: var(--color-error);
  background: #fdeceb;
}

.message-success {
  color: var(--color-success);
  background: #e9f6ee;
}

/* -- profile -------------------------------------------------------------- */

.profile-layout {
  width: var(--page-width);
  max-width: 92%;
  margin: 0 auto 3rem;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 15rem 1fr;
  align-items: start;
}

.profile-nav {
  padding: 0.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  background: var(--color-surface);
}

.profile-nav a {
  display: block;
  padding: 0.625rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.profile-nav a:hover {
  background: var(--color-bg);
}

/*
 * Mark where you are. Without it the four items were indistinguishable and the
 * nav told you nothing about the page you were already on.
 */
.profile-nav a[aria-current="page"] {
  background: var(--color-bg);
  color: var(--color-primary);
  font-weight: 500;
}

.profile-panel {
  padding: 1.75rem 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  background: var(--color-surface);
}

/* A rule under the page title, so the heading reads as a header. */
.profile-panel > h1 {
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.profile-avatar {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-bg);
  flex: none;
}

/*
 * Two columns on a wide panel: the labels were stacked above their values in a
 * tall ragged list with acres of space beside it.
 */
.profile-fields {
  margin: 0;
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
}

.profile-fields dt { margin: 0; }
.profile-fields dd { margin: 0; }

/* A divider above the actions, so the button is clearly a page action. */
.profile-actions {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.badge {
  display: inline-block;
  margin-left: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-quiet);
}

.consent-scopes li {
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--color-border);
}

/*
 * Accessible label hiding. The sign-in and sign-up forms use placeholders for
 * the visual design, and a placeholder is not a label -- screen readers need
 * the real thing.
 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* -- narrow screens ------------------------------------------------------- */
/*
 * This replaces the entire separate mobile.css and the user-agent sniffing
 * that chose it. The card already sizes itself with max-width: 90%; what
 * genuinely differs is the profile side-nav, which stacks.
 */
@media (max-width: 48rem) {
  .profile-layout {
    grid-template-columns: 1fr;
    max-width: 100%;
    padding: 0 1rem;
    gap: 1rem;
  }

  /* The side nav becomes a horizontal row of pills above the panel. */
  .profile-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .profile-nav a {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .profile-panel { padding: 1.25rem; }

  /* Labels above values once there is no room for two columns. */
  .profile-fields { grid-template-columns: 1fr; gap: 0.25rem; }
  .profile-fields dt:not(:first-child) { margin-top: 0.75rem; }

  .app-header-inner { max-width: 100%; padding: 0 1rem; }
  .app-user-name { display: none; }

  .sso-box {
    margin-top: 0.5rem;
    padding: 1.25rem;
  }

  .profile-identity { gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
