/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *
 *= require_tree .
 *= require_self
 */

/* Paper-and-ink design system — matched token-for-token to agent_app's
   app-kit.css (--ak-*) so the estate's two surfaces (this engine + the
   br3nt.au landing page) read as one system. Light by default, dark via
   prefers-color-scheme; --pk-* names are kept for engine-internal continuity. */
:root {
  --pk-bg: #f2efe7;
  --pk-card: #fcfaf4;
  --pk-text: #26231c;
  --pk-muted: #6c6759;
  --pk-faint: #a09a89;
  --pk-accent: #7c2d2d;
  --pk-error: #963c3c;
  --pk-success: #4e6231;
  --pk-border: #d6d0c0;
  --pk-radius: 10px;
  --pk-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --pk-sans: -apple-system, system-ui, sans-serif;
  --pk-serif: "Iowan Old Style", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --pk-bg: #1c1a16;
    --pk-card: #26231d;
    --pk-text: #ece7d8;
    --pk-muted: #b3ab98;
    --pk-faint: #7a7363;
    --pk-accent: #d98a8a;
    --pk-error: #e2908f;
    --pk-success: #9cc46a;
    --pk-border: #3a352c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 var(--pk-sans);
  background: var(--pk-bg);
  color: var(--pk-text);
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  gap: 1rem;
}

/* Wordmark header, present on every engine page (see the layout) — links back
   to the estate apex via PasskeyIdp.apex_host. Serif, ink, no underline: it
   reads as identity, not a nav link. */
.site-mark {
  font: 600 1rem var(--pk-serif);
  color: var(--pk-text);
  text-decoration: none;
  letter-spacing: .01em;
}
.site-mark:hover { color: var(--pk-accent); }

.auth-card {
  width: 100%;
  max-width: 24rem;
  background: var(--pk-card);
  border: 1px solid var(--pk-border);
  border-radius: var(--pk-radius);
  padding: 2rem;
}

.auth-card h1 { margin: 0 0 0.35rem; font: 650 1.5rem var(--pk-serif); }
.auth-card h2 {
  margin: 1.75rem 0 0.6rem; padding-top: 1.25rem; border-top: 1px solid var(--pk-border);
  font: 650 1.05rem var(--pk-serif); color: var(--pk-text);
}
/* First section in a long page (credentials/index) shouldn't carry a divider
   straight under the h1 — only sections after the first do. */
.auth-card h1 + h2, .auth-card h1 + details + h2 {
  margin-top: 1.5rem; padding-top: 0; border-top: 0;
}
.muted { color: var(--pk-muted); margin: 0 0 1.25rem; }

.auth-form { display: flex; flex-direction: column; gap: 0.6rem; }
.auth-form label {
  font: 600 .72rem var(--pk-mono); letter-spacing: .04em; text-transform: uppercase;
  color: var(--pk-muted);
}
.auth-form input[type="text"],
.auth-form input[type="number"] {
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--pk-border);
  background: var(--pk-bg);
  color: var(--pk-text);
  font: .95rem var(--pk-sans);
}
.auth-form input::placeholder { color: var(--pk-faint); }
.auth-form input:focus { outline: 2px solid var(--pk-accent); outline-offset: -1px; border-color: transparent; }

.primary {
  margin-top: 0.5rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--pk-accent);
  border-radius: 8px;
  background: var(--pk-accent);
  color: #fff;
  font: 600 .95rem var(--pk-sans);
  cursor: pointer;
  min-height: 2.4rem;
  transition: filter .12s;
}
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: 0.5; cursor: default; }

.auth-status { min-height: 1.25rem; margin: 0.25rem 0 0; font-size: 0.85rem; }
.auth-status[data-kind="error"] { color: var(--pk-error); }
.auth-status[data-kind="success"] { color: var(--pk-success); }
.auth-status[data-kind="info"] { color: var(--pk-muted); }

/* In-app-browser escape hatch (passkey-login / passkey-join) — sits above the
   button rather than replacing it, since some in-app webviews do work. */
.in-app-browser-notice {
  margin: 0 0 1rem; padding: 0.75rem 0.9rem;
  border: 1px solid var(--pk-error); border-radius: 8px;
  background: var(--pk-bg); color: var(--pk-text); font-size: 0.85rem;
}
.in-app-browser-notice p { margin: 0 0 0.6rem; }
.in-app-browser-link { display: flex; gap: 0.4rem; }
.in-app-browser-link input[type="text"] {
  flex: 1; min-width: 0; padding: 0.4rem 0.55rem; border-radius: 7px;
  border: 1px solid var(--pk-border); background: var(--pk-card); color: var(--pk-text);
  font: .8rem var(--pk-mono);
}

.credential-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.credential-list li {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--pk-border);
}
.credential-list .muted {
  margin: 0; display: block;
  font: 600 .68rem var(--pk-mono); letter-spacing: .03em; text-transform: uppercase; color: var(--pk-muted);
}
.credential-list .link-button { margin-left: auto; }
.credential-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.rename { padding-bottom: 0.7rem; border-bottom: 1px solid var(--pk-border); }
.rename summary {
  font: 600 .72rem var(--pk-mono); letter-spacing: .04em; text-transform: uppercase;
  color: var(--pk-muted); cursor: pointer; list-style: none;
}
.rename summary::-webkit-details-marker { display: none; }
.rename-form {
  display: flex; gap: 0.4rem; align-items: center; margin: 0.5rem 0 0;
}
.rename-form input[type="text"] {
  flex: 1; padding: 0.4rem 0.55rem; font: .85rem var(--pk-sans);
  background: var(--pk-bg); border: 1px solid var(--pk-border); border-radius: 7px; color: var(--pk-text);
}

/* Secondary action, ak-btn shape: outlined card, not a bare text link — used
   for Remove / rename Save / Sign out / Close now. */
.link-button {
  background: var(--pk-card); border: 1px solid var(--pk-border); color: var(--pk-text);
  cursor: pointer; font: 600 .78rem var(--pk-sans); padding: .35rem .7rem; border-radius: 7px;
  transition: border-color .12s;
}
.link-button:hover { border-color: var(--pk-muted); }

.links { margin-top: 1.5rem; font-size: 0.85rem; color: var(--pk-muted); }
.links a { color: var(--pk-accent); text-decoration: none; }
.links a:hover { text-decoration: underline; }

.primary-link { display: inline-block; text-align: center; text-decoration: none; }
.totp-secret {
  display: inline-block; margin-top: 0.4rem; padding: 0.4rem 0.6rem;
  background: var(--pk-bg); border: 1px solid var(--pk-border); border-radius: 7px;
  font: .9rem var(--pk-mono); letter-spacing: .03em; word-break: break-all; color: var(--pk-text);
}
.flash {
  max-width: 24rem; margin: 0 auto 1rem; padding: 0.6rem 0.9rem;
  border-radius: 8px; font-size: 0.85rem; background: var(--pk-card); border: 1px solid var(--pk-border);
}
.flash-notice { color: var(--pk-success); border-color: var(--pk-success); }
.flash-alert { color: var(--pk-error); border-color: var(--pk-error); }

.event-list { list-style: none; padding: 0; margin: 0; }
.event-list li { padding: 0.7rem 0; border-bottom: 1px solid var(--pk-border); }
.event-list .muted {
  font: 600 .68rem var(--pk-mono); letter-spacing: .03em; text-transform: uppercase; color: var(--pk-muted);
}

/* Self-contained QR generator draws a fixed black-on-white SVG (public/qr/qr.js)
   regardless of theme, for scannability — this just gives it a paper mount. */
.qr-code {
  display: inline-block; padding: .6rem; background: #fff; border: 1px solid var(--pk-border);
  border-radius: 8px; margin: .5rem 0 1rem;
}

/* App checkboxes as a wrapping row of labelled pills, used on the app_accesses
   and new-invitation admin pages so a long app list wraps instead of stacking
   bare inputs down the card. Reset back to normal case/weight: these are app
   slugs, not form micro-labels. */
.app-checkboxes { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0.6rem 0; }
.app-checkboxes label {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font: .85rem var(--pk-sans); text-transform: none; letter-spacing: normal; color: var(--pk-text);
}

.auth-form fieldset { border: 1px solid var(--pk-border); border-radius: 8px; padding: 0.85rem 0.9rem; margin: 0; }
.auth-form legend {
  padding: 0 0.4rem; font: 600 .72rem var(--pk-mono); letter-spacing: .04em;
  text-transform: uppercase; color: var(--pk-muted);
}

/* Admin: app access — one block per user. */
.access-list { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.access-row { padding: 1rem 0; border-bottom: 1px solid var(--pk-border); }
.access-row .primary { margin-top: 0.35rem; }
.access-row .muted {
  font: 600 .68rem var(--pk-mono); letter-spacing: .03em; text-transform: uppercase; color: var(--pk-muted);
}

/* Admin: invitations */
.invite-url {
  display: block; width: 100%; margin: 0 0 1.25rem; padding: 0.6rem 0.7rem;
  border-radius: 8px; border: 1px solid var(--pk-border);
  background: var(--pk-bg); color: var(--pk-text); font: .82rem var(--pk-mono);
}
.invitation-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.invitation-list li { padding: 0.75rem 0; border-bottom: 1px solid var(--pk-border); }
.invitation-list .muted {
  display: block; margin-top: 0.2rem;
  font: 600 .68rem var(--pk-mono); letter-spacing: .03em; text-transform: uppercase; color: var(--pk-muted);
}

/* Admin: entitlements — one card per account, one explained row per feature.
   Unlike app_accesses' wrapping pill grid, each entitlement earns a full row so
   its title, description, and grant status all fit and read on a phone (~400px).
   Row wraps to two lines only when it must: [☑ title ........ status] then the
   description spans the full width beneath — no floating source tags, no crowding. */
.entitlement-card { padding: 1.1rem 0; }
.entitlement-card .username { display: block; margin-bottom: 0.3rem; }
.entitlement-rows { margin: 0.2rem 0 0.6rem; }
.entitlement-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.6rem;
  padding: 0.6rem 0; border-top: 1px solid var(--pk-border);
}
.entitlement-main {
  flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: baseline; gap: 0.45rem;
  font: .92rem var(--pk-sans); text-transform: none; letter-spacing: normal; color: var(--pk-text);
  cursor: pointer;
}
.entitlement-main input[type="checkbox"] { flex: 0 0 auto; margin: 0; }
.entitlement-title { font-weight: 600; }
.entitlement-status {
  flex: 0 0 auto; margin-left: auto; white-space: nowrap;
  font: 600 .64rem var(--pk-mono); letter-spacing: .03em; text-transform: uppercase; color: var(--pk-muted);
}
.entitlement-desc {
  flex-basis: 100%; margin: 0.1rem 0 0 1.55rem;
  font: .8rem/1.45 var(--pk-sans); color: var(--pk-muted);
}
/* Quiet Save: the estate's secondary button shape, not the heavy accent block —
   saving an admin's tweak shouldn't shout. */
.entitlement-save { margin-top: 0.7rem; }

/* Invite form: comped-feature choices reuse the entitlement title/description
   pairing so the invitee's comps read the same as the admin page. */
.entitlement-choices { display: flex; flex-direction: column; gap: 0.7rem; margin: 0.6rem 0 0; }
.entitlement-choice {
  display: flex; align-items: baseline; gap: 0.5rem;
  font: .9rem var(--pk-sans); text-transform: none; letter-spacing: normal; color: var(--pk-text);
  cursor: pointer;
}
.entitlement-choice input[type="checkbox"] { flex: 0 0 auto; margin: 0.15rem 0 0; }
.entitlement-choice-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.entitlement-choice .entitlement-desc { flex-basis: auto; margin: 0; }
