/* Asgard: one mobile-first stylesheet. Hop greens and pale-ale amber. */

:root {
  color-scheme: light dark;

  --bg: #eef0e4;
  --surface: #fafbf4;
  --ink: #121212;
  --muted: #5e6450;
  --line: #d5d9c4;
  --band: #3e5b2b;
  --band-ink: #eee9da;
  --active: #3e5b2b;
  --amber: #d9a021;
  --danger: #a3301f;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --measure: 40rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15180f;
    --surface: #1f2318;
    --ink: #eee9da;
    --muted: #a0a68e;
    --line: #343a29;
    --band: #263820;
    --band-ink: #eee9da;
    --active: #a9c97f;
    --amber: #e3ae36;
    --danger: #f08a75;
  }
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

a {
  color: var(--active);
}

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

/* App shell: header band, page content, navigation. */

.shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "header" "main" "nav";
  min-height: 100dvh;
}

.shell-header {
  grid-area: header;
  display: flex;
  align-items: center;
  padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-3) var(--space-3);
  background: var(--band);
  color: var(--band-ink);
}

.logo {
  display: block;
}

/* Sized by height: the band is built around a 32 px lockup. */
.logo img {
  display: block;
  width: auto;
  height: 2rem;
}

/* The way into settings: a cog at the band's far end, a full tap target that doesn't make the
   band taller than the logo does. */
.settings-link {
  position: relative;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-2)) calc(-1 * var(--space-2)) auto;
  color: var(--band-ink);
  opacity: 0.8;
}

.settings-link svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-link[aria-current="page"] {
  opacity: 1;
}

.settings-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset: auto var(--space-2) calc(-1 * var(--space-2));
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--amber);
}

.shell-main {
  grid-area: main;
  width: 100%;
  max-width: var(--measure);
  padding: var(--space-4) var(--space-3) var(--space-5);
}

.shell-main h1 {
  margin: 0 0 var(--space-3);
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* Bottom navigation: four equal tabs, the active one marked with an amber bar. */

.tabs {
  grid-area: nav;
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-height: 3.5rem;
  padding: var(--space-2) var(--space-1);
  color: var(--muted);
  font-size: 0.75rem;
  text-decoration: none;
}

.tab svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab[aria-current="page"] {
  color: var(--active);
  font-weight: 600;
}

.tab[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset: -1px 25% auto;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--amber);
}

@media (min-width: 48rem) {
  /* The header band spans the row and the navigation sits on top of it, so no seam shows. The
     last column keeps the settings cog clear of the tabs. */
  .shell {
    grid-template-columns: 1fr auto calc(3rem + var(--space-4));
    grid-template-rows: auto 1fr;
    grid-template-areas: none;
  }

  .shell-header {
    grid-area: 1 / 1 / 2 / -1;
    padding-inline: var(--space-4);
  }

  .shell-main {
    grid-area: 2 / 1 / 3 / -1;
    padding-inline: var(--space-4);
  }

  .tabs {
    grid-area: 1 / 2 / 2 / 3;
    position: static;
    grid-template-columns: repeat(4, auto);
    gap: var(--space-1);
    padding: 0;
    background: var(--band);
    border-top: 0;
  }

  .tab {
    flex-direction: row;
    gap: var(--space-2);
    min-height: 0;
    padding: var(--space-3);
    color: var(--band-ink);
    font-size: 0.9375rem;
    opacity: 0.8;
  }

  .tab svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .tab[aria-current="page"] {
    color: var(--band-ink);
    opacity: 1;
  }

  .tab[aria-current="page"]::before {
    inset: auto var(--space-3) 0;
    border-radius: 3px 3px 0 0;
  }
}

/* Placeholder content, and the pages shown outside the shell. */

.empty {
  max-width: 32rem;
  color: var(--muted);
}

.standalone {
  display: grid;
  place-content: center;
  min-height: 100dvh;
  padding: var(--space-4) var(--space-3);
}

.hero img {
  display: block;
  width: min(180px, 50vw);
  height: auto;
  margin-bottom: var(--space-3);
}

.standalone h1 {
  margin: 0 0 var(--space-2);
  font-size: 1.75rem;
  line-height: 1.2;
}

.standalone p {
  max-width: 28rem;
  margin: 0 0 var(--space-3);
  color: var(--muted);
}

.standalone .lead {
  color: var(--ink);
  font-size: 1.125rem;
}

/* Buttons and the status line beneath them. */

.button {
  justify-self: start;
  min-height: 3rem;
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: 0.5rem;
  background: var(--band);
  color: var(--band-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.standalone .status {
  min-height: 1.5em;
  margin-top: var(--space-3);
  color: var(--ink);
}

.status:empty {
  visibility: hidden;
}

/* The welcome and settings pages: their sections, the install and tour lists, and the
   placeholders for controls still to come. */

.welcome-section,
.settings-section {
  max-width: 28rem;
  margin-bottom: var(--space-4);
}

.welcome-section h2,
.settings-section h2 {
  margin: 0 0 var(--space-2);
  font-size: 1.125rem;
  line-height: 1.3;
}

.install,
.tour {
  margin: 0;
}

.install dt,
.tour dt {
  font-weight: 600;
}

.install dd,
.tour dd {
  margin: 0 0 var(--space-2);
  color: var(--muted);
}

.placeholder {
  padding: var(--space-3);
  border: 2px dashed var(--line);
  border-radius: 0.5rem;
  color: var(--muted);
}

/* Forms: a label, the field and its button on one row, and a note beneath. */

.name-form label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 600;
}

.field-row {
  display: flex;
  gap: var(--space-2);
}

.field-row input,
.field-row select {
  flex: 1;
  min-width: 0;
  min-height: 3rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.field-row input[aria-invalid="true"] {
  border-color: var(--danger);
}

.name-form .note {
  margin: var(--space-2) 0 0;
  font-size: 0.875rem;
}

.name-form .note.refused {
  color: var(--danger);
}

/* The passkey list in settings: each passkey's rename form with its delete button beneath,
   then the add button and the status line the passkey script writes to. */

.passkey-list {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
}

.passkey {
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
}

.passkey-rename label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--muted);
  font-size: 0.875rem;
}

.passkey-delete {
  margin-top: var(--space-2);
}

.passkeys .note {
  margin: var(--space-2) 0 0;
  font-size: 0.875rem;
}

.passkeys > .note {
  margin: 0 0 var(--space-3);
}

.passkeys .note:empty {
  display: none;
}

.passkeys .note.refused {
  color: var(--danger);
}

.button.quiet {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--danger);
}

.settings-section .lead-in {
  margin: 0 0 var(--space-2);
  color: var(--muted);
}

.settings-section .status {
  min-height: 1.5em;
  margin: var(--space-2) 0 0;
}

/* The admin page: the link just made with its copy button, then the open links, each with its
   revoke button beside it. */

a.button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.new-link {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.new-link label {
  display: block;
  margin-bottom: var(--space-2);
}

.new-link input {
  font-size: 0.875rem;
}

.admin-links .note {
  margin: var(--space-2) 0 0;
  font-size: 0.875rem;
}

.admin-links .note:empty {
  display: none;
}

.link-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.open-link {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
}

.open-link p {
  margin: 0;
}

.open-link .expires {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Finance: the Member's own Balance up top, the big "+ Expense" button, then the Crew's
   Balances and the latest entries. Owed is green, owes is red, Even is muted. */

.my-balance {
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.my-balance h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.balance-figure {
  margin: var(--space-1) 0 0;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.balance-says {
  margin: var(--space-1) 0 0;
  color: var(--muted);
}

.owed .balance-figure,
.owed .balance-amount {
  color: var(--active);
}

.owes .balance-figure,
.owes .balance-amount {
  color: var(--danger);
}

.even .balance-amount {
  color: var(--muted);
}

.button-large {
  width: 100%;
  min-height: 3.5rem;
  justify-content: center;
  font-size: 1.125rem;
}

.finance-actions {
  margin-bottom: var(--space-5);
}

.finance-section {
  margin-bottom: var(--space-5);
}

.finance-section h2 {
  margin: 0 0 var(--space-2);
  font-size: 1.125rem;
  line-height: 1.3;
}

.finance-section .lead-in {
  margin: 0;
  color: var(--muted);
}

.balance-list,
.entry-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.balance-list li,
.entry {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
}

.balance-amount,
.entry-amount {
  flex: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.entry-main {
  display: grid;
  min-width: 0;
}

.entry-what {
  overflow-wrap: anywhere;
}

.entry-meta {
  color: var(--muted);
  font-size: 0.875rem;
}

/* The Expense form: one field under another, each with its problem beneath it. The Expense
   date folds away while it is today. */

.entry-form {
  display: grid;
  gap: var(--space-3);
  max-width: 28rem;
}

.entry-form label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 600;
}

.entry-form input,
.entry-form select {
  width: 100%;
  min-height: 3rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.entry-form [aria-invalid="true"] {
  border-color: var(--danger);
}

.field-problem {
  margin: var(--space-1) 0 0;
  color: var(--danger);
  font-size: 0.875rem;
}

.expense-date summary {
  min-height: 2.75rem;
  padding: var(--space-2) 0;
  color: var(--active);
  cursor: pointer;
}

.expense-date[open] summary {
  margin-bottom: var(--space-1);
}
