/* Dark by default, light when the system asks for it, and either when the
   visitor picks one with the toggle (theme.js puts data-theme on <html>). */
:root {
  color-scheme: dark;
  --background: #131312;
  --text: #ecebe6;
  --muted: #8f8e88;
  --surface: #1a1a19;
  --field: #1a1a19;
  --line: #2a2a28;
  --line-strong: #3a3a36;
  --shadow: rgb(0 0 0 / 35%);
  --quiet: #858480;
  --live: #5bd18b;
  --denied: #e8a598;
  --sun: block;
  --moon: none;
  --button: #2a2a28;
  --button-hover: #323230;
  --button-line: #3a3a36;
  --button-text: #ecebe6;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --background: #f5f4ef;
    --text: #161615;
    --muted: #66655f;
    --surface: #ffffff;
    --field: #f5f4ef;
    --line: #e2e0d9;
    --line-strong: #cfcdc5;
    --shadow: rgb(0 0 0 / 8%);
    --quiet: #72706a;
    --live: #1f9d55;
    --denied: #b3412e;
    --sun: none;
    --moon: block;
    --button: #f3f2ed;
    --button-hover: #ebeae4;
    --button-line: #cfcdc5;
    --button-text: #161615;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #f5f4ef;
  --text: #161615;
  --muted: #66655f;
  --surface: #ffffff;
  --field: #f5f4ef;
  --line: #e2e0d9;
  --line-strong: #cfcdc5;
  --shadow: rgb(0 0 0 / 8%);
  --quiet: #72706a;
  --live: #1f9d55;
  --denied: #b3412e;
  --sun: none;
  --moon: block;
  --button: #f3f2ed;
  --button-hover: #ebeae4;
  --button-line: #cfcdc5;
  --button-text: #161615;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  /* Sit a little above the middle, where the eye expects the centre. */
  grid-template-rows: 1fr auto 1.35fr;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  grid-row: 2;
  width: min(100% - 48px, 32rem);
  margin-inline: auto;
}

h1 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.012em;
}

a {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  transition: color 160ms ease;
}

a:hover,
a:focus-visible {
  color: var(--text);
}

a:focus-visible {
  outline: 1px solid var(--muted);
  outline-offset: 2px;
}

/* Pages of running text, like /privacy. */
.text p {
  margin: 0 0 14px;
  color: var(--muted);
}

/* The /gtm sign-in card. */
.card {
  width: min(100% - 32px, 360px);
  padding: 36px 32px 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 24px 64px var(--shadow);
  text-align: center;
}

.card h1 {
  margin-bottom: 6px;
}

/* With no note under the heading, the card's first control keeps its distance. */
.card h1 + .button,
.card h1 + .or,
.card h1 + .form {
  margin-top: 24px;
}

.note {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.note + .note {
  margin-top: -16px;
}

/* A quiet line at the foot of a card. */
.aside {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.aside a {
  display: inline;
  color: var(--text);
}

/* The address a code went to, on a line of its own. */
.note .who {
  display: block;
  color: var(--text);
}

.denied {
  color: var(--denied);
}

/* Under a card: the way back to tahseenomar.com, and the theme toggle. */
.below {
  grid-row: 3;
  align-self: start;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 8px;
}

/* A thumb-sized target that sits 20px under the card, as if unpadded. */
.back {
  margin: 0 -16px;
  padding: 12px 16px;
  font-size: 13px;
}

/* The end of a text page: "← Home", and the theme toggle. */
.foot {
  display: flex;
  align-items: center;
  gap: 28px;
}

/* "← Home" at the end of a text page: a thumb-sized target, without moving it. */
.home {
  margin: -11px -14px;
  padding: 11px 14px;
}

/* The card's one button, in Google's own sign-in button style for each mode. */
.button {
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  border: 1px solid var(--button-line);
  background: var(--button);
  color: var(--button-text);
  font-size: 14px;
  font-weight: 500;
  transition: background 160ms ease;
}

.button:hover,
.button:focus-visible {
  color: var(--button-text);
  background: var(--button-hover);
}

/* The email sign-in: a divider, then the address or code and its button. */
.or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--quiet);
  font-size: 12px;
}

.or::before,
.or::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.form {
  display: grid;
  gap: 10px;
  margin: 0;
}

.field {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: center;
  appearance: none;
}

.field::placeholder {
  color: var(--quiet);
}

.field:focus {
  border-color: var(--muted);
  outline: none;
}

.code {
  height: 56px;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
}

.code::placeholder {
  font-size: 15px;
  letter-spacing: 0.5em;
}

button.button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.switch {
  margin-top: 18px;
  font-size: 13px;
}

/* Under the code: send a new one, or start over with another address. */
.switches {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 20px 0 0;
}

.switches .switch {
  margin: 0;
}

.g {
  width: 18px;
  height: 18px;
}

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--quiet);
}

.dot.live {
  background: var(--live);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 15%, transparent);
}

/* Shown on the signed-in page until the first map is published. */
.soon {
  padding: 18px 16px;
  border: 1px dashed var(--line-strong);
}

.soon .status {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14px;
}

.soon .note {
  margin: 0;
}

.signout {
  display: flex;
  justify-content: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

/* Light or dark, beside each page's other links; theme.js shows it and
   remembers the choice. A thumb-sized target that takes only its icon's room. */
.theme {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -14px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease;
}

.theme[hidden] {
  display: none;
}

.theme:hover,
.theme:focus-visible {
  color: var(--text);
}

.theme:focus-visible {
  outline: 1px solid var(--muted);
  outline-offset: -6px;
}

.theme svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.sun {
  display: var(--sun);
}

.moon {
  display: var(--moon);
}

nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* A bigger tap target without moving anything. */
nav a {
  padding: 10px;
  margin: -10px;
}

.logo {
  fill: currentColor;
}

/* LinkedIn's filled square reads heavier than the open X, so it is drawn smaller. */
.linkedin {
  width: 15px;
  height: 15px;
}

.x {
  width: 16px;
  height: 16px;
}

/* The name slides out of its logo on hover, pushing the next logo along. */
.label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 0;
  margin-left: 0;
  overflow: hidden;
  opacity: 0;
  font-size: 13px;
  white-space: nowrap;
  transition: max-width 240ms ease, margin-left 240ms ease, opacity 200ms ease;
}

a:hover .label,
a:focus-visible .label,
.labelled .label {
  max-width: 6rem;
  margin-left: 8px;
  opacity: 1;
}

/* Comparison page /2 shows the names all the time. */
.labelled {
  gap: 26px;
}

.arrow {
  width: 8px;
  height: 8px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 480px) {
  .linkedin {
    width: 17px;
    height: 17px;
  }

  .x {
    width: 18px;
    height: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  a,
  .theme,
  .label {
    transition: none;
  }
}

/* Signed-in pages: your apps, and admin. Wider cards, left-aligned. */
.card.wide {
  width: min(100% - 32px, 640px);
  text-align: left;
}

.card.wide h1 {
  margin-bottom: 4px;
}

.card.wide h2 {
  margin: 32px 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line-strong);
  background: var(--field);
  color: var(--text);
  transition: border-color 160ms ease;
}

a.tile:hover,
a.tile:focus-visible {
  border-color: var(--muted);
  color: var(--text);
}

.tile-name {
  font-size: 15px;
  font-weight: 500;
}

.tile-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tile-open {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.tile.waiting {
  border-style: dashed;
}

.card-links {
  display: flex;
  gap: 20px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.card:not(.wide) .card-links {
  justify-content: center;
}

.note a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Admin: one row per person; "Manage" opens their settings beneath it. Every
   panel shares one grid, a label column and a control column, so the labels
   line up with the names above them and the controls with each other. */
.admin .note {
  margin-bottom: 24px;
}

.notice {
  margin: 0 0 16px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--muted);
  font-size: 13px;
}

.notice.denied {
  border-left-color: var(--denied);
  color: var(--denied);
}

.panel .notice {
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.btn:hover {
  border-color: var(--muted);
}

.btn.primary {
  border-color: var(--button-line);
  background: var(--button);
  color: var(--button-text);
  font-weight: 500;
}

.btn.primary:hover {
  background: var(--button-hover);
}

.btn.danger {
  color: var(--denied);
}

.btn.quiet-danger {
  padding: 0 0 0 8px;
  border-color: transparent;
  color: var(--muted);
}

.btn.quiet-danger:hover {
  border-color: transparent;
  color: var(--denied);
}

/* A keyboard user always sees where they are. Text fields show it with their border. */
:where(button, summary, select, input[type="checkbox"]):focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 2px;
}

details > summary {
  list-style: none;
  cursor: pointer;
}

details > summary::-webkit-details-marker {
  display: none;
}

details:not([open]) > summary .open-label,
details[open] > summary .closed-label {
  display: none;
}

.add {
  margin-bottom: 24px;
}

.add > summary {
  width: max-content;
}

/* Open, the button reads "Cancel" and steps back, leaving "Add person" the one loud button. */
.add[open] > summary {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-weight: 400;
}

.people {
  border-top: 1px solid var(--line);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 128px 56px;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.row.head {
  padding: 10px 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.person[open] > summary.row {
  border-bottom-color: transparent;
}

.who {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.who-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.who-mail {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-apps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.row-apps .quiet {
  font-size: 12px;
}

.row-seen {
  color: var(--muted);
  font-size: 12px;
}

.row-manage {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
}

.person > summary.row:hover .row-manage,
.person[open] > summary.row .row-manage {
  color: var(--text);
}

.person.off .who,
.person.off .row-apps {
  opacity: 0.55;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill.off {
  border-color: var(--denied);
  color: var(--denied);
}

.panel {
  margin: 0;
  padding: 4px 0 24px;
  border-bottom: 1px solid var(--line);
}

.add > .panel {
  padding: 12px 0 8px;
  border-bottom: 0;
}

.setting {
  display: grid;
  grid-template-columns: 104px minmax(0, 448px);
  align-items: start;
  gap: 0 24px;
  padding: 8px 0;
}

.setting-label {
  padding-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.setting-control {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.setting-control > .btn {
  justify-self: start;
}

.setting.access {
  margin-top: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.inline form {
  margin: 0;
}

/* Admin fields sit on the card, not sunk into it. */
.field.slim,
.select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
}

.select {
  padding: 0 6px;
}

.addresses {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.address {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px 72px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.address-email {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.address form {
  justify-self: end;
  margin: 0;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  min-height: 36px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

/* "Remove person": a quiet link-like button that opens its own confirmation. */
.confirm > summary.btn {
  width: max-content;
  padding: 0;
}

.confirm[open] > summary {
  color: var(--text);
}

.confirm-body {
  margin-top: 8px;
  padding: 12px 0 0 12px;
  border-left: 2px solid var(--denied);
  font-size: 13px;
}

.confirm-body p {
  margin: 0 0 10px;
  color: var(--muted);
}

.activity {
  margin-top: 24px;
}

.activity > summary {
  width: max-content;
  padding: 10px 0;
  margin: -10px 0;
  color: var(--muted);
  font-size: 12px;
}

.activity > summary::before {
  content: "+ ";
}

.activity[open] > summary::before {
  content: "− ";
}

.log {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
}

.log li {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
}

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

@media (max-width: 560px) {
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
  }

  .row.head {
    display: none;
  }

  .row-apps,
  .row-seen {
    grid-column: 1;
  }

  .row-manage {
    grid-column: 2;
    grid-row: 1;
  }

  /* The column heads are hidden here, so the date says what it is. */
  .row-seen::before {
    content: "Last signed in · ";
  }

  .setting {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .setting-label {
    padding-top: 0;
  }

  .setting-label:empty {
    display: none;
  }

  .address {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .address-email {
    grid-column: 1 / -1;
  }

  .btn,
  .field.slim,
  .select {
    height: 40px;
  }

  .log li {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  /* Small text links get a thumb-sized target without moving. */
  .card-links a,
  .card-links button.link,
  .switches .switch,
  .activity > summary {
    padding: 12px 0;
    margin: -12px 0;
  }
}

/* A form button that reads as a link, for sign-out among links. */
button.link.plain {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

button.link.plain:hover,
button.link.plain:focus-visible {
  color: var(--text);
}

/* The homepage: the name large on one left edge with its two links beneath,
   and the way in and the theme toggle in a quiet footer at the bottom. */
body.home {
  grid-template-rows: 1fr auto 1fr auto;
}

.home main {
  width: min(100% - 48px, 44rem);
}

.home h1 {
  margin: 0 0 24px;
  font-size: clamp(34px, 9vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.home .links {
  gap: 28px;
}

.home .links a {
  gap: 5px;
  padding: 10px 0;
  margin: -10px 0;
  color: var(--text);
  font-size: 15px;
}

.home .links a:hover,
.home .links a:focus-visible {
  color: var(--muted);
}

.home .links .arrow {
  width: 9px;
  height: 9px;
}

.home footer {
  grid-row: 4;
  display: flex;
  align-items: center;
  gap: 20px;
  width: min(100% - 48px, 44rem);
  margin-inline: auto;
  padding: 20px 0 28px;
  border-top: 1px solid var(--line);
}

/* The homepage's way in, quiet beside the theme toggle. */
.signin {
  padding: 10px 0;
  margin: -10px 0;
  font-size: 13px;
}

input[type="checkbox"] {
  accent-color: var(--text);
}

.row-apps .quiet {
  font-size: 12px;
}
